glyphcss 0.0.1 → 0.0.2

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.cjs CHANGED
@@ -1,9 +1,17 @@
1
- "use strict";var B=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var Ie=(n,t)=>{for(var e in t)B(n,e,{get:t[e],enumerable:!0})},ke=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Oe(t))!Re.call(n,s)&&s!==e&&B(n,s,{get:()=>t[s],enumerable:!(r=Pe(t,s))||r.enumerable});return n};var Ye=n=>ke(B({},"__esModule",{value:!0}),n);var yt={};Ie(yt,{GlyphcssHotspotElement:()=>I,GlyphcssMapControlsElement:()=>z,GlyphcssMeshElement:()=>R,GlyphcssOrbitControlsElement:()=>X,GlyphcssOrthographicCameraElement:()=>F,GlyphcssPerspectiveCameraElement:()=>Y,GlyphcssSceneElement:()=>O});module.exports=Ye(yt);function oe(n,t,e){let r=Math.cos(t),s=Math.sin(t),c=r*n[1]-s*n[0],i=s*n[1]+r*n[0],o=n[2],a=Math.cos(e),l=Math.sin(e),f=a*i-l*o,m=l*i+a*o;return[c,f,m]}function V(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,scale:n.scale??.4,stretch:n.stretch??1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=oe(a,t.rotY,t.rotX),f=30,m=1.5,E=l[2]*f,g=.001,h=1-E/t.distance;if(h<g)return[NaN,NaN,l[2]];let G=1/h,M=Math.min(c,i)*t.scale*m*G,_=c*e+l[0]*M*o*t.stretch,d=i*r+l[1]*M;return[_,d,l[2]]}}}function le(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,scale:n.zoom??.4,stretch:1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=oe(a,t.rotY,t.rotX),m=Math.min(c,i)*t.scale*1.5,E=c*e+l[0]*m*o*t.stretch,g=i*r+l[1]*m;return[E,g,l[2]]}}}var ce=require("@glyphcss/core"),Fe={direction:[.5,.7,.5],intensity:1},Xe={intensity:.4};function ae(n){let t=n.triangles??[],e=n.mode??(t.length?"solid":"wireframe"),r=n.wireframe??(e==="wireframe"?(0,ce.trianglesToFeatureEdges)(t):[]);return{camera:n.camera,grid:n.grid,triangles:t,wireframe:r,mode:e,directionalLight:n.directionalLight??Fe,ambientLight:n.ambientLight??Xe,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0}}var Et=" .:-=+*#%@".split(""),Gt=" .:-=+*#%@".split(""),j={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("")}},Mt=j.default;function W(n){return j[n]??j.default}function ue(n){let{camera:t,grid:e,wireframe:r,triangles:s,mode:c,directionalLight:i,ambientLight:o}=n,{cols:a,rows:l,cellAspect:f}=e;if(c==="solid")return ze(n,a,l,f);let m=W(n.glyphPalette),E=new Uint8Array(a*l),g=n.useColors?new Array(a*l).fill(null):null;for(let h of r){let G=t.project(h.from,a,l,f),M=t.project(h.to,a,l,f);G[0]!==G[0]||M[0]!==M[0]||De(E,g,G[0]|0,G[1]|0,M[0]|0,M[1]|0,h.weight??2,h.color??null,a,l)}return Be(E,g,a,l,m)}function ze(n,t,e,r){let{camera:s,triangles:c,directionalLight:i,ambientLight:o}=n,a=W(n.glyphPalette).solid,l=new Array(t*e).fill(" "),f=n.useColors,m=f?new Array(t*e).fill(null):null,E=new Float64Array(t*e).fill(-1/0),g=i.direction,h=Math.hypot(g[0],g[1],g[2])||1,G=g[0]/h,M=g[1]/h,_=g[2]/h,d=i.intensity??1,b=o.intensity??.4,v=U(i.color??"#ffffff"),L=U(o.color??"#ffffff");for(let y of c){let[u,C,A]=y.vertices,T=s.project(u,t,e,r),p=s.project(C,t,e,r),x=s.project(A,t,e,r);if(T[0]!==T[0]||p[0]!==p[0]||x[0]!==x[0])continue;let S=C[0]-u[0],w=C[1]-u[1],H=C[2]-u[2],Q=A[0]-u[0],ee=A[1]-u[1],te=A[2]-u[2],ne=w*te-H*ee,se=H*Q-S*te,re=S*ee-w*Q,Ee=Math.hypot(ne,se,re)||1,Ge=(ne*G+se*M+re*_)/Ee,N=Math.max(0,Ge)*d,Me=Math.min(1,Math.max(0,b+N)),xe=Math.min(a.length-1,Me*(a.length-1)|0),Le=a[xe],ie=null;if(f){let D=y.color?U(y.color):[255,255,255],Ae=b*L[0]/255+N*v[0]/255,Te=b*L[1]/255+N*v[1]/255,_e=b*L[2]/255+N*v[2]/255,Se=Math.min(255,D[0]*Ae),He=Math.min(255,D[1]*Te),we=Math.min(255,D[2]*_e);ie=`#${$(Se)}${$(He)}${$(we)}`}let Ce=(T[2]+p[2]+x[2])/3;Ne(T[0],T[1],p[0],p[1],x[0],x[1],Ce,Le,ie,l,m,E,t,e)}return Ve(l,m,t,e)}function Ne(n,t,e,r,s,c,i,o,a,l,f,m,E,g){let h=n,G=t,M=e,_=r,d=s,b=c;if(_<G){let y=h;h=M,M=y,y=G,G=_,_=y}if(b<G){let y=h;h=d,d=y,y=G,G=b,b=y}if(b<_){let y=M;M=d,d=y,y=_,_=b,b=y}let v=Math.max(0,Math.ceil(G)),L=Math.min(g-1,Math.floor(b));if(!(v>L))for(let y=v;y<=L;y++){let u=(y-G)/(b-G||1),C=h+(d-h)*u,A;if(y<_){let x=(y-G)/(_-G||1);A=h+(M-h)*x}else{let x=(y-_)/(b-_||1);A=M+(d-M)*x}let T=Math.max(0,Math.ceil(Math.min(C,A))),p=Math.min(E-1,Math.floor(Math.max(C,A)));for(let x=T;x<=p;x++){let S=y*E+x;i>m[S]&&(m[S]=i,l[S]=o,f&&(f[S]=a))}}}function Ve(n,t,e,r){let s=[],c=null,i="",o=()=>{i&&(c!==null?s.push(`<span style="color:${c}">${i}</span>`):s.push(i),i="")};for(let a=0;a<r;a++){for(let l=0;l<e;l++){let f=a*e+l,m=n[f],E=t&&m!==" "?t[f]??null:null;E!==c&&(o(),c=E),i+=m}o(),c=null,a<r-1&&s.push(`
2
- `)}return s.join("")}function De(n,t,e,r,s,c,i,o,a,l){let f=Math.abs(s-e),m=-Math.abs(c-r),E=e<s?1:-1,g=r<c?1:-1,h=f+m;for(;;){if(e>=0&&e<a&&r>=0&&r<l){let M=r*a+e;n[M]<i&&(n[M]=i,t&&(t[M]=o))}if(e===s&&r===c)break;let G=2*h;G>=m&&(h+=m,e+=E),G<=f&&(h+=f,r+=g)}}function Be(n,t,e,r,s){let c=[],i=null,o="",a=()=>{o&&(i!==null?c.push(`<span style="color:${i}">${o}</span>`):c.push(o),o="")};for(let l=0;l<r;l++){for(let f=0;f<e;f++){let m=l*e+f,E=n[m],g,h;E===0?(g=" ",h=null):(g=E===1?s.thin[Math.random()*s.thin.length|0]:E===2?s.normal[Math.random()*s.normal.length|0]:s.core[Math.random()*s.core.length|0],h=t?t[m]??null:null),h!==i&&(a(),i=h),o+=g}a(),i=null,l<r-1&&c.push(`
3
- `)}return c.join("")}function U(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),s=parseInt(t[2]+t[2],16);return[e||0,r||0,s||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return[e||0,r||0,s||0]}return[255,255,255]}function $(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var pe="glyphcss-styles";function de(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(pe))return;let e=t.createElement("style");e.id=pe,e.textContent=je,t.head.appendChild(e)}var je=`
1
+ "use strict";var ve=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var ot=(n,t)=>{for(var e in t)ve(n,e,{get:t[e],enumerable:!0})},it=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of nt(t))!rt.call(n,r)&&r!==e&&ve(n,r,{get:()=>t[r],enumerable:!(o=tt(t,r))||o.enumerable});return n};var st=n=>it(ve({},"__esModule",{value:!0}),n);var Xt={};ot(Xt,{GlyphHotspotElement:()=>te,GlyphMapControlsElement:()=>oe,GlyphMeshElement:()=>ee,GlyphOrbitControlsElement:()=>re,GlyphOrthographicCameraElement:()=>j,GlyphPerspectiveCameraElement:()=>ne,GlyphSceneElement:()=>Q});module.exports=st(Xt);function He(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 le(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=He(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 Pe(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=He(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 lt={direction:[.5,.7,.5],intensity:1},at={intensity:.4};function ct(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 Oe(n){let t=n.polygons??[],e=n.mode??(t.length?"solid":"wireframe"),o=n.wireframe??(e==="wireframe"?ct(t):[]);return{camera:n.camera,grid:n.grid,polygons:t,wireframe:o,mode:e,directionalLight:n.directionalLight??lt,ambientLight:n.ambientLight??at,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0,smoothShading:n.smoothShading??!1,creaseAngle:n.creaseAngle??60}}var Bt=" .:-=+*#%@".split(""),$t=" .:-=+*#%@".split(""),Ee={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("")}},Wt=Ee.default;function Me(n){return Ee[n]??Ee.default}function Re(n){let{camera:t,grid:e,wireframe:o,mode:r}=n,{cols:a,rows:i,cellAspect:s}=e;if(r==="solid")return ut(n,a,i,s);let c=Me(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]||ft(l,p,f[0]|0,f[1]|0,y[0]|0,y[1]|0,h.weight??2,h.color??null,a,i)}return yt(l,p,a,i,c)}function ut(n,t,e,o){let{camera:r,polygons:a,directionalLight:i,ambientLight:s,smoothShading:c,creaseAngle:l}=n,p=Me(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=Ae(i.color??"#ffffff"),v=Ae(s.color??"#ffffff"),A=c&&l>0?pt(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],ae=P[2]-H[2],U=N[0]-H[0],F=N[1]-H[1],ie=N[2]-H[2],se=B*ie-ae*F,q=ae*U-X*ie,we=X*F-B*U,ce=Math.hypot(se,q,we)||1,Be=se/ce,$e=q/ce,We=we/ce,ue,de,he,pe,me,fe,ye,ge,be;if(A){let Z=A[G],D=Z[0],V=Z[z],K=Z[I];ue=D[0],de=D[1],he=D[2],pe=V[0],me=V[1],fe=V[2],ye=K[0],ge=K[1],be=K[2]}else ue=pe=ye=Be,de=me=ge=$e,he=fe=be=We;let je=ue*x+de*M+he*C,Ue=pe*x+me*M+fe*C,qe=ye*x+ge*M+be*C,_e=Math.min(1,b+Math.max(0,je)*d),Se=Math.min(1,b+Math.max(0,Ue)*d),ze=Math.min(1,b+Math.max(0,qe)*d),Te=null;if(y){let Z=(_e+Se+ze)/3,D=Math.max(0,Z-b),V=m.color?Ae(m.color):[255,255,255],K=b*v[0]/255+D*u[0]/255,Ze=b*v[1]/255+D*u[1]/255,Ke=b*v[2]/255+D*u[2]/255,Je=Math.min(255,V[0]*K),Qe=Math.min(255,V[1]*Ze),et=Math.min(255,V[2]*Ke);Te=`#${Ce(Je)}${Ce(Qe)}${Ce(et)}`}ht(O[0],O[1],O[2],_e,R[0],R[1],R[2],Se,Y[0],Y[1],Y[2],ze,p,h,Te,f,g,L,t,e)}}return mt(f,g,t,e)}var dt=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 ht(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,U=(B<0?0:B>1?1:B)*y,F=U|0,ie=U-F,se=dt[(z&3)*4+(H&3)],q=ie>se&&F<y?F+1:F;L[X]=f[q>y?y:q],E&&(E[X]=g)}}}}function pt(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 mt(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 ft(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 yt(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 Ae(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 Ce(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 Ie(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=gt,t.head.appendChild(e)}var gt=`
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
+
6
+ .glyph-host {
7
+ /* Fill the camera wrapper so autoSize can observe a non-zero height. */
8
+ width: 100%;
9
+ height: 100%;
10
+ }
11
+
4
12
  /* \u2500\u2500 Glyphcss scene container \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
13
 
6
- .glyphcss-scene {
14
+ .glyph-scene {
7
15
  position: relative;
8
16
  display: block;
9
17
  overflow: hidden;
@@ -12,8 +20,12 @@
12
20
 
13
21
  /* \u2500\u2500 ASCII output <pre> \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\u2500\u2500\u2500\u2500\u2500\u2500 */
