UNPKG

@wayrisignals/kicad-webview

Version:

Interactive KiCad schematic, PCB and 3D viewer for the web, with Gerber, Excellon, linked views and offline HTML exports

3 lines (2 loc) • 8.66 kB
/*! KiCad WebView 1.2.1 | Copyright (c) 2026 wayri | SPDX-License-Identifier: MPL-2.0 | Source: https://github.com/wayri/kicad-webview/tree/v1.2.1 | Keep LICENSE and THIRD-PARTY-NOTICES.md; bundled dependencies retain their licenses. */ import{b as Wt}from"./chunk-TZWR7E27.js";var Ct=Wt((ct,it)=>{(function(G){typeof it<"u"&&typeof ct=="object"?it.exports=G():typeof define<"u"&&define.amd?define(["fzstd",G]):(typeof self<"u"?self:this).fzstd=G()})(function(){var G={},yt=ArrayBuffer,w=Uint8Array,K=Uint16Array,pt=Int16Array,Pt=Uint32Array,N=Int32Array,D=function(t,e,s){if(w.prototype.slice)return w.prototype.slice.call(t,e,s);(e==null||e<0)&&(e=0),(s==null||s>t.length)&&(s=t.length);var a=new w(s-e);return a.set(t.subarray(e,s)),a},X=function(t,e,s,a){if(w.prototype.fill)return w.prototype.fill.call(t,e,s,a);for((s==null||s<0)&&(s=0),(a==null||a>t.length)&&(a=t.length);s<a;++s)t[s]=e;return t},at=function(t,e,s,a){if(w.prototype.copyWithin)return w.prototype.copyWithin.call(t,e,s,a);for((s==null||s<0)&&(s=0),(a==null||a>t.length)&&(a=t.length);s<a;)t[e++]=t[s++]};G.ZstdErrorCode={InvalidData:0,WindowSizeTooLarge:1,InvalidBlockType:2,FSEAccuracyTooHigh:3,DistanceTooFarBack:4,UnexpectedEOF:5};var wt=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],v=function(t,e,s){var a=Error(e||wt[t]);if(a.code=t,Error.captureStackTrace&&Error.captureStackTrace(a,v),!s)throw a;return a},nt=function(t,e,s){for(var a=0,i=0;a<s;++a)i|=t[e++]<<(a<<3);return i},dt=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},ot=function(t,e){var s=t[0]|t[1]<<8|t[2]<<16;if(s==3126568&&t[3]==253){var a=t[4],i=a>>5&1,o=a>>2&1,n=3&a,r=a>>6;8&a&&v(0);var l=6-i,c=n==3?4:n,y=nt(t,l,c),g=r?1<<r:i,p=nt(t,l+=c,g)+(r==1&&256),x=p;if(!i){var U=1<<10+(t[5]>>3);x=U+(U>>3)*(7&t[5])}x>2145386496&&v(1);var u=new w((e==1?p||x:e?0:x)+12);return u[0]=1,u[4]=4,u[8]=8,{b:l+g,y:0,l:0,d:y,w:e&&e!=1?e:u.subarray(12),e:x,o:new N(u.buffer,0,3),u:p,c:o,m:Math.min(131072,x)}}if((s>>4|t[3]<<20)==25481893)return dt(t,4)+8;v(0)},H=function(t){for(var e=0;1<<e<=t;++e);return e-1},Y=function(t,e,s){var a=4+(e<<3),i=5+(15&t[e]);i>s&&v(3);for(var o=1<<i,n=o,r=-1,l=-1,c=-1,y=o,g=new yt(512+(o<<2)),p=new pt(g,0,256),x=new K(g,0,256),U=new K(g,512,o),u=512+(o<<1),z=new w(g,u,o),k=new w(g,u+o);r<255&&n>0;){var S=H(n+1),E=a>>3,_=(1<<S+1)-1,d=(t[E]|t[E+1]<<8|t[E+2]<<16)>>(7&a)&_,f=(1<<S)-1,C=_-n-1,W=d&f;if(W<C?(a+=S,d=W):(a+=S+1,d>f&&(d-=C)),p[++r]=--d,d==-1?(n+=d,z[--y]=r):n-=d,!d)do{var q=a>>3;l=(t[q]|t[q+1]<<8)>>(7&a)&3,a+=2,r+=l}while(l==3)}(r>255||n)&&v(0);for(var T=0,P=(o>>1)+(o>>3)+3,Z=o-1,m=0;m<=r;++m){var b=p[m];if(b<1)x[m]=-b;else for(c=0;c<b;++c){z[T]=m;do T=T+P&Z;while(T>=y)}}for(T&&v(0),c=0;c<o;++c){var h=x[z[c]]++,A=k[c]=i-H(h);U[c]=(h<<A)-o}return[a+7>>3,{b:i,s:z,n:k,t:U}]},gt=function(t,e){var s=0,a=-1,i=new w(292),o=t[e],n=i.subarray(0,256),r=i.subarray(256,268),l=new K(i.buffer,268);if(o<128){var c=Y(t,e+1,6),y=c[1],g=c[0]<<3,p=t[e+=o];p||v(0);for(var x=0,U=0,u=y.b,z=u,k=(++e<<3)-8+H(p);!((k-=u)<g);){var S=k>>3;if(n[++a]=y.s[x+=(t[S]|t[S+1]<<8)>>(7&k)&(1<<u)-1],(k-=z)<g)break;n[++a]=y.s[U+=(t[S=k>>3]|t[S+1]<<8)>>(7&k)&(1<<z)-1],u=y.n[x],x=y.t[x],z=y.n[U],U=y.t[U]}++a>255&&v(0)}else{for(a=o-127;s<a;s+=2){var E=t[++e];n[s]=E>>4,n[s+1]=15&E}++e}var _=0;for(s=0;s<a;++s)(W=n[s])>11&&v(0),_+=W&&1<<W-1;var d=H(_)+1,f=1<<d,C=f-_;for(C&C-1&&v(0),n[a++]=H(C)+1,s=0;s<a;++s){var W;++r[n[s]=(W=n[s])&&d+1-W]}var q=new w(f<<1),T=q.subarray(0,f),P=q.subarray(f);for(l[d]=0,s=d;s>0;--s){var Z=l[s];X(P,s,Z,l[s-1]=Z+r[s]*(1<<d-s))}for(l[0]!=f&&v(0),s=0;s<a;++s){var m=n[s];if(m){var b=l[m];X(T,s,b,l[m]=b+(1<<d-m))}}return[e,{n:P,b:d,s:T}]},zt=Y(new w([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],xt=Y(new w([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Et=Y(new w([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],ft=function(t,e){for(var s=t.length,a=new N(s),i=0;i<s;++i)a[i]=e,e+=1<<t[i];return a},L=new w(new N([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Tt=ft(L,0),R=new w(new N([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Ut=ft(R,3),$=function(t,e,s){var a=t.length,i=e.length,o=t[a-1],n=(1<<s.b)-1,r=-s.b;o||v(0);for(var l=0,c=s.b,y=(a<<3)-8+H(o)-c,g=-1;y>r&&g<i;){var p=y>>3;e[++g]=s.s[l=(l<<c|(t[p]|t[p+1]<<8|t[p+2]<<16)>>(7&y))&n],y-=c=s.n[l]}y==r&&g+1==i||v(0)},kt=function(t,e,s){var a=6,i=e.length+3>>2,o=i<<1,n=i+o;$(t.subarray(a,a+=t[0]|t[1]<<8),e.subarray(0,i),s),$(t.subarray(a,a+=t[2]|t[3]<<8),e.subarray(i,o),s),$(t.subarray(a,a+=t[4]|t[5]<<8),e.subarray(o,n),s),$(t.subarray(a),e.subarray(n),s)},ut=function(t,e,s){var a,i=e.b,o=t[i],n=o>>1&3;e.l=1&o;var r=o>>3|t[i+1]<<5|t[i+2]<<13,l=(i+=3)+r;if(n==1)return i>=t.length?void 0:(e.b=i+1,s?(X(s,t[i],e.y,e.y+=r),s):X(new w(r),t[i]));if(!(l>t.length)){if(n==0)return e.b=l,s?(s.set(t.subarray(i,l),e.y),e.y+=r,s):D(t,i,l);if(n==2){var c=t[i],y=3&c,g=c>>2&3,p=c>>4,x=0,U=0;y<2?1&g?p|=t[++i]<<4|(2&g&&t[++i]<<12):p=c>>3:(U=g,g<2?(p|=(63&t[++i])<<4,x=t[i]>>6|t[++i]<<2):g==2?(p|=t[++i]<<4|(3&t[++i])<<12,x=t[i]>>2|t[++i]<<6):(p|=t[++i]<<4|(63&t[++i])<<12,x=t[i]>>6|t[++i]<<2|t[++i]<<10)),++i;var u=s?s.subarray(e.y,e.y+e.m):new w(e.m),z=u.length-p;if(y==0)u.set(t.subarray(i,i+=p),z);else if(y==1)X(u,t[i++],z);else{var k=e.h;if(y==2){var S=gt(t,i);x+=i-(i=S[0]),e.h=k=S[1]}else k||v(0);(U?kt:$)(t.subarray(i,i+=x),u.subarray(z),k)}var E=t[i++];if(E){E==255?E=32512+(t[i++]|t[i++]<<8):E>127&&(E=E-128<<8|t[i++]);var _=t[i++];3&_&&v(0);for(var d=[xt,Et,zt],f=2;f>-1;--f){var C=_>>2+(f<<1)&3;if(C==1){var W=new w([0,0,t[i++]]);d[f]={s:W.subarray(2,3),n:W.subarray(0,1),t:new K(W.buffer,0,1),b:0}}else C==2?(i=(a=Y(t,i,9-(1&f)))[0],d[f]=a[1]):C==3&&(e.t||v(0),d[f]=e.t[f])}var q=e.t=d,T=q[0],P=q[1],Z=q[2],m=t[l-1];m||v(0);var b=(l<<3)-8+H(m)-Z.b,h=b>>3,A=0,O=(t[h]|t[h+1]<<8)>>(7&b)&(1<<Z.b)-1,M=(t[h=(b-=P.b)>>3]|t[h+1]<<8)>>(7&b)&(1<<P.b)-1,j=(t[h=(b-=T.b)>>3]|t[h+1]<<8)>>(7&b)&(1<<T.b)-1;for(++E;--E;){var et=Z.s[O],rt=Z.n[O],st=T.s[j],ht=T.n[j],lt=P.s[M],vt=P.n[M],bt=1<<lt,B=bt+((t[h=(b-=lt)>>3]|t[h+1]<<8|t[h+2]<<16|t[h+3]<<24)>>>(7&b)&bt-1);h=(b-=R[st])>>3;var F=Ut[st]+((t[h]|t[h+1]<<8|t[h+2]<<16)>>(7&b)&(1<<R[st])-1);h=(b-=L[et])>>3;var V=Tt[et]+((t[h]|t[h+1]<<8|t[h+2]<<16)>>(7&b)&(1<<L[et])-1);if(h=(b-=rt)>>3,O=Z.t[O]+((t[h]|t[h+1]<<8)>>(7&b)&(1<<rt)-1),h=(b-=ht)>>3,j=T.t[j]+((t[h]|t[h+1]<<8)>>(7&b)&(1<<ht)-1),h=(b-=vt)>>3,M=P.t[M]+((t[h]|t[h+1]<<8)>>(7&b)&(1<<vt)-1),B>3)e.o[2]=e.o[1],e.o[1]=e.o[0],e.o[0]=B-=3;else{var Q=B-(V!=0);Q?(B=Q==3?e.o[0]-1:e.o[Q],Q>1&&(e.o[2]=e.o[1]),e.o[1]=e.o[0],e.o[0]=B):B=e.o[0]}for(f=0;f<V;++f)u[A+f]=u[z+f];z+=V;var I=(A+=V)-B;if(I<0){var J=-I,St=e.e+I;for(J>F&&(J=F),f=0;f<J;++f)u[A+f]=e.w[St+f];A+=J,F-=J,I=0}for(f=0;f<F;++f)u[A+f]=u[I+f];A+=F}if(A!=z)for(;z<u.length;)u[A++]=u[z++];else A=u.length;s?e.y+=A:u=D(u,0,A)}else if(s){if(e.y+=p,z)for(f=0;f<p;++f)u[f]=u[z+f]}else z&&(u=D(u,z));return e.b=l,u}v(2)}},tt=function(t,e){if(t.length==1)return t[0];for(var s=new w(e),a=0,i=0;a<t.length;++a){var o=t[a];s.set(o,i),i+=o.length}return s};function mt(t,e){for(var s=[],a=+!e,i=0,o=0;t.length;){var n=ot(t,a||e);if(typeof n=="object"){for(a?(e=null,n.w.length==n.u&&(s.push(e=n.w),o+=n.u)):(s.push(e),n.e=0);!n.l;){var r=ut(t,n,e);r||v(5),e?n.e=n.y:(s.push(r),o+=r.length,at(n.w,0,r.length),n.w.set(r,n.w.length-r.length))}i=n.b+4*n.c}else i=n;t=t.subarray(i)}return tt(s,o)}G.decompress=mt;var At=(function(){function t(e){this.ondata=e,this.c=[],this.l=0,this.z=0}return t.prototype.push=function(e,s){if(typeof this.s=="number"){var a=Math.min(e.length,this.s);e=e.subarray(a),this.s-=a}var i=e.length+this.l;if(!this.s){if(s){if(!i)return void this.ondata(new w(0),!0);i<5&&v(5)}else if(i<18)return this.c.push(e),void(this.l=i);if(this.l&&(this.c.push(e),e=tt(this.c,i),this.c=[],this.l=0),typeof(this.s=ot(e))=="number")return this.push(e,s)}if(typeof this.s!="number"){if(i<(this.z||3))return s&&v(5),this.c.push(e),void(this.l=i);if(this.l&&(this.c.push(e),e=tt(this.c,i),this.c=[],this.l=0),!this.z&&i<(this.z=2&e[this.s.b]?4:3+(e[this.s.b]>>3|e[this.s.b+1]<<5|e[this.s.b+2]<<13)))return s&&v(5),this.c.push(e),void(this.l=i);for(this.z=0;;){var o=ut(e,this.s);if(!o){s&&v(5);var n=e.subarray(this.s.b);return this.s.b=0,this.c.push(n),void(this.l+=n.length)}if(this.ondata(o,!1),at(this.s.w,0,o.length),this.s.w.set(o,this.s.w.length-o.length),this.s.l){var r=e.subarray(this.s.b);return this.s=4*this.s.c,void this.push(r,s)}}}else s&&v(5)},t})();return G.Decompress=At,G})});export{Ct as a};