glyphcss 0.0.2 → 0.0.4

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/elements.js CHANGED
@@ -1,6 +1,6 @@
1
- function ze(n,t,e){let o=Math.cos(t),r=Math.sin(t),a=o*n[1]-r*n[0],i=r*n[1]+o*n[0],s=n[2],c=Math.cos(e),l=Math.sin(e),p=c*i-l*s,h=l*i+c*s;return[a,p,h]}function ee(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,zoom:n.zoom??.4,stretch:n.stretch??1,target:[0,0,0],eyeMode:!1,focal:5},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},project(r,a,i,s){let c=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],l=ze(c,t.rotY,t.rotX);if(t.eyeMode){if(l[2]>=-.001)return[NaN,NaN,l[2]];let C=t.focal/-l[2],d=Math.min(a,i)*t.zoom*C,b=a*e+l[0]*d*s*t.stretch,u=i*o+l[1]*d;return[b,u,l[2]]}let p=30,h=1.5,f=l[2]*p,y=.001,g=1-f/t.distance;if(g<y)return[NaN,NaN,l[2]];let L=1/g,E=Math.min(a,i)*t.zoom*h*L,w=a*e+l[0]*E*s*t.stretch,x=i*o+l[1]*E;return[w,x,l[2]]}}}function Te(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,zoom:n.zoom??.4,stretch:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},project(r,a,i,s){let c=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],l=ze(c,t.rotY,t.rotX),h=Math.min(a,i)*t.zoom*1.5,f=a*e+l[0]*h*s*t.stretch,y=i*o+l[1]*h;return[f,y,l[2]]}}}var Qe={direction:[.5,.7,.5],intensity:1},et={intensity:.4};function tt(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let a=0;a<r.length;a++){let i=r[a],s=r[(a+1)%r.length],c=`${i[0]},${i[1]},${i[2]}`,l=`${s[0]},${s[1]},${s[2]}`,p=c<l?`${c}|${l}`:`${l}|${c}`;if(t.has(p))continue;t.add(p);let h={from:i,to:s,weight:2};o.color&&(h.color=o.color),e.push(h)}}return e}function He(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?tt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??Qe,ambientLight:n.ambientLight??et,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60}}var It=" .:-=+*#%@".split(""),Nt=" .:-=+*#%@".split(""),be={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Yt=be.default;function ve(n){return be[n]??be.default}function Pe(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:a,rows:i,cellAspect:s}=e;if(r==="solid")return nt(n,a,i,s);let c=ve(n.glyphPalette),l=new Uint8Array(a*i),p=n.useColors?new Array(a*i).fill(null):null;for(let h of o){let f=t.project(h.from,a,i,s),y=t.project(h.to,a,i,s);f[0]!==f[0]||y[0]!==y[0]||lt(l,p,f[0]|0,f[1]|0,y[0]|0,y[1]|0,h.weight??2,h.color??null,a,i)}return at(l,p,a,i,c)}function nt(n,t,e,o){let{camera:r,polygons:a,directionalLight:i,ambientLight:s,smoothShading:c,creaseAngle:l}=n,p=ve(n.glyphPalette).solid,h=p.length-1,f=new Array(t*e).fill(" "),y=n.useColors,g=y?new Array(t*e).fill(null):null,L=new Float64Array(t*e).fill(-1/0),E=i.direction,w=Math.hypot(E[0],E[1],E[2])||1,x=E[0]/w,M=E[1]/w,C=E[2]/w,d=i.intensity??1,b=s.intensity??.4,u=Ee(i.color??"#ffffff"),v=Ee(s.color??"#ffffff"),A=c&&l>0?it(a,l):null;for(let G=0;G<a.length;G++){let m=a[G],_=m.vertices;if(!(_.length<3))for(let S=1;S<_.length-1;S++){let z=S,I=S+1,H=_[0],P=_[z],N=_[I],O=r.project(H,t,e,o),R=r.project(P,t,e,o),Y=r.project(N,t,e,o);if(O[0]!==O[0]||R[0]!==R[0]||Y[0]!==Y[0])continue;let X=P[0]-H[0],B=P[1]-H[1],le=P[2]-H[2],W=N[0]-H[0],F=N[1]-H[1],J=N[2]-H[2],Q=B*J-le*F,j=le*W-X*J,xe=X*F-B*W,ae=Math.hypot(Q,j,xe)||1,De=Q/ae,Ve=j/ae,Be=xe/ae,ce,ue,de,he,pe,me,fe,ye,ge;if(A){let U=A[G],D=U[0],V=U[z],q=U[I];ce=D[0],ue=D[1],de=D[2],he=V[0],pe=V[1],me=V[2],fe=q[0],ye=q[1],ge=q[2]}else ce=he=fe=De,ue=pe=ye=Ve,de=me=ge=Be;let $e=ce*x+ue*M+de*C,We=he*x+pe*M+me*C,je=fe*x+ye*M+ge*C,Le=Math.min(1,b+Math.max(0,$e)*d),we=Math.min(1,b+Math.max(0,We)*d),_e=Math.min(1,b+Math.max(0,je)*d),Se=null;if(y){let U=(Le+we+_e)/3,D=Math.max(0,U-b),V=m.color?Ee(m.color):[255,255,255],q=b*v[0]/255+D*u[0]/255,Ue=b*v[1]/255+D*u[1]/255,qe=b*v[2]/255+D*u[2]/255,Ze=Math.min(255,V[0]*q),Ke=Math.min(255,V[1]*Ue),Je=Math.min(255,V[2]*qe);Se=`#${Me(Ze)}${Me(Ke)}${Me(Je)}`}ot(O[0],O[1],O[2],Le,R[0],R[1],R[2],we,Y[0],Y[1],Y[2],_e,p,h,Se,f,g,L,t,e)}}return st(f,g,t,e)}var rt=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]);function ot(n,t,e,o,r,a,i,s,c,l,p,h,f,y,g,L,E,w,x,M){let C=(r-n)*(l-t)-(a-t)*(c-n);if(C===0||C>0)return;let d=1/C,b=C>0,u=n<r?n:r;c<u&&(u=c);let v=n>r?n:r;c>v&&(v=c);let A=t<a?t:a;l<A&&(A=l);let G=t>a?t:a;l>G&&(G=l);let m=Math.max(0,Math.ceil(u)),_=Math.min(x-1,Math.floor(v)),S=Math.max(0,Math.ceil(A)),T=Math.min(M-1,Math.floor(G));if(!(m>_||S>T))for(let z=S;z<=T;z++){let I=z;for(let H=m;H<=_;H++){let P=H,N=(r-P)*(l-I)-(a-I)*(c-P),O=(c-P)*(t-I)-(l-I)*(n-P),R=(n-P)*(a-I)-(t-I)*(r-P);if(b?N<0||O<0||R<0:N>0||O>0||R>0)continue;let Y=(N*e+O*i+R*p)*d,X=z*x+H;if(Y>w[X]){w[X]=Y;let B=(N*o+O*s+R*h)*d,W=(B<0?0:B>1?1:B)*y,F=W|0,J=W-F,Q=rt[(z&3)*4+(H&3)],j=J>Q&&F<y?F+1:F;L[X]=f[j>y?y:j],E&&(E[X]=g)}}}}function it(n,t){let e=n.length,o=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices;if(c.length<3){o[s]=[0,0,0];continue}let l=c[0],p=c[1],h=c[2],f=p[0]-l[0],y=p[1]-l[1],g=p[2]-l[2],L=h[0]-l[0],E=h[1]-l[1],w=h[2]-l[2],x=y*w-g*E,M=g*L-f*w,C=f*E-y*L,d=Math.hypot(x,M,C)||1;o[s]=[x/d,M/d,C/d]}let r=new Map;for(let s=0;s<e;s++){let c=n[s].vertices;for(let l=0;l<c.length;l++){let p=c[l],h=`${p[0]},${p[1]},${p[2]}`,f=r.get(h);f||(f=[],r.set(h,f)),(f.length===0||f[f.length-1]!==s)&&f.push(s)}}let a=Math.cos(t*Math.PI/180),i=new Array(e);for(let s=0;s<e;s++){let c=n[s].vertices,l=o[s],p=new Array(c.length);for(let h=0;h<c.length;h++){let f=c[h],y=r.get(`${f[0]},${f[1]},${f[2]}`),g=0,L=0,E=0;for(let x=0;x<y.length;x++){let M=y[x],C=o[M];l[0]*C[0]+l[1]*C[1]+l[2]*C[2]>=a&&(g+=C[0],L+=C[1],E+=C[2])}let w=Math.hypot(g,L,E)||1;p[h]=[g/w,L/w,E/w]}i[s]=p}return i}function st(n,t,e,o){let r=[],a=null,i="",s=()=>{i&&(a!==null?r.push(`<span style="color:${a}">${i}</span>`):r.push(i),i="")};for(let c=0;c<o;c++){for(let l=0;l<e;l++){let p=c*e+l,h=n[p],f=t&&h!==" "?t[p]??null:null;f!==a&&(s(),a=f),i+=h}s(),a=null,c<o-1&&r.push(`
2
- `)}return r.join("")}function lt(n,t,e,o,r,a,i,s,c,l){let p=Math.abs(r-e),h=-Math.abs(a-o),f=e<r?1:-1,y=o<a?1:-1,g=p+h;for(;;){if(e>=0&&e<c&&o>=0&&o<l){let E=o*c+e;n[E]<i&&(n[E]=i,t&&(t[E]=s))}if(e===r&&o===a)break;let L=2*g;L>=h&&(g+=h,e+=f),L<=p&&(g+=p,o+=y)}}function at(n,t,e,o,r){let a=[],i=null,s="",c=()=>{s&&(i!==null?a.push(`<span style="color:${i}">${s}</span>`):a.push(s),s="")};for(let l=0;l<o;l++){for(let p=0;p<e;p++){let h=l*e+p,f=n[h],y,g;f===0?(y=" ",g=null):(y=f===1?r.thin[Math.random()*r.thin.length|0]:f===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],g=t?t[h]??null:null),g!==i&&(c(),i=g),s+=y}c(),i=null,l<o-1&&a.push(`
3
- `)}return a.join("")}function Ee(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function Me(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Oe="glyph-styles";function Re(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Oe))return;let e=t.createElement("style");e.id=Oe,e.textContent=ct,t.head.appendChild(e)}var ct=`
1
+ var et=Math.PI/180;function tt(n,t,e){let i=n[1],r=n[0],s=n[2],l=e*et,o=Math.cos(l),c=Math.sin(l),u=i*o-r*c,d=i*c+r*o,a=s,f=t*et,v=Math.cos(f),g=Math.sin(f),w=d*v-a*g,x=d*g+a*v;return[u,w,x]}function Ae(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:n.distance??6,zoom:n.zoom??.65,stretch:n.stretch??1,target:[0,0,0],eyeMode:!1,focal:1},[e,i]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},project(r,s,l,o){let u=50/o,d=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],a=tt(d,t.rotX,t.rotY);if(t.eyeMode){if(a[2]>=-.001)return[NaN,NaN,a[2]];let y=t.focal/-a[2],E=a[0]*y*t.zoom*50,L=a[1]*y*t.zoom*50,p=s*e+E/u*t.stretch,m=l*i+L/50;return[p,m,a[2]]}let f=.001,v=t.distance-a[2];if(v<f)return[NaN,NaN,a[2]];let g=t.distance/v,w=a[0]*g*t.zoom*50,x=a[1]*g*t.zoom*50,_=s*e+w/u*t.stretch,G=l*i+x/50;return[_,G,a[2]]}}}function nt(n={}){let t={rotX:n.rotX??65,rotY:n.rotY??45,distance:0,zoom:n.zoom??.65,stretch:1,target:[0,0,0]},[e,i]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},project(r,s,l,o){let u=50/o,d=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],a=tt(d,t.rotX,t.rotY),f=a[0]*t.zoom*50,v=a[1]*t.zoom*50,g=s*e+f/u,w=l*i+v/50;return[g,w,a[2]]}}}var St={direction:[-.5,-.7,-.5],intensity:1},Gt={intensity:.4};function Lt(n){let t=new Set,e=[];for(let i of n){let r=i.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let l=r[s],o=r[(s+1)%r.length],c=`${l[0]},${l[1]},${l[2]}`,u=`${o[0]},${o[1]},${o[2]}`,d=c<u?`${c}|${u}`:`${u}|${c}`;if(t.has(d))continue;t.add(d);let a={from:l,to:o,weight:2};i.color&&(a.color=i.color),e.push(a)}}return e}function rt(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),i=n.wireframe??(e==="wireframe"?Lt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:i,mode:e,directionalLight:n.directionalLight??St,ambientLight:n.ambientLight??Gt,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,shadow:n.shadow,castShadowFlags:n.castShadowFlags??[],receiveShadowFlags:n.receiveShadowFlags??[]}}var pn=" .:-=+*#%@".split(""),fn=" .:-=+*#%@".split(""),Ve={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},gn=Ve.default;function $e(n){return Ve[n]??Ve.default}function it(n){let{camera:t,grid:e,wireframe:i,mode:r}=n,{cols:s,rows:l,cellAspect:o}=e;if(r==="solid")return _t(n,s,l,o);let c=$e(n.glyphPalette),u=new Uint8Array(s*l),d=n.useColors?new Array(s*l).fill(null):null;for(let a of i){let f=t.project(a.from,s,l,o),v=t.project(a.to,s,l,o);f[0]!==f[0]||v[0]!==v[0]||Rt(u,d,f[0]|0,f[1]|0,v[0]|0,v[1]|0,a.weight??2,a.color??null,s,l)}return kt(u,d,s,l,c)}function _t(n,t,e,i){let{camera:r,polygons:s,directionalLight:l,ambientLight:o,smoothShading:c,creaseAngle:u,castShadowFlags:d,receiveShadowFlags:a}=n,f=$e(n.glyphPalette).solid,v=f.length-1,g=new Array(t*e).fill(" "),w=n.useColors,x=w?new Array(t*e).fill(null):null,_=new Float64Array(t*e).fill(-1/0),G=l.direction,z=Math.hypot(G[0],G[1],G[2])||1,y=G[0]/z,E=G[1]/z,L=G[2]/z,p=l.intensity??1,m=o.intensity??.4,b=ve(l.color??"#ffffff"),A=ve(o.color??"#ffffff"),h=c&&u>0?Ot(s,u):null,C=new Map,S=n.shadow,H=S!=null&&d.length>0?Ht(s,d,y,E,L):null,T=S?.opacity??.25,I=S?.lift??.05,R=S?.color??"#000000",q=H?ve(R):[0,0,0],P=globalThis.__glyphPerfDetail,U=P?performance.now():0,B=[],O=n.shadeCache??null,k=-1;for(let re=0;re<s.length;re++){let fe=s[re],Y=fe.vertices;if(!(Y.length<3)){for(let N=0;N<Y.length;N++)B[N]=r.project(Y[N],t,e,i);for(let N=1;N<Y.length-1;N++){k++;let ge=0,D=N,K=N+1,Z=Y[ge],oe=Y[D],ie=Y[K],F=B[ge],X=B[D],V=B[K];if(F[0]!==F[0]||X[0]!==X[0]||V[0]!==V[0]||(X[0]-F[0])*(V[1]-F[1])-(X[1]-F[1])*(V[0]-F[0])>0)continue;let $,J,Q,se=null;if(O!==null&&O.iA[k]!==void 0)$=O.iA[k],J=O.iB[k],Q=O.iC[k],se=O.lit[k];else{let M=oe[0]-Z[0],le=oe[1]-Z[1],ae=oe[2]-Z[2],ce=ie[0]-Z[0],qe=ie[1]-Z[1],Ue=ie[2]-Z[2],Ke=le*Ue-ae*qe,Ze=ae*ce-M*Ue,Je=M*qe-le*ce,Pe=Math.hypot(Ke,Ze,Je)||1,pt=Ke/Pe,ft=Ze/Pe,gt=Je/Pe,Oe,Ie,Re,ke,Fe,Be,Ye,Ne,Xe;if(h){let ye=h[re],ee=ye[ge],ue=ye[D],be=ye[K];Oe=ee[0],Ie=ee[1],Re=ee[2],ke=ue[0],Fe=ue[1],Be=ue[2],Ye=be[0],Ne=be[1],Xe=be[2]}else Oe=ke=Ye=pt,Ie=Fe=Ne=ft,Re=Be=Xe=gt;let yt=Math.max(0,-(Oe*y+Ie*E+Re*L)),bt=Math.max(0,-(ke*y+Fe*E+Be*L)),vt=Math.max(0,-(Ye*y+Ne*E+Xe*L));if($=Math.min(1,m+yt*p),J=Math.min(1,m+bt*p),Q=Math.min(1,m+vt*p),w){let ye=($+J+Q)/3,ee=Math.max(0,ye-m),ue=fe.color??"#ffffff",be=ee*255|0,Qe=`${ue}:${be}`,Ce=C.get(Qe);if(Ce===void 0){let De=ve(ue),Et=m*A[0]/255+ee*b[0]/255,wt=m*A[1]/255+ee*b[1]/255,Ct=m*A[2]/255+ee*b[2]/255,At=Math.min(255,De[0]*Et),Mt=Math.min(255,De[1]*wt),xt=Math.min(255,De[2]*Ct);Ce=`#${he(At)}${he(Mt)}${he(xt)}`,C.set(Qe,Ce)}se=Ce}O!==null&&(O.iA[k]=$,O.iB[k]=J,O.iC[k]=Q,O.lit[k]=se)}let He=a[re]??!1,we=null;if(H!==null&&He){let M=H,le=de(Z,M.right[0],M.right[1],M.right[2],M.up[0],M.up[1],M.up[2],M.dir[0],M.dir[1],M.dir[2],M.uMin,M.uMax,M.vMin,M.vMax),ae=de(oe,M.right[0],M.right[1],M.right[2],M.up[0],M.up[1],M.up[2],M.dir[0],M.dir[1],M.dir[2],M.uMin,M.uMax,M.vMin,M.vMax),ce=de(ie,M.right[0],M.right[1],M.right[2],M.up[0],M.up[1],M.up[2],M.dir[0],M.dir[1],M.dir[2],M.uMin,M.uMax,M.vMin,M.vMax);we={map:M,luA:le[0],lvA:le[1],ldA:le[2],luB:ae[0],lvB:ae[1],ldB:ae[2],luC:ce[0],lvC:ce[1],ldC:ce[2],lift:I,opacity:T,shadowColorRgb:q,shadowColorHex:R,litCache:C}}Pt(F[0],F[1],F[2],$,X[0],X[1],X[2],J,V[0],V[1],V[2],Q,f,v,se,g,x,_,t,e,we)}}}P&&(P.loop??(P.loop=[])).push(performance.now()-U);let ne=P?performance.now():0,pe=It(g,x,t,e);return P&&(P.string??(P.string=[])).push(performance.now()-ne),pe}var Tt=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),W=256;function de(n,t,e,i,r,s,l,o,c,u,d,a,f,v){let g=t*n[0]+e*n[1]+i*n[2],w=r*n[0]+s*n[1]+l*n[2],x=-(o*n[0]+c*n[1]+u*n[2]),_=(g-d)/(a-d)*(W-1),G=(w-f)/(v-f)*(W-1);return[_,G,x]}function zt(n,t,e,i){let r=t[0],s=t[1],l=t[2],o=e[0],c=e[1],u=e[2],d=i[0],a=i[1],f=i[2],v=(o-r)*(a-s)-(c-s)*(d-r);if(v===0)return;let g=1/v,w=r<o?r:o;d<w&&(w=d);let x=r>o?r:o;d>x&&(x=d);let _=s<c?s:c;a<_&&(_=a);let G=s>c?s:c;a>G&&(G=a);let z=Math.max(0,Math.ceil(w)),y=Math.min(W-1,Math.floor(x)),E=Math.max(0,Math.ceil(_)),L=Math.min(W-1,Math.floor(G));if(z>y||E>L)return;let p=v>0;for(let m=E;m<=L;m++)for(let b=z;b<=y;b++){let A=b,h=m,C=(o-A)*(a-h)-(c-h)*(d-A),S=(d-A)*(s-h)-(a-h)*(r-A),H=(r-A)*(c-h)-(s-h)*(o-A);if(p?C<0||S<0||H<0:C>0||S>0||H>0)continue;let T=(C*l+S*u+H*f)*g,I=m*W+b;T>n[I]&&(n[I]=T)}}function Ht(n,t,e,i,r){let s,l,o;Math.abs(e)<.9?(s=0,l=r,o=-i):(s=-r,l=0,o=e);let c=Math.hypot(s,l,o);s/=c,l/=c,o/=c;let u=l*r-o*i,d=o*e-s*r,a=s*i-l*e,f=1/0,v=-1/0,g=1/0,w=-1/0,x=!1;for(let y=0;y<n.length;y++)if(t[y]){x=!0;for(let E of n[y].vertices){let L=s*E[0]+l*E[1]+o*E[2],p=u*E[0]+d*E[1]+a*E[2];L<f&&(f=L),L>v&&(v=L),p<g&&(g=p),p>w&&(w=p)}}if(!x)return null;let _=(v-f)*.05+.01,G=(w-g)*.05+.01;f-=_,v+=_,g-=G,w+=G;let z=new Float64Array(W*W).fill(-1/0);for(let y=0;y<n.length;y++){if(!t[y])continue;let E=n[y].vertices;if(!(E.length<3))for(let L=1;L<E.length-1;L++){let p=E[0],m=E[L],b=E[L+1],A=de(p,s,l,o,u,d,a,e,i,r,f,v,g,w),h=de(m,s,l,o,u,d,a,e,i,r,f,v,g,w),C=de(b,s,l,o,u,d,a,e,i,r,f,v,g,w);zt(z,A,h,C)}}return{buf:z,right:[s,l,o],up:[u,d,a],dir:[e,i,r],uMin:f,uMax:v,vMin:g,vMax:w}}function Pt(n,t,e,i,r,s,l,o,c,u,d,a,f,v,g,w,x,_,G,z,y){let E=(r-n)*(u-t)-(s-t)*(c-n);if(E===0||E>0)return;let L=1/E,p=E>0,m=n<r?n:r;c<m&&(m=c);let b=n>r?n:r;c>b&&(b=c);let A=t<s?t:s;u<A&&(A=u);let h=t>s?t:s;u>h&&(h=u);let C=Math.max(0,Math.ceil(m)),S=Math.min(G-1,Math.floor(b)),H=Math.max(0,Math.ceil(A)),T=Math.min(z-1,Math.floor(h));if(!(C>S||H>T))for(let I=H;I<=T;I++){let R=I;for(let q=C;q<=S;q++){let P=q,U=(r-P)*(u-R)-(s-R)*(c-P),B=(c-P)*(t-R)-(u-R)*(n-P),O=(n-P)*(s-R)-(t-R)*(r-P);if(p?U<0||B<0||O<0:U>0||B>0||O>0)continue;let k=(U*e+B*l+O*d)*L,ne=I*G+q;if(k>_[ne]){_[ne]=k;let pe=(U*i+B*o+O*a)*L,fe=(pe<0?0:pe>1?1:pe)*v,Y=fe|0,N=fe-Y,ge=Tt[(I&3)*4+(q&3)],D=N>ge&&Y<v?Y+1:Y;D>v&&(D=v);let K=g;if(y!==null){let Z=(U*y.luA+B*y.luB+O*y.luC)*L,oe=(U*y.lvA+B*y.lvB+O*y.lvC)*L,ie=(U*y.ldA+B*y.ldB+O*y.ldC)*L,F=Z|0,X=oe|0;if(F>=0&&F<W&&X>=0&&X<W){let V=y.map.buf[X*W+F];if(V>-1/0&&ie+y.lift<V&&(D=Math.max(0,D-Math.round(y.opacity*v)),K!==null)){let ze=`shadow:${K}:${D}`,$=y.litCache.get(ze);if($===void 0){let J=ve(K),Q=y.shadowColorRgb,se=Math.round(J[0]*(1-y.opacity)+Q[0]*y.opacity),He=Math.round(J[1]*(1-y.opacity)+Q[1]*y.opacity),we=Math.round(J[2]*(1-y.opacity)+Q[2]*y.opacity);$=`#${he(se)}${he(He)}${he(we)}`,y.litCache.set(ze,$)}K=$}}}w[ne]=f[D],x&&(x[ne]=K)}}}}function Ot(n,t){let e=n.length,i=new Array(e);for(let o=0;o<e;o++){let c=n[o].vertices;if(c.length<3){i[o]=[0,0,0];continue}let u=c[0],d=c[1],a=c[2],f=d[0]-u[0],v=d[1]-u[1],g=d[2]-u[2],w=a[0]-u[0],x=a[1]-u[1],_=a[2]-u[2],G=v*_-g*x,z=g*w-f*_,y=f*x-v*w,E=Math.hypot(G,z,y)||1;i[o]=[G/E,z/E,y/E]}let r=new Map;for(let o=0;o<e;o++){let c=n[o].vertices;for(let u=0;u<c.length;u++){let d=c[u],a=`${d[0]},${d[1]},${d[2]}`,f=r.get(a);f||(f=[],r.set(a,f)),(f.length===0||f[f.length-1]!==o)&&f.push(o)}}let s=Math.cos(t*Math.PI/180),l=new Array(e);for(let o=0;o<e;o++){let c=n[o].vertices,u=i[o],d=new Array(c.length);for(let a=0;a<c.length;a++){let f=c[a],v=r.get(`${f[0]},${f[1]},${f[2]}`),g=0,w=0,x=0;for(let G=0;G<v.length;G++){let z=v[G],y=i[z];u[0]*y[0]+u[1]*y[1]+u[2]*y[2]>=s&&(g+=y[0],w+=y[1],x+=y[2])}let _=Math.hypot(g,w,x)||1;d[a]=[g/_,w/_,x/_]}l[o]=d}return l}function It(n,t,e,i){let r=[],s=null,l="",o=()=>{l&&(s!==null?r.push(`<span style="color:${s}">${l}</span>`):r.push(l),l="")};for(let c=0;c<i;c++){for(let u=0;u<e;u++){let d=c*e+u,a=n[d],f=t&&a!==" "?t[d]??null:null;f!==s&&(o(),s=f),l+=a}o(),s=null,c<i-1&&r.push(`
2
+ `)}return r.join("")}function Rt(n,t,e,i,r,s,l,o,c,u){let d=Math.abs(r-e),a=-Math.abs(s-i),f=e<r?1:-1,v=i<s?1:-1,g=d+a;for(;;){if(e>=0&&e<c&&i>=0&&i<u){let x=i*c+e;n[x]<l&&(n[x]=l,t&&(t[x]=o))}if(e===r&&i===s)break;let w=2*g;w>=a&&(g+=a,e+=f),w<=d&&(g+=d,i+=v)}}function kt(n,t,e,i,r){let s=[],l=null,o="",c=()=>{o&&(l!==null?s.push(`<span style="color:${l}">${o}</span>`):s.push(o),o="")};for(let u=0;u<i;u++){for(let d=0;d<e;d++){let a=u*e+d,f=n[a],v,g;f===0?(v=" ",g=null):(v=f===1?r.thin[Math.random()*r.thin.length|0]:f===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],g=t?t[a]??null:null),g!==l&&(c(),l=g),o+=v}c(),l=null,u<i-1&&s.push(`
3
+ `)}return s.join("")}var ot=new Map;function ve(n){let t=ot.get(n);if(t!==void 0)return t;let e=Ft(n);return ot.set(n,e),e}function Ft(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),i=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,i||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),i=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,i||0,r||0]}return[255,255,255]}function he(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var st="glyph-styles";function lt(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(st))return;let e=t.createElement("style");e.id=st,e.textContent=Bt,t.head.appendChild(e)}var Bt=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5
5
 
6
6
  .glyph-host {
@@ -59,4 +59,5 @@ function ze(n,t,e){let o=Math.cos(t),r=Math.sin(t),a=o*n[1]-r*n[0],i=r*n[1]+o*n[
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function ke(n,t,e,o,r){return n.map(a=>{let[i,s,c]=t.project(a.at,e,o,r),l=c>-3&&i>=0&&i<e&&s>=0&&s<o;return{id:a.id,col:i,row:s,depth:c,visible:l}})}var ut=1;function dt(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[a,i,s]=e??[0,0,0],c=1,l=1,p=1;o!==void 0&&(typeof o=="number"?c=l=p=o:[c,l,p]=o);let[h,f,y]=r??[0,0,0],g=Math.cos(h),L=Math.sin(h),E=Math.cos(f),w=Math.sin(f),x=Math.cos(y),M=Math.sin(y);function C(d){let b=d[0]*c,u=d[1]*l,v=d[2]*p,A=x*b-M*u,G=M*b+x*u,m=v;return b=E*A+w*m,u=G,v=-w*A+E*m,A=b,G=g*u-L*v,m=L*u+g*v,[A+a,G+i,m+s]}return n.map(d=>({...d,vertices:d.vertices.map(C)}))}function Ie(n,t={}){Re(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[.5,.7,.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??ee(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,autoSize:t.autoSize??!1},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let a=n.ownerDocument.createElement("div");a.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(a),n.appendChild(o);let i=new Map,s=[],c=!1;function l(){c||(c=!0,Promise.resolve().then(()=>{c=!1,p()}))}function p(){let d=[];for(let v of i.values()){let A=dt(v.polygons,v.transform);for(let G of A)d.push(G)}let b=He({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:d,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle}),u=Pe(b);e.useColors?r.innerHTML=u:r.textContent=u,h()}function h(){let{cols:d,rows:b,cellAspect:u,camera:v}=e,A=ke(s.map(S=>S.hotspot),v,d,b,u),G=r.getBoundingClientRect(),m=d>0?G.width/d:8,_=b>0?G.height/b:16;for(let S=0;S<s.length;S++){let{el:T}=s[S],z=A[S];z.visible?(T.style.display="",T.style.left=`${(z.col+.5)*m}px`,T.style.top=`${(z.row+.5)*_}px`,T.style.zIndex=String(Math.round(z.depth*1e3))):T.style.display="none"}}function f(d,b={}){let u=ut++;return i.set(u,{id:u,polygons:d,transform:b}),l(),{get id(){return u},get name(){return i.get(u)?.transform.id},get polygons(){return d},setTransform(v){let A=i.get(u);A&&(A.transform=v,l())},dispose(){i.delete(u),l()}}}function y(d,b){let u=n.ownerDocument.createElement("div");u.className="glyph-hotspot",u.setAttribute("data-hotspot-id",d.id);let[v,A]=d.size??[1,1];u.style.position="absolute",u.style.width=`${v}ch`,u.style.height=`${A*e.cellAspect}ch`,b&&u.addEventListener("click",b),a.appendChild(u);let G={hotspot:{id:d.id,at:d.at,size:d.size},el:u,onClick:b};return s.push(G),l(),{get el(){return u},remove(){let m=s.indexOf(G);m>=0&&s.splice(m,1),b&&u.removeEventListener("click",b),a.removeChild(u),l()}}}function g(){p()}function L(d){d.mode!==void 0&&(e.mode=d.mode),d.glyphPalette!==void 0&&(e.glyphPalette=d.glyphPalette),d.useColors!==void 0&&(e.useColors=d.useColors),d.cols!==void 0&&(e.cols=d.cols),d.rows!==void 0&&(e.rows=d.rows),d.cellAspect!==void 0&&(e.cellAspect=d.cellAspect),d.directionalLight!==void 0&&(e.directionalLight=d.directionalLight),d.ambientLight!==void 0&&(e.ambientLight=d.ambientLight),d.camera!==void 0&&(e.camera=d.camera),d.smoothShading!==void 0&&(e.smoothShading=d.smoothShading),d.creaseAngle!==void 0&&(e.creaseAngle=d.creaseAngle),d.autoSize!==void 0&&(e.autoSize=d.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>x()),M.observe(n),x()):!e.autoSize&&M&&(M.disconnect(),M=null)),l()}function E(){return{...e}}function w(){let d=n.ownerDocument.createElement("span");d.textContent="M",d.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(d);let b=d.getBoundingClientRect();return d.remove(),{w:b.width||8,h:b.height||16}}function x(){let d=n.clientWidth,b=n.clientHeight;if(!d||!b)return;let u=w(),v=Math.max(20,Math.floor(d/u.w)),A=Math.max(8,Math.floor(b/u.h)),G=u.h/u.w,m=!1;e.cols!==v&&(e.cols=v,m=!0),e.rows!==A&&(e.rows=A,m=!0),Math.abs(e.cellAspect-G)>.01&&(e.cellAspect=G,m=!0),m&&l()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>x()),M.observe(n),x());function C(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return l(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:f,addHotspot:y,rerender:g,setOptions:L,getOptions:E,fit:x,destroy:C}}var ht=typeof HTMLElement<"u"?HTMLElement:class{},pt=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size"];function Z(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function mt(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function ft(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var te=class extends ht{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...pt]}getScene(){return this._scene}_readOptions(){let e={},o=mt(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let a=ft(this.getAttribute("use-colors"));a!==void 0&&(e.useColors=a);let i=Z(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let s=Z(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=Z(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let l=Z(this.getAttribute("directional-intensity"));l!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:l});let p=Z(this.getAttribute("ambient-intensity"));return p!==void 0&&(e.ambientLight={intensity:p}),this.hasAttribute("auto-size")&&(e.autoSize=!0),e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=Ie(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-perspective-camera> or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as yt,resolveGeometry as gt,computeSceneBbox as bt}from"@glyphcss/core";var vt=typeof HTMLElement<"u"?HTMLElement:class{},Et=["src","geometry","size","color","position","scale","rotation","normalize"];function Mt(n){let t=bt(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,i=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(s=>({...s,vertices:s.vertices.map(c=>[(c[0]-e)*i,(c[1]-o)*i,(c[2]-r)*i])}))}function Ae(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function At(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Ae(n)}}function Ct(n){return n.closest("glyph-scene")??null}var ne=class extends vt{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Et]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Ae(this.getAttribute("position")),scale:At(this.getAttribute("scale")),rotation:Ae(this.getAttribute("rotation"))}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Ct(this);if(r){if(!r.getScene()){let a=()=>{r.removeEventListener("glyphcss:scene-ready",a),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",a);return}if(e){let a=++this._loadToken,i;try{i=await yt(e)}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}if(a!==this._loadToken){try{i.dispose()}catch{}return}let s=r.getScene();if(!s){try{i.dispose()}catch{}return}let l=this.hasAttribute("normalize")?Mt(i.polygons):i.polygons;this._handle=s.add(l,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:l},bubbles:!0}));return}if(o){let a=r.getScene();if(!a)return;let i=this.getAttribute("size"),s=i!==null?parseFloat(i):1,c=this.getAttribute("color")??void 0,l;try{l=gt(o,{size:Number.isFinite(s)?s:1,color:c})}catch(p){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:p,bubbles:!0}));return}this._handle=a.add(l,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:l},bubbles:!0}))}}}};var Gt=typeof HTMLElement<"u"?HTMLElement:class{};function xt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Lt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function wt(n){return n.closest("glyph-scene")??null}var re=class extends Gt{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=xt(this.getAttribute("at"));if(!e)return;let o=wt(this);if(!o)return;if(!o.getScene()){let c=()=>{o.removeEventListener("glyphcss:scene-ready",c),this._register()};o.addEventListener("glyphcss:scene-ready",c);return}let r=o.getScene();if(!r)return;let a=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Lt(this.getAttribute("size"));this._handle=r.addHotspot({id:a,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:a},bubbles:!0})));let s=this._handle.el;for(;this.firstChild;)s.appendChild(this.firstChild)}};var _t=typeof HTMLElement<"u"?HTMLElement:class{};function k(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var oe=class extends _t{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=ee({rotX:k(this.getAttribute("rot-x")),rotY:k(this.getAttribute("rot-y")),distance:k(this.getAttribute("distance")),zoom:k(this.getAttribute("zoom")),stretch:k(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let a=this._camera;if(!a)return;let i=k(this.getAttribute("rot-x")),s=k(this.getAttribute("rot-y")),c=k(this.getAttribute("distance")),l=k(this.getAttribute("zoom")),p=k(this.getAttribute("stretch")),h=!1;i!==void 0&&a.rotX!==i&&(a.rotX=i,h=!0),s!==void 0&&a.rotY!==s&&(a.rotY=s,h=!0),c!==void 0&&a.distance!==c&&(a.distance=c,h=!0),l!==void 0&&a.zoom!==l&&(a.zoom=l,h=!0),p!==void 0&&a.stretch!==p&&(a.stretch=p,h=!0),h&&this.querySelector("glyph-scene")?.rerender?.()}};var St=typeof HTMLElement<"u"?HTMLElement:class{};function $(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var K=class extends St{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Te({rotX:$(this.getAttribute("rot-x")),rotY:$(this.getAttribute("rot-y")),zoom:$(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let a=this._camera;if(!a)return;let i=$(this.getAttribute("rot-x")),s=$(this.getAttribute("rot-y")),c=$(this.getAttribute("zoom")),l=!1;i!==void 0&&a.rotX!==i&&(a.rotX=i,l=!0),s!==void 0&&a.rotY!==s&&(a.rotY=s,l=!0),c!==void 0&&a.zoom!==c&&(a.zoom=c,l=!0),l&&this.querySelector("glyph-scene")?.rerender?.()}};function Ye(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,a=Ne(t.invert),i=t.animate??!1,s=!1,c=!1,l=null,p=null,h=null,f={x:0,y:0},y=n.camera;function g(u){if(!(!o||s)&&h===null&&u.isPrimary!==!1){u.preventDefault(),h=u.pointerId,f={x:u.clientX,y:u.clientY},e.style.cursor="grabbing";try{u.target.setPointerCapture(u.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(c=!0)}}function L(u){if(h===null||u.pointerId!==h||!o||s)return;u.preventDefault();let v=u.clientX-f.x,A=u.clientY-f.y;f={x:u.clientX,y:u.clientY};let G=a,_=1/4*Math.PI/180;y.rotY=y.rotY-v*_*G,y.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,y.rotX-A*_*G)),n.rerender()}function E(u){if(h===u.pointerId){h=null,e.style.cursor=o&&!s?"grab":"";try{u.target.releasePointerCapture(u.pointerId)}catch{}i&&(c=!1)}}function w(u){if(!r||s)return;u.preventDefault();let v=u.deltaY*.001;y.zoom=Math.max(.05,Math.min(10,y.zoom*(1-v))),n.rerender()}function x(u){if(!(s||!i)){if(!c){let v=p!==null?Math.min(u-p,50):16.67,A=typeof i=="object"&&i.speed?i.speed:.3,G=typeof i=="object"&&i.axis?i.axis:"y",m=A*(Math.PI/180)*(v/16.67);G==="y"?y.rotY=y.rotY+m:y.rotX=y.rotX+m,n.rerender()}p=u,l=requestAnimationFrame(x)}}function M(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(x))}function C(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),p=null}function d(){e.addEventListener("pointerdown",g),e.addEventListener("pointermove",L),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),e.addEventListener("wheel",w,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function b(){e.removeEventListener("pointerdown",g),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.removeEventListener("wheel",w),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return d(),M(),{update(u){let v=!!i;o=u.drag??o,r=u.wheel??r,a=Ne(u.invert),i=u.animate??i,!s&&h===null&&(e.style.cursor=o?"grab":"");let A=!!i;v&&!A?C():!v&&A&&M()},pause(){s||(s=!0,b(),C(),h=null,c=!1)},resume(){s&&(s=!1,d(),M())},destroy(){s||b(),C(),s=!0}}}function Ne(n){return n===void 0||n===!1?1:n===!0?-1:n}var zt=typeof HTMLElement<"u"?HTMLElement:class{};function Tt(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ce(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Ht(n){return n.closest("glyph-scene")??null}var ie=class extends zt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Ce(this.getAttribute("drag")),o=Ce(this.getAttribute("wheel")),r=Ce(this.getAttribute("invert")),a=Tt(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...a!==void 0?{animate:{speed:a,axis:i}}:{}}}_attach(){if(this._controls)return;let e=Ht(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Ye(o,this._readOptions())}};function Fe(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,a=Xe(t.invert),i=t.animate??!1,s=!1,c=!1,l=null,p=null,h=null,f={x:0,y:0},y=!1,g=n.camera,L=1/4*Math.PI/180,E=.02;function w(m){if(!(!o||s)&&h===null&&m.isPrimary!==!1){m.preventDefault(),h=m.pointerId,f={x:m.clientX,y:m.clientY},y=m.button===2,e.style.cursor="grabbing";try{m.target.setPointerCapture(m.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(c=!0)}}function x(m){if(h===null||m.pointerId!==h||!o||s)return;m.preventDefault();let _=m.clientX-f.x,S=m.clientY-f.y;f={x:m.clientX,y:m.clientY};let T=a;if(y||m.shiftKey)g.rotY=g.rotY-_*L*T,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+S*L*T));else{let z=g.target;g.target=[z[0]-_*E/g.zoom,z[1]-S*E/g.zoom,z[2]]}n.rerender()}function M(m){if(h===m.pointerId){h=null,y=!1,e.style.cursor=o&&!s?"grab":"";try{m.target.releasePointerCapture(m.pointerId)}catch{}i&&(c=!1)}}function C(m){m.preventDefault()}function d(m){if(!r||s)return;m.preventDefault();let _=m.deltaY*.001;g.zoom=Math.max(.05,Math.min(10,g.zoom*(1-_))),n.rerender()}function b(m){if(!(s||!i)){if(!c){let _=p!==null?Math.min(m-p,50):16.67,S=typeof i=="object"&&i.speed?i.speed:.3,T=typeof i=="object"&&i.axis?i.axis:"y",z=S*(Math.PI/180)*(_/16.67);T==="y"?g.rotY=g.rotY+z:g.rotX=g.rotX+z,n.rerender()}p=m,l=requestAnimationFrame(b)}}function u(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(b))}function v(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),p=null}function A(){e.addEventListener("pointerdown",w),e.addEventListener("pointermove",x),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",C),e.addEventListener("wheel",d,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function G(){e.removeEventListener("pointerdown",w),e.removeEventListener("pointermove",x),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",C),e.removeEventListener("wheel",d),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),u(),{update(m){let _=!!i;o=m.drag??o,r=m.wheel??r,a=Xe(m.invert),i=m.animate??i,!s&&h===null&&(e.style.cursor=o?"grab":"");let S=!!i;_&&!S?v():!_&&S&&u()},pause(){s||(s=!0,G(),v(),h=null,c=!1)},resume(){s&&(s=!1,A(),u())},destroy(){s||G(),v(),s=!0}}}function Xe(n){return n===void 0||n===!1?1:n===!0?-1:n}var Pt=typeof HTMLElement<"u"?HTMLElement:class{};function Ge(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Ot(n){return n.closest("glyph-scene")??null}var se=class extends Pt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Ge(this.getAttribute("drag")),o=Ge(this.getAttribute("wheel")),r=Ge(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Ot(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Fe(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",te),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",ne),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",re),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",oe),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",K),!customElements.get("glyph-camera")){class n extends K{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",ie),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",se)}export{re as GlyphHotspotElement,se as GlyphMapControlsElement,ne as GlyphMeshElement,ie as GlyphOrbitControlsElement,K as GlyphOrthographicCameraElement,oe as GlyphPerspectiveCameraElement,te as GlyphSceneElement};
62
+ `;function at(n,t,e,i,r){return n.map(s=>{let[l,o,c]=t.project(s.at,e,i,r),u=c>-3&&l>=0&&l<e&&o>=0&&o<i;return{id:s.id,col:l,row:o,depth:c,visible:u}})}var Yt=1;function Nt(n,t){let{position:e,scale:i,rotation:r}=t;if(!e&&!i&&!r)return n;let[s,l,o]=e??[0,0,0],c=1,u=1,d=1;i!==void 0&&(typeof i=="number"?c=u=d=i:[c,u,d]=i);let a=Math.PI/180,[f,v,g]=r??[0,0,0],w=f*a,x=v*a,_=g*a,G=Math.cos(w),z=Math.sin(w),y=Math.cos(x),E=Math.sin(x),L=Math.cos(_),p=Math.sin(_);function m(b){let A=b[0]*c,h=b[1]*u,C=b[2]*d,S=L*A-p*h,H=p*A+L*h,T=C;return A=y*S+E*T,h=H,C=-E*S+y*T,S=A,H=G*h-z*C,T=z*h+G*C,[S+s,H+l,T+o]}return n.map(b=>({...b,vertices:b.vertices.map(m)}))}function ct(n,t={}){lt(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??Ae(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,autoSize:t.autoSize??!1,shadow:t.shadow},i=n.ownerDocument.createElement("div");i.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",i.appendChild(r),i.appendChild(s),n.appendChild(i);let l=new Map,o=[],c=!1,u={iA:[],iB:[],iC:[],lit:[]};function d(){u.iA.length=0,u.iB.length=0,u.iC.length=0,u.lit.length=0}function a(){c||(c=!0,Promise.resolve().then(()=>{c=!1,f()}))}function f(){let p=[],m=[],b=[];for(let T of l.values()){let I=Nt(T.polygons,T.transform),R=T.transform.castShadow??!1,q=T.transform.receiveShadow??!1;for(let P of I)p.push(P),m.push(R),b.push(q)}let A=rt({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:p,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,shadow:e.shadow,castShadowFlags:m,receiveShadowFlags:b});A.shadeCache=u;let h=globalThis.__glyphPerf,C=h?performance.now():0,S=it(A),H=h?performance.now():0;if(e.useColors?r.innerHTML=S:r.textContent=S,h){let T=performance.now();(h.raster??(h.raster=[])).push(H-C),(h.dom??(h.dom=[])).push(T-H),(h.polys??(h.polys=[])).push(p.length)}v()}function v(){let{cols:p,rows:m,cellAspect:b,camera:A}=e,h=at(o.map(T=>T.hotspot),A,p,m,b),C=r.getBoundingClientRect(),S=p>0?C.width/p:8,H=m>0?C.height/m:16;for(let T=0;T<o.length;T++){let{el:I}=o[T],R=h[T];R.visible?(I.style.display="",I.style.left=`${(R.col+.5)*S}px`,I.style.top=`${(R.row+.5)*H}px`,I.style.zIndex=String(Math.round(R.depth*1e3))):I.style.display="none"}}function g(p,m={}){let b=Yt++;return l.set(b,{id:b,polygons:p,transform:m}),d(),a(),{get id(){return b},get name(){return l.get(b)?.transform.id},get polygons(){return p},setTransform(A){let h=l.get(b);h&&(h.transform=A,d(),a())},dispose(){l.delete(b),d(),a()}}}function w(p,m){let b=n.ownerDocument.createElement("div");b.className="glyph-hotspot",b.setAttribute("data-hotspot-id",p.id);let[A,h]=p.size??[1,1];b.style.position="absolute",b.style.width=`${A}ch`,b.style.height=`${h*e.cellAspect}ch`,m&&b.addEventListener("click",m),s.appendChild(b);let C={hotspot:{id:p.id,at:p.at,size:p.size},el:b,onClick:m};return o.push(C),a(),{get el(){return b},remove(){let S=o.indexOf(C);S>=0&&o.splice(S,1),m&&b.removeEventListener("click",m),s.removeChild(b),a()}}}function x(){f()}function _(p){p.mode!==void 0&&(e.mode=p.mode),p.glyphPalette!==void 0&&(e.glyphPalette=p.glyphPalette),p.useColors!==void 0&&(e.useColors=p.useColors),p.cols!==void 0&&(e.cols=p.cols),p.rows!==void 0&&(e.rows=p.rows),p.cellAspect!==void 0&&(e.cellAspect=p.cellAspect),p.directionalLight!==void 0&&(e.directionalLight=p.directionalLight),p.ambientLight!==void 0&&(e.ambientLight=p.ambientLight),p.camera!==void 0&&(e.camera=p.camera),p.smoothShading!==void 0&&(e.smoothShading=p.smoothShading),p.creaseAngle!==void 0&&(e.creaseAngle=p.creaseAngle),"shadow"in p&&(e.shadow=p.shadow),p.autoSize!==void 0&&(e.autoSize=p.autoSize,e.autoSize&&!E&&typeof ResizeObserver<"u"?(E=new ResizeObserver(()=>y()),E.observe(n),y()):!e.autoSize&&E&&(E.disconnect(),E=null)),(p.mode!==void 0||p.useColors!==void 0||p.directionalLight!==void 0||p.ambientLight!==void 0||p.smoothShading!==void 0||p.creaseAngle!==void 0||p.glyphPalette!==void 0)&&d(),a()}function G(){return{...e}}function z(){let m=n.ownerDocument.createElement("span");m.textContent=Array(20).fill("M").join(`
63
+ `),m.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(m);let b=m.getBoundingClientRect();return m.remove(),{w:b.width||8,h:b.height?b.height/20:16}}function y(){let p=n.clientWidth,m=n.clientHeight;if(!p||!m)return;let b=z(),A=Math.max(20,Math.floor(p/b.w)),h=Math.max(8,Math.floor(m/b.h)),C=b.h/b.w,S=!1;e.cols!==A&&(e.cols=A,S=!0),e.rows!==h&&(e.rows=h,S=!0),Math.abs(e.cellAspect-C)>.01&&(e.cellAspect=C,S=!0),S&&a()}let E=null;e.autoSize&&typeof ResizeObserver<"u"&&(E=new ResizeObserver(()=>y()),E.observe(n),y());function L(){E&&(E.disconnect(),E=null),l.clear(),n.contains(i)&&n.removeChild(i)}return a(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:g,addHotspot:w,rerender:x,setOptions:_,getOptions:G,fit:y,destroy:L}}var Xt=typeof HTMLElement<"u"?HTMLElement:class{},Dt=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function te(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Vt(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function $t(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Me=class extends Xt{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Dt]}getScene(){return this._scene}_readOptions(){let e={},i=Vt(this.getAttribute("mode"));i!==void 0&&(e.mode=i);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=$t(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let l=te(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let o=te(this.getAttribute("rows"));o!==void 0&&(e.rows=o);let c=te(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let u=te(this.getAttribute("directional-intensity"));u!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:u});let d=te(this.getAttribute("ambient-intensity"));if(d!==void 0&&(e.ambientLight={intensity:d}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let a={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},f=this.getAttribute("shadow-color");f&&(a.color=f);let v=te(this.getAttribute("shadow-opacity"));v!==void 0&&(a.opacity=v);let g=te(this.getAttribute("shadow-lift"));g!==void 0&&(a.lift=g);let w=te(this.getAttribute("shadow-max-extend"));w!==void 0&&(a.maxExtend=w),e.shadow=a}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let i=e.tagName.toLowerCase();if(i==="glyph-perspective-camera"||i==="glyph-orthographic-camera"||i==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let i=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();i&&(r.camera=i),this._scene=ct(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,i,r){i!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Wt,resolveGeometry as jt,computeSceneBbox as qt}from"@glyphcss/core";var Ut=typeof HTMLElement<"u"?HTMLElement:class{},Kt=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function Zt(n){let t=qt(n),e=(t.min[0]+t.max[0])/2,i=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,l=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(o=>({...o,vertices:o.vertices.map(c=>[(c[0]-e)*l,(c[1]-i)*l,(c[2]-r)*l])}))}function We(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Jt(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return We(n)}}function Qt(n){return n.closest("glyph-scene")??null}var xe=class extends Ut{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Kt]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,i,r){if(i!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:We(this.getAttribute("position")),scale:Jt(this.getAttribute("scale")),rotation:We(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),i=this.getAttribute("geometry"),r=Qt(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,l;try{l=await Wt(e)}catch(d){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:d,bubbles:!0}));return}if(s!==this._loadToken){try{l.dispose()}catch{}return}let o=r.getScene();if(!o){try{l.dispose()}catch{}return}let u=this.hasAttribute("normalize")?Zt(l.polygons):l.polygons;this._handle=o.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}));return}if(i){let s=r.getScene();if(!s)return;let l=this.getAttribute("size"),o=l!==null?parseFloat(l):1,c=this.getAttribute("color")??void 0,u;try{u=jt(i,{size:Number.isFinite(o)?o:1,color:c})}catch(d){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:d,bubbles:!0}));return}this._handle=s.add(u,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:u},bubbles:!0}))}}}};var en=typeof HTMLElement<"u"?HTMLElement:class{};function tn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function nn(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function rn(n){return n.closest("glyph-scene")??null}var Se=class extends en{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,i,r){i!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=tn(this.getAttribute("at"));if(!e)return;let i=rn(this);if(!i)return;if(!i.getScene()){let c=()=>{i.removeEventListener("glyphcss:scene-ready",c),this._register()};i.addEventListener("glyphcss:scene-ready",c);return}let r=i.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=nn(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let o=this._handle.el;for(;this.firstChild;)o.appendChild(this.firstChild)}};var on=typeof HTMLElement<"u"?HTMLElement:class{};function j(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Ge=class extends on{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=Ae({rotX:j(this.getAttribute("rot-x")),rotY:j(this.getAttribute("rot-y")),distance:j(this.getAttribute("distance")),zoom:j(this.getAttribute("zoom")),stretch:j(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,i,r){if(i===r)return;let s=this._camera;if(!s)return;let l=j(this.getAttribute("rot-x")),o=j(this.getAttribute("rot-y")),c=j(this.getAttribute("distance")),u=j(this.getAttribute("zoom")),d=j(this.getAttribute("stretch")),a=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,a=!0),o!==void 0&&s.rotY!==o&&(s.rotY=o,a=!0),c!==void 0&&s.distance!==c&&(s.distance=c,a=!0),u!==void 0&&s.zoom!==u&&(s.zoom=u,a=!0),d!==void 0&&s.stretch!==d&&(s.stretch=d,a=!0),a&&this.querySelector("glyph-scene")?.rerender?.()}};var sn=typeof HTMLElement<"u"?HTMLElement:class{};function me(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var Ee=class extends sn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=nt({rotX:me(this.getAttribute("rot-x")),rotY:me(this.getAttribute("rot-y")),zoom:me(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,i,r){if(i===r)return;let s=this._camera;if(!s)return;let l=me(this.getAttribute("rot-x")),o=me(this.getAttribute("rot-y")),c=me(this.getAttribute("zoom")),u=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,u=!0),o!==void 0&&s.rotY!==o&&(s.rotY=o,u=!0),c!==void 0&&s.zoom!==c&&(s.zoom=c,u=!0),u&&this.querySelector("glyph-scene")?.rerender?.()}};function dt(n,t={}){let e=n.host,i=t.drag??!0,r=t.wheel??!0,s=ut(t.invert),l=t.clampPitch??!0,o=t.animate??!1,c=!1,u=!1,d=null,a=null,f=null,v={x:0,y:0},g=n.camera;function w(m){if(!(!i||c)&&f===null&&m.isPrimary!==!1){m.preventDefault(),f=m.pointerId,v={x:m.clientX,y:m.clientY},e.style.cursor="grabbing";try{m.target.setPointerCapture(m.pointerId)}catch{}o&&o.pauseOnInteraction!==!1&&(u=!0)}}function x(m){if(f===null||m.pointerId!==f||!i||c)return;m.preventDefault();let b=m.clientX-v.x,A=m.clientY-v.y;v={x:m.clientX,y:m.clientY};let h=s,C=1/4;g.rotY=g.rotY-b*C*h;let S=g.rotX-A*C*h;g.rotX=l?Math.max(-90,Math.min(90,S)):S,n.rerender()}function _(m){if(f===m.pointerId){f=null,e.style.cursor=i&&!c?"grab":"";try{m.target.releasePointerCapture(m.pointerId)}catch{}o&&(u=!1)}}function G(m){if(!r||c)return;m.preventDefault();let b=m.deltaY*.001;g.zoom=Math.max(.1,Math.min(500,g.zoom*(1-b))),n.rerender()}function z(m){if(!(c||!o)){if(!u){let b=a!==null?Math.min(m-a,50):16.67,A=typeof o=="object"&&o.speed?o.speed:.3,h=typeof o=="object"&&o.axis?o.axis:"y",C=A*(b/16.67);h==="y"?g.rotY=g.rotY+C:g.rotX=g.rotX+C,n.rerender()}a=m,d=requestAnimationFrame(z)}}function y(){d===null&&typeof requestAnimationFrame<"u"&&o&&(d=requestAnimationFrame(z))}function E(){d!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(d),d=null),a=null}function L(){e.addEventListener("pointerdown",w),e.addEventListener("pointermove",x),e.addEventListener("pointerup",_),e.addEventListener("pointercancel",_),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=i?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function p(){e.removeEventListener("pointerdown",w),e.removeEventListener("pointermove",x),e.removeEventListener("pointerup",_),e.removeEventListener("pointercancel",_),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return L(),y(),{update(m){let b=!!o;i=m.drag??i,r=m.wheel??r,s=ut(m.invert),m.clampPitch!==void 0&&(l=m.clampPitch),o=m.animate??o,!c&&f===null&&(e.style.cursor=i?"grab":"");let A=!!o;b&&!A?E():!b&&A&&y()},pause(){c||(c=!0,p(),E(),f=null,u=!1)},resume(){c&&(c=!1,L(),y())},destroy(){c||p(),E(),c=!0}}}function ut(n){return n===void 0||n===!1?1:n===!0?-1:n}var ln=typeof HTMLElement<"u"?HTMLElement:class{};function an(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Le(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function cn(n){return n.closest("glyph-scene")??null}var _e=class extends ln{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,i,r){i!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Le(this.getAttribute("drag")),i=Le(this.getAttribute("wheel")),r=Le(this.getAttribute("invert")),s=Le(this.getAttribute("clamp-pitch")),l=an(this.getAttribute("animate-speed")),o=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...i!==void 0?{wheel:i}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...l!==void 0?{animate:{speed:l,axis:o}}:{}}}_attach(){if(this._controls)return;let e=cn(this);if(!e)return;let i=e.getScene();if(!i){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=dt(i,this._readOptions())}};function mt(n,t={}){let e=n.host,i=t.drag??!0,r=t.wheel??!0,s=ht(t.invert),l=t.animate??!1,o=!1,c=!1,u=null,d=null,a=null,f={x:0,y:0},v=!1,g=n.camera,w=1/4,x=.02;function _(h){if(!(!i||o)&&a===null&&h.isPrimary!==!1){h.preventDefault(),a=h.pointerId,f={x:h.clientX,y:h.clientY},v=h.button===2,e.style.cursor="grabbing";try{h.target.setPointerCapture(h.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(c=!0)}}function G(h){if(a===null||h.pointerId!==a||!i||o)return;h.preventDefault();let C=h.clientX-f.x,S=h.clientY-f.y;f={x:h.clientX,y:h.clientY};let H=s;if(v||h.shiftKey)g.rotY=g.rotY-C*w*H,g.rotX=Math.max(-90,Math.min(90,g.rotX+S*w*H));else{let T=g.target;g.target=[T[0]-C*x/g.zoom,T[1]-S*x/g.zoom,T[2]]}n.rerender()}function z(h){if(a===h.pointerId){a=null,v=!1,e.style.cursor=i&&!o?"grab":"";try{h.target.releasePointerCapture(h.pointerId)}catch{}l&&(c=!1)}}function y(h){h.preventDefault()}function E(h){if(!r||o)return;h.preventDefault();let C=h.deltaY*.001;g.zoom=Math.max(.1,Math.min(500,g.zoom*(1-C))),n.rerender()}function L(h){if(!(o||!l)){if(!c){let C=d!==null?Math.min(h-d,50):16.67,S=typeof l=="object"&&l.speed?l.speed:.3,H=typeof l=="object"&&l.axis?l.axis:"y",T=S*(C/16.67);H==="y"?g.rotY=g.rotY+T:g.rotX=g.rotX+T,n.rerender()}d=h,u=requestAnimationFrame(L)}}function p(){u===null&&typeof requestAnimationFrame<"u"&&l&&(u=requestAnimationFrame(L))}function m(){u!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(u),u=null),d=null}function b(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",G),e.addEventListener("pointerup",z),e.addEventListener("pointercancel",z),e.addEventListener("contextmenu",y),e.addEventListener("wheel",E,{passive:!1}),e.style.cursor=i?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function A(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",z),e.removeEventListener("pointercancel",z),e.removeEventListener("contextmenu",y),e.removeEventListener("wheel",E),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return b(),p(),{update(h){let C=!!l;i=h.drag??i,r=h.wheel??r,s=ht(h.invert),l=h.animate??l,!o&&a===null&&(e.style.cursor=i?"grab":"");let S=!!l;C&&!S?m():!C&&S&&p()},pause(){o||(o=!0,A(),m(),a=null,c=!1)},resume(){o&&(o=!1,b(),p())},destroy(){o||A(),m(),o=!0}}}function ht(n){return n===void 0||n===!1?1:n===!0?-1:n}var un=typeof HTMLElement<"u"?HTMLElement:class{};function je(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function dn(n){return n.closest("glyph-scene")??null}var Te=class extends un{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,i,r){i!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=je(this.getAttribute("drag")),i=je(this.getAttribute("wheel")),r=je(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...i!==void 0?{wheel:i}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=dn(this);if(!e)return;let i=e.getScene();if(!i){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=mt(i,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Me),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",xe),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",Se),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",Ge),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",Ee),!customElements.get("glyph-camera")){class n extends Ee{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",_e),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",Te)}export{Se as GlyphHotspotElement,Te as GlyphMapControlsElement,xe as GlyphMeshElement,_e as GlyphOrbitControlsElement,Ee as GlyphOrthographicCameraElement,Ge as GlyphPerspectiveCameraElement,Me as GlyphSceneElement};
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var ze=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var yt=Object.prototype.hasOwnProperty;var gt=(n,t)=>{for(var e in t)ze(n,e,{get:t[e],enumerable:!0})},Te=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ft(t))!yt.call(n,r)&&r!==e&&ze(n,r,{get:()=>t[r],enumerable:!(o=mt(t,r))||o.enumerable});return n},T=(n,t,e)=>(Te(n,t,"default"),e&&Te(e,t,"default"));var bt=n=>Te(ze({},"__esModule",{value:!0}),n);var H={};gt(H,{DEFAULT_RAMP:()=>$e,GlyphHotspotElement:()=>fe,GlyphMapControlsElement:()=>ve,GlyphMeshElement:()=>me,GlyphOrbitControlsElement:()=>be,GlyphOrthographicCameraElement:()=>ge,GlyphPerspectiveCameraElement:()=>ye,GlyphSceneElement:()=>he,SOLID_RAMP:()=>je,WIREFRAME_GLYPHS:()=>Ue,WIREFRAME_PALETTES:()=>te,bakeFrames:()=>qe,buildRasterizeContext:()=>le,createGlyphCamera:()=>We,createGlyphFirstPersonControls:()=>et,createGlyphMapControls:()=>pe,createGlyphOrbitControls:()=>de,createGlyphOrthographicCamera:()=>ee,createGlyphPerspectiveCamera:()=>j,createGlyphScene:()=>ue,findGlyphMeshHandle:()=>tt,findMeshUnderPoint:()=>nt,getWireframeGlyphs:()=>ne,injectGlyphBaseStyles:()=>ae,pointInMeshElement:()=>ke,projectHotspots:()=>ce,rasterize:()=>re});module.exports=bt(H);function Be(n,t,e){let o=Math.cos(t),r=Math.sin(t),s=o*n[1]-r*n[0],i=r*n[1]+o*n[0],a=n[2],u=Math.cos(e),c=Math.sin(e),h=u*i-c*a,d=c*i+u*a;return[s,h,d]}function j(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,zoom:n.zoom??.4,stretch:n.stretch??1,target:[0,0,0],eyeMode:!1,focal:5},[e,o]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return t.eyeMode},set eyeMode(r){t.eyeMode=r},project(r,s,i,a){let u=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Be(u,t.rotY,t.rotX);if(t.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2]];let x=t.focal/-c[2],p=Math.min(s,i)*t.zoom*x,b=s*e+c[0]*p*a*t.stretch,l=i*o+c[1]*p;return[b,l,c[2]]}let h=30,d=1.5,f=c[2]*h,m=.001,g=1-f/t.distance;if(g<m)return[NaN,NaN,c[2]];let L=1/g,E=Math.min(s,i)*t.zoom*d*L,S=s*e+c[0]*E*a*t.stretch,A=i*o+c[1]*E;return[S,A,c[2]]}}}function ee(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,zoom:n.zoom??.4,stretch:1,target:[0,0,0]},[e,o]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(r){t.rotX=r},get rotY(){return t.rotY},set rotY(r){t.rotY=r},get distance(){return t.distance},set distance(r){t.distance=r},get zoom(){return t.zoom},set zoom(r){t.zoom=r},get stretch(){return t.stretch},set stretch(r){t.stretch=r},get target(){return t.target},set target(r){t.target=r},get eyeMode(){return!1},set eyeMode(r){},project(r,s,i,a){let u=[r[0]-t.target[0],r[1]-t.target[1],r[2]-t.target[2]],c=Be(u,t.rotY,t.rotX),d=Math.min(s,i)*t.zoom*1.5,f=s*e+c[0]*d*a*t.stretch,m=i*o+c[1]*d;return[f,m,c[2]]}}}var We=ee;var vt={direction:[.5,.7,.5],intensity:1},Et={intensity:.4};function Gt(n){let t=new Set,e=[];for(let o of n){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let i=r[s],a=r[(s+1)%r.length],u=`${i[0]},${i[1]},${i[2]}`,c=`${a[0]},${a[1]},${a[2]}`,h=u<c?`${u}|${c}`:`${c}|${u}`;if(t.has(h))continue;t.add(h);let d={from:i,to:a,weight:2};o.color&&(d.color=o.color),e.push(d)}}return e}function le(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?Gt(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??vt,ambientLight:n.ambientLight??Et,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60}}var $e=" .:-=+*#%@".split(""),je=" .:-=+*#%@".split(""),te={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},Ue=te.default;function ne(n){return te[n]??te.default}function re(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:s,rows:i,cellAspect:a}=e;if(r==="solid")return Mt(n,s,i,a);let u=ne(n.glyphPalette),c=new Uint8Array(s*i),h=n.useColors?new Array(s*i).fill(null):null;for(let d of o){let f=t.project(d.from,s,i,a),m=t.project(d.to,s,i,a);f[0]!==f[0]||m[0]!==m[0]||St(c,h,f[0]|0,f[1]|0,m[0]|0,m[1]|0,d.weight??2,d.color??null,s,i)}return wt(c,h,s,i,u)}function Mt(n,t,e,o){let{camera:r,polygons:s,directionalLight:i,ambientLight:a,smoothShading:u,creaseAngle:c}=n,h=ne(n.glyphPalette).solid,d=h.length-1,f=new Array(t*e).fill(" "),m=n.useColors,g=m?new Array(t*e).fill(null):null,L=new Float64Array(t*e).fill(-1/0),E=i.direction,S=Math.hypot(E[0],E[1],E[2])||1,A=E[0]/S,M=E[1]/S,x=E[2]/S,p=i.intensity??1,b=a.intensity??.4,l=Pe(i.color??"#ffffff"),v=Pe(a.color??"#ffffff"),G=u&&c>0?At(s,c):null;for(let C=0;C<s.length;C++){let y=s[C],w=y.vertices;if(!(w.length<3))for(let _=1;_<w.length-1;_++){let z=_,Y=_+1,O=w[0],k=w[z],D=w[Y],R=r.project(O,t,e,o),I=r.project(k,t,e,o),N=r.project(D,t,e,o);if(R[0]!==R[0]||I[0]!==I[0]||N[0]!==N[0])continue;let X=k[0]-O[0],$=k[1]-O[1],Ee=k[2]-O[2],K=D[0]-O[0],V=D[1]-O[1],ie=D[2]-O[2],se=$*ie-Ee*V,Z=Ee*K-X*ie,Ye=X*V-$*K,Ge=Math.hypot(se,Z,Ye)||1,rt=se/Ge,ot=Z/Ge,it=Ye/Ge,Me,Ce,xe,Ae,Le,Se,we,_e,He;if(G){let J=G[C],B=J[0],W=J[z],Q=J[Y];Me=B[0],Ce=B[1],xe=B[2],Ae=W[0],Le=W[1],Se=W[2],we=Q[0],_e=Q[1],He=Q[2]}else Me=Ae=we=rt,Ce=Le=_e=ot,xe=Se=He=it;let st=Me*A+Ce*M+xe*x,lt=Ae*A+Le*M+Se*x,at=we*A+_e*M+He*x,De=Math.min(1,b+Math.max(0,st)*p),Ne=Math.min(1,b+Math.max(0,lt)*p),Xe=Math.min(1,b+Math.max(0,at)*p),Ve=null;if(m){let J=(De+Ne+Xe)/3,B=Math.max(0,J-b),W=y.color?Pe(y.color):[255,255,255],Q=b*v[0]/255+B*l[0]/255,ct=b*v[1]/255+B*l[1]/255,ut=b*v[2]/255+B*l[2]/255,dt=Math.min(255,W[0]*Q),pt=Math.min(255,W[1]*ct),ht=Math.min(255,W[2]*ut);Ve=`#${Oe(dt)}${Oe(pt)}${Oe(ht)}`}xt(R[0],R[1],R[2],De,I[0],I[1],I[2],Ne,N[0],N[1],N[2],Xe,h,d,Ve,f,g,L,t,e)}}return Lt(f,g,t,e)}var Ct=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]);function xt(n,t,e,o,r,s,i,a,u,c,h,d,f,m,g,L,E,S,A,M){let x=(r-n)*(c-t)-(s-t)*(u-n);if(x===0||x>0)return;let p=1/x,b=x>0,l=n<r?n:r;u<l&&(l=u);let v=n>r?n:r;u>v&&(v=u);let G=t<s?t:s;c<G&&(G=c);let C=t>s?t:s;c>C&&(C=c);let y=Math.max(0,Math.ceil(l)),w=Math.min(A-1,Math.floor(v)),_=Math.max(0,Math.ceil(G)),P=Math.min(M-1,Math.floor(C));if(!(y>w||_>P))for(let z=_;z<=P;z++){let Y=z;for(let O=y;O<=w;O++){let k=O,D=(r-k)*(c-Y)-(s-Y)*(u-k),R=(u-k)*(t-Y)-(c-Y)*(n-k),I=(n-k)*(s-Y)-(t-Y)*(r-k);if(b?D<0||R<0||I<0:D>0||R>0||I>0)continue;let N=(D*e+R*i+I*h)*p,X=z*A+O;if(N>S[X]){S[X]=N;let $=(D*o+R*a+I*d)*p,K=($<0?0:$>1?1:$)*m,V=K|0,ie=K-V,se=Ct[(z&3)*4+(O&3)],Z=ie>se&&V<m?V+1:V;L[X]=f[Z>m?m:Z],E&&(E[X]=g)}}}}function At(n,t){let e=n.length,o=new Array(e);for(let a=0;a<e;a++){let u=n[a].vertices;if(u.length<3){o[a]=[0,0,0];continue}let c=u[0],h=u[1],d=u[2],f=h[0]-c[0],m=h[1]-c[1],g=h[2]-c[2],L=d[0]-c[0],E=d[1]-c[1],S=d[2]-c[2],A=m*S-g*E,M=g*L-f*S,x=f*E-m*L,p=Math.hypot(A,M,x)||1;o[a]=[A/p,M/p,x/p]}let r=new Map;for(let a=0;a<e;a++){let u=n[a].vertices;for(let c=0;c<u.length;c++){let h=u[c],d=`${h[0]},${h[1]},${h[2]}`,f=r.get(d);f||(f=[],r.set(d,f)),(f.length===0||f[f.length-1]!==a)&&f.push(a)}}let s=Math.cos(t*Math.PI/180),i=new Array(e);for(let a=0;a<e;a++){let u=n[a].vertices,c=o[a],h=new Array(u.length);for(let d=0;d<u.length;d++){let f=u[d],m=r.get(`${f[0]},${f[1]},${f[2]}`),g=0,L=0,E=0;for(let A=0;A<m.length;A++){let M=m[A],x=o[M];c[0]*x[0]+c[1]*x[1]+c[2]*x[2]>=s&&(g+=x[0],L+=x[1],E+=x[2])}let S=Math.hypot(g,L,E)||1;h[d]=[g/S,L/S,E/S]}i[a]=h}return i}function Lt(n,t,e,o){let r=[],s=null,i="",a=()=>{i&&(s!==null?r.push(`<span style="color:${s}">${i}</span>`):r.push(i),i="")};for(let u=0;u<o;u++){for(let c=0;c<e;c++){let h=u*e+c,d=n[h],f=t&&d!==" "?t[h]??null:null;f!==s&&(a(),s=f),i+=d}a(),s=null,u<o-1&&r.push(`
2
- `)}return r.join("")}function qe(n,t,e="y"){let{camera:o}=n,r=e==="y"?o.rotY:o.rotX,s=new Array(t);for(let i=0;i<t;i++){let a=r+i/t*Math.PI*2;e==="y"?o.rotY=a:o.rotX=a,s[i]=re(n)}return e==="y"?o.rotY=r:o.rotX=r,s}function St(n,t,e,o,r,s,i,a,u,c){let h=Math.abs(r-e),d=-Math.abs(s-o),f=e<r?1:-1,m=o<s?1:-1,g=h+d;for(;;){if(e>=0&&e<u&&o>=0&&o<c){let E=o*u+e;n[E]<i&&(n[E]=i,t&&(t[E]=a))}if(e===r&&o===s)break;let L=2*g;L>=d&&(g+=d,e+=f),L<=h&&(g+=h,o+=m)}}function wt(n,t,e,o,r){let s=[],i=null,a="",u=()=>{a&&(i!==null?s.push(`<span style="color:${i}">${a}</span>`):s.push(a),a="")};for(let c=0;c<o;c++){for(let h=0;h<e;h++){let d=c*e+h,f=n[d],m,g;f===0?(m=" ",g=null):(m=f===1?r.thin[Math.random()*r.thin.length|0]:f===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],g=t?t[d]??null:null),g!==i&&(u(),i=g),a+=m}u(),i=null,c<o-1&&s.push(`
3
- `)}return s.join("")}function Pe(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),o=parseInt(t[1]+t[1],16),r=parseInt(t[2]+t[2],16);return[e||0,o||0,r||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function Oe(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var Ke="glyph-styles";function ae(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(Ke))return;let e=t.createElement("style");e.id=Ke,e.textContent=_t,t.head.appendChild(e)}var _t=`
1
+ "use strict";var ot=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var Xt=Object.getOwnPropertyNames;var Nt=Object.prototype.hasOwnProperty;var Vt=(t,n)=>{for(var e in n)ot(t,e,{get:n[e],enumerable:!0})},rt=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Xt(n))!Nt.call(t,r)&&r!==e&&ot(t,r,{get:()=>n[r],enumerable:!(o=Bt(n,r))||o.enumerable});return t},O=(t,n,e)=>(rt(t,n,"default"),e&&rt(e,n,"default"));var $t=t=>rt(ot({},"__esModule",{value:!0}),t);var z={};Vt(z,{DEFAULT_RAMP:()=>gt,GlyphHotspotElement:()=>Fe,GlyphMapControlsElement:()=>Ne,GlyphMeshElement:()=>ke,GlyphOrbitControlsElement:()=>Xe,GlyphOrthographicCameraElement:()=>De,GlyphPerspectiveCameraElement:()=>Ye,GlyphSceneElement:()=>Re,SOLID_RAMP:()=>bt,WIREFRAME_GLYPHS:()=>vt,WIREFRAME_PALETTES:()=>xe,bakeFrames:()=>wt,buildRasterizeContext:()=>He,createGlyphCamera:()=>yt,createGlyphFirstPersonControls:()=>Gt,createGlyphMapControls:()=>Ie,createGlyphOrbitControls:()=>Oe,createGlyphOrthographicCamera:()=>Me,createGlyphPerspectiveCamera:()=>pe,createGlyphScene:()=>ze,findGlyphMeshHandle:()=>St,findMeshUnderPoint:()=>Lt,getWireframeGlyphs:()=>Ae,injectGlyphBaseStyles:()=>Pe,pointInMeshElement:()=>it,projectHotspots:()=>Te,rasterize:()=>Se});module.exports=$t(z);var mt=Math.PI/180;function ft(t,n,e){let o=t[1],r=t[0],s=t[2],l=e*mt,i=Math.cos(l),u=Math.sin(l),d=o*i-r*u,h=o*u+r*i,c=s,f=n*mt,g=Math.cos(f),y=Math.sin(f),w=h*g-c*y,M=h*y+c*g;return[d,w,M]}function pe(t={}){let n={rotX:t.rotX??65,rotY:t.rotY??45,distance:t.distance??6,zoom:t.zoom??.65,stretch:t.stretch??1,target:[0,0,0],eyeMode:!1,focal:1},[e,o]=t.center??[.5,.5];return{kind:"perspective",get rotX(){return n.rotX},set rotX(r){n.rotX=r},get rotY(){return n.rotY},set rotY(r){n.rotY=r},get distance(){return n.distance},set distance(r){n.distance=r},get zoom(){return n.zoom},set zoom(r){n.zoom=r},get stretch(){return n.stretch},set stretch(r){n.stretch=r},get target(){return n.target},set target(r){n.target=r},get eyeMode(){return n.eyeMode},set eyeMode(r){n.eyeMode=r},project(r,s,l,i){let d=50/i,h=[r[0]-n.target[0],r[1]-n.target[1],r[2]-n.target[2]],c=ft(h,n.rotX,n.rotY);if(n.eyeMode){if(c[2]>=-.001)return[NaN,NaN,c[2]];let v=n.focal/-c[2],E=c[0]*v*n.zoom*50,L=c[1]*v*n.zoom*50,a=s*e+E/d*n.stretch,m=l*o+L/50;return[a,m,c[2]]}let f=.001,g=n.distance-c[2];if(g<f)return[NaN,NaN,c[2]];let y=n.distance/g,w=c[0]*y*n.zoom*50,M=c[1]*y*n.zoom*50,_=s*e+w/d*n.stretch,G=l*o+M/50;return[_,G,c[2]]}}}function Me(t={}){let n={rotX:t.rotX??65,rotY:t.rotY??45,distance:0,zoom:t.zoom??.65,stretch:1,target:[0,0,0]},[e,o]=t.center??[.5,.5];return{kind:"orthographic",get rotX(){return n.rotX},set rotX(r){n.rotX=r},get rotY(){return n.rotY},set rotY(r){n.rotY=r},get distance(){return n.distance},set distance(r){n.distance=r},get zoom(){return n.zoom},set zoom(r){n.zoom=r},get stretch(){return n.stretch},set stretch(r){n.stretch=r},get target(){return n.target},set target(r){n.target=r},get eyeMode(){return!1},set eyeMode(r){},project(r,s,l,i){let d=50/i,h=[r[0]-n.target[0],r[1]-n.target[1],r[2]-n.target[2]],c=ft(h,n.rotX,n.rotY),f=c[0]*n.zoom*50,g=c[1]*n.zoom*50,y=s*e+f/d,w=l*o+g/50;return[y,w,c[2]]}}}var yt=Me;var Wt={direction:[-.5,-.7,-.5],intensity:1},jt={intensity:.4};function qt(t){let n=new Set,e=[];for(let o of t){let r=o.vertices;if(!(r.length<2))for(let s=0;s<r.length;s++){let l=r[s],i=r[(s+1)%r.length],u=`${l[0]},${l[1]},${l[2]}`,d=`${i[0]},${i[1]},${i[2]}`,h=u<d?`${u}|${d}`:`${d}|${u}`;if(n.has(h))continue;n.add(h);let c={from:l,to:i,weight:2};o.color&&(c.color=o.color),e.push(c)}}return e}function He(t){let n=t.polygons??[],e=t.mode??(n.length?"solid":"wireframe"),o=t.wireframe??(e==="wireframe"?qt(n):[]);return{camera:t.camera,grid:t.grid,polygons:n,wireframe:o,mode:e,directionalLight:t.directionalLight??Wt,ambientLight:t.ambientLight??jt,glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,shadow:t.shadow,castShadowFlags:t.castShadowFlags??[],receiveShadowFlags:t.receiveShadowFlags??[]}}var gt=" .:-=+*#%@".split(""),bt=" .:-=+*#%@".split(""),xe={default:{thin:"\xB7\u22C5\u2219\u02D9\xB7\u22C5\u2219".split(""),normal:"\u254B\u256C\u253C\u2573\u25C6\u25C7\u25CA\u25B2\u25B3\u25BC\u25BD\u25C8\u2B21\u2B22\u2234\u2235\u22A5\u2295\u2297\u2299\u229A\u229B".split(""),core:"\u2726\u2727\u2729\u25C9\u2299\u25CE".split(""),solid:" .:-=+*#%@".split("")},ascii:{thin:".'".split(""),normal:"+*x".split(""),core:"#@".split(""),solid:" .,:;!+=*xX#@".split("")},dots:{thin:"\xB7\u22C5".split(""),normal:"\u2022\u25CF".split(""),core:"\u25C9\u25CE".split(""),solid:" \xB7\u22C5\u2218\u2022\u25CF\u25C9\u25CE\u2B24".split("")},lines:{thin:"\u2500\u2502".split(""),normal:"\u2550\u2551".split(""),core:"\u2588".split(""),solid:" \u2500\u2550\u256C\u2551\u2588\u2593\u2592\u2591".split("")},blocks:{thin:"\u2591\u2581".split(""),normal:"\u2592\u2593\u258C\u2590\u2580\u2584".split(""),core:"\u2588".split(""),solid:" \u2591\u2592\u2593\u258C\u2590\u2588\u2580\u2584\u25A0".split("")},stars:{thin:"\xB7\u22C6".split(""),normal:"\u2726\u2727\u2729\u272A".split(""),core:"\u272B\u272C\u272D\u2605".split(""),solid:" \xB7\u22C6\u2217\u2726\u2727\u2729\u272A\u272B\u2605".split("")},arrows:{thin:"\xB7\u2219".split(""),normal:"\u2190\u2191\u2192\u2193".split(""),core:"\u2196\u2197\u2198\u2199\u2921\u2922".split(""),solid:" \xB7\u2219\u2191\u2197\u2192\u2198\u2193\u2199\u2190\u2196".split("")},braille:{thin:"\u2801\u2802\u2804\u2808".split(""),normal:"\u2803\u2805\u2806\u2809\u280A\u280B\u280C\u280D\u280E\u280F".split(""),core:"\u283F\u28FF".split(""),solid:" \u2801\u2803\u2807\u2827\u2837\u283F\u287F\u28FF".split("")},runes:{thin:".\xB7".split(""),normal:"\u16A0\u16A1\u16A2\u16A3\u16A4\u16A6\u16A8\u16B1\u16B2\u16B3\u16B7\u16B9\u16C3\u16C7\u16C9".split(""),core:"\u16DE\u16DF\u16E1\u16E2\u16E3".split(""),solid:" \xB7\u16A0\u16A3\u16A4\u16A8\u16B1\u16B7\u16DE\u16E2".split("")},math:{thin:"\u2219\u2218".split(""),normal:"\u2211\u220F\u222B\u221A\u221E\u2248\u2260\u2264\u2265\u2282\u2283\u2286\u2287".split(""),core:"\u222E\u222F\u2230\u2202".split(""),solid:" \u2219\u2218\u2211\u222B\u221A\u221E\u2248\u2295\u2297".split("")},binary:{thin:"\xB7.".split(""),normal:"01".split(""),core:"\u2588".split(""),solid:" .:01\u2588\u2588".split("")},hex:{thin:"\xB7\u2219".split(""),normal:"0123456789ABCDEF".split(""),core:"FFAA".split(""),solid:" 0123456789AF".split("")}},vt=xe.default;function Ae(t){return xe[t]??xe.default}function Se(t){let{camera:n,grid:e,wireframe:o,mode:r}=t,{cols:s,rows:l,cellAspect:i}=e;if(r==="solid")return Ut(t,s,l,i);let u=Ae(t.glyphPalette),d=new Uint8Array(s*l),h=t.useColors?new Array(s*l).fill(null):null;for(let c of o){let f=n.project(c.from,s,l,i),g=n.project(c.to,s,l,i);f[0]!==f[0]||g[0]!==g[0]||nn(d,h,f[0]|0,f[1]|0,g[0]|0,g[1]|0,c.weight??2,c.color??null,s,l)}return rn(d,h,s,l,u)}function Ut(t,n,e,o){let{camera:r,polygons:s,directionalLight:l,ambientLight:i,smoothShading:u,creaseAngle:d,castShadowFlags:h,receiveShadowFlags:c}=t,f=Ae(t.glyphPalette).solid,g=f.length-1,y=new Array(n*e).fill(" "),w=t.useColors,M=w?new Array(n*e).fill(null):null,_=new Float64Array(n*e).fill(-1/0),G=l.direction,P=Math.hypot(G[0],G[1],G[2])||1,v=G[0]/P,E=G[1]/P,L=G[2]/P,a=l.intensity??1,m=i.intensity??.4,b=Ge(l.color??"#ffffff"),C=Ge(i.color??"#ffffff"),p=u&&d>0?en(s,d):null,x=new Map,S=t.shadow,T=S!=null&&h.length>0?Jt(s,h,v,E,L):null,H=S?.opacity??.25,k=S?.lift??.05,F=S?.color??"#000000",K=T?Ge(F):[0,0,0],I=globalThis.__glyphPerfDetail,Z=I?performance.now():0,B=[],R=t.shadeCache??null,Y=-1;for(let ie=0;ie<s.length;ie++){let ve=s[ie],X=ve.vertices;if(!(X.length<3)){for(let N=0;N<X.length;N++)B[N]=r.project(X[N],n,e,o);for(let N=1;N<X.length-1;N++){Y++;let Ee=0,$=N,J=N+1,Q=X[Ee],se=X[$],le=X[J],D=B[Ee],V=B[$],W=B[J];if(D[0]!==D[0]||V[0]!==V[0]||W[0]!==W[0]||(V[0]-D[0])*(W[1]-D[1])-(V[1]-D[1])*(W[0]-D[0])>0)continue;let j,ee,te,ae=null;if(R!==null&&R.iA[Y]!==void 0)j=R.iA[Y],ee=R.iB[Y],te=R.iC[Y],ae=R.lit[Y];else{let A=se[0]-Q[0],ce=se[1]-Q[1],ue=se[2]-Q[2],de=le[0]-Q[0],at=le[1]-Q[1],ct=le[2]-Q[2],ut=ce*ct-ue*at,dt=ue*de-A*ct,ht=A*at-ce*de,We=Math.hypot(ut,dt,ht)||1,_t=ut/We,Ht=dt/We,Pt=ht/We,je,qe,Ue,Ke,Ze,Je,Qe,et,tt;if(p){let we=p[ie],ne=we[Ee],he=we[$],Ce=we[J];je=ne[0],qe=ne[1],Ue=ne[2],Ke=he[0],Ze=he[1],Je=he[2],Qe=Ce[0],et=Ce[1],tt=Ce[2]}else je=Ke=Qe=_t,qe=Ze=et=Ht,Ue=Je=tt=Pt;let Tt=Math.max(0,-(je*v+qe*E+Ue*L)),zt=Math.max(0,-(Ke*v+Ze*E+Je*L)),Ot=Math.max(0,-(Qe*v+et*E+tt*L));if(j=Math.min(1,m+Tt*a),ee=Math.min(1,m+zt*a),te=Math.min(1,m+Ot*a),w){let we=(j+ee+te)/3,ne=Math.max(0,we-m),he=ve.color??"#ffffff",Ce=ne*255|0,pt=`${he}:${Ce}`,_e=x.get(pt);if(_e===void 0){let nt=Ge(he),It=m*C[0]/255+ne*b[0]/255,Rt=m*C[1]/255+ne*b[1]/255,kt=m*C[2]/255+ne*b[2]/255,Ft=Math.min(255,nt[0]*It),Yt=Math.min(255,nt[1]*Rt),Dt=Math.min(255,nt[2]*kt);_e=`#${fe(Ft)}${fe(Yt)}${fe(Dt)}`,x.set(pt,_e)}ae=_e}R!==null&&(R.iA[Y]=j,R.iB[Y]=ee,R.iC[Y]=te,R.lit[Y]=ae)}let $e=c[ie]??!1,Le=null;if(T!==null&&$e){let A=T,ce=me(Q,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),ue=me(se,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax),de=me(le,A.right[0],A.right[1],A.right[2],A.up[0],A.up[1],A.up[2],A.dir[0],A.dir[1],A.dir[2],A.uMin,A.uMax,A.vMin,A.vMax);Le={map:A,luA:ce[0],lvA:ce[1],ldA:ce[2],luB:ue[0],lvB:ue[1],ldB:ue[2],luC:de[0],lvC:de[1],ldC:de[2],lift:k,opacity:H,shadowColorRgb:K,shadowColorHex:F,litCache:x}}Qt(D[0],D[1],D[2],j,V[0],V[1],V[2],ee,W[0],W[1],W[2],te,f,g,ae,y,M,_,n,e,Le)}}}I&&(I.loop??(I.loop=[])).push(performance.now()-Z);let oe=I?performance.now():0,be=tn(y,M,n,e);return I&&(I.string??(I.string=[])).push(performance.now()-oe),be}var Kt=new Float64Array([(0+.5)/16,(8+.5)/16,(2+.5)/16,(10+.5)/16,(12+.5)/16,(4+.5)/16,(14+.5)/16,(6+.5)/16,(3+.5)/16,(11+.5)/16,(1+.5)/16,(9+.5)/16,(15+.5)/16,(7+.5)/16,(13+.5)/16,(5+.5)/16]),q=256;function me(t,n,e,o,r,s,l,i,u,d,h,c,f,g){let y=n*t[0]+e*t[1]+o*t[2],w=r*t[0]+s*t[1]+l*t[2],M=-(i*t[0]+u*t[1]+d*t[2]),_=(y-h)/(c-h)*(q-1),G=(w-f)/(g-f)*(q-1);return[_,G,M]}function Zt(t,n,e,o){let r=n[0],s=n[1],l=n[2],i=e[0],u=e[1],d=e[2],h=o[0],c=o[1],f=o[2],g=(i-r)*(c-s)-(u-s)*(h-r);if(g===0)return;let y=1/g,w=r<i?r:i;h<w&&(w=h);let M=r>i?r:i;h>M&&(M=h);let _=s<u?s:u;c<_&&(_=c);let G=s>u?s:u;c>G&&(G=c);let P=Math.max(0,Math.ceil(w)),v=Math.min(q-1,Math.floor(M)),E=Math.max(0,Math.ceil(_)),L=Math.min(q-1,Math.floor(G));if(P>v||E>L)return;let a=g>0;for(let m=E;m<=L;m++)for(let b=P;b<=v;b++){let C=b,p=m,x=(i-C)*(c-p)-(u-p)*(h-C),S=(h-C)*(s-p)-(c-p)*(r-C),T=(r-C)*(u-p)-(s-p)*(i-C);if(a?x<0||S<0||T<0:x>0||S>0||T>0)continue;let H=(x*l+S*d+T*f)*y,k=m*q+b;H>t[k]&&(t[k]=H)}}function Jt(t,n,e,o,r){let s,l,i;Math.abs(e)<.9?(s=0,l=r,i=-o):(s=-r,l=0,i=e);let u=Math.hypot(s,l,i);s/=u,l/=u,i/=u;let d=l*r-i*o,h=i*e-s*r,c=s*o-l*e,f=1/0,g=-1/0,y=1/0,w=-1/0,M=!1;for(let v=0;v<t.length;v++)if(n[v]){M=!0;for(let E of t[v].vertices){let L=s*E[0]+l*E[1]+i*E[2],a=d*E[0]+h*E[1]+c*E[2];L<f&&(f=L),L>g&&(g=L),a<y&&(y=a),a>w&&(w=a)}}if(!M)return null;let _=(g-f)*.05+.01,G=(w-y)*.05+.01;f-=_,g+=_,y-=G,w+=G;let P=new Float64Array(q*q).fill(-1/0);for(let v=0;v<t.length;v++){if(!n[v])continue;let E=t[v].vertices;if(!(E.length<3))for(let L=1;L<E.length-1;L++){let a=E[0],m=E[L],b=E[L+1],C=me(a,s,l,i,d,h,c,e,o,r,f,g,y,w),p=me(m,s,l,i,d,h,c,e,o,r,f,g,y,w),x=me(b,s,l,i,d,h,c,e,o,r,f,g,y,w);Zt(P,C,p,x)}}return{buf:P,right:[s,l,i],up:[d,h,c],dir:[e,o,r],uMin:f,uMax:g,vMin:y,vMax:w}}function Qt(t,n,e,o,r,s,l,i,u,d,h,c,f,g,y,w,M,_,G,P,v){let E=(r-t)*(d-n)-(s-n)*(u-t);if(E===0||E>0)return;let L=1/E,a=E>0,m=t<r?t:r;u<m&&(m=u);let b=t>r?t:r;u>b&&(b=u);let C=n<s?n:s;d<C&&(C=d);let p=n>s?n:s;d>p&&(p=d);let x=Math.max(0,Math.ceil(m)),S=Math.min(G-1,Math.floor(b)),T=Math.max(0,Math.ceil(C)),H=Math.min(P-1,Math.floor(p));if(!(x>S||T>H))for(let k=T;k<=H;k++){let F=k;for(let K=x;K<=S;K++){let I=K,Z=(r-I)*(d-F)-(s-F)*(u-I),B=(u-I)*(n-F)-(d-F)*(t-I),R=(t-I)*(s-F)-(n-F)*(r-I);if(a?Z<0||B<0||R<0:Z>0||B>0||R>0)continue;let Y=(Z*e+B*l+R*h)*L,oe=k*G+K;if(Y>_[oe]){_[oe]=Y;let be=(Z*o+B*i+R*c)*L,ve=(be<0?0:be>1?1:be)*g,X=ve|0,N=ve-X,Ee=Kt[(k&3)*4+(K&3)],$=N>Ee&&X<g?X+1:X;$>g&&($=g);let J=y;if(v!==null){let Q=(Z*v.luA+B*v.luB+R*v.luC)*L,se=(Z*v.lvA+B*v.lvB+R*v.lvC)*L,le=(Z*v.ldA+B*v.ldB+R*v.ldC)*L,D=Q|0,V=se|0;if(D>=0&&D<q&&V>=0&&V<q){let W=v.map.buf[V*q+D];if(W>-1/0&&le+v.lift<W&&($=Math.max(0,$-Math.round(v.opacity*g)),J!==null)){let Ve=`shadow:${J}:${$}`,j=v.litCache.get(Ve);if(j===void 0){let ee=Ge(J),te=v.shadowColorRgb,ae=Math.round(ee[0]*(1-v.opacity)+te[0]*v.opacity),$e=Math.round(ee[1]*(1-v.opacity)+te[1]*v.opacity),Le=Math.round(ee[2]*(1-v.opacity)+te[2]*v.opacity);j=`#${fe(ae)}${fe($e)}${fe(Le)}`,v.litCache.set(Ve,j)}J=j}}}w[oe]=f[$],M&&(M[oe]=J)}}}}function en(t,n){let e=t.length,o=new Array(e);for(let i=0;i<e;i++){let u=t[i].vertices;if(u.length<3){o[i]=[0,0,0];continue}let d=u[0],h=u[1],c=u[2],f=h[0]-d[0],g=h[1]-d[1],y=h[2]-d[2],w=c[0]-d[0],M=c[1]-d[1],_=c[2]-d[2],G=g*_-y*M,P=y*w-f*_,v=f*M-g*w,E=Math.hypot(G,P,v)||1;o[i]=[G/E,P/E,v/E]}let r=new Map;for(let i=0;i<e;i++){let u=t[i].vertices;for(let d=0;d<u.length;d++){let h=u[d],c=`${h[0]},${h[1]},${h[2]}`,f=r.get(c);f||(f=[],r.set(c,f)),(f.length===0||f[f.length-1]!==i)&&f.push(i)}}let s=Math.cos(n*Math.PI/180),l=new Array(e);for(let i=0;i<e;i++){let u=t[i].vertices,d=o[i],h=new Array(u.length);for(let c=0;c<u.length;c++){let f=u[c],g=r.get(`${f[0]},${f[1]},${f[2]}`),y=0,w=0,M=0;for(let G=0;G<g.length;G++){let P=g[G],v=o[P];d[0]*v[0]+d[1]*v[1]+d[2]*v[2]>=s&&(y+=v[0],w+=v[1],M+=v[2])}let _=Math.hypot(y,w,M)||1;h[c]=[y/_,w/_,M/_]}l[i]=h}return l}function tn(t,n,e,o){let r=[],s=null,l="",i=()=>{l&&(s!==null?r.push(`<span style="color:${s}">${l}</span>`):r.push(l),l="")};for(let u=0;u<o;u++){for(let d=0;d<e;d++){let h=u*e+d,c=t[h],f=n&&c!==" "?n[h]??null:null;f!==s&&(i(),s=f),l+=c}i(),s=null,u<o-1&&r.push(`
2
+ `)}return r.join("")}function wt(t,n,e="y"){let{camera:o}=t,r=e==="y"?o.rotY:o.rotX,s=new Array(n);for(let l=0;l<n;l++){let i=r+l/n*Math.PI*2;e==="y"?o.rotY=i:o.rotX=i,s[l]=Se(t)}return e==="y"?o.rotY=r:o.rotX=r,s}function nn(t,n,e,o,r,s,l,i,u,d){let h=Math.abs(r-e),c=-Math.abs(s-o),f=e<r?1:-1,g=o<s?1:-1,y=h+c;for(;;){if(e>=0&&e<u&&o>=0&&o<d){let M=o*u+e;t[M]<l&&(t[M]=l,n&&(n[M]=i))}if(e===r&&o===s)break;let w=2*y;w>=c&&(y+=c,e+=f),w<=h&&(y+=h,o+=g)}}function rn(t,n,e,o,r){let s=[],l=null,i="",u=()=>{i&&(l!==null?s.push(`<span style="color:${l}">${i}</span>`):s.push(i),i="")};for(let d=0;d<o;d++){for(let h=0;h<e;h++){let c=d*e+h,f=t[c],g,y;f===0?(g=" ",y=null):(g=f===1?r.thin[Math.random()*r.thin.length|0]:f===2?r.normal[Math.random()*r.normal.length|0]:r.core[Math.random()*r.core.length|0],y=n?n[c]??null:null),y!==l&&(u(),l=y),i+=g}u(),l=null,d<o-1&&s.push(`
3
+ `)}return s.join("")}var Et=new Map;function Ge(t){let n=Et.get(t);if(n!==void 0)return n;let e=on(t);return Et.set(t,e),e}function on(t){let n=t.startsWith("#")?t.slice(1):t;if(n.length===3){let e=parseInt(n[0]+n[0],16),o=parseInt(n[1]+n[1],16),r=parseInt(n[2]+n[2],16);return[e||0,o||0,r||0]}if(n.length===6){let e=parseInt(n.slice(0,2),16),o=parseInt(n.slice(2,4),16),r=parseInt(n.slice(4,6),16);return[e||0,o||0,r||0]}return[255,255,255]}function fe(t){let n=Math.max(0,Math.min(255,t|0)).toString(16);return n.length===1?"0"+n:n}var Ct="glyph-styles";function Pe(t){let n=t??(typeof document<"u"?document:void 0);if(!n||n.getElementById(Ct))return;let e=n.createElement("style");e.id=Ct,e.textContent=sn,n.head.appendChild(e)}var sn=`
4
4
  /* \u2500\u2500 React / Vue host wrapper \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
5
5
 
6
6
  .glyph-host {
@@ -59,4 +59,5 @@
59
59
  the content from the 3D vertex being labelled. */
60
60
  transform: translate(-50%, -50%);
61
61
  }
62
- `;function ce(n,t,e,o,r){return n.map(s=>{let[i,a,u]=t.project(s.at,e,o,r),c=u>-3&&i>=0&&i<e&&a>=0&&a<o;return{id:s.id,col:i,row:a,depth:u,visible:c}})}var Ht=1;function Tt(n,t){let{position:e,scale:o,rotation:r}=t;if(!e&&!o&&!r)return n;let[s,i,a]=e??[0,0,0],u=1,c=1,h=1;o!==void 0&&(typeof o=="number"?u=c=h=o:[u,c,h]=o);let[d,f,m]=r??[0,0,0],g=Math.cos(d),L=Math.sin(d),E=Math.cos(f),S=Math.sin(f),A=Math.cos(m),M=Math.sin(m);function x(p){let b=p[0]*u,l=p[1]*c,v=p[2]*h,G=A*b-M*l,C=M*b+A*l,y=v;return b=E*G+S*y,l=C,v=-S*G+E*y,G=b,C=g*l-L*v,y=L*l+g*v,[G+s,C+i,y+a]}return n.map(p=>({...p,vertices:p.vertices.map(x)}))}function ue(n,t={}){ae(n.ownerDocument??void 0);let e={mode:t.mode??"solid",glyphPalette:t.glyphPalette??"default",useColors:t.useColors??!0,cols:t.cols??80,rows:t.rows??24,cellAspect:t.cellAspect??2,directionalLight:t.directionalLight??{direction:[.5,.7,.5],intensity:1},ambientLight:t.ambientLight??{intensity:.4},camera:t.camera??j(),smoothShading:t.smoothShading??!1,creaseAngle:t.creaseAngle??60,autoSize:t.autoSize??!1},o=n.ownerDocument.createElement("div");o.className="glyph-scene";let r=n.ownerDocument.createElement("pre");r.className="glyph-output";let s=n.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),n.appendChild(o);let i=new Map,a=[],u=!1;function c(){u||(u=!0,Promise.resolve().then(()=>{u=!1,h()}))}function h(){let p=[];for(let v of i.values()){let G=Tt(v.polygons,v.transform);for(let C of G)p.push(C)}let b=le({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:p,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle}),l=re(b);e.useColors?r.innerHTML=l:r.textContent=l,d()}function d(){let{cols:p,rows:b,cellAspect:l,camera:v}=e,G=ce(a.map(_=>_.hotspot),v,p,b,l),C=r.getBoundingClientRect(),y=p>0?C.width/p:8,w=b>0?C.height/b:16;for(let _=0;_<a.length;_++){let{el:P}=a[_],z=G[_];z.visible?(P.style.display="",P.style.left=`${(z.col+.5)*y}px`,P.style.top=`${(z.row+.5)*w}px`,P.style.zIndex=String(Math.round(z.depth*1e3))):P.style.display="none"}}function f(p,b={}){let l=Ht++;return i.set(l,{id:l,polygons:p,transform:b}),c(),{get id(){return l},get name(){return i.get(l)?.transform.id},get polygons(){return p},setTransform(v){let G=i.get(l);G&&(G.transform=v,c())},dispose(){i.delete(l),c()}}}function m(p,b){let l=n.ownerDocument.createElement("div");l.className="glyph-hotspot",l.setAttribute("data-hotspot-id",p.id);let[v,G]=p.size??[1,1];l.style.position="absolute",l.style.width=`${v}ch`,l.style.height=`${G*e.cellAspect}ch`,b&&l.addEventListener("click",b),s.appendChild(l);let C={hotspot:{id:p.id,at:p.at,size:p.size},el:l,onClick:b};return a.push(C),c(),{get el(){return l},remove(){let y=a.indexOf(C);y>=0&&a.splice(y,1),b&&l.removeEventListener("click",b),s.removeChild(l),c()}}}function g(){h()}function L(p){p.mode!==void 0&&(e.mode=p.mode),p.glyphPalette!==void 0&&(e.glyphPalette=p.glyphPalette),p.useColors!==void 0&&(e.useColors=p.useColors),p.cols!==void 0&&(e.cols=p.cols),p.rows!==void 0&&(e.rows=p.rows),p.cellAspect!==void 0&&(e.cellAspect=p.cellAspect),p.directionalLight!==void 0&&(e.directionalLight=p.directionalLight),p.ambientLight!==void 0&&(e.ambientLight=p.ambientLight),p.camera!==void 0&&(e.camera=p.camera),p.smoothShading!==void 0&&(e.smoothShading=p.smoothShading),p.creaseAngle!==void 0&&(e.creaseAngle=p.creaseAngle),p.autoSize!==void 0&&(e.autoSize=p.autoSize,e.autoSize&&!M&&typeof ResizeObserver<"u"?(M=new ResizeObserver(()=>A()),M.observe(n),A()):!e.autoSize&&M&&(M.disconnect(),M=null)),c()}function E(){return{...e}}function S(){let p=n.ownerDocument.createElement("span");p.textContent="M",p.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(p);let b=p.getBoundingClientRect();return p.remove(),{w:b.width||8,h:b.height||16}}function A(){let p=n.clientWidth,b=n.clientHeight;if(!p||!b)return;let l=S(),v=Math.max(20,Math.floor(p/l.w)),G=Math.max(8,Math.floor(b/l.h)),C=l.h/l.w,y=!1;e.cols!==v&&(e.cols=v,y=!0),e.rows!==G&&(e.rows=G,y=!0),Math.abs(e.cellAspect-C)>.01&&(e.cellAspect=C,y=!0),y&&c()}let M=null;e.autoSize&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(()=>A()),M.observe(n),A());function x(){M&&(M.disconnect(),M=null),i.clear(),n.contains(o)&&n.removeChild(o)}return c(),{get host(){return n},get output(){return r},get camera(){return e.camera},add:f,addHotspot:m,rerender:g,setOptions:L,getOptions:E,fit:A,destroy:x}}function de(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Ze(t.invert),i=t.animate??!1,a=!1,u=!1,c=null,h=null,d=null,f={x:0,y:0},m=n.camera;function g(l){if(!(!o||a)&&d===null&&l.isPrimary!==!1){l.preventDefault(),d=l.pointerId,f={x:l.clientX,y:l.clientY},e.style.cursor="grabbing";try{l.target.setPointerCapture(l.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function L(l){if(d===null||l.pointerId!==d||!o||a)return;l.preventDefault();let v=l.clientX-f.x,G=l.clientY-f.y;f={x:l.clientX,y:l.clientY};let C=s,w=1/4*Math.PI/180;m.rotY=m.rotY-v*w*C,m.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,m.rotX-G*w*C)),n.rerender()}function E(l){if(d===l.pointerId){d=null,e.style.cursor=o&&!a?"grab":"";try{l.target.releasePointerCapture(l.pointerId)}catch{}i&&(u=!1)}}function S(l){if(!r||a)return;l.preventDefault();let v=l.deltaY*.001;m.zoom=Math.max(.05,Math.min(10,m.zoom*(1-v))),n.rerender()}function A(l){if(!(a||!i)){if(!u){let v=h!==null?Math.min(l-h,50):16.67,G=typeof i=="object"&&i.speed?i.speed:.3,C=typeof i=="object"&&i.axis?i.axis:"y",y=G*(Math.PI/180)*(v/16.67);C==="y"?m.rotY=m.rotY+y:m.rotX=m.rotX+y,n.rerender()}h=l,c=requestAnimationFrame(A)}}function M(){c===null&&typeof requestAnimationFrame<"u"&&i&&(c=requestAnimationFrame(A))}function x(){c!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(c),c=null),h=null}function p(){e.addEventListener("pointerdown",g),e.addEventListener("pointermove",L),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),e.addEventListener("wheel",S,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function b(){e.removeEventListener("pointerdown",g),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.removeEventListener("wheel",S),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return p(),M(),{update(l){let v=!!i;o=l.drag??o,r=l.wheel??r,s=Ze(l.invert),i=l.animate??i,!a&&d===null&&(e.style.cursor=o?"grab":"");let G=!!i;v&&!G?x():!v&&G&&M()},pause(){a||(a=!0,b(),x(),d=null,u=!1)},resume(){a&&(a=!1,p(),M())},destroy(){a||b(),x(),a=!0}}}function Ze(n){return n===void 0||n===!1?1:n===!0?-1:n}function pe(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,s=Je(t.invert),i=t.animate??!1,a=!1,u=!1,c=null,h=null,d=null,f={x:0,y:0},m=!1,g=n.camera,L=1/4*Math.PI/180,E=.02;function S(y){if(!(!o||a)&&d===null&&y.isPrimary!==!1){y.preventDefault(),d=y.pointerId,f={x:y.clientX,y:y.clientY},m=y.button===2,e.style.cursor="grabbing";try{y.target.setPointerCapture(y.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(u=!0)}}function A(y){if(d===null||y.pointerId!==d||!o||a)return;y.preventDefault();let w=y.clientX-f.x,_=y.clientY-f.y;f={x:y.clientX,y:y.clientY};let P=s;if(m||y.shiftKey)g.rotY=g.rotY-w*L*P,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+_*L*P));else{let z=g.target;g.target=[z[0]-w*E/g.zoom,z[1]-_*E/g.zoom,z[2]]}n.rerender()}function M(y){if(d===y.pointerId){d=null,m=!1,e.style.cursor=o&&!a?"grab":"";try{y.target.releasePointerCapture(y.pointerId)}catch{}i&&(u=!1)}}function x(y){y.preventDefault()}function p(y){if(!r||a)return;y.preventDefault();let w=y.deltaY*.001;g.zoom=Math.max(.05,Math.min(10,g.zoom*(1-w))),n.rerender()}function b(y){if(!(a||!i)){if(!u){let w=h!==null?Math.min(y-h,50):16.67,_=typeof i=="object"&&i.speed?i.speed:.3,P=typeof i=="object"&&i.axis?i.axis:"y",z=_*(Math.PI/180)*(w/16.67);P==="y"?g.rotY=g.rotY+z:g.rotX=g.rotX+z,n.rerender()}h=y,c=requestAnimationFrame(b)}}function l(){c===null&&typeof requestAnimationFrame<"u"&&i&&(c=requestAnimationFrame(b))}function v(){c!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(c),c=null),h=null}function G(){e.addEventListener("pointerdown",S),e.addEventListener("pointermove",A),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("contextmenu",x),e.addEventListener("wheel",p,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function C(){e.removeEventListener("pointerdown",S),e.removeEventListener("pointermove",A),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("contextmenu",x),e.removeEventListener("wheel",p),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return G(),l(),{update(y){let w=!!i;o=y.drag??o,r=y.wheel??r,s=Je(y.invert),i=y.animate??i,!a&&d===null&&(e.style.cursor=o?"grab":"");let _=!!i;w&&!_?v():!w&&_&&l()},pause(){a||(a=!0,C(),v(),d=null,u=!1)},resume(){a&&(a=!1,G(),l())},destroy(){a||C(),v(),a=!0}}}function Je(n){return n===void 0||n===!1?1:n===!0?-1:n}function et(n,t={}){if(n.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");n.camera.eyeMode=!0;let e=n.host,o=t.drag??!0,r=t.keyboard??!0,s=t.moveSpeed??.05,i=t.lookSpeed??.004,a=Qe(t.invert),u=!1,c=null,h={x:0,y:0},d=new Set,f=null,m=n.camera;function g(l){if(!(!o||u)&&c===null){l.preventDefault(),c=l.pointerId,h={x:l.clientX,y:l.clientY};try{l.target.setPointerCapture(l.pointerId)}catch{}}}function L(l){if(c===null||l.pointerId!==c||!o||u)return;l.preventDefault();let v=l.clientX-h.x,G=l.clientY-h.y;h={x:l.clientX,y:l.clientY},m.rotY=m.rotY-v*i*a,m.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,m.rotX+G*i*a)),n.rerender()}function E(l){if(c===l.pointerId){c=null;try{l.target.releasePointerCapture(l.pointerId)}catch{}}}function S(l){r&&!u&&d.add(l.key.toLowerCase())}function A(l){d.delete(l.key.toLowerCase())}function M(){if(u||!r||d.size===0)return;let l=m.target,v=Math.cos(m.rotY),G=Math.sin(m.rotY),C=!1;(d.has("w")||d.has("arrowup"))&&(m.target=[l[0]-G*s,l[1]-v*s,l[2]],C=!0),(d.has("s")||d.has("arrowdown"))&&(m.target=[l[0]+G*s,l[1]+v*s,l[2]],C=!0),(d.has("a")||d.has("arrowleft"))&&(m.target=[l[0]-v*s,l[1]+G*s,l[2]],C=!0),(d.has("d")||d.has("arrowright"))&&(m.target=[l[0]+v*s,l[1]-G*s,l[2]],C=!0),C&&n.rerender()}function x(){u||(M(),f=requestAnimationFrame(x))}function p(){e.addEventListener("pointerdown",g),e.addEventListener("pointermove",L),e.addEventListener("pointerup",E),e.addEventListener("pointercancel",E),r&&(e.ownerDocument?.addEventListener("keydown",S),e.ownerDocument?.addEventListener("keyup",A)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(f=requestAnimationFrame(x))}function b(){e.removeEventListener("pointerdown",g),e.removeEventListener("pointermove",L),e.removeEventListener("pointerup",E),e.removeEventListener("pointercancel",E),e.ownerDocument?.removeEventListener("keydown",S),e.ownerDocument?.removeEventListener("keyup",A),e.style.touchAction="",e.style.userSelect="",f!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(f),f=null),d.clear(),n.camera.eyeMode=!1}return p(),{update(l){o=l.drag??o,r=l.keyboard??r,s=l.moveSpeed??s,i=l.lookSpeed??i,a=Qe(l.invert)},pause(){u||(u=!0,b(),c=null)},resume(){u&&(u=!1,p())},destroy(){u||b(),u=!0}}}function Qe(n){return n===void 0||n===!1?1:n===!0?-1:n}function tt(n,t){let e=n.querySelector(`[data-glyph-mesh-id="${CSS.escape(t)}"]`);return e instanceof HTMLElement?e:null}function ke(n,t,e){let o=n.getBoundingClientRect();return o.width<=0||o.height<=0?!1:t>=o.left&&t<=o.right&&e>=o.top&&e<=o.bottom}function nt(n,t,e){let o=(n instanceof Document,n),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let s of r)if(ke(s,t,e))return s;return null}var zt=typeof HTMLElement<"u"?HTMLElement:class{},Pt=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size"];function oe(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ot(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function kt(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var he=class extends zt{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Pt]}getScene(){return this._scene}_readOptions(){let e={},o=Ot(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=kt(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let i=oe(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let a=oe(this.getAttribute("rows"));a!==void 0&&(e.rows=a);let u=oe(this.getAttribute("cell-aspect"));u!==void 0&&(e.cellAspect=u);let c=oe(this.getAttribute("directional-intensity"));c!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:c});let h=oe(this.getAttribute("ambient-intensity"));return h!==void 0&&(e.ambientLight={intensity:h}),this.hasAttribute("auto-size")&&(e.autoSize=!0),e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=ue(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-perspective-camera> or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var U=require("@glyphcss/core"),Rt=typeof HTMLElement<"u"?HTMLElement:class{},It=["src","geometry","size","color","position","scale","rotation","normalize"];function Ft(n){let t=(0,U.computeSceneBbox)(n),e=(t.min[0]+t.max[0])/2,o=(t.min[1]+t.max[1])/2,r=(t.min[2]+t.max[2])/2,i=2/(Math.max(t.max[0]-t.min[0],t.max[1]-t.min[1],t.max[2]-t.min[2])||1);return n.map(a=>({...a,vertices:a.vertices.map(u=>[(u[0]-e)*i,(u[1]-o)*i,(u[2]-r)*i])}))}function Re(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Yt(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Re(n)}}function Dt(n){return n.closest("glyph-scene")??null}var me=class extends Rt{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...It]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:Re(this.getAttribute("position")),scale:Yt(this.getAttribute("scale")),rotation:Re(this.getAttribute("rotation"))}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=Dt(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,i;try{i=await(0,U.loadMesh)(e)}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}if(s!==this._loadToken){try{i.dispose()}catch{}return}let a=r.getScene();if(!a){try{i.dispose()}catch{}return}let c=this.hasAttribute("normalize")?Ft(i.polygons):i.polygons;this._handle=a.add(c,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:c},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let i=this.getAttribute("size"),a=i!==null?parseFloat(i):1,u=this.getAttribute("color")??void 0,c;try{c=(0,U.resolveGeometry)(o,{size:Number.isFinite(a)?a:1,color:u})}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}this._handle=s.add(c,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:c},bubbles:!0}))}}}};var Nt=typeof HTMLElement<"u"?HTMLElement:class{};function Xt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==3||t.some(e=>!Number.isFinite(e))))return[t[0],t[1],t[2]]}function Vt(n){if(!n)return;let t=n.split(",").map(e=>parseFloat(e.trim()));if(!(t.length!==2||t.some(e=>!Number.isFinite(e))))return[t[0],t[1]]}function Bt(n){return n.closest("glyph-scene")??null}var fe=class extends Nt{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=Xt(this.getAttribute("at"));if(!e)return;let o=Bt(this);if(!o)return;if(!o.getScene()){let u=()=>{o.removeEventListener("glyphcss:scene-ready",u),this._register()};o.addEventListener("glyphcss:scene-ready",u);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Vt(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let a=this._handle.el;for(;this.firstChild;)a.appendChild(this.firstChild)}};var Wt=typeof HTMLElement<"u"?HTMLElement:class{};function F(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ye=class extends Wt{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=j({rotX:F(this.getAttribute("rot-x")),rotY:F(this.getAttribute("rot-y")),distance:F(this.getAttribute("distance")),zoom:F(this.getAttribute("zoom")),stretch:F(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=F(this.getAttribute("rot-x")),a=F(this.getAttribute("rot-y")),u=F(this.getAttribute("distance")),c=F(this.getAttribute("zoom")),h=F(this.getAttribute("stretch")),d=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,d=!0),a!==void 0&&s.rotY!==a&&(s.rotY=a,d=!0),u!==void 0&&s.distance!==u&&(s.distance=u,d=!0),c!==void 0&&s.zoom!==c&&(s.zoom=c,d=!0),h!==void 0&&s.stretch!==h&&(s.stretch=h,d=!0),d&&this.querySelector("glyph-scene")?.rerender?.()}};var $t=typeof HTMLElement<"u"?HTMLElement:class{};function q(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ge=class extends $t{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=ee({rotX:q(this.getAttribute("rot-x")),rotY:q(this.getAttribute("rot-y")),zoom:q(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let i=q(this.getAttribute("rot-x")),a=q(this.getAttribute("rot-y")),u=q(this.getAttribute("zoom")),c=!1;i!==void 0&&s.rotX!==i&&(s.rotX=i,c=!0),a!==void 0&&s.rotY!==a&&(s.rotY=a,c=!0),u!==void 0&&s.zoom!==u&&(s.zoom=u,c=!0),c&&this.querySelector("glyph-scene")?.rerender?.()}};var jt=typeof HTMLElement<"u"?HTMLElement:class{};function Ut(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ie(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function qt(n){return n.closest("glyph-scene")??null}var be=class extends jt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Ie(this.getAttribute("drag")),o=Ie(this.getAttribute("wheel")),r=Ie(this.getAttribute("invert")),s=Ut(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{animate:{speed:s,axis:i}}:{}}}_attach(){if(this._controls)return;let e=qt(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=de(o,this._readOptions())}};var Kt=typeof HTMLElement<"u"?HTMLElement:class{};function Fe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Zt(n){return n.closest("glyph-scene")??null}var ve=class extends Kt{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Fe(this.getAttribute("drag")),o=Fe(this.getAttribute("wheel")),r=Fe(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Zt(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=pe(o,this._readOptions())}};T(H,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
62
+ `;function Te(t,n,e,o,r){return t.map(s=>{let[l,i,u]=n.project(s.at,e,o,r),d=u>-3&&l>=0&&l<e&&i>=0&&i<o;return{id:s.id,col:l,row:i,depth:u,visible:d}})}var ln=1;function an(t,n){let{position:e,scale:o,rotation:r}=n;if(!e&&!o&&!r)return t;let[s,l,i]=e??[0,0,0],u=1,d=1,h=1;o!==void 0&&(typeof o=="number"?u=d=h=o:[u,d,h]=o);let c=Math.PI/180,[f,g,y]=r??[0,0,0],w=f*c,M=g*c,_=y*c,G=Math.cos(w),P=Math.sin(w),v=Math.cos(M),E=Math.sin(M),L=Math.cos(_),a=Math.sin(_);function m(b){let C=b[0]*u,p=b[1]*d,x=b[2]*h,S=L*C-a*p,T=a*C+L*p,H=x;return C=v*S+E*H,p=T,x=-E*S+v*H,S=C,T=G*p-P*x,H=P*p+G*x,[S+s,T+l,H+i]}return t.map(b=>({...b,vertices:b.vertices.map(m)}))}function ze(t,n={}){Pe(t.ownerDocument??void 0);let e={mode:n.mode??"solid",glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,cols:n.cols??80,rows:n.rows??24,cellAspect:n.cellAspect??2,directionalLight:n.directionalLight??{direction:[-.5,-.7,-.5],intensity:1},ambientLight:n.ambientLight??{intensity:.4},camera:n.camera??pe(),smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60,autoSize:n.autoSize??!1,shadow:n.shadow},o=t.ownerDocument.createElement("div");o.className="glyph-scene";let r=t.ownerDocument.createElement("pre");r.className="glyph-output";let s=t.ownerDocument.createElement("div");s.className="glyph-hotspot-layer",o.appendChild(r),o.appendChild(s),t.appendChild(o);let l=new Map,i=[],u=!1,d={iA:[],iB:[],iC:[],lit:[]};function h(){d.iA.length=0,d.iB.length=0,d.iC.length=0,d.lit.length=0}function c(){u||(u=!0,Promise.resolve().then(()=>{u=!1,f()}))}function f(){let a=[],m=[],b=[];for(let H of l.values()){let k=an(H.polygons,H.transform),F=H.transform.castShadow??!1,K=H.transform.receiveShadow??!1;for(let I of k)a.push(I),m.push(F),b.push(K)}let C=He({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},polygons:a,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors,smoothShading:e.smoothShading,creaseAngle:e.creaseAngle,shadow:e.shadow,castShadowFlags:m,receiveShadowFlags:b});C.shadeCache=d;let p=globalThis.__glyphPerf,x=p?performance.now():0,S=Se(C),T=p?performance.now():0;if(e.useColors?r.innerHTML=S:r.textContent=S,p){let H=performance.now();(p.raster??(p.raster=[])).push(T-x),(p.dom??(p.dom=[])).push(H-T),(p.polys??(p.polys=[])).push(a.length)}g()}function g(){let{cols:a,rows:m,cellAspect:b,camera:C}=e,p=Te(i.map(H=>H.hotspot),C,a,m,b),x=r.getBoundingClientRect(),S=a>0?x.width/a:8,T=m>0?x.height/m:16;for(let H=0;H<i.length;H++){let{el:k}=i[H],F=p[H];F.visible?(k.style.display="",k.style.left=`${(F.col+.5)*S}px`,k.style.top=`${(F.row+.5)*T}px`,k.style.zIndex=String(Math.round(F.depth*1e3))):k.style.display="none"}}function y(a,m={}){let b=ln++;return l.set(b,{id:b,polygons:a,transform:m}),h(),c(),{get id(){return b},get name(){return l.get(b)?.transform.id},get polygons(){return a},setTransform(C){let p=l.get(b);p&&(p.transform=C,h(),c())},dispose(){l.delete(b),h(),c()}}}function w(a,m){let b=t.ownerDocument.createElement("div");b.className="glyph-hotspot",b.setAttribute("data-hotspot-id",a.id);let[C,p]=a.size??[1,1];b.style.position="absolute",b.style.width=`${C}ch`,b.style.height=`${p*e.cellAspect}ch`,m&&b.addEventListener("click",m),s.appendChild(b);let x={hotspot:{id:a.id,at:a.at,size:a.size},el:b,onClick:m};return i.push(x),c(),{get el(){return b},remove(){let S=i.indexOf(x);S>=0&&i.splice(S,1),m&&b.removeEventListener("click",m),s.removeChild(b),c()}}}function M(){f()}function _(a){a.mode!==void 0&&(e.mode=a.mode),a.glyphPalette!==void 0&&(e.glyphPalette=a.glyphPalette),a.useColors!==void 0&&(e.useColors=a.useColors),a.cols!==void 0&&(e.cols=a.cols),a.rows!==void 0&&(e.rows=a.rows),a.cellAspect!==void 0&&(e.cellAspect=a.cellAspect),a.directionalLight!==void 0&&(e.directionalLight=a.directionalLight),a.ambientLight!==void 0&&(e.ambientLight=a.ambientLight),a.camera!==void 0&&(e.camera=a.camera),a.smoothShading!==void 0&&(e.smoothShading=a.smoothShading),a.creaseAngle!==void 0&&(e.creaseAngle=a.creaseAngle),"shadow"in a&&(e.shadow=a.shadow),a.autoSize!==void 0&&(e.autoSize=a.autoSize,e.autoSize&&!E&&typeof ResizeObserver<"u"?(E=new ResizeObserver(()=>v()),E.observe(t),v()):!e.autoSize&&E&&(E.disconnect(),E=null)),(a.mode!==void 0||a.useColors!==void 0||a.directionalLight!==void 0||a.ambientLight!==void 0||a.smoothShading!==void 0||a.creaseAngle!==void 0||a.glyphPalette!==void 0)&&h(),c()}function G(){return{...e}}function P(){let m=t.ownerDocument.createElement("span");m.textContent=Array(20).fill("M").join(`
63
+ `),m.style.cssText="position:absolute;visibility:hidden;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre;padding:0;margin:0",r.appendChild(m);let b=m.getBoundingClientRect();return m.remove(),{w:b.width||8,h:b.height?b.height/20:16}}function v(){let a=t.clientWidth,m=t.clientHeight;if(!a||!m)return;let b=P(),C=Math.max(20,Math.floor(a/b.w)),p=Math.max(8,Math.floor(m/b.h)),x=b.h/b.w,S=!1;e.cols!==C&&(e.cols=C,S=!0),e.rows!==p&&(e.rows=p,S=!0),Math.abs(e.cellAspect-x)>.01&&(e.cellAspect=x,S=!0),S&&c()}let E=null;e.autoSize&&typeof ResizeObserver<"u"&&(E=new ResizeObserver(()=>v()),E.observe(t),v());function L(){E&&(E.disconnect(),E=null),l.clear(),t.contains(o)&&t.removeChild(o)}return c(),{get host(){return t},get output(){return r},get camera(){return e.camera},add:y,addHotspot:w,rerender:M,setOptions:_,getOptions:G,fit:v,destroy:L}}function Oe(t,n={}){let e=t.host,o=n.drag??!0,r=n.wheel??!0,s=Mt(n.invert),l=n.clampPitch??!0,i=n.animate??!1,u=!1,d=!1,h=null,c=null,f=null,g={x:0,y:0},y=t.camera;function w(m){if(!(!o||u)&&f===null&&m.isPrimary!==!1){m.preventDefault(),f=m.pointerId,g={x:m.clientX,y:m.clientY},e.style.cursor="grabbing";try{m.target.setPointerCapture(m.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(d=!0)}}function M(m){if(f===null||m.pointerId!==f||!o||u)return;m.preventDefault();let b=m.clientX-g.x,C=m.clientY-g.y;g={x:m.clientX,y:m.clientY};let p=s,x=1/4;y.rotY=y.rotY-b*x*p;let S=y.rotX-C*x*p;y.rotX=l?Math.max(-90,Math.min(90,S)):S,t.rerender()}function _(m){if(f===m.pointerId){f=null,e.style.cursor=o&&!u?"grab":"";try{m.target.releasePointerCapture(m.pointerId)}catch{}i&&(d=!1)}}function G(m){if(!r||u)return;m.preventDefault();let b=m.deltaY*.001;y.zoom=Math.max(.1,Math.min(500,y.zoom*(1-b))),t.rerender()}function P(m){if(!(u||!i)){if(!d){let b=c!==null?Math.min(m-c,50):16.67,C=typeof i=="object"&&i.speed?i.speed:.3,p=typeof i=="object"&&i.axis?i.axis:"y",x=C*(b/16.67);p==="y"?y.rotY=y.rotY+x:y.rotX=y.rotX+x,t.rerender()}c=m,h=requestAnimationFrame(P)}}function v(){h===null&&typeof requestAnimationFrame<"u"&&i&&(h=requestAnimationFrame(P))}function E(){h!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(h),h=null),c=null}function L(){e.addEventListener("pointerdown",w),e.addEventListener("pointermove",M),e.addEventListener("pointerup",_),e.addEventListener("pointercancel",_),e.addEventListener("wheel",G,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function a(){e.removeEventListener("pointerdown",w),e.removeEventListener("pointermove",M),e.removeEventListener("pointerup",_),e.removeEventListener("pointercancel",_),e.removeEventListener("wheel",G),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return L(),v(),{update(m){let b=!!i;o=m.drag??o,r=m.wheel??r,s=Mt(m.invert),m.clampPitch!==void 0&&(l=m.clampPitch),i=m.animate??i,!u&&f===null&&(e.style.cursor=o?"grab":"");let C=!!i;b&&!C?E():!b&&C&&v()},pause(){u||(u=!0,a(),E(),f=null,d=!1)},resume(){u&&(u=!1,L(),v())},destroy(){u||a(),E(),u=!0}}}function Mt(t){return t===void 0||t===!1?1:t===!0?-1:t}function Ie(t,n={}){let e=t.host,o=n.drag??!0,r=n.wheel??!0,s=xt(n.invert),l=n.animate??!1,i=!1,u=!1,d=null,h=null,c=null,f={x:0,y:0},g=!1,y=t.camera,w=1/4,M=.02;function _(p){if(!(!o||i)&&c===null&&p.isPrimary!==!1){p.preventDefault(),c=p.pointerId,f={x:p.clientX,y:p.clientY},g=p.button===2,e.style.cursor="grabbing";try{p.target.setPointerCapture(p.pointerId)}catch{}l&&l.pauseOnInteraction!==!1&&(u=!0)}}function G(p){if(c===null||p.pointerId!==c||!o||i)return;p.preventDefault();let x=p.clientX-f.x,S=p.clientY-f.y;f={x:p.clientX,y:p.clientY};let T=s;if(g||p.shiftKey)y.rotY=y.rotY-x*w*T,y.rotX=Math.max(-90,Math.min(90,y.rotX+S*w*T));else{let H=y.target;y.target=[H[0]-x*M/y.zoom,H[1]-S*M/y.zoom,H[2]]}t.rerender()}function P(p){if(c===p.pointerId){c=null,g=!1,e.style.cursor=o&&!i?"grab":"";try{p.target.releasePointerCapture(p.pointerId)}catch{}l&&(u=!1)}}function v(p){p.preventDefault()}function E(p){if(!r||i)return;p.preventDefault();let x=p.deltaY*.001;y.zoom=Math.max(.1,Math.min(500,y.zoom*(1-x))),t.rerender()}function L(p){if(!(i||!l)){if(!u){let x=h!==null?Math.min(p-h,50):16.67,S=typeof l=="object"&&l.speed?l.speed:.3,T=typeof l=="object"&&l.axis?l.axis:"y",H=S*(x/16.67);T==="y"?y.rotY=y.rotY+H:y.rotX=y.rotX+H,t.rerender()}h=p,d=requestAnimationFrame(L)}}function a(){d===null&&typeof requestAnimationFrame<"u"&&l&&(d=requestAnimationFrame(L))}function m(){d!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(d),d=null),h=null}function b(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",G),e.addEventListener("pointerup",P),e.addEventListener("pointercancel",P),e.addEventListener("contextmenu",v),e.addEventListener("wheel",E,{passive:!1}),e.style.cursor=o?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function C(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",P),e.removeEventListener("pointercancel",P),e.removeEventListener("contextmenu",v),e.removeEventListener("wheel",E),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return b(),a(),{update(p){let x=!!l;o=p.drag??o,r=p.wheel??r,s=xt(p.invert),l=p.animate??l,!i&&c===null&&(e.style.cursor=o?"grab":"");let S=!!l;x&&!S?m():!x&&S&&a()},pause(){i||(i=!0,C(),m(),c=null,u=!1)},resume(){i&&(i=!1,b(),a())},destroy(){i||C(),m(),i=!0}}}function xt(t){return t===void 0||t===!1?1:t===!0?-1:t}function Gt(t,n={}){if(t.camera.kind!=="perspective")throw new Error("glyphcss: GlyphFirstPersonControls requires a perspective camera. Use <GlyphPerspectiveCamera> (not <GlyphOrthographicCamera> / <GlyphCamera>).");t.camera.eyeMode=!0;let e=t.host,o=n.drag??!0,r=n.keyboard??!0,s=n.moveSpeed??.05,l=n.lookSpeed??.15,i=At(n.invert),u=!1,d=null,h={x:0,y:0},c=new Set,f=null,g=t.camera;function y(a){if(!(!o||u)&&d===null){a.preventDefault(),d=a.pointerId,h={x:a.clientX,y:a.clientY};try{a.target.setPointerCapture(a.pointerId)}catch{}}}function w(a){if(d===null||a.pointerId!==d||!o||u)return;a.preventDefault();let m=a.clientX-h.x,b=a.clientY-h.y;h={x:a.clientX,y:a.clientY},g.rotY=g.rotY-m*l*i,g.rotX=Math.max(-90,Math.min(90,g.rotX+b*l*i)),t.rerender()}function M(a){if(d===a.pointerId){d=null;try{a.target.releasePointerCapture(a.pointerId)}catch{}}}function _(a){r&&!u&&c.add(a.key.toLowerCase())}function G(a){c.delete(a.key.toLowerCase())}function P(){if(u||!r||c.size===0)return;let a=g.target,m=g.rotY*Math.PI/180,b=Math.cos(m),C=Math.sin(m),p=!1;(c.has("w")||c.has("arrowup"))&&(g.target=[a[0]-C*s,a[1]-b*s,a[2]],p=!0),(c.has("s")||c.has("arrowdown"))&&(g.target=[a[0]+C*s,a[1]+b*s,a[2]],p=!0),(c.has("a")||c.has("arrowleft"))&&(g.target=[a[0]-b*s,a[1]+C*s,a[2]],p=!0),(c.has("d")||c.has("arrowright"))&&(g.target=[a[0]+b*s,a[1]-C*s,a[2]],p=!0),p&&t.rerender()}function v(){u||(P(),f=requestAnimationFrame(v))}function E(){e.addEventListener("pointerdown",y),e.addEventListener("pointermove",w),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),r&&(e.ownerDocument?.addEventListener("keydown",_),e.ownerDocument?.addEventListener("keyup",G)),e.style.touchAction="none",e.style.userSelect="none",typeof requestAnimationFrame<"u"&&(f=requestAnimationFrame(v))}function L(){e.removeEventListener("pointerdown",y),e.removeEventListener("pointermove",w),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.ownerDocument?.removeEventListener("keydown",_),e.ownerDocument?.removeEventListener("keyup",G),e.style.touchAction="",e.style.userSelect="",f!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(f),f=null),c.clear(),t.camera.eyeMode=!1}return E(),{update(a){o=a.drag??o,r=a.keyboard??r,s=a.moveSpeed??s,l=a.lookSpeed??l,i=At(a.invert)},pause(){u||(u=!0,L(),d=null)},resume(){u&&(u=!1,E())},destroy(){u||L(),u=!0}}}function At(t){return t===void 0||t===!1?1:t===!0?-1:t}function St(t,n){let e=t.querySelector(`[data-glyph-mesh-id="${CSS.escape(n)}"]`);return e instanceof HTMLElement?e:null}function it(t,n,e){let o=t.getBoundingClientRect();return o.width<=0||o.height<=0?!1:n>=o.left&&n<=o.right&&e>=o.top&&e<=o.bottom}function Lt(t,n,e){let o=(t instanceof Document,t),r=Array.from(o.querySelectorAll(".glyph-mesh"));for(let s of r)if(it(s,n,e))return s;return null}var cn=typeof HTMLElement<"u"?HTMLElement:class{},un=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size","shadow","shadow-color","shadow-opacity","shadow-lift","shadow-max-extend"];function re(t){if(t==null)return;let n=parseFloat(t);return Number.isFinite(n)?n:void 0}function dn(t){if(t==="wireframe"||t==="solid"||t==="voxel")return t}function hn(t){if(t!==null){if(t==="false")return!1;if(t==="true"||t==="")return!0}}var Re=class extends cn{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...un]}getScene(){return this._scene}_readOptions(){let e={},o=dn(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let s=hn(this.getAttribute("use-colors"));s!==void 0&&(e.useColors=s);let l=re(this.getAttribute("cols"));l!==void 0&&(e.cols=l);let i=re(this.getAttribute("rows"));i!==void 0&&(e.rows=i);let u=re(this.getAttribute("cell-aspect"));u!==void 0&&(e.cellAspect=u);let d=re(this.getAttribute("directional-intensity"));d!==void 0&&(e.directionalLight={direction:[-.5,-.7,-.5],intensity:d});let h=re(this.getAttribute("ambient-intensity"));if(h!==void 0&&(e.ambientLight={intensity:h}),this.hasAttribute("auto-size")&&(e.autoSize=!0),this.hasAttribute("shadow")){let c={color:"#000000",opacity:.25,lift:.05,maxExtend:2e3},f=this.getAttribute("shadow-color");f&&(c.color=f);let g=re(this.getAttribute("shadow-opacity"));g!==void 0&&(c.opacity=g);let y=re(this.getAttribute("shadow-lift"));y!==void 0&&(c.lift=y);let w=re(this.getAttribute("shadow-max-extend"));w!==void 0&&(c.maxExtend=w),e.shadow=c}return e}_findCameraAncestor(){let e=this.parentElement;for(;e;){let o=e.tagName.toLowerCase();if(o==="glyph-perspective-camera"||o==="glyph-orthographic-camera"||o==="glyph-camera")return e;e=e.parentElement}return null}_initScene(e){let o=typeof e.getCamera=="function"?e.getCamera():void 0,r=this._readOptions();o&&(r.camera=o),this._scene=ze(this,r),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1}))}connectedCallback(){if(this._scene)return;let e=this._findCameraAncestor();if(!e)throw new Error("glyphcss: <glyph-scene> must be placed inside a <glyph-camera>, <glyph-perspective-camera>, or <glyph-orthographic-camera>.");if((typeof e.getCamera=="function"?e.getCamera():null)!==null)this._initScene(e);else{let r=()=>{e.removeEventListener("glyph:camera-ready",r),this._scene||this._initScene(e)};e.addEventListener("glyph:camera-ready",r)}}rerender(){this._scene?.rerender()}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,o,r){o!==r&&this._scene&&this._scene.setOptions(this._readOptions())}};var ye=require("@glyphcss/core"),pn=typeof HTMLElement<"u"?HTMLElement:class{},mn=["src","geometry","size","color","position","scale","rotation","normalize","cast-shadow","receive-shadow"];function fn(t){let n=(0,ye.computeSceneBbox)(t),e=(n.min[0]+n.max[0])/2,o=(n.min[1]+n.max[1])/2,r=(n.min[2]+n.max[2])/2,l=2/(Math.max(n.max[0]-n.min[0],n.max[1]-n.min[1],n.max[2]-n.min[2])||1);return t.map(i=>({...i,vertices:i.vertices.map(u=>[(u[0]-e)*l,(u[1]-o)*l,(u[2]-r)*l])}))}function st(t){if(!t)return;let n=t.split(",").map(e=>parseFloat(e.trim()));if(!(n.length!==3||n.some(e=>!Number.isFinite(e))))return[n[0],n[1],n[2]]}function yn(t){if(t){if(!t.includes(",")){let n=parseFloat(t);return Number.isFinite(n)?n:void 0}return st(t)}}function gn(t){return t.closest("glyph-scene")??null}var ke=class extends pn{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...mn]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,o,r){if(o!==r){if(e==="src"||e==="geometry"||e==="size"||e==="color"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:st(this.getAttribute("position")),scale:yn(this.getAttribute("scale")),rotation:st(this.getAttribute("rotation")),castShadow:this.hasAttribute("cast-shadow"),receiveShadow:this.hasAttribute("receive-shadow")}}_tearDown(){if(this._loadToken+=1,this._handle){try{this._handle.dispose()}catch{}this._handle=null}}async _maybeLoad(){let e=this.getAttribute("src"),o=this.getAttribute("geometry"),r=gn(this);if(r){if(!r.getScene()){let s=()=>{r.removeEventListener("glyphcss:scene-ready",s),this._maybeLoad()};r.addEventListener("glyphcss:scene-ready",s);return}if(e){let s=++this._loadToken,l;try{l=await(0,ye.loadMesh)(e)}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}if(s!==this._loadToken){try{l.dispose()}catch{}return}let i=r.getScene();if(!i){try{l.dispose()}catch{}return}let d=this.hasAttribute("normalize")?fn(l.polygons):l.polygons;this._handle=i.add(d,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:d},bubbles:!0}));return}if(o){let s=r.getScene();if(!s)return;let l=this.getAttribute("size"),i=l!==null?parseFloat(l):1,u=this.getAttribute("color")??void 0,d;try{d=(0,ye.resolveGeometry)(o,{size:Number.isFinite(i)?i:1,color:u})}catch(h){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:h,bubbles:!0}));return}this._handle=s.add(d,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{polygons:d},bubbles:!0}))}}}};var bn=typeof HTMLElement<"u"?HTMLElement:class{};function vn(t){if(!t)return;let n=t.split(",").map(e=>parseFloat(e.trim()));if(!(n.length!==3||n.some(e=>!Number.isFinite(e))))return[n[0],n[1],n[2]]}function En(t){if(!t)return;let n=t.split(",").map(e=>parseFloat(e.trim()));if(!(n.length!==2||n.some(e=>!Number.isFinite(e))))return[n[0],n[1]]}function wn(t){return t.closest("glyph-scene")??null}var Fe=class extends bn{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&this._unregister()}attributeChangedCallback(e,o,r){o!==r&&(this._handle&&this._unregister(),this._register())}_unregister(){if(!this._handle)return;let e=this._handle.el;for(;e.firstChild;)this.appendChild(e.firstChild);this._handle.remove(),this._handle=null}_register(){let e=vn(this.getAttribute("at"));if(!e)return;let o=wn(this);if(!o)return;if(!o.getScene()){let u=()=>{o.removeEventListener("glyphcss:scene-ready",u),this._register()};o.addEventListener("glyphcss:scene-ready",u);return}let r=o.getScene();if(!r)return;let s=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),l=En(this.getAttribute("size"));this._handle=r.addHotspot({id:s,at:e,size:l},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:s},bubbles:!0})));let i=this._handle.el;for(;this.firstChild;)i.appendChild(this.firstChild)}};var Cn=typeof HTMLElement<"u"?HTMLElement:class{};function U(t){if(t==null)return;let n=parseFloat(t);return Number.isFinite(n)?n:void 0}var Ye=class extends Cn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=pe({rotX:U(this.getAttribute("rot-x")),rotY:U(this.getAttribute("rot-y")),distance:U(this.getAttribute("distance")),zoom:U(this.getAttribute("zoom")),stretch:U(this.getAttribute("stretch"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=U(this.getAttribute("rot-x")),i=U(this.getAttribute("rot-y")),u=U(this.getAttribute("distance")),d=U(this.getAttribute("zoom")),h=U(this.getAttribute("stretch")),c=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,c=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,c=!0),u!==void 0&&s.distance!==u&&(s.distance=u,c=!0),d!==void 0&&s.zoom!==d&&(s.zoom=d,c=!0),h!==void 0&&s.stretch!==h&&(s.stretch=h,c=!0),c&&this.querySelector("glyph-scene")?.rerender?.()}};var Mn=typeof HTMLElement<"u"?HTMLElement:class{};function ge(t){if(t==null)return;let n=parseFloat(t);return Number.isFinite(n)?n:void 0}var De=class extends Mn{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Me({rotX:ge(this.getAttribute("rot-x")),rotY:ge(this.getAttribute("rot-y")),zoom:ge(this.getAttribute("zoom"))}),this.dispatchEvent(new CustomEvent("glyph:camera-ready",{bubbles:!1}))}disconnectedCallback(){this._camera=null}attributeChangedCallback(e,o,r){if(o===r)return;let s=this._camera;if(!s)return;let l=ge(this.getAttribute("rot-x")),i=ge(this.getAttribute("rot-y")),u=ge(this.getAttribute("zoom")),d=!1;l!==void 0&&s.rotX!==l&&(s.rotX=l,d=!0),i!==void 0&&s.rotY!==i&&(s.rotY=i,d=!0),u!==void 0&&s.zoom!==u&&(s.zoom=u,d=!0),d&&this.querySelector("glyph-scene")?.rerender?.()}};var xn=typeof HTMLElement<"u"?HTMLElement:class{};function An(t){if(t==null)return;let n=parseFloat(t);return Number.isFinite(n)?n:void 0}function Be(t){if(t!==null){if(t==="false")return!1;if(t==="true"||t==="")return!0}}function Gn(t){return t.closest("glyph-scene")??null}var Xe=class extends xn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert","clamp-pitch","animate-speed","animate-axis"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=Be(this.getAttribute("drag")),o=Be(this.getAttribute("wheel")),r=Be(this.getAttribute("invert")),s=Be(this.getAttribute("clamp-pitch")),l=An(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{},...s!==void 0?{clampPitch:s}:{},...l!==void 0?{animate:{speed:l,axis:i}}:{}}}_attach(){if(this._controls)return;let e=Gn(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Oe(o,this._readOptions())}};var Sn=typeof HTMLElement<"u"?HTMLElement:class{};function lt(t){if(t!==null){if(t==="false")return!1;if(t==="true"||t==="")return!0}}function Ln(t){return t.closest("glyph-scene")??null}var Ne=class extends Sn{constructor(){super(...arguments);this._controls=null}static get observedAttributes(){return["drag","wheel","invert"]}connectedCallback(){this._attach()}disconnectedCallback(){this._controls&&(this._controls.destroy(),this._controls=null)}attributeChangedCallback(e,o,r){o!==r&&this._controls?.update(this._readOptions())}_readOptions(){let e=lt(this.getAttribute("drag")),o=lt(this.getAttribute("wheel")),r=lt(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...o!==void 0?{wheel:o}:{},...r!==void 0?{invert:r}:{}}}_attach(){if(this._controls)return;let e=Ln(this);if(!e)return;let o=e.getScene();if(!o){let r=()=>{e.removeEventListener("glyphcss:scene-ready",r),this._attach()};e.addEventListener("glyphcss:scene-ready",r);return}this._controls=Ie(o,this._readOptions())}};O(z,require("@glyphcss/core"),module.exports);0&&(module.exports={DEFAULT_RAMP,GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement,SOLID_RAMP,WIREFRAME_GLYPHS,WIREFRAME_PALETTES,bakeFrames,buildRasterizeContext,createGlyphCamera,createGlyphFirstPersonControls,createGlyphMapControls,createGlyphOrbitControls,createGlyphOrthographicCamera,createGlyphPerspectiveCamera,createGlyphScene,findGlyphMeshHandle,findMeshUnderPoint,getWireframeGlyphs,injectGlyphBaseStyles,pointInMeshElement,projectHotspots,rasterize,...require("@glyphcss/core")});
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight } from './elements-DVWVBIG0.cjs';
2
- export { d as GlyphHotspotElement, e as GlyphHotspotHandle, f as GlyphHotspotOptions, g as GlyphMapControlsElement, h as GlyphMeshElement, i as GlyphMeshHandle, j as GlyphMeshTransform, k as GlyphOrbitControlsElement, l as GlyphOrthographicCameraElement, m as GlyphOrthographicCameraHandle, n as GlyphOrthographicCameraOptions, o as GlyphPerspectiveCameraElement, p as GlyphPerspectiveCameraHandle, q as GlyphPerspectiveCameraOptions, r as GlyphSceneElement, s as GlyphSceneOptions, t as createGlyphCamera, u as createGlyphOrthographicCamera, v as createGlyphPerspectiveCamera, w as createGlyphScene } from './elements-DVWVBIG0.cjs';
1
+ import { G as GlyphSceneHandle, a as GlyphCamera, b as GlyphDirectionalLight, c as GlyphAmbientLight, d as GlyphShadowOptions } from './elements-dJUvIMDN.cjs';
2
+ export { e as GlyphHotspotElement, f as GlyphHotspotHandle, g as GlyphHotspotOptions, h as GlyphMapControlsElement, i as GlyphMeshElement, j as GlyphMeshHandle, k as GlyphMeshTransform, l as GlyphOrbitControlsElement, m as GlyphOrthographicCameraElement, n as GlyphOrthographicCameraHandle, o as GlyphOrthographicCameraOptions, p as GlyphPerspectiveCameraElement, q as GlyphPerspectiveCameraHandle, r as GlyphPerspectiveCameraOptions, s as GlyphSceneElement, t as GlyphSceneOptions, u as createGlyphCamera, v as createGlyphOrthographicCamera, w as createGlyphPerspectiveCamera, x as createGlyphScene } from './elements-dJUvIMDN.cjs';
3
3
  import { Hotspot, HotspotCell, GridSize, Polygon, WireframeEdge, RenderMode, CharRamp } from '@glyphcss/core';
4
4
  export * from '@glyphcss/core';
5
5
 
@@ -7,8 +7,12 @@ export * from '@glyphcss/core';
7
7
  * createGlyphOrbitControls — orbit-mode camera input for a GlyphScene.
8
8
  *
9
9
  * Left-drag rotates rotX / rotY around the target (orbit). Wheel zooms or
10
- * dollies. Mirrors glyphcss's createPolyOrbitControls semantics, adapted for
10
+ * dollies. Mirrors voxcss's createPolyOrbitControls semantics, adapted for
11
11
  * the ASCII rasterizer's GlyphCamera instead of the CSS matrix3d camera.
12
+ *
13
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
14
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
15
+ * Animate speed: degrees per 60 Hz-equivalent frame.
12
16
  */
13
17
 
14
18
  interface GlyphOrbitControlsOptions {
@@ -18,6 +22,12 @@ interface GlyphOrbitControlsOptions {
18
22
  wheel?: boolean;
19
23
  /** Drag-direction inversion. Default: false. */
20
24
  invert?: boolean | number;
25
+ /**
26
+ * Clamp vertical drag to ±90° (camera stays above the equator, never
27
+ * flipping past either pole). Default: true. Set to false for globe-style
28
+ * unrestricted tumbling.
29
+ */
30
+ clampPitch?: boolean;
21
31
  /** Auto-rotate. Pass false or omit to disable. */
22
32
  animate?: false | {
23
33
  speed?: number;
@@ -37,8 +47,12 @@ declare function createGlyphOrbitControls(scene: GlyphSceneHandle, options?: Gly
37
47
  * createGlyphMapControls — map/pan-mode camera input for a GlyphScene.
38
48
  *
39
49
  * Left-drag pans the target (slippy-map semantics). Right-drag or
40
- * Shift+left-drag orbits. Wheel zooms. Mirrors glyphcss's createPolyMapControls
50
+ * Shift+left-drag orbits. Wheel zooms. Mirrors voxcss's createPolyMapControls
41
51
  * semantics, adapted for the ASCII rasterizer's GlyphCamera.
52
+ *
53
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
54
+ * Drag sensitivity: 4 px per degree (POINTER_DRAG_SPEED = 4).
55
+ * Animate speed: degrees per 60 Hz-equivalent frame.
42
56
  */
43
57
 
44
58
  interface GlyphMapControlsOptions {
@@ -68,12 +82,17 @@ declare function createGlyphMapControls(scene: GlyphSceneHandle, options?: Glyph
68
82
  * detach, restores `eyeMode = false`.
69
83
  *
70
84
  * Mouse-drag looks around (rotX/rotY). WASD or arrow keys move forward/backward/strafe.
85
+ *
86
+ * rotX and rotY are in DEGREES (three.js / voxcss convention).
87
+ * lookSpeed: degrees per pixel. Default: 0.15.
88
+ * moveSpeed: world units per frame.
71
89
  */
72
90
 
73
91
  interface GlyphFirstPersonControlsOptions {
74
92
  drag?: boolean;
75
93
  keyboard?: boolean;
76
94
  moveSpeed?: number;
95
+ /** Mouselook sensitivity in degrees per pixel. Default: 0.15. */
77
96
  lookSpeed?: number;
78
97
  invert?: boolean | number;
79
98
  }
@@ -184,6 +203,25 @@ interface RasterizeContextOptions {
184
203
  * shading; `180` smooths every shared vertex. Default `60`.
185
204
  */
186
205
  creaseAngle?: number;
206
+ shadow?: GlyphShadowOptions;
207
+ /** Per-polygon cast flag (parallel to `polygons` array). True = this poly's mesh has castShadow. */
208
+ castShadowFlags?: boolean[];
209
+ /** Per-polygon receive flag (parallel to `polygons` array). True = this poly's mesh has receiveShadow. */
210
+ receiveShadowFlags?: boolean[];
211
+ }
212
+ /**
213
+ * Cross-frame per-triangle shading cache. The Lambert intensities and lit
214
+ * color depend only on world-space normals + light, never the camera — so
215
+ * during a camera-only change (orbit/zoom drag) they are identical frame to
216
+ * frame. Parallel arrays indexed by positional triangle order; lazily filled
217
+ * as triangles become visible. The scene clears it when geometry, light, or
218
+ * shading options change. Absent/null → always recompute (current behavior).
219
+ */
220
+ interface ShadeCache {
221
+ iA: number[];
222
+ iB: number[];
223
+ iC: number[];
224
+ lit: (string | null)[];
187
225
  }
188
226
  interface RasterizeContext {
189
227
  camera: GlyphCamera;
@@ -198,6 +236,11 @@ interface RasterizeContext {
198
236
  useColors: boolean;
199
237
  smoothShading: boolean;
200
238
  creaseAngle: number;
239
+ shadow: GlyphShadowOptions | undefined;
240
+ castShadowFlags: boolean[];
241
+ receiveShadowFlags: boolean[];
242
+ /** Optional cross-frame shading cache (see {@link ShadeCache}). */
243
+ shadeCache?: ShadeCache | null;
201
244
  }
202
245
  declare function buildRasterizeContext(opts: RasterizeContextOptions): RasterizeContext;
203
246
 
@@ -252,4 +295,4 @@ declare function getWireframeGlyphs(name: string): WireframeGlyphTiers;
252
295
 
253
296
  declare function injectGlyphBaseStyles(doc?: Document): void;
254
297
 
255
- export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };
298
+ export { DEFAULT_RAMP, GlyphAmbientLight, GlyphCamera, GlyphDirectionalLight, type GlyphEventHandler, type GlyphFirstPersonControlsHandle, type GlyphFirstPersonControlsOptions, type GlyphMapControlsHandle, type GlyphMapControlsOptions, type GlyphMouseEvent, type GlyphOrbitControlsHandle, type GlyphOrbitControlsOptions, type GlyphPointerEvent, GlyphSceneHandle, GlyphShadowOptions, type GlyphWheelEvent, type RasterizeContext, type RasterizeContextOptions, SOLID_RAMP, WIREFRAME_GLYPHS, WIREFRAME_PALETTES, type WireframeGlyphTiers, bakeFrames, buildRasterizeContext, createGlyphFirstPersonControls, createGlyphMapControls, createGlyphOrbitControls, findGlyphMeshHandle, findMeshUnderPoint, getWireframeGlyphs, injectGlyphBaseStyles, pointInMeshElement, projectHotspots, rasterize };