@mlightcad/cad-simple-viewer-cli 1.7.2 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as ye,A as sr,c as Bt,B as lr,M as cr,P as ke,D as dr,Q as Ae,J as ur,L as mr,t as P,d as pr,e as hr,f as fr,h as gr,i as br,N as wr,T as da,l as xr,m as vr,o as yr,p as kr,q as Ar,r as zr,s as Mr,v as Fr,w as Wt,y as Sr,z as Cr,C as Pr,E as Lr,F as Er,G as Ir,H as Br,I as Dr,K as Ur,O as Nr,R as Or,S as Tr,U as Rr,V as $r,W as jr,X as _r,Y as Vr,Z as Hr,a0 as Yr,a1 as Xr,a2 as Gr,a3 as it,a4 as ua,a5 as Kr,a6 as Jt,a7 as Wr,a8 as Jr,a9 as Zr,aa as qr}from"./index-QZJdatvK.js";import{ab as ks,ac as As}from"./index-QZJdatvK.js";function Zt(...t){return`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 1024 1024">${t.map(a=>`<path fill="currentColor" d="${a}"/>`).join("")}</svg>`}Zt("M624 475.968V640h144a128 128 0 0 1 128 128H128a128 128 0 0 1 128-128h144V475.968a192 192 0 1 1 224 0M128 896v-64h768v64z");Zt("M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352m0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288m0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448m0 64a160.19 160.19 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160");Zt("M876.8 156.8c0-9.6-3.2-16-9.6-22.4s-12.8-9.6-22.4-9.6-16 3.2-22.4 9.6L736 220.8c-64-32-137.6-51.2-224-60.8-160 16-288 73.6-377.6 176S0 496 0 512s48 73.6 134.4 176c22.4 25.6 44.8 48 73.6 67.2l-86.4 89.6c-6.4 6.4-9.6 12.8-9.6 22.4s3.2 16 9.6 22.4 12.8 9.6 22.4 9.6 16-3.2 22.4-9.6l704-710.4c3.2-6.4 6.4-12.8 6.4-22.4m-646.4 528Q115.2 579.2 76.8 512q43.2-72 153.6-172.8C304 272 400 230.4 512 224c64 3.2 124.8 19.2 176 44.8l-54.4 54.4C598.4 300.8 560 288 512 288c-64 0-115.2 22.4-160 64s-64 96-64 160c0 48 12.8 89.6 35.2 124.8L256 707.2c-9.6-6.4-19.2-16-25.6-22.4m140.8-96Q352 555.2 352 512c0-44.8 16-83.2 48-112s67.2-48 112-48c28.8 0 54.4 6.4 73.6 19.2zM889.599 336c-12.8-16-28.8-28.8-41.6-41.6l-48 48c73.6 67.2 124.8 124.8 150.4 169.6q-43.2 72-153.6 172.8c-73.6 67.2-172.8 108.8-284.8 115.2-51.2-3.2-99.2-12.8-140.8-28.8l-48 48c57.6 22.4 118.4 38.4 188.8 44.8 160-16 288-73.6 377.6-176S1024 528 1024 512s-48.001-73.6-134.401-176","M511.998 672c-12.8 0-25.6-3.2-38.4-6.4l-51.2 51.2c28.8 12.8 57.6 19.2 89.6 19.2 64 0 115.2-22.4 160-64 41.6-41.6 64-96 64-160 0-32-6.4-64-19.2-89.6l-51.2 51.2c3.2 12.8 6.4 25.6 6.4 38.4 0 44.8-16 83.2-48 112s-67.2 48-112 48");const Qr='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10 13.5 14.5 9h-9L10 13.5Z"/></svg>',tn='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 3.53 16.09 6.97 10.09 10.29 4.18 7 10.09 3.56M10.09 2.4 2.17 7 3.31 7.65 10.09 11.45 17 7.62 18.17 7 10.08 2.37 10.09 2.4Z"/><path fill="currentColor" d="M10.25 14.83 18.17 10.22 17 9.57 10.22 13.57 3.32 9.59 2.17 10.22 10.25 14.83Z"/><path fill="currentColor" d="M10.25 17.63 18.17 13 17 12.37 10.22 16.37 3.32 12.38 2.17 13 10.25 17.63Z"/></svg>',en='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 5.15 16.09 8.59 10.09 11.91 4.18 8.59 10.09 5.15ZM10.09 4 2.17 8.61 3.31 9.25 10.09 13.06 17 9.24 18.16 8.61 10.08 4 10.09 4Z"/><path fill="currentColor" d="M10.25 16.46 18.17 11.85 17 11.2 10.22 15.2 3.32 11.21 2.17 11.85 10.25 16.46Z"/><path fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" d="M3.5 3.5 16.5 16.5"/></svg>',J=4;var $=Uint8Array,j=Uint16Array,qt=Int32Array,Qt=new $([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),te=new $([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ze=new $([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ma=function(t,e){for(var a=new j(31),r=0;r<31;++r)a[r]=e+=1<<t[r-1];for(var n=new qt(a[30]),r=1;r<30;++r)for(var i=a[r];i<a[r+1];++i)n[i]=i-a[r]<<5|r;return{b:a,r:n}},pa=ma(Qt,2),an=pa.b,$t=pa.r;an[28]=258,$t[258]=28;var rn=ma(te,0),Me=rn.r,jt=new j(32768);for(var y=0;y<32768;++y){var W=(y&43690)>>1|(y&21845)<<1;W=(W&52428)>>2|(W&13107)<<2,W=(W&61680)>>4|(W&3855)<<4,jt[y]=((W&65280)>>8|(W&255)<<8)>>1}var dt=(function(t,e,a){for(var r=t.length,n=0,i=new j(e);n<r;++n)t[n]&&++i[t[n]-1];var o=new j(e);for(n=1;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var s;if(a){s=new j(1<<e);var l=15-e;for(n=0;n<r;++n)if(t[n])for(var c=n<<4|t[n],d=e-t[n],u=o[t[n]-1]++<<d,m=u|(1<<d)-1;u<=m;++u)s[jt[u]>>l]=c}else for(s=new j(r),n=0;n<r;++n)t[n]&&(s[n]=jt[o[t[n]-1]++]>>15-t[n]);return s}),Q=new $(288);for(var y=0;y<144;++y)Q[y]=8;for(var y=144;y<256;++y)Q[y]=9;for(var y=256;y<280;++y)Q[y]=7;for(var y=280;y<288;++y)Q[y]=8;var xt=new $(32);for(var y=0;y<32;++y)xt[y]=5;var nn=dt(Q,9,0),on=dt(xt,5,0),ha=function(t){return(t+7)/8|0},fa=function(t,e,a){return(a==null||a>t.length)&&(a=t.length),new $(t.subarray(e,a))},sn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Mt=function(t,e,a){var r=new Error(e||sn[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Mt),!a)throw r;return r},K=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8},st=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8,t[r+2]|=a>>16},Dt=function(t,e){for(var a=[],r=0;r<t.length;++r)t[r]&&a.push({s:r,f:t[r]});var n=a.length,i=a.slice();if(!n)return{t:ba,l:0};if(n==1){var o=new $(a[0].s+1);return o[a[0].s]=1,{t:o,l:1}}a.sort(function(f,L){return f.f-L.f}),a.push({s:-1,f:25001});var s=a[0],l=a[1],c=0,d=1,u=2;for(a[0]={s:-1,f:s.f+l.f,l:s,r:l};d!=n-1;)s=a[a[c].f<a[u].f?c++:u++],l=a[c!=d&&a[c].f<a[u].f?c++:u++],a[d++]={s:-1,f:s.f+l.f,l:s,r:l};for(var m=i[0].s,r=1;r<n;++r)i[r].s>m&&(m=i[r].s);var p=new j(m+1),g=_t(a[d-1],p,0);if(g>e){var r=0,h=0,w=g-e,A=1<<w;for(i.sort(function(L,F){return p[F.s]-p[L.s]||L.f-F.f});r<n;++r){var z=i[r].s;if(p[z]>e)h+=A-(1<<g-p[z]),p[z]=e;else break}for(h>>=w;h>0;){var I=i[r].s;p[I]<e?h-=1<<e-p[I]++-1:++r}for(;r>=0&&h;--r){var M=i[r].s;p[M]==e&&(--p[M],++h)}g=e}return{t:new $(p),l:g}},_t=function(t,e,a){return t.s==-1?Math.max(_t(t.l,e,a+1),_t(t.r,e,a+1)):e[t.s]=a},Fe=function(t){for(var e=t.length;e&&!t[--e];);for(var a=new j(++e),r=0,n=t[0],i=1,o=function(l){a[r++]=l},s=1;s<=e;++s)if(t[s]==n&&s!=e)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=t[s]}return{c:a.subarray(0,r),n:e}},lt=function(t,e){for(var a=0,r=0;r<e.length;++r)a+=t[r]*e[r];return a},ga=function(t,e,a){var r=a.length,n=ha(e+2);t[n]=r&255,t[n+1]=r>>8,t[n+2]=t[n]^255,t[n+3]=t[n+1]^255;for(var i=0;i<r;++i)t[n+i+4]=a[i];return(n+4+r)*8},Se=function(t,e,a,r,n,i,o,s,l,c,d){K(e,d++,a),++n[256];for(var u=Dt(n,15),m=u.t,p=u.l,g=Dt(i,15),h=g.t,w=g.l,A=Fe(m),z=A.c,I=A.n,M=Fe(h),f=M.c,L=M.n,F=new j(19),x=0;x<z.length;++x)++F[z[x]&31];for(var x=0;x<f.length;++x)++F[f[x]&31];for(var b=Dt(F,7),D=b.t,Y=b.l,S=19;S>4&&!D[ze[S-1]];--S);var _=c+5<<3,B=lt(n,Q)+lt(i,xt)+o,U=lt(n,m)+lt(i,h)+o+14+3*S+lt(F,D)+2*F[16]+3*F[17]+7*F[18];if(l>=0&&_<=B&&_<=U)return ga(e,d,t.subarray(l,l+c));var N,k,O,V;if(K(e,d,1+(U<B)),d+=2,U<B){N=dt(m,p,0),k=m,O=dt(h,w,0),V=h;var Pt=dt(D,Y,0);K(e,d,I-257),K(e,d+5,L-1),K(e,d+10,S-4),d+=14;for(var x=0;x<S;++x)K(e,d+3*x,D[ze[x]]);d+=3*S;for(var X=[z,f],ot=0;ot<2;++ot)for(var et=X[ot],x=0;x<et.length;++x){var G=et[x]&31;K(e,d,Pt[G]),d+=D[G],G>15&&(K(e,d,et[x]>>5&127),d+=et[x]>>12)}}else N=nn,k=Q,O=on,V=xt;for(var x=0;x<s;++x){var T=r[x];if(T>255){var G=T>>18&31;st(e,d,N[G+257]),d+=k[G+257],G>7&&(K(e,d,T>>23&31),d+=Qt[G]);var at=T&31;st(e,d,O[at]),d+=V[at],at>3&&(st(e,d,T>>5&8191),d+=te[at])}else st(e,d,N[T]),d+=k[T]}return st(e,d,N[256]),d+k[256]},ln=new qt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ba=new $(0),cn=function(t,e,a,r,n,i){var o=i.z||t.length,s=new $(r+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(r,s.length-n),c=i.l,d=(i.r||0)&7;if(e){d&&(l[0]=i.r>>3);for(var u=ln[e-1],m=u>>13,p=u&8191,g=(1<<a)-1,h=i.p||new j(32768),w=i.h||new j(g+1),A=Math.ceil(a/3),z=2*A,I=function(It){return(t[It]^t[It+1]<<A^t[It+2]<<z)&g},M=new qt(25e3),f=new j(288),L=new j(32),F=0,x=0,b=i.i||0,D=0,Y=i.w||0,S=0;b+2<o;++b){var _=I(b),B=b&32767,U=w[_];if(h[B]=U,w[_]=B,Y<=b){var N=o-b;if((F>7e3||D>24576)&&(N>423||!c)){d=Se(t,l,0,M,f,L,x,D,S,b-S,d),D=F=x=0,S=b;for(var k=0;k<286;++k)f[k]=0;for(var k=0;k<30;++k)L[k]=0}var O=2,V=0,Pt=p,X=B-U&32767;if(N>2&&_==I(b-X))for(var ot=Math.min(m,N)-1,et=Math.min(32767,b),G=Math.min(258,N);X<=et&&--Pt&&B!=U;){if(t[b+O]==t[b+O-X]){for(var T=0;T<G&&t[b+T]==t[b+T-X];++T);if(T>O){if(O=T,V=X,T>ot)break;for(var at=Math.min(X,T-2),be=0,k=0;k<at;++k){var Lt=b-X+k&32767,ar=h[Lt],we=Lt-ar&32767;we>be&&(be=we,U=Lt)}}}B=U,U=h[B],X+=B-U&32767}if(V){M[D++]=268435456|$t[O]<<18|Me[V];var xe=$t[O]&31,ve=Me[V]&31;x+=Qt[xe]+te[ve],++f[257+xe],++L[ve],Y=b+O,++F}else M[D++]=t[b],++f[t[b]]}}for(b=Math.max(b,Y);b<o;++b)M[D++]=t[b],++f[t[b]];d=Se(t,l,c,M,f,L,x,D,S,b-S,d),c||(i.r=d&7|l[d/8|0]<<3,d-=7,i.h=w,i.p=h,i.i=b,i.w=Y)}else{for(var b=i.w||0;b<o+c;b+=65535){var Et=b+65535;Et>=o&&(l[d/8|0]=c,Et=o),d=ga(l,d+1,t.subarray(b,Et))}i.i=o}return fa(s,0,r+ha(d)+n)},dn=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var a=e,r=9;--r;)a=(a&1&&-306674912)^a>>>1;t[e]=a}return t})(),wa=function(){var t=-1;return{p:function(e){for(var a=t,r=0;r<e.length;++r)a=dn[a&255^e[r]]^a>>>8;t=a},d:function(){return~t}}},xa=function(t,e,a,r,n){if(!n&&(n={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),o=new $(i.length+t.length);o.set(i),o.set(t,i.length),t=o,n.w=i.length}return cn(t,e.level==null?6:e.level,e.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,a,r,n)},va=function(t,e){var a={};for(var r in t)a[r]=t[r];for(var r in e)a[r]=e[r];return a},C=function(t,e,a){for(;a;++e)t[e]=a,a>>>=8},un=function(t,e){var a=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&C(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),a){t[3]=8;for(var r=0;r<=a.length;++r)t[r+10]=a.charCodeAt(r)}},mn=function(t){return 10+(t.filename?t.filename.length+1:0)};function pn(t,e){return xa(t,e||{},0,0)}function hn(t,e){e||(e={});var a=wa(),r=t.length;a.p(t);var n=xa(t,e,mn(e),8),i=n.length;return un(n,e),C(n,i-8,a.d()),C(n,i-4,r),n}var ya=function(t,e,a,r){for(var n in t){var i=t[n],o=e+n,s=r;Array.isArray(i)&&(s=va(r,i[1]),i=i[0]),i instanceof $?a[o]=[i,s]:(a[o+="/"]=[new $(0),s],ya(i,o,a,r))}},Ce=typeof TextEncoder<"u"&&new TextEncoder,fn=typeof TextDecoder<"u"&&new TextDecoder,gn=0;try{fn.decode(ba,{stream:!0}),gn=1}catch{}function mt(t,e){var a;if(Ce)return Ce.encode(t);for(var r=t.length,n=new $(t.length+(t.length>>1)),i=0,o=function(d){n[i++]=d},a=0;a<r;++a){if(i+5>n.length){var s=new $(i+8+(r-a<<1));s.set(n),n=s}var l=t.charCodeAt(a);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|t.charCodeAt(++a)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return fa(n,0,i)}var Vt=function(t){var e=0;if(t)for(var a in t){var r=t[a].length;r>65535&&Mt(9),e+=r+4}return e},Pe=function(t,e,a,r,n,i,o,s){var l=r.length,c=a.extra,d=s&&s.length,u=Vt(c);C(t,e,o!=null?33639248:67324752),e+=4,o!=null&&(t[e++]=20,t[e++]=a.os),t[e]=20,e+=2,t[e++]=a.flag<<1|(i<0&&8),t[e++]=n&&8,t[e++]=a.compression&255,t[e++]=a.compression>>8;var m=new Date(a.mtime==null?Date.now():a.mtime),p=m.getFullYear()-1980;if((p<0||p>119)&&Mt(10),C(t,e,p<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>1),e+=4,i!=-1&&(C(t,e,a.crc),C(t,e+4,i<0?-i-2:i),C(t,e+8,a.size)),C(t,e+12,l),C(t,e+14,u),e+=16,o!=null&&(C(t,e,d),C(t,e+6,a.attrs),C(t,e+10,o),e+=14),t.set(r,e),e+=l,u)for(var g in c){var h=c[g],w=h.length;C(t,e,+g),C(t,e+2,w),t.set(h,e+4),e+=4+w}return d&&(t.set(s,e),e+=d),e},bn=function(t,e,a,r,n){C(t,e,101010256),C(t,e+8,a),C(t,e+10,a),C(t,e+12,r),C(t,e+16,n)};function wn(t,e){e||(e={});var a={},r=[];ya(t,"",a,e);var n=0,i=0;for(var o in a){var s=a[o],l=s[0],c=s[1],d=c.level==0?0:8,u=mt(o),m=u.length,p=c.comment,g=p&&mt(p),h=g&&g.length,w=Vt(c.extra);m>65535&&Mt(11);var A=d?pn(l,c):l,z=A.length,I=wa();I.p(l),r.push(va(c,{size:l.length,crc:I.d(),c:A,f:u,m:g,u:m!=o.length||g&&p.length!=h,o:n,compression:d})),n+=30+m+w+z,i+=76+2*(m+w)+(h||0)+z}for(var M=new $(i+22),f=n,L=i-n,F=0;F<r.length;++F){var u=r[F];Pe(M,u.o,u,u.f,u.u,u.c.length);var x=30+u.f.length+Vt(u.extra);M.set(u.c,u.o+x),Pe(M,n,u,u.f,u.u,u.c.length,u.o,u.m),n+=16+x+(u.m?u.m.length:0)}return bn(M,n,r.length,L,f),M}const xn="gzip";function ee(t){return{bytes:hn(t),compression:xn}}const Le=1,Ee=2,Ie=4,Be=8,De=16,vn=32,Ue=1,Ne=2,Oe=4,Te=8,Re=16,yn=32,$e=64,je=128;function ae(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.lineDistances&&(e+=t.lineDistances.byteLength),t.linePattern&&(e+=64+t.linePattern.pattern.length*8),e}function re(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.gradientPositions&&(e+=t.gradientPositions.byteLength),t.uvs&&(e+=t.uvs.byteLength),t.texture&&(e+=t.texture.bytes.byteLength+64),t.hatchPattern&&(e+=128),t.gradientFill&&(e+=64),e}function ka(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=Le),e.linePattern&&(a|=Ee),e.lineDistances&&e.lineDistances.length>0&&(a|=Ie),e.lineWidth!=null&&e.lineWidth>0&&(a|=Be),e.renderOrder!=null&&e.renderOrder!==0&&(a|=De),e.excludeFromOsnap&&(a|=vn),t.writeU8(a),a&Le&&t.writeUint32Array(e.indices),a&Ee&&t.writeJson(e.linePattern),a&Ie&&t.writeFloat32Array(e.lineDistances),a&Be&&t.writeF32(e.lineWidth),a&De&&t.writeI32(e.renderOrder)}function Aa(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=Ue),e.hatchPattern&&(a|=Ne),e.gradientFill&&(a|=Oe),e.gradientPositions&&e.gradientPositions.length>0&&(a|=Te),e.side!=null&&(a|=Re),e.points&&(a|=yn),e.renderOrder!=null&&e.renderOrder!==0&&(a|=$e),e.texture&&e.texture.bytes.length>0&&e.uvs&&e.uvs.length>=2&&(a|=je),t.writeU8(a),a&Ue&&t.writeUint32Array(e.indices),a&Ne&&t.writeJson(e.hatchPattern),a&Oe&&t.writeJson(e.gradientFill),a&Te&&t.writeFloat32Array(e.gradientPositions),a&Re&&t.writeU8(e.side),a&$e&&t.writeI32(e.renderOrder),a&je&&(t.writeFloat32Array(e.uvs),t.writeString(e.texture.mimeType||"image/png"),t.writeU32(e.texture.bytes.byteLength),t.writeBytes(e.texture.bytes))}class ne{constructor(){this.chunks=[],this.length=0}writeU8(e){const a=new Uint8Array(1);a[0]=e&255,this.chunks.push(a),this.length+=1}writeU32(e){const a=new Uint8Array(4);new DataView(a.buffer).setUint32(0,e>>>0,!0),this.chunks.push(a),this.length+=4}writeI32(e){const a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,e|0,!0),this.chunks.push(a),this.length+=4}writeF32(e){const a=new Uint8Array(4);new DataView(a.buffer).setFloat32(0,e,!0),this.chunks.push(a),this.length+=4}writeF64(e){const a=new Uint8Array(8);new DataView(a.buffer).setFloat64(0,e,!0),this.chunks.push(a),this.length+=8}writeBytes(e){this.chunks.push(e),this.length+=e.length}writeString(e){const a=mt(e);this.writeU32(a.length),this.writeBytes(a)}writeJson(e){this.writeString(JSON.stringify(e))}writeFloat32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}writeUint32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}alignTo(e){const a=this.length%e;if(a===0)return;const r=e-a;for(let n=0;n<r;n++)this.writeU8(0)}toUint8Array(){const e=new Uint8Array(this.length);let a=0;for(const r of this.chunks)e.set(r,a),a+=r.length;return e}}const kn=1329939265,An=1,zn=1,Mn=2,Fn=3,Sn=4,Cn=5,Pn=6,Ln=7;function za(t){var e;switch(t.kind){case"line":return 37;case"circle":return 30;case"arc":return 46;case"ellipse":return 71;case"point":return 21;case"path":return 10+t.vertices.length*8;case"spline":return 10+(t.controlPoints.length+t.knots.length+t.weights.length+(((e=t.fitPoints)==null?void 0:e.length)??0))*8+16;default:return t}}function En(t,e){if(t.length===0)return[];const a=[];let r=[],n=64;const i=()=>{r.length!==0&&(a.push(r),r=[],n=64)};for(const o of t){const s=za(o);r.length>0&&n+s>e&&i(),r.push(o),n+=s}return i(),a}function Ma(t){const e=new ne;e.writeU32(kn),e.writeU8(An),e.writeU8(0),e.writeU8(0),e.writeU8(0);const a=[],r=new Map,n=i=>{const o=r.get(i);if(o!=null)return o;const s=a.length;return a.push(i),r.set(i,s),s};for(const i of t.primitives)n(i.layer);e.writeU32(a.length);for(const i of a)e.writeString(i);e.writeU32(t.primitives.length);for(const i of t.primitives)Bn(e,i,n(i.layer));return e.toUint8Array()}function In(t){const e=Ma(t),a=ee(e).bytes;return{uncompressed:e,compressed:a}}function Ut(t,e){t.writeU8(e<0?0:1)}function ct(t,e){t.writeU32(e.length);for(const a of e)t.writeF64(a)}function Bn(t,e,a){switch(e.kind){case"line":t.writeU8(zn),t.writeU32(a),t.writeF64(e.x0),t.writeF64(e.y0),t.writeF64(e.x1),t.writeF64(e.y1);return;case"circle":t.writeU8(Mn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),Ut(t,e.normalSign);return;case"arc":t.writeU8(Fn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),t.writeF64(e.startAngle),t.writeF64(e.endAngle),Ut(t,e.normalSign);return;case"ellipse":t.writeU8(Sn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.majorX),t.writeF64(e.majorY),t.writeF64(e.majorR),t.writeF64(e.minorR),t.writeF64(e.startAngle),t.writeF64(e.endAngle),t.writeU8(e.closed?1:0),Ut(t,e.normalSign??1);return;case"spline":t.writeU8(Cn),t.writeU32(a),ct(t,e.controlPoints),t.writeU32(e.degree),ct(t,e.knots),ct(t,e.weights),t.writeU8(e.closed?1:0),ct(t,e.fitPoints??[]);return;case"point":t.writeU8(Pn),t.writeU32(a),t.writeF64(e.x),t.writeF64(e.y);return;case"path":t.writeU8(Ln),t.writeU32(a),t.writeU8(e.closed?1:0),ct(t,e.vertices);return;default:{const r=e;throw new Error(`Unsupported osnap primitive: ${String(r)}`)}}}const Dn=1480934209;function Un(t){if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=new ne;e.writeU32(Dn),e.writeU8(J),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeJson(Nn(t)),e.writeJson(t.layers),e.writeString(t.activeLayoutBtrId),e.writeU32(t.layouts.length);for(const a of t.layouts)On(e,a);return e.toUint8Array()}function Nn(t){const e={...t.meta.savedViews??{}};for(const a of t.layouts)a.savedView&&(e[a.btrId]=a.savedView);if(Object.keys(e).length===0){if(t.meta.savedViews==null)return t.meta;const{savedViews:a,...r}=t.meta;return r}return{...t.meta,savedViews:e}}function On(t,e){t.writeString(e.btrId),t.writeString(e.name),t.writeU8(e.isModelSpace?1:0),Tn(t,e.osnap),t.writeJson(e.viewports??null),t.writeU32(e.lineBatches.length);for(const a of e.lineBatches)ka(t,a);t.writeU32(e.meshBatches.length);for(const a of e.meshBatches)Aa(t,a)}function Tn(t,e){if(!e||e.primitives.length===0){t.writeU32(0);return}const a=Ma(e);t.writeU32(a.length),t.writeBytes(a)}const Rn="application/vnd.mlightcad.acex-snapshot+binary";function Fa(t){if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=Un(t),a=ee(e);return{payload:jn(a.bytes),compression:a.compression}}function $n(){return Rn}function jn(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function tt(t,e,a){if(a<=0)return new Float32Array(0);const r=new Float32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function _n(t,e,a){if(a<=0)return new Uint32Array(0);const r=new Uint32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function Sa(t,e){if(e.length===0)return{positions:t,indices:e};let a=0;for(let n=0;n<e.length;n++){const i=e[n];i>a&&(a=i)}const r=(a+1)*3;return r>=t.length?{positions:t,indices:e}:{positions:tt(t,0,r),indices:e}}function _e(t,e){return t+e}const rt={x:0,y:0,z:0};function Vn(t){t.updateMatrixWorld(!0);const e=t.matrixWorld.elements;return rt.x=e[12],rt.y=e[13],rt.z=e[14],[rt.x,rt.y,rt.z]}function Hn(t,e){const a=e.elements,r=t.positions;if(r.length===0)return{positions:new Float32Array(0),indices:t.indices};const n=new Float32Array(r.length);for(let i=0;i<r.length;i+=3){const o=r[i],s=r[i+1],l=r[i+2];n[i]=a[0]*o+a[4]*s+a[8]*l+a[12],n[i+1]=a[1]*o+a[5]*s+a[9]*l+a[13],n[i+2]=a[2]*o+a[6]*s+a[10]*l+a[14]}return{positions:n,indices:t.indices?new Uint32Array(t.indices):void 0}}function Yn(t){const e=t.positions;if(e.length<3)return{slice:t,offset:[0,0,0]};let a=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,s=-1/0;for(let d=0;d<e.length;d+=3){const u=e[d],m=e[d+1],p=e[d+2];a=Math.min(a,u),r=Math.min(r,m),n=Math.min(n,p),i=Math.max(i,u),o=Math.max(o,m),s=Math.max(s,p)}const l=[(a+i)/2,(r+o)/2,(n+s)/2],c=new Float32Array(e.length);for(let d=0;d<e.length;d+=3)c[d]=e[d]-l[0],c[d+1]=e[d+1]-l[1],c[d+2]=e[d+2]-l[2];return{slice:{positions:c,indices:t.indices?new Uint32Array(t.indices):void 0},offset:l}}function Xn(t,e,a={}){t.updateMatrixWorld(!0);const r=Hn(e,t.matrixWorld);return Yn(r)}function Gn(t){const e=t.image;if(!e||typeof document>"u")return;const a=document.createElement("canvas"),r=a.getContext("2d");if(!r)return;try{if(e instanceof ImageData)a.width=e.width,a.height=e.height,r.putImageData(e,0,0);else if(Wn(e)){a.width=e.width,a.height=e.height;const l=Zn(e.data,e.width*e.height),c=new ImageData(new Uint8ClampedArray(l),e.width,e.height);r.putImageData(c,0,0)}else if(Kn(e)){const l=Jn(e);if(!l)return;a.width=l.width,a.height=l.height,r.drawImage(e,0,0)}else return}catch{return}const n=a.toDataURL("image/png"),i=n.indexOf(",");if(i<0)return;const o=atob(n.slice(i+1)),s=new Uint8Array(o.length);for(let l=0;l<o.length;l++)s[l]=o.charCodeAt(l);return{mimeType:"image/png",bytes:s}}function Kn(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}function Wn(t){if(!t||typeof t!="object")return!1;const e=t;return e.data!=null&&typeof e.width=="number"&&typeof e.height=="number"&&e.width>=1&&e.height>=1}function Jn(t){let e=Number(t.width),a=Number(t.height);if(t instanceof HTMLImageElement?(e=t.naturalWidth||t.width,a=t.naturalHeight||t.height):typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement&&(e=t.videoWidth||t.width,a=t.videoHeight||t.height),!(!Number.isFinite(e)||!Number.isFinite(a)||e<1||a<1))return{width:e,height:a}}function Zn(t,e){const a=e*4;if(t instanceof Uint8ClampedArray&&t.length>=a)return t.length===a?t:t.subarray(0,a);const r=new Uint8ClampedArray(a),n=Math.min(a,t.length);for(let i=0;i<n;i++)r[i]=t[i];if(t.length>=e*3&&t.length<a)for(let i=e-1;i>=0;i--){const o=i*3,s=i*4;r[s]=t[o],r[s+1]=t[o+1],r[s+2]=t[o+2],r[s+3]=255}return r}function qn(t,e){const a=t.getAttribute("uv");if(!a||a.count===0||a.itemSize<2)return;const r=Math.floor(e.length/3)*2;if(r<=0)return;const n=a.array;if(!(a.count*a.itemSize<r))return tt(n,0,r)}function Qn(t){const e=t;return e.map?!1:e.transparent===!0&&typeof e.opacity=="number"&&e.opacity<.01}function ie(t){const e=t;if(e.isShaderMaterial===!0||t.type==="ShaderMaterial")return e}function ti(t){var e;const a=ie(t);if(!a)return;const r=a.uniforms.pattern,n=a.uniforms.patternLength;if(!r||!n)return;const i=r.value;if(!(!Array.isArray(i)||i.length===0))return{pattern:[...i],patternLength:Number(n.value),viewportScale:Number(((e=a.uniforms.u_viewportScale)==null?void 0:e.value)??1)}}function ei(t){var e;const a=ie(t);if(!a)return;const r=a.uniforms.u_patternLines;if(!r)return;const n=r.value;if(!(!Array.isArray(n)||n.length===0))return{patternAngle:Number(((e=a.uniforms.u_patternAngle)==null?void 0:e.value)??0),patternLines:n.map(ri)}}function ai(t){var e,a,r,n,i;const o=ie(t);if(!o||o.uniforms.u_patternLines)return;const s=(e=o.uniforms.u_startColor)==null?void 0:e.value,l=(a=o.uniforms.u_endColor)==null?void 0:a.value,c=o.uniforms.u_gradientType;if(!(!(s!=null&&s.getHex)||c==null))return{startColor:s.getHex(),endColor:((r=l==null?void 0:l.getHex)==null?void 0:r.call(l))??s.getHex(),angle:Number(((n=o.uniforms.u_angle)==null?void 0:n.value)??0),shift:Number(((i=o.uniforms.u_shift)==null?void 0:i.value)??0),gradientType:Number(c.value)}}function ri(t){return{angle:t.angle,base:[t.base.x,t.base.y],offset:[t.offset.x,t.offset.y],dashLengths:[...t.dashLengths],patternLength:t.patternLength}}function Ca(t){const e=t.length/3;if(e<2)return new Float32Array(0);const a=new Float32Array(e);for(let r=0;r<e;r+=2){r===0?a[r]=0:a[r]=a[r-1];const n=t[r*3],i=t[r*3+1],o=t[r*3+2]??0,s=t[(r+1)*3],l=t[(r+1)*3+1],c=t[(r+1)*3+2]??0,d=s-n,u=l-i,m=c-o;a[r+1]=a[r]+Math.sqrt(d*d+u*u+m*m)}return a}function ni(t,e){const a=t.getAttribute(e);if(!a||a.count===0)return;const r=a.itemSize;if(t.getIndex()){const d=a.array;return tt(d,0,a.count*r)}const n=t.drawRange,i=a.count,o=Math.max(0,Math.min(Math.floor(n.start),i)),s=Math.max(0,i-o),l=!Number.isFinite(n.count)||n.count<=0?s:Math.min(Math.floor(n.count),s);if(l<=0)return;const c=a.array;return tt(c,o*r,l*r)}function Ve(t,e){const a=Math.atan2(e[1],e[0]),r=(i,o)=>[e[0]*i+e[4]*o+e[12],e[1]*i+e[5]*o+e[13]],n=(i,o)=>[e[0]*i+e[4]*o,e[1]*i+e[5]*o];return{patternAngle:t.patternAngle+a,patternLines:t.patternLines.map(i=>({angle:i.angle+a,base:r(i.base[0],i.base[1]),offset:n(i.offset[0],i.offset[1]),dashLengths:[...i.dashLengths],patternLength:i.patternLength}))}}function ii(t,e){return{patternAngle:t.patternAngle,patternLines:t.patternLines.map(a=>{const r=new P.Vector2(a.base[0]-e[0],a.base[1]-e[1]),n=new P.Vector2(a.offset[0],a.offset[1]);return yr(r,n,a.angle,t.patternAngle,a.patternLength),{angle:a.angle,base:[r.x,r.y],offset:[a.offset[0],a.offset[1]],dashLengths:[...a.dashLengths],patternLength:a.patternLength}})}}function Ht(t,e){return!Number.isFinite(t)||t<0?0:Math.min(Math.floor(t),e)}function Yt(t,e,a){const r=Math.max(0,e-a);return!Number.isFinite(t)||t<=0?r:Math.min(Math.floor(t),r)}function He(t){const e=t.getAttribute("position");if(!e)return{positions:new Float32Array(0)};const a=t.drawRange,r=e.array,n=e.itemSize,i=t.getIndex();if(i){const l=tt(r,0,e.count*n),c=i.array,d=Ht(a.start,i.count),u=Yt(a.count,i.count,d),m=_n(c,d,u);return Sa(l,m)}const o=Ht(a.start,e.count),s=Yt(a.count,e.count,o);return{positions:tt(r,o*n,s*n)}}function vt(t){return Yr(t.flags)&&Xr(t.flags)}function Pa(t){const{count:e}=t.mappingStats;for(let a=0;a<e;a++){let r;try{r=t.getGeometryRangeAt(a)}catch{continue}if(vt(r)&&r.bboxIntersectionCheck)return!0}return!1}function Ye(t){return vr(t).bboxIntersectionCheck===!0}function oe(t,e){const a=e.getAttribute("position");if(!a)return{positions:new Float32Array(0)};const r=a.itemSize,n=a.array,i=e.getIndex(),{count:o}=t.mappingStats;if(i){const l=tt(n,0,a.count*r),c=i.array,d=[];for(let u=0;u<o;u++){let m;try{m=t.getGeometryRangeAt(u)}catch{continue}const p=m.indexStart??0,g=m.indexCount??0;if(!(!vt(m)||g<=0))for(let h=0;h<g;h++)d.push(c[p+h])}return d.length===0?{positions:new Float32Array(0)}:Sa(l,new Uint32Array(d))}const s=[];for(let l=0;l<o;l++){let c;try{c=t.getGeometryRangeAt(l)}catch{continue}if(!vt(c)||c.vertexCount<=0)continue;const d=c.vertexStart*r,u=c.vertexCount*r;for(let m=0;m<u;m++)s.push(n[d+m])}return{positions:new Float32Array(s)}}function yt(t,e,a){t.push(e.getX(a),e.getY(a),e.getZ(a))}function oi(t,e){const a=e.getAttribute("instanceStart"),r=e.getAttribute("instanceEnd");if(!a||!r)return{positions:new Float32Array(0)};const{count:n}=t.mappingStats,i=[];for(let o=0;o<n;o++){let s;try{s=t.getGeometryRangeAt(o)}catch{continue}if(!vt(s)||s.vertexCount<=0)continue;const l=s.vertexStart,c=l+s.vertexCount;for(let d=l;d<c;d++)yt(i,a,d),yt(i,r,d)}return{positions:new Float32Array(i)}}function si(t,e){const a=t.instanceCount;if(Number.isFinite(a)&&a>=0)return Math.min(Math.floor(a),e);const r=t.drawRange,n=Ht(r.start,e);return Yt(r.count,e,n)}function li(t){const e=t.getAttribute("instanceStart"),a=t.getAttribute("instanceEnd");if(!e||!a||e.count===0)return{positions:new Float32Array(0)};const r=si(t,e.count);if(r<=0)return{positions:new Float32Array(0)};const n=[];for(let i=0;i<r;i++)yt(n,e,i),yt(n,a,i);return{positions:new Float32Array(n)}}function Nt(t){return wr(t)}function La(t){if(t instanceof xr)return t.linewidth}function Ot(t){if("material"in t){const e=t.userData.originalMaterial??t.material;return Array.isArray(e)?e[0]:e}return t.material}function pt(t){var e;const a=da(t),r=a.layer??"0",n=t;let i=n.color!=null?n.color.getHex():a.color??16777215;const o=ti(t),s=ei(t),l=ai(t);if(t instanceof P.ShaderMaterial||t.type==="ShaderMaterial"){const c=(e=t.uniforms.u_color)==null?void 0:e.value;c!=null&&c.getHex?i=c.getHex():l&&(i=l.startColor)}return{color:i,layer:r,linePattern:o,hatchPattern:s,gradientFill:l,side:s||l?t.side:void 0}}function ci(t,e){const a=da(e).drawOrder??t.renderOrder;return a===0?void 0:a}function ht(t,e,a){const r=ci(e,a);r!=null&&(t.renderOrder=r)}function di(t,e){if(!e)return;const a=t.userData.bakedWorldMatrix;return a&&a.length>=16?Ve(e,a):(t.updateMatrixWorld(!0),Ve(e,Array.from(t.matrixWorld.elements)))}function Ft(t){return Vn(t)}function Tt(t,e,a={}){const r=Xn(t,e,a);return{...r.slice,offset:r.offset}}function se(t,e,a,r,n){const i=pt(e),o=di(a,i.hatchPattern),s=o?ii(o,n):void 0,l=i.gradientFill?ni(t,"gradientPosition"):void 0,c={layer:i.layer,color:i.color,offset:n,hatchPattern:s,gradientFill:i.gradientFill,gradientPositions:l,side:i.side,...r},d=e;if(d.map){const u=Gn(d.map),m=qn(t,r.positions);if(!u||!m)return;c.texture=u,c.uvs=m,c.color=16777215,c.side=P.DoubleSide}return ht(c,a,e),c}function ui(t){const e=oi(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r}=pt(t.material),n=La(t.material),i={layer:r,color:a,offset:Ft(t),lineWidth:n,...e};return Pa(t)&&(i.excludeFromOsnap=!0),ht(i,t,t.material),i}function mi(t){const e=oe(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r,linePattern:n}=pt(t.material),i=n?Ca(e.positions):void 0,o={layer:r,color:a,offset:Ft(t),linePattern:n,lineDistances:i,...e};return Pa(t)&&(o.excludeFromOsnap=!0),ht(o,t,t.material),o}function pi(t){const e=oe(t,t.geometry);if(e.positions.length!==0)return se(t.geometry,t.material,t,e,Ft(t))}function hi(t){const e=oe(t,t.geometry);if(e.positions.length===0)return;const a=se(t.geometry,t.material,t,e,Ft(t));if(a)return{points:!0,...a}}function fi(t){const e=[],a=[];return t.traverse(r=>{if(!(lr(r)||cr(r))){if(r instanceof ke){const n=mi(r);n&&e.push(n);return}if(r instanceof dr){const n=ui(r);n&&e.push(n);return}if(r instanceof Ae){const n=pi(r);n&&a.push(n);return}if(r instanceof ur){const n=hi(r);n&&a.push(n);return}if(r instanceof mr){if(!Nt(r))return;const n=li(r.geometry);if(n.positions.length===0)return;const i=Ot(r),{color:o,layer:s}=pt(i),{offset:l,...c}=Tt(r,n),d={layer:s,color:o,offset:l,lineWidth:La(i),...c};Ye(r)&&(d.excludeFromOsnap=!0),ht(d,r,i),e.push(d)}else if(r instanceof P.LineSegments&&!(r instanceof ke)){if(!Nt(r))return;const n=He(r.geometry);if(n.positions.length===0)return;const i=Ot(r),{color:o,layer:s,linePattern:l}=pt(i),{offset:c,...d}=Tt(r,n),u=l?Ca(d.positions):void 0,m={layer:s,color:o,offset:c,linePattern:l,lineDistances:u,...d};Ye(r)&&(m.excludeFromOsnap=!0),ht(m,r,i),e.push(m)}else if(r instanceof P.Mesh&&!(r instanceof Ae)){if(!Nt(r))return;const n=Ot(r);if(Qn(n))return;const i=He(r.geometry);if(i.positions.length===0)return;const{offset:o,...s}=Tt(r,i),l=se(r.geometry,n,r,s,o);l&&a.push(l)}}}),{lineBatches:e,meshBatches:a}}const Xe={size:8,colorCss:"#0080ff",hotColorCss:"#ff0000"};function Ge(t){const e=new gr(br.ByACI,t);return e.cssColor??`rgb(${e.red}, ${e.green}, ${e.blue})`}function gi(t){try{const e=sr.instance(),a=e.getVar(Bt.GRIPSIZE,t),r=e.getVar(Bt.GRIPCOLOR,t),n=e.getVar(Bt.GRIPHOT,t);return!(a>0)||!Number.isFinite(a)?Xe:{size:a,colorCss:Ge(r),hotColorCss:Ge(n)}}catch{return Xe}}function Ke(t,e){const a=t.extmin,r=t.extmax,n=gi(t);return{title:e==null?void 0:e.title,extents:{minX:a.x,minY:a.y,maxX:r.x,maxY:r.y},units:{insunits:t.insunits,lunits:t.lunits,luprec:t.luprec,aunits:t.aunits,auprec:t.auprec,measurement:t.measurement,ltscale:t.ltscale,angbase:t.angbase,angdir:t.angdir},grip:n,background:(e==null?void 0:e.background)??0}}function We(t,e,a,r,n){return Math.atan2(r-e,n*(a-t))}function le(t){return t.z>=0?1:-1}function Ea(t,e,a){if(!(a.radius>0)||!Number.isFinite(a.radius))return;const r=a.clockwise?-1:1,n=a.center.x,i=a.center.y;t.push({kind:"arc",layer:e,cx:n,cy:i,r:a.radius,startAngle:We(n,i,a.startPoint.x,a.startPoint.y,r),endAngle:We(n,i,a.endPoint.x,a.endPoint.y,r),normalSign:r})}function E(t,e){const a=new P.Vector3(e.x,e.y,e.z??0).applyMatrix4(t);return{x:a.x,y:a.y}}function bi(t){const e=t.elements;return new P.Matrix4(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}function kt(t,e){return new P.Matrix4().multiplyMatrices(t,bi(e))}function Ia(t,e){const a=new P.Vector3(e.x,e.y,e.z??0).transformDirection(t).normalize();return{x:a.x,y:a.y}}function Xt(t){const e=new P.Vector3(t.elements[0],t.elements[1],t.elements[2]).length(),a=new P.Vector3(t.elements[4],t.elements[5],t.elements[6]).length();return it.equal(e,a,ua*Math.max(e,a,1))}function wi(t,e){const a=t.tables.blockTable.getIdAt(e);if(a)return a;for(const n of t.tables.blockTable.newIterator())if(n.objectId===e)return n;const r=t.tables.blockTable.modelSpace;if(r.objectId===e)return r}function xi(t){if(t instanceof Gr)return!0;const e=t;return(e.type==="LINE"||e.type==="Line")&&e.startPoint!=null&&e.endPoint!=null}function vi(t,e,a,r){r.startPoint,r.endPoint}function Ba(t,e){return t.blockTableRecord??(t.blockName?e.tables.blockTable.getAt(t.blockName):void 0)}function yi(t,e){const a=t.dimBlockId;return a?e.tables.blockTable.getAt(a):void 0}function ki(t,e){const a=Ba(t,e);if(a)return a;const r=t.owningBlockRecordId;return r?e.tables.blockTable.getAt(r):void 0}function Da(t){return t.getFullInsertionTransform()}function Ai(t){for(const e of t.newIterator())return!0;return!1}function zi(t){return typeof t.getFullInsertionTransform=="function"&&"blockTableRecord"in t}function Z(t,e,a,r,n){if(r.length<2)return;const i=Xt(a),o=a.elements[0]*a.elements[5]-a.elements[4]*a.elements[1]<0?-1:1,s=[];for(const l of r){const c=E(a,l);let d=l.bulge??0;it.isPositive(Math.abs(d))&&(d=i?d*o:0),s.push(c.x,c.y,d)}t.push({kind:"path",layer:e,closed:n,vertices:s})}function Ua(t,e){return it.equal(t.x,e.x)&&it.equal(t.y,e.y)}function Mi(t){return(t.clockwise?-1:1)*Math.tan(t.deltaAngle/4)}function Je(t,e,a,r){if(t.length===0){t.push({x:e.x,y:e.y,z:e.z??0,bulge:r}),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0});return}const n=t[t.length-1];Ua(n,e)?n.bulge=r:(n.bulge=0,t.push({x:e.x,y:e.y,z:e.z??0,bulge:r})),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0})}function Ze(t){return t.length>=2&&Ua(t[0],t[t.length-1])&&t.pop(),t}function ut(t,e,a,r,n){if(r.length<2)return;const i=n?r.length:r.length-1;for(let o=0;o<i;o++)r[o],r[(o+1)%r.length]}function Fi(t,e,a,r){const n=[r.startPosition];for(const i of r.segments)n.push(i.position);ut(t,e,a,n,r.closed)}function Si(t,e,a){if(a.vertices.length>=2)return a.vertices;if(a.vertices.length===0)return[];const r=a.vertices[0],n=e.lastLeaderLinePoint??e.landingPoint??t.landingPoint??t.contentBasePosition;if(!n)return a.vertices;const i=r.x-n.x,o=r.y-n.y,s=(r.z??0)-(n.z??0);return Math.hypot(i,o,s)<=ua?a.vertices:[r,n]}function Ci(t,e,a,r){var n,i;for(const s of r.leaders)for(const l of s.leaderLines){const c=Si(r,s,l);ut(t,e,a,c,!1)}const o=s=>{if(!s)return;const l=E(a,s);t.push({kind:"point",layer:e,x:l.x,y:l.y})};o(r.contentBasePosition),o((n=r.mtextContent)==null?void 0:n.anchorPoint),o((i=r.blockContent)==null?void 0:i.position)}function Pi(t,e,a,r){const n=r.numberOfVertices;if(n<2)return;const i=r.elevation,o=r.closed?n:n-1;for(let s=0;s<o;s++){const l=r.getPointAt(s),c=r.getPointAt((s+1)%n),d=r.getBulgeAt(s),u={x:l.x,y:l.y,z:i},m={x:c.x,y:c.y,z:i};if(it.isPositive(Math.abs(d))){const p=E(a,u),g=E(a,m);Ea(t,e,new Jt(p,g,d))}}}function Li(t,e,a,r,n,i){const o=E(a,r),s=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),l={kind:"circle",layer:e,cx:o.x,cy:o.y,r:n*s,normalSign:le(i)};t.push(l)}function Ei(t,e,a,r){const n=E(a,r.center),i=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),o={kind:"arc",layer:e,cx:n.x,cy:n.y,r:r.radius*i,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:le(r.normal)};t.push(o)}function Rt(t,e,a,r){const n=E(a,r.center),i=r._geo,o=(i==null?void 0:i.majorAxis)??{x:1,y:0,z:0},s=Ia(a,o),l=Math.hypot(s.x,s.y)||1,c=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),d=new P.Vector3(a.elements[4],a.elements[5],a.elements[6]).length(),u={kind:"ellipse",layer:e,cx:n.x,cy:n.y,majorX:s.x/l,majorY:s.y/l,majorR:r.majorAxisRadius*c,minorR:r.minorAxisRadius*d,startAngle:r.startAngle,endAngle:r.endAngle,closed:r.closed,normalSign:le(r.normal)};t.push(u)}function Ii(t,e,a,r){var n,i;const o=r._geo;if(!((n=o==null?void 0:o.controlPoints)!=null&&n.length))return;const s=[];for(const c of o.controlPoints){const d=E(a,c);s.push(d.x,d.y)}const l={kind:"spline",layer:e,controlPoints:s,degree:o.degree??3,knots:[...o.knots??[]],weights:[...o.weights??[]],closed:o.closed??!1};if((i=o.fitPoints)!=null&&i.length){l.fitPoints=[];for(const c of o.fitPoints){const d=E(a,c);l.fitPoints.push(d.x,d.y)}}t.push(l)}const qe=1e-6;function Bi(t){var e;const a=t.elevation,r=(e=t._geo)==null?void 0:e.vertices;return r&&r.length>1?r.map(n=>({x:n.x,y:n.y,z:a,bulge:n.bulge,startWidth:n.startWidth,endWidth:n.endWidth})):Array.from({length:t.numberOfVertices},(n,i)=>{const o=t.getPoint2dAt(i);return{x:o.x,y:o.y,z:a,bulge:0}})}function Di(t){return t.some(e=>{const a=Math.max(0,e.startWidth??0),r=Math.max(0,e.endWidth??0);return a>qe||r>qe})}function Ui(t,e,a,r){const n=Bi(r),i=n.length;if(i<2)return;if(Di(n)){Z(t,e,a,n,r.closed);return}const o=r.closed?i:i-1;for(let s=0;s<o;s++){const l=n[s],c=n[(s+1)%i],d=l.bulge??0;if(it.isPositive(Math.abs(d))){const u=E(a,l),m=E(a,c);Ea(t,e,new Jt(u,m,d))}}}function Ni(t,e,a,r,n){const i=E(a,{x:r.center.x,y:r.center.y,z:n}),o=Ia(a,{x:Math.cos(r.rotation),y:Math.sin(r.rotation),z:0}),s=Math.hypot(o.x,o.y)||1,l=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),c=new P.Vector3(a.elements[4],a.elements[5],a.elements[6]).length();t.push({kind:"ellipse",layer:e,cx:i.x,cy:i.y,majorX:o.x/s,majorY:o.y/s,majorR:r.majorAxisRadius*l,minorR:r.minorAxisRadius*c,startAngle:r.startAngle,endAngle:r.endAngle,closed:!1,normalSign:r.clockwise?-1:1})}function Oi(t,e,a,r,n){var i;const o=r.numberOfVertices;if(o<2)return;const s=[];for(let l=0;l<o;l++){const c=r.getPointAt(l);s.push({x:c.x,y:c.y,z:n,bulge:((i=r.vertices[l])==null?void 0:i.bulge)??0})}Z(t,e,a,s,r.closed)}function Ti(t,e,a,r,n){if(r instanceof Wr){Oi(t,e,a,r,n);return}if(!(r instanceof Jr))return;const i=[];let o=!1;const s=()=>{const c=Ze(i);c.length>=2&&Z(t,e,a,c,!1),i.length=0};for(const c of r.curves)c instanceof Zr?Je(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},0):c instanceof Jt?Je(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},Mi(c)):c instanceof qr&&(o=!0,s(),Ni(t,e,a,c,n));const l=Ze(i);l.length>=2&&Z(t,e,a,l,!o)}function Ri(t,e,a,r){var n;const i=(n=r._geo)==null?void 0:n.loops;if(!(i!=null&&i.length))return;const o=r.elevation;for(const s of i)Ti(t,e,a,s,o)}function $i(t,e,a,r){kt(a,Da(r));const n=[0];for(let o=0;o<r.numColumns;o++)n.push(n[o]+r.columnWidth(o));const i=[0];for(let o=0;o<r.numRows;o++)i.push(i[o]-r.rowHeight(o));n[n.length-1],i[i.length-1];for(const o of i);for(const o of n);}function ji(t,e,a,r,n,i,o,s=!0){const l=Gt(t.layer,a);if(o&&!o(l))return;const c=ki(t,i);if(c&&!n.has(c.objectId)&&Ai(c)){n.add(c.objectId);const u=kt(e,Da(t));At(c,u,l,r,n,i,o,s),n.delete(c.objectId);return}$i(r,l,e,t);const d=E(e,t.position);r.push({kind:"point",layer:l,x:d.x,y:d.y})}function _i(t,e,a,r){let n=r.boundaryPath();if(n.length>1){const o=n[0],s=n[n.length-1];o.x===s.x&&o.y===s.y&&(o.z??0)===(s.z??0)&&(n=n.slice(0,-1))}n.length>=2&&Z(t,e,a,n,!0);const i=E(a,r.position);t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Vi(t,e,a,r){const n=r.position();Z(t,e,a,[n.upperLeft,n.upperRight,n.lowerRight,n.lowerLeft],!0);const i=E(a,r.getLocation());t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Hi(t){var e;const a=(e=t.attributeIterator)==null?void 0:e.call(t);return a?typeof a.toArray=="function"?a.toArray():[...a]:[]}function Gt(t,e){return t==="0"?e:t}function Na(t,e,a,r,n,i,o,s=!0){if(!t.visibility)return;const l=Gt(t.layer,a);if(!(o&&!o(l))){if(t instanceof kr){ji(t,e,a,r,n,i,o,s);return}if(zi(t)){const c=Ba(t,i);if(!c||n.has(c.objectId))return;n.add(c.objectId);const d=t.getFullInsertionTransform(),u=Math.max(1,t.columnCount??1),m=Math.max(1,t.rowCount??1),p=t.columnSpacing??0,g=t.rowSpacing??0,h=Gt(t.layer,a);for(let w=0;w<m;w++)for(let A=0;A<u;A++){const z=kt(e,d);(A!==0||w!==0)&&z.multiply(new P.Matrix4().makeTranslation(A*p,w*g,0));const I=E(z,{x:0,y:0,z:0});r.push({kind:"point",layer:h,x:I.x,y:I.y}),At(c,z,h,r,n,i,o,s)}for(const w of Hi(t))w instanceof Ar,w.isInvisible||Na(w,e,h,r,n,i,o,s);n.delete(c.objectId);return}if(t instanceof zr){const c=t,d=yi(c,i);if(!d||n.has(d.objectId))return;n.add(d.objectId);const u=kt(e,c.getFullDimBlockTransform());At(d,u,l,r,n,i,o,!0),n.delete(d.objectId);return}if(xi(t)){vi(r,l,e,t);return}if(t instanceof Mr){Xt(e)?Li(r,l,e,t.center,t.radius,t.normal):Rt(r,l,e,Yi(t));return}if(t instanceof Fr){Xt(e)?Ei(r,l,e,t):Rt(r,l,e,Xi(t));return}if(t instanceof Wt){Rt(r,l,e,t);return}if(t instanceof Sr){Ii(r,l,e,t);return}if(t instanceof Cr){Ui(r,l,e,t);return}if(t instanceof Pr){Pi(r,l,e,t);return}if(t instanceof Lr){const c=[];for(let d=0;d<t.numberOfVertices;d++)c.push(t.getPointAt(d));ut(r,l,e,c,t.closed);return}if(t instanceof Er){s&&Ri(r,l,e,t);return}if(t instanceof Ir){t.basePoint,t.unitDir;return}if(t instanceof Br){t.basePoint,t.unitDir;return}if(t instanceof Dr){Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof Ur){s&&Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof Nr){const c=t.subGetGripPoints();c.length>=2&&ut(r,l,e,c,c.length>=3);return}if(t instanceof Or){const c=t.vertices;c.length>=2&&ut(r,l,e,c,!1);return}if(t instanceof Tr){Fi(r,l,e,t);return}if(t instanceof Rr){Ci(r,l,e,t);return}if(t instanceof $r){const c=E(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof jr){const c=E(e,t.location);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof _r){s&&Vi(r,l,e,t);return}if(t instanceof Vr){s&&_i(r,l,e,t);return}if(t instanceof Hr){const c=E(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y})}}}function At(t,e,a,r,n,i,o,s=!0){for(const l of t.newIterator())Na(l,e,a,r,n,i,o,s)}function Yi(t){return new Wt(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,0,Kr)}function Xi(t){return new Wt(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,t.startAngle,t.endAngle)}function Gi(t,e,a={}){const r=wi(t,e);if(!r)return{primitives:[]};const n=[],i=new P.Matrix4;return At(r,i,"0",n,new Set,t,a.includeLayer),{primitives:n.filter(o=>o.kind!=="line"&&Ki(o))}}function Ki(t){switch(t.kind){case"line":return Number.isFinite(t.x0)&&Number.isFinite(t.y0)&&Number.isFinite(t.x1)&&Number.isFinite(t.y1);case"circle":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r);case"arc":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"ellipse":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.majorX)&&Number.isFinite(t.majorY)&&Number.isFinite(t.majorR)&&Number.isFinite(t.minorR)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"spline":return t.controlPoints.every(e=>Number.isFinite(e))&&t.knots.every(e=>Number.isFinite(e))&&t.weights.every(e=>Number.isFinite(e));case"point":return Number.isFinite(t.x)&&Number.isFinite(t.y);case"path":return t.vertices.length>=6&&t.vertices.length%3===0&&t.vertices.every(e=>Number.isFinite(e));default:return t}}const Wi=["en","zh","cs","tr","ar"];function ce(t){if(t==null||t==="")return null;const e=t.toLowerCase().replace("_","-");for(const a of Wi)if(e===a||e.startsWith(`${a}-`))return a;return null}const Ji=1128612673;function Zi(t){const e=new ne;e.writeU32(Ji),e.writeU8(J),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeString(t.layoutBtrId),e.writeU32(t.lineBatches.length);for(const a of t.lineBatches)ka(e,a);e.writeU32(t.meshBatches.length);for(const a of t.meshBatches)Aa(e,a);return e.toUint8Array()}function qi(t){const e=Zi(t),a=ee(e).bytes;return{uncompressed:e,compressed:a}}const Qi=1,to=2*1024*1024,St=2*1024*1024,eo=512*1024,ao=8*1024*1024,Qe=12*1024*1024,ro=2*1024*1024,Ct="drawing.acex.json",no=`./${Ct}`,Kt={layerOn:tn,layerOff:en,chevronDown:Qr},io=[90,45,30,23,18,10,5];function oo(){return`<div id="mlcad-polar-angles" role="group" data-i18n-attr="aria-label" data-i18n-key="settings.polarAngles" aria-label="Polar tracking angles" hidden>
1
+ import{W as rr,U as nr,L as bt,u as v,v as nt,b as T,S as ir,a as H,D as or,c as ye,A as sr,d as Bt,N as lr,e as cr,F as ke,R as dr,t as Ae,i as ur,f as mr,g as P,h as pr,O as hr,K as fr,j as gr,k as br,Y as wr,T as da,l as xr,B as vr,r as yr,m as kr,n as Ar,o as zr,p as Mr,q as Fr,s as Wt,w as Sr,x as Cr,y as Pr,z as Lr,C as Er,E as Ir,G as Br,H as Ur,I as Dr,J as Nr,M as Or,P as Rr,Q as Tr,V as $r,X as jr,Z as _r,_ as Vr,$ as Hr,a0 as Yr,a1 as Xr,a2 as Gr,a3 as it,a4 as ua,a5 as Kr,a6 as Jt,a7 as Wr,a8 as Jr,a9 as Zr,aa as qr}from"./index-C09XPdM4.js";import{ab as ks,ac as As}from"./index-C09XPdM4.js";function Zt(...t){return`<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 1024 1024">${t.map(a=>`<path fill="currentColor" d="${a}"/>`).join("")}</svg>`}Zt("M624 475.968V640h144a128 128 0 0 1 128 128H128a128 128 0 0 1 128-128h144V475.968a192 192 0 1 1 224 0M128 896v-64h768v64z");Zt("M512 160c320 0 512 352 512 352S832 864 512 864 0 512 0 512s192-352 512-352m0 64c-225.28 0-384.128 208.064-436.8 288 52.608 79.872 211.456 288 436.8 288 225.28 0 384.128-208.064 436.8-288-52.608-79.872-211.456-288-436.8-288m0 64a224 224 0 1 1 0 448 224 224 0 0 1 0-448m0 64a160.19 160.19 0 0 0-160 160c0 88.192 71.744 160 160 160s160-71.808 160-160-71.744-160-160-160");Zt("M876.8 156.8c0-9.6-3.2-16-9.6-22.4s-12.8-9.6-22.4-9.6-16 3.2-22.4 9.6L736 220.8c-64-32-137.6-51.2-224-60.8-160 16-288 73.6-377.6 176S0 496 0 512s48 73.6 134.4 176c22.4 25.6 44.8 48 73.6 67.2l-86.4 89.6c-6.4 6.4-9.6 12.8-9.6 22.4s3.2 16 9.6 22.4 12.8 9.6 22.4 9.6 16-3.2 22.4-9.6l704-710.4c3.2-6.4 6.4-12.8 6.4-22.4m-646.4 528Q115.2 579.2 76.8 512q43.2-72 153.6-172.8C304 272 400 230.4 512 224c64 3.2 124.8 19.2 176 44.8l-54.4 54.4C598.4 300.8 560 288 512 288c-64 0-115.2 22.4-160 64s-64 96-64 160c0 48 12.8 89.6 35.2 124.8L256 707.2c-9.6-6.4-19.2-16-25.6-22.4m140.8-96Q352 555.2 352 512c0-44.8 16-83.2 48-112s67.2-48 112-48c28.8 0 54.4 6.4 73.6 19.2zM889.599 336c-12.8-16-28.8-28.8-41.6-41.6l-48 48c73.6 67.2 124.8 124.8 150.4 169.6q-43.2 72-153.6 172.8c-73.6 67.2-172.8 108.8-284.8 115.2-51.2-3.2-99.2-12.8-140.8-28.8l-48 48c57.6 22.4 118.4 38.4 188.8 44.8 160-16 288-73.6 377.6-176S1024 528 1024 512s-48.001-73.6-134.401-176","M511.998 672c-12.8 0-25.6-3.2-38.4-6.4l-51.2 51.2c28.8 12.8 57.6 19.2 89.6 19.2 64 0 115.2-22.4 160-64 41.6-41.6 64-96 64-160 0-32-6.4-64-19.2-89.6l-51.2 51.2c3.2 12.8 6.4 25.6 6.4 38.4 0 44.8-16 83.2-48 112s-67.2 48-112 48");const Qr='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" aria-hidden="true"><path fill="currentColor" d="M10 13.5 14.5 9h-9L10 13.5Z"/></svg>',tn='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 3.53 16.09 6.97 10.09 10.29 4.18 7 10.09 3.56M10.09 2.4 2.17 7 3.31 7.65 10.09 11.45 17 7.62 18.17 7 10.08 2.37 10.09 2.4Z"/><path fill="currentColor" d="M10.25 14.83 18.17 10.22 17 9.57 10.22 13.57 3.32 9.59 2.17 10.22 10.25 14.83Z"/><path fill="currentColor" d="M10.25 17.63 18.17 13 17 12.37 10.22 16.37 3.32 12.38 2.17 13 10.25 17.63Z"/></svg>',en='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 20 20"><path fill="currentColor" d="M10.09 5.15 16.09 8.59 10.09 11.91 4.18 8.59 10.09 5.15ZM10.09 4 2.17 8.61 3.31 9.25 10.09 13.06 17 9.24 18.16 8.61 10.08 4 10.09 4Z"/><path fill="currentColor" d="M10.25 16.46 18.17 11.85 17 11.2 10.22 15.2 3.32 11.21 2.17 11.85 10.25 16.46Z"/><path fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" d="M3.5 3.5 16.5 16.5"/></svg>',J=4;var $=Uint8Array,j=Uint16Array,qt=Int32Array,Qt=new $([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),te=new $([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ze=new $([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ma=function(t,e){for(var a=new j(31),r=0;r<31;++r)a[r]=e+=1<<t[r-1];for(var n=new qt(a[30]),r=1;r<30;++r)for(var i=a[r];i<a[r+1];++i)n[i]=i-a[r]<<5|r;return{b:a,r:n}},pa=ma(Qt,2),an=pa.b,$t=pa.r;an[28]=258,$t[258]=28;var rn=ma(te,0),Me=rn.r,jt=new j(32768);for(var y=0;y<32768;++y){var W=(y&43690)>>1|(y&21845)<<1;W=(W&52428)>>2|(W&13107)<<2,W=(W&61680)>>4|(W&3855)<<4,jt[y]=((W&65280)>>8|(W&255)<<8)>>1}var dt=(function(t,e,a){for(var r=t.length,n=0,i=new j(e);n<r;++n)t[n]&&++i[t[n]-1];var o=new j(e);for(n=1;n<e;++n)o[n]=o[n-1]+i[n-1]<<1;var s;if(a){s=new j(1<<e);var l=15-e;for(n=0;n<r;++n)if(t[n])for(var c=n<<4|t[n],d=e-t[n],u=o[t[n]-1]++<<d,m=u|(1<<d)-1;u<=m;++u)s[jt[u]>>l]=c}else for(s=new j(r),n=0;n<r;++n)t[n]&&(s[n]=jt[o[t[n]-1]++]>>15-t[n]);return s}),Q=new $(288);for(var y=0;y<144;++y)Q[y]=8;for(var y=144;y<256;++y)Q[y]=9;for(var y=256;y<280;++y)Q[y]=7;for(var y=280;y<288;++y)Q[y]=8;var xt=new $(32);for(var y=0;y<32;++y)xt[y]=5;var nn=dt(Q,9,0),on=dt(xt,5,0),ha=function(t){return(t+7)/8|0},fa=function(t,e,a){return(a==null||a>t.length)&&(a=t.length),new $(t.subarray(e,a))},sn=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Mt=function(t,e,a){var r=new Error(e||sn[t]);if(r.code=t,Error.captureStackTrace&&Error.captureStackTrace(r,Mt),!a)throw r;return r},K=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8},st=function(t,e,a){a<<=e&7;var r=e/8|0;t[r]|=a,t[r+1]|=a>>8,t[r+2]|=a>>16},Ut=function(t,e){for(var a=[],r=0;r<t.length;++r)t[r]&&a.push({s:r,f:t[r]});var n=a.length,i=a.slice();if(!n)return{t:ba,l:0};if(n==1){var o=new $(a[0].s+1);return o[a[0].s]=1,{t:o,l:1}}a.sort(function(f,L){return f.f-L.f}),a.push({s:-1,f:25001});var s=a[0],l=a[1],c=0,d=1,u=2;for(a[0]={s:-1,f:s.f+l.f,l:s,r:l};d!=n-1;)s=a[a[c].f<a[u].f?c++:u++],l=a[c!=d&&a[c].f<a[u].f?c++:u++],a[d++]={s:-1,f:s.f+l.f,l:s,r:l};for(var m=i[0].s,r=1;r<n;++r)i[r].s>m&&(m=i[r].s);var p=new j(m+1),g=_t(a[d-1],p,0);if(g>e){var r=0,h=0,w=g-e,A=1<<w;for(i.sort(function(L,F){return p[F.s]-p[L.s]||L.f-F.f});r<n;++r){var z=i[r].s;if(p[z]>e)h+=A-(1<<g-p[z]),p[z]=e;else break}for(h>>=w;h>0;){var I=i[r].s;p[I]<e?h-=1<<e-p[I]++-1:++r}for(;r>=0&&h;--r){var M=i[r].s;p[M]==e&&(--p[M],++h)}g=e}return{t:new $(p),l:g}},_t=function(t,e,a){return t.s==-1?Math.max(_t(t.l,e,a+1),_t(t.r,e,a+1)):e[t.s]=a},Fe=function(t){for(var e=t.length;e&&!t[--e];);for(var a=new j(++e),r=0,n=t[0],i=1,o=function(l){a[r++]=l},s=1;s<=e;++s)if(t[s]==n&&s!=e)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=t[s]}return{c:a.subarray(0,r),n:e}},lt=function(t,e){for(var a=0,r=0;r<e.length;++r)a+=t[r]*e[r];return a},ga=function(t,e,a){var r=a.length,n=ha(e+2);t[n]=r&255,t[n+1]=r>>8,t[n+2]=t[n]^255,t[n+3]=t[n+1]^255;for(var i=0;i<r;++i)t[n+i+4]=a[i];return(n+4+r)*8},Se=function(t,e,a,r,n,i,o,s,l,c,d){K(e,d++,a),++n[256];for(var u=Ut(n,15),m=u.t,p=u.l,g=Ut(i,15),h=g.t,w=g.l,A=Fe(m),z=A.c,I=A.n,M=Fe(h),f=M.c,L=M.n,F=new j(19),x=0;x<z.length;++x)++F[z[x]&31];for(var x=0;x<f.length;++x)++F[f[x]&31];for(var b=Ut(F,7),U=b.t,Y=b.l,S=19;S>4&&!U[ze[S-1]];--S);var _=c+5<<3,B=lt(n,Q)+lt(i,xt)+o,D=lt(n,m)+lt(i,h)+o+14+3*S+lt(F,U)+2*F[16]+3*F[17]+7*F[18];if(l>=0&&_<=B&&_<=D)return ga(e,d,t.subarray(l,l+c));var N,k,O,V;if(K(e,d,1+(D<B)),d+=2,D<B){N=dt(m,p,0),k=m,O=dt(h,w,0),V=h;var Pt=dt(U,Y,0);K(e,d,I-257),K(e,d+5,L-1),K(e,d+10,S-4),d+=14;for(var x=0;x<S;++x)K(e,d+3*x,U[ze[x]]);d+=3*S;for(var X=[z,f],ot=0;ot<2;++ot)for(var et=X[ot],x=0;x<et.length;++x){var G=et[x]&31;K(e,d,Pt[G]),d+=U[G],G>15&&(K(e,d,et[x]>>5&127),d+=et[x]>>12)}}else N=nn,k=Q,O=on,V=xt;for(var x=0;x<s;++x){var R=r[x];if(R>255){var G=R>>18&31;st(e,d,N[G+257]),d+=k[G+257],G>7&&(K(e,d,R>>23&31),d+=Qt[G]);var at=R&31;st(e,d,O[at]),d+=V[at],at>3&&(st(e,d,R>>5&8191),d+=te[at])}else st(e,d,N[R]),d+=k[R]}return st(e,d,N[256]),d+k[256]},ln=new qt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ba=new $(0),cn=function(t,e,a,r,n,i){var o=i.z||t.length,s=new $(r+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(r,s.length-n),c=i.l,d=(i.r||0)&7;if(e){d&&(l[0]=i.r>>3);for(var u=ln[e-1],m=u>>13,p=u&8191,g=(1<<a)-1,h=i.p||new j(32768),w=i.h||new j(g+1),A=Math.ceil(a/3),z=2*A,I=function(It){return(t[It]^t[It+1]<<A^t[It+2]<<z)&g},M=new qt(25e3),f=new j(288),L=new j(32),F=0,x=0,b=i.i||0,U=0,Y=i.w||0,S=0;b+2<o;++b){var _=I(b),B=b&32767,D=w[_];if(h[B]=D,w[_]=B,Y<=b){var N=o-b;if((F>7e3||U>24576)&&(N>423||!c)){d=Se(t,l,0,M,f,L,x,U,S,b-S,d),U=F=x=0,S=b;for(var k=0;k<286;++k)f[k]=0;for(var k=0;k<30;++k)L[k]=0}var O=2,V=0,Pt=p,X=B-D&32767;if(N>2&&_==I(b-X))for(var ot=Math.min(m,N)-1,et=Math.min(32767,b),G=Math.min(258,N);X<=et&&--Pt&&B!=D;){if(t[b+O]==t[b+O-X]){for(var R=0;R<G&&t[b+R]==t[b+R-X];++R);if(R>O){if(O=R,V=X,R>ot)break;for(var at=Math.min(X,R-2),be=0,k=0;k<at;++k){var Lt=b-X+k&32767,ar=h[Lt],we=Lt-ar&32767;we>be&&(be=we,D=Lt)}}}B=D,D=h[B],X+=B-D&32767}if(V){M[U++]=268435456|$t[O]<<18|Me[V];var xe=$t[O]&31,ve=Me[V]&31;x+=Qt[xe]+te[ve],++f[257+xe],++L[ve],Y=b+O,++F}else M[U++]=t[b],++f[t[b]]}}for(b=Math.max(b,Y);b<o;++b)M[U++]=t[b],++f[t[b]];d=Se(t,l,c,M,f,L,x,U,S,b-S,d),c||(i.r=d&7|l[d/8|0]<<3,d-=7,i.h=w,i.p=h,i.i=b,i.w=Y)}else{for(var b=i.w||0;b<o+c;b+=65535){var Et=b+65535;Et>=o&&(l[d/8|0]=c,Et=o),d=ga(l,d+1,t.subarray(b,Et))}i.i=o}return fa(s,0,r+ha(d)+n)},dn=(function(){for(var t=new Int32Array(256),e=0;e<256;++e){for(var a=e,r=9;--r;)a=(a&1&&-306674912)^a>>>1;t[e]=a}return t})(),wa=function(){var t=-1;return{p:function(e){for(var a=t,r=0;r<e.length;++r)a=dn[a&255^e[r]]^a>>>8;t=a},d:function(){return~t}}},xa=function(t,e,a,r,n){if(!n&&(n={l:1},e.dictionary)){var i=e.dictionary.subarray(-32768),o=new $(i.length+t.length);o.set(i),o.set(t,i.length),t=o,n.w=i.length}return cn(t,e.level==null?6:e.level,e.mem==null?n.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+e.mem,a,r,n)},va=function(t,e){var a={};for(var r in t)a[r]=t[r];for(var r in e)a[r]=e[r];return a},C=function(t,e,a){for(;a;++e)t[e]=a,a>>>=8},un=function(t,e){var a=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&C(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),a){t[3]=8;for(var r=0;r<=a.length;++r)t[r+10]=a.charCodeAt(r)}},mn=function(t){return 10+(t.filename?t.filename.length+1:0)};function pn(t,e){return xa(t,e||{},0,0)}function hn(t,e){e||(e={});var a=wa(),r=t.length;a.p(t);var n=xa(t,e,mn(e),8),i=n.length;return un(n,e),C(n,i-8,a.d()),C(n,i-4,r),n}var ya=function(t,e,a,r){for(var n in t){var i=t[n],o=e+n,s=r;Array.isArray(i)&&(s=va(r,i[1]),i=i[0]),i instanceof $?a[o]=[i,s]:(a[o+="/"]=[new $(0),s],ya(i,o,a,r))}},Ce=typeof TextEncoder<"u"&&new TextEncoder,fn=typeof TextDecoder<"u"&&new TextDecoder,gn=0;try{fn.decode(ba,{stream:!0}),gn=1}catch{}function mt(t,e){var a;if(Ce)return Ce.encode(t);for(var r=t.length,n=new $(t.length+(t.length>>1)),i=0,o=function(d){n[i++]=d},a=0;a<r;++a){if(i+5>n.length){var s=new $(i+8+(r-a<<1));s.set(n),n=s}var l=t.charCodeAt(a);l<128||e?o(l):l<2048?(o(192|l>>6),o(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|t.charCodeAt(++a)&1023,o(240|l>>18),o(128|l>>12&63),o(128|l>>6&63),o(128|l&63)):(o(224|l>>12),o(128|l>>6&63),o(128|l&63))}return fa(n,0,i)}var Vt=function(t){var e=0;if(t)for(var a in t){var r=t[a].length;r>65535&&Mt(9),e+=r+4}return e},Pe=function(t,e,a,r,n,i,o,s){var l=r.length,c=a.extra,d=s&&s.length,u=Vt(c);C(t,e,o!=null?33639248:67324752),e+=4,o!=null&&(t[e++]=20,t[e++]=a.os),t[e]=20,e+=2,t[e++]=a.flag<<1|(i<0&&8),t[e++]=n&&8,t[e++]=a.compression&255,t[e++]=a.compression>>8;var m=new Date(a.mtime==null?Date.now():a.mtime),p=m.getFullYear()-1980;if((p<0||p>119)&&Mt(10),C(t,e,p<<25|m.getMonth()+1<<21|m.getDate()<<16|m.getHours()<<11|m.getMinutes()<<5|m.getSeconds()>>1),e+=4,i!=-1&&(C(t,e,a.crc),C(t,e+4,i<0?-i-2:i),C(t,e+8,a.size)),C(t,e+12,l),C(t,e+14,u),e+=16,o!=null&&(C(t,e,d),C(t,e+6,a.attrs),C(t,e+10,o),e+=14),t.set(r,e),e+=l,u)for(var g in c){var h=c[g],w=h.length;C(t,e,+g),C(t,e+2,w),t.set(h,e+4),e+=4+w}return d&&(t.set(s,e),e+=d),e},bn=function(t,e,a,r,n){C(t,e,101010256),C(t,e+8,a),C(t,e+10,a),C(t,e+12,r),C(t,e+16,n)};function wn(t,e){e||(e={});var a={},r=[];ya(t,"",a,e);var n=0,i=0;for(var o in a){var s=a[o],l=s[0],c=s[1],d=c.level==0?0:8,u=mt(o),m=u.length,p=c.comment,g=p&&mt(p),h=g&&g.length,w=Vt(c.extra);m>65535&&Mt(11);var A=d?pn(l,c):l,z=A.length,I=wa();I.p(l),r.push(va(c,{size:l.length,crc:I.d(),c:A,f:u,m:g,u:m!=o.length||g&&p.length!=h,o:n,compression:d})),n+=30+m+w+z,i+=76+2*(m+w)+(h||0)+z}for(var M=new $(i+22),f=n,L=i-n,F=0;F<r.length;++F){var u=r[F];Pe(M,u.o,u,u.f,u.u,u.c.length);var x=30+u.f.length+Vt(u.extra);M.set(u.c,u.o+x),Pe(M,n,u,u.f,u.u,u.c.length,u.o,u.m),n+=16+x+(u.m?u.m.length:0)}return bn(M,n,r.length,L,f),M}const xn="gzip";function ee(t){return{bytes:hn(t),compression:xn}}const Le=1,Ee=2,Ie=4,Be=8,Ue=16,vn=32,De=1,Ne=2,Oe=4,Re=8,Te=16,yn=32,$e=64,je=128;function ae(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.lineDistances&&(e+=t.lineDistances.byteLength),t.linePattern&&(e+=64+t.linePattern.pattern.length*8),e}function re(t){let e=256+t.positions.byteLength;return t.indices&&(e+=t.indices.byteLength),t.gradientPositions&&(e+=t.gradientPositions.byteLength),t.uvs&&(e+=t.uvs.byteLength),t.texture&&(e+=t.texture.bytes.byteLength+64),t.hatchPattern&&(e+=128),t.gradientFill&&(e+=64),e}function ka(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=Le),e.linePattern&&(a|=Ee),e.lineDistances&&e.lineDistances.length>0&&(a|=Ie),e.lineWidth!=null&&e.lineWidth>0&&(a|=Be),e.renderOrder!=null&&e.renderOrder!==0&&(a|=Ue),e.excludeFromOsnap&&(a|=vn),t.writeU8(a),a&Le&&t.writeUint32Array(e.indices),a&Ee&&t.writeJson(e.linePattern),a&Ie&&t.writeFloat32Array(e.lineDistances),a&Be&&t.writeF32(e.lineWidth),a&Ue&&t.writeI32(e.renderOrder)}function Aa(t,e){t.writeString(e.layer),t.writeU32(e.color>>>0),t.writeF64(e.offset[0]),t.writeF64(e.offset[1]),t.writeF64(e.offset[2]),t.writeFloat32Array(e.positions);let a=0;e.indices&&e.indices.length>0&&(a|=De),e.hatchPattern&&(a|=Ne),e.gradientFill&&(a|=Oe),e.gradientPositions&&e.gradientPositions.length>0&&(a|=Re),e.side!=null&&(a|=Te),e.points&&(a|=yn),e.renderOrder!=null&&e.renderOrder!==0&&(a|=$e),e.texture&&e.texture.bytes.length>0&&e.uvs&&e.uvs.length>=2&&(a|=je),t.writeU8(a),a&De&&t.writeUint32Array(e.indices),a&Ne&&t.writeJson(e.hatchPattern),a&Oe&&t.writeJson(e.gradientFill),a&Re&&t.writeFloat32Array(e.gradientPositions),a&Te&&t.writeU8(e.side),a&$e&&t.writeI32(e.renderOrder),a&je&&(t.writeFloat32Array(e.uvs),t.writeString(e.texture.mimeType||"image/png"),t.writeU32(e.texture.bytes.byteLength),t.writeBytes(e.texture.bytes))}class ne{constructor(){this.chunks=[],this.length=0}writeU8(e){const a=new Uint8Array(1);a[0]=e&255,this.chunks.push(a),this.length+=1}writeU32(e){const a=new Uint8Array(4);new DataView(a.buffer).setUint32(0,e>>>0,!0),this.chunks.push(a),this.length+=4}writeI32(e){const a=new Uint8Array(4);new DataView(a.buffer).setInt32(0,e|0,!0),this.chunks.push(a),this.length+=4}writeF32(e){const a=new Uint8Array(4);new DataView(a.buffer).setFloat32(0,e,!0),this.chunks.push(a),this.length+=4}writeF64(e){const a=new Uint8Array(8);new DataView(a.buffer).setFloat64(0,e,!0),this.chunks.push(a),this.length+=8}writeBytes(e){this.chunks.push(e),this.length+=e.length}writeString(e){const a=mt(e);this.writeU32(a.length),this.writeBytes(a)}writeJson(e){this.writeString(JSON.stringify(e))}writeFloat32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}writeUint32Array(e){this.alignTo(4);const a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);this.writeU32(a.length),this.writeBytes(a)}alignTo(e){const a=this.length%e;if(a===0)return;const r=e-a;for(let n=0;n<r;n++)this.writeU8(0)}toUint8Array(){const e=new Uint8Array(this.length);let a=0;for(const r of this.chunks)e.set(r,a),a+=r.length;return e}}const kn=1329939265,An=1,zn=1,Mn=2,Fn=3,Sn=4,Cn=5,Pn=6,Ln=7;function za(t){var e;switch(t.kind){case"line":return 37;case"circle":return 30;case"arc":return 46;case"ellipse":return 71;case"point":return 21;case"path":return 10+t.vertices.length*8;case"spline":return 10+(t.controlPoints.length+t.knots.length+t.weights.length+(((e=t.fitPoints)==null?void 0:e.length)??0))*8+16;default:return t}}function En(t,e){if(t.length===0)return[];const a=[];let r=[],n=64;const i=()=>{r.length!==0&&(a.push(r),r=[],n=64)};for(const o of t){const s=za(o);r.length>0&&n+s>e&&i(),r.push(o),n+=s}return i(),a}function Ma(t){const e=new ne;e.writeU32(kn),e.writeU8(An),e.writeU8(0),e.writeU8(0),e.writeU8(0);const a=[],r=new Map,n=i=>{const o=r.get(i);if(o!=null)return o;const s=a.length;return a.push(i),r.set(i,s),s};for(const i of t.primitives)n(i.layer);e.writeU32(a.length);for(const i of a)e.writeString(i);e.writeU32(t.primitives.length);for(const i of t.primitives)Bn(e,i,n(i.layer));return e.toUint8Array()}function In(t){const e=Ma(t),a=ee(e).bytes;return{uncompressed:e,compressed:a}}function Dt(t,e){t.writeU8(e<0?0:1)}function ct(t,e){t.writeU32(e.length);for(const a of e)t.writeF64(a)}function Bn(t,e,a){switch(e.kind){case"line":t.writeU8(zn),t.writeU32(a),t.writeF64(e.x0),t.writeF64(e.y0),t.writeF64(e.x1),t.writeF64(e.y1);return;case"circle":t.writeU8(Mn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),Dt(t,e.normalSign);return;case"arc":t.writeU8(Fn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.r),t.writeF64(e.startAngle),t.writeF64(e.endAngle),Dt(t,e.normalSign);return;case"ellipse":t.writeU8(Sn),t.writeU32(a),t.writeF64(e.cx),t.writeF64(e.cy),t.writeF64(e.majorX),t.writeF64(e.majorY),t.writeF64(e.majorR),t.writeF64(e.minorR),t.writeF64(e.startAngle),t.writeF64(e.endAngle),t.writeU8(e.closed?1:0),Dt(t,e.normalSign??1);return;case"spline":t.writeU8(Cn),t.writeU32(a),ct(t,e.controlPoints),t.writeU32(e.degree),ct(t,e.knots),ct(t,e.weights),t.writeU8(e.closed?1:0),ct(t,e.fitPoints??[]);return;case"point":t.writeU8(Pn),t.writeU32(a),t.writeF64(e.x),t.writeF64(e.y);return;case"path":t.writeU8(Ln),t.writeU32(a),t.writeU8(e.closed?1:0),ct(t,e.vertices);return;default:{const r=e;throw new Error(`Unsupported osnap primitive: ${String(r)}`)}}}const Un=1480934209;function Dn(t){if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=new ne;e.writeU32(Un),e.writeU8(J),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeJson(Nn(t)),e.writeJson(t.layers),e.writeString(t.activeLayoutBtrId),e.writeU32(t.layouts.length);for(const a of t.layouts)On(e,a);return e.toUint8Array()}function Nn(t){const e={...t.meta.savedViews??{}};for(const a of t.layouts)a.savedView&&(e[a.btrId]=a.savedView);if(Object.keys(e).length===0){if(t.meta.savedViews==null)return t.meta;const{savedViews:a,...r}=t.meta;return r}return{...t.meta,savedViews:e}}function On(t,e){t.writeString(e.btrId),t.writeString(e.name),t.writeU8(e.isModelSpace?1:0),Rn(t,e.osnap),t.writeJson(e.viewports??null),t.writeU32(e.lineBatches.length);for(const a of e.lineBatches)ka(t,a);t.writeU32(e.meshBatches.length);for(const a of e.meshBatches)Aa(t,a)}function Rn(t,e){if(!e||e.primitives.length===0){t.writeU32(0);return}const a=Ma(e);t.writeU32(a.length),t.writeBytes(a)}const Tn="application/vnd.mlightcad.acex-snapshot+binary";function Fa(t){if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const e=Dn(t),a=ee(e);return{payload:jn(a.bytes),compression:a.compression}}function $n(){return Tn}function jn(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function tt(t,e,a){if(a<=0)return new Float32Array(0);const r=new Float32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function _n(t,e,a){if(a<=0)return new Uint32Array(0);const r=new Uint32Array(a);for(let n=0;n<a;n++)r[n]=t[e+n];return r}function Sa(t,e){if(e.length===0)return{positions:t,indices:e};let a=0;for(let n=0;n<e.length;n++){const i=e[n];i>a&&(a=i)}const r=(a+1)*3;return r>=t.length?{positions:t,indices:e}:{positions:tt(t,0,r),indices:e}}function _e(t,e){return t+e}const rt={x:0,y:0,z:0};function Vn(t){t.updateMatrixWorld(!0);const e=t.matrixWorld.elements;return rt.x=e[12],rt.y=e[13],rt.z=e[14],[rt.x,rt.y,rt.z]}function Hn(t,e){const a=e.elements,r=t.positions;if(r.length===0)return{positions:new Float32Array(0),indices:t.indices};const n=new Float32Array(r.length);for(let i=0;i<r.length;i+=3){const o=r[i],s=r[i+1],l=r[i+2];n[i]=a[0]*o+a[4]*s+a[8]*l+a[12],n[i+1]=a[1]*o+a[5]*s+a[9]*l+a[13],n[i+2]=a[2]*o+a[6]*s+a[10]*l+a[14]}return{positions:n,indices:t.indices?new Uint32Array(t.indices):void 0}}function Yn(t){const e=t.positions;if(e.length<3)return{slice:t,offset:[0,0,0]};let a=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,s=-1/0;for(let d=0;d<e.length;d+=3){const u=e[d],m=e[d+1],p=e[d+2];a=Math.min(a,u),r=Math.min(r,m),n=Math.min(n,p),i=Math.max(i,u),o=Math.max(o,m),s=Math.max(s,p)}const l=[(a+i)/2,(r+o)/2,(n+s)/2],c=new Float32Array(e.length);for(let d=0;d<e.length;d+=3)c[d]=e[d]-l[0],c[d+1]=e[d+1]-l[1],c[d+2]=e[d+2]-l[2];return{slice:{positions:c,indices:t.indices?new Uint32Array(t.indices):void 0},offset:l}}function Xn(t,e,a={}){t.updateMatrixWorld(!0);const r=Hn(e,t.matrixWorld);return Yn(r)}function Gn(t){const e=t.image;if(!e||typeof document>"u")return;const a=document.createElement("canvas"),r=a.getContext("2d");if(!r)return;try{if(e instanceof ImageData)a.width=e.width,a.height=e.height,r.putImageData(e,0,0);else if(Wn(e)){a.width=e.width,a.height=e.height;const l=Zn(e.data,e.width*e.height),c=new ImageData(new Uint8ClampedArray(l),e.width,e.height);r.putImageData(c,0,0)}else if(Kn(e)){const l=Jn(e);if(!l)return;a.width=l.width,a.height=l.height,r.drawImage(e,0,0)}else return}catch{return}const n=a.toDataURL("image/png"),i=n.indexOf(",");if(i<0)return;const o=atob(n.slice(i+1)),s=new Uint8Array(o.length);for(let l=0;l<o.length;l++)s[l]=o.charCodeAt(l);return{mimeType:"image/png",bytes:s}}function Kn(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}function Wn(t){if(!t||typeof t!="object")return!1;const e=t;return e.data!=null&&typeof e.width=="number"&&typeof e.height=="number"&&e.width>=1&&e.height>=1}function Jn(t){let e=Number(t.width),a=Number(t.height);if(t instanceof HTMLImageElement?(e=t.naturalWidth||t.width,a=t.naturalHeight||t.height):typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement&&(e=t.videoWidth||t.width,a=t.videoHeight||t.height),!(!Number.isFinite(e)||!Number.isFinite(a)||e<1||a<1))return{width:e,height:a}}function Zn(t,e){const a=e*4;if(t instanceof Uint8ClampedArray&&t.length>=a)return t.length===a?t:t.subarray(0,a);const r=new Uint8ClampedArray(a),n=Math.min(a,t.length);for(let i=0;i<n;i++)r[i]=t[i];if(t.length>=e*3&&t.length<a)for(let i=e-1;i>=0;i--){const o=i*3,s=i*4;r[s]=t[o],r[s+1]=t[o+1],r[s+2]=t[o+2],r[s+3]=255}return r}function qn(t,e){const a=t.getAttribute("uv");if(!a||a.count===0||a.itemSize<2)return;const r=Math.floor(e.length/3)*2;if(r<=0)return;const n=a.array;if(!(a.count*a.itemSize<r))return tt(n,0,r)}function Qn(t){const e=t;return e.map?!1:e.transparent===!0&&typeof e.opacity=="number"&&e.opacity<.01}function ie(t){const e=t;if(e.isShaderMaterial===!0||t.type==="ShaderMaterial")return e}function ti(t){var e;const a=ie(t);if(!a)return;const r=a.uniforms.pattern,n=a.uniforms.patternLength;if(!r||!n)return;const i=r.value;if(!(!Array.isArray(i)||i.length===0))return{pattern:[...i],patternLength:Number(n.value),viewportScale:Number(((e=a.uniforms.u_viewportScale)==null?void 0:e.value)??1)}}function ei(t){var e;const a=ie(t);if(!a)return;const r=a.uniforms.u_patternLines;if(!r)return;const n=r.value;if(!(!Array.isArray(n)||n.length===0))return{patternAngle:Number(((e=a.uniforms.u_patternAngle)==null?void 0:e.value)??0),patternLines:n.map(ri)}}function ai(t){var e,a,r,n,i;const o=ie(t);if(!o||o.uniforms.u_patternLines)return;const s=(e=o.uniforms.u_startColor)==null?void 0:e.value,l=(a=o.uniforms.u_endColor)==null?void 0:a.value,c=o.uniforms.u_gradientType;if(!(!(s!=null&&s.getHex)||c==null))return{startColor:s.getHex(),endColor:((r=l==null?void 0:l.getHex)==null?void 0:r.call(l))??s.getHex(),angle:Number(((n=o.uniforms.u_angle)==null?void 0:n.value)??0),shift:Number(((i=o.uniforms.u_shift)==null?void 0:i.value)??0),gradientType:Number(c.value)}}function ri(t){return{angle:t.angle,base:[t.base.x,t.base.y],offset:[t.offset.x,t.offset.y],dashLengths:[...t.dashLengths],patternLength:t.patternLength}}function Ca(t){const e=t.length/3;if(e<2)return new Float32Array(0);const a=new Float32Array(e);for(let r=0;r<e;r+=2){r===0?a[r]=0:a[r]=a[r-1];const n=t[r*3],i=t[r*3+1],o=t[r*3+2]??0,s=t[(r+1)*3],l=t[(r+1)*3+1],c=t[(r+1)*3+2]??0,d=s-n,u=l-i,m=c-o;a[r+1]=a[r]+Math.sqrt(d*d+u*u+m*m)}return a}function ni(t,e){const a=t.getAttribute(e);if(!a||a.count===0)return;const r=a.itemSize;if(t.getIndex()){const d=a.array;return tt(d,0,a.count*r)}const n=t.drawRange,i=a.count,o=Math.max(0,Math.min(Math.floor(n.start),i)),s=Math.max(0,i-o),l=!Number.isFinite(n.count)||n.count<=0?s:Math.min(Math.floor(n.count),s);if(l<=0)return;const c=a.array;return tt(c,o*r,l*r)}function Ve(t,e){const a=Math.atan2(e[1],e[0]),r=(i,o)=>[e[0]*i+e[4]*o+e[12],e[1]*i+e[5]*o+e[13]],n=(i,o)=>[e[0]*i+e[4]*o,e[1]*i+e[5]*o];return{patternAngle:t.patternAngle+a,patternLines:t.patternLines.map(i=>({angle:i.angle+a,base:r(i.base[0],i.base[1]),offset:n(i.offset[0],i.offset[1]),dashLengths:[...i.dashLengths],patternLength:i.patternLength}))}}function ii(t,e){return{patternAngle:t.patternAngle,patternLines:t.patternLines.map(a=>{const r=new P.Vector2(a.base[0]-e[0],a.base[1]-e[1]),n=new P.Vector2(a.offset[0],a.offset[1]);return yr(r,n,a.angle,t.patternAngle,a.patternLength),{angle:a.angle,base:[r.x,r.y],offset:[a.offset[0],a.offset[1]],dashLengths:[...a.dashLengths],patternLength:a.patternLength}})}}function Ht(t,e){return!Number.isFinite(t)||t<0?0:Math.min(Math.floor(t),e)}function Yt(t,e,a){const r=Math.max(0,e-a);return!Number.isFinite(t)||t<=0?r:Math.min(Math.floor(t),r)}function He(t){const e=t.getAttribute("position");if(!e)return{positions:new Float32Array(0)};const a=t.drawRange,r=e.array,n=e.itemSize,i=t.getIndex();if(i){const l=tt(r,0,e.count*n),c=i.array,d=Ht(a.start,i.count),u=Yt(a.count,i.count,d),m=_n(c,d,u);return Sa(l,m)}const o=Ht(a.start,e.count),s=Yt(a.count,e.count,o);return{positions:tt(r,o*n,s*n)}}function vt(t){return Yr(t.flags)&&Xr(t.flags)}function Pa(t){const{count:e}=t.mappingStats;for(let a=0;a<e;a++){let r;try{r=t.getGeometryRangeAt(a)}catch{continue}if(vt(r)&&r.bboxIntersectionCheck)return!0}return!1}function Ye(t){return vr(t).bboxIntersectionCheck===!0}function oe(t,e){const a=e.getAttribute("position");if(!a)return{positions:new Float32Array(0)};const r=a.itemSize,n=a.array,i=e.getIndex(),{count:o}=t.mappingStats;if(i){const l=tt(n,0,a.count*r),c=i.array,d=[];for(let u=0;u<o;u++){let m;try{m=t.getGeometryRangeAt(u)}catch{continue}const p=m.indexStart??0,g=m.indexCount??0;if(!(!vt(m)||g<=0))for(let h=0;h<g;h++)d.push(c[p+h])}return d.length===0?{positions:new Float32Array(0)}:Sa(l,new Uint32Array(d))}const s=[];for(let l=0;l<o;l++){let c;try{c=t.getGeometryRangeAt(l)}catch{continue}if(!vt(c)||c.vertexCount<=0)continue;const d=c.vertexStart*r,u=c.vertexCount*r;for(let m=0;m<u;m++)s.push(n[d+m])}return{positions:new Float32Array(s)}}function yt(t,e,a){t.push(e.getX(a),e.getY(a),e.getZ(a))}function oi(t,e){const a=e.getAttribute("instanceStart"),r=e.getAttribute("instanceEnd");if(!a||!r)return{positions:new Float32Array(0)};const{count:n}=t.mappingStats,i=[];for(let o=0;o<n;o++){let s;try{s=t.getGeometryRangeAt(o)}catch{continue}if(!vt(s)||s.vertexCount<=0)continue;const l=s.vertexStart,c=l+s.vertexCount;for(let d=l;d<c;d++)yt(i,a,d),yt(i,r,d)}return{positions:new Float32Array(i)}}function si(t,e){const a=t.instanceCount;if(Number.isFinite(a)&&a>=0)return Math.min(Math.floor(a),e);const r=t.drawRange,n=Ht(r.start,e);return Yt(r.count,e,n)}function li(t){const e=t.getAttribute("instanceStart"),a=t.getAttribute("instanceEnd");if(!e||!a||e.count===0)return{positions:new Float32Array(0)};const r=si(t,e.count);if(r<=0)return{positions:new Float32Array(0)};const n=[];for(let i=0;i<r;i++)yt(n,e,i),yt(n,a,i);return{positions:new Float32Array(n)}}function Nt(t){return wr(t)}function La(t){if(t instanceof xr)return t.linewidth}function Ot(t){if("material"in t){const e=t.userData.originalMaterial??t.material;return Array.isArray(e)?e[0]:e}return t.material}function pt(t){var e;const a=da(t),r=a.layer??"0",n=t;let i=n.color!=null?n.color.getHex():a.color??16777215;const o=ti(t),s=ei(t),l=ai(t);if(t instanceof P.ShaderMaterial||t.type==="ShaderMaterial"){const c=(e=t.uniforms.u_color)==null?void 0:e.value;c!=null&&c.getHex?i=c.getHex():l&&(i=l.startColor)}return{color:i,layer:r,linePattern:o,hatchPattern:s,gradientFill:l,side:s||l?t.side:void 0}}function ci(t,e){const a=da(e).drawOrder??t.renderOrder;return a===0?void 0:a}function ht(t,e,a){const r=ci(e,a);r!=null&&(t.renderOrder=r)}function di(t,e){if(!e)return;const a=t.userData.bakedWorldMatrix;return a&&a.length>=16?Ve(e,a):(t.updateMatrixWorld(!0),Ve(e,Array.from(t.matrixWorld.elements)))}function Ft(t){return Vn(t)}function Rt(t,e,a={}){const r=Xn(t,e,a);return{...r.slice,offset:r.offset}}function se(t,e,a,r,n){const i=pt(e),o=di(a,i.hatchPattern),s=o?ii(o,n):void 0,l=i.gradientFill?ni(t,"gradientPosition"):void 0,c={layer:i.layer,color:i.color,offset:n,hatchPattern:s,gradientFill:i.gradientFill,gradientPositions:l,side:i.side,...r},d=e;if(d.map){const u=Gn(d.map),m=qn(t,r.positions);if(!u||!m)return;c.texture=u,c.uvs=m,c.color=16777215,c.side=P.DoubleSide}return ht(c,a,e),c}function ui(t){const e=oi(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r}=pt(t.material),n=La(t.material),i={layer:r,color:a,offset:Ft(t),lineWidth:n,...e};return Pa(t)&&(i.excludeFromOsnap=!0),ht(i,t,t.material),i}function mi(t){const e=oe(t,t.geometry);if(e.positions.length===0)return;const{color:a,layer:r,linePattern:n}=pt(t.material),i=n?Ca(e.positions):void 0,o={layer:r,color:a,offset:Ft(t),linePattern:n,lineDistances:i,...e};return Pa(t)&&(o.excludeFromOsnap=!0),ht(o,t,t.material),o}function pi(t){const e=oe(t,t.geometry);if(e.positions.length!==0)return se(t.geometry,t.material,t,e,Ft(t))}function hi(t){const e=oe(t,t.geometry);if(e.positions.length===0)return;const a=se(t.geometry,t.material,t,e,Ft(t));if(a)return{points:!0,...a}}function fi(t){const e=[],a=[];return t.traverse(r=>{if(!(lr(r)||cr(r))){if(r instanceof ke){const n=mi(r);n&&e.push(n);return}if(r instanceof dr){const n=ui(r);n&&e.push(n);return}if(r instanceof Ae){const n=pi(r);n&&a.push(n);return}if(r instanceof ur){const n=hi(r);n&&a.push(n);return}if(r instanceof mr){if(!Nt(r))return;const n=li(r.geometry);if(n.positions.length===0)return;const i=Ot(r),{color:o,layer:s}=pt(i),{offset:l,...c}=Rt(r,n),d={layer:s,color:o,offset:l,lineWidth:La(i),...c};Ye(r)&&(d.excludeFromOsnap=!0),ht(d,r,i),e.push(d)}else if(r instanceof P.LineSegments&&!(r instanceof ke)){if(!Nt(r))return;const n=He(r.geometry);if(n.positions.length===0)return;const i=Ot(r),{color:o,layer:s,linePattern:l}=pt(i),{offset:c,...d}=Rt(r,n),u=l?Ca(d.positions):void 0,m={layer:s,color:o,offset:c,linePattern:l,lineDistances:u,...d};Ye(r)&&(m.excludeFromOsnap=!0),ht(m,r,i),e.push(m)}else if(r instanceof P.Mesh&&!(r instanceof Ae)){if(!Nt(r))return;const n=Ot(r);if(Qn(n))return;const i=He(r.geometry);if(i.positions.length===0)return;const{offset:o,...s}=Rt(r,i),l=se(r.geometry,n,r,s,o);l&&a.push(l)}}}),{lineBatches:e,meshBatches:a}}const Xe={size:8,colorCss:"#0080ff",hotColorCss:"#ff0000"};function Ge(t){const e=new gr(br.ByACI,t);return e.cssColor??`rgb(${e.red}, ${e.green}, ${e.blue})`}function gi(t){try{const e=sr.instance(),a=e.getVar(Bt.GRIPSIZE,t),r=e.getVar(Bt.GRIPCOLOR,t),n=e.getVar(Bt.GRIPHOT,t);return!(a>0)||!Number.isFinite(a)?Xe:{size:a,colorCss:Ge(r),hotColorCss:Ge(n)}}catch{return Xe}}function Ke(t,e){const a=t.extmin,r=t.extmax,n=gi(t);return{title:e==null?void 0:e.title,extents:{minX:a.x,minY:a.y,maxX:r.x,maxY:r.y},units:{insunits:t.insunits,lunits:t.lunits,luprec:t.luprec,aunits:t.aunits,auprec:t.auprec,measurement:t.measurement,ltscale:t.ltscale,angbase:t.angbase,angdir:t.angdir},grip:n,background:(e==null?void 0:e.background)??0}}function We(t,e,a,r,n){return Math.atan2(r-e,n*(a-t))}function le(t){return t.z>=0?1:-1}function Ea(t,e,a){if(!(a.radius>0)||!Number.isFinite(a.radius))return;const r=a.clockwise?-1:1,n=a.center.x,i=a.center.y;t.push({kind:"arc",layer:e,cx:n,cy:i,r:a.radius,startAngle:We(n,i,a.startPoint.x,a.startPoint.y,r),endAngle:We(n,i,a.endPoint.x,a.endPoint.y,r),normalSign:r})}function E(t,e){const a=new P.Vector3(e.x,e.y,e.z??0).applyMatrix4(t);return{x:a.x,y:a.y}}function bi(t){const e=t.elements;return new P.Matrix4(e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15])}function kt(t,e){return new P.Matrix4().multiplyMatrices(t,bi(e))}function Ia(t,e){const a=new P.Vector3(e.x,e.y,e.z??0).transformDirection(t).normalize();return{x:a.x,y:a.y}}function Xt(t){const e=new P.Vector3(t.elements[0],t.elements[1],t.elements[2]).length(),a=new P.Vector3(t.elements[4],t.elements[5],t.elements[6]).length();return it.equal(e,a,ua*Math.max(e,a,1))}function wi(t,e){const a=t.tables.blockTable.getIdAt(e);if(a)return a;for(const n of t.tables.blockTable.newIterator())if(n.objectId===e)return n;const r=t.tables.blockTable.modelSpace;if(r.objectId===e)return r}function xi(t){if(t instanceof Gr)return!0;const e=t;return(e.type==="LINE"||e.type==="Line")&&e.startPoint!=null&&e.endPoint!=null}function vi(t,e,a,r){r.startPoint,r.endPoint}function Ba(t,e){return t.blockTableRecord??(t.blockName?e.tables.blockTable.getAt(t.blockName):void 0)}function yi(t,e){const a=t.dimBlockId;return a?e.tables.blockTable.getAt(a):void 0}function ki(t,e){const a=Ba(t,e);if(a)return a;const r=t.owningBlockRecordId;return r?e.tables.blockTable.getAt(r):void 0}function Ua(t){return t.getFullInsertionTransform()}function Ai(t){for(const e of t.newIterator())return!0;return!1}function zi(t){return typeof t.getFullInsertionTransform=="function"&&"blockTableRecord"in t}function Z(t,e,a,r,n){if(r.length<2)return;const i=Xt(a),o=a.elements[0]*a.elements[5]-a.elements[4]*a.elements[1]<0?-1:1,s=[];for(const l of r){const c=E(a,l);let d=l.bulge??0;it.isPositive(Math.abs(d))&&(d=i?d*o:0),s.push(c.x,c.y,d)}t.push({kind:"path",layer:e,closed:n,vertices:s})}function Da(t,e){return it.equal(t.x,e.x)&&it.equal(t.y,e.y)}function Mi(t){return(t.clockwise?-1:1)*Math.tan(t.deltaAngle/4)}function Je(t,e,a,r){if(t.length===0){t.push({x:e.x,y:e.y,z:e.z??0,bulge:r}),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0});return}const n=t[t.length-1];Da(n,e)?n.bulge=r:(n.bulge=0,t.push({x:e.x,y:e.y,z:e.z??0,bulge:r})),t.push({x:a.x,y:a.y,z:a.z??0,bulge:0})}function Ze(t){return t.length>=2&&Da(t[0],t[t.length-1])&&t.pop(),t}function ut(t,e,a,r,n){if(r.length<2)return;const i=n?r.length:r.length-1;for(let o=0;o<i;o++)r[o],r[(o+1)%r.length]}function Fi(t,e,a,r){const n=[r.startPosition];for(const i of r.segments)n.push(i.position);ut(t,e,a,n,r.closed)}function Si(t,e,a){if(a.vertices.length>=2)return a.vertices;if(a.vertices.length===0)return[];const r=a.vertices[0],n=e.lastLeaderLinePoint??e.landingPoint??t.landingPoint??t.contentBasePosition;if(!n)return a.vertices;const i=r.x-n.x,o=r.y-n.y,s=(r.z??0)-(n.z??0);return Math.hypot(i,o,s)<=ua?a.vertices:[r,n]}function Ci(t,e,a,r){var n,i;for(const s of r.leaders)for(const l of s.leaderLines){const c=Si(r,s,l);ut(t,e,a,c,!1)}const o=s=>{if(!s)return;const l=E(a,s);t.push({kind:"point",layer:e,x:l.x,y:l.y})};o(r.contentBasePosition),o((n=r.mtextContent)==null?void 0:n.anchorPoint),o((i=r.blockContent)==null?void 0:i.position)}function Pi(t,e,a,r){const n=r.numberOfVertices;if(n<2)return;const i=r.elevation,o=r.closed?n:n-1;for(let s=0;s<o;s++){const l=r.getPointAt(s),c=r.getPointAt((s+1)%n),d=r.getBulgeAt(s),u={x:l.x,y:l.y,z:i},m={x:c.x,y:c.y,z:i};if(it.isPositive(Math.abs(d))){const p=E(a,u),g=E(a,m);Ea(t,e,new Jt(p,g,d))}}}function Li(t,e,a,r,n,i){const o=E(a,r),s=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),l={kind:"circle",layer:e,cx:o.x,cy:o.y,r:n*s,normalSign:le(i)};t.push(l)}function Ei(t,e,a,r){const n=E(a,r.center),i=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),o={kind:"arc",layer:e,cx:n.x,cy:n.y,r:r.radius*i,startAngle:r.startAngle,endAngle:r.endAngle,normalSign:le(r.normal)};t.push(o)}function Tt(t,e,a,r){const n=E(a,r.center),i=r._geo,o=(i==null?void 0:i.majorAxis)??{x:1,y:0,z:0},s=Ia(a,o),l=Math.hypot(s.x,s.y)||1,c=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),d=new P.Vector3(a.elements[4],a.elements[5],a.elements[6]).length(),u={kind:"ellipse",layer:e,cx:n.x,cy:n.y,majorX:s.x/l,majorY:s.y/l,majorR:r.majorAxisRadius*c,minorR:r.minorAxisRadius*d,startAngle:r.startAngle,endAngle:r.endAngle,closed:r.closed,normalSign:le(r.normal)};t.push(u)}function Ii(t,e,a,r){var n,i;const o=r._geo;if(!((n=o==null?void 0:o.controlPoints)!=null&&n.length))return;const s=[];for(const c of o.controlPoints){const d=E(a,c);s.push(d.x,d.y)}const l={kind:"spline",layer:e,controlPoints:s,degree:o.degree??3,knots:[...o.knots??[]],weights:[...o.weights??[]],closed:o.closed??!1};if((i=o.fitPoints)!=null&&i.length){l.fitPoints=[];for(const c of o.fitPoints){const d=E(a,c);l.fitPoints.push(d.x,d.y)}}t.push(l)}const qe=1e-6;function Bi(t){var e;const a=t.elevation,r=(e=t._geo)==null?void 0:e.vertices;return r&&r.length>1?r.map(n=>({x:n.x,y:n.y,z:a,bulge:n.bulge,startWidth:n.startWidth,endWidth:n.endWidth})):Array.from({length:t.numberOfVertices},(n,i)=>{const o=t.getPoint2dAt(i);return{x:o.x,y:o.y,z:a,bulge:0}})}function Ui(t){return t.some(e=>{const a=Math.max(0,e.startWidth??0),r=Math.max(0,e.endWidth??0);return a>qe||r>qe})}function Di(t,e,a,r){const n=Bi(r),i=n.length;if(i<2)return;if(Ui(n)){Z(t,e,a,n,r.closed);return}const o=r.closed?i:i-1;for(let s=0;s<o;s++){const l=n[s],c=n[(s+1)%i],d=l.bulge??0;if(it.isPositive(Math.abs(d))){const u=E(a,l),m=E(a,c);Ea(t,e,new Jt(u,m,d))}}}function Ni(t,e,a,r,n){const i=E(a,{x:r.center.x,y:r.center.y,z:n}),o=Ia(a,{x:Math.cos(r.rotation),y:Math.sin(r.rotation),z:0}),s=Math.hypot(o.x,o.y)||1,l=new P.Vector3(a.elements[0],a.elements[1],a.elements[2]).length(),c=new P.Vector3(a.elements[4],a.elements[5],a.elements[6]).length();t.push({kind:"ellipse",layer:e,cx:i.x,cy:i.y,majorX:o.x/s,majorY:o.y/s,majorR:r.majorAxisRadius*l,minorR:r.minorAxisRadius*c,startAngle:r.startAngle,endAngle:r.endAngle,closed:!1,normalSign:r.clockwise?-1:1})}function Oi(t,e,a,r,n){var i;const o=r.numberOfVertices;if(o<2)return;const s=[];for(let l=0;l<o;l++){const c=r.getPointAt(l);s.push({x:c.x,y:c.y,z:n,bulge:((i=r.vertices[l])==null?void 0:i.bulge)??0})}Z(t,e,a,s,r.closed)}function Ri(t,e,a,r,n){if(r instanceof Wr){Oi(t,e,a,r,n);return}if(!(r instanceof Jr))return;const i=[];let o=!1;const s=()=>{const c=Ze(i);c.length>=2&&Z(t,e,a,c,!1),i.length=0};for(const c of r.curves)c instanceof Zr?Je(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},0):c instanceof Jt?Je(i,{x:c.startPoint.x,y:c.startPoint.y,z:n},{x:c.endPoint.x,y:c.endPoint.y,z:n},Mi(c)):c instanceof qr&&(o=!0,s(),Ni(t,e,a,c,n));const l=Ze(i);l.length>=2&&Z(t,e,a,l,!o)}function Ti(t,e,a,r){var n;const i=(n=r._geo)==null?void 0:n.loops;if(!(i!=null&&i.length))return;const o=r.elevation;for(const s of i)Ri(t,e,a,s,o)}function $i(t,e,a,r){kt(a,Ua(r));const n=[0];for(let o=0;o<r.numColumns;o++)n.push(n[o]+r.columnWidth(o));const i=[0];for(let o=0;o<r.numRows;o++)i.push(i[o]-r.rowHeight(o));n[n.length-1],i[i.length-1];for(const o of i);for(const o of n);}function ji(t,e,a,r,n,i,o,s=!0){const l=Gt(t.layer,a);if(o&&!o(l))return;const c=ki(t,i);if(c&&!n.has(c.objectId)&&Ai(c)){n.add(c.objectId);const u=kt(e,Ua(t));At(c,u,l,r,n,i,o,s),n.delete(c.objectId);return}$i(r,l,e,t);const d=E(e,t.position);r.push({kind:"point",layer:l,x:d.x,y:d.y})}function _i(t,e,a,r){let n=r.boundaryPath();if(n.length>1){const o=n[0],s=n[n.length-1];o.x===s.x&&o.y===s.y&&(o.z??0)===(s.z??0)&&(n=n.slice(0,-1))}n.length>=2&&Z(t,e,a,n,!0);const i=E(a,r.position);t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Vi(t,e,a,r){const n=r.position();Z(t,e,a,[n.upperLeft,n.upperRight,n.lowerRight,n.lowerLeft],!0);const i=E(a,r.getLocation());t.push({kind:"point",layer:e,x:i.x,y:i.y})}function Hi(t){var e;const a=(e=t.attributeIterator)==null?void 0:e.call(t);return a?typeof a.toArray=="function"?a.toArray():[...a]:[]}function Gt(t,e){return t==="0"?e:t}function Na(t,e,a,r,n,i,o,s=!0){if(!t.visibility)return;const l=Gt(t.layer,a);if(!(o&&!o(l))){if(t instanceof kr){ji(t,e,a,r,n,i,o,s);return}if(zi(t)){const c=Ba(t,i);if(!c||n.has(c.objectId))return;n.add(c.objectId);const d=t.getFullInsertionTransform(),u=Math.max(1,t.columnCount??1),m=Math.max(1,t.rowCount??1),p=t.columnSpacing??0,g=t.rowSpacing??0,h=Gt(t.layer,a);for(let w=0;w<m;w++)for(let A=0;A<u;A++){const z=kt(e,d);(A!==0||w!==0)&&z.multiply(new P.Matrix4().makeTranslation(A*p,w*g,0));const I=E(z,{x:0,y:0,z:0});r.push({kind:"point",layer:h,x:I.x,y:I.y}),At(c,z,h,r,n,i,o,s)}for(const w of Hi(t))w instanceof Ar,w.isInvisible||Na(w,e,h,r,n,i,o,s);n.delete(c.objectId);return}if(t instanceof zr){const c=t,d=yi(c,i);if(!d||n.has(d.objectId))return;n.add(d.objectId);const u=kt(e,c.getFullDimBlockTransform());At(d,u,l,r,n,i,o,!0),n.delete(d.objectId);return}if(xi(t)){vi(r,l,e,t);return}if(t instanceof Mr){Xt(e)?Li(r,l,e,t.center,t.radius,t.normal):Tt(r,l,e,Yi(t));return}if(t instanceof Fr){Xt(e)?Ei(r,l,e,t):Tt(r,l,e,Xi(t));return}if(t instanceof Wt){Tt(r,l,e,t);return}if(t instanceof Sr){Ii(r,l,e,t);return}if(t instanceof Cr){Di(r,l,e,t);return}if(t instanceof Pr){Pi(r,l,e,t);return}if(t instanceof Lr){const c=[];for(let d=0;d<t.numberOfVertices;d++)c.push(t.getPointAt(d));ut(r,l,e,c,t.closed);return}if(t instanceof Er){s&&Ti(r,l,e,t);return}if(t instanceof Ir){t.basePoint,t.unitDir;return}if(t instanceof Br){t.basePoint,t.unitDir;return}if(t instanceof Ur){Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof Dr){s&&Z(r,l,e,[t.getPointAt(0),t.getPointAt(1),t.getPointAt(3),t.getPointAt(2)],!0);return}if(t instanceof Nr){const c=t.subGetGripPoints();c.length>=2&&ut(r,l,e,c,c.length>=3);return}if(t instanceof Or){const c=t.vertices;c.length>=2&&ut(r,l,e,c,!1);return}if(t instanceof Rr){Fi(r,l,e,t);return}if(t instanceof Tr){Ci(r,l,e,t);return}if(t instanceof $r){const c=E(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof jr){const c=E(e,t.location);r.push({kind:"point",layer:l,x:c.x,y:c.y});return}if(t instanceof _r){s&&Vi(r,l,e,t);return}if(t instanceof Vr){s&&_i(r,l,e,t);return}if(t instanceof Hr){const c=E(e,t.position);r.push({kind:"point",layer:l,x:c.x,y:c.y})}}}function At(t,e,a,r,n,i,o,s=!0){for(const l of t.newIterator())Na(l,e,a,r,n,i,o,s)}function Yi(t){return new Wt(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,0,Kr)}function Xi(t){return new Wt(t.center,t.normal,{x:1,y:0,z:0},t.radius,t.radius,t.startAngle,t.endAngle)}function Gi(t,e,a={}){const r=wi(t,e);if(!r)return{primitives:[]};const n=[],i=new P.Matrix4;return At(r,i,"0",n,new Set,t,a.includeLayer),{primitives:n.filter(o=>o.kind!=="line"&&Ki(o))}}function Ki(t){switch(t.kind){case"line":return Number.isFinite(t.x0)&&Number.isFinite(t.y0)&&Number.isFinite(t.x1)&&Number.isFinite(t.y1);case"circle":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r);case"arc":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.r)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"ellipse":return Number.isFinite(t.cx)&&Number.isFinite(t.cy)&&Number.isFinite(t.majorX)&&Number.isFinite(t.majorY)&&Number.isFinite(t.majorR)&&Number.isFinite(t.minorR)&&Number.isFinite(t.startAngle)&&Number.isFinite(t.endAngle);case"spline":return t.controlPoints.every(e=>Number.isFinite(e))&&t.knots.every(e=>Number.isFinite(e))&&t.weights.every(e=>Number.isFinite(e));case"point":return Number.isFinite(t.x)&&Number.isFinite(t.y);case"path":return t.vertices.length>=6&&t.vertices.length%3===0&&t.vertices.every(e=>Number.isFinite(e));default:return t}}const Wi=["en","zh","cs","tr","ar"];function ce(t){if(t==null||t==="")return null;const e=t.toLowerCase().replace("_","-");for(const a of Wi)if(e===a||e.startsWith(`${a}-`))return a;return null}const Ji=1128612673;function Zi(t){const e=new ne;e.writeU32(Ji),e.writeU8(J),e.writeU8(0),e.writeU8(0),e.writeU8(0),e.writeString(t.layoutBtrId),e.writeU32(t.lineBatches.length);for(const a of t.lineBatches)ka(e,a);e.writeU32(t.meshBatches.length);for(const a of t.meshBatches)Aa(e,a);return e.toUint8Array()}function qi(t){const e=Zi(t),a=ee(e).bytes;return{uncompressed:e,compressed:a}}const Qi=1,to=2*1024*1024,St=2*1024*1024,eo=512*1024,ao=8*1024*1024,Qe=12*1024*1024,ro=2*1024*1024,Ct="drawing.acex.json",no=`./${Ct}`,Kt={layerOn:tn,layerOff:en,chevronDown:Qr},io=[90,45,30,23,18,10,5];function oo(){return`<div id="mlcad-polar-angles" role="group" data-i18n-attr="aria-label" data-i18n-key="settings.polarAngles" aria-label="Polar tracking angles" hidden>
2
2
  ${io.map(t=>`<button type="button" class="mlcad-tool-btn mlcad-settings-option-btn mlcad-polar-angle-btn" data-polar-ang="${t}" title="${t}°" aria-label="${t}°"><span class="mlcad-settings-option-indicator" aria-hidden="true"></span><span class="mlcad-settings-option-text">${t}°</span></button>`).join("")}
3
3
  </div>`}const so=600,lo=960,de=`
4
4
  :root {
@@ -805,11 +805,15 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
805
805
  .mlcad-measure-dot {
806
806
  position: absolute;
807
807
  z-index: 3;
808
- width: 10px;
809
- height: 10px;
808
+ /* em size tracks the paired badge font-size (set inline on the dot) */
809
+ font-size: 12px;
810
+ width: 0.55em;
811
+ height: 0.55em;
812
+ min-width: 5px;
813
+ min-height: 5px;
810
814
  border-radius: 50%;
811
815
  background: var(--mlcad-measure-accent);
812
- border: 2px solid rgba(255, 255, 255, 0.9);
816
+ border: 0.12em solid rgba(255, 255, 255, 0.9);
813
817
  box-sizing: border-box;
814
818
  transform: translate(-50%, -50%);
815
819
  visibility: hidden;
@@ -819,10 +823,11 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
819
823
  .mlcad-measure-dot.mlcad-measure-selected {
820
824
  visibility: visible;
821
825
  pointer-events: auto;
826
+ /* Hard ring at half original em thickness + soft glow */
822
827
  box-shadow:
823
- 0 0 0 2px rgba(255, 213, 79, 0.75),
824
- 0 0 10px rgba(255, 213, 79, 0.95),
825
- 0 0 18px rgba(255, 213, 79, 0.55);
828
+ 0 0 0 0.06em rgba(255, 213, 79, 0.75),
829
+ 0 0 0.35em rgba(255, 213, 79, 0.9),
830
+ 0 0 0.7em rgba(255, 213, 79, 0.5);
826
831
  }
827
832
  #mlcad-measure-overlays.mlcad-grip-dragging .mlcad-measure-dot {
828
833
  visibility: hidden !important;
@@ -831,10 +836,11 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
831
836
  .mlcad-measure-badge {
832
837
  position: absolute;
833
838
  z-index: 2;
834
- padding: 3px 10px;
835
- border-radius: 14px;
839
+ /* em padding/radius/border so the capsule scales with font-size */
840
+ padding: 0.25em 0.833em;
841
+ border-radius: 1.167em;
836
842
  background: var(--mlcad-ui-bg-elevated);
837
- border: 1px solid var(--mlcad-measure-accent-border);
843
+ border: 0.083em solid var(--mlcad-measure-accent-border);
838
844
  color: var(--mlcad-measure-accent);
839
845
  font-size: 12px;
840
846
  font-weight: 600;
@@ -847,18 +853,21 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
847
853
  transform: translate(-50%, calc(-50% - 16px));
848
854
  }
849
855
  .mlcad-measure-badge.mlcad-measure-selected {
850
- outline: 2px solid rgba(255, 213, 79, 0.85);
851
- outline-offset: 1px;
856
+ /* Hard ring at half original em thickness + soft glow */
857
+ outline: 0.075em solid rgba(255, 213, 79, 0.85);
858
+ outline-offset: 0.04em;
852
859
  box-shadow:
853
- 0 0 0 2px rgba(255, 213, 79, 0.4),
854
- 0 0 12px rgba(255, 213, 79, 0.75),
860
+ 0 0 0 0.075em rgba(255, 213, 79, 0.4),
861
+ 0 0 0.45em rgba(255, 213, 79, 0.85),
862
+ 0 0 0.9em rgba(255, 213, 79, 0.55),
855
863
  0 2px 8px rgba(0, 0, 0, 0.35);
856
864
  }
857
865
  .mlcad-measure-canvas.mlcad-measure-selected {
866
+ /* font-size is seeded from the paired badge so em tracks text size */
858
867
  filter:
859
- drop-shadow(0 0 1.5px #ffd54f)
860
- drop-shadow(0 0 4px rgba(255, 213, 79, 0.95))
861
- drop-shadow(0 0 8px rgba(255, 213, 79, 0.55));
868
+ drop-shadow(0 0 0.12em #ffd54f)
869
+ drop-shadow(0 0 0.3em rgba(255, 213, 79, 0.95))
870
+ drop-shadow(0 0 0.6em rgba(255, 213, 79, 0.55));
862
871
  }
863
872
 
864
873
  #mlcad-markup-overlays {
@@ -909,11 +918,14 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
909
918
  }
910
919
  .mlcad-markup-preview-dot {
911
920
  position: absolute;
912
- width: 10px;
913
- height: 10px;
921
+ font-size: 12px;
922
+ width: 0.55em;
923
+ height: 0.55em;
924
+ min-width: 5px;
925
+ min-height: 5px;
914
926
  border-radius: 50%;
915
927
  background: var(--mlcad-markup-accent);
916
- border: 2px solid rgba(255, 255, 255, 0.9);
928
+ border: 0.12em solid rgba(255, 255, 255, 0.9);
917
929
  box-sizing: border-box;
918
930
  transform: translate(-50%, -50%);
919
931
  pointer-events: none;
@@ -921,11 +933,14 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
921
933
  .mlcad-markup-dot {
922
934
  position: absolute;
923
935
  z-index: 3;
924
- width: 10px;
925
- height: 10px;
936
+ font-size: 12px;
937
+ width: 0.55em;
938
+ height: 0.55em;
939
+ min-width: 5px;
940
+ min-height: 5px;
926
941
  border-radius: 50%;
927
942
  background: var(--mlcad-markup-accent);
928
- border: 2px solid rgba(255, 255, 255, 0.9);
943
+ border: 0.12em solid rgba(255, 255, 255, 0.9);
929
944
  box-sizing: border-box;
930
945
  transform: translate(-50%, -50%);
931
946
  visibility: hidden;
@@ -936,9 +951,9 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
936
951
  visibility: visible;
937
952
  pointer-events: auto;
938
953
  box-shadow:
939
- 0 0 0 2px rgba(255, 213, 79, 0.75),
940
- 0 0 10px rgba(255, 213, 79, 0.95),
941
- 0 0 18px rgba(255, 213, 79, 0.55);
954
+ 0 0 0 0.06em rgba(255, 213, 79, 0.75),
955
+ 0 0 0.35em rgba(255, 213, 79, 0.9),
956
+ 0 0 0.7em rgba(255, 213, 79, 0.5);
942
957
  }
943
958
  #mlcad-markup-overlays.mlcad-grip-dragging .mlcad-markup-dot {
944
959
  visibility: hidden !important;
@@ -946,18 +961,19 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
946
961
  }
947
962
  .mlcad-markup-badge.mlcad-markup-selected,
948
963
  .mlcad-markup-stamp.mlcad-markup-selected {
949
- outline: 2px solid rgba(255, 213, 79, 0.85);
950
- outline-offset: 1px;
964
+ outline: 0.075em solid rgba(255, 213, 79, 0.85);
965
+ outline-offset: 0.04em;
951
966
  box-shadow:
952
- 0 0 0 2px rgba(255, 213, 79, 0.4),
953
- 0 0 12px rgba(255, 213, 79, 0.75),
967
+ 0 0 0 0.075em rgba(255, 213, 79, 0.4),
968
+ 0 0 0.45em rgba(255, 213, 79, 0.85),
969
+ 0 0 0.9em rgba(255, 213, 79, 0.55),
954
970
  0 2px 8px rgba(0, 0, 0, 0.35);
955
971
  }
956
972
  .mlcad-markup-canvas.mlcad-markup-selected {
957
973
  filter:
958
- drop-shadow(0 0 1.5px #ffd54f)
959
- drop-shadow(0 0 4px rgba(255, 213, 79, 0.95))
960
- drop-shadow(0 0 8px rgba(255, 213, 79, 0.55));
974
+ drop-shadow(0 0 0.12em #ffd54f)
975
+ drop-shadow(0 0 0.3em rgba(255, 213, 79, 0.95))
976
+ drop-shadow(0 0 0.6em rgba(255, 213, 79, 0.55));
961
977
  }
962
978
 
963
979
  #mlcad-loading {
@@ -1479,6 +1495,7 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
1479
1495
  <div class="mlcad-measure-filter" role="group" data-i18n-key="measurePanel.filterGroup" data-i18n-attr="aria-label" aria-label="Filter by type">
1480
1496
  <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="distance" aria-pressed="false" data-i18n-key="measurePanel.filterDistance" data-i18n-text data-i18n-attr="title aria-label" title="Distance">Distance</button>
1481
1497
  <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="arc" aria-pressed="false" data-i18n-key="measurePanel.filterArc" data-i18n-text data-i18n-attr="title aria-label" title="Arc">Arc</button>
1498
+ <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="radius" aria-pressed="false" data-i18n-key="measurePanel.filterRadius" data-i18n-text data-i18n-attr="title aria-label" title="Radius">Radius</button>
1482
1499
  <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="angle" aria-pressed="false" data-i18n-key="measurePanel.filterAngle" data-i18n-text data-i18n-attr="title aria-label" title="Angle">Angle</button>
1483
1500
  <button type="button" class="mlcad-measure-filter-btn" data-measure-filter="area" aria-pressed="false" data-i18n-key="measurePanel.filterArea" data-i18n-text data-i18n-attr="title aria-label" title="Area">Area</button>
1484
1501
  </div>
@@ -1496,7 +1513,7 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
1496
1513
  <tbody></tbody>
1497
1514
  </table>
1498
1515
  </div>
1499
- </div>`}function mo(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.encoded??Fa(t),i=e.viewerRuntime,o=$n(),s=n.compression,l=((a=e.accessManifest)==null?void 0:a.encrypted)===!0,c=`#${t.meta.background.toString(16).padStart(6,"0")}`,d=ce(t.meta.locale)??"en",u=t.meta.viewerMode??"measure",m=t.meta.exportLayouts!==!1,p=e.accessManifest?` <script id="mlcad-access" type="application/json">${Ra(JSON.stringify(e.accessManifest))}<\/script>
1516
+ </div>`}function mo(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.encoded??Fa(t),i=e.viewerRuntime,o=$n(),s=n.compression,l=((a=e.accessManifest)==null?void 0:a.encrypted)===!0,c=`#${t.meta.background.toString(16).padStart(6,"0")}`,d=ce(t.meta.locale)??"en",u=t.meta.viewerMode??"measure",m=t.meta.exportLayouts!==!1,p=e.accessManifest?` <script id="mlcad-access" type="application/json">${Ta(JSON.stringify(e.accessManifest))}<\/script>
1500
1517
  `:"",g=l?`${o}+aes-gcm;base64`:`${o}+${s};base64`;return`<!DOCTYPE html>
1501
1518
  <html lang="${d}">
1502
1519
  <head>
@@ -1509,7 +1526,7 @@ import{j as rr,$ as nr,_ as bt,u as v,x as nt,b as R,g as ir,a as H,n as or,k as
1509
1526
  <body>
1510
1527
  ${ue(c,u,m)}
1511
1528
  ${p} <script id="mlcad-snapshot" type="${g}">${n.payload}<\/script>
1512
- <script>${Ta(i)}<\/script>
1529
+ <script>${Ra(i)}<\/script>
1513
1530
  </body>
1514
1531
  </html>`}function po(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.viewerRuntime,i=`#${t.meta.background.toString(16).padStart(6,"0")}`,o=ce(t.meta.locale)??"en",s=t.meta.viewerMode??"measure",l=t.meta.exportLayouts!==!1,c=(a=e.manifestUrl)==null?void 0:a.trim(),d=JSON.stringify(c&&c!==no?{manifestUrl:c}:{});return`<!DOCTYPE html>
1515
1532
  <html lang="${o}">
@@ -1522,11 +1539,11 @@ ${p} <script id="mlcad-snapshot" type="${g}">${n.payload}<\/script>
1522
1539
  </head>
1523
1540
  <body>
1524
1541
  ${ue(i,s,l)}
1525
- <script id="mlcad-package" type="application/json">${Ra(d)}<\/script>
1526
- <script>${Ta(n)}<\/script>
1542
+ <script id="mlcad-package" type="application/json">${Ta(d)}<\/script>
1543
+ <script>${Ra(n)}<\/script>
1527
1544
  </body>
1528
- </html>`}function Oa(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ta(t){return t.replace(/<\/script/gi,"<\\/script")}function Ra(t){return t.replace(/</g,"\\u003c")}const ho=1,fo=1e5,go=16,bo=12;function wo(t,e=Date.now(),a){return t==="never"?null:t==="custom"?a??null:e+t*24*60*60*1e3}function $a(t){var e;const a=!!((e=t.password)!=null&&e.trim());return t.expiresAt!=null||a}function zt(t){var e;if(!$a(t))return;const a=!!((e=t.password)!=null&&e.trim());return{v:ho,expiresAt:t.expiresAt,encrypted:a,...a&&t.salt?{salt:t.salt}:{}}}async function ja(t,e){const a=crypto.getRandomValues(new Uint8Array(go));return{key:await yo(t,a),salt:fe(a)}}async function pe(t,e){const a=crypto.getRandomValues(new Uint8Array(bo)),r=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,r)),i=new Uint8Array(a.length+n.length);return i.set(a,0),i.set(n,a.length),i}async function xo(t,e){const{key:a,salt:r}=await ja(t),n=new Uint8Array(ko(e)),i=await pe(a,n);return{encryptedPayload:fe(i),salt:r}}function he(t){return fe(t)}async function vo(t,e){var a;if(!$a(e))return{encoded:t};const r=(a=e.password)==null?void 0:a.trim();if(r){const{encryptedPayload:n,salt:i}=await xo(r,t.payload);return{encoded:{payload:n,compression:t.compression},manifest:zt({expiresAt:e.expiresAt,password:r,salt:i})}}return{encoded:t,manifest:zt({expiresAt:e.expiresAt})}}async function yo(t,e){const a=new TextEncoder,r=await crypto.subtle.importKey("raw",a.encode(t),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:new Uint8Array(e),iterations:fo,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function fe(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function ko(t){const e=atob(t.trim()),a=new Uint8Array(e.length);for(let r=0;r<e.length;r++)a[r]=e.charCodeAt(r);return a}const Ao=256;function zo(t,e=St){return!(e>0)||ae(t)<=e?[t]:t.indices&&t.indices.length>=2?So(t,e):Fo(t,e)}function Mo(t,e=St){return t.texture?[t]:!(e>0)||re(t)<=e?[t]:t.points?Po(t,e):!t.indices||t.indices.length<3?Va(t,e):Eo(t,e)}function _a(t){return t.linePattern?64+t.linePattern.pattern.length*8:0}function ge(t){return(t.hatchPattern?128:0)+(t.gradientFill?64:0)}function gt(t,e,a){const r=t-Ao-e;return r<a?1:Math.max(1,Math.floor(r/a))}function Fo(t,e){var a;const r=(((a=t.lineDistances)==null?void 0:a.length)??0)>=2,n=24+(r?8:0),i=gt(e,_a(t),n),o=t.positions.length/6|0;if(o<=1)return[t];const s=[];for(let l=0;l<o;l+=i){const c=Math.min(i,o-l),d=l*6,u={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(d,d+c*6)};if(Xa(t,u),r&&t.lineDistances){const m=l*2;u.lineDistances=t.lineDistances.slice(m,m+c*2)}s.push(u)}return s.length>0?s:[t]}function So(t,e){var a;const r=t.indices,n=32+((((a=t.lineDistances)==null?void 0:a.length)??0)>0?8:0),i=gt(e,_a(t),n),o=[];for(let s=0;s+1<r.length;){const l=Math.min(i*2,r.length-s),c=l-l%2;if(c<2)break;o.push(Co(t,s,c)),s+=c}return o.length>0?o:[t]}function Co(t,e,a){const r=Ya(t.positions,t.indices.subarray(e,e+a),t.lineDistances?[t.lineDistances]:[],[1]),n={layer:t.layer,color:t.color,offset:t.offset,positions:r.positions,indices:r.indices};return Xa(t,n),r.attributes[0]&&r.attributes[0].length>0&&(n.lineDistances=r.attributes[0]),n}function Po(t,e){return t.indices&&t.indices.length>0?Lo(t,e):Va(t,e)}function Lo(t,e){const a=t.indices,r=16+(t.uvs?8:0)+(t.gradientPositions?8:0),n=gt(e,ge(t),r),i=[];for(let o=0;o<a.length;){const s=Math.min(n,a.length-o);if(s<1)break;i.push(Ha(t,o,s)),o+=s}return i.length>0?i:[t]}function Va(t,e){const a=t.positions.length/3|0;if(a<=1)return[t];const r=12+(t.uvs?8:0)+(t.gradientPositions?8:0),n=gt(e,ge(t),r),i=t.points?1:3,o=Math.max(i,n-n%i),s=[];for(let l=0;l<a;l+=o){const c=Math.min(o,a-l),d=c-c%i;if(d<i)break;s.push(Io(t,l,d))}return s.length>0?s:[t]}function Eo(t,e){const a=t.indices,r=48+(t.uvs?24:0)+(t.gradientPositions?24:0),n=gt(e,ge(t),r),i=[];for(let o=0;o+2<a.length;){const s=Math.min(n*3,a.length-o),l=s-s%3;if(l<3)break;i.push(Ha(t,o,l)),o+=l}return i.length>0?i:[t]}function Io(t,e,a){const r=e*3,n={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(r,r+a*3)};return Ga(t,n),t.uvs&&(n.uvs=t.uvs.slice(e*2,(e+a)*2)),t.gradientPositions&&(n.gradientPositions=t.gradientPositions.slice(e*2,(e+a)*2)),n}function Ha(t,e,a){const r=[],n=[];t.uvs&&(r.push(t.uvs),n.push(2)),t.gradientPositions&&(r.push(t.gradientPositions),n.push(2));const i=Ya(t.positions,t.indices.subarray(e,e+a),r,n),o={layer:t.layer,color:t.color,offset:t.offset,positions:i.positions,indices:i.indices};Ga(t,o);let s=0;return t.uvs&&(o.uvs=i.attributes[s++]),t.gradientPositions&&(o.gradientPositions=i.attributes[s]),o}function Ya(t,e,a,r){const n=new Map,i=[],o=new Uint32Array(e.length),s=a.map(()=>[]);for(let l=0;l<e.length;l++){const c=e[l];let d=n.get(c);if(d==null){d=n.size,n.set(c,d);const u=c*3;i.push(t[u]??0,t[u+1]??0,t[u+2]??0);for(let m=0;m<a.length;m++){const p=r[m],g=a[m],h=c*p;for(let w=0;w<p;w++)s[m].push(g[h+w]??0)}}o[l]=d}return{positions:Float32Array.from(i),indices:o,attributes:s.map(l=>Float32Array.from(l))}}function Xa(t,e){t.linePattern&&(e.linePattern=t.linePattern),t.lineWidth!=null&&(e.lineWidth=t.lineWidth),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.excludeFromOsnap&&(e.excludeFromOsnap=!0)}function Ga(t,e){t.hatchPattern&&(e.hatchPattern=t.hatchPattern),t.gradientFill&&(e.gradientFill=t.gradientFill),t.side!=null&&(e.side=t.side),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.points&&(e.points=!0)}function Bo(t,e,a=St){const r=[];let n={lineBatches:[],meshBatches:[],estimatedBytes:64};const i=()=>{n.lineBatches.length===0&&n.meshBatches.length===0&&r.length>0||(r.push(n),n={lineBatches:[],meshBatches:[],estimatedBytes:64})},o=c=>{const d=ae(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.lineBatches.push(c),n.estimatedBytes+=d},s=c=>{const d=re(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.meshBatches.push(c),n.estimatedBytes+=d},l=Math.min(e,a);for(const c of t.lineBatches)for(const d of zo(c,l))o(d);for(const c of t.meshBatches)for(const d of Mo(c,l))s(d);return(r.length===0||n.lineBatches.length>0||n.meshBatches.length>0)&&i(),r.length===0&&r.push({lineBatches:[],meshBatches:[],estimatedBytes:64}),r}function Ka(t,e={}){var a,r;if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const n=e.maxChunkBytes??to,i=e.maxBatchBytes??St,o=e.maxOsnapChunkBytes??eo,s=Ct,l=Uo(t.layouts,t.activeLayoutBtrId),c=[],d=[],u=[],m=[],p=new Map;l.forEach((f,L)=>{var F;p.set(f.btrId,L);const x=Bo(f,n,i),b=[];x.forEach((S,_)=>{const B=`L${L}-${String(_).padStart(3,"0")}`,U=`chunks/${B}.acex.gz`,N={layoutBtrId:f.btrId,lineBatches:S.lineBatches,meshBatches:S.meshBatches},{uncompressed:k,compressed:O}=qi(N);b.push(B),c.push({id:B,href:U,layoutBtrId:f.btrId,byteLength:k.byteLength,compressedByteLength:O.byteLength,lineBatchCount:S.lineBatches.length,meshBatchCount:S.meshBatches.length}),m.push({path:U,bytes:O})});const D={btrId:f.btrId,name:f.name,isModelSpace:f.isModelSpace,viewports:f.viewports,...f.savedView?{savedView:f.savedView}:{},chunkIds:b},Y=(F=f.osnap)==null?void 0:F.primitives;if(Y&&Y.length>0){const S=En(Y,o),_=[];S.forEach((B,U)=>{const N=`L${L}-osnap-${String(U).padStart(3,"0")}`,k=`chunks/${N}.osnap.gz`,{uncompressed:O,compressed:V}=In({primitives:B});_.push(N),d.push({id:N,href:k,layoutBtrId:f.btrId,byteLength:O.byteLength,compressedByteLength:V.byteLength,primitiveCount:B.length}),m.push({path:k,bytes:V})}),D.osnapChunkIds=_}u.push(D)});const g=t.layouts.map(f=>{const L=p.get(f.btrId);return u[L]}),h=new Set(((a=g.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:a.chunkIds)??[]),w=[...c.filter(f=>h.has(f.id)),...c.filter(f=>!h.has(f.id))],A=new Set(((r=g.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:r.osnapChunkIds)??[]),z=[...d.filter(f=>A.has(f.id)),...d.filter(f=>!A.has(f.id))],I={format:"acex-package",packageVersion:Qi,snapshotVersion:J,meta:t.meta,layers:t.layers,activeLayoutBtrId:t.activeLayoutBtrId,layouts:g,chunks:w,...z.length>0?{osnapChunks:z}:{}},M=`${JSON.stringify(I)}
1529
- `;return m.unshift({path:s,bytes:mt(M)}),{manifest:I,manifestFileName:s,files:m}}function Do(t,e){const a=Ka(t,e),r=po(t,{title:t.meta.title,viewerRuntime:e.viewerRuntime,...e.manifestUrl?{manifestUrl:e.manifestUrl}:{}});return{html:r,manifest:a.manifest,manifestFileName:a.manifestFileName,files:[{path:"viewer.html",bytes:mt(r)},...a.files]}}function Uo(t,e){const a=t.find(n=>n.btrId===e),r=t.filter(n=>n.btrId!==e);return a?[a,...r]:[...t]}const No="application/vnd.mlightcad.acex-chunk;base64",Oo="application/vnd.mlightcad.acex-chunk+aes-gcm;base64",Wa="data-acex-href";function To(t){var e;let a=0;for(const r of t.layouts){for(const i of r.lineBatches)a+=ae(i);for(const i of r.meshBatches)a+=re(i);const n=(e=r.osnap)==null?void 0:e.primitives;if(n)for(const i of n)a+=za(i)}return a}function Ro(t,e=ao){return To(t)>=e}async function $o(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.viewerRuntime,i=`#${t.meta.background.toString(16).padStart(6,"0")}`,o=ce(t.meta.locale)??"en",s=t.meta.viewerMode??"measure",l=t.meta.exportLayouts!==!1,c=e.expiresAt??null,d=((a=e.password)==null?void 0:a.trim())||void 0,u={maxChunkBytes:e.maxChunkBytes??Qe,maxBatchBytes:e.maxBatchBytes??e.maxChunkBytes??Qe,maxOsnapChunkBytes:e.maxOsnapChunkBytes??ro},m=Ka(t,u);let p,g,h;if(d){const{key:A,salt:z}=await ja(d);p=zt({expiresAt:c,password:d,salt:z});const I=new TextEncoder().encode(`${JSON.stringify(m.manifest)}
1545
+ </html>`}function Oa(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ra(t){return t.replace(/<\/script/gi,"<\\/script")}function Ta(t){return t.replace(/</g,"\\u003c")}const ho=1,fo=1e5,go=16,bo=12;function wo(t,e=Date.now(),a){return t==="never"?null:t==="custom"?a??null:e+t*24*60*60*1e3}function $a(t){var e;const a=!!((e=t.password)!=null&&e.trim());return t.expiresAt!=null||a}function zt(t){var e;if(!$a(t))return;const a=!!((e=t.password)!=null&&e.trim());return{v:ho,expiresAt:t.expiresAt,encrypted:a,...a&&t.salt?{salt:t.salt}:{}}}async function ja(t,e){const a=crypto.getRandomValues(new Uint8Array(go));return{key:await yo(t,a),salt:fe(a)}}async function pe(t,e){const a=crypto.getRandomValues(new Uint8Array(bo)),r=new Uint8Array(e),n=new Uint8Array(await crypto.subtle.encrypt({name:"AES-GCM",iv:a},t,r)),i=new Uint8Array(a.length+n.length);return i.set(a,0),i.set(n,a.length),i}async function xo(t,e){const{key:a,salt:r}=await ja(t),n=new Uint8Array(ko(e)),i=await pe(a,n);return{encryptedPayload:fe(i),salt:r}}function he(t){return fe(t)}async function vo(t,e){var a;if(!$a(e))return{encoded:t};const r=(a=e.password)==null?void 0:a.trim();if(r){const{encryptedPayload:n,salt:i}=await xo(r,t.payload);return{encoded:{payload:n,compression:t.compression},manifest:zt({expiresAt:e.expiresAt,password:r,salt:i})}}return{encoded:t,manifest:zt({expiresAt:e.expiresAt})}}async function yo(t,e){const a=new TextEncoder,r=await crypto.subtle.importKey("raw",a.encode(t),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:new Uint8Array(e),iterations:fo,hash:"SHA-256"},r,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function fe(t){let e="";for(let a=0;a<t.length;a++)e+=String.fromCharCode(t[a]);return btoa(e)}function ko(t){const e=atob(t.trim()),a=new Uint8Array(e.length);for(let r=0;r<e.length;r++)a[r]=e.charCodeAt(r);return a}const Ao=256;function zo(t,e=St){return!(e>0)||ae(t)<=e?[t]:t.indices&&t.indices.length>=2?So(t,e):Fo(t,e)}function Mo(t,e=St){return t.texture?[t]:!(e>0)||re(t)<=e?[t]:t.points?Po(t,e):!t.indices||t.indices.length<3?Va(t,e):Eo(t,e)}function _a(t){return t.linePattern?64+t.linePattern.pattern.length*8:0}function ge(t){return(t.hatchPattern?128:0)+(t.gradientFill?64:0)}function gt(t,e,a){const r=t-Ao-e;return r<a?1:Math.max(1,Math.floor(r/a))}function Fo(t,e){var a;const r=(((a=t.lineDistances)==null?void 0:a.length)??0)>=2,n=24+(r?8:0),i=gt(e,_a(t),n),o=t.positions.length/6|0;if(o<=1)return[t];const s=[];for(let l=0;l<o;l+=i){const c=Math.min(i,o-l),d=l*6,u={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(d,d+c*6)};if(Xa(t,u),r&&t.lineDistances){const m=l*2;u.lineDistances=t.lineDistances.slice(m,m+c*2)}s.push(u)}return s.length>0?s:[t]}function So(t,e){var a;const r=t.indices,n=32+((((a=t.lineDistances)==null?void 0:a.length)??0)>0?8:0),i=gt(e,_a(t),n),o=[];for(let s=0;s+1<r.length;){const l=Math.min(i*2,r.length-s),c=l-l%2;if(c<2)break;o.push(Co(t,s,c)),s+=c}return o.length>0?o:[t]}function Co(t,e,a){const r=Ya(t.positions,t.indices.subarray(e,e+a),t.lineDistances?[t.lineDistances]:[],[1]),n={layer:t.layer,color:t.color,offset:t.offset,positions:r.positions,indices:r.indices};return Xa(t,n),r.attributes[0]&&r.attributes[0].length>0&&(n.lineDistances=r.attributes[0]),n}function Po(t,e){return t.indices&&t.indices.length>0?Lo(t,e):Va(t,e)}function Lo(t,e){const a=t.indices,r=16+(t.uvs?8:0)+(t.gradientPositions?8:0),n=gt(e,ge(t),r),i=[];for(let o=0;o<a.length;){const s=Math.min(n,a.length-o);if(s<1)break;i.push(Ha(t,o,s)),o+=s}return i.length>0?i:[t]}function Va(t,e){const a=t.positions.length/3|0;if(a<=1)return[t];const r=12+(t.uvs?8:0)+(t.gradientPositions?8:0),n=gt(e,ge(t),r),i=t.points?1:3,o=Math.max(i,n-n%i),s=[];for(let l=0;l<a;l+=o){const c=Math.min(o,a-l),d=c-c%i;if(d<i)break;s.push(Io(t,l,d))}return s.length>0?s:[t]}function Eo(t,e){const a=t.indices,r=48+(t.uvs?24:0)+(t.gradientPositions?24:0),n=gt(e,ge(t),r),i=[];for(let o=0;o+2<a.length;){const s=Math.min(n*3,a.length-o),l=s-s%3;if(l<3)break;i.push(Ha(t,o,l)),o+=l}return i.length>0?i:[t]}function Io(t,e,a){const r=e*3,n={layer:t.layer,color:t.color,offset:t.offset,positions:t.positions.slice(r,r+a*3)};return Ga(t,n),t.uvs&&(n.uvs=t.uvs.slice(e*2,(e+a)*2)),t.gradientPositions&&(n.gradientPositions=t.gradientPositions.slice(e*2,(e+a)*2)),n}function Ha(t,e,a){const r=[],n=[];t.uvs&&(r.push(t.uvs),n.push(2)),t.gradientPositions&&(r.push(t.gradientPositions),n.push(2));const i=Ya(t.positions,t.indices.subarray(e,e+a),r,n),o={layer:t.layer,color:t.color,offset:t.offset,positions:i.positions,indices:i.indices};Ga(t,o);let s=0;return t.uvs&&(o.uvs=i.attributes[s++]),t.gradientPositions&&(o.gradientPositions=i.attributes[s]),o}function Ya(t,e,a,r){const n=new Map,i=[],o=new Uint32Array(e.length),s=a.map(()=>[]);for(let l=0;l<e.length;l++){const c=e[l];let d=n.get(c);if(d==null){d=n.size,n.set(c,d);const u=c*3;i.push(t[u]??0,t[u+1]??0,t[u+2]??0);for(let m=0;m<a.length;m++){const p=r[m],g=a[m],h=c*p;for(let w=0;w<p;w++)s[m].push(g[h+w]??0)}}o[l]=d}return{positions:Float32Array.from(i),indices:o,attributes:s.map(l=>Float32Array.from(l))}}function Xa(t,e){t.linePattern&&(e.linePattern=t.linePattern),t.lineWidth!=null&&(e.lineWidth=t.lineWidth),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.excludeFromOsnap&&(e.excludeFromOsnap=!0)}function Ga(t,e){t.hatchPattern&&(e.hatchPattern=t.hatchPattern),t.gradientFill&&(e.gradientFill=t.gradientFill),t.side!=null&&(e.side=t.side),t.renderOrder!=null&&(e.renderOrder=t.renderOrder),t.points&&(e.points=!0)}function Bo(t,e,a=St){const r=[];let n={lineBatches:[],meshBatches:[],estimatedBytes:64};const i=()=>{n.lineBatches.length===0&&n.meshBatches.length===0&&r.length>0||(r.push(n),n={lineBatches:[],meshBatches:[],estimatedBytes:64})},o=c=>{const d=ae(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.lineBatches.push(c),n.estimatedBytes+=d},s=c=>{const d=re(c);n.estimatedBytes+d>e&&(n.lineBatches.length>0||n.meshBatches.length>0)&&i(),n.meshBatches.push(c),n.estimatedBytes+=d},l=Math.min(e,a);for(const c of t.lineBatches)for(const d of zo(c,l))o(d);for(const c of t.meshBatches)for(const d of Mo(c,l))s(d);return(r.length===0||n.lineBatches.length>0||n.meshBatches.length>0)&&i(),r.length===0&&r.push({lineBatches:[],meshBatches:[],estimatedBytes:64}),r}function Ka(t,e={}){var a,r;if(t.version!==J)throw new Error(`Unsupported snapshot version: ${t.version}`);const n=e.maxChunkBytes??to,i=e.maxBatchBytes??St,o=e.maxOsnapChunkBytes??eo,s=Ct,l=Do(t.layouts,t.activeLayoutBtrId),c=[],d=[],u=[],m=[],p=new Map;l.forEach((f,L)=>{var F;p.set(f.btrId,L);const x=Bo(f,n,i),b=[];x.forEach((S,_)=>{const B=`L${L}-${String(_).padStart(3,"0")}`,D=`chunks/${B}.acex.gz`,N={layoutBtrId:f.btrId,lineBatches:S.lineBatches,meshBatches:S.meshBatches},{uncompressed:k,compressed:O}=qi(N);b.push(B),c.push({id:B,href:D,layoutBtrId:f.btrId,byteLength:k.byteLength,compressedByteLength:O.byteLength,lineBatchCount:S.lineBatches.length,meshBatchCount:S.meshBatches.length}),m.push({path:D,bytes:O})});const U={btrId:f.btrId,name:f.name,isModelSpace:f.isModelSpace,viewports:f.viewports,...f.savedView?{savedView:f.savedView}:{},chunkIds:b},Y=(F=f.osnap)==null?void 0:F.primitives;if(Y&&Y.length>0){const S=En(Y,o),_=[];S.forEach((B,D)=>{const N=`L${L}-osnap-${String(D).padStart(3,"0")}`,k=`chunks/${N}.osnap.gz`,{uncompressed:O,compressed:V}=In({primitives:B});_.push(N),d.push({id:N,href:k,layoutBtrId:f.btrId,byteLength:O.byteLength,compressedByteLength:V.byteLength,primitiveCount:B.length}),m.push({path:k,bytes:V})}),U.osnapChunkIds=_}u.push(U)});const g=t.layouts.map(f=>{const L=p.get(f.btrId);return u[L]}),h=new Set(((a=g.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:a.chunkIds)??[]),w=[...c.filter(f=>h.has(f.id)),...c.filter(f=>!h.has(f.id))],A=new Set(((r=g.find(f=>f.btrId===t.activeLayoutBtrId))==null?void 0:r.osnapChunkIds)??[]),z=[...d.filter(f=>A.has(f.id)),...d.filter(f=>!A.has(f.id))],I={format:"acex-package",packageVersion:Qi,snapshotVersion:J,meta:t.meta,layers:t.layers,activeLayoutBtrId:t.activeLayoutBtrId,layouts:g,chunks:w,...z.length>0?{osnapChunks:z}:{}},M=`${JSON.stringify(I)}
1546
+ `;return m.unshift({path:s,bytes:mt(M)}),{manifest:I,manifestFileName:s,files:m}}function Uo(t,e){const a=Ka(t,e),r=po(t,{title:t.meta.title,viewerRuntime:e.viewerRuntime,...e.manifestUrl?{manifestUrl:e.manifestUrl}:{}});return{html:r,manifest:a.manifest,manifestFileName:a.manifestFileName,files:[{path:"viewer.html",bytes:mt(r)},...a.files]}}function Do(t,e){const a=t.find(n=>n.btrId===e),r=t.filter(n=>n.btrId!==e);return a?[a,...r]:[...t]}const No="application/vnd.mlightcad.acex-chunk;base64",Oo="application/vnd.mlightcad.acex-chunk+aes-gcm;base64",Wa="data-acex-href";function Ro(t){var e;let a=0;for(const r of t.layouts){for(const i of r.lineBatches)a+=ae(i);for(const i of r.meshBatches)a+=re(i);const n=(e=r.osnap)==null?void 0:e.primitives;if(n)for(const i of n)a+=za(i)}return a}function To(t,e=ao){return Ro(t)>=e}async function $o(t,e){var a;const r=e.title??t.meta.title??"CAD Drawing",n=e.viewerRuntime,i=`#${t.meta.background.toString(16).padStart(6,"0")}`,o=ce(t.meta.locale)??"en",s=t.meta.viewerMode??"measure",l=t.meta.exportLayouts!==!1,c=e.expiresAt??null,d=((a=e.password)==null?void 0:a.trim())||void 0,u={maxChunkBytes:e.maxChunkBytes??Qe,maxBatchBytes:e.maxBatchBytes??e.maxChunkBytes??Qe,maxOsnapChunkBytes:e.maxOsnapChunkBytes??ro},m=Ka(t,u);let p,g,h;if(d){const{key:A,salt:z}=await ja(d);p=zt({expiresAt:c,password:d,salt:z});const I=new TextEncoder().encode(`${JSON.stringify(m.manifest)}
1530
1547
  `),M=await pe(A,I);g={mode:"embedded",encrypted:!0,encryptedManifest:he(M)},h=await _o(m.files,A)}else p=zt({expiresAt:c}),g={mode:"embedded",manifest:m.manifest},h=jo(m.files);const w=p?` <script id="mlcad-access" type="application/json">${ta(JSON.stringify(p))}<\/script>
1531
1548
  `:"";return`<!DOCTYPE html>
1532
1549
  <html lang="${o}">
@@ -1544,4 +1561,4 @@ ${h} <script>${Vo(n)}<\/script>
1544
1561
  </body>
1545
1562
  </html>`}function jo(t){const e=[];for(const a of t)a.path!==Ct&&e.push(` <script type="${No}" ${Wa}="${Za(a.path)}">${he(a.bytes)}<\/script>
1546
1563
  `);return e.join("")}async function _o(t,e){const a=[];for(const r of t){if(r.path===Ct)continue;const n=await pe(e,r.bytes);a.push(` <script type="${Oo}" ${Wa}="${Za(r.path)}">${he(n)}<\/script>
1547
- `)}return a.join("")}function Ja(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Za(t){return Ja(t).replace(/'/g,"&#39;")}function Vo(t){return t.replace(/<\/script/gi,"<\\/script")}function ta(t){return t.replace(/</g,"\\u003c")}function Ho(t){return!t||t.startsWith("/")||t.includes("\\")||t.includes("\0")?!1:t.split("/").every(e=>e.length>0&&e!=="."&&e!==".."&&/^[A-Za-z0-9._-]+$/.test(e))}function Yo(t){const e={};for(const a of t.files){if(!Ho(a.path))throw new Error(`Unsafe package path: ${a.path}`);e[a.path]=a.bytes}return wn(e,{level:6})}const Xo=400;function q(t={}){var e;const a=t.exportFormat==="multi"?"multi":"single";return{exportFormat:a,exportInvisibleLayers:t.exportInvisibleLayers!==!1,exportLayouts:t.exportLayouts!==!1,initialView:t.initialView??"fit",viewerMode:t.viewerMode??"measure",expiryDays:a==="multi"?"never":t.expiryDays??"never",expiresAt:a==="multi"?null:t.expiresAt??null,password:a==="multi"?"":((e=t.password)==null?void 0:e.trim())??""}}function Go(t){const e=t.activeLayoutView,a=e.center,r=e.trCamera.zoom,n=Math.max(e.height,1),i=r*(2*Xo)/n;return{centerX:a.x,centerY:a.y,zoom:i}}const Ko="./viewer-runtime.iife.js";let ft={};function Wo(t){ft={...ft,...t}}function Jo(){return{...ft}}function Zo(t){return t!=null?String(t):ft.viewerRuntimeUrl!=null?String(ft.viewerRuntimeUrl):Ko}const qa="https://mlightcad.com/cad-viewer/docs/";let Qa=tr(qa);function qo(){return Qa}function Qo(t){Qa=tr(t)}function tr(t){const e=t.trim();return e?e.replace(/\/+$/,""):qa.replace(/\/+$/,"")}function ts(){return{minX:0,minY:0,maxX:0,maxY:0,valid:!1}}function es(t,e,a){if(e.length<3)return;const r=a[0],n=a[1];for(let i=0;i+2<e.length;i+=3){const o=_e(e[i],r),s=_e(e[i+1],n);t.valid?(o<t.minX&&(t.minX=o),o>t.maxX&&(t.maxX=o),s<t.minY&&(t.minY=s),s>t.maxY&&(t.maxY=s)):(t.minX=t.maxX=o,t.minY=t.maxY=s,t.valid=!0)}}function ea(t,e){es(t,e.positions,e.offset)}function as(t){return t.valid?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null}function rs(t,e){const a=ts();for(const r of t)ea(a,r);for(const r of e)ea(a,r);return as(a)}function er(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e??null}function ns(t){if(!t||t.length===0)return null;let e=null;for(const a of t)e=er(e,a.paper);return e}function is(t){return er(rs(t.lineBatches,t.meshBatches),ns(t.viewports))}function os(t,e,a){if(a)return;const r=ss(t,e);if(!(r!=null&&r.newIterator))return;const n=[];for(const i of r.newIterator()){if(!(i instanceof pr)||hr.isDefaultPaperSpaceViewport(i)||typeof i.toGiViewport!="function")continue;const o=i.toGiViewport(),s=o.box,l=o.viewBox,c=aa(s),d=aa(l);if(!c||!d)continue;const u=Number.isFinite(o.viewTwistAngle)?o.viewTwistAngle:i.viewTwistAngle;n.push(Number.isFinite(u)&&Math.abs(u)>1e-12?{paper:c,model:d,twist:u}:{paper:c,model:d})}return n.length>0?n:void 0}function aa(t){if(typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}function ss(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(!r)return;const n=typeof r.getIdAt=="function"?r.getIdAt(e):void 0;if(n)return n;if(typeof r.newIterator=="function"){for(const o of r.newIterator())if(o.objectId===e)return o}const i=r.modelSpace;if((i==null?void 0:i.objectId)===e)return i}const ra=16/9;function ls(t,e,a,r=ra){var n,i,o,s;const l=Number.isFinite(r)&&r>0?r:ra;if(a){const d=(o=(i=(n=t.tables)==null?void 0:n.viewportTable)==null?void 0:i.getActiveVportBox)==null?void 0:o.call(i,l);return na(d)}const c=(s=t.objects)==null?void 0:s.layout;if(c!=null&&c.newIterator){for(const d of c.newIterator())if(d.blockTableRecordId===e)return na(d.limits)}}function na(t){if(!t||typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}class cs{build(e,a,r={}){return this.buildSync(e,a,r)}async buildAsync(e,a,r={}){await H();const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>wt(e,p,n),s=Ke(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{wt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=oa(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=la(e,i),m=[];for(const p of sa(e,c,i))m.push(ca(e,a,p,d,r,o)),await H();return{version:J,meta:ia(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}buildSync(e,a,r){const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>wt(e,p,n),s=Ke(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{wt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=oa(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=la(e,i),m=[];for(const p of sa(e,c,i))m.push(ca(e,a,p,d,r,o));return{version:J,meta:ia(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}}function ia(t,e,a,r){const n=a.find(s=>s.btrId===r)??a[0],i=n?is(n):null,o=e.initialView??"fit";return{title:t.title,createdAt:new Date().toISOString(),extents:t.extents,viewExtents:i??void 0,units:t.units,grip:t.grip,background:t.background,locale:e.locale??v.currentLocale,initialView:o,viewState:o==="current"?e.viewState:void 0,viewerMode:e.viewerMode??"measure",exportLayouts:e.exportLayouts!==!1,docsBaseUrl:ds()}}function ds(){try{Qo(fr())}catch{}return qo()}function us(t){return(t.viewerMode??"measure")==="measure"}function wt(t,e,a){if(a)return!0;const r=t.layers.get(e);return r?!r.isOff&&!r.isFrozen:!0}function oa(t){var e;const a=(e=t.objects)==null?void 0:e.layout;if(!(a!=null&&a.newIterator))return[];const r=[];for(const n of a.newIterator()){const i=n.blockTableRecordId;i&&r.push({name:n.layoutName||i,tabOrder:n.tabOrder??0,blockTableRecordId:i})}return r.sort((n,i)=>n.tabOrder-i.tabOrder),r}function sa(t,e,a){if(!a)return t.modelSpaceBtrId?[t.modelSpaceBtrId]:[];const r=new Set,n=[];for(const i of e)r.has(i.blockTableRecordId)||(r.add(i.blockTableRecordId),n.push(i.blockTableRecordId));for(const i of t.layouts.keys())r.has(i)||(r.add(i),n.push(i));return n}function la(t,e){return e&&t.activeLayoutBtrId||t.modelSpaceBtrId}function ca(t,e,a,r,n,i){const o=[],s=[],l=t.layouts.get(a);if(l)for(const[,u]of l.layers){if(i&&!i(u.name))continue;const m=fi(u.internalObject);o.push(...m.lineBatches),s.push(...m.meshBatches)}const c=a===t.modelSpaceBtrId,d=ls(e,a,c,n.canvasAspectRatio);return{btrId:a,name:r.get(a)??ms(e,a),isModelSpace:c,lineBatches:o,meshBatches:s,osnap:us(n)?Gi(e,a,{includeLayer:i}):void 0,viewports:os(e,a,c),...d?{savedView:d}:{}}}function ms(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(r!=null&&r.newIterator){for(const n of r.newIterator())if(n.objectId===e)return n.name}return e}class ps{constructor(e={}){this.options=e,this._snapshotBuilder=new cs}async prepareAcTrView2dForHtmlExport(e,a={}){if(!e||!("cadScene"in e)||!e.cadScene)throw new Error("CAD scene is not available. Open a drawing before exporting to HTML.");if(!(e instanceof ir))throw new Error("HTML export requires a 2D CAD view. Open a drawing before exporting.");const r=q(a),n={includeInvisibleLayers:r.exportInvisibleLayers,includeLayouts:r.exportLayouts};return await e.ensureEntitiesConvertedForExport(n),await H(),e}async convert(e,a={},r){const n=nt.instance,i=q(a);await n.withBusyIndicator(async()=>{await H();const o=n.curDocument,s=await this.prepareAcTrView2dForHtmlExport(r??n.curView,i),l=e||o.fileName||o.docTitle,c=or(l),d=await this._snapshotBuilder.buildAsync(s.cadScene,o.database,{title:c,background:s.backgroundColor,exportInvisibleLayers:i.exportInvisibleLayers,exportLayouts:i.exportLayouts,initialView:i.initialView,viewerMode:i.viewerMode,viewState:i.initialView==="current"&&(i.exportLayouts||s.activeLayoutBtrId===s.modelSpaceBtrId)?Go(s):void 0,canvasAspectRatio:s.width/Math.max(s.height,1)});await H();const u=await this.loadViewerRuntime();if(await H(),i.exportFormat==="multi"){const g=Do(d,{viewerRuntime:u}),h=Yo(g);await H(),this.downloadBytes(h,ye(l,"zip"),"application/zip");return}const m=wo(i.expiryDays,Date.now(),i.expiresAt),p=await this.packSelfContainedHtml(d,u,{expiresAt:m,password:i.password||void 0});await H(),this.downloadHtml(p,ye(l,"html"))})}async packSnapshot(e,a){await nt.instance.withBusyIndicator(async()=>{await H();const r=await this.loadViewerRuntime();await H();const n=await this.packSelfContainedHtml(e,r,{expiresAt:null});await H(),this.downloadHtml(n,a)})}async packSelfContainedHtml(e,a,r){if(Ro(e))return $o(e,{title:e.meta.title,viewerRuntime:a,expiresAt:r.expiresAt,password:r.password});const n=await vo(Fa(e),{expiresAt:r.expiresAt,password:r.password});return mo(e,{title:e.meta.title,viewerRuntime:a,encoded:n.encoded,accessManifest:n.manifest})}async loadViewerRuntime(){const e=Zo(this.options.viewerRuntimeUrl),a=await fetch(e);if(!a.ok)throw new Error(`Failed to load HTML viewer runtime from "${e}" (${a.status}). Install @mlightcad/cad-html-plugin, copy viewer-runtime.iife.js to your app assets, and set viewerRuntimeUrl on registerLazyHtmlPlugin / createHtmlPlugin / AcApHtmlConvertor.`);return a.text()}downloadHtml(e,a){this.downloadBytes(new TextEncoder().encode(e),a,"text/html;charset=utf-8")}downloadBytes(e,a,r){const n=new Uint8Array(e.byteLength);n.set(e);const i=new Blob([n],{type:r}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=a,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}}class hs extends nr{constructor(e={}){super(),this.pluginOptions=e}async execute(e){const a=await this.promptOptions();a&&await new ps(this.pluginOptions).convert(e.doc.fileName||e.doc.docTitle,a,e.view)}async promptOptions(){const e=q(),a=await this.promptExportFormat();if(a===void 0)return;const r=await this.promptYesNo("jig.chtml.exportInvisibleLayers",e.exportInvisibleLayers);if(r===void 0)return;const n=await this.promptYesNo("jig.chtml.exportLayouts",e.exportLayouts);if(n===void 0)return;const i=await this.promptInitialView();if(i===void 0)return;const o=await this.promptViewerMode();if(o!==void 0)return q({exportFormat:a,exportInvisibleLayers:r,exportLayouts:n,initialView:i,viewerMode:o})}async promptExportFormat(){const e=q(),a=new bt(v.t("jig.chtml.exportFormat"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.single.display"),v.t("jig.chtml.keywords.single.global"),v.t("jig.chtml.keywords.single.local")),n=a.keywords.add(v.t("jig.chtml.keywords.multi.display"),v.t("jig.chtml.keywords.multi.global"),v.t("jig.chtml.keywords.multi.local"));a.keywords.default=e.exportFormat==="multi"?n:r;const i=await nt.instance.editor.getKeywords(a);if(i.status!==R.Cancel){if(i.status===R.None)return e.exportFormat;if(i.status===R.OK||i.status===R.Keyword)return i.stringResult?i.stringResult==="Multi"?"multi":"single":e.exportFormat}}async promptYesNo(e,a){const r=new bt(v.t(e));r.allowNone=!0;const n=r.keywords.add(v.t("jig.chtml.keywords.yes.display"),v.t("jig.chtml.keywords.yes.global"),v.t("jig.chtml.keywords.yes.local")),i=r.keywords.add(v.t("jig.chtml.keywords.no.display"),v.t("jig.chtml.keywords.no.global"),v.t("jig.chtml.keywords.no.local"));r.keywords.default=a?n:i;const o=await nt.instance.editor.getKeywords(r);if(o.status!==R.Cancel){if(o.status===R.None)return a;if(o.status===R.OK||o.status===R.Keyword)return o.stringResult?o.stringResult==="Yes":a}}async promptInitialView(){const e=q(),a=new bt(v.t("jig.chtml.initialView"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.extents.display"),v.t("jig.chtml.keywords.extents.global"),v.t("jig.chtml.keywords.extents.local")),n=a.keywords.add(v.t("jig.chtml.keywords.current.display"),v.t("jig.chtml.keywords.current.global"),v.t("jig.chtml.keywords.current.local"));a.keywords.default=e.initialView==="current"?n:r;const i=await nt.instance.editor.getKeywords(a);if(i.status!==R.Cancel){if(i.status===R.None)return e.initialView;if(i.status===R.OK||i.status===R.Keyword)return i.stringResult?i.stringResult==="Current"?"current":"fit":e.initialView}}async promptViewerMode(){const e=q(),a=new bt(v.t("jig.chtml.viewerMode"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.view.display"),v.t("jig.chtml.keywords.view.global"),v.t("jig.chtml.keywords.view.local")),n=a.keywords.add(v.t("jig.chtml.keywords.measure.display"),v.t("jig.chtml.keywords.measure.global"),v.t("jig.chtml.keywords.measure.local"));a.keywords.default=e.viewerMode==="view"?r:n;const i=await nt.instance.editor.getKeywords(a);if(i.status!==R.Cancel){if(i.status===R.None)return e.viewerMode;if(i.status===R.OK||i.status===R.Keyword)return i.stringResult?i.stringResult==="View"?"view":"measure":e.viewerMode}}}const fs="1.7.2",gs={version:fs};class bs{constructor(e={}){this.options=e,this.name="HtmlPlugin",this.version=gs.version,this.description="HTML export (-chtml) command",this.registeredCommands=[]}onLoad(e,a){const r=rr.SYSTEMT_COMMAND_GROUP_NAME,n=new hs(this.options);a.addCommand(r,"-chtml","-chtml",n),this.registeredCommands.push({group:r,name:"-chtml"}),a.lookupGlobalCmd("chtml")||(a.addCommand(r,"chtml","chtml",n),this.registeredCommands.push({group:r,name:"chtml"}))}onUnload(e,a){for(const r of this.registeredCommands)a.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function xs(t={}){return t.viewerRuntimeUrl!=null&&Wo(t),new bs(Jo())}export{Ji as ACEC_CHUNK_MAGIC,kn as ACEO_OSNAP_MAGIC,An as ACEO_OSNAP_VERSION,to as ACEX_DEFAULT_CHUNK_MAX_BYTES,Ct as ACEX_DEFAULT_MANIFEST_FILE,no as ACEX_DEFAULT_MANIFEST_HREF,eo as ACEX_DEFAULT_OSNAP_CHUNK_MAX_BYTES,Oo as ACEX_EMBEDDED_CHUNK_ENCRYPTED_MIME,Wa as ACEX_EMBEDDED_CHUNK_HREF_ATTR,Qe as ACEX_EMBEDDED_CHUNK_MAX_BYTES,No as ACEX_EMBEDDED_CHUNK_MIME,ao as ACEX_EMBEDDED_CHUNK_THRESHOLD_BYTES,ro as ACEX_EMBEDDED_OSNAP_CHUNK_MAX_BYTES,St as ACEX_MAX_GEOMETRY_BATCH_BYTES,Qi as ACEX_PACKAGE_VERSION,xn as ACEX_SNAPSHOT_COMPRESSION,J as ACEX_SNAPSHOT_VERSION,hs as AcApExportHtmlCmd,ps as AcApHtmlConvertor,cs as AcApHtmlSnapshotBuilder,Ko as DEFAULT_HTML_VIEWER_RUNTIME_URL,ks as HTML_PLUGIN_NAME,As as HTML_PLUGIN_TRIGGERS,he as acExHtmlBytesToBase64,zt as buildAcExHtmlAccessManifest,Do as buildAcExPackage,Ka as buildAcExPackageData,Gi as buildOsnapCatalog,Ke as buildViewerMetadata,Go as captureAcApHtmlViewState,fi as collectBatchesFromObject3D,ee as compressSnapshotBinary,Wo as configureHtmlPlugin,ja as createAcExHtmlAccessKey,xs as createHtmlPlugin,Zi as encodeChunkBinary,qi as encodeChunkGzip,Ma as encodeOsnapCatalogBinary,In as encodeOsnapCatalogGzip,Fa as encodeSnapshot,Un as encodeSnapshotBinary,pe as encryptAcExHtmlBytes,xo as encryptAcExHtmlSnapshotPayload,To as estimateAcExSnapshotGeometryBytes,za as estimateOsnapPrimitiveBytes,oi as exportActiveBatchedLine2Slice,oe as exportActiveBatchedSlice,He as exportBufferGeometrySlice,Jo as getHtmlPluginOptions,oa as listDatabaseLayouts,$a as needsAcExHtmlAccessControl,mo as packHtml,$o as packHtmlEmbeddedPackage,po as packHtmlPackage,vo as protectAcExHtmlEncodedSnapshot,wo as resolveAcApHtmlExpiresAt,q as resolveAcApHtmlExportOptions,ce as resolveAcExHtmlLocale,Zo as resolveViewerRuntimeUrl,Ro as shouldEmbedAcExChunks,$n as snapshotMimeType,Bo as splitLayoutIntoSlices,En as splitOsnapPrimitives,Yo as zipAcExPackageFiles};
1564
+ `)}return a.join("")}function Ja(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Za(t){return Ja(t).replace(/'/g,"&#39;")}function Vo(t){return t.replace(/<\/script/gi,"<\\/script")}function ta(t){return t.replace(/</g,"\\u003c")}function Ho(t){return!t||t.startsWith("/")||t.includes("\\")||t.includes("\0")?!1:t.split("/").every(e=>e.length>0&&e!=="."&&e!==".."&&/^[A-Za-z0-9._-]+$/.test(e))}function Yo(t){const e={};for(const a of t.files){if(!Ho(a.path))throw new Error(`Unsafe package path: ${a.path}`);e[a.path]=a.bytes}return wn(e,{level:6})}const Xo=400;function q(t={}){var e;const a=t.exportFormat==="multi"?"multi":"single";return{exportFormat:a,exportInvisibleLayers:t.exportInvisibleLayers!==!1,exportLayouts:t.exportLayouts!==!1,initialView:t.initialView??"fit",viewerMode:t.viewerMode??"measure",expiryDays:a==="multi"?"never":t.expiryDays??"never",expiresAt:a==="multi"?null:t.expiresAt??null,password:a==="multi"?"":((e=t.password)==null?void 0:e.trim())??""}}function Go(t){const e=t.activeLayoutView,a=e.center,r=e.trCamera.zoom,n=Math.max(e.height,1),i=r*(2*Xo)/n;return{centerX:a.x,centerY:a.y,zoom:i}}const Ko="./viewer-runtime.iife.js";let ft={};function Wo(t){ft={...ft,...t}}function Jo(){return{...ft}}function Zo(t){return t!=null?String(t):ft.viewerRuntimeUrl!=null?String(ft.viewerRuntimeUrl):Ko}const qa="https://mlightcad.com/cad-viewer/docs/";let Qa=tr(qa);function qo(){return Qa}function Qo(t){Qa=tr(t)}function tr(t){const e=t.trim();return e?e.replace(/\/+$/,""):qa.replace(/\/+$/,"")}function ts(){return{minX:0,minY:0,maxX:0,maxY:0,valid:!1}}function es(t,e,a){if(e.length<3)return;const r=a[0],n=a[1];for(let i=0;i+2<e.length;i+=3){const o=_e(e[i],r),s=_e(e[i+1],n);t.valid?(o<t.minX&&(t.minX=o),o>t.maxX&&(t.maxX=o),s<t.minY&&(t.minY=s),s>t.maxY&&(t.maxY=s)):(t.minX=t.maxX=o,t.minY=t.maxY=s,t.valid=!0)}}function ea(t,e){es(t,e.positions,e.offset)}function as(t){return t.valid?{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}:null}function rs(t,e){const a=ts();for(const r of t)ea(a,r);for(const r of e)ea(a,r);return as(a)}function er(t,e){return t?e?{minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}:t:e??null}function ns(t){if(!t||t.length===0)return null;let e=null;for(const a of t)e=er(e,a.paper);return e}function is(t){return er(rs(t.lineBatches,t.meshBatches),ns(t.viewports))}function os(t,e,a){if(a)return;const r=ss(t,e);if(!(r!=null&&r.newIterator))return;const n=[];for(const i of r.newIterator()){if(!(i instanceof pr)||hr.isDefaultPaperSpaceViewport(i)||typeof i.toGiViewport!="function")continue;const o=i.toGiViewport(),s=o.box,l=o.viewBox,c=aa(s),d=aa(l);if(!c||!d)continue;const u=Number.isFinite(o.viewTwistAngle)?o.viewTwistAngle:i.viewTwistAngle;n.push(Number.isFinite(u)&&Math.abs(u)>1e-12?{paper:c,model:d,twist:u}:{paper:c,model:d})}return n.length>0?n:void 0}function aa(t){if(typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}function ss(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(!r)return;const n=typeof r.getIdAt=="function"?r.getIdAt(e):void 0;if(n)return n;if(typeof r.newIterator=="function"){for(const o of r.newIterator())if(o.objectId===e)return o}const i=r.modelSpace;if((i==null?void 0:i.objectId)===e)return i}const ra=16/9;function ls(t,e,a,r=ra){var n,i,o,s;const l=Number.isFinite(r)&&r>0?r:ra;if(a){const d=(o=(i=(n=t.tables)==null?void 0:n.viewportTable)==null?void 0:i.getActiveVportBox)==null?void 0:o.call(i,l);return na(d)}const c=(s=t.objects)==null?void 0:s.layout;if(c!=null&&c.newIterator){for(const d of c.newIterator())if(d.blockTableRecordId===e)return na(d.limits)}}function na(t){if(!t||typeof t.isEmpty=="function"&&t.isEmpty())return;const e=t.min.x,a=t.min.y,r=t.max.x,n=t.max.y;if(!(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(r)||!Number.isFinite(n)||r-e<=0||n-a<=0))return{minX:e,minY:a,maxX:r,maxY:n}}class cs{build(e,a,r={}){return this.buildSync(e,a,r)}async buildAsync(e,a,r={}){await H();const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>wt(e,p,n),s=Ke(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{wt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=oa(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=la(e,i),m=[];for(const p of sa(e,c,i))m.push(ca(e,a,p,d,r,o)),await H();return{version:J,meta:ia(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}buildSync(e,a,r){const n=r.exportInvisibleLayers!==!1,i=r.exportLayouts!==!1,o=n?void 0:p=>wt(e,p,n),s=Ke(a,{title:r.title,background:r.background}),l=[];e.layers.forEach(p=>{wt(e,p.name,n)&&l.push({name:p.name,color:p.color.RGB??16777215,visible:!p.isOff&&!p.isFrozen})});const c=oa(a),d=new Map(c.map(p=>[p.blockTableRecordId,p.name])),u=la(e,i),m=[];for(const p of sa(e,c,i))m.push(ca(e,a,p,d,r,o));return{version:J,meta:ia(s,r,m,u),layers:l,layouts:m,activeLayoutBtrId:u}}}function ia(t,e,a,r){const n=a.find(s=>s.btrId===r)??a[0],i=n?is(n):null,o=e.initialView??"fit";return{title:t.title,createdAt:new Date().toISOString(),extents:t.extents,viewExtents:i??void 0,units:t.units,grip:t.grip,background:t.background,locale:e.locale??v.currentLocale,initialView:o,viewState:o==="current"?e.viewState:void 0,viewerMode:e.viewerMode??"measure",exportLayouts:e.exportLayouts!==!1,docsBaseUrl:ds()}}function ds(){try{Qo(fr())}catch{}return qo()}function us(t){return(t.viewerMode??"measure")==="measure"}function wt(t,e,a){if(a)return!0;const r=t.layers.get(e);return r?!r.isOff&&!r.isFrozen:!0}function oa(t){var e;const a=(e=t.objects)==null?void 0:e.layout;if(!(a!=null&&a.newIterator))return[];const r=[];for(const n of a.newIterator()){const i=n.blockTableRecordId;i&&r.push({name:n.layoutName||i,tabOrder:n.tabOrder??0,blockTableRecordId:i})}return r.sort((n,i)=>n.tabOrder-i.tabOrder),r}function sa(t,e,a){if(!a)return t.modelSpaceBtrId?[t.modelSpaceBtrId]:[];const r=new Set,n=[];for(const i of e)r.has(i.blockTableRecordId)||(r.add(i.blockTableRecordId),n.push(i.blockTableRecordId));for(const i of t.layouts.keys())r.has(i)||(r.add(i),n.push(i));return n}function la(t,e){return e&&t.activeLayoutBtrId||t.modelSpaceBtrId}function ca(t,e,a,r,n,i){const o=[],s=[],l=t.layouts.get(a);if(l)for(const[,u]of l.layers){if(i&&!i(u.name))continue;const m=fi(u.internalObject);o.push(...m.lineBatches),s.push(...m.meshBatches)}const c=a===t.modelSpaceBtrId,d=ls(e,a,c,n.canvasAspectRatio);return{btrId:a,name:r.get(a)??ms(e,a),isModelSpace:c,lineBatches:o,meshBatches:s,osnap:us(n)?Gi(e,a,{includeLayer:i}):void 0,viewports:os(e,a,c),...d?{savedView:d}:{}}}function ms(t,e){var a;const r=(a=t.tables)==null?void 0:a.blockTable;if(r!=null&&r.newIterator){for(const n of r.newIterator())if(n.objectId===e)return n.name}return e}class ps{constructor(e={}){this.options=e,this._snapshotBuilder=new cs}async prepareAcTrView2dForHtmlExport(e,a={}){if(!e||!("cadScene"in e)||!e.cadScene)throw new Error("CAD scene is not available. Open a drawing before exporting to HTML.");if(!(e instanceof ir))throw new Error("HTML export requires a 2D CAD view. Open a drawing before exporting.");const r=q(a),n={includeInvisibleLayers:r.exportInvisibleLayers,includeLayouts:r.exportLayouts};return await e.ensureEntitiesConvertedForExport(n),await H(),e}async convert(e,a={},r){const n=nt.instance,i=q(a);await n.withBusyIndicator(async()=>{await H();const o=n.curDocument,s=await this.prepareAcTrView2dForHtmlExport(r??n.curView,i),l=e||o.fileName||o.docTitle,c=or(l),d=await this._snapshotBuilder.buildAsync(s.cadScene,o.database,{title:c,background:s.backgroundColor,exportInvisibleLayers:i.exportInvisibleLayers,exportLayouts:i.exportLayouts,initialView:i.initialView,viewerMode:i.viewerMode,viewState:i.initialView==="current"&&(i.exportLayouts||s.activeLayoutBtrId===s.modelSpaceBtrId)?Go(s):void 0,canvasAspectRatio:s.width/Math.max(s.height,1)});await H();const u=await this.loadViewerRuntime();if(await H(),i.exportFormat==="multi"){const g=Uo(d,{viewerRuntime:u}),h=Yo(g);await H(),this.downloadBytes(h,ye(l,"zip"),"application/zip");return}const m=wo(i.expiryDays,Date.now(),i.expiresAt),p=await this.packSelfContainedHtml(d,u,{expiresAt:m,password:i.password||void 0});await H(),this.downloadHtml(p,ye(l,"html"))})}async packSnapshot(e,a){await nt.instance.withBusyIndicator(async()=>{await H();const r=await this.loadViewerRuntime();await H();const n=await this.packSelfContainedHtml(e,r,{expiresAt:null});await H(),this.downloadHtml(n,a)})}async packSelfContainedHtml(e,a,r){if(To(e))return $o(e,{title:e.meta.title,viewerRuntime:a,expiresAt:r.expiresAt,password:r.password});const n=await vo(Fa(e),{expiresAt:r.expiresAt,password:r.password});return mo(e,{title:e.meta.title,viewerRuntime:a,encoded:n.encoded,accessManifest:n.manifest})}async loadViewerRuntime(){const e=Zo(this.options.viewerRuntimeUrl),a=await fetch(e);if(!a.ok)throw new Error(`Failed to load HTML viewer runtime from "${e}" (${a.status}). Install @mlightcad/cad-html-plugin, copy viewer-runtime.iife.js to your app assets, and set viewerRuntimeUrl on registerLazyHtmlPlugin / createHtmlPlugin / AcApHtmlConvertor.`);return a.text()}downloadHtml(e,a){this.downloadBytes(new TextEncoder().encode(e),a,"text/html;charset=utf-8")}downloadBytes(e,a,r){const n=new Uint8Array(e.byteLength);n.set(e);const i=new Blob([n],{type:r}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=a,document.body.appendChild(s),s.click(),document.body.removeChild(s),window.setTimeout(()=>URL.revokeObjectURL(o),6e4)}}class hs extends nr{constructor(e={}){super(),this.pluginOptions=e}async execute(e){const a=await this.promptOptions();a&&await new ps(this.pluginOptions).convert(e.doc.fileName||e.doc.docTitle,a,e.view)}async promptOptions(){const e=q(),a=await this.promptExportFormat();if(a===void 0)return;const r=await this.promptYesNo("jig.chtml.exportInvisibleLayers",e.exportInvisibleLayers);if(r===void 0)return;const n=await this.promptYesNo("jig.chtml.exportLayouts",e.exportLayouts);if(n===void 0)return;const i=await this.promptInitialView();if(i===void 0)return;const o=await this.promptViewerMode();if(o!==void 0)return q({exportFormat:a,exportInvisibleLayers:r,exportLayouts:n,initialView:i,viewerMode:o})}async promptExportFormat(){const e=q(),a=new bt(v.t("jig.chtml.exportFormat"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.single.display"),v.t("jig.chtml.keywords.single.global"),v.t("jig.chtml.keywords.single.local")),n=a.keywords.add(v.t("jig.chtml.keywords.multi.display"),v.t("jig.chtml.keywords.multi.global"),v.t("jig.chtml.keywords.multi.local"));a.keywords.default=e.exportFormat==="multi"?n:r;const i=await nt.instance.editor.getKeywords(a);if(i.status!==T.Cancel){if(i.status===T.None)return e.exportFormat;if(i.status===T.OK||i.status===T.Keyword)return i.stringResult?i.stringResult==="Multi"?"multi":"single":e.exportFormat}}async promptYesNo(e,a){const r=new bt(v.t(e));r.allowNone=!0;const n=r.keywords.add(v.t("jig.chtml.keywords.yes.display"),v.t("jig.chtml.keywords.yes.global"),v.t("jig.chtml.keywords.yes.local")),i=r.keywords.add(v.t("jig.chtml.keywords.no.display"),v.t("jig.chtml.keywords.no.global"),v.t("jig.chtml.keywords.no.local"));r.keywords.default=a?n:i;const o=await nt.instance.editor.getKeywords(r);if(o.status!==T.Cancel){if(o.status===T.None)return a;if(o.status===T.OK||o.status===T.Keyword)return o.stringResult?o.stringResult==="Yes":a}}async promptInitialView(){const e=q(),a=new bt(v.t("jig.chtml.initialView"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.extents.display"),v.t("jig.chtml.keywords.extents.global"),v.t("jig.chtml.keywords.extents.local")),n=a.keywords.add(v.t("jig.chtml.keywords.current.display"),v.t("jig.chtml.keywords.current.global"),v.t("jig.chtml.keywords.current.local"));a.keywords.default=e.initialView==="current"?n:r;const i=await nt.instance.editor.getKeywords(a);if(i.status!==T.Cancel){if(i.status===T.None)return e.initialView;if(i.status===T.OK||i.status===T.Keyword)return i.stringResult?i.stringResult==="Current"?"current":"fit":e.initialView}}async promptViewerMode(){const e=q(),a=new bt(v.t("jig.chtml.viewerMode"));a.allowNone=!0;const r=a.keywords.add(v.t("jig.chtml.keywords.view.display"),v.t("jig.chtml.keywords.view.global"),v.t("jig.chtml.keywords.view.local")),n=a.keywords.add(v.t("jig.chtml.keywords.measure.display"),v.t("jig.chtml.keywords.measure.global"),v.t("jig.chtml.keywords.measure.local"));a.keywords.default=e.viewerMode==="view"?r:n;const i=await nt.instance.editor.getKeywords(a);if(i.status!==T.Cancel){if(i.status===T.None)return e.viewerMode;if(i.status===T.OK||i.status===T.Keyword)return i.stringResult?i.stringResult==="View"?"view":"measure":e.viewerMode}}}const fs="1.7.4",gs={version:fs};class bs{constructor(e={}){this.options=e,this.name="HtmlPlugin",this.version=gs.version,this.description="HTML export (-chtml) command",this.registeredCommands=[]}onLoad(e,a){const r=rr.SYSTEMT_COMMAND_GROUP_NAME,n=new hs(this.options);a.addCommand(r,"-chtml","-chtml",n),this.registeredCommands.push({group:r,name:"-chtml"}),a.lookupGlobalCmd("chtml")||(a.addCommand(r,"chtml","chtml",n),this.registeredCommands.push({group:r,name:"chtml"}))}onUnload(e,a){for(const r of this.registeredCommands)a.removeCmd(r.group,r.name);this.registeredCommands=[]}}async function xs(t={}){return t.viewerRuntimeUrl!=null&&Wo(t),new bs(Jo())}export{Ji as ACEC_CHUNK_MAGIC,kn as ACEO_OSNAP_MAGIC,An as ACEO_OSNAP_VERSION,to as ACEX_DEFAULT_CHUNK_MAX_BYTES,Ct as ACEX_DEFAULT_MANIFEST_FILE,no as ACEX_DEFAULT_MANIFEST_HREF,eo as ACEX_DEFAULT_OSNAP_CHUNK_MAX_BYTES,Oo as ACEX_EMBEDDED_CHUNK_ENCRYPTED_MIME,Wa as ACEX_EMBEDDED_CHUNK_HREF_ATTR,Qe as ACEX_EMBEDDED_CHUNK_MAX_BYTES,No as ACEX_EMBEDDED_CHUNK_MIME,ao as ACEX_EMBEDDED_CHUNK_THRESHOLD_BYTES,ro as ACEX_EMBEDDED_OSNAP_CHUNK_MAX_BYTES,St as ACEX_MAX_GEOMETRY_BATCH_BYTES,Qi as ACEX_PACKAGE_VERSION,xn as ACEX_SNAPSHOT_COMPRESSION,J as ACEX_SNAPSHOT_VERSION,hs as AcApExportHtmlCmd,ps as AcApHtmlConvertor,cs as AcApHtmlSnapshotBuilder,Ko as DEFAULT_HTML_VIEWER_RUNTIME_URL,ks as HTML_PLUGIN_NAME,As as HTML_PLUGIN_TRIGGERS,he as acExHtmlBytesToBase64,zt as buildAcExHtmlAccessManifest,Uo as buildAcExPackage,Ka as buildAcExPackageData,Gi as buildOsnapCatalog,Ke as buildViewerMetadata,Go as captureAcApHtmlViewState,fi as collectBatchesFromObject3D,ee as compressSnapshotBinary,Wo as configureHtmlPlugin,ja as createAcExHtmlAccessKey,xs as createHtmlPlugin,Zi as encodeChunkBinary,qi as encodeChunkGzip,Ma as encodeOsnapCatalogBinary,In as encodeOsnapCatalogGzip,Fa as encodeSnapshot,Dn as encodeSnapshotBinary,pe as encryptAcExHtmlBytes,xo as encryptAcExHtmlSnapshotPayload,Ro as estimateAcExSnapshotGeometryBytes,za as estimateOsnapPrimitiveBytes,oi as exportActiveBatchedLine2Slice,oe as exportActiveBatchedSlice,He as exportBufferGeometrySlice,Jo as getHtmlPluginOptions,oa as listDatabaseLayouts,$a as needsAcExHtmlAccessControl,mo as packHtml,$o as packHtmlEmbeddedPackage,po as packHtmlPackage,vo as protectAcExHtmlEncodedSnapshot,wo as resolveAcApHtmlExpiresAt,q as resolveAcApHtmlExportOptions,ce as resolveAcExHtmlLocale,Zo as resolveViewerRuntimeUrl,To as shouldEmbedAcExChunks,$n as snapshotMimeType,Bo as splitLayoutIntoSlices,En as splitOsnapPrimitives,Yo as zipAcExPackageFiles};