14
22
 
15
- .glyphcss-scene .glyphcss-output {
16
- display: block;
23
+ .glyph-scene .glyph-output {
24
+ /* inline-block so the box shrinks to the text's natural width. With display:
25
+ block the pre inherits parent width, leaving empty space on the right, and
26
+ cellW = preRect.width / cols overshoots the actual character cell \u2014 placing
27
+ hotspots to the right of the rasterized glyph they're supposed to anchor. */
28
+ display: inline-block;
17
29
  margin: 0;
18
30
  padding: 0;
19
31
  font-family: monospace;
@@ -27,15 +39,24 @@
27
39
 
28
40
  /* \u2500\u2500 Hotspot overlay \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
29
41
 
30
- .glyphcss-scene .glyphcss-hotspot-layer {
42
+ .glyph-scene .glyph-hotspot-layer {
31
43
  position: absolute;
32
44
  inset: 0;
33
45
  pointer-events: none;
46
+ /* Isolate the stacking context so per-hotspot z-index values (derived from
47
+ camera depth, sometimes negative) stay scoped INSIDE the layer. Without
48
+ this, a negative-z-index hotspot would render below the sibling <pre>,
49
+ hidden behind the rasterized glyphs. */
50
+ isolation: isolate;
34
51
  }
35
52
 
36
- .glyphcss-scene .glyphcss-hotspot {
53
+ .glyph-scene .glyph-hotspot {
37
54
  position: absolute;
38
55
  pointer-events: all;
39
56
  cursor: pointer;
57
+ /* Center the label on the projected anchor point rather than anchoring its
58
+ top-left corner there. Without this, padding / label width visually offset
59
+ the content from the 3D vertex being labelled. */
60
+ transform: translate(-50%, -50%);
40
61
  }
41
- `;function he(n,t,e,r,s){return n.map(c=>{let[i,o,a]=t.project(c.at,e,r,s),l=a>-3&&i>=0&&i<e&&o>=0&&o<r;return{id:c.id,col:i,row:o,depth:a,visible:l}})}var We=1;function Ue(n,t){let{position:e,scale:r,rotation:s}=t;if(!e&&!r&&!s)return n;let[c,i,o]=e??[0,0,0],a=1,l=1,f=1;r!==void 0&&(typeof r=="number"?a=l=f=r:[a,l,f]=r);let[m,E,g]=s??[0,0,0],h=Math.cos(m),G=Math.sin(m),M=Math.cos(E),_=Math.sin(E),d=Math.cos(g),b=Math.sin(g);function v(L){let y=L[0]*a,u=L[1]*l,C=L[2]*f,A=d*y-b*u,T=b*y+d*u,p=C;return y=M*A+_*p,u=T,C=-_*A+M*p,A=y,T=h*u-G*C,p=G*u+h*C,[A+c,T+i,p+o]}return n.map(L=>({...L,vertices:[v(L.vertices[0]),v(L.vertices[1]),v(L.vertices[2])]}))}function me(n,t={}){de(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??V()},r=n.ownerDocument.createElement("div");r.className="glyphcss-scene";let s=n.ownerDocument.createElement("pre");s.className="glyphcss-output";let c=n.ownerDocument.createElement("div");c.className="glyphcss-hotspot-layer",r.appendChild(s),r.appendChild(c),n.appendChild(r);let i=new Map,o=[],a=!1;function l(){a||(a=!0,Promise.resolve().then(()=>{a=!1,f()}))}function f(){let d=[];for(let L of i.values()){let y=Ue(L.triangles,L.transform);for(let u of y)d.push(u)}let b=ae({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},triangles:d,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors}),v=ue(b);e.useColors?s.innerHTML=v:s.textContent=v,m()}function m(){let{cols:d,rows:b,cellAspect:v,camera:L}=e,y=he(o.map(T=>T.hotspot),L,d,b,v),u=s.getBoundingClientRect(),C=d>0?u.width/d:8,A=b>0?u.height/b:16;for(let T=0;T<o.length;T++){let{el:p}=o[T],x=y[T];x.visible?(p.style.display="",p.style.left=`${x.col*C}px`,p.style.top=`${x.row*A}px`,p.style.zIndex=String(Math.round(x.depth*1e3))):p.style.display="none"}}function E(d,b={}){let v=We++;return i.set(v,{id:v,triangles:d,transform:b}),l(),{get id(){return v},get triangles(){return d},setTransform(L){let y=i.get(v);y&&(y.transform=L,l())},dispose(){i.delete(v),l()}}}function g(d,b){let v=n.ownerDocument.createElement("div");v.className="glyphcss-hotspot",v.setAttribute("data-hotspot-id",d.id);let[L,y]=d.size??[1,1];v.style.position="absolute",v.style.width=`${L}ch`,v.style.height=`${y*e.cellAspect}ch`,b&&v.addEventListener("click",b),c.appendChild(v);let u={hotspot:{id:d.id,at:d.at,size:d.size},el:v,onClick:b};return o.push(u),l(),{remove(){let C=o.indexOf(u);C>=0&&o.splice(C,1),b&&v.removeEventListener("click",b),c.removeChild(v),l()}}}function h(){f()}function G(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),l()}function M(){return{...e}}function _(){i.clear(),n.contains(r)&&n.removeChild(r)}return l(),{get host(){return n},get output(){return s},get camera(){return e.camera},add:E,addHotspot:g,rerender:h,setOptions:G,getOptions:M,destroy:_}}var $e=typeof HTMLElement<"u"?HTMLElement:class{},qe=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity"];function P(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ze(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Ke(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var O=class extends $e{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...qe]}getScene(){return this._scene}_readOptions(){let e={},r=Ze(this.getAttribute("mode"));r!==void 0&&(e.mode=r);let s=this.getAttribute("glyph-palette");s&&(e.glyphPalette=s);let c=Ke(this.getAttribute("use-colors"));c!==void 0&&(e.useColors=c);let i=P(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let o=P(this.getAttribute("rows"));o!==void 0&&(e.rows=o);let a=P(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let l=P(this.getAttribute("directional-intensity"));l!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:l});let f=P(this.getAttribute("ambient-intensity"));return f!==void 0&&(e.ambientLight={intensity:f}),e}connectedCallback(){this._scene||(this._scene=me(this,this._readOptions()),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1})))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,r,s){r!==s&&this._scene&&this._scene.setOptions(this._readOptions())}};var fe=require("@glyphcss/core"),Je=typeof HTMLElement<"u"?HTMLElement:class{},Qe=["src","position","scale","rotation"];function q(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 et(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return q(n)}}function tt(n){return n.closest("glyphcss-scene")??null}function nt(n){let t=[[0,0],[0,0],[0,0]],e=[];for(let r of n){let s=r.vertices;if(!(s.length<3))for(let c=1;c<s.length-1;c++)e.push({vertices:[s[0],s[c],s[c+1]],uvs:t,...r.color?{color:r.color}:{}})}return e}var R=class extends Je{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...Qe]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,r,s){if(r!==s){if(e==="src"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:q(this.getAttribute("position")),scale:et(this.getAttribute("scale")),rotation:q(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");if(!e)return;let r=tt(this);if(!r)return;let s=++this._loadToken,c;try{c=await(0,fe.loadMesh)(e)}catch(a){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:a,bubbles:!0}));return}if(s!==this._loadToken){try{c.dispose()}catch{}return}let i=r.getScene();if(!i){try{c.dispose()}catch{}return}let o=nt(c.polygons);this._handle=i.add(o,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{triangles:o},bubbles:!0}))}};var st=typeof HTMLElement<"u"?HTMLElement:class{};function rt(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 it(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 ot(n){return n.closest("glyphcss-scene")??null}var I=class extends st{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&(this._handle.remove(),this._handle=null)}attributeChangedCallback(e,r,s){r!==s&&(this._handle&&(this._handle.remove(),this._handle=null),this._register())}_register(){let e=rt(this.getAttribute("at"));if(!e)return;let s=ot(this)?.getScene();if(!s)return;let c=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=it(this.getAttribute("size"));this._handle=s.addHotspot({id:c,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:c},bubbles:!0})))}};var lt=typeof HTMLElement<"u"?HTMLElement:class{};function k(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ct(n){return n.closest("glyphcss-scene")??null}var Y=class extends lt{static get observedAttributes(){return["rot-x","rot-y","distance","scale","stretch"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=ct(this)?.getScene();if(!e)return;let r=V({rotX:k(this.getAttribute("rot-x")),rotY:k(this.getAttribute("rot-y")),distance:k(this.getAttribute("distance")),scale:k(this.getAttribute("scale")),stretch:k(this.getAttribute("stretch"))});e.setOptions({camera:r})}};var at=typeof HTMLElement<"u"?HTMLElement:class{};function Z(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function ut(n){return n.closest("glyphcss-scene")??null}var F=class extends at{static get observedAttributes(){return["rot-x","rot-y","zoom"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=ut(this)?.getScene();if(!e)return;let r=le({rotX:Z(this.getAttribute("rot-x")),rotY:Z(this.getAttribute("rot-y")),zoom:Z(this.getAttribute("zoom"))});e.setOptions({camera:r})}};function ge(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=ye(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=n.camera;function h(u){if(!(!r||o)&&m===null&&u.isPrimary!==!1){u.preventDefault(),m=u.pointerId,E={x:u.clientX,y:u.clientY},e.style.cursor="grabbing";try{u.target.setPointerCapture(u.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function G(u){if(m===null||u.pointerId!==m||!r||o)return;u.preventDefault();let C=u.clientX-E.x,A=u.clientY-E.y;E={x:u.clientX,y:u.clientY};let T=c,x=1/4*Math.PI/180;g.rotY=g.rotY-C*x*T,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+A*x*T)),n.rerender()}function M(u){if(m===u.pointerId){m=null,e.style.cursor=r&&!o?"grab":"";try{u.target.releasePointerCapture(u.pointerId)}catch{}i&&(a=!1)}}function _(u){if(!s||o)return;u.preventDefault();let C=u.deltaY*.001;g.scale=Math.max(.05,Math.min(10,g.scale*(1-C))),n.rerender()}function d(u){if(!(o||!i)){if(!a){let C=f!==null?Math.min(u-f,50):16.67,A=typeof i=="object"&&i.speed?i.speed:.3,T=typeof i=="object"&&i.axis?i.axis:"y",p=A*(Math.PI/180)*(C/16.67);T==="y"?g.rotY=g.rotY+p:g.rotX=g.rotX+p,n.rerender()}f=u,l=requestAnimationFrame(d)}}function b(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(d))}function v(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function L(){e.addEventListener("pointerdown",h),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("wheel",_,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",h),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("wheel",_),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return L(),b(),{update(u){let C=!!i;r=u.drag??r,s=u.wheel??s,c=ye(u.invert),i=u.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let A=!!i;C&&!A?v():!C&&A&&b()},pause(){o||(o=!0,y(),v(),m=null,a=!1)},resume(){o&&(o=!1,L(),b())},destroy(){o||y(),v(),o=!0}}}function ye(n){return n===void 0||n===!1?1:n===!0?-1:n}var pt=typeof HTMLElement<"u"?HTMLElement:class{};function dt(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function K(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ht(n){return n.closest("glyphcss-scene")??null}var X=class extends pt{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,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=K(this.getAttribute("drag")),r=K(this.getAttribute("wheel")),s=K(this.getAttribute("invert")),c=dt(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{},...c!==void 0?{animate:{speed:c,axis:i}}:{}}}_attach(){if(this._controls)return;let e=ht(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=ge(r,this._readOptions())}};function ve(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=be(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=!1,h=n.camera,G=1/4*Math.PI/180,M=.02;function _(p){if(!(!r||o)&&m===null&&p.isPrimary!==!1){p.preventDefault(),m=p.pointerId,E={x:p.clientX,y:p.clientY},g=p.button===2,e.style.cursor="grabbing";try{p.target.setPointerCapture(p.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function d(p){if(m===null||p.pointerId!==m||!r||o)return;p.preventDefault();let x=p.clientX-E.x,S=p.clientY-E.y;E={x:p.clientX,y:p.clientY};let w=c;if(g||p.shiftKey)h.rotY=h.rotY-x*G*w,h.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,h.rotX+S*G*w));else{let H=h.target;h.target=[H[0]-x*M/h.scale,H[1]-S*M/h.scale,H[2]]}n.rerender()}function b(p){if(m===p.pointerId){m=null,g=!1,e.style.cursor=r&&!o?"grab":"";try{p.target.releasePointerCapture(p.pointerId)}catch{}i&&(a=!1)}}function v(p){p.preventDefault()}function L(p){if(!s||o)return;p.preventDefault();let x=p.deltaY*.001;h.scale=Math.max(.05,Math.min(10,h.scale*(1-x))),n.rerender()}function y(p){if(!(o||!i)){if(!a){let x=f!==null?Math.min(p-f,50):16.67,S=typeof i=="object"&&i.speed?i.speed:.3,w=typeof i=="object"&&i.axis?i.axis:"y",H=S*(Math.PI/180)*(x/16.67);w==="y"?h.rotY=h.rotY+H:h.rotX=h.rotX+H,n.rerender()}f=p,l=requestAnimationFrame(y)}}function u(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(y))}function C(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",d),e.addEventListener("pointerup",b),e.addEventListener("pointercancel",b),e.addEventListener("contextmenu",v),e.addEventListener("wheel",L,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function T(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",b),e.removeEventListener("pointercancel",b),e.removeEventListener("contextmenu",v),e.removeEventListener("wheel",L),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),u(),{update(p){let x=!!i;r=p.drag??r,s=p.wheel??s,c=be(p.invert),i=p.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let S=!!i;x&&!S?C():!x&&S&&u()},pause(){o||(o=!0,T(),C(),m=null,a=!1)},resume(){o&&(o=!1,A(),u())},destroy(){o||T(),C(),o=!0}}}function be(n){return n===void 0||n===!1?1:n===!0?-1:n}var mt=typeof HTMLElement<"u"?HTMLElement:class{};function J(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ft(n){return n.closest("glyphcss-scene")??null}var z=class extends mt{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,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=J(this.getAttribute("drag")),r=J(this.getAttribute("wheel")),s=J(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{}}}_attach(){if(this._controls)return;let e=ft(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=ve(r,this._readOptions())}};typeof customElements<"u"&&(customElements.get("glyphcss-scene")||customElements.define("glyphcss-scene",O),customElements.get("glyphcss-mesh")||customElements.define("glyphcss-mesh",R),customElements.get("glyphcss-hotspot")||customElements.define("glyphcss-hotspot",I),customElements.get("glyphcss-perspective-camera")||customElements.define("glyphcss-perspective-camera",Y),customElements.get("glyphcss-orthographic-camera")||customElements.define("glyphcss-orthographic-camera",F),customElements.get("glyphcss-orbit-controls")||customElements.define("glyphcss-orbit-controls",X),customElements.get("glyphcss-map-controls")||customElements.define("glyphcss-map-controls",z));0&&(module.exports={GlyphcssHotspotElement,GlyphcssMapControlsElement,GlyphcssMeshElement,GlyphcssOrbitControlsElement,GlyphcssOrthographicCameraElement,GlyphcssPerspectiveCameraElement,GlyphcssSceneElement});
62
+ `;function Ne(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 bt=1;function vt(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 Ye(n,t={}){Ie(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??le(),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=vt(v.polygons,v.transform);for(let G of A)d.push(G)}let b=Oe({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=Re(b);e.useColors?r.innerHTML=u:r.textContent=u,h()}function h(){let{cols:d,rows:b,cellAspect:u,camera:v}=e,A=Ne(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=bt++;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 Et=typeof HTMLElement<"u"?HTMLElement:class{},Mt=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity","auto-size"];function J(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function At(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function Ct(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var Q=class extends Et{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Mt]}getScene(){return this._scene}_readOptions(){let e={},o=At(this.getAttribute("mode"));o!==void 0&&(e.mode=o);let r=this.getAttribute("glyph-palette");r&&(e.glyphPalette=r);let a=Ct(this.getAttribute("use-colors"));a!==void 0&&(e.useColors=a);let i=J(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let s=J(this.getAttribute("rows"));s!==void 0&&(e.rows=s);let c=J(this.getAttribute("cell-aspect"));c!==void 0&&(e.cellAspect=c);let l=J(this.getAttribute("directional-intensity"));l!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:l});let p=J(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=Ye(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 $=require("@glyphcss/core"),Gt=typeof HTMLElement<"u"?HTMLElement:class{},xt=["src","geometry","size","color","position","scale","rotation","normalize"];function Lt(n){let t=(0,$.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(s=>({...s,vertices:s.vertices.map(c=>[(c[0]-e)*i,(c[1]-o)*i,(c[2]-r)*i])}))}function Ge(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 wt(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return Ge(n)}}function _t(n){return n.closest("glyph-scene")??null}var ee=class extends Gt{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...xt]}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:Ge(this.getAttribute("position")),scale:wt(this.getAttribute("scale")),rotation:Ge(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=_t(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(0,$.loadMesh)(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")?Lt(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=(0,$.resolveGeometry)(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 St=typeof HTMLElement<"u"?HTMLElement:class{};function zt(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 Tt(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 Ht(n){return n.closest("glyph-scene")??null}var te=class extends St{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=zt(this.getAttribute("at"));if(!e)return;let o=Ht(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=Tt(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 Pt=typeof HTMLElement<"u"?HTMLElement:class{};function k(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var ne=class extends Pt{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","distance","zoom","stretch"]}getCamera(){return this._camera}connectedCallback(){this._camera=le({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 Ot=typeof HTMLElement<"u"?HTMLElement:class{};function W(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}var j=class extends Ot{constructor(){super(...arguments);this._camera=null}static get observedAttributes(){return["rot-x","rot-y","zoom"]}getCamera(){return this._camera}connectedCallback(){this._camera=Pe({rotX:W(this.getAttribute("rot-x")),rotY:W(this.getAttribute("rot-y")),zoom:W(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=W(this.getAttribute("rot-x")),s=W(this.getAttribute("rot-y")),c=W(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 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=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=Xe(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 Xe(n){return n===void 0||n===!1?1:n===!0?-1:n}var Rt=typeof HTMLElement<"u"?HTMLElement:class{};function kt(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function xe(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function It(n){return n.closest("glyph-scene")??null}var re=class extends Rt{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=xe(this.getAttribute("drag")),o=xe(this.getAttribute("wheel")),r=xe(this.getAttribute("invert")),a=kt(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=It(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())}};function Ve(n,t={}){let e=n.host,o=t.drag??!0,r=t.wheel??!0,a=De(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=De(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 De(n){return n===void 0||n===!1?1:n===!0?-1:n}var Nt=typeof HTMLElement<"u"?HTMLElement:class{};function Le(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function Yt(n){return n.closest("glyph-scene")??null}var oe=class extends Nt{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=Le(this.getAttribute("drag")),o=Le(this.getAttribute("wheel")),r=Le(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=Yt(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=Ve(o,this._readOptions())}};if(typeof customElements<"u"){if(customElements.get("glyph-scene")||customElements.define("glyph-scene",Q),customElements.get("glyph-mesh")||customElements.define("glyph-mesh",ee),customElements.get("glyph-hotspot")||customElements.define("glyph-hotspot",te),customElements.get("glyph-perspective-camera")||customElements.define("glyph-perspective-camera",ne),customElements.get("glyph-orthographic-camera")||customElements.define("glyph-orthographic-camera",j),!customElements.get("glyph-camera")){class n extends j{}customElements.define("glyph-camera",n)}customElements.get("glyph-orbit-controls")||customElements.define("glyph-orbit-controls",re),customElements.get("glyph-map-controls")||customElements.define("glyph-map-controls",oe)}0&&(module.exports={GlyphHotspotElement,GlyphMapControlsElement,GlyphMeshElement,GlyphOrbitControlsElement,GlyphOrthographicCameraElement,GlyphPerspectiveCameraElement,GlyphSceneElement});
@@ -1,2 +1,2 @@
1
- export { g as GlyphcssHotspotElement, j as GlyphcssMapControlsElement, k as GlyphcssMeshElement, n as GlyphcssOrbitControlsElement, o as GlyphcssOrthographicCameraElement, r as GlyphcssPerspectiveCameraElement, u as GlyphcssSceneElement } from './elements-Bb37NHHO.cjs';
1
+ export { d as GlyphHotspotElement, g as GlyphMapControlsElement, h as GlyphMeshElement, k as GlyphOrbitControlsElement, l as GlyphOrthographicCameraElement, o as GlyphPerspectiveCameraElement, r as GlyphSceneElement } from './elements-DVWVBIG0.cjs';
2
2
  import '@glyphcss/core';
@@ -1,2 +1,2 @@
1
- export { g as GlyphcssHotspotElement, j as GlyphcssMapControlsElement, k as GlyphcssMeshElement, n as GlyphcssOrbitControlsElement, o as GlyphcssOrthographicCameraElement, r as GlyphcssPerspectiveCameraElement, u as GlyphcssSceneElement } from './elements-Bb37NHHO.js';
1
+ export { d as GlyphHotspotElement, g as GlyphMapControlsElement, h as GlyphMeshElement, k as GlyphOrbitControlsElement, l as GlyphOrthographicCameraElement, o as GlyphPerspectiveCameraElement, r as GlyphSceneElement } from './elements-DVWVBIG0.js';
2
2
  import '@glyphcss/core';
package/dist/elements.js CHANGED
@@ -1,9 +1,17 @@
1
- function ie(n,t,e){let r=Math.cos(t),s=Math.sin(t),c=r*n[1]-s*n[0],i=s*n[1]+r*n[0],o=n[2],a=Math.cos(e),l=Math.sin(e),f=a*i-l*o,m=l*i+a*o;return[c,f,m]}function I(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:n.distance??3,scale:n.scale??.4,stretch:n.stretch??1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"perspective",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=ie(a,t.rotY,t.rotX),f=30,m=1.5,E=l[2]*f,g=.001,h=1-E/t.distance;if(h<g)return[NaN,NaN,l[2]];let G=1/h,M=Math.min(c,i)*t.scale*m*G,_=c*e+l[0]*M*o*t.stretch,d=i*r+l[1]*M;return[_,d,l[2]]}}}function oe(n={}){let t={rotX:n.rotX??0,rotY:n.rotY??0,distance:0,scale:n.zoom??.4,stretch:1,target:[0,0,0]},[e,r]=n.center??[.5,.5];return{kind:"orthographic",get rotX(){return t.rotX},set rotX(s){t.rotX=s},get rotY(){return t.rotY},set rotY(s){t.rotY=s},get distance(){return t.distance},set distance(s){t.distance=s},get scale(){return t.scale},set scale(s){t.scale=s},get stretch(){return t.stretch},set stretch(s){t.stretch=s},get target(){return t.target},set target(s){t.target=s},project(s,c,i,o){let a=[s[0]-t.target[0],s[1]-t.target[1],s[2]-t.target[2]],l=ie(a,t.rotY,t.rotX),m=Math.min(c,i)*t.scale*1.5,E=c*e+l[0]*m*o*t.stretch,g=i*r+l[1]*m;return[E,g,l[2]]}}}import{trianglesToFeatureEdges as Se}from"@glyphcss/core";var He={direction:[.5,.7,.5],intensity:1},we={intensity:.4};function le(n){let t=n.triangles??[],e=n.mode??(t.length?"solid":"wireframe"),r=n.wireframe??(e==="wireframe"?Se(t):[]);return{camera:n.camera,grid:n.grid,triangles:t,wireframe:r,mode:e,directionalLight:n.directionalLight??He,ambientLight:n.ambientLight??we,glyphPalette:n.glyphPalette??"default",useColors:n.useColors??!0}}var dt=" .:-=+*#%@".split(""),ht=" .:-=+*#%@".split(""),B={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("")}},mt=B.default;function j(n){return B[n]??B.default}function ce(n){let{camera:t,grid:e,wireframe:r,triangles:s,mode:c,directionalLight:i,ambientLight:o}=n,{cols:a,rows:l,cellAspect:f}=e;if(c==="solid")return Pe(n,a,l,f);let m=j(n.glyphPalette),E=new Uint8Array(a*l),g=n.useColors?new Array(a*l).fill(null):null;for(let h of r){let G=t.project(h.from,a,l,f),M=t.project(h.to,a,l,f);G[0]!==G[0]||M[0]!==M[0]||Ie(E,g,G[0]|0,G[1]|0,M[0]|0,M[1]|0,h.weight??2,h.color??null,a,l)}return ke(E,g,a,l,m)}function Pe(n,t,e,r){let{camera:s,triangles:c,directionalLight:i,ambientLight:o}=n,a=j(n.glyphPalette).solid,l=new Array(t*e).fill(" "),f=n.useColors,m=f?new Array(t*e).fill(null):null,E=new Float64Array(t*e).fill(-1/0),g=i.direction,h=Math.hypot(g[0],g[1],g[2])||1,G=g[0]/h,M=g[1]/h,_=g[2]/h,d=i.intensity??1,b=o.intensity??.4,v=W(i.color??"#ffffff"),L=W(o.color??"#ffffff");for(let y of c){let[u,C,A]=y.vertices,T=s.project(u,t,e,r),p=s.project(C,t,e,r),x=s.project(A,t,e,r);if(T[0]!==T[0]||p[0]!==p[0]||x[0]!==x[0])continue;let S=C[0]-u[0],w=C[1]-u[1],H=C[2]-u[2],J=A[0]-u[0],Q=A[1]-u[1],ee=A[2]-u[2],te=w*ee-H*Q,ne=H*J-S*ee,se=S*Q-w*J,ge=Math.hypot(te,ne,se)||1,be=(te*G+ne*M+se*_)/ge,R=Math.max(0,be)*d,ve=Math.min(1,Math.max(0,b+R)),Ee=Math.min(a.length-1,ve*(a.length-1)|0),Ge=a[Ee],re=null;if(f){let D=y.color?W(y.color):[255,255,255],xe=b*L[0]/255+R*v[0]/255,Le=b*L[1]/255+R*v[1]/255,Ce=b*L[2]/255+R*v[2]/255,Ae=Math.min(255,D[0]*xe),Te=Math.min(255,D[1]*Le),_e=Math.min(255,D[2]*Ce);re=`#${U(Ae)}${U(Te)}${U(_e)}`}let Me=(T[2]+p[2]+x[2])/3;Oe(T[0],T[1],p[0],p[1],x[0],x[1],Me,Ge,re,l,m,E,t,e)}return Re(l,m,t,e)}function Oe(n,t,e,r,s,c,i,o,a,l,f,m,E,g){let h=n,G=t,M=e,_=r,d=s,b=c;if(_<G){let y=h;h=M,M=y,y=G,G=_,_=y}if(b<G){let y=h;h=d,d=y,y=G,G=b,b=y}if(b<_){let y=M;M=d,d=y,y=_,_=b,b=y}let v=Math.max(0,Math.ceil(G)),L=Math.min(g-1,Math.floor(b));if(!(v>L))for(let y=v;y<=L;y++){let u=(y-G)/(b-G||1),C=h+(d-h)*u,A;if(y<_){let x=(y-G)/(_-G||1);A=h+(M-h)*x}else{let x=(y-_)/(b-_||1);A=M+(d-M)*x}let T=Math.max(0,Math.ceil(Math.min(C,A))),p=Math.min(E-1,Math.floor(Math.max(C,A)));for(let x=T;x<=p;x++){let S=y*E+x;i>m[S]&&(m[S]=i,l[S]=o,f&&(f[S]=a))}}}function Re(n,t,e,r){let s=[],c=null,i="",o=()=>{i&&(c!==null?s.push(`<span style="color:${c}">${i}</span>`):s.push(i),i="")};for(let a=0;a<r;a++){for(let l=0;l<e;l++){let f=a*e+l,m=n[f],E=t&&m!==" "?t[f]??null:null;E!==c&&(o(),c=E),i+=m}o(),c=null,a<r-1&&s.push(`
2
- `)}return s.join("")}function Ie(n,t,e,r,s,c,i,o,a,l){let f=Math.abs(s-e),m=-Math.abs(c-r),E=e<s?1:-1,g=r<c?1:-1,h=f+m;for(;;){if(e>=0&&e<a&&r>=0&&r<l){let M=r*a+e;n[M]<i&&(n[M]=i,t&&(t[M]=o))}if(e===s&&r===c)break;let G=2*h;G>=m&&(h+=m,e+=E),G<=f&&(h+=f,r+=g)}}function ke(n,t,e,r,s){let c=[],i=null,o="",a=()=>{o&&(i!==null?c.push(`<span style="color:${i}">${o}</span>`):c.push(o),o="")};for(let l=0;l<r;l++){for(let f=0;f<e;f++){let m=l*e+f,E=n[m],g,h;E===0?(g=" ",h=null):(g=E===1?s.thin[Math.random()*s.thin.length|0]:E===2?s.normal[Math.random()*s.normal.length|0]:s.core[Math.random()*s.core.length|0],h=t?t[m]??null:null),h!==i&&(a(),i=h),o+=g}a(),i=null,l<r-1&&c.push(`
3
- `)}return c.join("")}function W(n){let t=n.startsWith("#")?n.slice(1):n;if(t.length===3){let e=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),s=parseInt(t[2]+t[2],16);return[e||0,r||0,s||0]}if(t.length===6){let e=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return[e||0,r||0,s||0]}return[255,255,255]}function U(n){let t=Math.max(0,Math.min(255,n|0)).toString(16);return t.length===1?"0"+t:t}var ae="glyphcss-styles";function ue(n){let t=n??(typeof document<"u"?document:void 0);if(!t||t.getElementById(ae))return;let e=t.createElement("style");e.id=ae,e.textContent=Ye,t.head.appendChild(e)}var Ye=`
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=`
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
+
6
+ .glyph-host {
7
+ /* Fill the camera wrapper so autoSize can observe a non-zero height. */
8
+ width: 100%;
9
+ height: 100%;
10
+ }
11
+
4
12
  /* \u2500\u2500 Glyphcss scene container \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
13
 
6
- .glyphcss-scene {
14
+ .glyph-scene {
7
15
  position: relative;
8
16
  display: block;
9
17
  overflow: hidden;
@@ -12,8 +20,12 @@ function ie(n,t,e){let r=Math.cos(t),s=Math.sin(t),c=r*n[1]-s*n[0],i=s*n[1]+r*n[
12
20
 
13
21
  /* \u2500\u2500 ASCII output <pre> \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\u2500\u2500\u2500\u2500\u2500\u2500 */
14
22
 
15
- .glyphcss-scene .glyphcss-output {
16
- display: block;
23
+ .glyph-scene .glyph-output {
24
+ /* inline-block so the box shrinks to the text's natural width. With display:
25
+ block the pre inherits parent width, leaving empty space on the right, and
26
+ cellW = preRect.width / cols overshoots the actual character cell \u2014 placing
27
+ hotspots to the right of the rasterized glyph they're supposed to anchor. */
28
+ display: inline-block;
17
29
  margin: 0;
18
30
  padding: 0;
19
31
  font-family: monospace;
@@ -27,15 +39,24 @@ function ie(n,t,e){let r=Math.cos(t),s=Math.sin(t),c=r*n[1]-s*n[0],i=s*n[1]+r*n[
27
39
 
28
40
  /* \u2500\u2500 Hotspot overlay \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\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
29
41
 
30
- .glyphcss-scene .glyphcss-hotspot-layer {
42
+ .glyph-scene .glyph-hotspot-layer {
31
43
  position: absolute;
32
44
  inset: 0;
33
45
  pointer-events: none;
46
+ /* Isolate the stacking context so per-hotspot z-index values (derived from
47
+ camera depth, sometimes negative) stay scoped INSIDE the layer. Without
48
+ this, a negative-z-index hotspot would render below the sibling <pre>,
49
+ hidden behind the rasterized glyphs. */
50
+ isolation: isolate;
34
51
  }
35
52
 
36
- .glyphcss-scene .glyphcss-hotspot {
53
+ .glyph-scene .glyph-hotspot {
37
54
  position: absolute;
38
55
  pointer-events: all;
39
56
  cursor: pointer;
57
+ /* Center the label on the projected anchor point rather than anchoring its
58
+ top-left corner there. Without this, padding / label width visually offset
59
+ the content from the 3D vertex being labelled. */
60
+ transform: translate(-50%, -50%);
40
61
  }
41
- `;function pe(n,t,e,r,s){return n.map(c=>{let[i,o,a]=t.project(c.at,e,r,s),l=a>-3&&i>=0&&i<e&&o>=0&&o<r;return{id:c.id,col:i,row:o,depth:a,visible:l}})}var Fe=1;function Xe(n,t){let{position:e,scale:r,rotation:s}=t;if(!e&&!r&&!s)return n;let[c,i,o]=e??[0,0,0],a=1,l=1,f=1;r!==void 0&&(typeof r=="number"?a=l=f=r:[a,l,f]=r);let[m,E,g]=s??[0,0,0],h=Math.cos(m),G=Math.sin(m),M=Math.cos(E),_=Math.sin(E),d=Math.cos(g),b=Math.sin(g);function v(L){let y=L[0]*a,u=L[1]*l,C=L[2]*f,A=d*y-b*u,T=b*y+d*u,p=C;return y=M*A+_*p,u=T,C=-_*A+M*p,A=y,T=h*u-G*C,p=G*u+h*C,[A+c,T+i,p+o]}return n.map(L=>({...L,vertices:[v(L.vertices[0]),v(L.vertices[1]),v(L.vertices[2])]}))}function de(n,t={}){ue(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??I()},r=n.ownerDocument.createElement("div");r.className="glyphcss-scene";let s=n.ownerDocument.createElement("pre");s.className="glyphcss-output";let c=n.ownerDocument.createElement("div");c.className="glyphcss-hotspot-layer",r.appendChild(s),r.appendChild(c),n.appendChild(r);let i=new Map,o=[],a=!1;function l(){a||(a=!0,Promise.resolve().then(()=>{a=!1,f()}))}function f(){let d=[];for(let L of i.values()){let y=Xe(L.triangles,L.transform);for(let u of y)d.push(u)}let b=le({camera:e.camera,grid:{cols:e.cols,rows:e.rows,cellAspect:e.cellAspect},triangles:d,mode:e.mode,directionalLight:e.directionalLight,ambientLight:e.ambientLight,glyphPalette:e.glyphPalette,useColors:e.useColors}),v=ce(b);e.useColors?s.innerHTML=v:s.textContent=v,m()}function m(){let{cols:d,rows:b,cellAspect:v,camera:L}=e,y=pe(o.map(T=>T.hotspot),L,d,b,v),u=s.getBoundingClientRect(),C=d>0?u.width/d:8,A=b>0?u.height/b:16;for(let T=0;T<o.length;T++){let{el:p}=o[T],x=y[T];x.visible?(p.style.display="",p.style.left=`${x.col*C}px`,p.style.top=`${x.row*A}px`,p.style.zIndex=String(Math.round(x.depth*1e3))):p.style.display="none"}}function E(d,b={}){let v=Fe++;return i.set(v,{id:v,triangles:d,transform:b}),l(),{get id(){return v},get triangles(){return d},setTransform(L){let y=i.get(v);y&&(y.transform=L,l())},dispose(){i.delete(v),l()}}}function g(d,b){let v=n.ownerDocument.createElement("div");v.className="glyphcss-hotspot",v.setAttribute("data-hotspot-id",d.id);let[L,y]=d.size??[1,1];v.style.position="absolute",v.style.width=`${L}ch`,v.style.height=`${y*e.cellAspect}ch`,b&&v.addEventListener("click",b),c.appendChild(v);let u={hotspot:{id:d.id,at:d.at,size:d.size},el:v,onClick:b};return o.push(u),l(),{remove(){let C=o.indexOf(u);C>=0&&o.splice(C,1),b&&v.removeEventListener("click",b),c.removeChild(v),l()}}}function h(){f()}function G(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),l()}function M(){return{...e}}function _(){i.clear(),n.contains(r)&&n.removeChild(r)}return l(),{get host(){return n},get output(){return s},get camera(){return e.camera},add:E,addHotspot:g,rerender:h,setOptions:G,getOptions:M,destroy:_}}var ze=typeof HTMLElement<"u"?HTMLElement:class{},Ne=["mode","glyph-palette","use-colors","cols","rows","cell-aspect","directional-direction","directional-intensity","ambient-intensity"];function P(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Ve(n){if(n==="wireframe"||n==="solid"||n==="voxel")return n}function De(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}var k=class extends ze{constructor(){super(...arguments);this._scene=null}static get observedAttributes(){return[...Ne]}getScene(){return this._scene}_readOptions(){let e={},r=Ve(this.getAttribute("mode"));r!==void 0&&(e.mode=r);let s=this.getAttribute("glyph-palette");s&&(e.glyphPalette=s);let c=De(this.getAttribute("use-colors"));c!==void 0&&(e.useColors=c);let i=P(this.getAttribute("cols"));i!==void 0&&(e.cols=i);let o=P(this.getAttribute("rows"));o!==void 0&&(e.rows=o);let a=P(this.getAttribute("cell-aspect"));a!==void 0&&(e.cellAspect=a);let l=P(this.getAttribute("directional-intensity"));l!==void 0&&(e.directionalLight={direction:[.5,.7,.5],intensity:l});let f=P(this.getAttribute("ambient-intensity"));return f!==void 0&&(e.ambientLight={intensity:f}),e}connectedCallback(){this._scene||(this._scene=de(this,this._readOptions()),this.dispatchEvent(new CustomEvent("glyphcss:scene-ready",{bubbles:!1})))}disconnectedCallback(){this._scene&&(this._scene.destroy(),this._scene=null)}attributeChangedCallback(e,r,s){r!==s&&this._scene&&this._scene.setOptions(this._readOptions())}};import{loadMesh as Be}from"@glyphcss/core";var je=typeof HTMLElement<"u"?HTMLElement:class{},We=["src","position","scale","rotation"];function $(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 Ue(n){if(n){if(!n.includes(",")){let t=parseFloat(n);return Number.isFinite(t)?t:void 0}return $(n)}}function $e(n){return n.closest("glyphcss-scene")??null}function qe(n){let t=[[0,0],[0,0],[0,0]],e=[];for(let r of n){let s=r.vertices;if(!(s.length<3))for(let c=1;c<s.length-1;c++)e.push({vertices:[s[0],s[c],s[c+1]],uvs:t,...r.color?{color:r.color}:{}})}return e}var Y=class extends je{constructor(){super(...arguments);this._handle=null;this._loadToken=0}static get observedAttributes(){return[...We]}getMeshHandle(){return this._handle}connectedCallback(){this._maybeLoad()}disconnectedCallback(){this._tearDown()}attributeChangedCallback(e,r,s){if(r!==s){if(e==="src"){this._tearDown(),this._maybeLoad();return}this._handle&&this._handle.setTransform(this._readTransform())}}_readTransform(){return{position:$(this.getAttribute("position")),scale:Ue(this.getAttribute("scale")),rotation:$(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");if(!e)return;let r=$e(this);if(!r)return;let s=++this._loadToken,c;try{c=await Be(e)}catch(a){this.dispatchEvent(new CustomEvent("glyphcss:error",{detail:a,bubbles:!0}));return}if(s!==this._loadToken){try{c.dispose()}catch{}return}let i=r.getScene();if(!i){try{c.dispose()}catch{}return}let o=qe(c.polygons);this._handle=i.add(o,this._readTransform()),this.dispatchEvent(new CustomEvent("glyphcss:loaded",{detail:{triangles:o},bubbles:!0}))}};var Ze=typeof HTMLElement<"u"?HTMLElement:class{};function Ke(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 Je(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 Qe(n){return n.closest("glyphcss-scene")??null}var F=class extends Ze{constructor(){super(...arguments);this._handle=null}static get observedAttributes(){return["at","size","hotspot-id"]}connectedCallback(){this._register()}disconnectedCallback(){this._handle&&(this._handle.remove(),this._handle=null)}attributeChangedCallback(e,r,s){r!==s&&(this._handle&&(this._handle.remove(),this._handle=null),this._register())}_register(){let e=Ke(this.getAttribute("at"));if(!e)return;let s=Qe(this)?.getScene();if(!s)return;let c=this.getAttribute("hotspot-id")??this.getAttribute("id")??String(Math.random()),i=Je(this.getAttribute("size"));this._handle=s.addHotspot({id:c,at:e,size:i},()=>this.dispatchEvent(new CustomEvent("glyphcss:hotspot-click",{detail:{id:c},bubbles:!0})))}};var et=typeof HTMLElement<"u"?HTMLElement:class{};function O(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function tt(n){return n.closest("glyphcss-scene")??null}var X=class extends et{static get observedAttributes(){return["rot-x","rot-y","distance","scale","stretch"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=tt(this)?.getScene();if(!e)return;let r=I({rotX:O(this.getAttribute("rot-x")),rotY:O(this.getAttribute("rot-y")),distance:O(this.getAttribute("distance")),scale:O(this.getAttribute("scale")),stretch:O(this.getAttribute("stretch"))});e.setOptions({camera:r})}};var nt=typeof HTMLElement<"u"?HTMLElement:class{};function q(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function st(n){return n.closest("glyphcss-scene")??null}var z=class extends nt{static get observedAttributes(){return["rot-x","rot-y","zoom"]}connectedCallback(){this._apply()}attributeChangedCallback(t,e,r){e!==r&&this._apply()}_apply(){let e=st(this)?.getScene();if(!e)return;let r=oe({rotX:q(this.getAttribute("rot-x")),rotY:q(this.getAttribute("rot-y")),zoom:q(this.getAttribute("zoom"))});e.setOptions({camera:r})}};function me(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=he(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=n.camera;function h(u){if(!(!r||o)&&m===null&&u.isPrimary!==!1){u.preventDefault(),m=u.pointerId,E={x:u.clientX,y:u.clientY},e.style.cursor="grabbing";try{u.target.setPointerCapture(u.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function G(u){if(m===null||u.pointerId!==m||!r||o)return;u.preventDefault();let C=u.clientX-E.x,A=u.clientY-E.y;E={x:u.clientX,y:u.clientY};let T=c,x=1/4*Math.PI/180;g.rotY=g.rotY-C*x*T,g.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,g.rotX+A*x*T)),n.rerender()}function M(u){if(m===u.pointerId){m=null,e.style.cursor=r&&!o?"grab":"";try{u.target.releasePointerCapture(u.pointerId)}catch{}i&&(a=!1)}}function _(u){if(!s||o)return;u.preventDefault();let C=u.deltaY*.001;g.scale=Math.max(.05,Math.min(10,g.scale*(1-C))),n.rerender()}function d(u){if(!(o||!i)){if(!a){let C=f!==null?Math.min(u-f,50):16.67,A=typeof i=="object"&&i.speed?i.speed:.3,T=typeof i=="object"&&i.axis?i.axis:"y",p=A*(Math.PI/180)*(C/16.67);T==="y"?g.rotY=g.rotY+p:g.rotX=g.rotX+p,n.rerender()}f=u,l=requestAnimationFrame(d)}}function b(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(d))}function v(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function L(){e.addEventListener("pointerdown",h),e.addEventListener("pointermove",G),e.addEventListener("pointerup",M),e.addEventListener("pointercancel",M),e.addEventListener("wheel",_,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function y(){e.removeEventListener("pointerdown",h),e.removeEventListener("pointermove",G),e.removeEventListener("pointerup",M),e.removeEventListener("pointercancel",M),e.removeEventListener("wheel",_),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return L(),b(),{update(u){let C=!!i;r=u.drag??r,s=u.wheel??s,c=he(u.invert),i=u.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let A=!!i;C&&!A?v():!C&&A&&b()},pause(){o||(o=!0,y(),v(),m=null,a=!1)},resume(){o&&(o=!1,L(),b())},destroy(){o||y(),v(),o=!0}}}function he(n){return n===void 0||n===!1?1:n===!0?-1:n}var rt=typeof HTMLElement<"u"?HTMLElement:class{};function it(n){if(n==null)return;let t=parseFloat(n);return Number.isFinite(t)?t:void 0}function Z(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ot(n){return n.closest("glyphcss-scene")??null}var N=class extends rt{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,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=Z(this.getAttribute("drag")),r=Z(this.getAttribute("wheel")),s=Z(this.getAttribute("invert")),c=it(this.getAttribute("animate-speed")),i=this.getAttribute("animate-axis")==="x"?"x":"y";return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{},...c!==void 0?{animate:{speed:c,axis:i}}:{}}}_attach(){if(this._controls)return;let e=ot(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=me(r,this._readOptions())}};function ye(n,t={}){let e=n.host,r=t.drag??!0,s=t.wheel??!0,c=fe(t.invert),i=t.animate??!1,o=!1,a=!1,l=null,f=null,m=null,E={x:0,y:0},g=!1,h=n.camera,G=1/4*Math.PI/180,M=.02;function _(p){if(!(!r||o)&&m===null&&p.isPrimary!==!1){p.preventDefault(),m=p.pointerId,E={x:p.clientX,y:p.clientY},g=p.button===2,e.style.cursor="grabbing";try{p.target.setPointerCapture(p.pointerId)}catch{}i&&i.pauseOnInteraction!==!1&&(a=!0)}}function d(p){if(m===null||p.pointerId!==m||!r||o)return;p.preventDefault();let x=p.clientX-E.x,S=p.clientY-E.y;E={x:p.clientX,y:p.clientY};let w=c;if(g||p.shiftKey)h.rotY=h.rotY-x*G*w,h.rotX=Math.max(-Math.PI/2,Math.min(Math.PI/2,h.rotX+S*G*w));else{let H=h.target;h.target=[H[0]-x*M/h.scale,H[1]-S*M/h.scale,H[2]]}n.rerender()}function b(p){if(m===p.pointerId){m=null,g=!1,e.style.cursor=r&&!o?"grab":"";try{p.target.releasePointerCapture(p.pointerId)}catch{}i&&(a=!1)}}function v(p){p.preventDefault()}function L(p){if(!s||o)return;p.preventDefault();let x=p.deltaY*.001;h.scale=Math.max(.05,Math.min(10,h.scale*(1-x))),n.rerender()}function y(p){if(!(o||!i)){if(!a){let x=f!==null?Math.min(p-f,50):16.67,S=typeof i=="object"&&i.speed?i.speed:.3,w=typeof i=="object"&&i.axis?i.axis:"y",H=S*(Math.PI/180)*(x/16.67);w==="y"?h.rotY=h.rotY+H:h.rotX=h.rotX+H,n.rerender()}f=p,l=requestAnimationFrame(y)}}function u(){l===null&&typeof requestAnimationFrame<"u"&&i&&(l=requestAnimationFrame(y))}function C(){l!==null&&(typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(l),l=null),f=null}function A(){e.addEventListener("pointerdown",_),e.addEventListener("pointermove",d),e.addEventListener("pointerup",b),e.addEventListener("pointercancel",b),e.addEventListener("contextmenu",v),e.addEventListener("wheel",L,{passive:!1}),e.style.cursor=r?"grab":"",e.style.touchAction="none",e.style.userSelect="none"}function T(){e.removeEventListener("pointerdown",_),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",b),e.removeEventListener("pointercancel",b),e.removeEventListener("contextmenu",v),e.removeEventListener("wheel",L),e.style.cursor="",e.style.touchAction="",e.style.userSelect=""}return A(),u(),{update(p){let x=!!i;r=p.drag??r,s=p.wheel??s,c=fe(p.invert),i=p.animate??i,!o&&m===null&&(e.style.cursor=r?"grab":"");let S=!!i;x&&!S?C():!x&&S&&u()},pause(){o||(o=!0,T(),C(),m=null,a=!1)},resume(){o&&(o=!1,A(),u())},destroy(){o||T(),C(),o=!0}}}function fe(n){return n===void 0||n===!1?1:n===!0?-1:n}var lt=typeof HTMLElement<"u"?HTMLElement:class{};function K(n){if(n!==null){if(n==="false")return!1;if(n==="true"||n==="")return!0}}function ct(n){return n.closest("glyphcss-scene")??null}var V=class extends lt{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,r,s){r!==s&&this._controls?.update(this._readOptions())}_readOptions(){let e=K(this.getAttribute("drag")),r=K(this.getAttribute("wheel")),s=K(this.getAttribute("invert"));return{...e!==void 0?{drag:e}:{},...r!==void 0?{wheel:r}:{},...s!==void 0?{invert:s}:{}}}_attach(){if(this._controls)return;let e=ct(this);if(!e)return;let r=e.getScene();if(!r){let s=()=>{e.removeEventListener("glyphcss:scene-ready",s),this._attach()};e.addEventListener("glyphcss:scene-ready",s);return}this._controls=ye(r,this._readOptions())}};typeof customElements<"u"&&(customElements.get("glyphcss-scene")||customElements.define("glyphcss-scene",k),customElements.get("glyphcss-mesh")||customElements.define("glyphcss-mesh",Y),customElements.get("glyphcss-hotspot")||customElements.define("glyphcss-hotspot",F),customElements.get("glyphcss-perspective-camera")||customElements.define("glyphcss-perspective-camera",X),customElements.get("glyphcss-orthographic-camera")||customElements.define("glyphcss-orthographic-camera",z),customElements.get("glyphcss-orbit-controls")||customElements.define("glyphcss-orbit-controls",N),customElements.get("glyphcss-map-controls")||customElements.define("glyphcss-map-controls",V));export{F as GlyphcssHotspotElement,V as GlyphcssMapControlsElement,Y as GlyphcssMeshElement,N as GlyphcssOrbitControlsElement,z as GlyphcssOrthographicCameraElement,X as GlyphcssPerspectiveCameraElement,k as GlyphcssSceneElement};
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};