diff --git a/docs/assets/js/next2d.js b/docs/assets/js/next2d.js index 5a04e0ce..09b8e8ca 100644 --- a/docs/assets/js/next2d.js +++ b/docs/assets/js/next2d.js @@ -1,2358 +1,20 @@ -const on="__next2d__",Ze=Math.min(2,window.devicePixelRatio),Vt=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},Er=document.createElement("canvas");Er.width=Er.height=1;const Tr=Er.getContext("2d");let ci=null;const _s=e=>{ci=e};let li=null;const Ds=e=>{li=e},ui=()=>li,vt=()=>ci,ft=new Float32Array([1,0,0,1,0,0]),gt=new Float32Array([1,0,0,1,0,0]),ie={x:0,y:0,pointer:"",hit:null};let hi=null;const Cn=e=>{hi=e},fi=()=>hi,Ls=(e,t=1)=>{let r="";r+="-webkit-tap-highlight-color: rgba(0,0,0,0);",r+="backface-visibility: hidden;",r+="touch-action: none;",r+="user-select: none;",r+="-webkit-user-select: none;",r+="-webkit-touch-callout: none;",t>1&&(r+=`transform: scale(${1/t});`),e.width=1,e.height=1,e.setAttribute("style",r)},di=`(function(){"use strict";let ut=2048;const Xc=t=>{ut=Math.max(2048,t/2)};let bs=4;const Yc=t=>{bs=t};let p;const Wc=t=>{p=t};let O;const jc=t=>{O=t};let Pn=!1;const It=()=>{Pn||(Pn=!0,p.enable(p.SCISSOR_TEST))},yt=()=>{Pn&&(Pn=!1,p.disable(p.SCISSOR_TEST))};let An=!1;const Yr=()=>{An||(An=!0,p.enable(p.STENCIL_TEST))},Wr=()=>{An&&(An=!1,p.disable(p.STENCIL_TEST))},jr=(t,e,r,n=null)=>{const s=+t;return isNaN(s)&&n!==null?n:Math.min(Math.max(e,isNaN(s)?0:s),r)},li=[],Hr=(...t)=>{const e=li.pop()||[];return t.length&&e.push(...t),e},ui=(t=null)=>{t&&(t.length&&(t.length=0),li.push(t))},Fn=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),fi=[],hi=(t=0,e=0,r=0,n=0)=>{const s=fi.pop()||new Float32Array(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s},di=t=>{fi.push(t)},pi=[],xs=(t=0,e=0,r=0,n=0,s=0,o=0,i=0,l=0,c=0)=>{const u=pi.pop()||new Float32Array(9);return u[0]=t,u[1]=e,u[2]=r,u[3]=n,u[4]=s,u[5]=o,u[6]=i,u[7]=l,u[8]=c,u},Hc=t=>{pi.push(t)},mi=[],dr=(t=0,e=0,r=0,n=0,s=0,o=0)=>{const i=mi.pop()||new Float32Array(6);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i[4]=s,i[5]=o,i},Kr=t=>{mi.push(t)},ys=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),r=t[3]*t[7]-t[4]*t[6],n=t[1]*t[6]-t[0]*t[7];return xs(t[4]*e,0-t[1]*e,0,0-t[3]*e,t[0]*e,0,r*e,n*e,1)};let pt=0,mt=0;const Kc=(t,e)=>{pt=t,mt=e},qc=t=>{const e=-819.2*t[0]-819.2*t[2]+t[4],r=819.2*t[0]-819.2*t[2]+t[4],n=-819.2*t[0]+819.2*t[2]+t[4],s=-819.2*t[1]-819.2*t[3]+t[5],o=819.2*t[1]-819.2*t[3]+t[5],i=-819.2*t[1]+819.2*t[3]+t[5];let l=n-e,c=i-s;const u=Math.sqrt(l*l+c*c);u?(l=l/u,c=c/u):(l=0,c=0);const a=(r-e)*l+(o-s)*c;return hi(e+a*l,s+a*c,r,o)};let vt=1;const Qc=t=>{vt=t},Zc=(t,e)=>{const r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],l=t[5],c=e[0],u=e[1],a=e[2],h=e[3],d=e[4],g=e[5];return dr(r*c+s*u,n*c+o*u,r*a+s*h,n*a+o*h,r*d+s*g+i,n*d+o*g+l)},Jc=()=>typeof crypto?.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),me=Hr(),Kt=Hr(),pr=(t=!1)=>{const e=t?6:9;me.length>=e&&Kt.push(me.slice(0)),me.length=0;const r=[];for(let n=0;n=e&&r.push(s)}return Kt.length=0,r},el=()=>{for(me.length=0;Kt.length;)ui(Kt.pop())},mr=(t,e,r)=>{me.push(t,e,r)},qr=(t,e)=>{const r=me.length,n=+me[r-3],s=+me[r-2];return t===n&&e===s},tl=()=>{if(me.length<3){me.length=0;return}Kt.push(me.slice(0)),me.length=0},wn=(t,e)=>{if(!me.length){mr(t,e,!1);return}qr(t,e)||(tl(),mr(t,e,!1))},rl=(t,e)=>{me.length||wn(t,e),!qr(t,e)&&mr(t,e,!1)},gi=(t,e,r,n)=>{me.length||wn(0,0),!qr(r,n)&&(mr(t,e,!0),mr(r,n,!1))},nl=()=>{if(me.length<7)return;const t=+me[0],e=+me[1];qr(t,e)||mr(t,e,!1)};let Re=new Float32Array(64),bi=0;const vs=.5,Ms=2,sl=8,ol=(t,e,r,n,s,o,i,l)=>{const c=3*r-2*t-i,u=3*n-2*e-l,a=3*s-2*i-t,h=3*o-2*l-e;return Math.max(c*c+u*u,a*a+h*h)},il=(t,e,r,n,s,o,i,l)=>{const c=ol(t,e,r,n,s,o,i,l);if(c{Re.length{bi=t},Ss=[];let $s=0;const xi=()=>{$s=0},Se=()=>($s>=Ss.length&&Ss.push(new Float32Array(8)),Ss[$s++]),ft=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=1-c,d=h*t+c*r,g=h*e+c*n,m=h*r+c*s,f=h*n+c*o,b=h*s+c*i,x=h*o+c*l,y=h*d+c*m,P=h*g+c*f,S=h*m+c*b,M=h*f+c*x,$=h*y+c*S,T=h*P+c*M;u[0]=t,u[1]=e,u[2]=d,u[3]=g,u[4]=y,u[5]=P,u[6]=$,u[7]=T,a[0]=$,a[1]=T,a[2]=S,a[3]=M,a[4]=b,a[5]=x,a[6]=i,a[7]=l},Ye=(t,e,r,n,s,o,i,l,c,u)=>{const a=(3*r+3*s-t-i)*.25,h=(3*n+3*o-e-l)*.25;c[u]=a,c[u+1]=h,c[u+2]=i,c[u+3]=l},Mt=new Float32Array(8),St=new Float32Array(8),ll=(t,e,r,n,s,o,i,l)=>{const c=il(t,e,r,n,s,o,i,l),u=c*4;al(u);let a=0;if(c<=2)ft(t,e,r,n,s,o,i,l,.5,Mt,St),Ye(Mt[0],Mt[1],Mt[2],Mt[3],Mt[4],Mt[5],Mt[6],Mt[7],Re,a),a+=4,Ye(St[0],St[1],St[2],St[3],St[4],St[5],St[6],St[7],Re,a),a+=4;else if(c<=4){xi();const h=Se(),d=Se();ft(t,e,r,n,s,o,i,l,.5,h,d);const g=Se(),m=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,g,m),ft(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,f,b),Ye(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],Re,a),a+=4,Ye(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],Re,a),a+=4,Ye(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],Re,a),a+=4,Ye(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],Re,a),a+=4}else{xi();const h=Se(),d=Se();ft(t,e,r,n,s,o,i,l,.5,h,d);const g=Se(),m=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,g,m),ft(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,f,b);const x=Se(),y=Se(),P=Se(),S=Se(),M=Se(),$=Se(),T=Se(),w=Se();ft(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],.5,x,y),ft(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],.5,P,S),ft(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],.5,M,$),ft(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],.5,T,w),Ye(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],Re,a),a+=4,Ye(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],Re,a),a+=4,Ye(P[0],P[1],P[2],P[3],P[4],P[5],P[6],P[7],Re,a),a+=4,Ye(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],Re,a),a+=4,Ye(M[0],M[1],M[2],M[3],M[4],M[5],M[6],M[7],Re,a),a+=4,Ye($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],Re,a),a+=4,Ye(T[0],T[1],T[2],T[3],T[4],T[5],T[6],T[7],Re,a),a+=4,Ye(w[0],w[1],w[2],w[3],w[4],w[5],w[6],w[7],Re,a),a+=4}return cl(a/4),{buffer:Re,count:bi}},Qr=(t,e,r,n,s,o)=>{if(me.length||wn(0,0),qr(s,o))return;const i=me.length,l=+me[i-3],c=+me[i-2],u=ll(l,c,t,e,r,n,s,o),a=u.buffer,h=u.count;for(let d=0;d{const n=r,s=r*.5522847498307936;Qr(t+n,e+s,t+s,e+n,t,e+n),Qr(t-s,e+n,t-n,e+s,t-n,e),Qr(t-n,e-s,t-s,e-n,t,e-n),Qr(t+s,e-n,t+n,e-s,t+n,e)},fl=(t,e,r,n,s)=>{t.$clearColorR=jr(e,0,1,0),t.$clearColorG=jr(r,0,1,0),t.$clearColorB=jr(n,0,1,0),t.$clearColorA=jr(s,0,1,0)},hl=(t,e,r,n)=>{p.clearColor(t,e,r,n),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),p.clearColor(0,0,0,0)},$t=[],yi=t=>{let e=-1,r=$t.length;for(;Math.abs(r-e)>1;){const n=Math.floor((r+e)/2);t<=$t[n].area?r=n:e=n}return r},dl=t=>{if($t.indexOf(t)>-1)return;const e=yi(t.area);t.dirty=!0,$t.splice(e,0,t)},ae=t=>{p.deleteTexture(t.resource)},et=[],pl=t=>{if(!(et.indexOf(t)>-1)){if(et.length>10){p.deleteRenderbuffer(t.resource);return}t.dirty=!0,et.push(t)}},Ts=[];let Tt;const ml=t=>{Tt=t.createFramebuffer()};let vi=null;const gl=t=>{vi=t.createFramebuffer()};let On=null;const bl=(t,e)=>{On=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,On),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.resource,0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,On)};let Bs=null;const Mi=t=>{Bs=t};let Ps=!1;const As=t=>{Ps=t};let Fs=null,Zr=null,Si=null,$i=null;const xl=t=>{Zr=t.createFramebuffer(),Fs=t.createFramebuffer(),Si=t.createFramebuffer(),$i=t.createBuffer(),t.bindBuffer(t.PIXEL_PACK_BUFFER,$i)},be=(t,e=!0)=>{t.msaa?(dl(t.color),t.color=null,t.stencil=null):(e&&ae(t.texture),t.texture=null,pl(t.stencil),t.stencil=null),Ts.push(t)};let yl=0;const vl=()=>({id:yl++,width:0,height:0,clipLevel:0,msaa:!1,mask:!1,color:null,texture:null,stencil:null}),Ml=()=>{const t={id:0,resource:p.createRenderbuffer(),width:0,height:0,area:0,dirty:!1};return{resource:p.createRenderbuffer(),stencil:t,width:0,height:0,area:0,dirty:!1}},Sl=t=>{if(!$t.length)return Ml();const e=yi(t);if(e<$t.length){const n=$t[e];return $t.splice(e,1),n}const r=$t.shift();if(!r)throw new Error("the color buffer is void.");return r},$l=(t,e)=>{t=Math.max(256,Fn(t)),e=Math.max(256,Fn(e));const r=Sl(t*e);return(r.width({id:Tl++,resource:p.createRenderbuffer(),width:0,height:0,area:0,dirty:!1}),Pl=(t,e)=>{if(!et.length)return Bl();let r=-1,n=1/0;for(let s=0;s=t&&o.height>=e&&o.area{const r=Pl(t,e);return(r.width!==t||r.height!==e)&&(r.width=t,r.height=e,r.area=t*e,r.dirty=!1,p.bindRenderbuffer(p.RENDERBUFFER,r.resource),p.renderbufferStorage(p.RENDERBUFFER,p.STENCIL_INDEX8,t,e)),r};let Fl=0;const Ti=(t,e)=>({id:Fl++,resource:p.createTexture(),width:t,height:e,area:t*e,smooth:!1});let gr=-1;const Bi=t=>{gr=t},ws=[null,null,null],wl=(t,e=!1)=>{gr!==p.TEXTURE0&&(Bi(p.TEXTURE0),p.activeTexture(p.TEXTURE0)),ws[0]=t,p.bindTexture(p.TEXTURE_2D,t.resource),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,e?p.LINEAR:p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,e?p.LINEAR:p.NEAREST),p.texStorage2D(p.TEXTURE_2D,1,p.RGBA8,t.width,t.height)},Jr=(t,e,r=!1)=>{const n=Ti(t,e);return wl(n,r),n},we=(t,e,r=!1)=>{const n=Ts.length?Ts.pop():vl();return n.width=t,n.height=e,r?(n.msaa=!0,n.texture=null,n.color=$l(t,e),n.stencil=n.color.stencil):(n.msaa=!1,n.texture=Jr(t,e),n.color=null,n.stencil=Al(t,e)),n.mask=!1,n.clipLevel=0,n},Ol=()=>{Mi(null),Ps&&(As(!1),p.bindFramebuffer(p.FRAMEBUFFER,null))},El=()=>{const t=Ti(ut,ut);return p.activeTexture(p.TEXTURE3),p.bindTexture(p.TEXTURE_2D,t.resource),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texStorage2D(p.TEXTURE_2D,1,p.RGBA8,t.width,t.height),p.activeTexture(gr!==-1?gr:p.TEXTURE0),t},Os=Number.MAX_VALUE,Es=-Number.MAX_VALUE;let qt=0;const Qt=t=>{qt=t},En=[],Rl=()=>En,Cl=t=>{En[qt]=t},Ul=()=>(qt in En||Cl(we(ut,ut,!0)),En[qt]),br=[];let Rs=null;const Pi=()=>(Rs||(Rs=El()),Rs),en=[],Ai=t=>(t in en||(en[t]=new Float32Array([Os,Os,Es,Es])),en[t]),Gl=()=>{for(let t=0;t{Cs=t},Ll=()=>{br.length=0,Qt(0);const t=Rl();for(let e=0;e{if(t.clearArraysInstanced(),t.$stackAttachmentObject.length)for(let s=0;s{It(),p.scissor(t,e,r,n),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),yt()},Ke=(t,e,r=null,n=!1)=>{(gr===-1||e!==gr)&&(Bi(e),p.activeTexture(e));const s=ws[t];s!==null&&r!==null&&s.id===r.id||r===s||(ws[t]=r,p.bindTexture(p.TEXTURE_2D,r?r.resource:null),r&&r.smooth!==n&&(r.smooth=n,p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,n?p.LINEAR:p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,n?p.LINEAR:p.NEAREST)))},$e=(t,e=!1)=>{Ke(2,p.TEXTURE2,null),Ke(1,p.TEXTURE1,null),Ke(0,p.TEXTURE0,t,e)},_l=t=>{Mi(t),Ps||(As(!0),p.bindFramebuffer(p.FRAMEBUFFER,Tt)),t.msaa?(p.bindRenderbuffer(p.RENDERBUFFER,t.color.resource),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.RENDERBUFFER,t.color.resource)):($e(t.texture),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,t.texture.resource,0),Ke(0,p.TEXTURE0,null)),p.bindRenderbuffer(p.RENDERBUFFER,t.stencil.resource),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.STENCIL_ATTACHMENT,p.RENDERBUFFER,t.stencil.resource)},Us=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=t.clipLevel;let r=0;for(let n=0;n{wi=t},Gs=()=>wi,tn=new Map,rn=new Map,Vl=t=>{!t&&Gs()?(Rn(!1),Wr(),yt()):t&&!Gs()&&(Rn(!0),Yr(),Us())},Dl=(t,e)=>{const r=Bs;if(r&&e.id===r.id)return;_l(e),(!r||r.width!==e.width||r.height!==e.height)&&(Kc(e.width,e.height),p.viewport(0,0,e.width,e.height));const n=e.msaa?e.color:e.stencil;n.dirty&&(n.dirty=!1,t.clearRect(0,0,e.width,e.height)),Vl(e.mask)},Nl=t=>{t.$stack.push(xs(...t.$matrix))},zl=t=>{if(!t.$stack.length)return;const e=t.$stack.pop();t.$matrix[0]=e[0],t.$matrix[1]=e[1],t.$matrix[3]=e[3],t.$matrix[4]=e[4],t.$matrix[6]=e[6],t.$matrix[7]=e[7],Hc(e)},Xl=(t,e,r,n,s,o,i)=>{t[0]=e,t[1]=r,t[3]=n,t[4]=s,t[6]=o,t[7]=i},Yl=(t,e,r,n,s,o,i)=>{const l=t.$matrix[0],c=t.$matrix[1],u=t.$matrix[3],a=t.$matrix[4],h=t.$matrix[6],d=t.$matrix[7];t.$matrix[0]=e*l+r*u,t.$matrix[1]=e*c+r*a,t.$matrix[3]=n*l+s*u,t.$matrix[4]=n*c+s*a,t.$matrix[6]=o*l+i*u+h,t.$matrix[7]=o*c+i*a+d},Wl=t=>{t.globalAlpha=1,t.globalCompositeOperation="normal",t.imageSmoothingEnabled=!1},jl=t=>{t.$fillStyle.fill(1),t.$strokeStyle.fill(1)},Hl=(t,e,r,n)=>{It(),p.scissor(t,e,r+1,n+1),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),p.scissor(t,e,r,n)},Kl=()=>{yt()},ql=(t,e,r,n,s,o,i,l,c,u,a,h,d)=>{const g=t.length-5;for(let m=3;m(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t);let nn=new Float32Array(128),xr=0;const Ql=()=>nn,Zl=()=>xr,yr=t=>{const e=t.length+xr;if(e>nn.length){const r=new Float32Array(Oi(e));r.set(nn),r.set(t,xr),nn=r}else nn.set(t,xr);xr+=t.length},We=[],Bt=[],Ei=()=>{Bt.length=0,xr=0,We.length=0};let Ls=new Float32Array(32);const Jl=t=>(Ls.length{const r=e==="fill"?O.$fillStyle:O.$strokeStyle,n=r[0],s=r[1],o=r[2],i=r[3],l=O.$matrix,c=pt,u=mt,a=l[0]/c,h=l[3]/c,d=l[6]/c,g=l[1]/u,m=l[4]/u,f=l[7]/u;let b=0;for(let P=0;P{const e=pr();if(!e.length)return;Bt.push(t);const r=Cn(e);yr(r.buffer),We.push(r.indexCount)},qe=[],tu=(t,e,r,n,s,o)=>{const i=pr();if(!i.length)return;Bt.push(t===0?"linear":"radial");const l=Cn(i);yr(l.buffer),We.push(l.indexCount),qe.push(e,r,n,s),t===1&&qe.push(o)},ru=(t,e,r)=>{const n=Math.sqrt(t*t+e*e);return{x:-(e/n)*r,y:t/n*r}},nu=(t,e,r)=>{const n={x:e.x-t.x,y:e.y-t.y},s=ru(n.x,n.y,r),o={x:t.x+s.x,y:t.y+s.y},i={x:e.x+s.x,y:e.y+s.y},l={x:t.x-s.x,y:t.y-s.y},c={x:e.x-s.x,y:e.y-s.y};return[o.x,o.y,!1,i.x,i.y,!1,c.x,c.y,!1,l.x,l.y,!1,o.x,o.y,!1]},ks=(t,e,r)=>({x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}),su=(t,e,r,n=.5)=>{const s=ks(t,e,n),o=ks(e,r,n),i=ks(s,o,n);return[[t,s,i],[i,o,r]]},ou=(t,e,r,n=4)=>{let s=[[t,e,r]];for(let o=0;o({x:(1-t)**2*e.x+2*(1-t)*t*r.x+t**2*n.x,y:(1-t)**2*e.y+2*(1-t)*t*r.y+t**2*n.y}),au=(t,e,r,n)=>({x:2*(1-t)*(r.x-e.x)+2*t*(n.x-r.x),y:2*(1-t)*(r.y-e.y)+2*t*(n.y-r.y)}),cu=t=>{const e=Math.sqrt(t.x*t.x+t.y*t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},Ri=(t,e,r,n)=>{const s=[0,.5,1],o=[];for(let i=0;i{const s=ou(t,e,r,5),o=[],i=[];for(let h=0;h{const s=[];for(let i=0;i1e-4||s.push(l,c)}return s},Mr=new OffscreenCanvas(1,1).getContext("2d"),Sr=(t,e)=>{Mr.beginPath(),Mr.moveTo(e[0],e[1]);for(let r=3;r{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=n[o].length>15,c=n[i].length>15;if(l&&c)return;const u=vr(t,e,r,n[o]),a=vr(t,e,r,n[i]),h=Sr(u,n[i]);if(!h)return;const d=Sr(a,n[o]);if(!d)return;const g=Math.atan2(h[1]-e,h[0]-t);let f=Math.atan2(d[1]-e,d[0]-t)-g;f>Math.PI?f-=2*Math.PI:f<-Math.PI&&(f+=2*Math.PI);const b=Math.abs(f);if(b<.1||b>Math.PI-.1)return;const x=8,y=f/x,P=[t,e,!1];for(let S=0;S<=x;S++){const M=g+S*y,$=t+r*Math.cos(M),T=e+r*Math.sin(M);P.push($,T,!1)}n.splice(-1,0,P)},Ui=(t,e,r,n,s=!1)=>{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=n[o].length>15,c=n[i].length>15;if(l&&c)return;const u=vr(t,e,r,n[o]),a=vr(t,e,r,n[i]);if(u[0]===a[0]&&u[1]===a[1]||u[0]===a[2]&&u[1]===a[3])return;const h=Sr(u,n[i]);if(!h)return;const d=Sr(a,n[o]);d&&n.splice(-1,0,[t,e,!1,h[0],h[1],!1,d[0],d[1],!1,t,e,!1])},uu=(t,e,r)=>{for(let n=0;n<2;++n){let s=0,o=0,i=0,l=0;n===0?(s=t[0],o=t[1],i=t[3],l=t[4]):(s=t[t.length-3],o=t[t.length-2],i=t[t.length-6],l=t[t.length-5]);const c=i-s,u=l-o,a=Math.atan2(u,c),h=a+Math.PI/2,d=a-Math.PI/2,g=16,m=(d-h)/g,f=[];for(let b=0;b<=g;b++){const x=d+m*b,y=s+e*Math.cos(x),P=o+e*Math.sin(x);f.push(y,P,!1)}n===0?r.unshift(f):r.push(f)}},fu=(t,e,r)=>{for(let n=0;n<2;++n){let s=0,o=0,i=0,l=0;n===0?(s=t[0],o=t[1],i=t[3],l=t[4]):(s=t[t.length-3],o=t[t.length-2],i=t[t.length-6],l=t[t.length-5]);const c=-(i-s),u=-(l-o),a=Math.sqrt(c*c+u*u);if(a===0)continue;const h=c/a,d=u/a,g=s+e*h,m=o+e*d,f=-d,b=h,x=[g+e*h+e*f,m+e*d+e*b,!1,g+e*h-e*f,m+e*d-e*b,!1,g-e*h-e*f,m-e*d-e*b,!1,g+e*h+e*f,m+e*d+e*b,!1,g-e*h-e*f,m-e*d-e*b,!1,g-e*h+e*f,m-e*d+e*b,!1];n===0?r.unshift(x):r.push(x)}},Gi=(t,e,r,n,s,o=!1)=>{const i=o?0:s.length-1,l=o?s.length-1:s.length-2,c=s[i].length>15,u=s[l].length>15;if(c&&u)return;const a=vr(t.x,t.y,n,s[i]),h=vr(t.x,t.y,n,s[l]);if(a[0]===h[0]&&a[1]===h[1]||a[0]===h[2]&&a[1]===h[3])return;const d=Sr(a,s[l]);if(!d)return;const g=Sr(h,s[i]);if(!g)return;const m=e.x-t.x,f=e.y-t.y,b=Math.hypot(m,f),x={x:m/b,y:f/b},y=r.x-t.x,P=r.y-t.y,S=Math.hypot(y,P),M={x:y/S,y:P/S},$=x.x,T=x.y,w=M.x,E=M.y,F=$*E-T*w;if(F===0){s.splice(-1,0,[t.x,t.y,!1,d[0],d[1],!1,g[0],g[1],!1]);return}const A=((g[0]-d[0])*E-(g[1]-d[1])*w)/F,R=d[0]+A*$,v=d[1]+A*T;s.splice(-1,0,[t.x,t.y,!1,d[0],d[1],!1,R,v,!1,t.x,t.y,!1,g[0],g[1],!1,R,v,!1])},hu={x:0,y:0},du={x:0,y:0},pu={x:0,y:0},mu={x:0,y:0},gu=(t,e)=>{const r=hu;r.x=t[0],r.y=t[1];const n=du;n.x=0,n.y=0;const s=pu;s.x=0,s.y=0;const o=mu;o.x=0,o.y=0;const i=[];for(let g=3;g1)switch(O.joints){case 0:Ui(r.x,r.y,e,i);break;case 1:o.x=t[g-6],o.y=t[g-5],Gi(r,s,o,e,i);break;case 2:Ci(r.x,r.y,e,i);break}r.x=s.x,r.y=s.y}const l=t[0],c=t[1],u=t[t.length-3],a=t[t.length-2],h=1e-4;if(Math.abs(l-u)1)switch(O.joints){case 0:Ui(l,c,e,i,!0);break;case 1:r.x=l,r.y=c,s.x=t[3],s.y=t[4],o.x=t[t.length-6],o.y=t[t.length-5],Gi(r,s,o,e,i,!0);break;case 2:Ci(l,c,e,i,!0);break}else switch(O.caps){case 1:uu(t,e,i);break;case 2:fu(t,e,i);break}return i},Is=t=>{const e=O.thickness/2,r=Hr();for(let s=0;s{const i=pr(!0);if(!i.length)return;Bt.push(t===0?"linear":"radial");const l=Is(i);yr(l.buffer),We.push(l.indexCount),qe.push(e,r,n,s),t===1&&qe.push(o)},$r=new Map,Li=()=>{$r.clear()},xu=t=>{$r.set(We.length,t)},Un=()=>({id:Jc(),resource:p.createVertexArray(),vertexBuffer:p.createBuffer(),vertexLength:0});let _s;const Pt=t=>{_s&&_s.id===t.id||(_s=t,p.bindVertexArray(t.resource))},yu=()=>{const t=Un();Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer);const e=new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]);return p.bufferData(p.ARRAY_BUFFER,e,p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),t},Gn=[],tt=new Float32Array([0,0,0,1,1,0,1,1]);let Vs;const vu=t=>{Vs=t.createBuffer()};let ki;const Mu=t=>{ki=t};let Ds;const Ln=()=>(Ds||(Ds=yu()),Ds),Su=()=>{if(Gn.length)return Gn.pop();const t=Un();return Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),p.enableVertexAttribArray(0),p.enableVertexAttribArray(1),p.enableVertexAttribArray(2),p.enableVertexAttribArray(3),p.enableVertexAttribArray(4),p.enableVertexAttribArray(5),p.vertexAttribPointer(0,2,p.FLOAT,!1,68,0),p.vertexAttribPointer(1,2,p.FLOAT,!1,68,8),p.vertexAttribPointer(2,4,p.FLOAT,!1,68,16),p.vertexAttribPointer(3,3,p.FLOAT,!1,68,32),p.vertexAttribPointer(4,3,p.FLOAT,!1,68,44),p.vertexAttribPointer(5,3,p.FLOAT,!1,68,56),t},Ii=()=>{const t=Su();Pt(t);const e=Ql(),r=Zl();return p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),t.vertexLength{Gn.indexOf(t)>-1||Gn.push(t)};let $u=0;const Tu=(t,e)=>{const r=p.createProgram(),n=p.createShader(p.VERTEX_SHADER);p.shaderSource(n,t),p.compileShader(n);const s=p.createShader(p.FRAGMENT_SHADER);return p.shaderSource(s,e),p.compileShader(s),p.attachShader(r,n),p.attachShader(r,s),p.linkProgram(r),p.detachShader(r,n),p.detachShader(r,s),p.deleteShader(n),p.deleteShader(s),{id:$u++,resource:r}},Bu=(t,e,r=!1)=>{const n=p.getProgramParameter(t,p.ACTIVE_UNIFORMS);for(let s=0;s{Vi!==t.id&&(Vi=t.id,p.useProgram(t.resource))},Au=t=>{for(const e of t.values())e.method===void 0||e.assign===void 0||(e.assign<0?e.method(e.array):e.assign>0&&(e.assign--,e.method(e.array)))};class _e{_$programObject;_$uniformMap;highp;mediump;textures;constructor(e,r,n=!1){this._$programObject=Tu(e,r),this._$uniformMap=new Map,Bu(this._$programObject.resource,this._$uniformMap,n);const s=new Float32Array(0);this.highp=this._$uniformMap.get("u_highp")?.array??s,this.mediump=this._$uniformMap.get("u_mediump")?.array??s,this.textures=this._$uniformMap.get("u_textures")?.array??s}useProgram(){Pu(this._$programObject)}bindUniform(){Au(this._$uniformMap)}}const At=new Map,Fu=()=>\` -vec2 applyMatrix(in vec2 vertex) { - mat3 matrix = mat3(a_matrix0, a_matrix1, a_matrix2); - return (matrix * vec3(vertex, 1.0)).xy; -}\`,wu=t=>\` -vec2 applyMatrix(in vec2 vertex) { - mat3 parent_matrix = mat3( - u_highp[\${t}].xyz, - u_highp[\${t+1}].xyz, - u_highp[\${t+2}].xyz - ); - mat3 ancestor_matrix = mat3( - u_highp[\${t+3}].xyz, - u_highp[\${t+4}].xyz, - u_highp[\${t+5}].xyz - ); - - vec2 parent_offset = vec2(u_highp[\${t+2}].w, u_highp[\${t+3}].w); - vec2 parent_size = vec2(u_highp[\${t+4}].w, u_highp[\${t+5}].w); - vec4 grid_min = u_highp[\${t+6}]; - vec4 grid_max = u_highp[\${t+7}]; - - vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy; - position = (position - parent_offset) / parent_size; - - vec4 ga = grid_min; - vec4 gb = grid_max - grid_min; - vec4 gc = vec4(1.0) - grid_max; - - vec2 pa = position; - vec2 pb = position - grid_min.st; - vec2 pc = position - grid_max.st; - - position = (ga.pq / ga.st) * min(pa, ga.st) - + (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st) - + (gc.pq / gc.st) * max(vec2(0.0), pc); - - position = position * parent_size + parent_offset; - position = (ancestor_matrix * vec3(position, 1.0)).xy; - - position = position + vec2(u_highp[\${t+8}].x, u_highp[\${t+8}].y); - return position / vec2(u_highp[0].w, u_highp[1].w); -}\`,Ou=()=>"layout (location = 1) in vec2 a_bezier;",Eu=()=>\`layout (location = 3) in vec3 a_matrix0; -layout (location = 4) in vec3 a_matrix1; -layout (location = 5) in vec3 a_matrix2;\`,Ru=()=>"out vec2 v_uv;",Cu=()=>"out vec2 v_bezier;",Uu=()=>\` - mat3 uv_matrix = mat3( - u_highp[0].xyz, - u_highp[1].xyz, - u_highp[2].xyz - ); - mat3 inverse_matrix = mat3( - u_highp[3].xyz, - u_highp[4].xyz, - vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w) - ); - v_uv = (inverse_matrix * uv_matrix * vec3(a_vertex, 1.0)).xy;\`,Gu=()=>"v_bezier = a_bezier;",Lu=()=>"layout (location = 2) in vec4 a_color;",ku=()=>"out vec4 v_color;",Iu=()=>"v_color = a_color;",kn=(t,e,r,n)=>{const s=r?Ou():"",o=r?Cu():e?Ru():"",i=r?Gu():e?Uu():"",l=n?wu(e?5:0):Fu(),c=r?"":Lu(),u=r?"":ku(),a=r?"":Iu(),h=n?"":Eu(),d=t>1?\`uniform vec4 u_highp[\${t}];\`:"";return\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -\${s} -\${c} -\${h} - -\${d} -\${o} -\${u} -\${l} - -void main() { - \${a} - \${i} - vec2 pos = applyMatrix(a_vertex); - pos = pos * 2.0 - 1.0; - gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0); -}\`},_u=()=>\`#version 300 es -layout (location = 0) in vec2 a_vertex; -void main() { - vec2 pos = a_vertex * 2.0 - 1.0; - gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0); -}\`,Vu=()=>\`#version 300 es -precision mediump float; - -in vec4 v_color; -out vec4 o_color; - -void main() { - o_color = vec4(v_color.rgb * v_color.a, v_color.a); -}\`,Du=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[1]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 uv = vec2(v_uv.x, u_mediump[0].y - v_uv.y) / u_mediump[0].xy; - - vec4 src = texture(u_texture, uv); - o_color = src; -}\`,Nu=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[1]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 uv = fract(vec2(v_uv.x, -v_uv.y) / u_mediump[0].xy); - - vec4 src = texture(u_texture, uv); - o_color = src; -}\`,zu=()=>\`#version 300 es -precision mediump float; - -in vec2 v_bezier; -out vec4 o_color; - -void main() { - float f_val = v_bezier.x * v_bezier.x - v_bezier.y; - - float dx = dFdx(f_val); - float dy = dFdy(f_val); - - float dist = f_val / length(vec2(dx, dy)); - float alpha = smoothstep(0.5, -0.5, dist); - - if (alpha > 0.001) { - o_color = vec4(min(alpha, 1.0)); - } else { - discard; - } -}\`,Xu=()=>\`#version 300 es -precision mediump float; -out vec4 o_color; -void main() { - o_color = vec4(1.0); -}\`,sn=t=>{const e=\`m\${t?"y":"n"}\`;if(At.has(e))return At.get(e);const r=new _e(kn(t?9:0,!1,!0,t),zu());return At.set(e,r),r},on=(t,e)=>{const r=t.highp;r[0]=e[0],r[1]=e[1],r[2]=0,r[4]=e[2],r[5]=e[3],r[6]=0,r[8]=e[4],r[9]=e[5],r[10]=1,r[12]=e[6],r[13]=e[7],r[14]=0,r[16]=e[8],r[17]=e[9],r[18]=0,r[20]=e[10],r[21]=e[11],r[22]=1,r[3]=pt,r[7]=mt,r[11]=e[12],r[15]=e[13],r[19]=e[14],r[23]=e[15],r[24]=e[16],r[25]=e[17],r[26]=e[18],r[27]=e[19],r[28]=e[20],r[29]=e[21],r[30]=e[22],r[31]=e[23],r[32]=e[24],r[33]=e[25]};let In="normal";const Di=t=>{In=t};let Ft=600;const _t=t=>{Ft=t},Ce=()=>{Ft!==613&&(_t(613),p.blendFunc(p.ONE,p.ONE_MINUS_SRC_ALPHA))},rt=(t,e,r,n)=>{t.useProgram(),t.bindUniform(),Ce(),Pt(e),p.drawArrays(p.TRIANGLES,r,n)},Ns=()=>{const t="rmnn";if(At.has(t))return At.get(t);const e=new _e(_u(),Xu());return At.set(t,e),e},Yu=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=1<{const t=O.currentAttachmentObject;if(!t)return;const e=tn.get(t.clipLevel),r=e[0],n=e[1],s=e[2],o=e[3],i=Math.ceil(Math.abs(s-r)),l=Math.ceil(Math.abs(o-n));It(),p.scissor(r,t.height-n-l,i,l);const c=Ii();let u=rn.get(t.clipLevel),a=0,h=null;const d=We.length;for(let g=0;g7&&(Yu(),u=t.clipLevel+1)}rn.set(t.clipLevel,u),_i(c),Ei(),Li(),yt()},ju=(t,e,r)=>{if(t.used){const l=t.left?.insert(e,r);return l||t.right?.insert(e,r)||null}if(e>t.w||r>t.h)return null;if(e===t.w&&r===t.h)return t.used=!0,t;const n=e+1,s=r+1,o=t.w-n,i=t.h-s;return o>i?(t.left=t.create(t.index,t.x,t.y,e,t.h),t.right=t.create(t.index,t.x+n,t.y,o,t.h)):(t.left=t.create(t.index,t.x,t.y,t.w,r),t.right=t.create(t.index,t.x,t.y+s,t.w,i)),t.used=!0,t.left.insert(e,r)},Hu=(t,e,r,n,s)=>t.left?.dispose(e,r,n,s)?(!t.left.used&&!t.right?.used&&(t.left&&t.left.release(),t.right&&t.right.release(),t.left=t.right=null,t.used=!1),!0):t.right?.dispose(e,r,n,s)?(!t.right.used&&!t.left?.used&&(t.left&&t.left.release(),t.right&&t.right.release(),t.left=t.right=null,t.used=!1),!0):e===t.x&&r===t.y&&n===t.w&&s===t.h?(t.used=!1,!0):!1,zs=[];class Xs{index;x;y;w;h;left;right;used;constructor(e,r,n,s,o){this.index=e,this.x=r,this.y=n,this.w=s,this.h=o,this.left=null,this.right=null,this.used=!1}insert(e,r){return ju(this,e,r)}dispose(e,r,n,s){return Hu(this,e,r,n,s)}create(e,r,n,s,o){const i=zs.length?zs.pop():new Xs(e,0,0,0,0);return i.index=e,i.x=r,i.y=n,i.w=s,i.h=o,i.left=null,i.right=null,i.used=!1,i}release(){this.left&&(this.left.release(),this.left=null),this.right&&(this.right.release(),this.right=null),this.used=!1,zs.push(this)}}class Ni{_$root;constructor(e,r,n){this._$root=new Xs(e,0,0,r,n)}insert(e,r){return this._$root.insert(e,r)}dispose(e,r,n,s){return this._$root.dispose(e,r,n,s)}}const Ys=(t,e)=>{const r=qt;br[r]||(br[r]=new Ni(r,ut,ut));const s=br[r].insert(t,e);if(s)return s;for(let o=0;o<10;o++){if(r===o)continue;Qt(o);const i=br[o];if(!i)return Ys(t,e);const l=i.insert(t,e);if(l)return l}return Ys(t,e)},Ku=t=>{const e=br[t.index];e&&e.dispose(t.x,t.y,t.w,t.h)},Ws=()=>\` -float isInside(in vec2 uv) { - return step(4.0, dot(step(vec4(0.0, uv.x, 0.0, uv.y), vec4(uv.x, 1.0, uv.y, 1.0)), vec4(1.0))); -}\`,zi=t=>\` - vec4 mul = u_mediump[\${t}]; - vec4 add = u_mediump[\${t+1}]; - - if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0 - || add.x != 0.0 || add.y != 0.0 || add.z != 0.0 - ) { - src.rgb /= max(0.0001, src.a); - src = clamp(src * mul + add, 0.0, 1.0); - src.rgb *= src.a; - } -\`,Xi=t=>{const e=t?"uniform vec4 u_mediump[2];":"",r=t?zi(0):"";return\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -\${e} - -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec4 src = texture(u_texture, v_coord); - \${r} - o_color = src; -}\`},qu=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; - -in vec4 v_mul; -in vec4 v_add; -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec4 src = texture(u_texture, v_coord); - - if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0 - || v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0 - ) { - src.rgb /= max(0.0001, src.a); - src = clamp(src * v_mul + v_add, 0.0, 1.0); - src.rgb *= src.a; - } - - o_color = src; -}\`,Qu=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t);class Zu{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...e){this.buffer.length\`#version 300 es - -layout (location = 0) in vec2 a_vertex; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - vec2 position = a_vertex * 2.0 - 1.0; - gl_Position = vec4(position, 0.0, 1.0); -}\`,ef=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -uniform vec4 u_highp[3]; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - mat3 matrix = mat3( - u_highp[0].x, u_highp[0].y, 0.0, - u_highp[0].z, u_highp[0].w, 0.0, - u_highp[1].x, u_highp[1].y, 1.0 - ); - - vec2 size = u_highp[1].zw; - vec2 viewport = vec2(u_highp[2].x, u_highp[2].y); - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * size; - position = (matrix * vec3(position, 1.0)).xy; - position /= viewport; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,tf=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -uniform vec4 u_highp[2]; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - vec2 offset = u_highp[0].xy; - vec2 size = u_highp[0].zw; - vec2 viewport = vec2(u_highp[1].x, u_highp[1].y); - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * size + offset; - position /= viewport; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,rf=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -layout (location = 1) in vec4 a_rect; -layout (location = 2) in vec4 a_size; -layout (location = 3) in vec2 a_offset; -layout (location = 4) in vec4 a_matrix; -layout (location = 5) in vec4 a_mul; -layout (location = 6) in vec4 a_add; - -out vec2 v_coord; -out vec4 v_mul; -out vec4 v_add; - -void main() { - v_coord = a_vertex * a_rect.zw + a_rect.xy; - v_mul = a_mul; - v_add = a_add; - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * a_size.xy; - - mat3 matrix = mat3( - a_matrix.x, a_matrix.y, 0.0, - a_matrix.z, a_matrix.w, 0.0, - a_offset.x, a_offset.y, 1.0 - ); - - position = (matrix * vec3(position, 1.0)).xy; - position /= a_size.zw; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,nt=new Map,js=()=>{if(nt.has("i"))return nt.get("i");const e=new Ju(rf(),qu());return nt.set("i",e),e},nf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - return src + dst - dst * src.a; -}\`,sf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,of=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - vec4 c = src * dst; - - return a + b + c; -}\`,af=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,cf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,lf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 mul = src * dst; - vec3 c1 = 2.0 * mul.rgb; - vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0; - vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a); - c.rgb *= c.a; - - return a + b + c; -}\`,uf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 mul = src * dst; - vec3 c1 = 2.0 * mul.rgb; - vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0; - vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a); - c.rgb *= c.a; - - return a + b + c; -}\`,ff=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,hf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 b = dst - dst * src.a; - vec4 c = vec4(src.a - dst.rgb * src.a, src.a); - - return b + c; -}\`,df=(t,e)=>{let r;switch(t){case"subtract":r=sf();break;case"multiply":r=of();break;case"lighten":r=af();break;case"darken":r=cf();break;case"overlay":r=lf();break;case"hardlight":r=uf();break;case"difference":r=ff();break;case"invert":r=hf();break;default:r=nf();break}const n="uniform vec4 u_mediump[2];",s=zi(0);return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[2]; -\${n} - -in vec2 v_coord; -out vec4 o_color; - -\${r} - -void main() { - vec4 dst = texture(u_textures[0], v_coord); - vec4 src = texture(u_textures[1], v_coord); - \${s} - o_color = blend(src, dst); -}\`},Yi=(t,e)=>{const r=\`i\${t}y\`;if(nt.has(r))return nt.get(r);const n=new _e(Zt(),df(t));return nt.set(r,n),n},Wi=()=>{if(!O.newDrawState)return;const t=O.currentAttachmentObject,e=O.atlasAttachmentObject;O.bind(e),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,On),As(!1);const n=Ai(qt);It(),p.scissor(n[0],n[1],n[2]-n[0],n[3]-n[1]),p.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,p.COLOR_BUFFER_BIT,p.NEAREST),yt(),t&&O.bind(t),O.newDrawState=!1},ji=t=>{const e=qt;Qt(t.index),Wi(),p.bindFramebuffer(p.FRAMEBUFFER,Fs);const r=Pi();p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,r.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,Zr);const n=Jr(t.w,t.h);return p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,n.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,null),p.bindFramebuffer(p.READ_FRAMEBUFFER,Fs),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,Zr),p.blitFramebuffer(t.x,t.y,t.x+t.w,t.y+t.h,0,0,t.w,t.h,p.COLOR_BUFFER_BIT,p.NEAREST),Qt(e),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.FRAMEBUFFER,Tt),n},_n=(t,e,r=!1)=>{Ke(2,p.TEXTURE2,null,r),Ke(1,p.TEXTURE1,e,r),Ke(0,p.TEXTURE0,t,r)},Jt=()=>{if(nt.has("p"))return nt.get("p");const e=new _e(tf(),Xi(!1));return nt.set("p",e),e},wt=(t,e,r)=>{const n=t.highp,s=O.$matrix;n[0]=s[6],n[1]=s[7],n[2]=e,n[3]=r,n[4]=pt,n[5]=mt},xe=t=>{t.useProgram(),t.bindUniform(),Pt(Ln()),p.drawArrays(p.TRIANGLES,0,6)};let er=null;const Hi=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=O.$mainAttachmentObject;return O.bind(o),p.bindFramebuffer(p.FRAMEBUFFER,Zr),(!er||er.width!==o.width||er.height!==o.height)&&(er=Jr(o.width,o.height)),$e(er),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,er.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,null),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,Zr),It(),p.scissor(t,o.height-e-n,r+1,n+1),p.blitFramebuffer(0,0,o.width,o.height,0,0,o.width,o.height,p.COLOR_BUFFER_BIT,p.NEAREST),yt(),p.bindFramebuffer(p.FRAMEBUFFER,Tt),s&&O.bind(s),er},Vn=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=Hi(t,e,r,n),i=we(r,n,!1);O.bind(i),O.save(),O.setTransform(1,0,0,1,-t,-e);const l=Jt();wt(l,o.width,o.height),Ce(),$e(o),xe(l);const c=i.texture;return O.restore(),be(i,!1),s&&O.bind(s),c},Tr=()=>{Ft!==610&&(_t(610),p.blendFunc(p.ONE,p.ZERO))},Ki=t=>{$e(t),Tr();const e=Jt();wt(e,t.width,t.height),xe(e),Ce()},qi=(t,e,r,n,s,o,i,l,c)=>{const u=t.textures;u[0]=0,u[1]=1;const a=t.mediump;a[0]=e,a[1]=r,a[2]=n,a[3]=s,a[4]=o,a[5]=i,a[6]=l,a[7]=c},Dn=(t=!1)=>{const e=\`m\${t?"y":"n"}\`;if(nt.has(e))return nt.get(e);const r=new _e(ef(),Xi(t));return nt.set(e,r),r},Nn=(t,e,r)=>{const n=t.highp,s=O.$matrix;n[0]=s[0],n[1]=s[1],n[2]=s[3],n[3]=s[4],n[4]=s[6],n[5]=s[7],n[6]=e,n[7]=r,n[8]=pt,n[9]=mt},pf=(t,e,r,n,s,o)=>{const i=o[0],l=o[1],c=o[2],u=O.globalAlpha,a=o[4]/255,h=o[5]/255,d=o[6]/255,g=0,m=O.$matrix;switch(O.globalCompositeOperation){case"normal":case"layer":case"add":case"screen":case"alpha":case"erase":case"copy":{if(In!==O.globalCompositeOperation||Cs!==t.index){Qt(Cs);const b=O.globalCompositeOperation;O.globalCompositeOperation=In,O.newDrawState=!0,O.drawArraysInstanced(),O.newDrawState=!0,O.globalCompositeOperation=b,Di(O.globalCompositeOperation),Fi(t.index),Qt(t.index)}const f=js();Ve.pushDisplayObjectBuffer((t.x+.5)/ut,(t.y+.5)/ut,(t.w-1)/ut,(t.h-1)/ut,t.w,t.h,pt,mt,m[6],m[7],m[0],m[1],m[3],m[4],i,l,c,u,a,h,d,g),f.count++}break;default:{const f=O.currentAttachmentObject;O.drawArraysInstanced();const b=Math.ceil(Math.abs(n-e)),x=Math.ceil(Math.abs(s-r));let y=0,P=0,S=ji(t);if(m[0]!==1||m[1]!==0||m[3]!==0||m[4]!==1){const w=we(b,x,!1),E=dr(m[0],m[1],m[3],m[4],b/2,x/2),F=dr(1,0,0,1,-t.w/2,-t.h/2),A=dr(E[0]*F[0]+E[2]*F[1],E[1]*F[0]+E[3]*F[1],E[0]*F[2]+E[2]*F[3],E[1]*F[2]+E[3]*F[3],E[0]*F[4]+E[2]*F[5]+E[4],E[1]*F[4]+E[3]*F[5]+E[5]);O.save(),O.bind(w),O.setTransform(A[0],A[1],A[2],A[3],A[4],A[5]),y=A[4],P=A[5];const R=Dn();Nn(R,S.width,S.height),$e(S,!0),xe(R),ae(S),S=w.texture,be(w,!1),f&&O.bind(f),O.restore()}(y||P)&&(m[6]-=y,m[7]-=P);const M=Vn(m[6],m[7],b,x),$=we(b,x,!1);O.bind($),_n(M,S);const T=Yi(O.globalCompositeOperation);qi(T,i,l,c,u,a,h,d,g),xe(T),f&&O.bind(f),Ki($.texture),(y||P)&&(m[6]+=y,m[7]+=P),ae(S),ae(M),be($),Di(O.globalCompositeOperation),Fi(t.index),Qt(t.index)}break}},mf=()=>{js().clear()};let Hs=0;const gf=()=>{Pt(ki),p.bindBuffer(p.ARRAY_BUFFER,Vs),Ve.buffer.length>Hs&&(Hs=Ve.buffer.length,p.bufferData(p.ARRAY_BUFFER,Hs*4,p.STREAM_DRAW)),p.bufferSubData(p.ARRAY_BUFFER,0,Ve.buffer,0,Ve.offset)},bf=t=>{t.useProgram(),t.bindUniform(),gf(),p.drawArraysInstanced(p.TRIANGLES,0,6,t.count)},xf=()=>{Ft!==611&&(_t(611),p.blendFunc(p.ONE,p.ONE))},yf=()=>{Ft!==641&&(_t(641),p.blendFunc(p.ONE_MINUS_DST_COLOR,p.ONE))},vf=()=>{Ft!==606&&(_t(606),p.blendFunc(p.ZERO,p.SRC_ALPHA))},Ks=()=>{Ft!==603&&(_t(603),p.blendFunc(p.ZERO,p.ONE_MINUS_SRC_ALPHA))},Qi=t=>{switch(t){case"add":xf();break;case"screen":yf();break;case"alpha":vf();break;case"erase":Ks();break;case"copy":Tr();break;default:Ce();break}},Mf=()=>{const t=js();t.count&&(Wi(),Qi(In),bf(t),t.clear())},Sf=()=>{const t=Un();return Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),p.bufferData(p.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]),p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),p.bindBuffer(p.ARRAY_BUFFER,Vs),p.bufferData(p.ARRAY_BUFFER,Ve.buffer.length,p.STREAM_DRAW),p.enableVertexAttribArray(1),p.vertexAttribPointer(1,4,p.FLOAT,!1,88,0),p.vertexAttribDivisor(1,1),p.enableVertexAttribArray(2),p.vertexAttribPointer(2,4,p.FLOAT,!1,88,16),p.vertexAttribDivisor(2,1),p.enableVertexAttribArray(3),p.vertexAttribPointer(3,2,p.FLOAT,!1,88,32),p.vertexAttribDivisor(3,1),p.enableVertexAttribArray(4),p.vertexAttribPointer(4,4,p.FLOAT,!1,88,40),p.vertexAttribDivisor(4,1),p.enableVertexAttribArray(5),p.vertexAttribPointer(5,4,p.FLOAT,!1,88,56),p.vertexAttribDivisor(5,1),p.enableVertexAttribArray(6),p.vertexAttribPointer(6,4,p.FLOAT,!1,88,72),p.vertexAttribDivisor(6,1),t},$f=t=>{vu(t),Mu(Sf())},Tf=()=>{const t=O.$mainAttachmentObject;O.bind(t),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,null);const e=t.width,r=t.height;p.blitFramebuffer(0,0,e,r,0,0,e,r,p.COLOR_BUFFER_BIT,p.NEAREST),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,vi),p.bindFramebuffer(p.FRAMEBUFFER,Tt)},Bf=()=>{p.enable(p.BLEND),Ce()},Pf=()=>{const t=O.currentAttachmentObject;t&&(t.mask=!0,t.clipLevel++,rn.set(t.clipLevel,t.clipLevel),Gs()||(Rn(!0),Yr(),p.enable(p.SAMPLE_ALPHA_TO_COVERAGE),p.stencilFunc(p.ALWAYS,0,255),p.stencilOp(p.ZERO,p.INVERT,p.INVERT),p.colorMask(!1,!1,!1,!1)))},Af=(t,e,r,n)=>{const s=O.currentAttachmentObject;if(!s)return;tn.set(s.clipLevel,hi(t,e,r,n));const o=Math.ceil(Math.abs(r-t)),i=Math.ceil(Math.abs(n-e));It(),p.scissor(t,s.height-e-i,o,i)},Ff=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=t.clipLevel,r=tn.get(e),n=r[0],s=r[1],o=r[2],i=r[3];tn.delete(e),rn.delete(e),di(r);const l=Math.ceil(Math.abs(o-n)),c=Math.ceil(Math.abs(i-s));if(It(),p.scissor(n,t.height-s-c,l,c),--t.clipLevel,!t.clipLevel){t.mask=!1,Rn(!1),p.clear(p.STENCIL_BUFFER_BIT),Wr(),yt(),rn.clear(),tn.clear();return}p.stencilMask(1<{const s=Jr(t,e,n);return p.texSubImage2D(p.TEXTURE_2D,0,0,0,t,e,p.RGBA,p.UNSIGNED_BYTE,r),s},wf=(t,e)=>{const r=qs(t.w,t.h,e),n=Jt();wt(n,t.w,t.h),Ce(),xe(n),ae(r)},Of=(t,e,r,n=!1)=>{const s=Jr(t,e,n);return p.texSubImage2D(p.TEXTURE_2D,0,0,0,p.RGBA,p.UNSIGNED_BYTE,r),s},Ef=(t,e)=>{const r=Of(t.w,t.h,e),n=Jt();wt(n,t.w,t.h),Ce(),xe(n),ae(r)},Vt=[],Rf=(t,e,r,n,s,o)=>{const i=pr();if(!i.length)return;Bt.push("bitmap");const l=Cn(i);yr(l.buffer),We.push(l.indexCount),Vt.push(t,e,r,n,s,o)},Cf=(t,e,r,n,s,o)=>{const i=pr(!0);if(!i.length)return;Bt.push("bitmap");const l=Is(i);yr(l.buffer),We.push(l.indexCount),Vt.push(t,e,r,n,s,o)},Uf=()=>{const t=pr(!0);if(!t.length)return;Bt.push("fill");const e=Is(t);yr(e.buffer),We.push(e.indexCount)},Gf=t=>{const e=t.toFixed(1);return\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump; - -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec2 offset = u_mediump.xy; - float fraction = u_mediump.z; - float samples = u_mediump.w; - - vec4 color = texture(u_texture, v_coord); - - for (float i = 1.0; i < \${e}; i += 1.0) { - color += texture(u_texture, v_coord + offset * i); - color += texture(u_texture, v_coord - offset * i); - } - color += texture(u_texture, v_coord + offset * \${e}) * fraction; - color += texture(u_texture, v_coord - offset * \${e}) * fraction; - color /= samples; - - o_color = color; -}\`},De=new Map,Lf=t=>{const e=\`b\${t}\`;if(De.has(e))return De.get(e);const r=new _e(Zt(),Gf(t));return De.set(e,r),r},kf=(t,e,r,n,s,o)=>{const i=t.mediump;n?(i[0]=1/e,i[1]=0):(i[0]=0,i[1]=1/r),i[2]=s,i[3]=o},Zi=(t,e,r)=>{$e(t,!0);const n=Math.ceil(r*.5),s=1-(n-r*.5),o=1+r,i=Lf(n);kf(i,t.width,t.height,e,s,o),xe(i)},re={x:0,y:0},Br=(t,e,r)=>(t>>16)*(r?e:1)/255,Pr=(t,e,r)=>(t>>8&255)*(r?e:1)/255,Ar=(t,e,r)=>(t&255)*(r?e:1)/255,If=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],tr=(t,e,r=4,n=4,s=1,o=!0)=>{const i=O.currentAttachmentObject,l=Math.sqrt(e[0]*e[0]+e[1]*e[1]),c=Math.sqrt(e[2]*e[2]+e[3]*e[3]),u=vt,a=r*(l/u),h=n*(c/u),d=If[s-1],g=Math.round(a*d),m=Math.round(h*d);re.x+=g,re.y+=m;const f=t.width+g*2,b=t.height+m*2;let x=1,y=1;a>128?x=.0625:a>64?x=.125:a>32?x=.25:a>16&&(x=.5),h>128?y=.0625:h>64?y=.125:h>32?y=.25:h>16&&(y=.5);const P=Math.ceil(f*x),S=Math.ceil(b*y),M=we(P,S,!1),$=we(P,S,!1),T=[M,$];O.bind(M),O.reset(),O.setTransform(x,0,0,y,g*x,m*y),$e(t);const w=Dn();Nn(w,t.width,t.height),xe(w),o&&ae(t);const E=a*x,F=h*y;let A=0,R=M.texture;$e(R,!0),Tr();for(let v=0;v0){A=(A+1)%2;const U=T[A];O.bind(U),Zi(R,!0,E),R=U.texture}if(n>0){A=(A+1)%2;const U=T[A];O.bind(U),Zi(R,!1,F),R=U.texture}}if(Ce(),x!==1||y!==1){const v=we(f,b,!1);O.bind(v),O.setTransform(1/x,0,0,1/y,0,0),$e(R,!0),Nn(w,R.width,R.height),xe(w),R=v.texture,be(T[0]),be(T[1]),be(v,!1)}else A=(A+1)%2,be(T[A]),A=(A+1)%2,be(T[A],!1);return i&&O.bind(i),R},_f=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[5]; - -in vec2 v_coord; -out vec4 o_color; - -void main() { - mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]); - vec4 add = u_mediump[4]; - - vec4 color = texture(u_texture, v_coord); - - color.rgb /= max(0.0001, color.a); - color = clamp(color * mul + add, 0.0, 1.0); - color.rgb *= color.a; - - o_color = color; -}\`,Vf=()=>{if(De.has("m"))return De.get("m");const e=new _e(Zt(),_f());return De.set("m",e),e},Df=(t,e)=>{const r=t.mediump;r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[5],r[5]=e[6],r[6]=e[7],r[7]=e[8],r[8]=e[10],r[9]=e[11],r[10]=e[12],r[11]=e[13],r[12]=e[15],r[13]=e[16],r[14]=e[17],r[15]=e[18],r[16]=e[4]/255,r[17]=e[9]/255,r[18]=e[14]/255,r[19]=e[19]/255},Ji=(t,e)=>{const r=O.currentAttachmentObject,n=we(t.width,t.height,!1);O.bind(n),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t),Ce();const s=Vf();Df(s,e),xe(s);const o=n.texture;return ae(t),be(n,!1),r&&O.bind(r),o},Nf=(t,e,r=!1)=>{Ke(2,p.TEXTURE2,e,r),Ke(1,p.TEXTURE1,null),Ke(0,p.TEXTURE0,t,r)},zf=(t,e,r,n=!1)=>{Ke(2,p.TEXTURE2,r,n),Ke(1,p.TEXTURE1,e,n),Ke(0,p.TEXTURE0,t,n)},Xf=()=>{Ft!==670&&(_t(670),p.blendFunc(p.DST_ALPHA,p.ZERO))},Yf=()=>{Ft!==673&&(_t(673),p.blendFunc(p.DST_ALPHA,p.ONE_MINUS_SRC_ALPHA))},Wf=t=>\` - vec2 base_scale = u_mediump[\${t}].xy; - vec2 base_offset = u_mediump[\${t}].zw; - - vec2 uv = v_coord * base_scale - base_offset; - vec4 base = mix(vec4(0.0), texture(u_textures[1], uv), isInside(uv)); -\`,jf=()=>\` - vec4 blur = texture(u_textures[0], v_coord); -\`,Hf=t=>\` - vec2 blur_scale = u_mediump[\${t}].xy; - vec2 blur_offset = u_mediump[\${t}].zw; - - vec2 st = v_coord * blur_scale - blur_offset; - vec4 blur = mix(vec4(0.0), texture(u_textures[0], st), isInside(st)); -\`,Kf=t=>{const e=Math.floor(t/4),r=t%4;return\` - float strength = u_mediump[\${e}][\${r}]; - blur.a = clamp(blur.a * strength, 0.0, 1.0); -\`},qf=t=>\` - vec4 color = u_mediump[\${t}]; - blur = color * blur.a; -\`,Qf=t=>\` - blur = texture(u_textures[\${t?2:1}], vec2(blur.a, 0.5)); -\`,ea=(t,e,r,n,s,o)=>{const i=t?"blur.a = 1.0 - blur.a;":"",l=r?Kf(o):"",c=n?Qf(e):qf(s);return\` - \${i} - \${l} - \${c} -\`},Zf=()=>\` - vec4 blur2 = texture(u_textures[0], 1.0 - v_coord); -\`,Jf=()=>\` - vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset; - vec4 blur2 = mix(vec4(0.0), texture(u_textures[0], pq), isInside(pq)); -\`,eh=t=>{const e=Math.floor(t/4),r=t%4;return\` - float strength = u_mediump[\${e}][\${r}]; - highlight_alpha *= strength; - shadow_alpha *= strength; -\`},th=t=>\` - vec4 highlight_color = u_mediump[\${t}]; - vec4 shadow_color = u_mediump[\${t+1}]; - blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha; -\`,rh=t=>\` - blur = texture(u_textures[\${t?2:1}], vec2( - 0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha, - 0.5 - )); -\`,nh=(t,e,r,n,s,o,i,l,c)=>{let u=0;const a=r?Wf(u++):"",h=n?Hf(u++):jf(),d=o==="inner",g=u;let m=u*4,f;c?f=s?ea(!1,r,l,c,g,m):ta(r,n,l,c,g,m):s?(m+=4,f=ea(d,r,l,c,g,m)):(m+=8,f=ta(r,n,l,c,g,m));let b;switch(o){case"outer":b=i?"blur - blur * base.a":"base + blur - blur * base.a";break;case"full":b=i?"blur":"base - base * blur.a + blur";break;default:b="blur";break}return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[\${t}]; -uniform vec4 u_mediump[\${e}]; - -in vec2 v_coord; -out vec4 o_color; - -\${Ws()} - -void main() { - \${a} - \${h} - \${f} - o_color = \${b}; -}\`},ta=(t,e,r,n,s,o)=>{const i=e?Jf():Zf(),l=r?eh(o):"",c=n?rh(t):th(s);return\` - \${i} - float highlight_alpha = blur.a - blur2.a; - float shadow_alpha = blur2.a - blur.a; - \${l} - highlight_alpha = clamp(highlight_alpha, 0.0, 1.0); - shadow_alpha = clamp(shadow_alpha, 0.0, 1.0); - \${c} -\`},sh=(t,e,r,n,s,o,i)=>{const g=\`f\${t?"y":"n"}\${e?"y":"n"}\${r?"y":"n"}\${n}\${s?"y":"n"}\${o?"y":"n"}\${i?"y":"n"}\`;if(De.has(g))return De.get(g);let m=1;t&&m++,i&&m++;let f=(t?4:0)+(e?4:0)+(o?1:0);i||(f+=r?4:8),f=Math.ceil(f/4);const b=new _e(Zt(),nh(m,f,t,e,r,n,s,o,i));return De.set(g,b),b},oh=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b,x,y,P,S,M,$,T,w)=>{let E;M?(E=t.textures,E[0]=0,E[1]=1,w&&(E[2]=2)):w&&(E=t.textures,E[0]=0,E[1]=2);const F=t.mediump;let A=0;M&&(F[A++]=e/n,F[A++]=r/s,F[A++]=o/n,F[A++]=(r-s-i)/s),$&&(F[A++]=e/l,F[A++]=r/c,F[A++]=u/l,F[A++]=(r-c-a)/c),w||(h?(F[A++]=g,F[A++]=m,F[A++]=f,F[A++]=b):(F[A++]=g,F[A++]=m,F[A++]=f,F[A++]=b,F[A++]=x,F[A++]=y,F[A++]=P,F[A++]=S)),T&&(F[A]=d)},ih=16,zn=new Map,Dt=[],ah=(t,e)=>{const r=Dt.indexOf(t);for(r!==-1&&Dt.splice(r,1);zn.size>=ih&&Dt.length>0;){const n=Dt.shift();n&&zn.delete(n)}zn.set(t,e),Dt.push(t)},ch=t=>{const e=zn.get(t);if(e){const r=Dt.indexOf(t);r!==-1&&(Dt.splice(r,1),Dt.push(t))}return e},lh=(t,e,r)=>{let n="";for(let o=1;o{const s=\`l\${("00"+t).slice(-3)}\${e?"y":"n"}\`,o=ch(s);if(o)return o;const i=Math.ceil(t*5/4),l=new _e(Zt(),lh(i,t,e));return ah(s,l),l},uh=(t,e,r,n,s,o)=>{const i=t.mediump;let l=0;for(let c=s;c>16)/255,i[l++]=(u>>8&255)/255,i[l++]=(u&255)/255,i[l++]=n[c]}for(let c=s;c{const r=Un();return Pt(r),p.bindBuffer(p.ARRAY_BUFFER,r.vertexBuffer),tt[0]=t,tt[2]=t,tt[4]=e,tt[6]=e,p.bufferData(p.ARRAY_BUFFER,tt,p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),r};let Qs;const hh=(t,e)=>(Qs?(tt[0]!==t||tt[4]!==e)&&(tt[0]=t,tt[2]=t,tt[4]=e,tt[6]=e,p.bufferSubData(p.ARRAY_BUFFER,0,tt)):Qs=fh(t,e),Qs),na=(t,e,r)=>{t.useProgram(),t.bindUniform(),Pt(hh(e,r)),p.drawArrays(p.TRIANGLE_STRIP,0,4)},Zs=new Map,dh=t=>t<=4?256:t<=8?512:1024,sa=t=>{if(!Zs.has(t)){const e=we(t,1,!1);Zs.set(t,e)}return Zs.get(t)},ph=()=>sa(512);let oa=0;const ia=()=>oa,mh=t=>{oa=Math.floor(t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS)*.75)},aa=new Float32Array(256),ca=new Float32Array(256);for(let t=0;t<256;++t){const e=t/255;aa[t]=Math.pow(e,2.23333333),ca[t]=e}const gh=(t,e,r)=>{const n=O.currentAttachmentObject,s=ph();O.bind(s);const o=t.length;Tr();const i=ia();for(let l=0;l{const A=O.currentAttachmentObject,R=we(r,n,!1);O.bind(R);const v=g==="inner",U=b!==null&&x!==null&&y!==null;let L=null;if(U&&(L=gh(b,x,y)),v){O.reset(),O.setTransform(1,0,0,1,0,0),$e(t,!0);const _=Jt();wt(_,t.width,t.height),xe(_),U&&L?Nf(e,L,!0):$e(e,!0)}else U&&L?zf(e,t,L,!0):_n(e,t,!0);const D=!(v||g==="full"&&m),G=!(r===c&&n===u&&a===0&&h===0),B=f!==1;v?m?Xf():Yf():Tr();const z=sh(D,G,d,g,m,B,U);oh(z,r,n,s,o,i,l,c,u,a,h,d,f,P,S,M,$,T,w,E,F,D,G,B,U),xe(z);const k=R.texture;return be(R,!1),Ce(),A&&O.bind(A),k},la=(t,e,r=0,n=1,s=4,o=4,i=1,l=1,c=!1,u=!1)=>{const a=O.currentAttachmentObject,h=t.width,d=t.height,g=re.x,m=re.y,f=tr(t,e,s,o,l,!1),b=f.width,x=f.height,y=re.x,P=re.y,S=c?h:b,M=c?d:x,$=y-g,T=P-m,w=c?0:$,E=c?0:T,F=c?-$:0,A=c?-T:0,v=an(t,f,S,M,h,d,w,E,b,x,F,A,!0,c?"inner":"outer",u,i,null,null,null,Br(r,n,!0),Pr(r,n,!0),Ar(r,n,!0),n,0,0,0,0);return ae(t),ae(f),a&&O.bind(a),v},bh=Math.PI/180,ua=(t,e,r=4,n=45,s=0,o=1,i=4,l=4,c=1,u=1,a=!1,h=!1,d=!1)=>{const g=O.currentAttachmentObject,m=t.width,f=t.height,b=re.x,x=re.y,y=tr(t,e,i,l,u,!1),P=y.width,S=y.height,M=re.x,$=re.y,T=M-b,w=$-x,E=Math.sqrt(e[0]*e[0]+e[1]*e[1]),F=Math.sqrt(e[2]*e[2]+e[3]*e[3]),A=vt,R=n*bh,v=Math.cos(R)*r*(E/A),U=Math.sin(R)*r*(F/A),L=a?m:P+Math.max(0,Math.abs(v)-T),D=a?f:S+Math.max(0,Math.abs(U)-w),G=Math.ceil(L),B=Math.ceil(D),z=(G-L)/2,k=(B-D)/2,_=a?0:Math.max(0,T-v)+z,I=a?0:Math.max(0,w-U)+k,V=a?v-M:(v>0?Math.max(0,v-T):0)+z,X=a?U-$:(U>0?Math.max(0,U-w):0)+k;let Y="",W;a?(Y="inner",W=h||d):!h&&d?(Y="full",W=!0):(Y="outer",W=h);const K=an(t,y,G,B,m,f,_,I,P,S,V,X,!0,Y,W,c,null,null,null,Br(s,o,!0),Pr(s,o,!0),Ar(s,o,!0),o,0,0,0,0);return ae(t),ae(y),g&&O.bind(g),K},xh=Math.PI/180,fa=(t,e,r=4,n=45,s=16777215,o=1,i=0,l=1,c=4,u=4,a=1,h=1,d=0,g=!1)=>{const m=t.width,f=t.height,b=re.x,x=re.y,y=Math.sqrt(e[0]*e[0]+e[1]*e[1]),P=Math.sqrt(e[2]*e[2]+e[3]*e[3]),S=vt,M=n*xh,$=Math.cos(M)*r*(y/S),T=Math.sin(M)*r*(P/S),w=O.currentAttachmentObject,E=we(m,f,!1);O.bind(E),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t);const F=Jt();wt(F,t.width,t.height),xe(F),O.setTransform(1,0,0,1,$*2,T*2),Ks(),wt(F,t.width,t.height),xe(F),Ce();const A=E.texture;w&&O.bind(w);const R=tr(A,e,c,u,h,!1);be(E);const v=R.width,U=R.height,L=Math.ceil(v+Math.abs($)*2),D=Math.ceil(U+Math.abs(T)*2);let G="";switch(d){case 0:G="full";break;case 1:G="inner";break;case 2:G="outer";break}const B=G==="inner",z=B?m:L,k=B?f:D,_=Math.abs($),I=Math.abs(T),V=(v-m)/2,X=(U-f)/2,Y=B?0:_+V,W=B?0:I+X,K=B?-V-$:_-$,q=B?-X-T:I-T,ce=an(t,R,z,k,m,f,Y,W,v,U,K,q,!1,G,g,a,null,null,null,Br(s,o,!0),Pr(s,o,!0),Ar(s,o,!0),o,Br(i,l,!0),Pr(i,l,!0),Ar(i,l,!0),l);return re.x=b+Y,re.y=x+W,ae(t),ae(R),ce},yh=Math.PI/180,ha=(t,e,r=4,n=45,s,o,i,l=4,c=4,u=1,a=1,h=0,d=!1)=>{const g=t.width,m=t.height,f=re.x,b=re.y,x=Math.sqrt(e[0]*e[0]+e[1]*e[1]),y=Math.sqrt(e[2]*e[2]+e[3]*e[3]),P=vt,S=n*yh,M=Math.cos(S)*r*(x/P),$=Math.sin(S)*r*(y/P),T=O.currentAttachmentObject,w=we(g,m,!1);O.bind(w),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t);const E=Jt();wt(E,t.width,t.height),xe(E),O.setTransform(1,0,0,1,M*2,$*2),Ks(),wt(E,t.width,t.height),xe(E),Ce();const F=w.texture;T&&O.bind(T);const A=tr(F,e,l,c,a,!1);be(w);const R=A.width,v=A.height,U=Math.ceil(R+Math.abs(M)*2),L=Math.ceil(v+Math.abs($)*2);let D="";switch(h){case 0:D="full";break;case 1:D="inner";break;case 2:D="outer";break}const G=D==="inner",B=G?g:U,z=G?m:L,k=Math.abs(M),_=Math.abs($),I=(R-g)/2,V=(v-m)/2,X=G?0:k+I,Y=G?0:_+V,W=G?-I-M:k-M,K=G?-V-$:_-$,q=an(t,A,B,z,g,m,X,Y,R,v,W,K,!1,D,d,u,i,s,o,0,0,0,0,0,0,0,0);return re.x=f+X,re.y=b+Y,ae(t),ae(A),q},vh=Math.PI/180,da=(t,e,r=4,n=45,s,o,i,l=4,c=4,u=1,a=1,h=0,d=!1)=>{const g=t.width,m=t.height,f=re.x,b=re.y,x=tr(t,e,l,c,a,!1),y=x.width,P=x.height,S=re.x,M=re.y,$=S-f,T=M-b,w=Math.sqrt(e[0]*e[0]+e[1]*e[1]),E=Math.sqrt(e[2]*e[2]+e[3]*e[3]),F=vt,A=n*vh,R=Math.cos(A)*r*(w/F),v=Math.sin(A)*r*(E/F),U=h===1,L=U?g:y+Math.max(0,Math.abs(R)-$),D=U?m:P+Math.max(0,Math.abs(v)-T),G=Math.ceil(L),B=Math.ceil(D),z=(G-L)/2,k=(B-D)/2,_=U?0:Math.max(0,$-R)+z,I=U?0:Math.max(0,T-v)+k,V=U?R-S:(R>0?Math.max(0,R-$):0)+z,X=U?v-M:(v>0?Math.max(0,v-T):0)+k;let Y="";switch(h){case 0:Y="full";break;case 1:Y="inner";break;case 2:Y="outer";break}const W=an(t,x,G,B,g,m,_,I,y,P,V,X,!0,Y,d,u,i,s,o,0,0,0,0,0,0,0,0);return re.x=f+_,re.y=b+I,ae(t),ae(x),W},Mh=(t,e,r,n,s)=>{const o=Math.floor(e*.5),i=Math.floor(r*.5),l=e*r;let c="";const u=s?1:2;for(let d=0;d{const s=("0"+t).slice(-2),o=("0"+e).slice(-2),c=\`c\${s}\${o}\${r?"y":"n"}\${n?"y":"n"}\`;if(De.has(c))return De.get(c);const u=(n?1:2)+Math.ceil(t*e/4),a=new _e(Zt(),Mh(u,t,e,r,n));return De.set(c,a),a},$h=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=t.mediump;h[0]=1/e,h[1]=1/r,h[2]=1/s,h[3]=o/255;let d=4;i||(h[d++]=l,h[d++]=c,h[d++]=u,h[d++]=a);const g=n.length;for(let m=0;m{const a=O.currentAttachmentObject,h=t.width,d=t.height,g=we(h,d,!1);O.bind(g),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t,!0),Ce();const m=Sh(e,r,i,l);$h(m,h,d,n,s,o,l,Br(c,u,!1),Pr(c,u,!1),Ar(c,u,!1),u),xe(m);const f=g.texture;return ae(t),be(g,!1),a&&O.bind(a),f},Th=(t,e,r,n)=>{let s,o,i;switch(e){case 1:s="map_color.r";break;case 2:s="map_color.g";break;case 4:s="map_color.b";break;case 8:s="map_color.a";break;default:s="0.5";break}switch(r){case 1:o="map_color.r";break;case 2:o="map_color.g";break;case 4:o="map_color.b";break;case 8:o="map_color.a";break;default:o="0.5";break}switch(n){case 0:i=\` - vec4 source_color = texture(u_textures[0], uv); -\`;break;case 3:i=\` - vec4 source_color =texture(u_textures[0], mix(v_coord, uv, step(abs(uv - vec2(0.5)), vec2(0.5)))); -\`;break;case 1:i=\` - vec4 substitute_color = u_mediump[2]; - vec4 source_color = mix(substitute_color, texture(u_textures[0], uv), isInside(uv)); -\`;break;default:i=\` - vec4 source_color = texture(u_textures[0], fract(uv)); -\`;break}return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[2]; -uniform vec4 u_mediump[\${t}]; - -in vec2 v_coord; -out vec4 o_color; - -\${Ws()} - -void main() { - vec2 uv_to_st_scale = u_mediump[0].xy; - vec2 uv_to_st_offset = u_mediump[0].zw; - vec2 scale = u_mediump[1].xy; - - vec2 st = v_coord * uv_to_st_scale - uv_to_st_offset; - vec4 map_color = texture(u_textures[1], st); - - vec2 offset = vec2(\${s}, \${o}) - 0.5; - vec2 uv = v_coord + offset * scale; - \${i} - - o_color = mix(texture(u_textures[0], v_coord), source_color, isInside(st)); -}\`},Bh=(t,e,r)=>{const n=\`d\${t}\${e}\${r}\`;if(De.has(n))return De.get(n);const s=r===1?3:2,o=new _e(Zt(),Th(s,t,e,r));return De.set(n,o),o},Ph=(t,e,r,n,s,o,i,l,c,u,a,h,d,g)=>{const m=t.textures;m[0]=0,m[1]=1;const f=t.mediump;f[0]=n/e,f[1]=s/r,f[2]=o/e,f[3]=(s-r-i)/r,f[4]=l/n,f[5]=-c/s,u===1&&(f[8]=a,f[9]=h,f[10]=d,f[11]=g)},ma=(t,e,r=0,n=0,s=0,o=0,i=0,l=0,c=0,u=0,a=2,h=0,d=0)=>{const g=O.currentAttachmentObject,m=t.width,f=t.height,b=we(m,f,!1);O.bind(b);const x=qs(r,n,e);_n(t,x);const y=Bh(i,l,a);Ph(y,r,n,r,n,s,o,c,u,a,Br(h,d,!0),Pr(h,d,!0),Ar(h,d,!0),d),Ce(),xe(y);const P=b.texture;return g&&O.bind(g),ae(t),ae(x),be(b,!1),P},Ah=(t,e,r,n)=>{const s=t.highp,o=O.$matrix;s[0]=o[0],s[1]=o[1],s[2]=o[3],s[3]=o[4],s[4]=o[6],s[5]=o[7],s[6]=r,s[7]=n,s[8]=pt,s[9]=mt;const i=t.mediump;i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7]},Xn=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=t.width,i=t.height;switch(O.globalCompositeOperation){case"normal":case"layer":case"add":case"screen":case"alpha":case"erase":case"copy":{O.bind(O.$mainAttachmentObject),O.setTransform(1,0,0,1,r,n);const l=Dn(!0);Ah(l,e,o,i),$e(t),Qi(O.globalCompositeOperation),xe(l)}break;default:{const l=Vn(r,n,o,i),c=we(o,i,!1);O.bind(c),_n(l,t);const u=Yi(O.globalCompositeOperation);qi(u,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),xe(u),O.bind(O.$mainAttachmentObject),O.reset(),O.setTransform(1,0,0,1,r,n),Ki(c.texture),ae(l),be(c)}break}s&&O.bind(s),Ce()},ga=[],Yn=t=>{t.size&&t.clear(),ga.push(t)},Fh=()=>ga.pop()||new Map,wh=(t,e,r)=>{r.clear(),t.$timerId!==null&&clearTimeout(t.$timerId);for(const n of e.values()){for(const s of n.values())s&&t.destroy(s);Yn(n)}e.clear()},Oh=(t,e)=>{if(!(!e||typeof e!="object")&&"canvas"in e){const r=e.canvas,n=r.width,s=r.height;e.clearRect(0,0,n+1,s+1),r.width=r.height=1,t.push(r)}},Eh=(t,e,r)=>{if(!t.has(e))return;const n=t.get(e);n.has(r)&&(n.delete(r),n.size||(Yn(n),t.delete(e)))},Rh=(t,e,r)=>{if(!e.has(r))return;const n=e.get(r);for(const s of n.values())t.destroy(s);e.delete(r),Yn(n)},Ch=(t,e,r)=>{const n=t.get(e)||null;return n?(n.delete("trash"),n.get(r)||null):null},Uh=(t,e,r,n,s=null)=>{e.has(r)||e.set(r,Fh());const o=e.get(r);if(s===null){if(!o.has(n))return;t.destroy(o.get(n)),o.delete(n),o.size||(e.delete(r),Yn(o));return}o.set(n,s)},Gh=(t,e,r="")=>r?t.has(e)?t.get(e).has(r):!1:t.has(e),Lh=(t,e,r)=>{let n=2166136261,s=t*100|0;return n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619),s=e*100|0,n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619),r&&(s=r*100|0,n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619)),(n>>>0)%16777216},kh=(t,e,r,n)=>{let s=2166136261,o=t*100|0;return s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=e*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=r*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=n*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),(s>>>0)%16777216},Ih=(t,e,r,n)=>{if(r.has(n))return;const s=e.get(n);s&&(s.set("trash",!0),r.set(n,s),t.$timerId!==null&&clearTimeout(t.$timerId),t.$removeCache=!1,t.$timerId=setTimeout(()=>{t.$removeCache=!0,t.$timerId=null},1e3))},_h=(t,e)=>{if(e.size){for(const[r,n]of e)n.has("trash")&&(t.removeById(r),t.$removeIds.push(+r));e.clear(),t.$removeCache=!1}};class Vh{_$pool;_$store;_$trash;$timerId;$removeCache;$removeIds;constructor(){this._$pool=[],this._$store=new Map,this._$trash=new Map,this.$timerId=null,this.$removeIds=[],this.$removeCache=!1}reset(){wh(this,this._$store,this._$trash)}destroy(e=null){Oh(this._$pool,e)}getCanvas(){return this._$pool.pop()||document.createElement("canvas")}remove(e,r){Eh(this._$store,e,r)}removeTimer(e){Ih(this,this._$store,this._$trash,e)}removeTimerScheduledCache(){_h(this,this._$trash)}removeById(e){Rh(this,this._$store,e)}getById(e){return this._$store.get(e)}get(e,r){return Ch(this._$store,e,r)}set(e,r,n=null){Uh(this,this._$store,e,r,n)}has(e,r=""){return Gh(this._$store,e,r)}generateKeys(e,r,n){return Lh(e,r,n)}generateFilterKeys(e,r,n,s){return kh(e,r,n,s)}}const ee=new Vh,ba=new Float32Array(20),Dh=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=O.currentAttachmentObject;let d=null;const g=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.sqrt(i[2]*i[2]+i[3]*i[3]),f=ee.generateFilterKeys(i[0],i[1],i[2],i[3]);let b=!1;if(ee.get(e,"fKey")===f){const S=ee.get(e,"fTexture");r?ae(S):(b=!0,d=S)}let y=0,P=0;if(b)y=ee.get(e,"offsetX"),P=ee.get(e,"offsetY");else{d=ji(t);const S=Math.atan2(i[1],i[0]),M=Math.atan2(-i[2],i[3]),$=o?g*Math.cos(S):Math.cos(S),T=o?g*Math.sin(S):Math.sin(S),w=o?-m*Math.sin(M):-Math.sin(M),E=o?m*Math.cos(M):Math.cos(M),F=dr($,T,w,E,n/2,s/2),A=dr(1,0,0,1,-t.w/2,-t.h/2),R=Zc(F,A);if(Kr(F),Kr(A),R[0]!==1||R[1]!==0||R[2]!==0||R[3]!==1){const v=we(n,s,!1);O.bind(v),O.reset(),O.setTransform(R[0],R[1],R[2],R[3],R[4],R[5]),y=R[4],P=R[5],$e(d);const U=Dn();Nn(U,d.width,d.height),xe(U),ae(d),d=v.texture,be(v,!1),h&&O.bind(h)}Kr(R),re.x=0,re.y=0;for(let v=0;a.length>v;)switch(a[v++]){case 0:d=fa(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++]);break;case 1:d=tr(d,i,a[v++],a[v++],a[v++]);break;case 2:for(let L=0;L<20;++L)ba[L]=a[v++];d=Ji(d,ba);break;case 3:{const L=a[v++],D=a[v++],G=L*D,B=a.subarray(v,v+G);v+=G,d=pa(d,L,D,B,a[v++],a[v++],!!a[v++],!!a[v++],a[v++],a[v++])}break;case 4:{const L=a[v++],D=new Uint8Array(L);D.set(a.subarray(v,v+L)),v+=L,d=ma(d,D,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++])}break;case 5:d=ua(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++],!!a[v++],!!a[v++]);break;case 6:d=la(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++],!!a[v++]);break;case 7:{const L=a[v++],D=a[v++];let G=a[v++];const B=a.subarray(v,v+G);v+=G,G=a[v++];const z=a.subarray(v,v+G);v+=G,G=a[v++];const k=a.subarray(v,v+G);v+=G,d=ha(d,i,L,D,B,z,k,a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++])}break;case 8:{const L=a[v++],D=a[v++];let G=a[v++];const B=a.subarray(v,v+G);v+=G,G=a[v++];const z=a.subarray(v,v+G);v+=G,G=a[v++];const k=a.subarray(v,v+G);v+=G,d=da(d,i,L,D,B,z,k,a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++])}break}}if(d){const S=vt,M=u[0]*(g/S),$=u[1]*(m/S);O.reset(),O.setTransform(1,0,0,1,0,0),O.globalCompositeOperation=c,Xn(d,l,-y+M+i[4],-P+$+i[5])}b||(ee.set(e,"fKey",f),ee.set(e,"fTexture",d),ee.set(e,"offsetX",y),ee.set(e,"offsetY",P)),h&&O.bind(h)},Js=[],Nh=(t,e)=>{O.drawArraysInstanced();const r=O.$mainAttachmentObject;Js.push(r);const n=we(t,e,!1);O.$mainAttachmentObject=n,O.bind(n)},xa=new Float32Array(20),zh=(t,e,r,n,s,o,i,l)=>{O.drawArraysInstanced();const c=O.$mainAttachmentObject;let u=null;if(n&&s&&o){u=Vn(0,0,c.width,c.height),O.$mainAttachmentObject=Js.pop(),be(c),O.bind(O.$mainAttachmentObject),re.x=0,re.y=0;for(let a=0;o.length>a;)switch(o[a++]){case 0:u=fa(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++]);break;case 1:u=tr(u,e,o[a++],o[a++],o[a++]);break;case 2:for(let d=0;d<20;++d)xa[d]=o[a++];u=Ji(u,xa);break;case 3:{const d=o[a++],g=o[a++],m=d*g,f=o.subarray(a,a+m);a+=m,u=pa(u,d,g,f,o[a++],o[a++],!!o[a++],!!o[a++],o[a++],o[a++])}break;case 4:{const d=o[a++],g=new Uint8Array(d);g.set(o.subarray(a,a+d)),a+=d,u=ma(u,g,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++])}break;case 5:u=ua(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++],!!o[a++],!!o[a++]);break;case 6:u=la(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++],!!o[a++]);break;case 7:{const d=o[a++],g=o[a++];let m=o[a++];const f=o.subarray(a,a+m);a+=m,m=o[a++];const b=o.subarray(a,a+m);a+=m,m=o[a++];const x=o.subarray(a,a+m);a+=m,u=ha(u,e,d,g,f,b,x,o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++])}break;case 8:{const d=o[a++],g=o[a++];let m=o[a++];const f=o.subarray(a,a+m);a+=m,m=o[a++];const b=o.subarray(a,a+m);a+=m,m=o[a++];const x=o.subarray(a,a+m);a+=m,u=da(u,e,d,g,f,b,x,o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++])}break}if(i&&(ee.set(i,"fKey",l),ee.set(i,"fTexture",u)),u){const a=Math.sqrt(e[0]*e[0]+e[1]*e[1]),h=Math.sqrt(e[2]*e[2]+e[3]*e[3]),d=vt,g=s[0]*(a/d),m=s[1]*(h/d);O.reset(),O.globalCompositeOperation=t,Xn(u,r,g+e[4],m+e[5])}}else u=Vn(0,0,c.width,c.height),O.$mainAttachmentObject=Js.pop(),be(c),O.bind(O.$mainAttachmentObject),u&&(O.reset(),O.globalCompositeOperation=t,Xn(u,r,e[4],e[5]),ae(u));O.bind(O.$mainAttachmentObject)},Xh=(t,e,r,n,s,o)=>{if(ee.get(s,"fKey")!==o)return;const l=ee.get(s,"fTexture");if(!l)return;const c=Math.sqrt(e[0]*e[0]+e[1]*e[1]),u=Math.sqrt(e[2]*e[2]+e[3]*e[3]),a=vt,h=n[0]*(c/a),d=n[1]*(u/a);O.drawArraysInstanced(),O.reset(),O.globalCompositeOperation=t,Xn(l,r,h+e[4],d+e[5])},ya=t=>{const e=Ai(t.index),r=e[0],n=e[1],s=e[2],o=e[3];e[0]=Math.min(t.x,r),e[1]=Math.min(t.y,n),e[2]=Math.max(t.x+t.w+1,s),e[3]=Math.max(t.y+t.h+1,o)},Yh=t=>{const e=\`s\${t?"y":"n"}\`;if(At.has(e))return At.get(e);const r=new _e(kn(t?9:0,!1,!1,t),Vu());return At.set(e,r),r},Wh=(t,e)=>{const r=t.highp;r[0]=e[0],r[1]=e[1],r[2]=0,r[4]=e[2],r[5]=e[3],r[6]=0,r[8]=e[4],r[9]=e[5],r[10]=1,r[12]=e[6],r[13]=e[7],r[14]=0,r[16]=e[8],r[17]=e[9],r[18]=0,r[20]=e[10],r[21]=e[11],r[22]=1,r[3]=pt,r[7]=mt,r[11]=e[12],r[15]=e[13],r[19]=e[14],r[23]=e[15],r[24]=e[16],r[25]=e[17],r[26]=e[18],r[27]=e[19],r[28]=e[20],r[29]=e[21],r[30]=e[22],r[31]=e[23],r[32]=e[24],r[33]=e[25]};let Wn=0;const va=1,Ma=2,Sa=t=>{Wn=t},jh=()=>{Wn=0};let eo=!0;const to=t=>{eo=t};let ro=!1;const no=t=>{ro=t},jn=()=>{Wn!==va&&(Sa(va),p.stencilFunc(p.ALWAYS,0,255),p.stencilOpSeparate(p.FRONT,p.KEEP,p.KEEP,p.INCR_WRAP),p.stencilOpSeparate(p.BACK,p.KEEP,p.KEEP,p.DECR_WRAP)),eo&&(to(!1),p.colorMask(!1,!1,!1,!1))},Hn=()=>{Wn!==Ma&&(Sa(Ma),p.stencilFunc(p.NOTEQUAL,0,255),p.stencilOp(p.KEEP,p.ZERO,p.ZERO)),eo||(to(!0),p.colorMask(!0,!0,!0,!0))},Kn=()=>{ro||(no(!0),p.enable(p.SAMPLE_ALPHA_TO_COVERAGE))},qn=()=>{ro&&(no(!1),p.disable(p.SAMPLE_ALPHA_TO_COVERAGE))},Hh=(t,e,r,n)=>{jn();const s=!!n,o=sn(s);n&&on(o,n),Kn(),rt(o,t,e,r),qn(),Hn();const i=Yh(s);n&&Wh(i,n),rt(i,t,e,r)},Kh=(t,e,r,n,s)=>{const o=t.mediump;let i=0;for(let l=r;l{const r=O.currentAttachmentObject,n=p.getParameter(p.SCISSOR_BOX);yt();const s=e===0,o=t.length/5,i=dh(o),l=sa(i);O.bind(l);const c=s?aa:ca;Tr();const u=ia();for(let a=0;a{const s=t?"y":"n",o=e?"y":"n",i=e&&r?"y":"n",l=\`\${n}\`;return\`\${s}\${o}\${i}\${l}\`},Qh=t=>\` - vec2 focal = vec2(u_highp[\${t}][1], 0.0); - - vec2 diff = coord - focal; - float lenDiff = length(diff); - vec2 dir = diff / lenDiff; - float b = 2.0 * dot(dir, focal); - float c = dot(focal, focal) - 1.0; - float x = (-b + sqrt(max(b * b - 4.0 * c, 0.0))) * 0.5; - - float t = lenDiff / abs(x);\`,Zh=()=>"float t = length(coord);",Jh=(t,e)=>{const r=e?Qh(t):Zh();return\` - float radius = u_highp[\${t}][0]; - vec2 coord = p / radius; - \${r} -\`},ed=t=>\` - vec2 a = u_highp[\${t}].xy; - vec2 b = u_highp[\${t}].zw; - - vec2 ab = b - a; - vec2 ap = p - a; - - float t = dot(ab, ap) / dot(ab, ab);\`,td=(t,e,r,n,s)=>{const o=r?Jh(e,n):ed(e);let i;switch(s){case 0:i="1.0 - abs(fract(t * 0.5) * 2.0 - 1.0)";break;case 1:i="fract(t)";break;default:i="clamp(t, 0.0, 1.0)";break}return\`#version 300 es -precision highp float; - -uniform sampler2D u_texture; -uniform vec4 u_highp[\${t}]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 p = v_uv; - \${o} - t = \${i}; - o_color = texture(u_texture, vec2(t, 0.5)); -}\`},Ta=(t,e,r,n)=>{const s=qh(n,t,e,r);if(so.has(s))return so.get(s);const o=(n?14:5)+1,i=o-1,l=new _e(kn(o,!0,!1,n),td(o,i,t,e,r));return so.set(s,l),l},Ba=(t,e,r,n,s=0,o=null,i=null)=>{const l=t.highp;l[0]=r[0],l[1]=r[1],l[2]=r[2],l[4]=r[3],l[5]=r[4],l[6]=r[5],l[8]=r[6],l[9]=r[7],l[10]=r[8],l[12]=n[0],l[13]=n[1],l[14]=n[2],l[16]=n[3],l[17]=n[4],l[18]=n[5],l[11]=n[6],l[15]=n[7],l[19]=n[8],l[3]=pt,l[7]=mt;let c=20;i&&(l[20]=i[0],l[21]=i[1],l[22]=0,l[24]=i[2],l[25]=i[3],l[26]=0,l[28]=i[4],l[29]=i[5],l[30]=1,l[32]=i[6],l[33]=i[7],l[34]=0,l[36]=i[8],l[37]=i[9],l[38]=0,l[40]=i[10],l[41]=i[11],l[42]=1,l[31]=i[12],l[35]=i[13],l[39]=i[14],l[43]=i[15],l[44]=i[16],l[45]=i[17],l[46]=i[18],l[47]=i[19],l[48]=i[20],l[49]=i[21],l[50]=i[22],l[51]=i[23],l[52]=i[24],l[53]=i[25],c=56),e===0?(l[c++]=o[0],l[c++]=o[1],l[c++]=o[2],l[c]=o[3]):(l[c++]=819.2,l[c]=jr(s,-.975,.975,0))},Qn=()=>{jh(),to(!0),no(!1)},rd=(t,e,r,n)=>{const s=qe.shift(),o=qe.shift(),i=qe.shift(),l=qe.shift();Qn(),Wr();const c=$a(s,l);$e(c),Yr(),p.stencilMask(255),jn();const u=!!n,a=sn(u);n&&on(a,n),Kn(),rt(a,t,e,r),qn(),Hn();const h=Ta(!1,!1,i,u),d=qc(o),g=ys(O.$matrix);Ba(h,0,O.$matrix,g,0,d,n),di(d),Kr(g),rt(h,t,e,r)},nd=(t,e,r,n)=>{const s=qe.shift(),o=qe.shift(),i=qe.shift(),l=qe.shift(),c=qe.shift();Qn(),Wr();const u=$a(s,l);$e(u),Yr(),p.stencilMask(255),jn();const a=!!n,h=sn(a);n&&on(h,n),Kn(),rt(h,t,e,r),qn(),Hn(),O.save(),O.transform(o[0],o[1],o[2],o[3],o[4],o[5]);const d=O.$stack[O.$stack.length-1],g=ys(O.$matrix),m=Ta(!0,!!c,i,a);Ba(m,1,d,g,c,n),O.restore(),Kr(g),rt(m,t,e,r)},oo=new Map,sd=(t,e)=>{const r=\`b\${t?"y":"n"}\${e?"y":"n"}\`;if(oo.has(r))return oo.get(r);const n=t?Nu():Du(),s=new _e(kn(e?14:5,!0,!1,e),n);return oo.set(r,s),s},od=(t,e,r,n)=>{const s=t.highp,o=O.$stack[O.$stack.length-1];s[0]=o[0],s[1]=o[1],s[2]=o[2],s[4]=o[3],s[5]=o[4],s[6]=o[5],s[8]=o[6],s[9]=o[7],s[10]=o[8];const i=ys(O.$matrix);s[12]=i[0],s[13]=i[1],s[14]=i[2],s[16]=i[3],s[17]=i[4],s[18]=i[5],s[11]=i[6],s[15]=i[7],s[19]=i[8],s[3]=pt,s[7]=mt,n&&(s[20]=n[0],s[21]=n[1],s[22]=0,s[24]=n[2],s[25]=n[3],s[26]=0,s[28]=n[4],s[29]=n[5],s[30]=1,s[32]=n[6],s[33]=n[7],s[34]=0,s[36]=n[8],s[37]=n[9],s[38]=0,s[40]=n[10],s[41]=n[11],s[42]=1,s[31]=n[12],s[35]=n[13],s[39]=n[14],s[43]=n[15],s[44]=n[16],s[45]=n[17],s[46]=n[18],s[47]=n[19],s[48]=n[20],s[49]=n[21],s[50]=n[22],s[51]=n[23],s[52]=n[24],s[53]=n[25]);const l=t.mediump;l[0]=e,l[1]=r},id=(t,e,r,n)=>{jn();const s=!!n,o=sn(s);n&&on(o,n),Kn(),rt(o,t,e,r),qn();const i=Vt.shift(),l=Vt.shift(),c=Vt.shift(),u=Vt.shift(),a=Vt.shift(),h=Vt.shift(),d=qs(c,u,i,h);O.save(),O.transform(l[0],l[1],l[2],l[3],l[4],l[5]),Hn();const g=sd(a,s);od(g,c,u,n),rt(g,t,e,r),O.restore(),ae(d)},ad=()=>{const t=Ii();Yr(),p.stencilMask(255),Qn();let e=0,r=null;for(let n=0;n{const r=Hi(0,0,t,e);$e(r),p.bindFramebuffer(p.FRAMEBUFFER,Si),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,r.resource,0);const n=new Uint8Array(t*e*4),s=O.$mainAttachmentObject;n.byteLength>io&&(io=Fn(n.byteLength),p.bufferData(p.PIXEL_PACK_BUFFER,io,p.STREAM_READ)),p.readPixels(0,s.height-e,t,e,p.RGBA,p.UNSIGNED_BYTE,0);const o=p.fenceSync(p.SYNC_GPU_COMMANDS_COMPLETE,0);await new Promise(i=>{const l=()=>{if(p.clientWaitSync(o,p.SYNC_FLUSH_COMMANDS_BIT,0)===p.TIMEOUT_EXPIRED){requestAnimationFrame(l);return}return p.deleteSync(o),p.getBufferSubData(p.PIXEL_PACK_BUFFER,0,n),i()};l()}),p.bindFramebuffer(p.FRAMEBUFFER,Tt);for(let i=0;i0?le.float32Array4Pool.pop():new Float32Array(4)}static poolFloat32Array4(e){e.length===4&&le.float32Array4Pool.push(e)}}let st=null;const ud=t=>{st=t},fd=()=>le.getFloat32Array4(),hd=t=>{le.poolFloat32Array4(t)},dd=(t,e,r,n)=>{const s=n.x-t.x,o=n.y-t.y,i=s*s+o*o;if(i<1e-10){const h=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y),d=(r.x-t.x)*(r.x-t.x)+(r.y-t.y)*(r.y-t.y);return Math.max(h,d)}const l=(e.x-t.x)*o-(e.y-t.y)*s,c=l*l/i,u=(r.x-t.x)*o-(r.y-t.y)*s,a=u*u/i;return Math.max(c,a)},pd=(t,e,r,n)=>{const s={x:(t.x+e.x)*.5,y:(t.y+e.y)*.5},o={x:(e.x+r.x)*.5,y:(e.y+r.y)*.5},i={x:(r.x+n.x)*.5,y:(r.y+n.y)*.5},l={x:(s.x+o.x)*.5,y:(s.y+o.y)*.5},c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5},u={x:(l.x+c.x)*.5,y:(l.y+c.y)*.5};return{first:[t,s,l,u],second:[u,c,i,n]}},Aa=.25,md=8,gd=(t,e,r,n,s=Aa)=>{const o=[],i=(l,c,u,a,h)=>{if(dd(l,c,u,a)<=s||h>=md){const m={x:(c.x+u.x)*.5,y:(c.y+u.y)*.5};o.push({ctrl:m,end:a});return}const g=pd(l,c,u,a);i(g.first[0],g.first[1],g.first[2],g.first[3],h+1),i(g.second[0],g.second[1],g.second[2],g.second[3],h+1)};return i(t,e,r,n,0),o},bd=t=>{const r=Aa/(t*t);return Math.max(.0625,Math.min(4,r))};class xd{$currentPath;$vertices;$currentX;$currentY;$startX;$startY;constructor(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}beginPath(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}moveTo(e,r){this.$currentPath.length>=6&&this.$vertices.push(this.$currentPath),this.$currentPath=[e,r,!1],this.$currentX=e,this.$currentY=r,this.$startX=e,this.$startY=r}lineTo(e,r){e===this.$currentX&&r===this.$currentY||(this.$currentPath.push(e,r,!1),this.$currentX=e,this.$currentY=r)}quadraticCurveTo(e,r,n,s){this.$currentPath.push(e,r,!0),this.$currentPath.push(n,s,!1),this.$currentX=n,this.$currentY=s}$flatnessThreshold=.25;setScale(e){this.$flatnessThreshold=bd(e)}bezierCurveTo(e,r,n,s,o,i){const l={x:this.$currentX,y:this.$currentY},h=gd(l,{x:e,y:r},{x:n,y:s},{x:o,y:i},this.$flatnessThreshold);for(const d of h)this.$currentPath.push(d.ctrl.x,d.ctrl.y,!0),this.$currentPath.push(d.end.x,d.end.y,!1);this.$currentX=o,this.$currentY=i}arc(e,r,n){const s=n,o=n*.5522847498307936;this.bezierCurveTo(e+s,r+o,e+o,r+s,e,r+s),this.bezierCurveTo(e-o,r+s,e-s,r+o,e-s,r),this.bezierCurveTo(e-s,r-o,e-o,r-s,e,r-s),this.bezierCurveTo(e+o,r-s,e+s,r-o,e+s,r);const i=this.$currentPath.length;i>=3&&(this.$currentPath[i-3]=this.$startX,this.$currentPath[i-2]=this.$startY),this.$currentX=this.$startX,this.$currentY=this.$startY}closePath(){this.$currentPath.length>=3&&(this.$currentX!==this.$startX||this.$currentY!==this.$startY)&&this.$currentPath.push(this.$startX,this.$startY,!1)}get $getVertices(){const e=[...this.$vertices];return this.$currentPath.length>=9&&e.push(this.$currentPath),e}generateVertices(){const e=this.$getVertices,r=[];for(const n of e){if(n.length<9)continue;const s=[];for(let o=0;o0&&e.push(n)}if(this.$currentPath.length>=3){const r=[];for(let n=0;n0&&e.push(r)}return e}getVerticesForStroke(){const e=[...this.$vertices];return this.$currentPath.length>=6&&e.push(this.$currentPath),e}reset(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}}const yd=(t,e,r,n)=>new Float32Array([t,e,0,0,t+r,e,1,0,t,e+n,0,1,t+r,e,1,0,t+r,e+n,1,1,t,e+n,0,1]),vd=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t+1),Md=(t,e,r,n)=>{const s=vd(r),o=e.get(s);let i;return o&&o.length>0?(i=o.pop(),n&&t.queue.writeBuffer(i,0,n.buffer,n.byteOffset,n.byteLength)):n?(i=t.createBuffer({size:s,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),new Float32Array(i.getMappedRange()).set(n),i.unmap()):i=t.createBuffer({size:s,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),i},Sd=(t,e,r)=>{const n=Math.ceil(r/16)*16,s=e.get(n);return s&&s.length>0?s.pop():t.createBuffer({size:n,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})},$d=32,Fa=(t,e)=>{const r=e.size;let n=t.get(r);if(n||(n=[],t.set(r,n)),n.length>=$d){e.destroy();return}n.push(e)},Td=32,wa=(t,e)=>{const r=e.size;let n=t.get(r);if(n||(n=[],t.set(r,n)),n.length>=Td){e.destroy();return}n.push(e)},Bd=(t,e)=>t.createBuffer({size:e.size,usage:e.usage|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,label:e.label||"storage_buffer"}),Pd=(t,e,r,n)=>{const s=Math.ceil(r/256)*256;let o=null,i=1/0;for(const u of e)if(!u.inUse&&u.size>=s){const a=u.size-s;a{for(const r of t)if(r.buffer===e){r.inUse=!1;return}},Fd=(t,e,r=60)=>{for(let n=t.length-1;n>=0;n--){const s=t[n];!s.inUse&&e-s.lastUsedFrame>r&&(s.buffer.destroy(),t.splice(n,1))}},Oa=(t,e,r,n=0,s=0)=>{const o=new Uint32Array([e,r,n,s]),i=t.createBuffer({size:o.byteLength,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_DST,mappedAtCreation:!0,label:"indirect_buffer"});return new Uint32Array(i.getMappedRange()).set(o),i.unmap(),i},Ea=(t,e,r,n,s=0,o=0)=>{const i=new Uint32Array([r,n,s,o]);t.queue.writeBuffer(e,0,i)};class wd{device;buffer=null;offset=0;capacity;alignment=256;pendingDestroyBuffers=[];stagingBuffer;stagingFloat32;dirtyEnd=0;constructor(e,r=65536){this.device=e,this.capacity=r,this.stagingBuffer=new ArrayBuffer(r),this.stagingFloat32=new Float32Array(this.stagingBuffer)}resetFrame(){this.offset=0,this.dirtyEnd=0;for(const e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}getBuffer(){return this.buffer||(this.buffer=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})),this.buffer}allocate(e){this.buffer||this.getBuffer();const r=this.offset,n=e.byteLength;if(r+n>this.capacity){this.flush(),this.capacity*=2;const o=this.buffer;this.buffer=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),o&&this.pendingDestroyBuffers.push(o),this.stagingBuffer=new ArrayBuffer(this.capacity),this.stagingFloat32=new Float32Array(this.stagingBuffer)}this.stagingFloat32.set(e,r/4);const s=r+n;return s>this.dirtyEnd&&(this.dirtyEnd=s),this.offset=r+Math.ceil(n/this.alignment)*this.alignment,r}flush(){this.dirtyEnd>0&&this.buffer&&(this.device.queue.writeBuffer(this.buffer,0,this.stagingBuffer,0,this.dirtyEnd),this.dirtyEnd=0)}dispose(){this.buffer&&(this.buffer.destroy(),this.buffer=null);for(const e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}}class Od{device;vertexBuffers;uniformBuffers;vertexBufferBuckets;uniformBufferBuckets;storageBufferPool;indirectBuffer;indirectBufferPool;frameIndirectBuffers;frameNumber;unitRectBuffer;frameVertexPoolBuffers;frameUniformPoolBuffers;dynamicUniform;constructor(e){this.device=e,this.vertexBuffers=new Map,this.uniformBuffers=new Map,this.vertexBufferBuckets=new Map,this.uniformBufferBuckets=new Map,this.storageBufferPool=[],this.indirectBuffer=null,this.indirectBufferPool=[],this.frameIndirectBuffers=[],this.frameNumber=0,this.unitRectBuffer=null,this.frameVertexPoolBuffers=[],this.frameUniformPoolBuffers=[],this.dynamicUniform=new wd(e)}createVertexBuffer(e,r){const n=this.device.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0});return new Float32Array(n.getMappedRange()).set(r),n.unmap(),this.vertexBuffers.set(e,n),n}createUniformBuffer(e,r){const n=this.device.createBuffer({size:r,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return this.uniformBuffers.set(e,n),n}updateUniformBuffer(e,r){const n=this.uniformBuffers.get(e);n&&this.device.queue.writeBuffer(n,0,r.buffer,r.byteOffset,r.byteLength)}getVertexBuffer(e){return this.vertexBuffers.get(e)}getUniformBuffer(e){return this.uniformBuffers.get(e)}createRectVertices(e,r,n,s){return yd(e,r,n,s)}acquireVertexBuffer(e,r){const n=Md(this.device,this.vertexBufferBuckets,e,r);return this.frameVertexPoolBuffers.push(n),n}releaseVertexBuffer(e){Fa(this.vertexBufferBuckets,e)}acquireUniformBuffer(e){const r=Sd(this.device,this.uniformBufferBuckets,e);return this.frameUniformPoolBuffers.push(r),r}acquireAndWriteUniformBuffer(e,r){const n=r??e.byteLength,s=this.acquireUniformBuffer(n);return this.device.queue.writeBuffer(s,0,e.buffer,e.byteOffset,n),s}releaseUniformBuffer(e){wa(this.uniformBufferBuckets,e)}destroyBuffer(e){const r=this.vertexBuffers.get(e);r&&(r.destroy(),this.vertexBuffers.delete(e));const n=this.uniformBuffers.get(e);n&&(n.destroy(),this.uniformBuffers.delete(e))}dispose(){for(const e of this.vertexBuffers.values())e.destroy();this.vertexBuffers.clear();for(const e of this.uniformBuffers.values())e.destroy();this.uniformBuffers.clear();for(const e of this.vertexBufferBuckets.values())for(const r of e)r.destroy();this.vertexBufferBuckets.clear();for(const e of this.uniformBufferBuckets.values())for(const r of e)r.destroy();this.uniformBufferBuckets.clear();for(const e of this.storageBufferPool)e.buffer.destroy();this.storageBufferPool=[],this.indirectBuffer&&(this.indirectBuffer.destroy(),this.indirectBuffer=null);for(const e of this.indirectBufferPool)e.destroy();this.indirectBufferPool=[];for(const e of this.frameIndirectBuffers)e.destroy();this.frameIndirectBuffers=[],this.unitRectBuffer&&(this.unitRectBuffer.destroy(),this.unitRectBuffer=null),this.frameVertexPoolBuffers.length=0,this.frameUniformPoolBuffers.length=0,this.dynamicUniform.dispose()}getPoolStats(){let e=0;for(const n of this.vertexBufferBuckets.values())e+=n.length;let r=0;for(const n of this.uniformBufferBuckets.values())r+=n.length;return{vertexPoolSize:e,uniformPoolSize:r}}clearFrameBuffers(){for(const e of this.vertexBuffers.values())e.destroy();this.vertexBuffers.clear();for(const e of this.uniformBuffers.values())e.destroy();this.uniformBuffers.clear();for(const e of this.frameVertexPoolBuffers)Fa(this.vertexBufferBuckets,e);this.frameVertexPoolBuffers.length=0;for(const e of this.frameUniformPoolBuffers)wa(this.uniformBufferBuckets,e);this.frameUniformPoolBuffers.length=0;for(const e of this.frameIndirectBuffers)this.indirectBufferPool.push(e);this.frameIndirectBuffers.length=0,this.releaseAllStorageBuffers(),this.dynamicUniform.resetFrame(),this.frameNumber++,this.frameNumber%60===0&&Fd(this.storageBufferPool,this.frameNumber)}releaseAllStorageBuffers(){for(const e of this.storageBufferPool)e.inUse=!1}acquireStorageBuffer(e){return Pd(this.device,this.storageBufferPool,e,this.frameNumber)}releaseStorageBuffer(e){Ad(this.storageBufferPool,e)}writeStorageBuffer(e,r){this.device.queue.writeBuffer(e,0,r.buffer,r.byteOffset,r.byteLength)}getOrCreateIndirectBuffer(e,r,n=0,s=0){return this.indirectBuffer?Ea(this.device,this.indirectBuffer,e,r,n,s):this.indirectBuffer=Oa(this.device,e,r,n,s),this.indirectBuffer}createIndirectBuffer(e,r,n=0,s=0){let o=this.indirectBufferPool.pop();return o?Ea(this.device,o,e,r,n,s):o=Oa(this.device,e,r,n,s),this.frameIndirectBuffers.push(o),o}getUnitRectBuffer(){if(!this.unitRectBuffer){const e=this.createRectVertices(0,0,1,1);this.unitRectBuffer=this.device.createBuffer({size:e.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),new Float32Array(this.unitRectBuffer.getMappedRange()).set(e),this.unitRectBuffer.unmap()}return this.unitRectBuffer}getFrameNumber(){return this.frameNumber}getStoragePoolStats(){const e=this.storageBufferPool.filter(r=>r.inUse).length;return{storagePoolSize:this.storageBufferPool.length,storagePoolInUse:e}}}const Ed=(t,e)=>{const r=t.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("linear",r);const n=t.createSampler({magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("nearest",n);const s=t.createSampler({magFilter:"nearest",minFilter:"linear",mipmapFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("atlas_instanced_sampler",s);const o=t.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"repeat",addressModeV:"repeat"});e.set("repeat",o)},Rd=(t,e,r,n,s,o)=>{const i=t.createTexture({size:{width:s,height:o},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return t.queue.writeTexture({texture:i},n.buffer,{bytesPerRow:s*4,offset:n.byteOffset},{width:s,height:o}),e.set(r,i),i},Cd=(t,e,r,n)=>{const s=t.createTexture({size:{width:n.width,height:n.height},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return t.queue.copyExternalImageToTexture({source:n,flipY:!0},{texture:s,premultipliedAlpha:!0},{width:n.width,height:n.height}),e.set(r,s),s};class Ud{device;textures;samplers;constructor(e){this.device=e,this.textures=new Map,this.samplers=new Map,Ed(e,this.samplers)}createTexture(e,r,n,s="rgba8unorm"){const o=this.device.createTexture({size:{width:r,height:n},format:s,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return this.textures.set(e,o),o}createTextureFromPixels(e,r,n,s){return Rd(this.device,this.textures,e,r,n,s)}createTextureFromImageBitmap(e,r){return Cd(this.device,this.textures,e,r)}updateTexture(e,r,n,s){const o=this.textures.get(e);o&&this.device.queue.writeTexture({texture:o},r.buffer,{bytesPerRow:n*4,offset:r.byteOffset},{width:n,height:s})}getTexture(e){return this.textures.get(e)}getSampler(e){return this.samplers.get(e)}createSampler(e,r=!0){const n=this.samplers.get(e);if(n)return n;const s=this.device.createSampler({magFilter:r?"linear":"nearest",minFilter:r?"linear":"nearest",mipmapFilter:r?"linear":"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});return this.samplers.set(e,s),s}destroyTexture(e){const r=this.textures.get(e);r&&(r.destroy(),this.textures.delete(e))}dispose(){for(const e of this.textures.values())e.destroy();this.textures.clear(),this.samplers.clear()}}const Gd=(t,e,r,n,s,o,i,l,c)=>{const u=n==="atlas"||n.startsWith("atlas_"),a=u||n.startsWith("temp_")?"rgba8unorm":e,h=i||u&&ao>1,d=h?ao:1,g=t.createTexture({size:{width:s,height:o},format:a,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),m=g.createView(),f={id:c.textureId++,resource:g,view:m,width:s,height:o,area:s*o,smooth:!0};let b=null;if(h){const S=t.createTexture({size:{width:s,height:o},format:a,sampleCount:d,usage:GPUTextureUsage.RENDER_ATTACHMENT}),M=S.createView();b={id:c.textureId++,resource:S,view:M,width:s,height:o,area:s*o,smooth:!0}}let x=null,y=null;if(u||n==="main"||l){const S=t.createTexture({size:{width:s,height:o},format:"stencil8",usage:GPUTextureUsage.RENDER_ATTACHMENT}),M=S.createView();if(x={id:c.stencilId++,resource:S,view:M,width:s,height:o,area:s*o,dirty:!1},h){const $=t.createTexture({size:{width:s,height:o},format:"stencil8",sampleCount:d,usage:GPUTextureUsage.RENDER_ATTACHMENT}),T=$.createView();y={id:c.stencilId++,resource:$,view:T,width:s,height:o,area:s*o,dirty:!1}}}const P={id:c.nextId++,width:s,height:o,clipLevel:0,msaa:h,mask:l,color:null,texture:f,stencil:x,msaaTexture:b,msaaStencil:y};return r.set(n,P),P},Ld=(t,e,r)=>{for(const[n,s]of t.entries())if(s.id===r.id){t.delete(n),e.push(s);break}},cn={r:0,g:0,b:0,a:0},Zn={view:null,clearValue:cn,loadOp:"clear",storeOp:"store"},kd={colorAttachments:[Zn]},Id=(t,e=0,r=0,n=0,s=0,o="clear",i=null)=>(Zn.view=t,cn.r=e,cn.g=r,cn.b=n,cn.a=s,Zn.loadOp=o,Zn.resolveTarget=i??void 0,kd),Jn={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:"load",storeOp:"store"},co={view:null,stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},_d={colorAttachments:[Jn],depthStencilAttachment:co},Vd=(t,e,r="load",n="clear",s=null)=>(Jn.view=t,Jn.loadOp=r,Jn.resolveTarget=s??void 0,co.view=e,co.stencilLoadOp=n,_d),Dd=(t,e,r)=>\`\${t}_\${e}_\${r}\`,Nd=(t,e,r,n,s,o,i,l,c)=>{const u=Dd(r,n,s),a=e.get(u);if(a)for(let g=0;g=l){let g=1/0,m="",f=-1;for(const[b,x]of e)for(let y=0;y=0){const b=e.get(m);b[f].texture.destroy(),b.splice(f,1),b.length===0&&e.delete(m),c[0]--}}const h=t.createTexture({size:{width:r,height:n},format:s,usage:o}),d={texture:h,width:r,height:n,format:s,lastUsedFrame:i,inUse:!0};return a?a.push(d):e.set(u,[d]),c[0]++,h},zd=(t,e,r)=>{for(const n of t.values())for(let s=0;s{const s=e-r;for(const[o,i]of t){for(let l=i.length-1;l>=0;l--){const c=i[l];!c.inUse&&c.lastUsedFrame({id:t.attachmentId++,width:0,height:0,clipLevel:0,msaa:!1,mask:!1,color:null,texture:null,stencil:null,msaaTexture:null,msaaStencil:null}),qd=(t,e,r,n)=>{const s=t.createTexture({size:{width:e,height:r},format:"depth24plus-stencil8",usage:GPUTextureUsage.RENDER_ATTACHMENT});return{id:n.stencilId++,resource:s,view:s.createView(),width:e,height:r,area:e*r,dirty:!1}},Qd=(t,e,r,n,s)=>{for(let o=0;o=r&&i.height>=n)return e.splice(o,1),i.dirty=!1,i}return qd(t,r,n,s)},Zd=(t,e,r,n)=>{const s=t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST});return{resource:s,view:s.createView(),stencil:n,width:e,height:r,area:e*r,dirty:!1}},Jd=(t,e,r,n,s)=>{for(let o=0;o=r&&i.height>=n)return e.splice(o,1),i.stencil=s,i.dirty=!1,i}return Zd(t,r,n,s)},ep=(t,e,r,n,s)=>{const o=t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),i=o.createView();return{id:s.textureId++,resource:o,view:i,width:e,height:r,area:e*r,smooth:n}},tp=(t,e,r,n,s,o)=>{const i=\`\${r}x\${n}_smooth\`;if(e.has(i)){const l=e.get(i);if(l.length>0)return l.pop()}return ep(t,r,n,s,o)},rp=(t,e,r,n,s,o,i,l,c)=>{const u=e.length>0?e.pop():Kd(c);u.width=o,u.height=i,u.msaa=l,u.mask=!1,u.clipLevel=0;const a=Qd(t,s,o,i,c),h=Jd(t,n,o,i,a);u.color=h,u.stencil=a;const d=tp(t,r,o,i,!0,c);return u.texture=d,u},np=(t,e)=>{const r=\`\${e.width}x\${e.height}_\${e.smooth?"smooth":"nearest"}\`;t.has(r)||t.set(r,[]),t.get(r).push(e)},sp=(t,e,r,n,s)=>{s.texture&&(np(e,s.texture),s.texture=null),s.color&&(r.push(s.color),s.color=null),s.stencil&&(n.push(s.stencil),s.stencil=null),t.push(s)},ln={r:0,g:0,b:0,a:0},lo={view:null,loadOp:"clear",storeOp:"store",clearValue:ln},Ra={view:null,depthLoadOp:"clear",depthStoreOp:"store",depthClearValue:1,stencilLoadOp:"clear",stencilStoreOp:"store",stencilClearValue:0},uo={colorAttachments:[lo]},op=(t,e,r,n,s,o="clear")=>{const i=t.color?.view??t.texture?.view;if(!i)throw new Error("No color view available for render pass");return lo.view=i,lo.loadOp=o,ln.r=e,ln.g=r,ln.b=n,ln.a=s,t.stencil?.view?(Ra.view=t.stencil.view,uo.depthStencilAttachment=Ra):uo.depthStencilAttachment=void 0,uo};class ip{device;attachmentPool;texturePool;colorBufferPool;stencilBufferPool;idCounter;currentAttachment;constructor(e){this.device=e,this.attachmentPool=[],this.texturePool=new Map,this.colorBufferPool=[],this.stencilBufferPool=[],this.idCounter={attachmentId:0,textureId:0,stencilId:0},this.currentAttachment=null}getAttachmentObject(e,r,n=!1){return rp(this.device,this.attachmentPool,this.texturePool,this.colorBufferPool,this.stencilBufferPool,e,r,n,this.idCounter)}bindAttachment(e){this.currentAttachment=e}getCurrentAttachment(){return this.currentAttachment}get currentAttachmentObject(){return this.currentAttachment}unbindAttachment(){this.currentAttachment=null}releaseAttachment(e){sp(this.attachmentPool,this.texturePool,this.colorBufferPool,this.stencilBufferPool,e)}createRenderPassDescriptor(e,r,n,s,o,i="clear"){return op(e,r,n,s,o,i)}dispose(){for(const e of this.texturePool.values())for(const r of e)r.resource.destroy();this.texturePool.clear();for(const e of this.colorBufferPool)e.resource.destroy();this.colorBufferPool=[];for(const e of this.stencilBufferPool)e.resource.destroy();this.stencilBufferPool=[];for(const e of this.attachmentPool)e.texture&&e.texture.resource.destroy(),e.color&&e.color.resource.destroy(),e.stencil&&e.stencil.resource.destroy();this.attachmentPool=[]}}const Ca=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.bezier = input.bezier; - output.color = uniforms.color; - return output; -} -\`,Ua=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.bezier = input.bezier; - return output; -} -\`,Ga=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) color: vec4, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.color = uniforms.color; - return output; -} -\`,ap=\` -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -struct Uniforms { - viewportSize: vec2, - _padding0: vec2, - matrixCol0: vec3, - _padding1: f32, - matrixCol1: vec3, - _padding2: f32, - matrixCol2: vec3, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: Uniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrixCol0, uniforms.matrixCol1, uniforms.matrixCol2); - let transformed = matrix * vec3(input.position, 1.0); - let pos = transformed.xy; - let ndc = pos * 2.0 - 1.0; - output.position = vec4(ndc.x, -ndc.y, 0.0, 1.0); - output.bezier = input.bezier; - return output; -} -\`,La=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) texCoord: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -struct Uniforms { - matrix: mat3x3, - color: vec4, - alpha: f32, -} - -@group(0) @binding(0) var uniforms: Uniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let pos = uniforms.matrix * vec3(input.position, 1.0); - let ndc = pos.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.texCoord = input.texCoord; - let premultipliedColor = vec4( - uniforms.color.rgb * uniforms.color.a * uniforms.alpha, - uniforms.color.a * uniforms.alpha - ); - output.color = premultipliedColor; - return output; -} -\`,cp=\` -struct VertexInput { - @location(0) position: vec2, - @location(1) texCoord: vec2, -} - -struct InstanceInput { - @location(2) textureRect: vec4, - @location(3) textureDim: vec4, - @location(4) matrixTx: vec4, - @location(5) matrixScale: vec4, - @location(6) mulColor: vec4, - @location(7) addColor: vec4, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) mulColor: vec4, - @location(2) addColor: vec4, -} - -@vertex -fn main( - input: VertexInput, - instance: InstanceInput, - @builtin(instance_index) instanceIdx: u32 -) -> VertexOutput { - var output: VertexOutput; - let texX = instance.textureRect.x + input.texCoord.x * instance.textureRect.z; - let texY = instance.textureRect.y + input.texCoord.y * instance.textureRect.w; - output.texCoord = vec2(texX, texY); - var pos = vec2(input.position.x, 1.0 - input.position.y); - pos = pos * vec2(instance.textureDim.x, instance.textureDim.y); - let scale0 = instance.matrixScale.x; - let rotate0 = instance.matrixScale.y; - let scale1 = instance.matrixScale.z; - let rotate1 = instance.matrixScale.w; - let transformedX = pos.x * scale0 + pos.y * scale1 + instance.matrixTx.x; - let transformedY = pos.x * rotate0 + pos.y * rotate1 + instance.matrixTx.y; - var position = vec2(transformedX, transformedY) / vec2(instance.textureDim.z, instance.textureDim.w); - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - output.mulColor = instance.mulColor; - output.addColor = instance.addColor; - return output; -} -\`,ka=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} - -struct GradientUniforms { - inverseMatrix: mat3x3, - gradientType: f32, - focal: f32, - spread: f32, - radius: f32, - linearPoints: vec4, - color: vec4, - contextMatrix0: vec4, - contextMatrix1: vec4, - contextMatrix2: vec4, -} - -@group(0) @binding(0) var gradient: GradientUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let contextMatrix = mat3x3(gradient.contextMatrix0.xyz, gradient.contextMatrix1.xyz, gradient.contextMatrix2.xyz); - let pos = contextMatrix * vec3(input.position, 1.0); - let ndc = vec2(pos.x * 2.0 - 1.0, pos.y * 2.0 - 1.0); - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - let uvPos = gradient.inverseMatrix * vec3(input.position, 1.0); - output.v_uv = uvPos.xy; - output.bezier = input.bezier; - output.color = gradient.color; - return output; -} -\`,Ia=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, - @location(2) worldPos: vec2, -} - -struct BitmapUniforms { - bitmapMatrix: mat3x3, - width: f32, - height: f32, - repeat: f32, - _pad: f32, - color: vec4, - contextMatrix0: vec4, - contextMatrix1: vec4, - contextMatrix2: vec4, -} - -@group(0) @binding(0) var bitmap: BitmapUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(bitmap.contextMatrix0.xyz, bitmap.contextMatrix1.xyz, bitmap.contextMatrix2.xyz); - let transformedPos = matrix * vec3(input.position, 1.0); - let clipX = transformedPos.x * 2.0 - 1.0; - let clipY = (transformedPos.y * 2.0 - 1.0) * yFlipSign; - output.position = vec4(clipX, clipY, 0.0, 1.0); - output.bezier = input.bezier; - output.color = bitmap.color; - output.worldPos = input.position; - return output; -} -\`,Nt=\` -fn isInside(uv: vec2) -> f32 { - let s = step(vec2(0.0), uv) * step(uv, vec2(1.0)); - return s.x * s.y; -}\`,lp=\` - const positions = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2(-1.0, 1.0), - vec2(-1.0, 1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0) - );\`,es=\` - const vertices = array, 6>( - vec2(0.0, 0.0), - vec2(1.0, 0.0), - vec2(0.0, 1.0), - vec2(0.0, 1.0), - vec2(1.0, 0.0), - vec2(1.0, 1.0) - );\`,Be=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -}\`,fo=t=>\` -\${Be} - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${lp} - var texCoords = array, 6>( - vec2(0.0, \${t?"1.0":"0.0"}), - vec2(1.0, \${t?"1.0":"0.0"}), - vec2(0.0, \${t?"0.0":"1.0"}), - vec2(0.0, \${t?"0.0":"1.0"}), - vec2(1.0, \${t?"1.0":"0.0"}), - vec2(1.0, \${t?"0.0":"1.0"}) - ); - output.position = vec4(positions[vertexIndex], 0.0, 1.0); - output.texCoord = texCoords[vertexIndex]; - return output; -} -\`,up=fo(!0),fp=fo(!1),hp=fo(!1),dp=\` -struct VertexInput { - @location(0) position: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, -} - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let ndc = input.position * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y, 0.0, 1.0); - return output; -} -\`,pp=\` -struct PositionUniforms { - offset: vec2, - size: vec2, - viewport: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: PositionUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = vec2(vertex.x, 1.0 - vertex.y); - var position = vertex * uniforms.size + uniforms.offset; - position = position / uniforms.viewport; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - return output; -} -\`,mp=\` -struct BitmapSyncUniforms { - nodeRect: vec4, - textureSize: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: BitmapSyncUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - let pixelPos = vec2( - uniforms.nodeRect.x + vertex.x * uniforms.nodeRect.z, - uniforms.nodeRect.y + vertex.y * uniforms.nodeRect.w - ); - let ndc = pixelPos / uniforms.textureSize * 2.0 - 1.0; - output.position = vec4(ndc.x, -ndc.y, 0.0, 1.0); - output.texCoord = pixelPos / uniforms.textureSize; - return output; -} -\`,gp=\` -struct ScaleUniforms { - matrix: vec4, - translate: vec2, - srcSize: vec2, - dstSize: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: ScaleUniforms; -\`,bp=\` - var pos = vertex * uniforms.srcSize; - let a = uniforms.matrix.x; - let b = uniforms.matrix.y; - let c = uniforms.matrix.z; - let d = uniforms.matrix.w; - let tx = uniforms.translate.x; - let ty = uniforms.translate.y; - let transformedX = pos.x * a + pos.y * c + tx; - let transformedY = pos.x * b + pos.y * d + ty; - var position = vec2(transformedX, transformedY) / uniforms.dstSize; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); -\`,ho=t=>\` -\${gp} - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = \${t?"vec2(vertex.x, 1.0 - vertex.y)":"vertex"}; -\${bp} - return output; -} -\`,xp=ho(!1),yp=ho(!0),vp=ho(!1),_a=t=>\` -struct PositionUniforms { - offset: vec2, - size: vec2, - viewport: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: PositionUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = \${t?"vec2(vertex.x, 1.0 - vertex.y)":"vertex"}; - var position = vertex * uniforms.size + uniforms.offset; - position = position / uniforms.viewport; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - return output; -} -\`,Mp=_a(!1),Sp=_a(!0),$p=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let f_val = input.bezier.x * input.bezier.x - input.bezier.y; - let dx = dpdx(f_val); - let dy = dpdy(f_val); - - if (input.bezier.x == 0.5 && input.bezier.y == 0.5) { - return vec4(input.color.rgb * input.color.a, input.color.a); - } - - let dist = f_val * inverseSqrt(dx * dx + dy * dy); - let coverage = smoothstep(0.5, -0.5, dist); - - if (coverage <= 0.001) { - discard; - } - - let finalAlpha = input.color.a * min(coverage, 1.0); - return vec4(input.color.rgb * finalAlpha, finalAlpha); -} -\`,Tp=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let f_val = input.bezier.x * input.bezier.x - input.bezier.y; - let dx = dpdx(f_val); - let dy = dpdy(f_val); - let dist = f_val * inverseSqrt(dx * dx + dy * dy); - let alpha = smoothstep(0.5, -0.5, dist); - - if (alpha <= 0.001) { - discard; - } - - return vec4(0.0, 0.0, 0.0, min(alpha, 1.0)); -} -\`,Bp=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) color: vec4, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let a = input.color.a; - return vec4(input.color.r * a, input.color.g * a, input.color.b * a, a); -} -\`,Pp=\` -struct FragmentInput { - @location(0) bezier: vec2, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let px = dpdx(input.bezier); - let py = dpdy(input.bezier); - let f = (2.0 * input.bezier.x) * vec2(px.x, py.x) - vec2(px.y, py.y); - let alpha = 0.5 - (input.bezier.x * input.bezier.x - input.bezier.y) / length(f); - if (alpha <= 0.0) { - discard; - } - return vec4(min(alpha, 1.0)); -} -\`,Ap=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return input.color; -} -\`,Fp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var textureData: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let textureColor = textureSampleLevel(textureData, textureSampler, input.texCoord, 0); - return textureColor * input.color; -} -\`,wp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) mulColor: vec4, - @location(2) addColor: vec4, -} - -@group(0) @binding(0) var textureSampler: sampler; -@group(0) @binding(1) var textureData: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var src = textureSample(textureData, textureSampler, input.texCoord); - src = vec4(src.rgb / max(0.0001, src.a), src.a); - src = clamp(src * input.mulColor + input.addColor, vec4(0.0), vec4(1.0)); - src = vec4(src.rgb * src.a, src.a); - return src; -} -\`,po=\` -struct GradientUniforms { - inverseMatrix: mat3x3, - gradientType: f32, - focal: f32, - spread: f32, - radius: f32, - linearPoints: vec4, -} - -@group(0) @binding(0) var gradient: GradientUniforms; -@group(0) @binding(1) var gradientSampler: sampler; -@group(0) @binding(2) var gradientTexture: texture_2d; - -override GRADIENT_TYPE: u32 = 0u; -override SPREAD_MODE: u32 = 2u; - -fn applySpread(t: f32) -> f32 { - if (SPREAD_MODE == 0u) { - return 1.0 - abs(fract(t * 0.5) * 2.0 - 1.0); - } else if (SPREAD_MODE == 1u) { - return fract(t); - } else { - return clamp(t, 0.0, 1.0); - } -} -\`,mo=\` - var t: f32; - if (GRADIENT_TYPE == 0u) { - let a = gradient.linearPoints.xy; - let b = gradient.linearPoints.zw; - let ab = b - a; - let ap = p - a; - let dotAB = dot(ab, ab); - if (dotAB < 0.0001) { - t = 0.0; - } else { - t = dot(ab, ap) / dotAB; - } - } else { - let r = gradient.radius; - let coord = p / r; - let focalRatio = gradient.focal; - - if (abs(focalRatio) < 0.001) { - t = length(coord); - } else { - let focal = vec2(focalRatio, 0.0); - let diff = coord - focal; - let lenDiff = length(diff); - - if (lenDiff < 0.0001) { - t = 0.0; - } else { - let dir = diff / lenDiff; - - // Solve quadratic equation for unit circle intersection (a=1 since dir is normalized) - let b_coef = 2.0 * dot(dir, focal); - let c_coef = dot(focal, focal) - 1.0; - let discriminant = b_coef * b_coef - 4.0 * c_coef; - let x = (-b_coef + sqrt(max(discriminant, 0.0))) * 0.5; - t = lenDiff / abs(x); - } - } - } - t = applySpread(t); - let gradientColor = textureSampleLevel(gradientTexture, gradientSampler, vec2(t, 0.5), 0); -\`,Op=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.v_uv; -\${mo} - let result = gradientColor * input.color; - return vec4(result.rgb * result.a, result.a); -} -\`,Ep=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.v_uv; -\${mo} - return vec4(gradientColor.rgb * gradientColor.a, gradientColor.a); -} -\`,Rp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.texCoord; -\${mo} - let result = gradientColor * input.color; - return vec4(result.rgb * result.a, result.a); -} -\`,Cp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, - @location(2) worldPos: vec2, -} - -struct BitmapUniforms { - bitmapMatrix: mat3x3, - textureWidth: f32, - textureHeight: f32, - repeat: f32, - _pad: f32, -} - -@group(0) @binding(0) var uniforms: BitmapUniforms; -@group(0) @binding(1) var bitmapSampler: sampler; -@group(0) @binding(2) var bitmapTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let u = input.bezier.x; - let v = input.bezier.y; - if (abs(u - 0.5) > 0.001 || abs(v - 0.5) > 0.001) { - let d = u * u - v; - if (d > 0.0) { - discard; - } - } - let transformedPos = uniforms.bitmapMatrix * vec3(input.worldPos, 1.0); - var uv = vec2( - transformedPos.x / uniforms.textureWidth, - transformedPos.y / uniforms.textureHeight - ); - if (uniforms.repeat > 0.5) { - uv = fract(uv); - } - let bitmapColor = textureSampleLevel(bitmapTexture, bitmapSampler, uv, 0); - let alpha = bitmapColor.a * input.color.a; - return vec4(bitmapColor.rgb * input.color.a, alpha); -} -\`,Up=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - return textureSampleLevel(inputTexture, textureSampler, uv, 0); -} -\`,Gp=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = (input.texCoord - uniforms.offset) * uniforms.scale; - let clampedUv = clamp(uv, vec2(0.0), vec2(1.0)); - let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0); - let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0; - return select(vec4(0.0, 0.0, 0.0, 0.0), color, inBounds); -} -\`,Lp=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - let clampedUv = clamp(uv, vec2(0.0), vec2(1.0)); - let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0); - let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0; - return select(vec4(0.0, 0.0, 0.0, 0.0), color, inBounds); -} -\`,kp=\` -\${Be} - -struct ColorTransformUniforms { - mul: vec4, - add: vec4, -} - -@group(0) @binding(0) var ct: ColorTransformUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - color = clamp(color * ct.mul + ct.add, vec4(0.0), vec4(1.0)); - color = vec4(color.rgb * color.a, color.a); - - return color; -} -\`,Ip=\` -\${Be} - -struct YFlipCTUniforms { - scale: vec2, - offset: vec2, - mul: vec4, - add: vec4, -} - -@group(0) @binding(0) var uniforms: YFlipCTUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - var color = textureSampleLevel(inputTexture, textureSampler, uv, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - color = clamp(color * uniforms.mul + uniforms.add, vec4(0.0), vec4(1.0)); - color = vec4(color.rgb * color.a, color.a); - - return color; -} -\`,_p=\` -\${Be} - -struct ColorMatrixUniforms { - matrix: mat4x4, - offset: vec4, -} - -@group(0) @binding(0) var uniforms: ColorMatrixUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - var result = uniforms.matrix * color + uniforms.offset; - result = clamp(result, vec4(0.0), vec4(1.0)); - result = vec4(result.rgb * result.a, result.a); - - return result; -} -\`,Vp=\` -@fragment -fn main() -> @location(0) vec4 { - return vec4(0.0, 0.0, 0.0, 0.0); -} -\`,Dp=\` -\${Be} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); -} -\`,Np=\` -\${Be} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); -} -\`,zp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -struct BlendUniforms { - blendMode: f32, -} - -@group(0) @binding(1) var blend: BlendUniforms; -@group(0) @binding(2) var srcSampler: sampler; -@group(0) @binding(3) var srcTexture: texture_2d; -@group(0) @binding(4) var dstSampler: sampler; -@group(0) @binding(5) var dstTexture: texture_2d; - -fn blendNormal(src: vec4, dst: vec4) -> vec4 { - return src; -} - -fn blendMultiply(src: vec4, dst: vec4) -> vec4 { - return src * dst; -} - -fn blendScreen(src: vec4, dst: vec4) -> vec4 { - return src + dst - src * dst; -} - -fn blendAdd(src: vec4, dst: vec4) -> vec4 { - return min(src + dst, vec4(1.0)); -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let src = textureSampleLevel(srcTexture, srcSampler, input.texCoord, 0); - let dst = textureSampleLevel(dstTexture, dstSampler, input.texCoord, 0); - var result: vec4; - if (blend.blendMode < 0.5) { - result = blendNormal(src, dst); - } else if (blend.blendMode < 1.5) { - result = blendMultiply(src, dst); - } else if (blend.blendMode < 2.5) { - result = blendScreen(src, dst); - } else { - result = blendAdd(src, dst); - } - return result * input.color; -} -\`,Xp=\` -\${Be} - -override IS_INNER: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GlowUniforms { - color: vec4, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: GlowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blurColor = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - var rawAlpha = blurColor.a; - if (IS_INNER == 1u) { - rawAlpha = 1.0 - rawAlpha; - } - let glowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0); - let glowColor = vec4(uniforms.color.rgb * glowAlpha, uniforms.color.a * glowAlpha); - if (IS_INNER == 1u) { - let innerGlow = glowColor * baseColor.a; - if (IS_KNOCKOUT == 1u) { - return innerGlow; - } else { - return innerGlow + baseColor * (1.0 - glowColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - return glowColor * (1.0 - baseColor.a); - } else { - return baseColor + glowColor * (1.0 - baseColor.a); - } - } -} -\`,Yp=\` -\${Be} - -override IS_INNER: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; -override IS_HIDE_OBJECT: u32 = 0u; - -struct DropShadowUniforms { - color: vec4, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: DropShadowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - var rawAlpha = blur.a; - if (IS_INNER == 1u) { - rawAlpha = 1.0 - rawAlpha; - } - let shadowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0); - let shadowColor = vec4(uniforms.color.rgb * shadowAlpha, uniforms.color.a * shadowAlpha); - - if (IS_INNER == 1u) { - let innerShadow = shadowColor * baseColor.a; - if (IS_KNOCKOUT == 1u) { - return innerShadow; - } else { - return innerShadow + baseColor * (1.0 - shadowColor.a); - } - } else { - if (IS_HIDE_OBJECT == 1u) { - return shadowColor; - } else if (IS_KNOCKOUT == 1u) { - return shadowColor * (1.0 - baseColor.a); - } else { - return shadowColor * (1.0 - baseColor.a) + baseColor; - } - } -} -\`,Wp=\` -\${Be} - -override GLOW_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GradientGlowUniforms { - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: GradientGlowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -@group(0) @binding(4) var gradientLUT: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - var blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - blur.a = clamp(blur.a * uniforms.strength, 0.0, 1.0); - let glowColor = textureSampleLevel(gradientLUT, textureSampler, vec2(blur.a, 0.5), 0); - var result: vec4; - if (GLOW_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = glowColor; - } else { - result = base - base * glowColor.a + glowColor; - } - } else if (GLOW_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = glowColor * base.a; - } else { - result = glowColor * base.a + base * (1.0 - glowColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = glowColor - glowColor * base.a; - } else { - result = base + glowColor - glowColor * base.a; - } - } - return result; -} -\`,jp=\` -\${Be} - -override BEVEL_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GradientBevelUniforms { - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: GradientBevelUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -@group(0) @binding(4) var gradientLUT: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset; - let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV); - - var highlightAlpha = blur1.a - blur2.a; - var shadowAlpha = blur2.a - blur1.a; - highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0); - shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0); - - let lutCoord = 0.5019607843137255 - 0.5019607843137255 * shadowAlpha + 0.4980392156862745 * highlightAlpha; - let bevelColor = textureSampleLevel(gradientLUT, textureSampler, vec2(lutCoord, 0.5), 0); - - var result: vec4; - if (BEVEL_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor; - } else { - result = base - base * bevelColor.a + bevelColor; - } - } else if (BEVEL_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor * base.a; - } else { - result = bevelColor * base.a + base * (1.0 - bevelColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = bevelColor - bevelColor * base.a; - } else { - result = base + bevelColor - bevelColor * base.a; - } - } - - return result; -} -\`,Hp=\` -\${Be} - -override BEVEL_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct BevelUniforms { - highlightColor: vec4, - shadowColor: vec4, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: BevelUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset; - let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV); - - var highlightAlpha = blur1.a - blur2.a; - var shadowAlpha = blur2.a - blur1.a; - highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0); - shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0); - - let bevelColor = uniforms.highlightColor * highlightAlpha + uniforms.shadowColor * shadowAlpha; - var result: vec4; - if (BEVEL_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor; - } else { - result = base - base * bevelColor.a + bevelColor; - } - } else if (BEVEL_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor * base.a; - } else { - result = bevelColor * base.a + base * (1.0 - bevelColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = bevelColor - bevelColor * base.a; - } else { - result = base + bevelColor - bevelColor * base.a; - } - } - - return result; -} -\`,Kp=\` -\${Be} - -struct BevelBaseUniforms { - offset: vec2, - _padding: vec2, -} - -@group(0) @binding(0) var uniforms: BevelBaseUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var sourceTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let original = textureSampleLevel(sourceTexture, textureSampler, input.texCoord, 0); - let shiftedUV = input.texCoord - uniforms.offset; - let shifted = textureSampleLevel(sourceTexture, textureSampler, shiftedUV, 0) * isInside(shiftedUV); - return original * (1.0 - shifted.a); -} -\`;class N{static getFillVertexShader(){return Ca}static getFillMainVertexShader(){return Ca}static getFillFragmentShader(){return $p}static getStencilWriteVertexShader(){return Ua}static getStencilWriteMainVertexShader(){return Ua}static getStencilWriteFragmentShader(){return Tp}static getStencilFillVertexShader(){return Ga}static getStencilFillMainVertexShader(){return Ga}static getStencilFillFragmentShader(){return Bp}static getMaskVertexShader(){return ap}static getMaskFragmentShader(){return Pp}static getBasicVertexShader(){return La}static getBasicMainVertexShader(){return La}static getBasicFragmentShader(){return Ap}static getTextureFragmentShader(){return Fp}static getInstancedVertexShader(){return cp}static getInstancedFragmentShader(){return wp}static getGradientFillVertexShader(){return ka}static getGradientFillMainVertexShader(){return ka}static getGradientFillFragmentShader(){return Op}static getGradientFillStencilFragmentShader(){return Ep}static getGradientFragmentShader(){return Rp}static getBitmapFillVertexShader(){return Ia}static getBitmapFillMainVertexShader(){return Ia}static getBitmapFillFragmentShader(){return Cp}static getBlendFragmentShader(){return zp}static getBlurFilterVertexShader(){return up}static getBitmapSyncVertexShader(){return mp}static getBitmapSyncFragmentShader(){return Np}static getBlurFilterFragmentShader(e){const r=e.toFixed(1);return\` -\${Be} - -struct BlurUniforms { - offset: vec2, - fraction: f32, - samples: f32, -} - -@group(0) @binding(0) var uniforms: BlurUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let offset = uniforms.offset; - let fraction = uniforms.fraction; - let samples = uniforms.samples; - var color = textureSample(inputTexture, textureSampler, input.texCoord); - for (var i: f32 = 1.0; i < \${r}; i += 1.0) { - color += textureSample(inputTexture, textureSampler, input.texCoord + offset * i); - color += textureSample(inputTexture, textureSampler, input.texCoord - offset * i); - } - color += textureSample(inputTexture, textureSampler, input.texCoord + offset * \${r}) * fraction; - color += textureSample(inputTexture, textureSampler, input.texCoord - offset * \${r}) * fraction; - color /= samples; - return color; -} -\`}static getTextureCopyFragmentShader(){return Up}static getBlurTextureCopyFragmentShader(){return Gp}static getFilterOutputFragmentShader(){return Lp}static getColorTransformFragmentShader(){return kp}static getYFlipColorTransformFragmentShader(){return Ip}static getColorMatrixFilterFragmentShader(){return _p}static getGlowFilterFragmentShader(){return Xp}static getDropShadowFilterFragmentShader(){return Yp}static getGradientGlowFilterFragmentShader(){return Wp}static getGradientBevelFilterFragmentShader(){return jp}static getBevelFilterFragmentShader(){return Hp}static getBevelBaseFragmentShader(){return Kp}static getConvolutionFilterFragmentShader(e,r,n=!0,s=!0){const o=Math.floor(e*.5),i=Math.floor(r*.5),l=e*r;let c="";for(let h=0;h, - rcpDivisor: f32, - bias: f32, - substituteColor: vec4, - matrix: array, \${Math.ceil(l/4)}>, -} - -@group(0) @binding(0) var uniforms: ConvolutionUniforms; -@group(0) @binding(1) var sourceSampler: sampler; -@group(0) @binding(2) var sourceTexture: texture_2d; - -\${Be} - -\${Nt} - -fn getMatrixWeight(index: i32) -> f32 { - let vecIndex = index / 4; - let component = index % 4; - let vec = uniforms.matrix[vecIndex]; - if (component == 0) { return vec.x; } - else if (component == 1) { return vec.y; } - else if (component == 2) { return vec.z; } - else { return vec.w; } -} - -fn getWeightedColor(i: i32, weight: f32) -> vec4 { - let rcpSize = uniforms.rcpSize; - let iDivX = i / \${e}; - let iModX = i - \${e} * iDivX; - let offset = vec2(f32(iModX - \${o}), f32(\${i} - iDivX)); - var uv = input.texCoord + offset * rcpSize; - var color = textureSample(sourceTexture, sourceSampler, uv); - color = vec4(color.rgb / max(0.0001, color.a), color.a); - \${a} - return color * weight; -} - -var input: VertexOutput; - -@vertex -fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var positions = array, 6>( - vec2(-1.0, -1.0), - vec2(1.0, -1.0), - vec2(-1.0, 1.0), - vec2(-1.0, 1.0), - vec2(1.0, -1.0), - vec2(1.0, 1.0) - ); - var texCoords = array, 6>( - vec2(0.0, 1.0), - vec2(1.0, 1.0), - vec2(0.0, 0.0), - vec2(0.0, 0.0), - vec2(1.0, 1.0), - vec2(1.0, 0.0) - ); - var output: VertexOutput; - output.position = vec4(positions[vertexIndex], 0.0, 1.0); - output.texCoord = texCoords[vertexIndex]; - return output; -} - -@fragment -fn fs_main(fragInput: VertexOutput) -> @location(0) vec4 { - input = fragInput; - let rcpDivisor = uniforms.rcpDivisor; - let bias = uniforms.bias; - var result = vec4(0.0); - \${c} - result = clamp(result * rcpDivisor + bias, vec4(0.0), vec4(1.0)); - \${u} - result = vec4(result.rgb * result.a, result.a); - return result; -} -\`}static getComplexBlendFragmentShader(){return N.getUnifiedComplexBlendFragmentShader()}static getBlendModeIndex(e){switch(e){case"subtract":return 0;case"multiply":return 1;case"lighten":return 2;case"darken":return 3;case"overlay":return 4;case"hardlight":return 5;case"difference":return 6;case"invert":return 7;default:return 1}}static getUnifiedComplexBlendFragmentShader(){return\` -\${Be} - -struct BlendUniforms { - mulColor: vec4, - addColor: vec4, - blendMode: f32, - _pad0: f32, - _pad1: f32, - _pad2: f32, -} - -@group(0) @binding(0) var uniforms: BlendUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var dstTexture: texture_2d; -@group(0) @binding(3) var srcTexture: texture_2d; - -fn blend(src: vec4, dst: vec4, mode: i32) -> vec4 { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - let a = src - src * dst.a; - let b = dst - dst * src.a; - - if (mode == 1) { - let c = src * dst; - return a + b + c; - } - - let srcRgb = src.rgb / src.a; - let dstRgb = dst.rgb / dst.a; - - var blended: vec3; - - switch (mode) { - case 0: { - blended = dstRgb - srcRgb; - } - case 2: { - blended = mix(srcRgb, dstRgb, step(srcRgb, dstRgb)); - } - case 3: { - blended = mix(srcRgb, dstRgb, step(dstRgb, srcRgb)); - } - case 4: { - let mul = srcRgb * dstRgb; - let c1 = 2.0 * mul; - let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0; - blended = mix(c1, c2, step(vec3(0.5), dstRgb)); - } - case 5: { - let mul = srcRgb * dstRgb; - let c1 = 2.0 * mul; - let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0; - blended = mix(c1, c2, step(vec3(0.5), srcRgb)); - } - case 6: { - blended = abs(srcRgb - dstRgb); - } - case 7: { - let ib = dst - dst * src.a; - let ic = vec4(src.a - dst.rgb * src.a, src.a); - return ib + ic; - } - default: { - blended = srcRgb; - } - } - - var c = vec4(blended, src.a * dst.a); - c = vec4(c.rgb * c.a, c.a); - return a + b + c; -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var dst = textureSample(dstTexture, textureSampler, input.texCoord); - var src = textureSample(srcTexture, textureSampler, input.texCoord); - let mul = uniforms.mulColor; - let add = uniforms.addColor; - if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0 - || add.x != 0.0 || add.y != 0.0 || add.z != 0.0) { - src = vec4(src.rgb / max(vec3(0.0001), vec3(src.a)), src.a); - src = clamp(src * mul + add, vec4(0.0), vec4(1.0)); - src = vec4(src.rgb * src.a, src.a); - } - return blend(src, dst, i32(uniforms.blendMode)); -} -\`}static getDisplacementMapFilterFragmentShader(e,r,n){let s,o;switch(e){case 1:s="mapColor.r";break;case 2:s="mapColor.g";break;case 4:s="mapColor.b";break;case 8:s="mapColor.a";break;default:s="0.5";break}switch(r){case 1:o="mapColor.r";break;case 2:o="mapColor.g";break;case 4:o="mapColor.b";break;case 8:o="mapColor.a";break;default:o="0.5";break}let i,l=!1;switch(n){case 0:i=\` -sourceColor = textureSample(srcTexture, textureSampler, uv); -\`;break;case 1:l=!0,i=\` -sourceColor = mix(uniforms.substituteColor, textureSample(srcTexture, textureSampler, uv), isInside(uv)); -\`;break;case 2:i=\` -sourceColor = textureSample(srcTexture, textureSampler, fract(uv)); -\`;break;case 3:i=\` -let insideUV = step(abs(uv - vec2(0.5)), vec2(0.5)); -sourceColor = textureSample(srcTexture, textureSampler, mix(input.texCoord, uv, insideUV)); -\`;break;default:i=\` -sourceColor = textureSample(srcTexture, textureSampler, fract(uv)); -\`;break}return\` -\${Be} - -\${l?\`struct DisplacementUniforms { - uvToStScale: vec2, - uvToStOffset: vec2, - scale: vec2, - padding: vec2, - substituteColor: vec4, -}\`:\`struct DisplacementUniforms { - uvToStScale: vec2, - uvToStOffset: vec2, - scale: vec2, - padding: vec2, -}\`} - -@group(0) @binding(0) var uniforms: DisplacementUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var srcTexture: texture_2d; -@group(0) @binding(3) var mapTexture: texture_2d; - -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let stCoord = vec2(input.texCoord.x, 1.0 - input.texCoord.y); - let st = stCoord * uniforms.uvToStScale - uniforms.uvToStOffset; - let mapColor = textureSample(mapTexture, textureSampler, vec2(st.x, 1.0 - st.y)); - let offset = vec2(\${s}, \${o}) - 0.5; - let uv = input.texCoord + offset * uniforms.scale; - var sourceColor: vec4; - \${i} - return mix(textureSample(srcTexture, textureSampler, input.texCoord), sourceColor, isInside(st)); -} -\`}static getNodeClearVertexShader(){return dp}static getNodeClearFragmentShader(){return Vp}static getPositionedTextureVertexShader(){return pp}static getTextureScaleVertexShader(){return xp}static getTextureScaleBlendVertexShader(){return yp}static getComplexBlendScaleVertexShader(){return vp}static getComplexBlendVertexShader(){return fp}static getComplexBlendCopyVertexShader(){return hp}static getComplexBlendOutputVertexShader(){return Mp}static getFilterComplexBlendOutputVertexShader(){return Sp}static getPositionedTextureFragmentShader(){return Dp}}const rr={arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},un={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};class qp{device;format;pipelines;bindGroupLayouts;sampleCount;shaderModuleCache=new Map;filterBindGroupLayouts=new Map;constructor(e,r){this.device=e,this.format=r,this.pipelines=new Map,this.bindGroupLayouts=new Map,this.sampleCount=ao,this.initialize()}getOrCreateShaderModule(e,r){let n=this.shaderModuleCache.get(e);return n||(n=this.device.createShaderModule({code:r}),this.shaderModuleCache.set(e,n)),n}initialize(){this.createFillPipeline(),this.createStencilFillPipelines(),this.createClipPipeline(),this.createMaskUnionPipelines(),this.createMaskPipeline(),this.createBasicPipeline(),this.createTexturePipeline(),this.createInstancedPipeline(),this.createGradientPipeline(),this.createBitmapFillPipeline(),this.createBlendPipeline(),this.createNodeClearPipeline()}lazyInitGroups=new Set;lazyGroupMap=new Map([...Array.from({length:16},(e,r)=>[\`blur_filter_\${r+1}\`,"blur_filter"]),["blur_filter","blur_filter"],["texture_copy","texture_copy"],["texture_copy_rgba8","texture_copy"],["color_transform","texture_copy"],["y_flip_color_transform","texture_copy"],["texture_erase","texture_copy"],["blur_texture_copy","texture_copy"],["filter_blend","texture_copy"],["texture_copy_bgra","texture_copy"],["filter_output","texture_copy"],["filter_output_add","texture_copy"],["filter_output_screen","texture_copy"],["filter_output_alpha","texture_copy"],["filter_output_erase","texture_copy"],["texture_copy_bgra_msaa","texture_copy"],["filter_output_msaa","texture_copy"],["filter_output_add_msaa","texture_copy"],["filter_output_screen_msaa","texture_copy"],["filter_output_alpha_msaa","texture_copy"],["filter_output_erase_msaa","texture_copy"],["positioned_texture","texture_copy"],["positioned_texture_rgba","texture_copy"],["bitmap_render_msaa","texture_copy"],["bitmap_render","texture_copy"],["texture_scale","texture_copy"],["texture_scale_blend","texture_copy"],["bitmap_sync","bitmap_sync"],["color_matrix_filter","filter"],["bevel_base","filter"],["glow_filter","filter"],["drop_shadow_filter","filter"],["bevel_filter","filter"],["gradient_glow_filter","filter"],["gradient_bevel_filter","filter"],["complex_blend","complex_blend"],["complex_blend_copy","complex_blend"],["complex_blend_scale","complex_blend"],["complex_blend_output","complex_blend"],["complex_blend_output_msaa","complex_blend"],["filter_complex_blend_output","complex_blend"],["filter_complex_blend_output_msaa","complex_blend"]]);ensureLazyGroup(e){const r=this.lazyGroupMap.get(e);if(!(!r||this.lazyInitGroups.has(r)))switch(this.lazyInitGroups.add(r),r){case"blur_filter":this.createBlurFilterPipeline();break;case"texture_copy":this.createTextureCopyPipeline();break;case"bitmap_sync":this.createBitmapSyncPipeline();break;case"filter":this.createColorMatrixFilterPipeline();break;case"complex_blend":this.createComplexBlendPipelines();break}}preloadLazyGroups(){const e=["blur_filter","texture_copy","bitmap_sync","filter","complex_blend"];for(const r of e)this.ensureLazyGroup(r)}createFillPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}}]});this.bindGroupLayouts.set("fill_dynamic",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("fillVertex",N.getFillVertexShader()),s=this.getOrCreateShaderModule("fillFragment",N.getFillFragmentShader()),o=rr,i=un,l=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}}),c=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("fill",l),this.pipelines.set("fill_bgra",c);const u=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:255,stencilWriteMask:0},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("fill_bgra_stencil",u)}createStencilFillPipelines(){const e=rr,r=this.bindGroupLayouts.get("fill_dynamic"),n=this.device.createPipelineLayout({bindGroupLayouts:[r]}),s=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write",s);const o=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill",o);const i=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write_atlas",i);const l=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:this.format,writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write_main",l);const c=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"max"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_atlas",c);const u=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:this.format,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"max"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_main",u);const a=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"greater",failOp:"keep",depthFailOp:"replace",passOp:"replace"},stencilBack:{compare:"greater",failOp:"keep",depthFailOp:"replace",passOp:"replace"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_masked",a)}createClipPipeline(){const e=rr,r=this.bindGroupLayouts.get("fill_dynamic"),n=this.device.createPipelineLayout({bindGroupLayouts:[r]}),s=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"zero",depthFailOp:"invert",passOp:"invert"},stencilBack:{compare:"always",failOp:"zero",depthFailOp:"invert",passOp:"invert"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("clip_write",s);const o=this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),i=this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader());for(let l=1;l<=8;l++){const c=1<1){const g={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}};this.pipelines.set("texture_copy_bgra_msaa",this.createFullscreenQuadPipeline(r,n,s,this.format,g,this.sampleCount));const m={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};this.pipelines.set("filter_output_msaa",this.createFullscreenQuadPipeline(r,n,h,this.format,m,this.sampleCount));for(const[f,b]of d)this.pipelines.set(\`\${f}_msaa\`,this.createFullscreenQuadPipeline(r,n,h,this.format,b,this.sampleCount))}this.createPositionedTexturePipeline(),this.createTextureScalePipeline()}createPositionedTexturePipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("positioned_texture",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("positionedTextureVertex",N.getPositionedTextureVertexShader()),s=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("positioned_texture",o);const i=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("positioned_texture_rgba",i);const l=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:4},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"}}});this.pipelines.set("bitmap_render_msaa",l);const c=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"}}});this.pipelines.set("bitmap_render",c)}createTextureScalePipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("texture_scale",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("textureScaleVertex",N.getTextureScaleVertexShader()),s=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("texture_scale",o);const i=this.getOrCreateShaderModule("textureScaleBlendVertex",N.getTextureScaleBlendVertexShader()),l=this.device.createRenderPipeline({layout:r,vertex:{module:i,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("texture_scale_blend",l)}createBitmapSyncPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});this.bindGroupLayouts.set("bitmap_sync",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("bitmapSyncVertex",N.getBitmapSyncVertexShader()),s=this.getOrCreateShaderModule("bitmapSyncFragment",N.getBitmapSyncFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:4}});this.pipelines.set("bitmap_sync",o)}createColorMatrixFilterPipeline(){const e={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},r={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};this.createFilterPipelineWithLayout("color_matrix_filter",N.getColorMatrixFilterFragmentShader(),1,e),this.createFilterPipelineWithLayout("bevel_base",N.getBevelBaseFragmentShader(),1,e),this.createFilterPipelineWithLayout("glow_filter",N.getGlowFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("drop_shadow_filter",N.getDropShadowFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("bevel_filter",N.getBevelFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("gradient_glow_filter",N.getGradientGlowFilterFragmentShader(),3,r),this.createFilterPipelineWithLayout("gradient_bevel_filter",N.getGradientBevelFilterFragmentShader(),3,r)}createComplexBlendPipelines(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("complex_blend",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("complexBlendVertex",N.getComplexBlendVertexShader()),s=this.getOrCreateShaderModule("unifiedComplexBlendFragment",N.getUnifiedComplexBlendFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("complex_blend",o),this.createComplexBlendCopyPipeline(),this.createComplexBlendOutputPipeline()}createComplexBlendCopyPipeline(){const e={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},r=this.bindGroupLayouts.get("texture_copy");if(r){const s=this.device.createPipelineLayout({bindGroupLayouts:[r]}),o=this.getOrCreateShaderModule("complexBlendCopyVertex",N.getComplexBlendCopyVertexShader()),i=this.getOrCreateShaderModule("textureCopyFragment",N.getTextureCopyFragmentShader());this.pipelines.set("complex_blend_copy",this.createFullscreenQuadPipeline(s,o,i,"rgba8unorm",e))}const n=this.bindGroupLayouts.get("texture_scale");if(n){const s=this.device.createPipelineLayout({bindGroupLayouts:[n]}),o=this.getOrCreateShaderModule("complexBlendScaleVertex",N.getComplexBlendScaleVertexShader()),i=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader());this.pipelines.set("complex_blend_scale",this.createFullscreenQuadPipeline(s,o,i,"rgba8unorm",e))}}createComplexBlendOutputPipeline(){const e=this.bindGroupLayouts.get("positioned_texture");if(!e)return;const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),s={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},o=this.getOrCreateShaderModule("complexBlendOutputVertex",N.getComplexBlendOutputVertexShader());this.pipelines.set("complex_blend_output",this.createFullscreenQuadPipeline(r,o,n,this.format,s)),this.sampleCount>1&&this.pipelines.set("complex_blend_output_msaa",this.createFullscreenQuadPipeline(r,o,n,this.format,s,this.sampleCount));const i=this.getOrCreateShaderModule("filterComplexBlendOutputVertex",N.getFilterComplexBlendOutputVertexShader());this.pipelines.set("filter_complex_blend_output",this.createFullscreenQuadPipeline(r,i,n,this.format,s)),this.sampleCount>1&&this.pipelines.set("filter_complex_blend_output_msaa",this.createFullscreenQuadPipeline(r,i,n,this.format,s,this.sampleCount))}createFilterPipelineWithLayout(e,r,n,s){let o=this.filterBindGroupLayouts.get(n);if(!o){const u=[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}}];for(let a=0;a1&&(c.multisample={count:i}),l&&(c.depthStencil=l),this.device.createRenderPipeline(c)}getPipeline(e){let r=this.pipelines.get(e);return r||(this.ensureLazyGroup(e),r=this.pipelines.get(e)),r}getFilterPipeline(e,r){const s=Object.keys(r).sort().map(h=>\`\${h}\${r[h]}\`).join("_"),o=\`\${e}_\${s}\`;let i=this.pipelines.get(o);if(i)return i;this.ensureLazyGroup(e);const l=this.shaderModuleCache.get(\`filter_\${e}\`),c=this.shaderModuleCache.get("blurFilterVertex"),u=this.bindGroupLayouts.get(e);if(!l||!c||!u)return this.pipelines.get(e);const a=this.device.createPipelineLayout({bindGroupLayouts:[u]});return i=this.device.createRenderPipeline({layout:a,vertex:{module:c,entryPoint:"main",buffers:[]},fragment:{module:l,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}],constants:r},primitive:{topology:"triangle-list",cullMode:"none"}}),this.pipelines.set(o,i),i}getGradientPipeline(e,r,n){const s=\`\${e}_t\${r}s\${n}\`;let o=this.pipelines.get(s);return o||(this.gradientPipelineLayout?(o=this.createGradientVariant(e,r,n),o?(this.pipelines.set(s,o),o):this.getPipeline(e)):this.getPipeline(e))}gradientPipelineLayout=null;gradientVertexShaderModule=null;gradientFragmentShaderModule=null;gradientStencilFragmentShaderModule=null;createGradientVariant(e,r,n){if(!this.gradientPipelineLayout)return;const s={GRADIENT_TYPE:r,SPREAD_MODE:n},o=rr,i=un,c=e.includes("stencil_atlas")||e==="gradient_fill_stencil_main"?this.gradientStencilFragmentShaderModule:this.gradientFragmentShaderModule,a=e.includes("bgra")||e==="gradient_fill_stencil_main"?this.format:"rgba8unorm",h=e.includes("bgra")||e==="gradient_fill_stencil_main",d={};h&&(d.yFlipSign=-1);let g,m=this.sampleCount;e.includes("stroke")?g={format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0}:e==="gradient_fill_stencil"||e==="gradient_fill_stencil_atlas"?g={format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255}:e==="gradient_fill_stencil_main"?(g={format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},m=1):e==="gradient_fill_bgra_stencil"?g={format:"stencil8",stencilFront:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:255,stencilWriteMask:0}:e==="gradient_fill_bgra_no_msaa"&&(m=1);const f={layout:this.gradientPipelineLayout,vertex:{module:this.gradientVertexShaderModule,entryPoint:"main",buffers:[o],constants:Object.keys(d).length>0?d:void 0},fragment:{module:c,entryPoint:"main",targets:[{format:a,blend:i}],constants:s},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:m}};return g&&(f.depthStencil=g),this.device.createRenderPipeline(f)}getBindGroupLayout(e){let r=this.bindGroupLayouts.get(e);return r||(this.ensureLazyGroup(e),r=this.bindGroupLayouts.get(e)),r}createNodeClearPipeline(){const e={arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},r=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.getOrCreateShaderModule("nodeClearVertex",N.getNodeClearVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("nodeClearFragment",N.getNodeClearFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},writeMask:GPUColorWrite.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"zero",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"always",failOp:"zero",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("node_clear_atlas",r)}dispose(){this.pipelines.clear(),this.bindGroupLayouts.clear(),this.shaderModuleCache.clear(),this.filterBindGroupLayouts.clear()}}class Qp{device;pipelines;bindGroupLayouts;constructor(e){this.device=e,this.pipelines=new Map,this.bindGroupLayouts=new Map,this.initializeBlurPipelines()}initializeBlurPipelines(){const e=this.device.createBindGroupLayout({label:"blur_compute_bind_group_layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:"write-only",format:"rgba8unorm"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}]});this.bindGroupLayouts.set("blur_compute",e),this.createBlurComputePipeline("blur_compute_horizontal"),this.createBlurComputePipeline("blur_compute_vertical"),this.createBlurComputePipeline("blur_compute_shared_horizontal",!0),this.createBlurComputePipeline("blur_compute_shared_vertical",!0)}createBlurComputePipeline(e,r=!1){const n=this.device.createShaderModule({label:\`\${e}_shader\`,code:r?this.getSharedBlurComputeShaderCode():this.getBlurComputeShaderCode()}),s=this.device.createPipelineLayout({label:\`\${e}_layout\`,bindGroupLayouts:[this.bindGroupLayouts.get("blur_compute")]}),o=this.device.createComputePipeline({label:e,layout:s,compute:{module:n,entryPoint:"main"}});this.pipelines.set(e,o)}getBlurComputeShaderCode(){return\` -struct BlurParams { - direction: vec2, // (1,0) or (0,1) - radius: f32, // ブラー半径 - fraction: f32, // 端ピクセルのブレンド割合 - texSize: vec2, // テクスチャサイズ - samples: f32, // サンプル数 - padding: f32, // パディング(16バイトアライメント) -} - -@group(0) @binding(0) var inputTexture: texture_2d; -@group(0) @binding(1) var outputTexture: texture_storage_2d; -@group(0) @binding(2) var params: BlurParams; - -const WORKGROUP_SIZE: u32 = 16u; - -@compute @workgroup_size(16, 16, 1) -fn main( - @builtin(global_invocation_id) globalId: vec3 -) { - let texSize = vec2(u32(params.texSize.x), u32(params.texSize.y)); - let radius = i32(params.radius); - - let outCoord = globalId.xy; - - if (outCoord.x >= texSize.x || outCoord.y >= texSize.y) { - return; - } - - let direction = vec2(i32(params.direction.x), i32(params.direction.y)); - let samples = params.samples; - let fraction = params.fraction; - - var color = vec4(0.0); - - for (var i = -radius; i <= radius; i = i + 1) { - var sampleCoord = vec2(outCoord) + direction * i; - - sampleCoord.x = clamp(sampleCoord.x, 0, i32(texSize.x) - 1); - sampleCoord.y = clamp(sampleCoord.y, 0, i32(texSize.y) - 1); - - let sample = textureLoad(inputTexture, vec2(sampleCoord), 0); - - // 端ピクセルにfraction重みを適用(Fragment Shaderと同じロジック) - if (i == -radius || i == radius) { - color = color + sample * fraction; - } else { - color = color + sample; - } - } - - color = color / samples; - - textureStore(outputTexture, outCoord, color); -} -\`}getSharedBlurComputeShaderCode(){return\` -struct BlurParams { - direction: vec2, - radius: f32, - fraction: f32, - texSize: vec2, - samples: f32, - padding: f32, -} - -@group(0) @binding(0) var inputTexture: texture_2d; -@group(0) @binding(1) var outputTexture: texture_storage_2d; -@group(0) @binding(2) var params: BlurParams; - -const TILE: u32 = 16u; -const MAX_APRON: u32 = 24u; -const SHARED_W: u32 = TILE + 2u * MAX_APRON; - -var tile: array, 1024>; - -@compute @workgroup_size(16, 16, 1) -fn main( - @builtin(global_invocation_id) globalId: vec3, - @builtin(local_invocation_id) localId: vec3, - @builtin(workgroup_id) workgroupId: vec3 -) { - let texSize = vec2(u32(params.texSize.x), u32(params.texSize.y)); - let radius = u32(params.radius); - let apron = min(radius, MAX_APRON); - let isHorizontal = params.direction.x > 0.5; - let fraction = params.fraction; - let samples = params.samples; - - let threadIdx = localId.x + localId.y * TILE; - let totalThreads = TILE * TILE; - - if (isHorizontal) { - let sharedWidth = TILE + 2u * apron; - let baseX = workgroupId.x * TILE; - let y = globalId.y; - let clampedY = clamp(y, 0u, max(texSize.y, 1u) - 1u); - - // 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード) - var idx = threadIdx; - loop { - if (idx >= sharedWidth) { break; } - let gx = i32(baseX) + i32(idx) - i32(apron); - let cx = u32(clamp(gx, 0, i32(max(texSize.x, 1u)) - 1)); - tile[localId.y * SHARED_W + idx] = textureLoad(inputTexture, vec2(cx, clampedY), 0); - idx += totalThreads; - } - - // 全スレッドがバリアに到達(早期returnなし) - workgroupBarrier(); - - // 範囲内のスレッドのみ出力 - let outX = globalId.x; - if (outX < texSize.x && y < texSize.y) { - let iRadius = i32(radius); - var color = vec4(0.0); - for (var i = -iRadius; i <= iRadius; i = i + 1) { - let tileIdx = i32(localId.x) + i32(apron) + i; - let s = tile[localId.y * SHARED_W + u32(clamp(tileIdx, 0, i32(sharedWidth) - 1))]; - if (i == -iRadius || i == iRadius) { - color += s * fraction; - } else { - color += s; - } - } - textureStore(outputTexture, vec2(outX, y), color / samples); - } - } else { - let sharedHeight = TILE + 2u * apron; - let baseY = workgroupId.y * TILE; - let x = globalId.x; - let clampedX = clamp(x, 0u, max(texSize.x, 1u) - 1u); - - // 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード) - var idx = threadIdx; - loop { - if (idx >= sharedHeight) { break; } - let gy = i32(baseY) + i32(idx) - i32(apron); - let cy = u32(clamp(gy, 0, i32(max(texSize.y, 1u)) - 1)); - tile[idx * TILE + localId.x] = textureLoad(inputTexture, vec2(clampedX, cy), 0); - idx += totalThreads; - } - - // 全スレッドがバリアに到達(早期returnなし) - workgroupBarrier(); - - // 範囲内のスレッドのみ出力 - let outY = globalId.y; - if (x < texSize.x && outY < texSize.y) { - let iRadius = i32(radius); - var color = vec4(0.0); - for (var i = -iRadius; i <= iRadius; i = i + 1) { - let tileIdx = i32(localId.y) + i32(apron) + i; - let s = tile[u32(clamp(tileIdx, 0, i32(sharedHeight) - 1)) * TILE + localId.x]; - if (i == -iRadius || i == iRadius) { - color += s * fraction; - } else { - color += s; - } - } - textureStore(outputTexture, vec2(x, outY), color / samples); - } - } -} -\`}getPipeline(e){return this.pipelines.get(e)}getBindGroupLayout(e){return this.bindGroupLayouts.get(e)}destroy(){this.pipelines.clear(),this.bindGroupLayouts.clear()}}const Va=Number.MAX_VALUE,Da=-Number.MAX_VALUE;let Fr=0;const wr=t=>{Fr=t},Zp=()=>Fr,zt=[],Jp=t=>{zt[Fr]=t};let go=null;const em=t=>{go=t},Ne=()=>{if(!(Fr in zt))if(go){const t=go(Fr);Jp(t)}else return null;return zt[Fr]},bo=t=>t in zt?zt[t]:null,fn=[],Na=[],za=[],tm=()=>{for(let t=0;t{Xa=t},yo=()=>Xa,rm=()=>{fn.length=0,wr(0);for(let t=0;t{ts=t},sm=new Set(["normal","layer","add","screen","alpha","erase","copy"]),hn=[],vo=[],Mo=[],om=()=>hn,So=()=>{for(let t=0;t{const t="blend_instanced";return $o.has(t)||$o.set(t,new nm),$o.get(t)},im=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const d=o[0],g=o[1],m=o[2],f=h,b=o[4]/255,x=o[5]/255,y=o[6]/255,P=0;if(sm.has(l)){(ts!==l||yo()!==t.index)&&(st&&(wr(yo()),st.drawArraysInstanced()),Ya(l),xo(t.index),wr(t.index));const S=rs();Ve.pushInstanceBuffer((t.x+.5)/a,(t.y+.5)/a,(t.w-1)/a,(t.h-1)/a,t.w,t.h,c,u,i[6],i[7],0,0,i[0],i[1],i[3],i[4],d,g,m,f,b,x,y,P),S.count++}else{st&&(wr(yo()),st.drawArraysInstanced());const S=vo.length>0?vo.pop():new Float32Array(8);S.set(o);const M=Mo.length>0?Mo.pop():new Float32Array(9);M.set(i),hn.push({node:t,x_min:e,y_min:r,x_max:n,y_max:s,color_transform:S,matrix:M,blend_mode:l,viewport_width:c,viewport_height:u,render_max_size:a,global_alpha:h}),Ya(l),xo(t.index),wr(t.index)}};let To=!1;const Bo=t=>{To=t},nr=()=>To;let Po=!1,Ao=0;const Wa=t=>{Po=t},gt=()=>Po,ja=t=>{Ao=t},Or=()=>Ao,Er=new Map,Rr=new Map,am=()=>{To=!1,Po=!1,Ao=0,Er.clear(),Rr.clear()},cm=()=>{const t=st.currentAttachmentObject;t&&(t.mask=!0,t.clipLevel++,Rr.set(t.clipLevel,t.clipLevel),nr()||Bo(!0))},lm=(t,e,r,n)=>{const s=st.currentAttachmentObject;if(!s)return;const o=s.clipLevel;let i=Er.get(o);i?(i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],r),i[3]=Math.max(i[3],n)):(i=fd(),i[0]=t,i[1]=e,i[2]=r,i[3]=n,Er.set(o,i))},Ha=()=>{const t=st.currentAttachmentObject;if(!t)return;const r=(1<{const t=st.currentAttachmentObject;if(!t)return;const e=t.clipLevel,r=Er.get(e);if(r&&(Er.delete(e),hd(r)),Rr.delete(e),--t.clipLevel,!t.clipLevel){t.mask=!1,Bo(!1),Wa(!1),ja(0),t.needsStencilClear=!0,Rr.clear(),Er.clear();return}t.pendingStencilClearLevel=t.clipLevel,Ha()},fm=(t,e,r)=>{const n=t.length-5;for(let s=3;s(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),dn=t=>{let e=0;for(const o of t){const i=o.length-5;for(let l=3;l{const n=Math.sqrt(t*t+e*e);return n===0?{x:0,y:0}:{x:-(e/n)*r,y:t/n*r}},wo=(t,e,r)=>({x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}),xm=t=>{const e=Math.sqrt(t.x*t.x+t.y*t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},ym=(t,e,r,n)=>({x:(1-t)**2*e.x+2*(1-t)*t*r.x+t**2*n.x,y:(1-t)**2*e.y+2*(1-t)*t*r.y+t**2*n.y}),vm=(t,e,r,n)=>({x:2*(1-t)*(r.x-e.x)+2*t*(n.x-r.x),y:2*(1-t)*(r.y-e.y)+2*t*(n.y-r.y)}),Mm=(t,e,r,n=.5)=>{const s=wo(t,e,n),o=wo(e,r,n),i=wo(s,o,n);return[[t,s,i],[i,o,r]]},Sm=(t,e,r,n=4)=>{let s=[[t,e,r]];for(let o=0;o{const s=[0,.5,1],o=[];for(const i of s){const l=ym(i,t,e,r),c=vm(i,t,e,r),u=xm({x:-c.y,y:c.x});o.push({x:l.x+u.x*n,y:l.y+u.y*n})}return o},$m=(t,e,r,n)=>{const s=Sm(t,e,r,5),o=[],i=[];for(const h of s)o.push(Ka(h[0],h[1],h[2],+n)),i.push(Ka(h[0],h[1],h[2],-n));for(let h=0;h{const n={x:e.x-t.x,y:e.y-t.y},s=bm(n.x,n.y,r),o={x:t.x+s.x,y:t.y+s.y},i={x:e.x+s.x,y:e.y+s.y},l={x:e.x-s.x,y:e.y-s.y},c={x:t.x-s.x,y:t.y-s.y};return[o.x,o.y,!1,i.x,i.y,!1,l.x,l.y,!1,c.x,c.y,!1,o.x,o.y,!1]},Ur=(t,e,r,n)=>{const s=[];for(let i=0;i1e-4||s.push(l,c)}return s},Gr=(t,e)=>{Cr.beginPath(),Cr.moveTo(e[0],e[1]);for(let r=3;r{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=Ur(t,e,r,n[o]),c=Ur(t,e,r,n[i]);if(l[0]===c[0]&&l[1]===c[1]||l[0]===c[2]&&l[1]===c[3])return;const u=Gr(l,n[i]);if(!u)return;const a=Gr(c,n[o]);a&&n.splice(-1,0,[t,e,!1,u[0],u[1],!1,a[0],a[1],!1,t,e,!1])},Qa=(t,e,r,n,s=!1)=>{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=Ur(t,e,r,n[o]),c=Ur(t,e,r,n[i]),u=Gr(l,n[i]);if(!u)return;const a=Gr(c,n[o]);if(!a)return;const h=Math.atan2(u[1]-e,u[0]-t);let g=Math.atan2(a[1]-e,a[0]-t)-h;g>Math.PI?g-=2*Math.PI:g<-Math.PI&&(g+=2*Math.PI);const m=8,f=g/m,b=[t,e,!1];for(let x=0;x<=m;x++){const y=h+x*f,P=t+r*Math.cos(y),S=e+r*Math.sin(y);b.push(P,S,!1)}n.splice(-1,0,b)},Za=(t,e,r,n,s,o=!1)=>{const i=o?0:s.length-1,l=o?s.length-1:s.length-2,c=Ur(t.x,t.y,n,s[i]),u=Ur(t.x,t.y,n,s[l]);if(c[0]===u[0]&&c[1]===u[1]||c[0]===u[2]&&c[1]===u[3])return;const a=Gr(c,s[l]);if(!a)return;const h=Gr(u,s[i]);if(!h)return;const d=e.x-t.x,g=e.y-t.y,m=Math.hypot(d,g),f={x:d/m,y:g/m},b=r.x-t.x,x=r.y-t.y,y=Math.hypot(b,x),P={x:b/y,y:x/y},S=f.x,M=f.y,$=P.x,T=P.y,w=S*T-M*$;if(w===0){s.splice(-1,0,[t.x,t.y,!1,a[0],a[1],!1,h[0],h[1],!1]);return}const E=((h[0]-a[0])*T-(h[1]-a[1])*$)/w,F=a[0]+E*S,A=a[1]+E*M;s.splice(-1,0,[t.x,t.y,!1,a[0],a[1],!1,F,A,!1,t.x,t.y,!1,h[0],h[1],!1,F,A,!1])},Bm=(t,e,r)=>{const n=t[0],s=t[1],o=t[3],i=t[4],l=Math.atan2(s-i,n-o),c=[n,s,!1],u=8;for(let b=0;b<=u;b++){const x=l-Math.PI/2+b*Math.PI/u;c.push(n+e*Math.cos(x),s+e*Math.sin(x),!1)}r.unshift(c);const a=t[t.length-3],h=t[t.length-2],d=t[t.length-6],g=t[t.length-5],m=Math.atan2(h-g,a-d),f=[a,h,!1];for(let b=0;b<=u;b++){const x=m-Math.PI/2+b*Math.PI/u;f.push(a+e*Math.cos(x),h+e*Math.sin(x),!1)}r.push(f)},Pm=(t,e,r)=>{const n=t[0],s=t[1],o=t[3],i=t[4],l=n-o,c=s-i,u=Math.hypot(l,c);if(u>0){const x=l/u,y=c/u,P=n+x*e,S=s+y*e,M=[n-y*e,s+x*e,!1,P-y*e,S+x*e,!1,P+y*e,S-x*e,!1,n+y*e,s-x*e,!1,n-y*e,s+x*e,!1];r.unshift(M)}const a=t[t.length-3],h=t[t.length-2],d=t[t.length-6],g=t[t.length-5],m=a-d,f=h-g,b=Math.hypot(m,f);if(b>0){const x=m/b,y=f/b,P=a+x*e,S=h+y*e,M=[a-y*e,h+x*e,!1,P-y*e,S+x*e,!1,P+y*e,S-x*e,!1,a+y*e,h-x*e,!1,a-y*e,h+x*e,!1];r.push(M)}},Oo=(t,e)=>{const r=dm;r.x=t[0],r.y=t[1];const n=pm;n.x=0,n.y=0;const s=mm;s.x=0,s.y=0;const o=gm;o.x=0,o.y=0;const i=[];for(let g=3;g1)switch(st.joints){case 0:qa(r.x,r.y,e,i);break;case 1:o.x=t[g-6],o.y=t[g-5],Za(r,s,o,e,i);break;case 2:Qa(r.x,r.y,e,i);break}r.x=s.x,r.y=s.y}const l=t[0],c=t[1],u=t[t.length-3],a=t[t.length-2],h=1e-4;if(Math.abs(l-u)1)switch(st.joints){case 0:qa(l,c,e,i,!0);break;case 1:r.x=l,r.y=c,s.x=t[3],s.y=t[4],o.x=t[t.length-6],o.y=t[t.length-5],Za(r,s,o,e,i,!0);break;case 2:Qa(l,c,e,i,!0);break}else if(i.length>0)switch(st.caps){case 1:Bm(t,e,i);break;case 2:Pm(t,e,i);break}return i},Am=(t,e)=>{const r=e/2,n=[];for(const s of t){if(s.length<6)continue;const o=Oo(s,r);for(const i of o)n.push(i)}return n},Ja=new Map;let ec=0;const Fm=()=>{Ja.clear(),ec=0},tc=new WeakMap,Eo=t=>{let e=tc.get(t);return e||(e=t.createView(),tc.set(t,e)),e},wm=6,Om=22,pn=new Map,mn=new Map,ns=(t,e,r)=>{const n=\`\${e}_\${r}\`,s=pn.get(n);return s&&s.length>0?s.pop():t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:wm})},Ot=t=>{const e=\`\${t.width}_\${t.height}\`;let r=pn.get(e);r||(r=[],pn.set(e,r)),r.push(t)},Ro=(t,e,r)=>{const n=\`\${e}_\${r}\`,s=mn.get(n);return s&&s.length>0?s.pop():t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:Om})},Xt=t=>{const e=\`\${t.width}_\${t.height}\`;let r=mn.get(e);r||(r=[],mn.set(e,r)),r.push(t)},Em=()=>{for(const[,t]of pn)for(const e of t)e.destroy();pn.clear();for(const[,t]of mn)for(const e of t)e.destroy();mn.clear()},rc=new Map,Rm=()=>{for(const t of rc.values())t.texture?.resource&&t.texture.resource.destroy();rc.clear()},Lr=new Map;let gn=0;const Cm=60,nc=(t,e,r)=>\`\${e}_\${r}_\${t.join(",")}\`,sc=(t,e,r)=>{const n=nc(t,e,r),s=Lr.get(n);return s?(s.lastUsedFrame=gn,s):null},oc=(t,e,r,n,s)=>{const o=nc(t,e,r);Lr.set(o,{texture:n,view:s,lastUsedFrame:gn})},Um=()=>{gn++;for(const[t,e]of Lr)gn-e.lastUsedFrame>Cm&&(Ot(e.texture),Lr.delete(t))},Gm=()=>{for(const t of Lr.values())Ot(t.texture);Lr.clear(),gn=0};let Co=null;const Lm=()=>{Co?.texture?.resource&&Co.texture.resource.destroy(),Co=null},km=(t,e,r,n,s,o)=>{const i=e.getPipeline("stencil_write_atlas");i&&(t.setPipeline(i),t.setStencilReference(0),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0));const l=e.getPipeline("stencil_fill_atlas");l&&(t.setPipeline(l),t.setStencilReference(0),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0))},Im=(t,e,r,n,s,o)=>{const i=e.getPipeline("stencil_write_main");i&&(t.setPipeline(i),t.setStencilReference(0),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0));const l=e.getPipeline("stencil_fill_main");l&&(t.setPipeline(l),t.setStencilReference(0),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0))},_m=(t,e,r,n,s,o,i,l=!1,c=1)=>{let u;if(i)u="fill";else if(l){if(nr())return;u="fill_bgra_stencil"}else u="fill_bgra";const a=e.getPipeline(u);if(!a){console.error(\`[WebGPU] \${u} pipeline not found\`);return}t.setPipeline(a),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),l&&!i&&!nr()&&t.setStencilReference(Or()),t.draw(n,1,0,0)},Uo=t=>t<=4?256:t<=8?512:1024,ic=(t,e,r)=>{const n=t.length/5,s=Uo(n),o=new Uint8Array(s*4);for(let i=0;i{const n=t.length/5;let s=0,o=0;for(let x=0;x=e&&o===0){o=x;break}}if(o===0&&(o=n-1),s===o){const x=s*5;return{r:t[x+1],g:t[x+2],b:t[x+3],a:t[x+4]}}const i=t[s*5],l=t[o*5],c=(e-i)/(l-i),u=t[s*5+1],a=t[s*5+2],h=t[s*5+3],d=t[s*5+4],g=t[o*5+1],m=t[o*5+2],f=t[o*5+3],b=t[o*5+4];return r===0?{r:Go(ot(kr(u/255),kr(g/255),c))*255,g:Go(ot(kr(a/255),kr(m/255),c))*255,b:Go(ot(kr(h/255),kr(f/255),c))*255,a:ot(d,b,c)}:{r:ot(u,g,c),g:ot(a,m,c),b:ot(h,f,c),a:ot(d,b,c)}},ot=(t,e,r)=>t+(e-t)*r,kr=t=>Math.pow(t,2.23333333),Go=t=>Math.pow(t,.45454545),ac=(t,e,r)=>{const s=new Uint8Array(1024),o=t.length,i=[];for(let l=0;l>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255,a:r[l]})}for(let l=0;l<256;l++){const c=l/255;let u=0,a=o-1;for(let P=0;P=c){u=P,a=P+1;break}const h=i[u],d=i[a];let g=0;d.offset!==h.offset&&(g=(c-h.offset)/(d.offset-h.offset));const m=ot(h.r,d.r,g),f=ot(h.g,d.g,g),b=ot(h.b,d.b,g),x=ot(h.a,d.a,g),y=l*4;s[y+0]=Math.round(m*x*255),s[y+1]=Math.round(f*x*255),s[y+2]=Math.round(b*x*255),s[y+3]=Math.round(x*255)}return s},cc=(t,e,r)=>{const n=t[0],s=t[1],o=t[2],i=t[3],l=t[4],c=t[5];if(r===0){const y=-819.2*n-819.2*o+l,P=819.2*n-819.2*o+l,S=-819.2*n+819.2*o+l,M=-819.2*s-819.2*i+c,$=819.2*s-819.2*i+c,T=-819.2*s+819.2*i+c;let w=S-y,E=T-M;const F=Math.sqrt(w*w+E*E);F?(w=w/F,E=E/F):(w=0,E=0);const A=(P-y)*w+($-M)*E,R=new Float32Array([y+A*w,M+A*E,P,$]);return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:R}}const u=n*i-s*o;if(Math.abs(u)<1e-10)return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:null};const a=1/u,h=i*a,d=-s*a,g=-o*a,m=n*a,f=(o*c-i*l)*a,b=(s*l-n*c)*a;return{inverseMatrix:new Float32Array([h,d,0,g,m,0,f,b,1]),linearPoints:null}};let Lo=null;const j=new Float32Array(36),Ue=new Float32Array(16);let ko=null,lc=null;const ss=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Dm=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b=!1,x=1)=>{const y=dn(s);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer);let S,M;const $=sc(c,a,h);if($)S=$.texture,M=$.view;else{const V=ic(c,a,h),X=c.length/5,Y=Uo(X);S=ns(t,Y,1),t.queue.writeTexture({texture:S},V,{bytesPerRow:Y*4,rowsPerImage:1},{width:Y,height:1}),M=S.createView(),oc(c,a,h,S,M)}const T=cc(u,o,l),w=i[3]>0?i[3]:1,E=o[0],F=o[1],A=o[3],R=o[4],v=o[6],U=o[7];j[0]=T.inverseMatrix[0],j[1]=T.inverseMatrix[3],j[2]=0,j[3]=0,j[4]=T.inverseMatrix[1],j[5]=T.inverseMatrix[4],j[6]=0,j[7]=0,j[8]=T.inverseMatrix[6],j[9]=T.inverseMatrix[7],j[10]=1,j[11]=0,j[12]=l,j[13]=Math.max(-.975,Math.min(.975,d)),j[14]=a,j[15]=819.2,T.linearPoints?(j[16]=T.linearPoints[0],j[17]=T.linearPoints[1],j[18]=T.linearPoints[2],j[19]=T.linearPoints[3]):(j[16]=0,j[17]=0,j[18]=0,j[19]=0),j[20]=1,j[21]=1,j[22]=1,j[23]=w,j[24]=E/g,j[25]=F/m,j[26]=0,j[27]=0,j[28]=A/g,j[29]=R/m,j[30]=0,j[31]=0,j[32]=v/g,j[33]=U/m,j[34]=1,j[35]=0;const L=r.acquireAndWriteUniformBuffer(j);Lo||(Lo=t.createSampler({magFilter:"linear",minFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}));const D=Lo,G=n.getBindGroupLayout("gradient_fill");if(!G)return console.error("[WebGPU] gradient_fill bind group layout not found"),null;ss[0].resource.buffer=L,ss[1].resource=D,ss[2].resource=M;const B=t.createBindGroup({layout:G,entries:ss}),z=()=>{const V=n.getBindGroupLayout("fill_dynamic");if(!V)return null;Ue[0]=1,Ue[1]=1,Ue[2]=1,Ue[3]=w,Ue[4]=E/g,Ue[5]=F/m,Ue[6]=0,Ue[7]=0,Ue[8]=A/g,Ue[9]=R/m,Ue[10]=0,Ue[11]=0,Ue[12]=v/g,Ue[13]=U/m,Ue[14]=1,Ue[15]=0;const X=r.dynamicUniform.allocate(Ue),Y=r.dynamicUniform.getBuffer();return(!ko||lc!==Y)&&(ko=t.createBindGroup({layout:V,entries:[{binding:0,resource:{buffer:Y,size:256}}]}),lc=Y),{bindGroup:ko,offset:X}};if(f){const V=n.getPipeline("stencil_write_atlas");if(V){const Y=z();e.setPipeline(V),e.setStencilReference(0),e.setVertexBuffer(0,P),Y&&e.setBindGroup(0,Y.bindGroup,[Y.offset]),e.draw(y.indexCount,1,0,0)}const X=n.getGradientPipeline("gradient_fill_stencil_atlas",l,a);return X&&(e.setPipeline(X),e.setStencilReference(0),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0)),null}if(b&&nr())return null;const k=n.getPipeline("stencil_write_main");if(k){const V=z();e.setPipeline(k),e.setStencilReference(0),e.setVertexBuffer(0,P),V&&e.setBindGroup(0,V.bindGroup,[V.offset]),e.draw(y.indexCount,1,0,0)}const _=b?"gradient_fill_bgra_stencil_masked":"gradient_fill_stencil_main",I=n.getGradientPipeline(_,l,a);return I&&(e.setPipeline(I),e.setStencilReference(b?Or():0),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0)),null},uc=(t,e)=>{const r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],l=t[5],c=e[0],u=e[1],a=e[3],h=e[4],d=e[6],g=e[7],m=c*r+a*n,f=c*s+a*o,b=u*r+h*n,x=u*s+h*o,y=c*i+a*l+d,P=u*i+h*l+g,S=m*x-f*b;if(Math.abs(S)<1e-10)return new Float32Array([1,0,0,0,1,0,0,0,1]);const M=1/S,$=x*M,T=-f*M,w=-b*M,E=m*M,F=(f*P-x*y)*M,A=(b*y-m*P)*M,R=$*c+T*u,v=$*a+T*h,U=w*c+E*u,L=w*a+E*h,D=$*d+T*g+F,G=w*d+E*g+A;return new Float32Array([R,U,0,v,L,0,D,G,1])},fc=new Map,Z=new Float32Array(32),Ge=new Float32Array(16);let Io=null,hc=null;const os=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Nm=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b=!1,x=1)=>{const y=dn(s);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer),S=ns(t,u,a);t.queue.writeTexture({texture:S},l.buffer,{bytesPerRow:u*4,rowsPerImage:a,offset:l.byteOffset},{width:u,height:a});const M=uc(c,o),$=i[0],T=i[1],w=i[2],E=i[3],F=o[0],A=o[1],R=o[3],v=o[4],U=o[6],L=o[7];Z[0]=M[0],Z[1]=M[1],Z[2]=M[2],Z[3]=0,Z[4]=M[3],Z[5]=M[4],Z[6]=M[5],Z[7]=0,Z[8]=M[6],Z[9]=M[7],Z[10]=M[8],Z[11]=0,Z[12]=u,Z[13]=a,Z[14]=h?1:0,Z[15]=0,Z[16]=$,Z[17]=T,Z[18]=w,Z[19]=E,Z[20]=F/g,Z[21]=A/m,Z[22]=0,Z[23]=0,Z[24]=R/g,Z[25]=v/m,Z[26]=0,Z[27]=0,Z[28]=U/g,Z[29]=L/m,Z[30]=1,Z[31]=0;const D=r.acquireAndWriteUniformBuffer(Z),G=\`bitmap_\${d?"s":"n"}_\${h?"r":"c"}\`;let B=fc.get(G);B||(B=t.createSampler({magFilter:d?"linear":"nearest",minFilter:d?"linear":"nearest",addressModeU:h?"repeat":"clamp-to-edge",addressModeV:h?"repeat":"clamp-to-edge"}),fc.set(G,B));const z=n.getBindGroupLayout("bitmap_fill");if(!z)return console.error("[WebGPU] bitmap_fill bind group layout not found"),Ot(S),null;os[0].resource.buffer=D,os[1].resource=B,os[2].resource=S.createView();const k=t.createBindGroup({layout:z,entries:os}),_=()=>{const I=n.getBindGroupLayout("fill_dynamic");if(!I)return null;Ge[0]=$,Ge[1]=T,Ge[2]=w,Ge[3]=E,Ge[4]=F/g,Ge[5]=A/m,Ge[6]=0,Ge[7]=0,Ge[8]=R/g,Ge[9]=v/m,Ge[10]=0,Ge[11]=0,Ge[12]=U/g,Ge[13]=L/m,Ge[14]=1,Ge[15]=0;const V=r.dynamicUniform.allocate(Ge),X=r.dynamicUniform.getBuffer();return(!Io||hc!==X)&&(Io=t.createBindGroup({layout:I,entries:[{binding:0,resource:{buffer:X,size:256}}]}),hc=X),{bindGroup:Io,offset:V}};if(f&&b){const I=n.getPipeline("stencil_write");if(I){const X=_();X&&(e.setPipeline(I),e.setStencilReference(0),e.setVertexBuffer(0,P),e.setBindGroup(0,X.bindGroup,[X.offset]),e.draw(y.indexCount,1,0,0))}const V=n.getPipeline("bitmap_fill_stencil");V&&(e.setPipeline(V),e.setStencilReference(0),e.setBindGroup(0,k),e.draw(y.indexCount,1,0,0))}else{let I;if(f)I="bitmap_fill";else if(b){if(nr())return Ot(S),null;I="bitmap_fill_bgra_stencil"}else I="bitmap_fill_bgra";const V=n.getPipeline(I);if(!V)return console.error(\`[WebGPU] \${I} pipeline not found\`),Ot(S),null;e.setPipeline(V),e.setVertexBuffer(0,P),e.setBindGroup(0,k),b&&!f&&!nr()&&e.setStencilReference(Or()),e.draw(y.indexCount,1,0,0)}return S},dc=(t,e,r)=>{const n=t.length-5;for(let s=3;s(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),Xm=(t,e)=>{const r=e/2,n=[];for(const c of t){const u=Oo(c,r);for(const a of u)n.push(a)}let s=0;for(const c of n){const u=c.length-5;for(let a=3;a{const y=Xm(s,o);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer);let S,M;const $=sc(u,h,d);if($)S=$.texture,M=$.view;else{const _=ic(u,h,d),I=u.length/5,V=Uo(I);S=ns(t,V,1),t.queue.writeTexture({texture:S},_,{bytesPerRow:V*4,rowsPerImage:1},{width:V,height:1}),M=S.createView(),oc(u,h,d,S,M)}const T=cc(a,i,c),w=l[3]>0?l[3]:1,E=i[0],F=i[1],A=i[3],R=i[4],v=i[6],U=i[7];H[0]=T.inverseMatrix[0],H[1]=T.inverseMatrix[3],H[2]=0,H[3]=0,H[4]=T.inverseMatrix[1],H[5]=T.inverseMatrix[4],H[6]=0,H[7]=0,H[8]=T.inverseMatrix[6],H[9]=T.inverseMatrix[7],H[10]=1,H[11]=0,H[12]=c,H[13]=Math.max(-.975,Math.min(.975,g)),H[14]=h,H[15]=819.2,T.linearPoints?(H[16]=T.linearPoints[0],H[17]=T.linearPoints[1],H[18]=T.linearPoints[2],H[19]=T.linearPoints[3]):(H[16]=0,H[17]=0,H[18]=0,H[19]=0),H[20]=1,H[21]=1,H[22]=1,H[23]=w,H[24]=E/m,H[25]=F/f,H[26]=0,H[27]=0,H[28]=A/m,H[29]=R/f,H[30]=0,H[31]=0,H[32]=v/m,H[33]=U/f,H[34]=1,H[35]=0;const L=r.acquireAndWriteUniformBuffer(H);Vo||(Vo=t.createSampler({magFilter:"linear",minFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}));const D=Vo,G=n.getBindGroupLayout("gradient_fill");if(!G)return console.error("[WebGPU] gradient_fill bind group layout not found"),null;is[0].resource.buffer=L,is[1].resource=D,is[2].resource=M;const B=t.createBindGroup({layout:G,entries:is}),z=x?b?"gradient_stroke_atlas":"gradient_stroke_bgra":b?"gradient_fill":"gradient_fill_bgra",k=n.getGradientPipeline(z,c,h);return k?(e.setPipeline(k),e.setVertexBuffer(0,P),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0),null):(console.error(\`[WebGPU] \${z} pipeline not found\`),null)};let Do=new Float32Array(32);const Wm=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),jm=(t,e)=>{const r=e/2,n=[];for(const c of t){const u=Oo(c,r);for(const a of u)n.push(a)}let s=0;for(const c of n){const u=c.length-5;for(let a=3;a{const y=jm(s,o);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer),S=ns(t,a,h);t.queue.writeTexture({texture:S},c.buffer,{bytesPerRow:a*4,rowsPerImage:h,offset:c.byteOffset},{width:a,height:h});const M=uc(u,i),$=1,T=1,w=1,E=l[3]>0?l[3]:1,F=i[0],A=i[1],R=i[3],v=i[4],U=i[6],L=i[7];J[0]=M[0],J[1]=M[1],J[2]=M[2],J[3]=0,J[4]=M[3],J[5]=M[4],J[6]=M[5],J[7]=0,J[8]=M[6],J[9]=M[7],J[10]=M[8],J[11]=0,J[12]=a,J[13]=h,J[14]=d?1:0,J[15]=0,J[16]=$,J[17]=T,J[18]=w,J[19]=E,J[20]=F/m,J[21]=A/f,J[22]=0,J[23]=0,J[24]=R/m,J[25]=v/f,J[26]=0,J[27]=0,J[28]=U/m,J[29]=L/f,J[30]=1,J[31]=0;const D=r.acquireAndWriteUniformBuffer(J),G=\`bitmap_\${g?"s":"n"}_\${d?"r":"c"}\`;let B=pc.get(G);B||(B=t.createSampler({magFilter:g?"linear":"nearest",minFilter:g?"linear":"nearest",addressModeU:d?"repeat":"clamp-to-edge",addressModeV:d?"repeat":"clamp-to-edge"}),pc.set(G,B));const z=n.getBindGroupLayout("bitmap_fill");if(!z)return console.error("[WebGPU] bitmap_fill bind group layout not found"),Ot(S),null;as[0].resource.buffer=D,as[1].resource=B,as[2].resource=S.createView();const k=t.createBindGroup({layout:z,entries:as}),_=x?b?"bitmap_stroke_atlas":"bitmap_stroke_bgra":b?"bitmap_fill":"bitmap_fill_bgra",I=n.getPipeline(_);return I?(e.setPipeline(I),e.setVertexBuffer(0,P),e.setBindGroup(0,k),e.draw(y.indexCount,1,0,0),S):(console.error(\`[WebGPU] \${_} pipeline not found\`),Ot(S),null)},mc=new Float32Array([-1,-1,.5,.5,1,-1,.5,.5,-1,1,.5,.5,-1,1,.5,.5,1,-1,.5,.5,1,1,.5,.5]),Km=new Float32Array([1,1,1,1,.5,0,0,0,0,.5,0,0,.5,.5,1,0]),qm=(t,e,r,n,s)=>{if(!s)return;const o=s.clipLevel,i=1<{const a=s.clipLevel,h=s.width,d=s.height,g=l[0],m=l[1],f=l[2],b=l[3]*c;if(o.length===0)return;const x=dn(o);if(x.indexCount===0)return;const y=r.acquireVertexBuffer(x.buffer.byteLength,x.buffer),P=i[0],S=i[1],M=i[3],$=i[4],T=i[6],w=i[7];Le[0]=g,Le[1]=m,Le[2]=f,Le[3]=b,Le[4]=P/h,Le[5]=S/d,Le[6]=0,Le[7]=0,Le[8]=M/h,Le[9]=$/d,Le[10]=0,Le[11]=0,Le[12]=T/h,Le[13]=w/d,Le[14]=1,Le[15]=0;const E=r.dynamicUniform.allocate(Le);let F=Rr.get(a)??a,A;u?A=\`clip_write_main_\${Math.min(8,Math.max(1,F))}\`:A="clip_write";const R=n.getPipeline(A);if(!R){console.error(\`[WebGPU] \${A} pipeline not found\`);return}const v=n.getBindGroupLayout("fill_dynamic");if(!v)return;const U=t.createBindGroup({layout:v,entries:[{binding:0,resource:{buffer:r.dynamicUniform.getBuffer(),size:256}}]});e.setPipeline(R),e.setStencilReference(0),e.setVertexBuffer(0,y),e.setBindGroup(0,U,[E]),e.draw(x.indexCount,1,0,0),F++,F>8&&(qm(t,e,r,n,s),F=a+1),Rr.set(a,F)};let No=null,gc=null;const Zm=(t,e,r,n,s,o,i,l)=>{const c=rs();if(c.count===0)return r;r&&(r.end(),r=null);const u=gt(),a=Or(),g=(F=>{switch(F){case"add":return"instanced_add";case"screen":return"instanced_screen";case"alpha":return"instanced_alpha";case"erase":return"instanced_erase";case"copy":return"instanced_copy";default:return"instanced"}})(ts),m=l.getPipeline(g),f=l.getPipeline("instanced_masked"),b=u&&f&&(n.msaaStencil?.view||n.stencil?.view),x=b?f:m;if(!x)return console.error("[WebGPU] Instanced pipeline not found"),null;let y;if(b){const F=n.msaa&&n.msaaTexture?.view,A=F?n.msaaTexture.view:n.texture.view,R=F&&n.msaaStencil?.view?n.msaaStencil.view:n.stencil.view,v=F?n.texture.view:null,U=o.createStencilRenderPassDescriptor(A,R,"load","load",v);y=e.beginRenderPass(U)}else{const F=n.msaa&&n.msaaTexture?.view,A=F?n.msaaTexture.view:n.texture.view,R=F?n.texture.view:null,v=o.createRenderPassDescriptor(A,0,0,0,0,"load",R);y=e.beginRenderPass(v)}y.setPipeline(x),b&&y.setStencilReference(a);const P=new Float32Array(Ve.buffer.buffer,Ve.buffer.byteOffset,Ve.offset),S=s.acquireVertexBuffer(P.byteLength,P),M=s.getUnitRectBuffer(),$=Ne()||o.getAttachment("atlas");if(!$)return console.error("[WebGPU] Atlas attachment not found"),y.end(),null;const T=i.createSampler("atlas_instanced_sampler",!1),w=l.getBindGroupLayout("instanced");if(!w)return console.error("[WebGPU] Instanced bind group layout not found"),y.end(),null;const E=$.texture.view;return(!No||gc!==E)&&(No=t.createBindGroup({layout:w,entries:[{binding:0,resource:T},{binding:1,resource:E}]}),gc=E),y.setVertexBuffer(0,M),y.setVertexBuffer(1,S),y.setBindGroup(0,No),y.draw(6,c.count,0,0),y.end(),c.clear(),null};let zo=null,bc=null;const Jm=(t,e,r,n,s,o,i,l,c=!0,u=!0)=>{const a=rs();if(a.count===0)return r;r&&(r.end(),r=null);const h=gt(),d=Or(),f=(R=>{switch(R){case"add":return"instanced_add";case"screen":return"instanced_screen";case"alpha":return"instanced_alpha";case"erase":return"instanced_erase";case"copy":return"instanced_copy";default:return"instanced"}})(ts),b=l.getPipeline(f),x=l.getPipeline("instanced_masked"),y=h&&x&&(n.msaaStencil?.view||n.stencil?.view),P=y?x:b;if(!P)return console.error("[WebGPU] Instanced pipeline not found"),null;let S;if(y){const R=n.msaa&&n.msaaTexture?.view,v=R?n.msaaTexture.view:n.texture.view,U=R&&n.msaaStencil?.view?n.msaaStencil.view:n.stencil.view,L=R?n.texture.view:null,D=o.createStencilRenderPassDescriptor(v,U,"load","load",L);S=e.beginRenderPass(D)}else{const R=n.msaa&&n.msaaTexture?.view,v=R?n.msaaTexture.view:n.texture.view,U=R?n.texture.view:null,L=o.createRenderPassDescriptor(v,0,0,0,0,"load",U);S=e.beginRenderPass(L)}S.setPipeline(P),y&&S.setStencilReference(d);const M=new Float32Array(Ve.buffer.buffer,Ve.buffer.byteOffset,Ve.offset);let $;u?($=s.acquireStorageBuffer(M.byteLength),s.writeStorageBuffer($,M)):$=s.acquireVertexBuffer(M.byteLength,M);const T=s.getUnitRectBuffer(),w=Ne()||o.getAttachment("atlas");if(!w)return console.error("[WebGPU] Atlas attachment not found"),S.end(),null;const E=i.createSampler("atlas_instanced_sampler",!1),F=l.getBindGroupLayout("instanced");if(!F)return console.error("[WebGPU] Instanced bind group layout not found"),S.end(),null;const A=w.texture.view;if((!zo||bc!==A)&&(zo=t.createBindGroup({layout:F,entries:[{binding:0,resource:E},{binding:1,resource:A}]}),bc=A),S.setVertexBuffer(0,T),S.setVertexBuffer(1,$),S.setBindGroup(0,zo),c){const R=s.createIndirectBuffer(6,a.count,0,0);S.drawIndirect(R,0)}else S.draw(6,a.count,0,0);return S.end(),a.clear(),null},je=new Float32Array(12),bn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Xo=(t,e,r,n,s)=>{const{device:o,commandEncoder:i,frameBufferManager:l,pipelineManager:c,textureManager:u}=s,a=Math.max(t.width,e.width),h=Math.max(t.height,e.height),d=l.createTemporaryAttachment(a,h),g=c.getPipeline("complex_blend"),m=c.getBindGroupLayout("complex_blend");if(!g||!m)return console.error(\`[WebGPU ComplexBlend] Pipeline not found for blend mode: \${r}\`),t;const f=u.createSampler("complex_blend_sampler",!0),b=N.getBlendModeIndex(r);je[0]=n[0],je[1]=n[1],je[2]=n[2],je[3]=n[3],je[4]=n[4],je[5]=n[5],je[6]=n[6],je[7]=n[7],je[8]=b,je[9]=0,je[10]=0,je[11]=0;const x=s.bufferManager?s.bufferManager.acquireAndWriteUniformBuffer(je):o.createBuffer({size:48,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});s.bufferManager||o.queue.writeBuffer(x,0,je),bn[0].resource.buffer=x,bn[1].resource=f,bn[2].resource=e.texture.view,bn[3].resource=t.texture.view;const y=o.createBindGroup({layout:m,entries:bn}),P=l.createRenderPassDescriptor(d.texture.view,0,0,0,0,"clear"),S=i.beginRenderPass(P);return S.setPipeline(g),S.setBindGroup(0,y),S.draw(6,1,0,0),S.end(),d},xn=new Float32Array(4),it=new Float32Array(6),Oe=new Float32Array(8),Qe=new Float32Array(12),at=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],e0=(t,e,r,n,s,o,i,l,c,u,a,h,d,g)=>{const m=d.getPipeline("complex_blend_copy"),f=d.getBindGroupLayout("texture_copy");if(!m||!f)return;xn[0]=c/i,xn[1]=u/l,xn[2]=s/i,xn[3]=o/l;const b=g.acquireAndWriteUniformBuffer(xn),x=h.createSampler("complex_blend_copy_sampler",!1);at[0].resource.buffer=b,at[1].resource=x,at[2].resource=r;const y=t.createBindGroup({layout:f,entries:at}),P=a.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),S=e.beginRenderPass(P);S.setPipeline(m),S.setBindGroup(0,y),S.draw(6,1,0,0),S.end()},t0=(t,e,r,n,s,o,i,l,c,u)=>{const a=n.msaa&&n.msaaTexture?.view,h=a?"complex_blend_output_msaa":"complex_blend_output",d=c.getPipeline(h),g=c.getBindGroupLayout("positioned_texture");if(!d||!g)return;Oe[0]=s,Oe[1]=o,Oe[2]=r.width,Oe[3]=r.height,Oe[4]=n.width,Oe[5]=n.height,Oe[6]=0,Oe[7]=0;const m=u.acquireAndWriteUniformBuffer(Oe),f=l.createSampler("complex_blend_output_sampler",!1);at[0].resource.buffer=m,at[1].resource=f,at[2].resource=r.texture.view;const b=t.createBindGroup({layout:g,entries:at}),x=a?n.msaaTexture.view:n.texture.view,y=a?n.texture.view:null,P=i.createRenderPassDescriptor(x,0,0,0,0,"load",y),S=e.beginRenderPass(P);S.setPipeline(d),S.setBindGroup(0,b),S.draw(6,1,0,0),S.end()},r0=(t,e,r,n,s,o,i)=>{const l=om();if(l.length===0)return;if(!r||!r.texture){So();return}const c=Ne()||n.getAttachment("atlas");if(!c||!c.texture){So();return}for(const u of l){const{node:a,x_min:h,y_min:d,x_max:g,y_max:m,color_transform:f,matrix:b,blend_mode:x,global_alpha:y}=u,P=Math.ceil(Math.abs(g-h)),S=Math.ceil(Math.abs(m-d));if(P<=0||S<=0)continue;const M=Math.max(0,Math.floor(b[6])),$=Math.max(0,Math.floor(b[7]));if(M>=r.width||$>=r.height)continue;const T=b[0]!==1||b[1]!==0||b[3]!==0||b[4]!==1,w=T?P:a.w,E=T?S:a.h,F=Math.min(w,r.width-M),A=Math.min(E,r.height-$);if(F<=0||A<=0)continue;let R;if(T){R=n.createTemporaryAttachment(w,E);const L=o.getPipeline("complex_blend_scale"),D=o.getBindGroupLayout("texture_scale");if(L&&D){const G=w/2,B=E/2,z=a.w/2,k=a.h/2;it[0]=b[0],it[1]=b[1],it[2]=b[3],it[3]=b[4],it[4]=-z*b[0]-k*b[3]+G,it[5]=-z*b[1]-k*b[4]+B;const _=n.createTemporaryAttachment(a.w,a.h);e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:_.texture.resource,origin:{x:0,y:0,z:0}},{width:a.w,height:a.h}),Qe[0]=it[0],Qe[1]=it[1],Qe[2]=it[2],Qe[3]=it[3],Qe[4]=it[4],Qe[5]=it[5],Qe[6]=a.w,Qe[7]=a.h,Qe[8]=w,Qe[9]=E,Qe[10]=0,Qe[11]=0;const I=i.acquireAndWriteUniformBuffer(Qe,48),V=s.createSampler("scale_sampler",!0);at[0].resource.buffer=I,at[1].resource=V,at[2].resource=_.texture.view;const X=t.createBindGroup({layout:D,entries:at}),Y=n.createRenderPassDescriptor(R.texture.view,0,0,0,0,"clear"),W=e.beginRenderPass(Y);W.setPipeline(L),W.setBindGroup(0,X),W.draw(6,1,0,0),W.end(),n.releaseTemporaryAttachment(_)}else e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:R.texture.resource,origin:{x:0,y:0,z:0}},{width:Math.min(a.w,w),height:Math.min(a.h,E)})}else R=n.createTemporaryAttachment(w,E),e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:R.texture.resource,origin:{x:0,y:0,z:0}},{width:w,height:E});const v=n.createTemporaryAttachment(w,E);e0(t,e,r.texture.view,v,M,$,r.width,r.height,w,E,n,s,o,i),Oe[0]=f[0],Oe[1]=f[1],Oe[2]=f[2],Oe[3]=y,Oe[4]=f[4],Oe[5]=f[5],Oe[6]=f[6],Oe[7]=0;const U=Xo(R,v,x,Oe,{device:t,commandEncoder:e,bufferManager:i,frameBufferManager:n,pipelineManager:o,textureManager:s});t0(t,e,U,r,M,$,n,s,o,i),n.releaseTemporaryAttachment(R),n.releaseTemporaryAttachment(v),n.releaseTemporaryAttachment(U)}So()},ne={x:0,y:0},xc=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],n0=(t,e,r,n,s)=>{const o=Math.sqrt(t[0]*t[0]+t[1]*t[1]),i=Math.sqrt(t[2]*t[2]+t[3]*t[3]),l=e*(o/s),c=r*(i/s),u=xc[Math.min(n-1,xc.length-1)],a=Math.round(l*u),h=Math.round(c*u);let d=1,g=1;return l>128?d=.0625:l>64?d=.125:l>32?d=.25:l>16&&(d=.5),c>128?g=.0625:c>64?g=.125:c>32?g=.25:c>16&&(g=.5),{baseBlurX:l,baseBlurY:c,offsetX:a,offsetY:h,bufferScaleX:d,bufferScaleY:g}},s0=(t,e,r,n)=>{const s=Math.ceil(e*.5),o=1-(s-e*.5),i=1+e,l=t?1/r:0,c=t?0:1/n;return{offsetX:l,offsetY:c,fraction:o,samples:i,halfBlur:s}},ht=new Float32Array(8),cs=[{binding:0,resource:null},{binding:1,resource:null},{binding:2,resource:{buffer:null}}],o0={label:"blur_compute_pass_h"},i0={label:"blur_compute_pass_v"},yc=(t,e,r,n,s,o,i,l)=>{const c=Math.ceil(i*.5),a=c>=8&&c<=24?o?"blur_compute_shared_horizontal":"blur_compute_shared_vertical":o?"blur_compute_horizontal":"blur_compute_vertical",h=r.getPipeline(a),d=r.getBindGroupLayout("blur_compute");if(!h||!d)return;const g=1-(c-i*.5),m=1+i;ht[0]=o?1:0,ht[1]=o?0:1,ht[2]=c,ht[3]=g,ht[4]=n.width,ht[5]=n.height,ht[6]=m,ht[7]=0;const f=l?l.acquireAndWriteUniformBuffer(ht):(()=>{const S=t.createBuffer({size:ht.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return t.queue.writeBuffer(S,0,ht),S})();cs[0].resource=n.texture.view,cs[1].resource=s.texture.view,cs[2].resource.buffer=f;const b=t.createBindGroup({layout:d,entries:cs}),x=e.beginComputePass(o?o0:i0);x.setPipeline(h),x.setBindGroup(0,b);const y=Math.ceil(s.width/16),P=Math.ceil(s.height/16);x.dispatchWorkgroups(y,P,1),x.end()},a0=(t,e,r,n)=>{const i=Math.max(t,e),l=Math.min(r,n);return i>=4&&l>=128},ye=new Float32Array(4),ct=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],sr=(t,e,r,n,s,o,i)=>{const{device:l,commandEncoder:c,frameBufferManager:u,pipelineManager:a,textureManager:h}=i,d=n0(e,r,n,s,o),{baseBlurX:g,baseBlurY:m,offsetX:f,offsetY:b,bufferScaleX:x,bufferScaleY:y}=d;ne.x+=f,ne.y+=b;const P=t.width+f*2,S=t.height+b*2,M=Math.ceil(P*x),$=Math.ceil(S*y),T=u.createTemporaryAttachment(M,$),w=u.createTemporaryAttachment(M,$),E=h.createSampler("blur_sampler",!0);c0(l,c,u,a,t,T,E,x,y,f*x,b*y,i.bufferManager);const F=g*x,A=m*y,R=i.computePipelineManager&&a0(g,m,M,$),v=[T,w];let U=0;for(let D=0;D0){const G=U;U=(U+1)%2,R?yc(l,c,i.computePipelineManager,v[G],v[U],!0,F,i.bufferManager):vc(l,c,u,a,v[G],v[U],E,!0,F,i.bufferManager)}if(n>0){const G=U;U=(U+1)%2,R?yc(l,c,i.computePipelineManager,v[G],v[U],!1,A,i.bufferManager):vc(l,c,u,a,v[G],v[U],E,!1,A,i.bufferManager)}}let L=v[U];if(x!==1||y!==1){const D=u.createTemporaryAttachment(P,S);l0(l,c,u,a,L,D,E,1/x,1/y,i.bufferManager),u.releaseTemporaryAttachment(T),u.releaseTemporaryAttachment(w),L=D}else{const D=(U+1)%2;u.releaseTemporaryAttachment(v[D])}return L},c0=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const d=n.getPipeline("texture_copy_rgba8"),g=n.getBindGroupLayout("texture_copy");if(!d||!g){console.error("[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found");return}const m=s.width*l,f=s.height*c,b=1,x=1,y=0,P=0;ye[0]=b,ye[1]=x,ye[2]=y,ye[3]=P;const S=h?h.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h||t.queue.writeBuffer(S,0,ye),ct[0].resource.buffer=S,ct[1].resource=i,ct[2].resource=s.texture.view;const M=t.createBindGroup({layout:g,entries:ct}),$=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),T=e.beginRenderPass($);T.setPipeline(d),T.setBindGroup(0,M),T.setViewport(u,a,m,f,0,1),T.setScissorRect(Math.floor(u),Math.floor(a),Math.ceil(m),Math.ceil(f)),T.draw(6,1,0,0),T.end()},vc=(t,e,r,n,s,o,i,l,c,u)=>{const a=s0(l,c,s.width,s.height),{offsetX:h,offsetY:d,fraction:g,samples:m,halfBlur:f}=a,b=Math.max(1,Math.min(16,f)),x=n.getPipeline(\`blur_filter_\${b}\`),y=n.getBindGroupLayout("blur_filter");if(!x||!y){console.error(\`[WebGPU BlurFilter] blur_filter_\${b} pipeline not found\`);return}ye[0]=h,ye[1]=d,ye[2]=g,ye[3]=m;const P=u?u.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});u||t.queue.writeBuffer(P,0,ye),ct[0].resource.buffer=P,ct[1].resource=i,ct[2].resource=s.texture.view;const S=t.createBindGroup({layout:y,entries:ct}),M=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),$=e.beginRenderPass(M);$.setPipeline(x),$.setBindGroup(0,S),$.draw(6,1,0,0),$.end()},l0=(t,e,r,n,s,o,i,l,c,u)=>{const a=n.getPipeline("texture_copy_rgba8"),h=n.getBindGroupLayout("texture_copy");if(!a||!h){console.error("[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found");return}ye[0]=1,ye[1]=1,ye[2]=0,ye[3]=0;const d=u?u.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});u||t.queue.writeBuffer(d,0,ye),ct[0].resource.buffer=d,ct[1].resource=i,ct[2].resource=s.texture.view;const g=t.createBindGroup({layout:h,entries:ct}),m=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),f=e.beginRenderPass(m);f.setPipeline(a),f.setBindGroup(0,g),f.draw(6,1,0,0),f.end()},de=new Float32Array(20),ls=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Mc=(t,e,r)=>{const{device:n,commandEncoder:s,frameBufferManager:o,pipelineManager:i,textureManager:l}=r,c=o.createTemporaryAttachment(t.width,t.height),u=i.getPipeline("color_matrix_filter"),a=i.getBindGroupLayout("color_matrix_filter");if(!u||!a)return console.error("[WebGPU ColorMatrixFilter] Pipeline not found"),t;const h=l.createSampler("color_matrix_sampler",!0);de[0]=e[0],de[1]=e[5],de[2]=e[10],de[3]=e[15],de[4]=e[1],de[5]=e[6],de[6]=e[11],de[7]=e[16],de[8]=e[2],de[9]=e[7],de[10]=e[12],de[11]=e[17],de[12]=e[3],de[13]=e[8],de[14]=e[13],de[15]=e[18],de[16]=e[4]/255,de[17]=e[9]/255,de[18]=e[14]/255,de[19]=e[19]/255;const d=r.bufferManager?r.bufferManager.acquireAndWriteUniformBuffer(de):n.createBuffer({size:de.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});r.bufferManager||n.queue.writeBuffer(d,0,de),ls[0].resource.buffer=d,ls[1].resource=h,ls[2].resource=t.texture.view;const g=n.createBindGroup({layout:a,entries:ls}),m=o.createRenderPassDescriptor(c.texture.view,0,0,0,0,"clear"),f=s.beginRenderPass(m);return f.setPipeline(u),f.setBindGroup(0,g),f.draw(6,1,0,0),f.end(),c},Pe=new Float32Array(16),yn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],u0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Sc=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const{device:d,commandEncoder:g,frameBufferManager:m,pipelineManager:f,textureManager:b}=h,x=ne.x,y=ne.y,P=t.width,S=t.height,M=sr(t,e,s,o,l,a,h),$=M.width,T=M.height,w=ne.x,E=ne.y,F=c?P:$,A=c?S:T,R=w-x,v=E-y,U=c?0:R,L=c?0:v,D=c?-R:0,G=c?-v:0,B=F/P,z=A/S,k=U/P,_=L/S,I=F/$,V=A/T,X=D/$,Y=G/T,W=m.createTemporaryAttachment(F,A),K=f.getFilterPipeline("glow_filter",{IS_INNER:c?1:0,IS_KNOCKOUT:u?1:0}),q=f.getBindGroupLayout("glow_filter");if(!K||!q)return console.error("[WebGPU GlowFilter] Pipeline not found"),m.releaseTemporaryAttachment(M),t;const ce=b.createSampler("glow_sampler",!0),[te,se,ue,Fe]=u0(r,n);Pe[0]=te,Pe[1]=se,Pe[2]=ue,Pe[3]=Fe,Pe[4]=B,Pe[5]=z,Pe[6]=k,Pe[7]=_,Pe[8]=I,Pe[9]=V,Pe[10]=X,Pe[11]=Y,Pe[12]=i,Pe[13]=c?1:0,Pe[14]=u?1:0,Pe[15]=0;const ge=h.bufferManager?h.bufferManager.acquireAndWriteUniformBuffer(Pe):d.createBuffer({size:Pe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.bufferManager||d.queue.writeBuffer(ge,0,Pe),yn[0].resource.buffer=ge,yn[1].resource=ce,yn[2].resource=M.texture.view,yn[3].resource=t.texture.view;const Q=d.createBindGroup({layout:q,entries:yn}),Ct=m.createRenderPassDescriptor(W.texture.view,0,0,0,0,"clear"),Je=g.beginRenderPass(Ct);return Je.setPipeline(K),Je.setBindGroup(0,Q),Je.draw(6,1,0,0),Je.end(),m.releaseTemporaryAttachment(M),W},f0=Math.PI/180,Ae=new Float32Array(16),vn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],h0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},$c=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,i,l,u,g,m),E=w.width,F=w.height,A=ne.x,R=ne.y,v=A-S,U=R-M,L=Math.sqrt(e[0]*e[0]+e[1]*e[1]),D=Math.sqrt(e[2]*e[2]+e[3]*e[3]),G=n*f0,B=Math.cos(G)*r*(L/g),z=Math.sin(G)*r*(D/g),k=a?$:E+Math.max(0,Math.abs(B)-v),_=a?T:F+Math.max(0,Math.abs(z)-U),I=Math.ceil(k),V=Math.ceil(_),X=(I-k)/2,Y=(V-_)/2,W=a?0:Math.max(0,v-B)+X,K=a?0:Math.max(0,U-z)+Y,q=a?B-A:(B>0?Math.max(0,B-v):0)+X,ce=a?z-R:(z>0?Math.max(0,z-U):0)+Y,te=x.createTemporaryAttachment(I,V),se=a;let ue=h,Fe=d;a?ue=h||d:!h&&d&&(ue=!0,Fe=!0);const ge=y.getFilterPipeline("drop_shadow_filter",{IS_INNER:se?1:0,IS_KNOCKOUT:ue?1:0,IS_HIDE_OBJECT:Fe?1:0}),Q=y.getBindGroupLayout("drop_shadow_filter");if(!ge||!Q)return console.error("[WebGPU DropShadowFilter] Pipeline not found"),x.releaseTemporaryAttachment(w),t;const Ct=P.createSampler("drop_shadow_sampler",!0),[Je,Ut,lr,ur]=h0(s,o),Yt=I/$,Gt=V/T,Lt=W/$,Wt=K/T,fr=I/E,jt=V/F,hr=q/E,Ht=ce/F;Ae[0]=Je,Ae[1]=Ut,Ae[2]=lr,Ae[3]=ur,Ae[4]=Yt,Ae[5]=Gt,Ae[6]=Lt,Ae[7]=Wt,Ae[8]=fr,Ae[9]=jt,Ae[10]=hr,Ae[11]=Ht,Ae[12]=c,Ae[13]=se?1:0,Ae[14]=ue?1:0,Ae[15]=Fe?1:0;const lt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Ae):f.createBuffer({size:Ae.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(lt,0,Ae),vn[0].resource.buffer=lt,vn[1].resource=Ct,vn[2].resource=w.texture.view,vn[3].resource=t.texture.view;const zr=f.createBindGroup({layout:Q,entries:vn}),Bn=x.createRenderPassDescriptor(te.texture.view,0,0,0,0,"clear"),kt=b.beginRenderPass(Bn);return kt.setPipeline(ge),kt.setBindGroup(0,zr),kt.draw(6,1,0,0),kt.end(),x.releaseTemporaryAttachment(w),te},d0=Math.PI/180,dt=new Float32Array(8),pe=new Float32Array(20),us=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Mn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Tc=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Bc=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f)=>{const{device:b,commandEncoder:x,frameBufferManager:y,pipelineManager:P,textureManager:S}=f,M=ne.x,$=ne.y,T=t.width,w=t.height,E=Math.sqrt(e[0]*e[0]+e[1]*e[1]),F=Math.sqrt(e[2]*e[2]+e[3]*e[3]),A=n*d0,R=Math.cos(A)*r*(E/m),v=Math.sin(A)*r*(F/m),U=y.createTemporaryAttachment(T,w);x.copyTextureToTexture({texture:t.texture.resource,origin:{x:0,y:0,z:0}},{texture:U.texture.resource,origin:{x:0,y:0,z:0}},{width:T,height:w});const L=P.getPipeline("texture_erase"),D=P.getBindGroupLayout("texture_copy");if(L&&D){const fg=S.createSampler("erase_sampler",!0),hg=R*2/T,dg=v*2/w;dt[0]=1,dt[1]=1,dt[2]=hg,dt[3]=dg,dt[4]=0,dt[5]=0,dt[6]=0,dt[7]=0;const zc=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(dt):b.createBuffer({size:dt.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(zc,0,dt),us[0].resource.buffer=zc,us[1].resource=fg,us[2].resource=t.texture.view;const pg=b.createBindGroup({layout:D,entries:us}),mg=y.createRenderPassDescriptor(U.texture.view,0,0,0,0,"load"),gs=x.beginRenderPass(mg);gs.setPipeline(L),gs.setBindGroup(0,pg),gs.draw(6,1,0,0),gs.end()}const G=sr(U,e,c,u,h,m,f);y.releaseTemporaryAttachment(U);const B=G.width,z=G.height,k=Math.abs(R),_=Math.abs(v),I=d===1,V=Math.ceil(B+k*2),X=Math.ceil(z+_*2),Y=I?T:V,W=I?w:X,K=(B-T)/2,q=(z-w)/2,ce=I?0:Math.floor(k+K),te=I?0:Math.floor(_+q),se=Math.floor(I?-K-R:k-R),ue=Math.floor(I?-q-v:_-v),Fe=Y/T,ge=W/w,Q=ce/T,Ct=te/w,Je=Y/B,Ut=W/z,lr=se/B,ur=ue/z,Yt=y.createTemporaryAttachment(Y,W),Gt=P.getFilterPipeline("bevel_filter",{BEVEL_TYPE:d,IS_KNOCKOUT:g?1:0}),Lt=P.getBindGroupLayout("bevel_filter");if(!Gt||!Lt)return console.error("[WebGPU BevelFilter] Pipeline not found"),y.releaseTemporaryAttachment(G),t;const Wt=S.createSampler("bevel_sampler",!0),[fr,jt,hr,Ht]=Tc(s,o),[lt,zr,Bn,kt]=Tc(i,l);pe[0]=fr,pe[1]=jt,pe[2]=hr,pe[3]=Ht,pe[4]=lt,pe[5]=zr,pe[6]=Bn,pe[7]=kt,pe[8]=a,pe[9]=I?1:0,pe[10]=g?1:0,pe[11]=d,pe[12]=Fe,pe[13]=ge,pe[14]=Q,pe[15]=Ct,pe[16]=Je,pe[17]=Ut,pe[18]=lr,pe[19]=ur;const ps=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(pe):b.createBuffer({size:pe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(ps,0,pe),Mn[0].resource.buffer=ps,Mn[1].resource=Wt,Mn[2].resource=G.texture.view,Mn[3].resource=t.texture.view;const ci=b.createBindGroup({layout:Lt,entries:Mn}),Xr=y.createRenderPassDescriptor(Yt.texture.view,0,0,0,0,"clear"),ms=x.beginRenderPass(Xr);return ms.setPipeline(Gt),ms.setBindGroup(0,ci),ms.draw(6,1,0,0),ms.end(),y.releaseTemporaryAttachment(G),ne.x=M+ce,ne.y=$+te,Yt},fs=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],p0=(t,e)=>{const r=(t>>16&255)/255,n=(t>>8&255)/255,s=(t&255)/255;return[r,n,s,e]},Pc=new Map,Ac=(t,e,r,n,s,o,i,l,c,u,a)=>{const{device:h,commandEncoder:d,frameBufferManager:g,textureManager:m}=a,f=t.width,b=t.height,x=g.createTemporaryAttachment(f,b),y=\`\${e},\${r},\${i},\${l}\`;let P=Pc.get(y);if(!P){const B=N.getConvolutionFilterFragmentShader(e,r,i,l),z=h.createShaderModule({code:B}),k=h.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]}),_=h.createPipelineLayout({bindGroupLayouts:[k]});P={pipeline:h.createRenderPipeline({layout:_,vertex:{module:z,entryPoint:"vs_main",buffers:[]},fragment:{module:z,entryPoint:"fs_main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}}),bindGroupLayout:k},Pc.set(y,P)}const S=m.createSampler("convolution_sampler",!0),M=e*r,$=Math.ceil(M/4),[T,w,E,F]=p0(c,u),A=new Float32Array($*4);for(let B=0;B{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=Math.sqrt(e[0]*e[0]+e[1]*e[1]),E=Math.sqrt(e[2]*e[2]+e[3]*e[3]),F=n*m0,A=Math.cos(F)*r*(w/g),R=Math.sin(F)*r*(E/g),v=y.getPipeline("bevel_base"),U=y.getBindGroupLayout("bevel_base");if(!v||!U)return console.error("[WebGPU GradientBevelFilter] bevel_base pipeline not found"),t;const L=x.createTemporaryAttachment($,T),D=P.createSampler("bevel_base_sampler",!0);or[0]=2*A/$,or[1]=2*R/T,or[2]=0,or[3]=0;const G=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(or):f.createBuffer({size:or.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(G,0,or),hs[0].resource.buffer=G,hs[1].resource=D,hs[2].resource=t.texture.view;const B=f.createBindGroup({layout:U,entries:hs}),z=x.createRenderPassDescriptor(L.texture.view,0,0,0,0,"clear"),k=b.beginRenderPass(z);k.setPipeline(v),k.setBindGroup(0,B),k.draw(6,1,0,0),k.end();const _=sr(L,e,l,c,a,g,m);x.releaseTemporaryAttachment(L);const I=_.width,V=_.height,X=h===1,Y=Math.abs(A),W=Math.abs(R),K=(I-$)/2,q=(V-T)/2,ce=Math.ceil(I+Y*2),te=Math.ceil(V+W*2),se=X?$:ce,ue=X?T:te,Fe=X?0:Y+K,ge=X?0:W+q,Q=X?-K-A:Y-A,Ct=X?-q-R:W-R,Je=ac(i,s,o),Ut=f.createTexture({size:{width:256,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});f.queue.writeTexture({texture:Ut},Je.buffer,{bytesPerRow:256*4,offset:Je.byteOffset},{width:256,height:1});const lr=Ut.createView(),ur=se/$,Yt=ue/T,Gt=Fe/$,Lt=ge/T,Wt=se/I,fr=ue/V,jt=Q/I,hr=Ct/V,Ht=x.createTemporaryAttachment(se,ue),lt=y.getFilterPipeline("gradient_bevel_filter",{BEVEL_TYPE:h,IS_KNOCKOUT:d?1:0}),zr=y.getBindGroupLayout("gradient_bevel_filter");if(!lt||!zr)return console.error("[WebGPU GradientBevelFilter] Pipeline not found"),x.releaseTemporaryAttachment(_),t;const Bn=P.createSampler("gradient_bevel_sampler",!0);ze[0]=u,ze[1]=X?1:0,ze[2]=d?1:0,ze[3]=h,ze[4]=ur,ze[5]=Yt,ze[6]=Gt,ze[7]=Lt,ze[8]=Wt,ze[9]=fr,ze[10]=jt,ze[11]=hr;const kt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(ze):f.createBuffer({size:ze.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(kt,0,ze),Ir[0].resource.buffer=kt,Ir[1].resource=Bn,Ir[2].resource=_.texture.view,Ir[3].resource=t.texture.view,Ir[4].resource=lr;const ps=f.createBindGroup({layout:zr,entries:Ir}),ci=x.createRenderPassDescriptor(Ht.texture.view,0,0,0,0,"clear"),Xr=b.beginRenderPass(ci);return Xr.setPipeline(lt),Xr.setBindGroup(0,ps),Xr.draw(6,1,0,0),Xr.end(),m.frameTextures.push(Ut),x.releaseTemporaryAttachment(_),ne.x=S+Fe,ne.y=M+ge,Ht},g0=Math.PI/180,Xe=new Float32Array(12),_r=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null},{binding:4,resource:null}],wc=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,l,c,a,g,m),E=w.width,F=w.height,A=ne.x,R=ne.y,v=A-S,U=R-M,L=Math.sqrt(e[0]*e[0]+e[1]*e[1]),D=Math.sqrt(e[2]*e[2]+e[3]*e[3]),G=n*g0,B=Math.cos(G)*r*(L/g),z=Math.sin(G)*r*(D/g),k=h===1,_=k?$:E+Math.max(0,Math.abs(B)-v),I=k?T:F+Math.max(0,Math.abs(z)-U),V=Math.ceil(_),X=Math.ceil(I),Y=(V-_)/2,W=(X-I)/2,K=k?0:Math.max(0,v-B)+Y,q=k?0:Math.max(0,U-z)+W,ce=k?B-A:(B>0?Math.max(0,B-v):0)+Y,te=k?z-R:(z>0?Math.max(0,z-U):0)+W,se=ac(i,s,o),ue=f.createTexture({size:{width:256,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});f.queue.writeTexture({texture:ue},se.buffer,{bytesPerRow:256*4,offset:se.byteOffset},{width:256,height:1});const Fe=ue.createView(),ge=V/$,Q=X/T,Ct=K/$,Je=q/T,Ut=V/E,lr=X/F,ur=ce/E,Yt=te/F,Gt=x.createTemporaryAttachment(V,X),Lt=y.getFilterPipeline("gradient_glow_filter",{GLOW_TYPE:h,IS_KNOCKOUT:d?1:0}),Wt=y.getBindGroupLayout("gradient_glow_filter");if(!Lt||!Wt)return console.error("[WebGPU GradientGlowFilter] Pipeline not found"),x.releaseTemporaryAttachment(w),t;const fr=P.createSampler("gradient_glow_sampler",!0);Xe[0]=u,Xe[1]=k?1:0,Xe[2]=d?1:0,Xe[3]=h,Xe[4]=ge,Xe[5]=Q,Xe[6]=Ct,Xe[7]=Je,Xe[8]=Ut,Xe[9]=lr,Xe[10]=ur,Xe[11]=Yt;const jt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Xe):f.createBuffer({size:Xe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(jt,0,Xe),_r[0].resource.buffer=jt,_r[1].resource=fr,_r[2].resource=w.texture.view,_r[3].resource=t.texture.view,_r[4].resource=Fe;const hr=f.createBindGroup({layout:Wt,entries:_r}),Ht=x.createRenderPassDescriptor(Gt.texture.view,0,0,0,0,"clear"),lt=b.beginRenderPass(Ht);return lt.setPipeline(Lt),lt.setBindGroup(0,hr),lt.draw(6,1,0,0),lt.end(),m.frameTextures.push(ue),x.releaseTemporaryAttachment(w),ne.x=S+K,ne.y=M+q,Gt},He=new Float32Array(12),Sn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],b0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Oc=new Map,Ec=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f)=>{const{device:b,commandEncoder:x,frameBufferManager:y,textureManager:P}=f,S=t.width,M=t.height,$=n,T=s,w=y.createTemporaryAttachment(S,M),E=b.createTexture({size:{width:n,height:s},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});b.queue.writeTexture({texture:E},r.buffer,{bytesPerRow:n*4,offset:r.byteOffset},{width:n,height:s});const F=\`\${l},\${c},\${h}\`;let A=Oc.get(F);if(!A){const z=N.getDisplacementMapFilterFragmentShader(l,c,h),k=b.createShaderModule({code:N.getBlurFilterVertexShader()}),_=b.createShaderModule({code:z}),I=b.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}}]}),V=b.createPipelineLayout({bindGroupLayouts:[I]});A={pipeline:b.createRenderPipeline({layout:V,vertex:{module:k,entryPoint:"main",buffers:[]},fragment:{module:_,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}}),bindGroupLayout:I},Oc.set(F,A)}const R=P.createSampler("displacement_sampler",!0),v=h===1,U=v?48:32;if(He[0]=$/n,He[1]=T/s,He[2]=o/n,He[3]=(T-s-i)/s,He[4]=u/$,He[5]=a/T,He[6]=0,He[7]=0,v){const[z,k,_,I]=b0(d,g);He[8]=z,He[9]=k,He[10]=_,He[11]=I}const L=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(He,U):b.createBuffer({size:U,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(L,0,He,0,U/4),Sn[0].resource.buffer=L,Sn[1].resource=R,Sn[2].resource=t.texture.view,Sn[3].resource=E.createView();const D=b.createBindGroup({layout:A.bindGroupLayout,entries:Sn}),G=y.createRenderPassDescriptor(w.texture.view,0,0,0,0,"clear"),B=x.beginRenderPass(G);return B.setPipeline(A.pipeline),B.setBindGroup(0,D),B.draw(6,1,0,0),B.end(),f.frameTextures.push(E),w},bt=new Float32Array(4),Te=new Float32Array(6),Ee=new Float32Array(6),oe=new Float32Array(8),Ze=new Float32Array(12),ve=new Float32Array(20),fe=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],x0=new Set(["normal","layer","add","screen","alpha","erase","copy"]),y0=new Float32Array([1,-1,0,1]),v0=t=>t[0]===1&&t[1]===1&&t[2]===1&&t[3]===1&&t[4]===0&&t[5]===0&&t[6]===0&&t[7]===0,M0=(t,e,r)=>{const n=t.frameBufferManager.createTemporaryAttachment(e.width,e.height),s=t.pipelineManager.getPipeline("color_transform"),o=t.pipelineManager.getBindGroupLayout("texture_copy");if(!s||!o||!e.texture||!n.texture)return e;oe[0]=r[0],oe[1]=r[1],oe[2]=r[2],oe[3]=r[3],oe[4]=r[4],oe[5]=r[5],oe[6]=r[6],oe[7]=0;const i=t.bufferManager.acquireAndWriteUniformBuffer(oe),l=t.textureManager.createSampler("color_transform_sampler",!1);fe[0].resource.buffer=i,fe[1].resource=l,fe[2].resource=e.texture.view;const c=t.device.createBindGroup({layout:o,entries:fe}),u=t.frameBufferManager.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),a=t.commandEncoder.beginRenderPass(u);return a.setPipeline(s),a.setBindGroup(0,c),a.draw(6,1,0,0),a.end(),n},S0=(t,e,r)=>{const n=r.createTemporaryAttachment(t.w,t.h),s=Ne()||r.getAttachment("atlas");return s&&s.texture&&n.texture?e.copyTextureToTexture({texture:s.texture.resource,origin:{x:t.x,y:t.y,z:0}},{texture:n.texture.resource,origin:{x:0,y:0,z:0}},{width:t.w,height:t.h}):console.error("[WebGPU Filter] getTextureFromNode: FAILED - missing atlas or textures"),n},$0=t=>x0.has(t),T0=(t,e,r,n,s,o)=>{const i=t.frameBufferManager.createTemporaryAttachment(s,o),l=t.pipelineManager.getPipeline("complex_blend_copy"),c=t.pipelineManager.getBindGroupLayout("texture_copy");if(!l||!c||!e.texture||!i.texture)return i;const u=s/e.width,a=o/e.height,h=r/e.width,d=n/e.height;bt[0]=u,bt[1]=a,bt[2]=h,bt[3]=d;const g=t.bufferManager.acquireAndWriteUniformBuffer(bt),m=t.textureManager.createSampler("filter_copy_sampler",!1);fe[0].resource.buffer=g,fe[1].resource=m,fe[2].resource=e.texture.view;const f=t.device.createBindGroup({layout:c,entries:fe}),b=t.frameBufferManager.createRenderPassDescriptor(i.texture.view,0,0,0,0,"clear"),x=t.commandEncoder.beginRenderPass(b);return x.setPipeline(l),x.setBindGroup(0,f),x.draw(6,1,0,0),x.end(),i},B0=(t,e,r,n,s)=>{const o=r.msaa&&r.msaaTexture?.view,i=o?"filter_complex_blend_output_msaa":"filter_complex_blend_output",l=t.pipelineManager.getPipeline(i),c=t.pipelineManager.getBindGroupLayout("positioned_texture");if(!l||!c||!e.texture||!r.texture)return;oe[0]=n,oe[1]=s,oe[2]=e.width,oe[3]=e.height,oe[4]=r.width,oe[5]=r.height,oe[6]=0,oe[7]=0;const u=t.bufferManager.acquireAndWriteUniformBuffer(oe),a=t.textureManager.createSampler("filter_blend_output_sampler",!1);fe[0].resource.buffer=u,fe[1].resource=a,fe[2].resource=e.texture.view;const h=t.device.createBindGroup({layout:c,entries:fe}),d=o?r.msaaTexture.view:r.texture.view,g=o?r.texture.view:null,m=t.frameBufferManager.createRenderPassDescriptor(d,0,0,0,0,"load",g),f=t.commandEncoder.beginRenderPass(m);f.setPipeline(l),f.setBindGroup(0,h),f.draw(6,1,0,0),f.end()},P0=(t,e,r,n,s,o,i,l)=>{const c=t.mainAttachment||t.frameBufferManager.getAttachment("main");if(!c||!c.texture||!e.texture)return;let u=s,a=o,h=e.width,d=e.height,g=0,m=0;if(u<0&&(g=-u/e.width,h+=u,u=0),a<0&&(m=-a/e.height,d+=a,a=0),h<=0||d<=0)return;const f=c.width,b=c.height;if(u+h>f&&(h=f-u),a+d>b&&(d=b-a),$0(n)){const x=c.msaa&&c.msaaTexture?.view;let y;switch(n){case"add":y=x?"filter_output_add_msaa":"filter_output_add";break;case"screen":y=x?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":y=x?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":y=x?"filter_output_erase_msaa":"filter_output_erase";break;case"copy":y=x?"texture_copy_bgra_msaa":"texture_copy_bgra";break;default:y=x?"filter_output_msaa":"filter_output";break}let P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("texture_copy");if((!P||!S)&&(y=x?"filter_output_msaa":"filter_output",P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("texture_copy"),!P||!S))return;const M=t.textureManager.createSampler("filter_output_sampler",!0),$=h/e.width,T=d/e.height;bt[0]=$,bt[1]=T,bt[2]=g,bt[3]=m;const w=t.bufferManager.acquireAndWriteUniformBuffer(bt);fe[0].resource.buffer=w,fe[1].resource=M,fe[2].resource=e.texture.view;const E=t.device.createBindGroup({layout:S,entries:fe}),F=x?c.msaaTexture.view:c.texture.view,A=x?c.texture.view:null,R=t.frameBufferManager.createRenderPassDescriptor(F,0,0,0,0,"load",A),v=Math.max(0,u),U=Math.max(0,a),L=Math.max(1,h),D=Math.max(1,d),G=Math.max(0,Math.floor(v)),B=Math.max(0,Math.floor(U)),z=Math.max(1,Math.min(Math.ceil(v+L)-G,f-G)),k=Math.max(1,Math.min(Math.ceil(U+D)-B,b-B));if(z<=0||k<=0||G>=f||B>=b)return;const _=t.commandEncoder.beginRenderPass(R);_.setPipeline(P),_.setBindGroup(0,E),_.setViewport(v,U,L,D,0,1),_.setScissorRect(G,B,z,k),_.draw(6,1,0,0),_.end()}else{const x=T0(t,c,u,a,h,d);oe[0]=r[0],oe[1]=r[1],oe[2]=r[2],oe[3]=r[3],oe[4]=r[4],oe[5]=r[5],oe[6]=r[6],oe[7]=0;const y=Xo(e,x,n,oe,{device:t.device,commandEncoder:t.commandEncoder,bufferManager:t.bufferManager,frameBufferManager:t.frameBufferManager,pipelineManager:t.pipelineManager,textureManager:t.textureManager,frameTextures:t.frameTextures});B0(t,y,c,u,a),t.frameBufferManager.releaseTemporaryAttachment(x),t.frameBufferManager.releaseTemporaryAttachment(y)}},A0=(t,e,r,n,s,o,i,l,c,u,a,h)=>{ne.x=0,ne.y=0;let d=S0(t,u.commandEncoder,u.frameBufferManager);if(d.texture){const B=u.frameBufferManager.createTemporaryAttachment(t.w,t.h),z=u.pipelineManager.getPipeline("texture_copy_rgba8"),k=u.pipelineManager.getBindGroupLayout("texture_copy");if(z&&k&&B.texture){const _=u.textureManager.createSampler("filter_flip_sampler",!1),I=u.bufferManager.acquireAndWriteUniformBuffer(y0);fe[0].resource.buffer=I,fe[1].resource=_,fe[2].resource=d.texture.view;const V=u.device.createBindGroup({layout:k,entries:fe}),X=u.frameBufferManager.createRenderPassDescriptor(B.texture.view,0,0,0,0,"clear"),Y=u.commandEncoder.beginRenderPass(X);Y.setPipeline(z),Y.setBindGroup(0,V),Y.draw(6,1,0,0),Y.end(),u.frameBufferManager.releaseTemporaryAttachment(d),d=B}}const g=le.getDevicePixelRatio(),m=Math.sqrt(s[0]*s[0]+s[1]*s[1]),f=Math.sqrt(s[2]*s[2]+s[3]*s[3]),b=Math.atan2(s[1],s[0]),x=Math.atan2(-s[2],s[3]),y=n?m*Math.cos(b):Math.cos(b),P=n?m*Math.sin(b):Math.sin(b),S=n?-f*Math.sin(x):-Math.sin(x),M=n?f*Math.cos(x):Math.cos(x);Te[0]=y,Te[1]=P,Te[2]=S,Te[3]=M,Te[4]=e/2,Te[5]=r/2,Ee[0]=1,Ee[1]=0,Ee[2]=0,Ee[3]=1,Ee[4]=-t.w/2,Ee[5]=-t.h/2;const $=Te[0]*Ee[0]+Te[2]*Ee[1],T=Te[1]*Ee[0]+Te[3]*Ee[1],w=Te[0]*Ee[2]+Te[2]*Ee[3],E=Te[1]*Ee[2]+Te[3]*Ee[3],F=Te[0]*Ee[4]+Te[2]*Ee[5]+Te[4],A=Te[1]*Ee[4]+Te[3]*Ee[5]+Te[5];let R=0,v=0;if($!==1||T!==0||w!==0||E!==1){const B=u.frameBufferManager.createTemporaryAttachment(e,r),k=u.pipelineManager.getPipeline("texture_scale"),_=u.pipelineManager.getBindGroupLayout("texture_scale");if(k&&_){Ze[0]=$,Ze[1]=T,Ze[2]=w,Ze[3]=E,Ze[4]=F,Ze[5]=A,Ze[6]=t.w,Ze[7]=t.h,Ze[8]=e,Ze[9]=r,Ze[10]=0,Ze[11]=0;const I=u.bufferManager.acquireAndWriteUniformBuffer(Ze,48),V=u.textureManager.createSampler("filter_scale_sampler",!0);fe[0].resource.buffer=I,fe[1].resource=V,fe[2].resource=d.texture.view;const X=u.device.createBindGroup({layout:_,entries:fe}),Y=u.frameBufferManager.createRenderPassDescriptor(B.texture.view,0,0,0,0,"clear"),W=u.commandEncoder.beginRenderPass(Y);W.setPipeline(k),W.setBindGroup(0,X),W.draw(6,1,0,0),W.end(),R=F,v=A,u.frameBufferManager.releaseTemporaryAttachment(d),d=B}}for(let B=0;c.length>B;)switch(c[B++]){case 0:{const k=c[B++],_=c[B++],I=c[B++],V=c[B++],X=c[B++],Y=c[B++],W=c[B++],K=c[B++],q=c[B++],ce=c[B++],te=c[B++],se=!!c[B++],ue=Bc(d,s,k,_,I,V,X,Y,W,K,q,ce,te,se,g,u);d!==ue&&u.frameBufferManager.releaseTemporaryAttachment(d),d=ue}break;case 1:{const k=c[B++],_=c[B++],I=c[B++],V=sr(d,s,k,_,I,g,u);d!==V&&u.frameBufferManager.releaseTemporaryAttachment(d),d=V}break;case 2:{ve[0]=c[B++],ve[1]=c[B++],ve[2]=c[B++],ve[3]=c[B++],ve[4]=c[B++],ve[5]=c[B++],ve[6]=c[B++],ve[7]=c[B++],ve[8]=c[B++],ve[9]=c[B++],ve[10]=c[B++],ve[11]=c[B++],ve[12]=c[B++],ve[13]=c[B++],ve[14]=c[B++],ve[15]=c[B++],ve[16]=c[B++],ve[17]=c[B++],ve[18]=c[B++],ve[19]=c[B++];const k=Mc(d,ve,u);d!==k&&u.frameBufferManager.releaseTemporaryAttachment(d),d=k}break;case 3:{const k=c[B++],_=c[B++],I=k*_,V=new Float32Array(I);for(let se=0;set?t[0]===1&&t[1]===1&&t[2]===1&&t[3]===1&&t[4]===0&&t[5]===0&&t[6]===0&&t[7]===0:!0,Cc=(t,e,r)=>{const n=t.frameBufferManager.createTemporaryAttachment(e.width,e.height),s=t.pipelineManager.getPipeline("color_transform"),o=t.pipelineManager.getBindGroupLayout("texture_copy");if(!s||!o||!e.texture||!n.texture)return e;ie[0]=r[0],ie[1]=r[1],ie[2]=r[2],ie[3]=r[3],ie[4]=r[4],ie[5]=r[5],ie[6]=r[6],ie[7]=0;const i=t.bufferManager.acquireAndWriteUniformBuffer(ie),l=t.textureManager.createSampler("container_ct_sampler",!1);Ie[0].resource.buffer=i,Ie[1].resource=l,Ie[2].resource=e.texture.view;const c=t.device.createBindGroup({layout:o,entries:Ie}),u=t.frameBufferManager.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),a=t.commandEncoder.beginRenderPass(u);return a.setPipeline(s),a.setBindGroup(0,c),a.draw(6,1,0,0),a.end(),n},Yo=(t,e,r,n,s,o)=>{const i=t.frameBufferManager.createTemporaryAttachment(s,o),l=t.pipelineManager.getPipeline("complex_blend_copy"),c=t.pipelineManager.getBindGroupLayout("texture_copy");if(!l||!c||!e.texture||!i.texture)return i;const u=s/e.width,a=r/e.width,h=-(o/e.height),d=(n+o)/e.height;xt[0]=u,xt[1]=h,xt[2]=a,xt[3]=d;const g=t.bufferManager.acquireAndWriteUniformBuffer(xt),m=t.textureManager.createSampler("container_copy_sampler",!1);Ie[0].resource.buffer=g,Ie[1].resource=m,Ie[2].resource=e.texture.view;const f=t.device.createBindGroup({layout:c,entries:Ie}),b=t.frameBufferManager.createRenderPassDescriptor(i.texture.view,0,0,0,0,"clear"),x=t.commandEncoder.beginRenderPass(b);return x.setPipeline(l),x.setBindGroup(0,f),x.draw(6,1,0,0),x.end(),i},Uc=(t,e,r,n,s,o,i)=>{if(!r.texture||!e.texture)return;let l=s,c=o,u=e.width,a=e.height,h=0,d=0;if(l<0&&(h=-l/e.width,u+=l,l=0),c<0&&(d=-c/e.height,a+=c,c=0),u<=0||a<=0)return;const g=r.width,m=r.height;if(l+u>g&&(u=g-l),c+a>m&&(a=m-c),F0.has(n)){const f=r.msaa&&r.msaaTexture?.view;let b;switch(n){case"add":b=f?"filter_output_add_msaa":"filter_output_add";break;case"screen":b=f?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":b=f?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":b=f?"filter_output_erase_msaa":"filter_output_erase";break;case"copy":b=f?"texture_copy_bgra_msaa":"texture_copy_bgra";break;default:b=f?"filter_output_msaa":"filter_output";break}const x=t.pipelineManager.getPipeline(b),y=t.pipelineManager.getBindGroupLayout("texture_copy");if(!x||!y)return;const P=t.textureManager.createSampler("container_output_sampler",!0),S=u/e.width,M=a/e.height;xt[0]=S,xt[1]=M,xt[2]=h,xt[3]=d;const $=i.acquireAndWriteUniformBuffer(xt);Ie[0].resource.buffer=$,Ie[1].resource=P,Ie[2].resource=e.texture.view;const T=t.device.createBindGroup({layout:y,entries:Ie}),w=f?r.msaaTexture.view:r.texture.view,E=f?r.texture.view:null,F=t.frameBufferManager.createRenderPassDescriptor(w,0,0,0,0,"load",E),A=Math.max(0,l),R=Math.max(0,c),v=Math.max(1,u),U=Math.max(1,a),L=Math.max(0,Math.floor(A)),D=Math.max(0,Math.floor(R)),G=Math.max(1,Math.min(Math.ceil(A+v)-L,g-L)),B=Math.max(1,Math.min(Math.ceil(R+U)-D,m-D));if(G<=0||B<=0||L>=g||D>=m)return;const z=t.commandEncoder.beginRenderPass(F);z.setPipeline(x),z.setBindGroup(0,T),z.setViewport(A,R,v,U,0,1),z.setScissorRect(L,D,G,B),z.draw(6,1,0,0),z.end()}else{const f=Yo(t,r,l,c,u,a);ie[0]=ir[0],ie[1]=ir[1],ie[2]=ir[2],ie[3]=ir[3],ie[4]=ir[4]/255,ie[5]=ir[5]/255,ie[6]=ir[6]/255,ie[7]=0;const b=Xo(e,f,n,ie,{device:t.device,commandEncoder:t.commandEncoder,bufferManager:t.bufferManager,frameBufferManager:t.frameBufferManager,pipelineManager:t.pipelineManager,textureManager:t.textureManager,frameTextures:t.frameTextures}),x=r.msaa&&r.msaaTexture?.view,y=x?"filter_complex_blend_output_msaa":"filter_complex_blend_output",P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("positioned_texture");if(P&&S&&b.texture&&r.texture){ie[0]=l,ie[1]=c,ie[2]=b.width,ie[3]=b.height,ie[4]=r.width,ie[5]=r.height,ie[6]=0,ie[7]=0;const M=i.acquireAndWriteUniformBuffer(ie),$=t.textureManager.createSampler("container_blend_output_sampler",!1);Ie[0].resource.buffer=M,Ie[1].resource=$,Ie[2].resource=b.texture.view;const T=t.device.createBindGroup({layout:S,entries:Ie}),w=x?r.msaaTexture.view:r.texture.view,E=x?r.texture.view:null,F=t.frameBufferManager.createRenderPassDescriptor(w,0,0,0,0,"load",E),A=t.commandEncoder.beginRenderPass(F);A.setPipeline(P),A.setBindGroup(0,T),A.draw(6,1,0,0),A.end()}t.frameBufferManager.releaseTemporaryAttachment(f),t.frameBufferManager.releaseTemporaryAttachment(b)}},w0=(t,e,r,n,s)=>{ne.x=0,ne.y=0;for(let o=0;r.length>o;)switch(r[o++]){case 0:{const l=Bc(t,e,r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],!!r[o++],n,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 1:{const l=sr(t,e,r[o++],r[o++],r[o++],n,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 2:{Me[0]=r[o++],Me[1]=r[o++],Me[2]=r[o++],Me[3]=r[o++],Me[4]=r[o++],Me[5]=r[o++],Me[6]=r[o++],Me[7]=r[o++],Me[8]=r[o++],Me[9]=r[o++],Me[10]=r[o++],Me[11]=r[o++],Me[12]=r[o++],Me[13]=r[o++],Me[14]=r[o++],Me[15]=r[o++],Me[16]=r[o++],Me[17]=r[o++],Me[18]=r[o++],Me[19]=r[o++];const l=Mc(t,Me,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 3:{const l=r[o++],c=r[o++],u=l*c,a=new Float32Array(u);for(let d=0;d{if(i&&s&&l&&c){let f=Yo(g,t,0,0,t.width,t.height);g.frameBufferManager.releaseTemporaryAttachment(t);const b=le.getDevicePixelRatio();if(f=w0(f,s,c,b,g),u&&(ee.set(u,"fKey",a),ee.set(u,"fTexture",f)),f){let x=f,y=null;Rc(o)||(y=Cc(g,f,o),x=y);const P=Math.sqrt(s[0]*s[0]+s[1]*s[1]),S=Math.sqrt(s[2]*s[2]+s[3]*s[3]),M=l[0]*(P/b),$=l[1]*(S/b),T=M+s[4],w=$+s[5];Uc(g,x,e,n,T,w,m),y&&g.frameBufferManager.releaseTemporaryAttachment(y),u||g.frameBufferManager.releaseTemporaryAttachment(f)}}else{let f=Yo(g,t,0,0,t.width,t.height);if(g.frameBufferManager.releaseTemporaryAttachment(t),!Rc(o)){const b=Cc(g,f,o);g.frameBufferManager.releaseTemporaryAttachment(f),f=b}Uc(g,f,e,n,s[4],s[5],m),g.frameBufferManager.releaseTemporaryAttachment(f)}},$n=new Float32Array([1,1,0,0]),Wo=[],Gc=new Float32Array([0,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,0,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,0,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1]),Lc=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]),Et=new Float32Array(8),ke=new Float32Array(16);let jo=null,kc=null,ds=null;const Ic={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"},E0={colorAttachments:[Ic]},he=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Tn={r:0,g:0,b:0,a:0},Ho={view:null,clearValue:Tn,loadOp:"clear",storeOp:"store",resolveTarget:void 0},_c={view:null,stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},Ko={colorAttachments:[Ho]},ar={view:null,resolveTarget:void 0,loadOp:"load",storeOp:"store"},Vr={view:null,stencilLoadOp:"load",stencilStoreOp:"store"},Rt={colorAttachments:[ar]};class R0{$stack;$matrix;$clearColorR;$clearColorG;$clearColorB;$clearColorA;$mainAttachmentObject;$stackAttachmentObject;globalAlpha;globalCompositeOperation;imageSmoothingEnabled;$fillStyle;$strokeStyle;maskBounds;thickness;caps;joints;miterLimit;device;canvasContext;preferredFormat;commandEncoder=null;renderPassEncoder=null;mainTexture=null;mainTextureView=null;frameStarted=!1;frameTextures=[];pooledTextures=[];pooledRenderTextures=[];currentRenderTarget=null;viewportWidth=0;viewportHeight=0;pathCommand;bufferManager;textureManager;frameBufferManager;pipelineManager;computePipelineManager;attachmentManager;newDrawState=!1;$containerLayerStack=[];containerLayerContentSizes=[];inMaskMode=!1;nodeAreaCleared=!1;currentNodeScissor=null;nodeRenderPassAtlasIndex=-1;fillDynamicBindGroup=null;fillDynamicBindGroupBuffer=null;nodeClearQuadBuffer=null;useOptimizedInstancing=!0;$uniformData8=new Float32Array(8);$scissorRect={x:0,y:0,w:0,h:0};$filterConfig;constructor(e,r,n,s=1){this.device=e,this.canvasContext=r,this.preferredFormat=n,le.setDevice(e),le.setDevicePixelRatio(s);const o=e.limits.maxTextureDimension2D,i=Math.max(2048,o/2);le.setRenderMaxSize(i),this.$stack=le.createArray(),this.$stackAttachmentObject=le.createArray(),this.$matrix=le.createFloat32Array(9),this.$matrix.set([1,0,0,0,1,0,0,0,1]),this.$clearColorR=0,this.$clearColorG=0,this.$clearColorB=0,this.$clearColorA=0,this.thickness=1,this.caps=0,this.joints=2,this.miterLimit=0,this.$mainAttachmentObject=null,this.globalAlpha=1,this.globalCompositeOperation="normal",this.imageSmoothingEnabled=!1,this.$fillStyle=new Float32Array([1,1,1,1]),this.$strokeStyle=new Float32Array([1,1,1,1]),this.maskBounds={xMin:0,yMin:0,xMax:0,yMax:0},r.configure({device:e,format:n,alphaMode:"premultiplied"}),this.viewportWidth=r.canvas.width,this.viewportHeight=r.canvas.height,this.pathCommand=new xd,this.bufferManager=new Od(e),this.textureManager=new Ud(e),this.frameBufferManager=new Hd(e,n),this.pipelineManager=new qp(e,n),this.pipelineManager.preloadLazyGroups(),this.computePipelineManager=new Qp(e),this.attachmentManager=new ip(e),em(l=>{const c=le.getRenderMaxSize();return this.frameBufferManager.createAttachment(\`atlas_\${l}\`,c,c,!1,!0)}),this.$filterConfig={device:this.device,commandEncoder:null,bufferManager:this.bufferManager,frameBufferManager:this.frameBufferManager,pipelineManager:this.pipelineManager,textureManager:this.textureManager,computePipelineManager:this.computePipelineManager,frameTextures:this.frameTextures},ud(this)}clearTransferBounds(){this.beginFrame()}updateBackgroundColor(e,r,n,s){this.$clearColorR=e,this.$clearColorG=r,this.$clearColorB=n,this.$clearColorA=s}fillBackgroundColor(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture)return;this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view;Ho.view=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,Ho.resolveTarget=e?this.$mainAttachmentObject.texture.view:void 0,Tn.r=this.$clearColorR,Tn.g=this.$clearColorG,Tn.b=this.$clearColorB,Tn.a=this.$clearColorA;const r=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil?.view;r?(_c.view=r,Ko.depthStencilAttachment=_c):Ko.depthStencilAttachment=void 0,this.renderPassEncoder=this.commandEncoder.beginRenderPass(Ko),this.renderPassEncoder.end(),this.renderPassEncoder=null}resize(e,r,n=!0){this.clearArraysInstanced();for(const o of this.frameTextures)o.destroy();this.frameTextures.length=0;for(const o of this.pooledTextures)Ot(o);this.pooledTextures.length=0;for(const o of this.pooledRenderTextures)Xt(o);this.pooledRenderTextures.length=0,Em(),this.frameStarted=!1,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,am();const s=this.canvasContext.canvas;if(s&&"width"in s&&"height"in s&&(s.width=e,s.height=r),this.$stackAttachmentObject.length){for(let o=0;o0?Wo.pop():new Float32Array(9);e.set(this.$matrix),this.$stack.push(e)}restore(){const e=this.$stack.pop();e&&(this.$matrix.set(e),Wo.push(e))}setTransform(e,r,n,s,o,i){this.$matrix[0]=e,this.$matrix[1]=r,this.$matrix[3]=n,this.$matrix[4]=s,this.$matrix[6]=o,this.$matrix[7]=i}transform(e,r,n,s,o,i){const l=this.$matrix,c=l[0],u=l[1],a=l[3],h=l[4],d=l[6],g=l[7];l[0]=e*c+r*a,l[1]=e*u+r*h,l[3]=n*c+s*a,l[4]=n*u+s*h,l[6]=o*c+i*a+d,l[7]=o*u+i*h+g}reset(){this.$matrix.set([1,0,0,0,1,0,0,0,1]),this.$stack.length=0,this.$stackAttachmentObject.length=0,this.globalAlpha=1,this.globalCompositeOperation="normal",this.imageSmoothingEnabled=!1}beginPath(){this.pathCommand.beginPath()}moveTo(e,r){this.pathCommand.moveTo(e,r)}lineTo(e,r){this.pathCommand.lineTo(e,r)}quadraticCurveTo(e,r,n,s){this.pathCommand.quadraticCurveTo(e,r,n,s)}fillStyle(e,r,n,s){this.$fillStyle[0]=e,this.$fillStyle[1]=r,this.$fillStyle[2]=n,this.$fillStyle[3]=s}strokeStyle(e,r,n,s){this.$strokeStyle[0]=e,this.$strokeStyle[1]=r,this.$strokeStyle[2]=n,this.$strokeStyle[3]=s}closePath(){this.pathCommand.closePath()}arc(e,r,n){this.pathCommand.arc(e,r,n)}bezierCurveTo(e,r,n,s,o,i){this.pathCommand.bezierCurveTo(e,r,n,s,o,i)}ensureFillRenderPass(){if(this.frameStarted||this.beginFrame(),this.ensureCommandEncoder(),this.renderPassEncoder){this.currentRenderTarget&&this.ensureNodeAreaCleared();return}{const e=this.getCurrentTextureView(),r=Ne(),n=r?.msaa&&r?.msaaTexture?.view,s=n?r.msaaTexture.view:e,o=n?e:null;if(this.currentRenderTarget&&r?.stencil?.view){const i=n&&r?.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,l=this.frameBufferManager.createStencilRenderPassDescriptor(s,i,"load","clear",o);this.renderPassEncoder=this.commandEncoder.beginRenderPass(l)}else if(!this.currentRenderTarget&&(gt()||nr())&&this.$mainAttachmentObject?.stencil?.view){const i=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,l=i?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,c=i&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,u=i?this.$mainAttachmentObject.texture.view:null,a=this.frameBufferManager.createStencilRenderPassDescriptor(l,c,"load","load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a),gt()&&this.renderPassEncoder.setStencilReference(Or())}else if(!this.currentRenderTarget&&this.$mainAttachmentObject){const i=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,l=i?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,c=i?this.$mainAttachmentObject.texture.view:null;if(this.$mainAttachmentObject.stencil?.view){const u=i&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,a=this.frameBufferManager.createStencilRenderPassDescriptor(l,u,"load","clear",c);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}else{const u=this.frameBufferManager.createRenderPassDescriptor(l,0,0,0,0,"load",c);this.renderPassEncoder=this.commandEncoder.beginRenderPass(u)}}else{const i=this.frameBufferManager.createRenderPassDescriptor(s,0,0,0,0,"load",o);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i)}}this.currentRenderTarget&&this.ensureNodeAreaCleared()}fill(){const e=this.pathCommand.$getVertices;if(e.length===0)return;this.ensureFillRenderPass();const r=this.viewportWidth,n=this.viewportHeight,s=dn(e);if(s.indexCount===0)return;const o=this.bufferManager.acquireVertexBuffer(s.buffer.byteLength,s.buffer),i=this.writeFillUniform(this.$fillStyle[0],this.$fillStyle[1],this.$fillStyle[2],this.$fillStyle[3],this.$matrix[0],this.$matrix[1],this.$matrix[3],this.$matrix[4],this.$matrix[6],this.$matrix[7],r,n),l=this.getOrCreateFillDynamicBindGroup(),c=Ne();if(this.currentRenderTarget&&c?.stencil?.view)this.fillWithStencil(o,s.indexCount,l,i);else if(!this.currentRenderTarget&&!this.inMaskMode&&!gt()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(o,s.indexCount,l,i);else{const u=(this.inMaskMode||gt())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(o,s.indexCount,u,l,i)}}getOrCreateFillDynamicBindGroup(){const e=this.bufferManager.dynamicUniform.getBuffer();if(!this.fillDynamicBindGroup||this.fillDynamicBindGroupBuffer!==e){const r=this.pipelineManager.getBindGroupLayout("fill_dynamic");if(!r)throw new Error("[WebGPU] fill_dynamic bind group layout not found");this.fillDynamicBindGroup=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:{buffer:e,size:256}}]}),this.fillDynamicBindGroupBuffer=e}return this.fillDynamicBindGroup}writeFillUniform(e,r,n,s,o,i,l,c,u,a,h,d){return ke[0]=e,ke[1]=r,ke[2]=n,ke[3]=s,ke[4]=o/h,ke[5]=i/d,ke[6]=0,ke[7]=0,ke[8]=l/h,ke[9]=c/d,ke[10]=0,ke[11]=0,ke[12]=u/h,ke[13]=a/d,ke[14]=1,ke[15]=0,this.bufferManager.dynamicUniform.allocate(ke)}fillWithStencil(e,r,n,s){km(this.renderPassEncoder,this.pipelineManager,e,r,n,s)}fillWithStencilMain(e,r,n,s){Im(this.renderPassEncoder,this.pipelineManager,e,r,n,s)}fillSimple(e,r,n,s,o){const i=this.$mainAttachmentObject?.clipLevel??1;_m(this.renderPassEncoder,this.pipelineManager,e,r,s,o,!!this.currentRenderTarget,n,i)}bindAttachment(e){this.attachmentManager.bindAttachment(e);const r=e.color?.view??e.texture?.view;r&&(this.currentRenderTarget=r)}unbindAttachment(){this.attachmentManager.unbindAttachment(),this.currentRenderTarget=null}getAttachmentObject(e,r,n=!1){return this.attachmentManager.getAttachmentObject(e,r,n)}releaseAttachment(e){this.attachmentManager.releaseAttachment(e)}stroke(){const e=this.pathCommand.getVerticesForStroke();if(e.length===0)return;this.ensureFillRenderPass();const r=this.viewportWidth,n=this.viewportHeight,s=Am(e,this.thickness);if(s.length===0)return;const o=dn(s);if(o.indexCount===0)return;const i=this.bufferManager.acquireVertexBuffer(o.buffer.byteLength,o.buffer),l=this.writeFillUniform(this.$strokeStyle[0],this.$strokeStyle[1],this.$strokeStyle[2],this.$strokeStyle[3],this.$matrix[0],this.$matrix[1],this.$matrix[3],this.$matrix[4],this.$matrix[6],this.$matrix[7],r,n),c=this.getOrCreateFillDynamicBindGroup(),u=Ne();if(this.currentRenderTarget&&u?.stencil?.view)this.fillWithStencil(i,o.indexCount,c,l);else if(!this.currentRenderTarget&&!this.inMaskMode&&!gt()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(i,o.indexCount,c,l);else{const a=(this.inMaskMode||gt())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(i,o.indexCount,a,c,l)}this.pathCommand.reset()}gradientFill(e,r,n,s,o,i){const l=this.pathCommand.$getVertices;if(l.length===0)return;this.ensureFillRenderPass();const c=this.viewportWidth,u=this.viewportHeight,h=!!((this.inMaskMode||gt())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),d=!!this.currentRenderTarget,g=Dm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.$matrix,this.$fillStyle,e,r,n,s,o,i,c,u,d,h,this.$mainAttachmentObject?.clipLevel??1);g&&this.addFrameTexture(g),this.beginPath()}bitmapFill(e,r,n,s,o,i){const l=this.pathCommand.$getVertices;if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!((this.inMaskMode||gt())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),h=u||a,d=this.$mainAttachmentObject?.clipLevel??1,g=Nm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.$matrix,this.$fillStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,!!h,d);g&&this.addFrameTexture(g),this.beginPath()}gradientStroke(e,r,n,s,o,i){const l=this.pathCommand.getVerticesForStroke();if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),h=u||a,d=Ym(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.thickness,this.$matrix,this.$strokeStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,h);d&&this.addFrameTexture(d),this.pathCommand.reset()}bitmapStroke(e,r,n,s,o,i){const l=this.pathCommand.getVerticesForStroke();if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),h=u||a,d=Hm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.thickness,this.$matrix,this.$strokeStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,h);d&&this.addFrameTexture(d),this.pathCommand.reset()}clip(){let e=this.frameBufferManager.getCurrentAttachment();const r=!e||e===this.$mainAttachmentObject;if(!e&&this.$mainAttachmentObject&&(e=this.$mainAttachmentObject),!e||!e.stencil)return;const n=this.pathCommand.$getVertices;if(n.length!==0){if(!this.renderPassEncoder)if(this.ensureCommandEncoder(),r&&this.$mainAttachmentObject?.stencil?.view){const s=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,o=s?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,i=s&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,l=this.frameBufferManager.createStencilRenderPassDescriptor(o,i,"load","load");this.renderPassEncoder=this.commandEncoder.beginRenderPass(l)}else return;Qm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,e,n,this.$matrix,this.$fillStyle,this.globalAlpha,r)}}bind(e){this.frameBufferManager.setCurrentAttachment(e),this.viewportWidth=e.width,this.viewportHeight=e.height}get currentAttachmentObject(){return this.frameBufferManager.getCurrentAttachment()||this.$mainAttachmentObject}get atlasAttachmentObject(){return Ne()}useGrid(e){Ja.set(ec,e)}beginNodeRendering(e){this.nodeAreaCleared=!1,this.frameStarted||this.beginFrame();const r=bo(e.index)||Ne();if(r&&r.texture){if(this.renderPassEncoder&&this.nodeRenderPassAtlasIndex===e.index)this.currentRenderTarget=r.texture.view,this.viewportWidth=r.width,this.viewportHeight=r.height;else{this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.currentRenderTarget=r.texture.view,this.viewportWidth=r.width,this.viewportHeight=r.height,this.ensureCommandEncoder();const l=r.msaa&&r.msaaTexture?.view,c=l?r.msaaTexture.view:r.texture.view,u=l?r.texture.view:null;if(r.stencil?.view){const a=l&&r.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,h=this.frameBufferManager.createStencilRenderPassDescriptor(c,a,"load","load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(h)}else{const a=this.frameBufferManager.createRenderPassDescriptor(c,0,0,0,0,"load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}this.nodeRenderPassAtlasIndex=e.index}let n=Math.max(0,e.x),s=Math.max(0,e.y),o=Math.min(e.w,r.width-n),i=Math.min(e.h,r.height-s);if(n=Math.min(n,r.width),s=Math.min(s,r.height),o=Math.max(0,Math.min(o,r.width-n)),i=Math.max(0,Math.min(i,r.height-s)),this.$scissorRect.x=n,this.$scissorRect.y=s,this.$scissorRect.w=o,this.$scissorRect.h=i,this.currentNodeScissor=this.$scissorRect,o>0&&i>0){const l=Math.min(o+1,r.width-n),c=Math.min(i+1,r.height-s);this.renderPassEncoder.setScissorRect(n,s,l,c)}}}ensureNodeAreaCleared(){this.nodeAreaCleared||(this.nodeAreaCleared=!0,this.clearNodeArea())}clearNodeArea(){if(!this.renderPassEncoder)return;const e=this.pipelineManager.getPipeline("node_clear_atlas");if(!e)return;if(!this.nodeClearQuadBuffer){const n=this.device.createBuffer({size:Lc.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0});new Float32Array(n.getMappedRange()).set(Lc),n.unmap(),this.nodeClearQuadBuffer=n}const r=this.nodeClearQuadBuffer;this.renderPassEncoder.setPipeline(e),this.renderPassEncoder.setVertexBuffer(0,r),this.renderPassEncoder.draw(6),this.currentNodeScissor&&this.renderPassEncoder.setScissorRect(this.currentNodeScissor.x,this.currentNodeScissor.y,this.currentNodeScissor.w,this.currentNodeScissor.h)}endNodeRendering(){this.currentRenderTarget=null,this.currentNodeScissor=null,this.viewportWidth=this.canvasContext.canvas.width,this.viewportHeight=this.canvasContext.canvas.height}drawFill(){Fm()}drawDisplayObject(e,r,n,s,o,i){const l=le.getRenderMaxSize();im(e,r,n,s,o,i,this.$matrix,this.globalCompositeOperation,this.viewportWidth,this.viewportHeight,l,this.globalAlpha)}drawArraysInstanced(){this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$mainAttachmentObject&&(this.useOptimizedInstancing?this.renderPassEncoder=Jm(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager,!0,!0):this.renderPassEncoder=Zm(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager),this.processComplexBlendQueue())}setOptimizedInstancing(e){this.useOptimizedInstancing=e}isOptimizedInstancingEnabled(){return this.useOptimizedInstancing}processComplexBlendQueue(){this.ensureCommandEncoder(),r0(this.device,this.commandEncoder,this.$mainAttachmentObject,this.frameBufferManager,this.textureManager,this.pipelineManager,this.bufferManager)}clearArraysInstanced(){rs().clear()}drawPixels(e,r){const n=bo(e.index)||Ne();if(!n||!n.texture)return;const s=e.w,o=e.h;if(this.renderPassEncoder&&(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,n.msaa&&n.msaaTexture?.view)this.drawPixelsToMsaa(n,e,r,s,o);else{const i=s*4;this.device.queue.writeTexture({texture:n.texture.resource,origin:{x:e.x,y:e.y,z:0}},r,{bytesPerRow:i,rowsPerImage:o,offset:0},{width:s,height:o,depthOrArrayLayers:1})}}drawPixelsToMsaa(e,r,n,s,o){const i=Ro(this.device,s,o),l=s*4;this.device.queue.writeTexture({texture:i},n,{bytesPerRow:l,rowsPerImage:o},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render_msaa");if(!c){Xt(i);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(i);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(i);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.msaaTexture.view,ar.resolveTarget=e.texture.view;const f=e.msaaStencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(i)}drawElement(e,r,n=!1){const s=bo(e.index)||Ne();if(!s||!s.texture)return;const o=e.w,i=e.h;this.renderPassEncoder&&(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,s.msaa&&s.msaaTexture?.view?this.drawElementToMsaa(s,e,r,o,i,n):this.drawElementToTexture(s,e,r,o,i,n)}drawElementToMsaa(e,r,n,s,o,i){const l=Ro(this.device,s,o);this.device.queue.copyExternalImageToTexture({source:n,flipY:i},{texture:l,premultipliedAlpha:!0},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render_msaa");if(!c){Xt(l);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(l);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.msaaTexture.view,ar.resolveTarget=e.texture.view;const f=e.msaaStencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(l)}drawElementToTexture(e,r,n,s,o,i){const l=Ro(this.device,s,o);this.device.queue.copyExternalImageToTexture({source:n,flipY:i},{texture:l,premultipliedAlpha:!0},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render");if(!c){Xt(l);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(l);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.texture.view,ar.resolveTarget=void 0;const f=e.stencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(l)}applyFilter(e,r,n,s,o,i,l,c,u,a,h){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=this.$mainAttachmentObject,A0(e,s,o,i,l,c,u,a,h,this.$filterConfig,this.mainTextureView,this.bufferManager)}containerBeginLayer(e,r){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null);const n=this.$mainAttachmentObject;this.$containerLayerStack.push(n),this.containerLayerContentSizes.push({width:e,height:r});const s=this.frameBufferManager.createAttachment("container_layer",e,r,n.msaa,!0);this.$mainAttachmentObject=s,this.bind(s)}containerEndLayer(e,r,n,s,o,i,l,c){this.drawArraysInstanced(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const u=this.$mainAttachmentObject,a=this.containerLayerContentSizes.pop()||{width:u.width,height:u.height};this.$mainAttachmentObject=this.$containerLayerStack.pop(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=void 0,O0(u,this.$mainAttachmentObject,"container_layer",e,r,n,s,o,i,l,c,a.width,a.height,this.$filterConfig,this.bufferManager),this.bind(this.$mainAttachmentObject)}containerDrawCachedFilter(e,r,n,s,o,i){if(ee.get(o,"fKey")!==i)return;const c=ee.get(o,"fTexture");if(!c||!c.texture)return;this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const u=this.$mainAttachmentObject;if(!u||!u.texture)return;let a=c,h=null;if(!(n[0]===1&&n[1]===1&&n[2]===1&&n[3]===1&&n[4]===0&&n[5]===0&&n[6]===0&&n[7]===0)){h=this.frameBufferManager.createTemporaryAttachment(c.width,c.height);const V=this.pipelineManager.getPipeline("color_transform"),X=this.pipelineManager.getBindGroupLayout("texture_copy");if(V&&X&&h.texture){Et[0]=n[0],Et[1]=n[1],Et[2]=n[2],Et[3]=n[3],Et[4]=n[4],Et[5]=n[5],Et[6]=n[6],Et[7]=0;const Y=Et,W=this.bufferManager.acquireAndWriteUniformBuffer(Y),K=this.textureManager.createSampler("cached_ct_sampler",!1);he[0].resource.buffer=W,he[1].resource=K,he[2].resource=c.texture.view;const q=this.device.createBindGroup({layout:X,entries:he}),ce=this.frameBufferManager.createRenderPassDescriptor(h.texture.view,0,0,0,0,"clear"),te=this.commandEncoder.beginRenderPass(ce);te.setPipeline(V),te.setBindGroup(0,q),te.draw(6,1,0,0),te.end(),a=h}}const g=le.getDevicePixelRatio(),m=Math.sqrt(r[0]*r[0]+r[1]*r[1]),f=Math.sqrt(r[2]*r[2]+r[3]*r[3]),b=s[0]*(m/g),x=s[1]*(f/g),y=Math.floor(b+r[4]),P=Math.floor(x+r[5]),S=u.msaa&&u.msaaTexture?.view;let M;switch(e){case"add":M=S?"filter_output_add_msaa":"filter_output_add";break;case"screen":M=S?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":M=S?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":M=S?"filter_output_erase_msaa":"filter_output_erase";break;default:M=S?"filter_output_msaa":"filter_output";break}const $=this.pipelineManager.getPipeline(M),T=this.pipelineManager.getBindGroupLayout("texture_copy");if(!$||!T)return;const w=this.textureManager.createSampler("cached_filter_sampler",!0),E=this.bufferManager.acquireAndWriteUniformBuffer($n);he[0].resource.buffer=E,he[1].resource=w,he[2].resource=a.texture.view;const F=this.device.createBindGroup({layout:T,entries:he}),A=S?u.msaaTexture.view:u.texture.view,R=S?u.texture.view:null,v=this.frameBufferManager.createRenderPassDescriptor(A,0,0,0,0,"load",R),U=Math.max(0,y),L=Math.max(0,P),D=Math.max(1,a.width),G=Math.max(1,a.height),B=u.width,z=u.height,k=Math.max(1,Math.min(D,B-U)),_=Math.max(1,Math.min(G,z-L));if(k<=0||_<=0||U>=B||L>=z){h&&this.frameBufferManager.releaseTemporaryAttachment(h);return}const I=this.commandEncoder.beginRenderPass(v);I.setPipeline($),I.setBindGroup(0,F),I.setViewport(U,L,D,G,0,1),I.setScissorRect(U,L,k,_),I.draw(6,1,0,0),I.end(),h&&this.frameBufferManager.releaseTemporaryAttachment(h),this.bind(u)}ensureMainTexture(){this.mainTexture||(this.mainTexture=this.canvasContext.getCurrentTexture(),this.mainTextureView=this.mainTexture.createView())}getCurrentTextureView(){return this.currentRenderTarget?this.currentRenderTarget:(this.ensureMainTexture(),this.mainTextureView)}ensureCommandEncoder(){this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder())}beginFrame(){this.frameStarted||(this.ensureMainTexture(),this.ensureCommandEncoder(),this.frameStarted=!0,this.frameBufferManager.beginFrame())}addFrameTexture(e){this.pooledTextures.push(e)}endFrame(){if(this.frameStarted){if(this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.bufferManager.dynamicUniform.flush(),this.commandEncoder)try{const e=this.commandEncoder.finish();this.device.queue.submit([e])}catch(e){console.error("Failed to submit frame commands:",e)}this.frameBufferManager.flushPendingReleases(),this.bufferManager.clearFrameBuffers();for(const e of this.frameTextures)e.destroy();this.frameTextures.length=0;for(const e of this.pooledTextures)Ot(e);this.pooledTextures.length=0;for(const e of this.pooledRenderTextures)Xt(e);this.pooledRenderTextures.length=0,Um(),this.fillDynamicBindGroup=null,this.fillDynamicBindGroupBuffer=null,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,this.nodeRenderPassAtlasIndex=-1,this.mainTexture=null,this.mainTextureView=null,this.frameStarted=!1}}submit(){this.endFrame()}createNode(e,r){const n=Zp();if(!fn[n]){const i=le.getRenderMaxSize();fn[n]=new Ni(n,i,i)}const o=fn[n].insert(e,r);return o||(wr(n+1),this.createNode(e,r))}removeNode(e){const r=e.index,n=fn[r];n&&n.dispose(e.x,e.y,e.w,e.h)}transferMainCanvas(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture){this.endFrame();return}this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder(),this.ensureMainTexture();const e=this.pipelineManager.getPipeline("texture_copy_bgra"),r=this.pipelineManager.getBindGroupLayout("texture_copy");if(!e||!r){console.error("[WebGPU] texture_copy_bgra pipeline not found"),this.endFrame();return}const n=this.$mainAttachmentObject.texture.view;if(!jo||kc!==n){ds||(ds=this.device.createBuffer({size:$n.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.device.queue.writeBuffer(ds,0,$n.buffer,$n.byteOffset,$n.byteLength));const i=this.textureManager.createSampler("transfer_sampler",!1);he[0].resource={buffer:ds},he[1].resource=i,he[2].resource=n,jo=this.device.createBindGroup({layout:r,entries:he}),kc=n}const s=jo;Ic.view=this.mainTextureView;const o=this.commandEncoder.beginRenderPass(E0);o.setPipeline(e),o.setBindGroup(0,s),o.draw(6,1,0,0),o.end(),this.endFrame()}async createImageBitmap(e,r){const n=Ne();if(!n)throw new Error("[WebGPU] Atlas attachment not found");this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null);const o=Math.ceil(e*4/256)*256,i=o*r,l=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),c=this.device.createCommandEncoder();if(!n.texture)throw new Error("Attachment texture is null");c.copyTextureToBuffer({texture:n.texture.resource,mipLevel:0,origin:{x:0,y:0,z:0}},{buffer:l,bytesPerRow:o,rowsPerImage:r},{width:e,height:r,depthOrArrayLayers:1}),this.device.queue.submit([c.finish()]),await l.mapAsync(GPUMapMode.READ);const u=l.getMappedRange(),a=new Uint8Array(u),h=new Uint8Array(e*r*4);for(let m=0;m1&&i){const u=\`clip_clear_main_\${Math.min(8,Math.max(1,r))}\`,a=this.pipelineManager.getPipeline(u);if(a){const h=this.frameBufferManager.createStencilRenderPassDescriptor(o,i,"load","load"),d=this.commandEncoder.beginRenderPass(h),g=this.bufferManager.acquireVertexBuffer(Gc.byteLength,Gc);d.setPipeline(a),d.setStencilReference(0),d.setVertexBuffer(0,g),d.draw(6,1,0,0),d.end()}}}}const C0=4;let C;const Vc=t=>{C=t};let qo;const U0=t=>{qo=t};let Qo=0;const G0=()=>Qo;let Zo=0;const L0=()=>Zo;let Jo=!1;const k0=(t,e)=>{Jo=!0,Qo=t,Zo=e},I0=()=>Jo,_0=()=>{qo.width=Qo,qo.height=Zo,Jo=!1},V0=[],Dc=(...t)=>{const e=V0.pop()||[];return t.length&&e.push(...t),e},Dr=(t,e=1)=>({R:(t&16711680)>>16,G:(t&65280)>>8,B:t&255,A:e*255}),D0=async(t,e)=>{if(U0(t),"gpu"in navigator){const r=navigator.gpu,n=await r.requestAdapter();if(!n)throw new Error("WebGPU adapter not available");const s=await n.requestDevice();if(!s)throw new Error("WebGPU device not available");const o=t.getContext("webgpu");if(!o)throw new Error("WebGPU context not available");const i=r.getPreferredCanvasFormat();Vc(new R0(s,o,i,e))}else{const r=t.getContext("webgl2",{stencil:!0,premultipliedAlpha:!0,antialias:!1,depth:!1});if(!r)throw new Error("webgl2 is not supported.");Vc(new ld(r,C0,e))}},N0=(t,e,r=!0)=>{G0()===t&&L0()===e||(k0(t,e),C.resize(t,e,r),r&&ee.reset())},z0=0,X0=1,Y0=2,W0=3,j0=4,H0=5,K0=6,q0=7,Q0=8,Z0=9,J0=10,eg=11,tg=12,rg=13,ng=14,ei=(t,e=!1)=>{let r=0;for(;t.length>r;)switch(t[r++]){case Z0:C.beginPath();break;case z0:C.moveTo(t[r++],t[r++]);break;case Y0:C.lineTo(t[r++],t[r++]);break;case X0:C.quadraticCurveTo(t[r++],t[r++],t[r++],t[r++]);break;case H0:if(e){r+=4;break}C.fillStyle(t[r++]/255,t[r++]/255,t[r++]/255,t[r++]/255);break;case q0:C.fill();break;case K0:if(e){r+=8;break}C.thickness=t[r++],C.caps=t[r++],C.joints=t[r++],C.miterLimit=t[r++],C.strokeStyle(t[r++]/255,t[r++]/255,t[r++]/255,t[r++]/255);break;case Q0:if(e)break;C.stroke();break;case tg:C.closePath();break;case j0:C.arc(t[r++],t[r++],t[r++]);break;case W0:C.bezierCurveTo(t[r++],t[r++],t[r++],t[r++],t[r++],t[r++]);break;case J0:{if(e){r+=1;const a=t[r++];r+=a*5,r+=9,C.fill();break}const n=t[r++],s=Dc(),o=t[r++];for(let a=0;a{switch(t){case 0:return"copy";case 1:return"add";case 2:return"alpha";case 3:return"darken";case 4:return"difference";case 5:return"erase";case 6:return"hardlight";case 7:return"invert";case 8:return"layer";case 9:return"lighten";case 10:return"multiply";case 11:return"normal";case 12:return"overlay";case 13:return"screen";case 14:return"subtract";default:return"normal"}},ti=(t,e)=>{const r=t.subarray(e,e+6);e+=6;const n=t.subarray(e,e+8);e+=8;const s=t.subarray(e,e+4);e+=4;const o=t[e++],i=t[e++],l=t[e++],c=t[e++],u=!!t[e++],a=!!t[e++],h=!!t[e++],d=\`\${t[e++]}\`,g=t[e++],m=t[e++],f=t[e++],b=\`\${t[e++]}\`;let x;if(t[e++]){if(x=ee.get(d,\`\${g}\`),!x)return e}else{const M=u?new Float32Array(28):null;M&&(M.set(t.subarray(e,e+24)),e+=24),C.useGrid(M);const $=t[e++],T=t.subarray(e,e+$);if(h&&!u){const w=Math.ceil(Math.abs(l-o)),E=Math.ceil(Math.abs(c-i));x=C.createNode(w,E),ee.set(d,\`\${g}\`,x);const F=C.currentAttachmentObject,A=C.atlasAttachmentObject;A&&C.bind(A),C.reset(),C.beginNodeRendering(x);const R=A?A.height-x.y-E:0;C.setTransform(1,0,0,1,x.x,R),a?(ei(T),C.drawFill()):C.drawPixels(x,new Uint8Array(T)),C.endNodeRendering(),F&&C.bind(F)}else{const w=Math.ceil(Math.abs(l-o)*m),E=Math.ceil(Math.abs(c-i)*f);x=C.createNode(w,E),ee.set(d,\`\${g}\`,x);const F=C.currentAttachmentObject,A=C.atlasAttachmentObject;A&&C.bind(A),C.reset(),C.beginNodeRendering(x);const R=A?A.height-x.y-E:0;C.setTransform(m,0,0,f,-o*m+x.x,-i*f+R),M&&(M[24]=x.x,M[25]=R),ei(T),C.drawFill(),C.endNodeRendering(),F&&C.bind(F)}e+=$}const P=t[e++];if(!!t[e++]){const M=!!t[e++],$=t.subarray(e,e+4);e+=4;const T=t[e++],w=t.subarray(e,e+T),E=Math.ceil(Math.abs(s[2]-s[0])),F=Math.ceil(Math.abs(s[3]-s[1]));return C.applyFilter(x,b,M,E,F,h,r,n,cr(P),$,w),e+=T,e}if(C.globalAlpha=Math.min(Math.max(0,n[3]+n[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(P),h&&!u)C.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),C.drawDisplayObject(x,s[0],s[1],s[2],s[3],n);else{const M=Math.atan2(r[1],r[0]),$=Math.atan2(-r[2],r[3]);if(M||$){const T=o*m,w=i*f,E=Math.cos(M),F=Math.sin(M),A=Math.cos($),R=Math.sin($);C.setTransform(E,F,-R,A,T*E-w*R+r[4],T*F+w*A+r[5])}else C.setTransform(1,0,0,1,s[0],s[1]);C.drawDisplayObject(x,s[0],s[1],s[2],s[3],n)}return e},ri=(t,e)=>{const r=t.subarray(e,e+6);e+=6,C.reset(),C.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]);const s=!!t[e++]?new Float32Array(28):null;C.useGrid(s),s&&(s.set(t.subarray(e,e+24)),e+=24);const o=t[e++],i=t.subarray(e,e+o);return ei(i,!0),e+=o,C.clip(),e},Nc=(t,e,r)=>{const n=t.widthTable[e.line]||0,s=e.textFormat,o=s.leftMargin||0;if(!r.wordWrap&&n>r.rawWidth)return Math.max(0,o);const i=s.rightMargin||0;return s.align==="center"||r.autoSize==="center"?Math.max(0,r.rawWidth/2-o-i-n/2-2):s.align==="right"||r.autoSize==="right"?Math.max(0,r.rawWidth-o-n-i-4):Math.max(0,o)},sg=t=>{let e="";return t.italic&&(e+="italic "),t.bold&&(e+="bold "),\`\${e}\${t.size}px '\${t.font}','sans-serif'\`},og=(t,e,r,n)=>{const s=new OffscreenCanvas(e.width,e.height),o=s.getContext("2d");if(!o)return s;const i=Math.min(1,Math.max(r,n));if(e.background||e.border){if(o.beginPath(),o.moveTo(0,0),o.lineTo(e.width,0),o.lineTo(e.width,e.height),o.lineTo(0,e.height),o.lineTo(0,0),e.background){const M=Dr(e.backgroundColor);o.fillStyle=\`rgba(\${M.R},\${M.G},\${M.B},\${M.A})\`,o.fill()}if(e.border){const M=Dr(e.borderColor);o.lineWidth=i,o.strokeStyle=\`rgba(\${M.R},\${M.G},\${M.B},\${M.A})\`,o.stroke()}}if(!t)return s;o.save(),o.beginPath(),o.moveTo(2,2),o.lineTo(e.width-2,2),o.lineTo(e.width-2,e.height-2),o.lineTo(2,e.height-2),o.lineTo(2,2),o.clip();let l=2;if(e.scrollX>0){const M=(e.textWidth+4-e.rawWidth)/e.rawWidth;l+=-e.scrollX*M}let c=2;if(e.scrollY>0){const M=(e.textHeight+2-e.rawHeight)/e.rawHeight;c+=-e.scrollY*M}if(o.setTransform(r,0,0,n,l*r,c*n),o.beginPath(),e.selectIndex>-1&&e.focusIndex>-1){const M=t.textTable.length-1;let $=0,T=0;e.focusIndex<=e.selectIndex?($=Math.min(e.focusIndex,M),T=Math.min(e.selectIndex,M)):($=Math.min(e.selectIndex,M),T=Math.min(e.focusIndex-1,M));const w=t.textTable[$],E=t.lineTable[w.line],F=Nc(t,E,e);let A=0;if($&&w.mode==="text"){let v=$;for(;v;){const U=t.textTable[--v];if(U.mode!=="text")break;A+=U.w}}o.fillStyle="#b4d7ff";let R=0;for(let v=$;v<=T;++v){const U=t.textTable[v];if(U.mode==="text"&&(R+=U.w,v!==T))continue;let L=0;const D=U.mode==="text"?U.line:U.line-1;for(let G=0;G0){const M=(e.textWidth-u)/u;a=e.scrollX*M}const h=u+a,d=e.rawHeight;let g=0;if(e.scrollY>0){const M=(e.textHeight-d)/d;g=e.scrollY*M}const m=d+g;let f=0,b=0,x=0,y=0,P=!1,S=-1;for(let M=0;M-1&&S>e.stopIndex))break;if(P&&$.mode==="text")continue;const T=$.textFormat;if(e.autoSize==="none"){if(b>m)break;if($.mode==="text"&&(a>f+$.w||f>h)){f+=$.w;continue}}const w=Dr(T.color||0);if(o.fillStyle=\`rgba(\${w.R},\${w.G},\${w.B},\${w.A})\`,e.focusVisible&&e.focusIndex===M){const F=f+x+.1;let A=$.line,R=$.y,v=t.ascentTable[A];$.mode!=="text"&&(R=$.mode==="break"?$.h:t.ascentTable[A-1],A>0?(A=$.line-1,v=t.ascentTable[A]):v=$.h),A>0&&t.ascentTable[A]===0&&A++;for(let U=0;Ub+t.heightTable[E]){P=!0;continue}y=t.ascentTable[E],x=Nc(t,$,e),P=!1;break;case"text":{o.beginPath(),o.font=sg(T);const F=f+x,A=b+y;if(T.underline){const R=Dr(T.color||0);o.lineWidth=i,o.strokeStyle=\`rgba(\${R.R},\${R.G},\${R.B},\${R.A})\`,o.beginPath(),o.moveTo(F,A+2),o.lineTo(F+$.w,A+2),o.stroke()}e.thickness&&o.strokeText($.text,F,A),o.fillText($.text,F,A),f+=$.w}break}}if(e.focusVisible&&e.focusIndex>=t.textTable.length){const M=t.textTable[e.focusIndex-1];if(M){const $=Dr(M.textFormat.color||0);o.strokeStyle=\`rgba(\${$.R},\${$.G},\${$.B},\${$.A})\`;const T=f+x+.1,w=b+y;o.beginPath(),M.mode==="text"?o.moveTo(T,w-M.y):o.moveTo(T,w+M.h),o.lineTo(T,w),o.stroke()}}return o.restore(),s},ig=new TextDecoder,ni=(t,e)=>{const r=t.subarray(e,e+6);e+=6;const n=t.subarray(e,e+8);e+=8;const s=t.subarray(e,e+4);e+=4;const o=t[e++],i=t[e++],l=t[e++],c=t[e++],u=\`\${t[e++]}\`,a=t[e++],h=!!t[e++],d=t[e++],g=t[e++],m=\`\${t[e++]}\`;let f;if(t[e++]){if(f=ee.get(u,\`\${a}\`),!f)return e}else{const M=Math.ceil(Math.abs(l-o)*d),$=Math.ceil(Math.abs(c-i)*g),T=!!t[e++];f=T?ee.get(u,\`\${a}\`):C.createNode(M,$),T||ee.set(u,\`\${a}\`,f);const w=t[e++],E=new Uint8Array(t.subarray(e,e+w));e+=w;let F="none";switch(t[e++]){case 0:F="center";break;case 1:F="left";break;case 2:F="none";break;case 3:F="right";break}const A={width:M,height:$,autoSize:F,stopIndex:t[e++],scrollX:t[e++],scrollY:t[e++],textWidth:t[e++],textHeight:t[e++],rawWidth:t[e++],rawHeight:t[e++],focusIndex:t[e++],selectIndex:t[e++],focusVisible:!!t[e++],thickness:t[e++],thicknessColor:t[e++],wordWrap:!!t[e++],border:!!t[e++],borderColor:t[e++],background:!!t[e++],backgroundColor:t[e++],defaultColor:t[e++],defaultSize:t[e++]},R=og(JSON.parse(ig.decode(E)),A,d,g),v=C.currentAttachmentObject,U=C.atlasAttachmentObject;U&&C.bind(U),C.reset(),C.beginNodeRendering(f);const L=U?U.height-f.y-$:0;C.setTransform(1,0,0,1,f.x,L),C.drawElement(f,R),C.endNodeRendering(),v&&C.bind(v)}const x=t[e++];if(!!t[e++]){const M=!!t[e++],$=t.subarray(e,e+4);e+=4;const T=t[e++],w=t.subarray(e,e+T),E=Math.ceil(Math.abs(s[2]-s[0])),F=Math.ceil(Math.abs(s[3]-s[1]));return C.applyFilter(f,m,!!Math.max(+h,+M),E,F,!1,r,n,cr(x),$,w),e+=T,e}C.globalAlpha=Math.min(Math.max(0,n[3]+n[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(x);const P=Math.atan2(r[1],r[0]),S=Math.atan2(-r[2],r[3]);if(P||S){const M=o*d,$=i*g,T=Math.cos(P),w=Math.sin(P),E=Math.cos(S),F=Math.sin(S);C.setTransform(T,w,-F,E,M*T-$*F+r[4],M*w+$*E+r[5])}else C.setTransform(1,0,0,1,s[0],s[1]);return C.drawDisplayObject(f,s[0],s[1],s[2],s[3],n),e},si=(t,e,r)=>{const n=t.subarray(e,e+6);e+=6;const s=t.subarray(e,e+8);e+=8;const o=t.subarray(e,e+4);e+=4;const i=t[e++],l=t[e++],c=t[e++],u=t[e++],a=\`\${t[e++]}\`,h="0",d=!!t[e++],g=\`\${t[e++]}\`;let m;if(t[e++]){if(m=ee.get(a,\`\${h}\`),!m)return e}else{const y=Math.abs(c-i),P=Math.abs(u-l),S=!!t[e++];if(m=S?ee.get(a,\`\${h}\`):C.createNode(y,P),S||ee.set(a,\`\${h}\`,m),r&&r.length){const M=C.currentAttachmentObject,$=C.atlasAttachmentObject;$&&C.bind($),C.reset(),C.beginNodeRendering(m);const T=$?$.height-m.y-P:0;C.setTransform(1,0,0,1,m.x,T);const w=r.shift();C.drawElement(m,w,!0),C.endNodeRendering(),M&&C.bind(M)}}const b=t[e++];if(!!t[e++]){const y=!!t[e++],P=t.subarray(e,e+4);e+=4;const S=t[e++],M=t.subarray(e,e+S),$=Math.ceil(Math.abs(o[2]-o[0])),T=Math.ceil(Math.abs(o[3]-o[1]));return C.applyFilter(m,g,!!Math.max(+d,+y),$,T,!0,n,s,cr(b),P,M),e+=S,e}return C.globalAlpha=Math.min(Math.max(0,s[3]+s[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(b),C.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]),C.drawDisplayObject(m,o[0],o[1],o[2],o[3],s),e},oi=(t,e)=>{const r=t[e++];for(let n=0;n{let n=0,s=!0;const o=cr(t[e++]),i=!!t[e++];let l=0,c=0,u=!1,a="",h="",d=null,g=null,m=null,f=null;if(i)if(l=t[e++],c=t[e++],u=!!t[e++],u){const y=!!t[e++];if(a=\`\${t[e++]}\`,h=\`\${t[e++]}\`,y)return d=t.subarray(e,e+4),e+=4,m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8,C.containerDrawCachedFilter(o,m,f,d,a,h),e;d=t.subarray(e,e+4),e+=4,m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8;const P=t[e++];g=t.subarray(e,e+P),e+=P}else m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8;i&&C.containerBeginLayer(l,c);const b=!!t[e++];if(b){switch(C.drawArraysInstanced(),C.save(),C.beginMask(),C.setMaskBounds(t[e++],t[e++],t[e++],t[e++]),t[e++]){case 0:e=oi(t,e);break;case 1:e=ri(t,e);break}C.endMask()}const x=t[e++];for(let y=0;x>y;y++){const P=t[e++],S=t[e++];if(n&&P>n&&(s&&(C.restore(),C.leaveMask()),n=0,s=!0),!s)continue;if(S){if(n=S,s=!!t[e++],!s)continue;switch(C.drawArraysInstanced(),C.save(),C.beginMask(),C.setMaskBounds(t[e++],t[e++],t[e++],t[e++]),t[e++]){case 0:e=oi(t,e);break;case 1:e=ri(t,e);break}C.endMask();continue}if(!t[e++])continue;switch(t[e++]){case 0:e=ii(t,e,r);break;case 1:e=ti(t,e);break;case 2:e=ni(t,e);break;case 3:e=si(t,e,r);break}}return(n||b)&&(C.restore(),C.leaveMask()),i&&C.containerEndLayer(o,m,f,u,d,g,a,h),e};let Nr=-1;const ag=(t,e)=>{C.clearTransferBounds();let r=0;const n=t[r++];for(Nr!==n&&(Nr=n,Nr===-1?C.updateBackgroundColor(0,0,0,0):C.updateBackgroundColor((Nr>>16&255)/255,(Nr>>8&255)/255,(Nr&255)/255,1)),C.reset(),C.setTransform(1,0,0,1,0,0),C.fillBackgroundColor();t.length>r;){if(!t[r++])continue;const s=t[r++];switch(s){case 0:r=ii(t,r,e);break;case 1:r=ti(t,r);break;case 2:r=ni(t,r);break;case 3:r=si(t,r,e);break;default:console.error("unknown type",s);break}}C.drawArraysInstanced(),I0()&&_0(),C.transferMainCanvas()},cg=t=>{for(let e=0;e{C.clearTransferBounds();let i=1;C.reset(),C.setTransform(1,0,0,1,0,0);const l=C.$clearColorR,c=C.$clearColorG,u=C.$clearColorB,a=C.$clearColorA;for(C.updateBackgroundColor((n>>16&255)/255,(n>>8&255)/255,(n&255)/255,s),C.fillBackgroundColor();t.length>i;){if(!t[i++])continue;const d=t[i++];switch(d){case 0:i=ii(t,i,o);break;case 1:i=ti(t,i);break;case 2:i=ni(t,i);break;case 3:i=si(t,i,o);break;default:console.error("unknown type",d);break}}C.drawArraysInstanced();const h=await C.createImageBitmap(e,r);return C.updateBackgroundColor(l,c,u,a),h};class ug{state;queue;constructor(){this.state="deactivate",this.queue=[]}async execute(){for(this.state="active";this.queue.length;){const e=this.queue.shift();if(e)switch(e.command){case"render":ag(e.buffer.subarray(0,e.length),e.imageBitmaps),globalThis.postMessage({message:"render",buffer:e.buffer},[e.buffer.buffer]);break;case"resize":N0(e.buffer[0],e.buffer[1],!!e.buffer[2]);break;case"initialize":await D0(e.canvas,e.devicePixelRatio);break;case"removeCache":cg(e.buffer);break;case"cacheClear":ee.reset();break;case"capture":{const r=await lg(e.buffer.subarray(0,e.length),e.width,e.height,e.bgColor,e.bgAlpha,e.imageBitmaps);globalThis.postMessage({message:"capture",buffer:e.buffer,imageBitmap:r},[e.buffer.buffer,r])}break}}this.state="deactivate"}}const ai=new ug;self.addEventListener("message",async t=>{ai.queue.push(t.data),ai.state==="deactivate"&&await ai.execute()})})(); -`,Fn=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",di],{type:"text/javascript;charset=utf-8"});function Ns(e){let t;try{if(t=Fn&&(self.URL||self.webkitURL).createObjectURL(Fn),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(di),{name:e?.name})}}const Ce=new Ns,Ys=e=>{const t=e.transferControlToOffscreen();Ce.postMessage({command:"initialize",canvas:t,devicePixelRatio:window.devicePixelRatio},[t])};class ze{static get AT_TARGET(){return 2}static get BUBBLING_PHASE(){return 3}static get CAPTURING_PHASE(){return 1}}let x=class{type;bubbles;listener;target;currentTarget;eventPhase;_$stopImmediatePropagation;_$stopPropagation;constructor(t,r=!1){this.type=`${t}`,this.bubbles=r,this.target=null,this.currentTarget=null,this.eventPhase=ze.AT_TARGET,this.listener=null,this._$stopImmediatePropagation=!1,this._$stopPropagation=!1}static get ADDED(){return"added"}static get ADDED_TO_STAGE(){return"addedToStage"}static get CHANGE(){return"change"}static get COMPLETE(){return"complete"}static get ENDED(){return"ended"}static get ENTER_FRAME(){return"enterFrame"}static get FRAME_LABEL(){return"frameLabel"}static get INPUT(){return"input"}static get OPEN(){return"open"}static get REMOVED(){return"removed"}static get REMOVED_FROM_STAGE(){return"removedFromStage"}static get RESIZE(){return"resize"}static get SCROLL(){return"scroll"}stopImmediatePropagation(){this._$stopImmediatePropagation=!0}stopPropagation(){this._$stopPropagation=!0}};const q=new Map,Kt=[],Qt=()=>Kt.length?Kt.pop():[],Pe=e=>{10>Kt.length&&(e.length=0,Kt.push(e))};let Ai=null;const We=e=>{Ai=e},jt=()=>Ai;class V extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case V.KEY_DOWN:case V.KEY_UP:return i in s?$event[i]:void 0;default:return}}})}static get KEY_DOWN(){return"keydown"}static get KEY_UP(){return"keyup"}}const Ws=(e,t,r,n=!1,i=0)=>{let s;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:(!q.size||!q.has(t))&&q.set(t,Qt()),s=q.get(t);break;default:e._$events||(e._$events=new Map),(!e._$events.size||!e._$events.has(t))&&e._$events.set(t,Qt()),s=e._$events.get(t);break}const a=s.length;let o=0;for(;o1&&s.sort((c,u)=>{switch(!0){case c.priority>u.priority:return-1;case c.priority{switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:return!!(q.size&&q.has(t));default:return!!(e._$events&&e._$events.size&&e._$events.has(t))}},Ks=(e,t,r,n=!1)=>{let i;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:if(!q.size||!q.has(t))return;i=q.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;i=e._$events.get(t);break}if(i){for(let s=0;s1&&i.sort((s,a)=>{switch(!0){case s.priority>a.priority:return-1;case s.priority{let n;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:if(!q.size||!q.has(t))return;n=q.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;n=e._$events.get(t);break}if(!n)return;const i=Qt();for(let s=0;s1&&i.sort((s,a)=>{switch(!0){case s.priority>a.priority:return-1;case s.priority{if(e.hasEventListener(t))return!0;if("parent"in e){let r=e.parent;for(;r;){if(r.hasEventListener(t))return!0;if(!("parent"in r))break;r=r.parent}}return!1},zs=(e,t)=>{switch(t.type){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:{if(!q.size||!q.has(t.type))return!1;const r=q.get(t.type);if(!r.length)return!1;for(let n=0;n-1;--i){const s=n[i];for(let a=0;a{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case Ne.FOCUS_IN:case Ne.FOCUS_OUT:return i in s?$event[i]:void 0;default:return}}})}static get FOCUS_IN(){return"focusin"}static get FOCUS_OUT(){return"focusout"}}class Gt extends x{status;responseHeaders;responseURL;constructor(t,r=!1,n=0,i="",s=[]){super(t,r),this.status=n|0,this.responseHeaders=s,this.responseURL=i}static get HTTP_STATUS(){return"httpStatus"}}class Re extends x{text;constructor(t,r=!1,n=""){super(t,r),this.text=`${n}`}static get IO_ERROR(){return"ioError"}}class S extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case S.POINTER_DOWN:case S.POINTER_MOVE:case S.POINTER_UP:case S.POINTER_LEAVE:case S.POINTER_OVER:case S.POINTER_OUT:return i in s?$event[i]:void 0;default:return}}})}static get DOUBLE_CLICK(){return"dblclick"}static get POINTER_DOWN(){return"pointerdown"}static get POINTER_LEAVE(){return"pointerleave"}static get POINTER_MOVE(){return"pointermove"}static get POINTER_OUT(){return"pointerout"}static get POINTER_OVER(){return"pointerover"}static get POINTER_UP(){return"pointerup"}static get POINTER_CANCEL(){return"pointercancel"}}class Z extends x{bytesLoaded;bytesTotal;constructor(t,r=!1,n=0,i=0){super(t,r),this.bytesLoaded=n|0,this.bytesTotal=i|0}static get PROGRESS(){return"progress"}}class Ae extends x{static get PLAY(){return"play"}static get PLAYING(){return"playing"}static get PAUSE(){return"pause"}static get SEEK(){return"seek"}}class ye extends x{static get UPDATE(){return"jobupdate"}static get STOP(){return"jobstop"}}class qe extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s&&s.type===qe.WHEEL)return i in s?$event[i]:void 0}})}static get WHEEL(){return"wheel"}}const pi=[],er=e=>{e.size&&e.clear(),pi.push(e)},Hs=()=>pi.pop()||new Map,Js=(e,t,r)=>{r.clear(),e.$timerId!==null&&clearTimeout(e.$timerId);for(const n of t.values()){for(const i of n.values())i&&e.destroy(i);er(n)}t.clear()},Zs=(e,t)=>{if(!(!t||typeof t!="object")&&"canvas"in t){const r=t.canvas,n=r.width,i=r.height;t.clearRect(0,0,n+1,i+1),r.width=r.height=1,e.push(r)}},qs=(e,t,r)=>{if(!e.has(t))return;const n=e.get(t);n.has(r)&&(n.delete(r),n.size||(er(n),e.delete(t)))},js=(e,t,r)=>{if(!t.has(r))return;const n=t.get(r);for(const i of n.values())e.destroy(i);t.delete(r),er(n)},ea=(e,t,r)=>{const n=e.get(t)||null;return n?(n.delete("trash"),n.get(r)||null):null},ta=(e,t,r,n,i=null)=>{t.has(r)||t.set(r,Hs());const s=t.get(r);if(i===null){if(!s.has(n))return;e.destroy(s.get(n)),s.delete(n),s.size||(t.delete(r),er(s));return}s.set(n,i)},ra=(e,t,r="")=>r?e.has(t)?e.get(t).has(r):!1:e.has(t),na=(e,t,r)=>{let n=2166136261,i=e*100|0;return n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619),i=t*100|0,n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619),r&&(i=r*100|0,n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619)),(n>>>0)%16777216},ia=(e,t,r,n)=>{let i=2166136261,s=e*100|0;return i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=t*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=r*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=n*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),(i>>>0)%16777216},sa=(e,t,r,n)=>{if(r.has(n))return;const i=t.get(n);i&&(i.set("trash",!0),r.set(n,i),e.$timerId!==null&&clearTimeout(e.$timerId),e.$removeCache=!1,e.$timerId=setTimeout(()=>{e.$removeCache=!0,e.$timerId=null},1e3))},aa=(e,t)=>{if(t.size){for(const[r,n]of t)n.has("trash")&&(e.removeById(r),e.$removeIds.push(+r));t.clear(),e.$removeCache=!1}};class oa{_$pool;_$store;_$trash;$timerId;$removeCache;$removeIds;constructor(){this._$pool=[],this._$store=new Map,this._$trash=new Map,this.$timerId=null,this.$removeIds=[],this.$removeCache=!1}reset(){Js(this,this._$store,this._$trash)}destroy(t=null){Zs(this._$pool,t)}getCanvas(){return this._$pool.pop()||document.createElement("canvas")}remove(t,r){qs(this._$store,t,r)}removeTimer(t){sa(this,this._$store,this._$trash,t)}removeTimerScheduledCache(){aa(this,this._$trash)}removeById(t){js(this,this._$store,t)}getById(t){return this._$store.get(t)}get(t,r){return ea(this._$store,t,r)}set(t,r,n=null){ta(this,this._$store,t,r,n)}has(t,r=""){return ra(this._$store,t,r)}generateKeys(t,r,n){return na(t,r,n)}generateFilterKeys(t,r,n,i){return ia(t,r,n,i)}}const O=new oa,ca=e=>{const t=O.getCanvas();t.width=e.width,t.height=e.height;const r=t.getContext("2d",{willReadFrequently:!0});r.drawImage(e,0,0);const n=r.getImageData(0,0,e.width,e.height),i=new Uint8Array(n.data.buffer);return O.destroy(r),i},la=e=>{const t=O.getCanvas();t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.setTransform(1,0,0,1,0,0),r.drawImage(e,0,0);const n=r.getImageData(0,0,e.width,e.height),i=new Uint8Array(n.data.buffer);return O.destroy(r),i};class _e{width;height;buffer;constructor(t=0,r=0){this.width=t|0,this.height=r|0,this.buffer=null}set image(t){if(!t){this.width=0,this.height=0,this.buffer=null;return}this.buffer=ca(t),this.width=t.width,this.height=t.height}set canvas(t){if(!t){this.width=0,this.height=0,this.buffer=null;return}this.buffer=la(t),this.width=t.width,this.height=t.height}clone(){const t=new _e(this.width,this.height);return this.buffer!==null&&(t.buffer=this.buffer.slice()),t}}class ua{static get ADD(){return"add"}static get ALPHA(){return"alpha"}static get DARKEN(){return"darken"}static get DIFFERENCE(){return"difference"}static get ERASE(){return"erase"}static get HARDLIGHT(){return"hardlight"}static get INVERT(){return"invert"}static get LAYER(){return"layer"}static get LIGHTEN(){return"lighten"}static get MULTIPLY(){return"multiply"}static get NORMAL(){return"normal"}static get OVERLAY(){return"overlay"}static get SCREEN(){return"screen"}static get SUBTRACT(){return"subtract"}}const j=e=>{e.changed=!0;let t=e.parent;for(;t&&!t.changed;)t.changed=!0,t=t.parent},ha=(e,t)=>{const r=U.multiply(e._$colorTransform,t._$colorTransform);e._$colorTransform[0]=r[0],e._$colorTransform[1]=r[1],e._$colorTransform[2]=r[2],e._$colorTransform[3]=r[3],e._$colorTransform[4]=r[4],e._$colorTransform[5]=r[5],e._$colorTransform[6]=r[6],e._$colorTransform[7]=r[7],U.release(r)},mi=[],En=(e=1,t=0,r=0,n=1,i=0,s=0)=>{const a=mi.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=i,a[5]=s,a},fa=e=>{mi.push(e)},gi=[],Pn=(e=1,t=1,r=1,n=1,i=0,s=0,a=0,o=0)=>{const c=gi.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=s,c[6]=a,c[7]=o,c},da=e=>{gi.push(e)},Ee=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};class U{_$colorTransform;constructor(t=1,r=1,n=1,i=1,s=0,a=0,o=0,c=0){this._$colorTransform=Pn(t,r,n,i,s,a,o,c)}get rawData(){return this._$colorTransform}get alphaMultiplier(){return this._$colorTransform[3]}set alphaMultiplier(t){this._$colorTransform[3]=Ee(t,0,1,1)}get alphaOffset(){return this._$colorTransform[7]}set alphaOffset(t){this._$colorTransform[7]=Ee(t,-255,255,0)}get blueMultiplier(){return this._$colorTransform[2]}set blueMultiplier(t){this._$colorTransform[2]=Ee(t,0,1,1)}get blueOffset(){return this._$colorTransform[6]}set blueOffset(t){this._$colorTransform[6]=Ee(t,-255,255,0)}get greenMultiplier(){return this._$colorTransform[1]}set greenMultiplier(t){this._$colorTransform[1]=Ee(t,0,1,1)}get greenOffset(){return this._$colorTransform[5]}set greenOffset(t){this._$colorTransform[5]=Ee(t,-255,255,0)}get redMultiplier(){return this._$colorTransform[0]}set redMultiplier(t){this._$colorTransform[0]=Ee(t,0,1,1)}get redOffset(){return this._$colorTransform[4]}set redOffset(t){this._$colorTransform[4]=Ee(t,-255,255,0)}clone(){return new U(...this._$colorTransform)}concat(t){ha(this,t)}static multiply(t,r){return Pn(t[0]*r[0],t[1]*r[1],t[2]*r[2],t[3]*r[3],t[0]*r[4]+t[4],t[1]*r[5]+t[5],t[2]*r[6]+t[6],t[3]*r[7]+t[7])}static release(t){da(t)}}const Aa=e=>new T(e._$matrix[0],e._$matrix[1],e._$matrix[2],e._$matrix[3],e._$matrix[4],e._$matrix[5]),pa=(e,t)=>{const r=e._$matrix,n=t._$matrix;let i=r[0]*n[0],s=0,a=0,o=r[3]*n[3],c=r[4]*n[0]+n[4],u=r[5]*n[3]+n[5];(r[1]||r[2]||n[1]||n[2])&&(i+=r[1]*n[2],o+=r[2]*n[1],s+=r[0]*n[1]+r[1]*n[3],a+=r[2]*n[0]+r[3]*n[2],c+=r[5]*n[2],u+=r[4]*n[1]),r[0]=i,r[1]=s,r[2]=a,r[3]=o,r[4]=c,r[5]=u},ma=(e,t)=>{e._$matrix[0]=t._$matrix[0],e._$matrix[1]=t._$matrix[1],e._$matrix[2]=t._$matrix[2],e._$matrix[3]=t._$matrix[3],e._$matrix[4]=t._$matrix[4],e._$matrix[5]=t._$matrix[5]},ga=(e,t,r,n=0,i=0,s=0)=>{e.identity(),e.rotate(n),e.scale(t,r),e.translate(i,s)},ba=(e,t,r,n=0,i=0,s=0)=>{const a=e._$matrix;if(a[0]=t/1638.4,a[3]=r/1638.4,n){const o=Math.cos(n),c=Math.sin(n);a[1]=c*a[3],a[2]=-c*a[0],a[0]*=o,a[3]*=o}else a[1]=0,a[2]=0;a[4]=i+t/2,a[5]=s+r/2},xa=(e,t)=>new se(e.x+t.x,e.y+t.y),ya=e=>new se(e.x,e.y),$a=(e,t)=>{e.x=t.x,e.y=t.y},va=(e,t)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),wa=(e,t)=>e.x===t.x&&e.y===t.y,Ma=(e,t,r)=>new se(e.x+(t.x-e.x)*(1-r),e.y+(t.y-e.y)*(1-r)),Ba=(e,t)=>{const r=t/e.length;e.x*=r,e.y*=r},Ta=(e,t,r)=>{e.x+=t,e.y+=r},Sa=(e,t)=>new se(e*Math.cos(t),e*Math.sin(t)),Ia=(e,t,r)=>{e.x=t,e.y=r},Ca=(e,t)=>new se(e.x-t.x,e.y-t.y);class se{x;y;constructor(t=0,r=0){this.x=t,this.y=r}get length(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))}add(t){return xa(this,t)}clone(){return ya(this)}copyFrom(t){$a(this,t)}static distance(t,r){return va(t,r)}equals(t){return wa(this,t)}static interpolate(t,r,n){return Ma(t,r,n)}normalize(t){Ba(this,t)}offset(t,r){Ta(this,t,r)}static polar(t,r){return Sa(t,r)}setTo(t,r){Ia(this,t,r)}subtract(t){return Ca(this,t)}}const Fa=(e,t)=>new se(t.x*e._$matrix[0]+t.y*e._$matrix[2],t.x*e._$matrix[1]+t.y*e._$matrix[3]),Ea=e=>{e._$matrix[0]=1,e._$matrix[1]=0,e._$matrix[2]=0,e._$matrix[3]=1,e._$matrix[4]=0,e._$matrix[5]=0},Pa=e=>{const t=e._$matrix[0],r=e._$matrix[1],n=e._$matrix[2],i=e._$matrix[3],s=e._$matrix[4],a=e._$matrix[5];if(r===0&&n===0)e._$matrix[0]=1/t,e._$matrix[1]=0,e._$matrix[2]=0,e._$matrix[3]=1/i,e._$matrix[4]=-e._$matrix[0]*s,e._$matrix[5]=-e._$matrix[3]*a;else{const o=t*i-r*n;if(o){const c=1/o;e._$matrix[0]=i*c,e._$matrix[1]=-r*c,e._$matrix[2]=-n*c,e._$matrix[3]=t*c,e._$matrix[4]=-(e._$matrix[0]*s+e._$matrix[2]*a),e._$matrix[5]=-(e._$matrix[1]*s+e._$matrix[3]*a)}}},Ra=(e,t)=>{const r=e._$matrix,n=r[0],i=r[1],s=r[2],a=r[3],o=r[4],c=r[5];r[0]=n*Math.cos(t)-i*Math.sin(t),r[1]=n*Math.sin(t)+i*Math.cos(t),r[2]=s*Math.cos(t)-a*Math.sin(t),r[3]=s*Math.sin(t)+a*Math.cos(t),r[4]=o*Math.cos(t)-c*Math.sin(t),r[5]=o*Math.sin(t)+c*Math.cos(t)},Oa=(e,t,r)=>{const n=e._$matrix;n[0]*=t,n[2]*=t,n[4]*=t,n[1]*=r,n[3]*=r,n[5]*=r},ka=(e,t,r,n,i,s,a)=>{const o=e._$matrix;o[0]=t,o[1]=r,o[2]=n,o[3]=i,o[4]=s,o[5]=a},Ua=(e,t)=>{const r=t.x,n=t.y,i=e._$matrix;return new se(r*i[0]+n*i[2]+i[4],r*i[1]+n*i[3]+i[5])},Ga=(e,t,r)=>{e.tx+=t,e.ty+=r};class T{_$matrix;constructor(t=1,r=0,n=0,i=1,s=0,a=0){this._$matrix=En(t,r,n,i,s,a)}get a(){return this._$matrix[0]}set a(t){this._$matrix[0]=t}get b(){return this._$matrix[1]}set b(t){this._$matrix[1]=t}get c(){return this._$matrix[2]}set c(t){this._$matrix[2]=t}get d(){return this._$matrix[3]}set d(t){this._$matrix[3]=t}get tx(){return this._$matrix[4]}set tx(t){this._$matrix[4]=t}get ty(){return this._$matrix[5]}set ty(t){this._$matrix[5]=t}get rawData(){return this._$matrix}clone(){return Aa(this)}concat(t){pa(this,t)}copyFrom(t){ma(this,t)}createBox(t,r,n=0,i=0,s=0){ga(this,t,r,n,i,s)}createGradientBox(t,r,n=0,i=0,s=0){ba(this,t,r,n,i,s)}deltaTransformPoint(t){return Fa(this,t)}identity(){Ea(this)}invert(){Pa(this)}rotate(t){Ra(this,t)}scale(t,r){Oa(this,t,r)}setTo(t,r,n,i,s,a){ka(this,t,r,n,i,s,a)}transformPoint(t){return Ua(this,t)}translate(t,r){Ga(this,t,r)}static multiply(t,r){const n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],c=t[5],u=r[0],h=r[1],l=r[2],f=r[3],A=r[4],d=r[5];return En(n*u+s*h,i*u+a*h,n*l+s*f,i*l+a*f,n*A+s*d+o,i*A+a*d+c)}static release(t){fa(t)}}const _a=e=>new be(e.x,e.y,e.width,e.height),Da=(e,t,r)=>e.x<=t&&e.y<=r&&e.right>t&&e.bottom>r,La=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>t.x&&e.bottom>t.y,Na=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>=t.right&&e.bottom>=t.bottom,Ya=(e,t)=>{e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},Wa=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Va=(e,t,r)=>{e.x-=t,e.width+=2*t,e.y-=r,e.height+=2*r},Ka=(e,t)=>{e.x-=t.x,e.width+=2*t.x,e.y-=t.y,e.height+=2*t.y},Qa=(e,t)=>{const r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom),a=i-r,o=s-n;return a>0&&o>0?new be(r,n,a,o):new be(0,0,0,0)},Xa=(e,t)=>{const r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom);return i-r>0&&s-n>0},za=e=>e.width<=0||e.height<=0,Ha=(e,t,r)=>{e.x+=t,e.y+=r},Ja=(e,t)=>{e.x+=t.x,e.y+=t.y},Za=e=>{e.x=e.y=e.width=e.height=0},qa=(e,t,r,n,i)=>{e.x=t,e.y=r,e.width=n,e.height=i},ja=(e,t)=>e.isEmpty()?t.clone():t.isEmpty()?e.clone():new be(Math.min(e.x,t.x),Math.min(e.y,t.y),Math.max(e.right-t.left,t.right-e.left),Math.max(e.bottom-t.top,t.bottom-e.top));class be{x;y;width;height;constructor(t=0,r=0,n=0,i=0){this.x=t,this.y=r,this.width=n,this.height=i}get bottom(){return this.y+this.height}set bottom(t){this.height=t-this.y}get bottomRight(){return new se(this.right,this.bottom)}set bottomRight(t){this.right=t.x,this.bottom=t.y}get left(){return this.x}set left(t){this.width=this.right-t,this.x=t}get right(){return this.x+this.width}set right(t){this.width=t-this.x}get size(){return new se(this.width,this.height)}set size(t){this.width=t.x,this.height=t.y}get top(){return this.y}set top(t){this.height=this.bottom-t,this.y=t}get topLeft(){return new se(this.x,this.y)}set topLeft(t){this.left=t.x,this.top=t.y}clone(){return _a(this)}contains(t,r){return Da(this,t,r)}containsPoint(t){return La(this,t)}containsRect(t){return Na(this,t)}copyFrom(t){Ya(this,t)}equals(t){return Wa(this,t)}inflate(t,r){Va(this,t,r)}inflatePoint(t){Ka(this,t)}intersection(t){return Qa(this,t)}intersects(t){return Xa(this,t)}isEmpty(){return za(this)}offset(t,r){Ha(this,t,r)}offsetPoint(t){Ja(this,t)}setEmpty(){Za(this)}setTo(t,r,n,i){qa(this,t,r,n,i)}union(t){return ja(this,t)}}const tr=e=>{if(e.placeObject)return e.placeObject;const t=e.placeId;if(t===-1)return null;const r=e.parent;if(!r)return null;const n=r.loaderInfo;if(!n||!n.data)return null;const i=n.data.characters[r.characterId],s=r.isTimelineEnabled?r.currentFrame:1,a=i.placeMap[s];if(!a||!(t in a))return null;const o=a[t],c=i.placeObjects[o];return c?(e.placeObject=c,c):null},bt=new se,bi=0,xi=1,eo=2,to=3,xt=new Float32Array([1,0,0,1,0,0]);let ro=0;const yi=()=>ro++,$i=[],Pr=[],vi=[],no=[],je=(e=0,t=0,r=0,n=0,i=0,s=0)=>{const a=vi.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=i,a[5]=s,a},Ft=e=>{vi.push(e)},_t=(e=1,t=1,r=1,n=1,i=0,s=0,a=0,o=0)=>{const c=no.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=s,c[6]=a,c[7]=o,c},wi=[],io=()=>wi.pop()||new Map,so=e=>{e.clear(),wi.push(e)},z=(...e)=>{const t=$i.pop()||[];return e.length&&t.push(...e),t},oe=e=>{e.length&&(e.length=0),$i.push(e)},re=(e,t,r,n)=>{const i=Pr.length?Pr.pop():new Float32Array(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i},k=e=>{Pr.push(e)},ao=e=>{let t=null;switch(e.method.toUpperCase()){case"GET":if(e.data){const n=e.url.split("?");n[1]=n.length===1?e.data.toString():`${n[1]}&${e.data.toString()}`,e.url=n.join("?")}break;case"PUT":case"POST":e.data&&(t=e.data.toString());break}const r=new XMLHttpRequest;if(r.open(e.method,e.url,!0),r.responseType=e.format,r.withCredentials=e.withCredentials,e.event){const n=Object.keys(e.event);for(let i=0;i{const t=z();if(e){const r=e.trim().split(` -`);for(let n=0;nIe?(Ie.fillStyle=e,+`0x${Ie.fillStyle.slice(1)}`):0,me=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},kr=[],Ur=[],Ue=new Map;let Mi=null;const Bi=e=>{Mi=e},lo=()=>Mi,_=e=>{if(e.$matrix)return e.$matrix.rawData;const t=tr(e);if(!t||!t.matrix)return null;if(!t.typedMatrix){const r=t.matrix;t.typedMatrix=je(r[0],r[1],r[2],r[3],r[4],r[5])}return t.typedMatrix},uo=e=>{const t=_(e);let r=t||xt,n=e.parent;for(;n;){const i=_(n);i&&(r=T.multiply(i,r)),n=n.parent}return new T(r[0],r[1],r[2],r[3],r[4],r[5])},Ve=e=>{if(e.$colorTransform)return e.$colorTransform.rawData;const t=tr(e);if(!t||!t.colorTransform)return null;if(!t.typedColorTransform){const r=t.colorTransform;t.typedColorTransform=_t(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7])}return t.typedColorTransform},ho=e=>{if(e.$alpha!==null)return e.$alpha;if(e.$colorTransform){const r=e.$colorTransform.rawData;return r[3]+r[7]/255}const t=Ve(e);return t?t[3]+t[7]/255:1},fo=(e,t)=>{if(t=me(t,0,1),e.$alpha===t)return;e.$alpha=t;let r=e.$colorTransform;if(!r){const n=Ve(e);r=n?new U(...n):new U}r.alphaMultiplier=t,r.alphaOffset=0,e.$colorTransform=r,j(e)};class Fe{$updated;constructor(){this.$updated=!0}canApplyFilter(){return!0}getBounds(t){return t}}const F=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},Gr=document.createElement("canvas");Gr.width=Gr.height=1;const Sr=Gr.getContext("2d"),Oe=e=>Sr?(Sr.fillStyle=e,+`0x${Sr.fillStyle.slice(1)}`):0,cn=Math.PI/180,ln=e=>{switch(e){case"full":return 0;case"inner":return 1;case"outer":return 2;default:return 0}},Ti=e=>e.strength>0&&e.distance!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Si=e=>e.blurX>0&&e.blurY>0&&e.quality>0,Ao=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],it=(e,t)=>{if(!Si(e))return t;const r=Ao[e.quality-1],n=Math.round(e.blurX*r),i=Math.round(e.blurY*r);return t[0]-=n,t[2]+=n,t[1]-=i,t[3]+=i,t},po=(e,t)=>{if(!Ti(e)||e.type==="inner")return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.abs(Math.cos(r)*n),s=Math.abs(Math.sin(r)*n);return t[0]-=i,t[2]+=i,t[1]-=s,t[3]+=s,t},mo=e=>[e.$filterType,e.distance,e.angle,e.highlightColor,e.highlightAlpha,e.shadowColor,e.shadowAlpha,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],go=e=>new Float32Array([e.$filterType,e.distance,e.angle,e.highlightColor,e.highlightAlpha,e.shadowColor,e.shadowAlpha,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout]);class rr extends Fe{$filterType=0;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$highlightColor;_$highlightAlpha;_$shadowColor;_$shadowAlpha;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=16777215,i=1,s=0,a=1,o=4,c=4,u=1,h=1,l="inner",f=!1){super(),this._$distance=4,this._$angle=45,this._$highlightColor=16777215,this._$highlightAlpha=1,this._$blurX=4,this._$blurY=4,this._$quality=1,this._$shadowColor=0,this._$shadowAlpha=1,this._$strength=1,this._$type="inner",this._$knockout=!1,this.blurX=o,this.blurY=c,this.quality=h,this.distance=t,this.angle=r,this.highlightColor=n,this.highlightAlpha=i,this.shadowColor=s,this.shadowAlpha=a,this.strength=u,this.type=l,this.knockout=f}get angle(){return this._$angle}set angle(t){t=F(t%360,-360,360,45),t!==this._$angle&&(this._$angle=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get distance(){return this._$distance}set distance(t){t=F(+t,-255,255,4),t!==this._$distance&&(this._$distance=t,this.$updated=!0)}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){t=F(+t,0,1,0),t!==this._$highlightAlpha&&(this._$highlightAlpha=t,this.$updated=!0)}get highlightColor(){return this._$highlightColor}set highlightColor(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,16777215),t!==this._$highlightColor&&(this._$highlightColor=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get shadowAlpha(){return this._$shadowAlpha}set shadowAlpha(t){t=F(t,0,1,0),t!==this._$shadowAlpha&&(this._$shadowAlpha=t,this.$updated=!0)}get shadowColor(){return this._$shadowColor}set shadowColor(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$shadowColor&&(this._$shadowColor=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}get type(){return this._$type}set type(t){if(t=`${t}`.toLowerCase(),t!==this._$type){switch(t){case"inner":case"outer":case"full":break;default:return}this._$type=t,this.$updated=!0}}clone(){return new rr(this._$distance,this._$angle,this._$highlightColor,this._$highlightAlpha,this._$shadowColor,this._$shadowAlpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return mo(this)}toNumberArray(){return go(this)}canApplyFilter(){return Ti(this)}getBounds(t){return po(this,t)}}const bo=e=>[e.$filterType,e.blurX,e.blurY,e.quality],xo=e=>new Float32Array([e.$filterType,e.blurX,e.blurY,e.quality]);class nr extends Fe{$filterType=1;_$blurX;_$blurY;_$quality;constructor(t=4,r=4,n=1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this.blurX=t,this.blurY=r,this.quality=n}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}clone(){return new nr(this._$blurX,this._$blurY,this._$quality)}toArray(){return bo(this)}toNumberArray(){return xo(this)}canApplyFilter(){return Si(this)}getBounds(t){return it(this,t)}}const yo=e=>[e.$filterType,e.matrix],$o=e=>new Float32Array([e.$filterType,...e.matrix]);class ir extends Fe{$filterType=2;_$matrix;constructor(t=null){super(),this._$matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],t&&t.length===20&&(this.matrix=t)}get matrix(){return this._$matrix}set matrix(t){if(this._$matrix!==t&&!(!Array.isArray(t)||t.length!==20)){for(let r=0;r<20;r++)if(t[r]!==this._$matrix[r]){this.$updated=!0;break}this.$updated&&(this._$matrix=t)}}clone(){return new ir(this._$matrix)}toArray(){return yo(this)}toNumberArray(){return $o(this)}}const vo=e=>e.matrix!==null&&e.matrixX*e.matrixY===e.matrix.length,wo=e=>[e.$filterType,e.matrixX,e.matrixY,e.matrix,e.divisor,e.bias,e.preserveAlpha,e.clamp,e.color,e.alpha],Mo=e=>{const t=e.matrix||[];return new Float32Array([e.$filterType,e.matrixX,e.matrixY,...t,e.divisor,e.bias,+e.preserveAlpha,+e.clamp,e.color,e.alpha])};class sr extends Fe{$filterType=3;_$matrixX;_$matrixY;_$matrix;_$divisor;_$bias;_$preserveAlpha;_$clamp;_$color;_$alpha;constructor(t=0,r=0,n=null,i=1,s=0,a=!0,o=!0,c=0,u=0){super(),this._$matrixX=0,this._$matrixY=0,this._$matrix=null,this._$divisor=1,this._$bias=0,this._$preserveAlpha=!0,this._$clamp=!0,this._$color=0,this._$alpha=0,this.matrixX=t,this.matrixY=r,this.matrix=n,this.divisor=i,this.bias=s,this.preserveAlpha=a,this.clamp=o,this.color=c,this.alpha=u}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get bias(){return this._$bias}set bias(t){t|=0,t!==this._$bias&&(this._$bias=t,this.$updated=!0)}get clamp(){return this._$clamp}set clamp(t){t=!!t,t!==this._$clamp&&(this._$clamp=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$color&&(this._$color=t,this.$updated=!0)}get divisor(){return this._$divisor}set divisor(t){t|=0,t!==this._$divisor&&(this._$divisor=t,this.$updated=!0)}get matrix(){return this._$matrix}set matrix(t){this._$matrix!==t&&(this._$matrix=t,this.$updated=!0)}get matrixX(){return this._$matrixX}set matrixX(t){t=F(t|0,0,15,0)|0,t!==this._$matrixX&&(this._$matrixX=t,this.$updated=!0)}get matrixY(){return this._$matrixY}set matrixY(t){t=F(t|0,0,15,0)|0,t!==this._$matrixY&&(this._$matrixY=t,this.$updated=!0)}get preserveAlpha(){return this._$preserveAlpha}set preserveAlpha(t){t=!!t,t!==this._$preserveAlpha&&(this._$preserveAlpha=t,this.$updated=!0)}clone(){return new sr(this._$matrixX,this._$matrixY,this._$matrix?this._$matrix.slice():null,this._$divisor,this._$bias,this._$preserveAlpha,this._$clamp,this._$color,this._$alpha)}toArray(){return wo(this)}toNumberArray(){return Mo(this)}canApplyFilter(){return vo(this)}}const Bo=e=>e.bitmapBuffer!==null&&e.componentX>0&&e.componentY>0&&e.scaleX!==0&&e.scaleY!==0,To=e=>[e.$filterType,e.bitmapBuffer?Array.from(e.bitmapBuffer):null,e.bitmapWidth,e.bitmapHeight,e.mapPointX,e.mapPointY,e.componentX,e.componentY,e.scaleX,e.scaleY,e.mode,e.color,e.alpha],So=e=>{let t=2;switch(e.mode){case"clamp":t=0;break;case"color":t=1;break;case"wrap":t=2;break;case"ignore":t=3;break;default:t=2;break}const r=e.bitmapBuffer||new Uint8Array,n=[e.$filterType,r.length];for(let i=0;i[e.$filterType,e.distance,e.angle,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout,e.hideObject],Co=e=>new Float32Array([e.$filterType,e.distance,e.angle,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,+e.inner,+e.knockout,+e.hideObject]),Ii=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Fo=(e,t)=>{if(!Ii(e)||e.inner)return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.cos(r)*n,s=Math.sin(r)*n;return t[0]=Math.min(t[0],i),i>0&&(t[2]+=i),t[1]=Math.min(t[1],s),s>0&&(t[3]+=s),t};class or extends Fe{$filterType=5;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$color;_$alpha;_$strength;_$inner;_$knockout;_$hideObject;constructor(t=4,r=45,n=0,i=1,s=4,a=4,o=1,c=1,u=!1,h=!1,l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this._$hideObject=!1,this.blurX=s,this.blurY=a,this.quality=c,this.distance=t,this.angle=r,this.color=n,this.alpha=i,this.strength=o,this.inner=u,this.knockout=h,this.hideObject=l}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get angle(){return this._$angle}set angle(t){t=F(t%360,-360,360,45),t!==this._$angle&&(this._$angle=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$color&&(this._$color=t,this.$updated=!0)}get distance(){return this._$distance}set distance(t){t=F(+t,-255,255,4),t!==this._$distance&&(this._$distance=t,this.$updated=!0)}get hideObject(){return this._$hideObject}set hideObject(t){t=!!t,t!==this._$hideObject&&(this._$hideObject=t,this.$updated=!0)}get inner(){return this._$inner}set inner(t){t=!!t,t!==this._$inner&&(this._$inner=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}clone(){return new or(this._$distance,this._$angle,this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout,this._$hideObject)}toArray(){return Io(this)}toNumberArray(){return Co(this)}canApplyFilter(){return Ii(this)}getBounds(t){return Fo(this,t)}}const Eo=e=>[e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout],Po=e=>new Float32Array([e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,+e.inner,+e.knockout]),Ci=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Ro=(e,t)=>!Ci(e)||e.inner?t:it(e,t);class cr extends Fe{$filterType=6;_$blurX;_$blurY;_$quality;_$color;_$alpha;_$strength;_$inner;_$knockout;constructor(t=0,r=1,n=4,i=4,s=1,a=1,o=!1,c=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this.blurX=n,this.blurY=i,this.quality=a,this.color=t,this.alpha=r,this.strength=s,this.inner=o,this.knockout=c}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,4),t!==this._$color&&(this._$color=t,this.$updated=!0)}get inner(){return this._$inner}set inner(t){t=!!t,t!==this._$inner&&(this._$inner=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}clone(){return new cr(this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout)}toArray(){return Eo(this)}toNumberArray(){return Po(this)}canApplyFilter(){return Ci(this)}getBounds(t){return Ro(this,t)}}const Fi=e=>e.strength>0&&e.distance>0&&e.alphas!==null&&e.ratios!==null&&e.colors!==null&&e.blurX>0&&e.blurY>0&&e.quality>0,Oo=e=>[e.$filterType,e.distance,e.angle,e.colors,e.alphas,e.ratios,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],ko=e=>{const t=e.colors?e.colors:[],r=e.alphas?e.alphas:[],n=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,r.length,...r,n.length,...n,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout])},Uo=(e,t)=>{if(!Fi(e)||e.type==="inner")return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.abs(Math.cos(r)*n),s=Math.abs(Math.sin(r)*n);return t[0]-=i,t[2]+=i,t[1]-=s,t[3]+=s,t};class lr extends Fe{$filterType=7;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=null,i=null,s=null,a=4,o=4,c=1,u=1,h="inner",l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type="inner",this._$knockout=!1,this.blurX=a,this.blurY=o,this.quality=u,this.distance=t,this.angle=r,this.colors=n,this.alphas=i,this.ratios=s,this.strength=c,this.type=h,this.knockout=l}get alphas(){return this._$alphas}set alphas(t){if(t!==this._$alphas){if(Array.isArray(t))for(let r=0;r[e.$filterType,e.distance,e.angle,e.colors,e.alphas,e.ratios,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],Ei=e=>e.strength>0&&e.distance>0&&e.alphas!==null&&e.ratios!==null&&e.colors!==null&&e.blurX>0&&e.blurY>0&&e.quality>0,_o=e=>{const t=e.colors?e.colors:[],r=e.alphas?e.alphas:[],n=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,r.length,...r,n.length,...n,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout])},Do=(e,t)=>!Ei(e)||e.type==="inner"?t:it(e,t);class ur extends Fe{$filterType=8;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=null,i=null,s=null,a=4,o=4,c=1,u=1,h="outer",l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type="outer",this._$knockout=!1,this.blurX=a,this.blurY=o,this.quality=u,this.distance=t,this.angle=r,this.colors=n,this.alphas=i,this.ratios=s,this.strength=c,this.type=h,this.knockout=l}get alphas(){return this._$alphas}set alphas(t){if(t!==this._$alphas){if(Array.isArray(t))for(let r=0;r{const t=z();for(let r=0;r{if(e.$filters)return e.$filters;const t=tr(e);return t&&t.surfaceFilterList?(t.filters||(t.filters=Lo(t.surfaceFilterList)),t.filters):null},Yo=(e,t)=>{e.$filters=t,j(e)},Wo=e=>{if(e.$blendMode)return e.$blendMode;const t=tr(e);return t&&t.blendMode?t.blendMode:"normal"},Vo=(e,t)=>{e.$blendMode!==t&&(e.$blendMode=t,j(e))},Ko=180/Math.PI,Qo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?Math.atan2(t[1],t[0])*Ko:0},Xo=Math.PI/180,zo=(e,t)=>{if(t=me(t%360,-360,360,0),e.$rotation===t)return;let r=e.$matrix;if(!r){const s=_(e);e.$matrix=r=s?new T(...s):new T}const n=Math.sqrt(r.a*r.a+r.b*r.b),i=Math.sqrt(r.c*r.c+r.d*r.d);if(t===0)r.a=n,r.b=0,r.c=0,r.d=i;else{let s=Math.atan2(r.b,r.a),a=Math.atan2(-r.c,r.d);const o=t*Xo;a=a+o-s,s=o,r.b=n*Math.sin(s),r.b===1||r.b===-1?r.a=0:r.a=n*Math.cos(s),r.c=-i*Math.sin(a),r.c===1||r.c===-1?r.d=0:r.d=i*Math.cos(a)}e.$scaleX=null,e.$scaleY=null,e.$rotation=t,j(e)},Ho=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);if(!t)return 1;const n=(Math.abs(t[0])>=1e-12?Math.sign(t[0]):Math.sign(t[1]))||1,i=Math.hypot(t[0],t[1]);return Math.round(i*n*1e4)/1e4},Pi=(e,t)=>{t=me(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);const r=Math.round(t*1e4)/1e4;if(e.$scaleX===r)return;let n=e.$matrix;if(!n){const i=_(e);e.$matrix=n=i?new T(...i):new T}if(n.b===0||isNaN(n.b))n.a=r;else{const s=Math.atan2(n.b,n.a),a=Math.hypot(n.a,n.b),o=(Math.abs(n.a)>=1e-12?Math.sign(n.a):Math.sign(n.b))||1,h=(a*o>=0?s:s-Math.PI)+(r<0?Math.PI:0),l=Math.abs(r);n.a=l*Math.cos(h),n.b=l*Math.sin(h)}e.$scaleX=r,e.$rotation=null,j(e)},Jo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);if(!t)return 1;const r=1e-12,n=Math.hypot(t[0],t[1]),i=(Math.abs(t[0])>=r?Math.sign(t[0]):Math.sign(t[1]))||1;return Math.round((t[0]*t[3]-t[1]*t[2])/(n*i)*1e4)/1e4},Ri=(e,t)=>{t=me(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);const r=Math.round(t*1e4)/1e4;if(e.$scaleY===r)return;let n=e.$matrix;if(!n){const i=_(e);e.$matrix=n=i?new T(...i):new T}if(n.c===0||isNaN(n.c))n.d=r;else{const i=Math.max(0,Math.abs(r)),s=1e-12;let a=Math.atan2(n.b,n.a);(n.a<0||Math.abs(n.a)Math.PI&&(a-=2*Math.PI);const o=a+(r<0?Math.PI:0);n.c=-i*Math.sin(o),n.d=i*Math.cos(o)}e.$scaleY=r,e.$rotation=null,j(e)},Zo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?t[4]:0},qo=(e,t)=>{let r=e.$matrix;if(!r){const n=_(e);e.$matrix=r=n?new T(...n):new T}e.$x!==t&&(e.$x=r.tx=t,j(e))},jo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?t[5]:0},ec=(e,t)=>{let r=e.$matrix;if(!r){const n=_(e);e.$matrix=r=n?new T(...n):new T}e.$y!==t&&(e.$y=r.ty=t,j(e))},he=(e,t,r,n,i)=>{const s=i[0],a=i[1],o=i[2],c=i[3],u=i[4],h=i[5],l=r*s+n*o+u,f=r*s+t*o+u,A=e*s+n*o+u,d=e*s+t*o+u,y=r*a+n*c+h,g=r*a+t*c+h,p=e*a+n*c+h,$=e*a+t*c+h;return re(Math.min(l,f,A,d),Math.min(y,g,p,$),Math.max(l,f,A,d),Math.max(y,g,p,$))},Oi=e=>{const t=e.graphics;return re(t.xMin,t.yMin,t.xMax,t.yMax)},wt=(e,t=null)=>{const r=Oi(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},ki=e=>re(0,0,e.videoWidth,e.videoHeight),Mt=(e,t=null)=>{const r=ki(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},Ui=e=>re(e.xMin,e.yMin,e.xMax,e.yMax),Bt=(e,t=null)=>{const r=Ui(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},yt=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),i=n?t?T.multiply(t,n):n:t,s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{switch(!0){case e.isContainerEnabled:return yt(e);case e.isShape:return wt(e);case e.isText:return Bt(e);case e.isVideo:return Mt(e);default:return re(0,0,0,0)}},tc=e=>{const t=Gi(e),r=Math.abs(t[2]-t[0]);switch(k(t),!0){case r===0:case r===1/0:case r===-1/0:return 0;default:return Math.round(r*100)/100}},_i=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e);let i=t;n&&(i=t?T.multiply(t,n):n);const s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{switch(!0){case e.isContainerEnabled:return _i(e);case e.isShape:return Oi(e);case e.isText:return Ui(e);case e.isVideo:return ki(e);default:return re(0,0,0,0)}},rc=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;const r=tt(e);let n=Math.abs(r[2]-r[0]);switch(!0){case n===0:case n===1/0:case n===-1/0:return;default:n=Math.round(n*100)/100;break}Pi(e,t/n)},nc=(e,t)=>{const r=e.concatenatedMatrix,n=new se(t.x*r.a+t.y*r.c+r.tx,t.x*r.b+t.y*r.d+r.ty);return T.release(r.rawData),n},ic=(e,t)=>{const r=e.concatenatedMatrix;r.invert();const n=new se(t.x*r.a+t.y*r.c+r.tx,t.x*r.b+t.y*r.d+r.ty);return T.release(r.rawData),n},sc=e=>{const t=Gi(e),r=Math.abs(t[3]-t[1]);switch(k(t),!0){case r===0:case r===1/0:case r===-1/0:return 0;default:return Math.round(r*100)/100}},ac=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;const r=tt(e);let n=Math.abs(r[3]-r[1]);switch(!0){case n===0:case n===1/0:case n===-1/0:return;default:n=Math.round(n*100)/100;break}Ri(e,t/n)},oc=e=>{const t=e.parent;t&&t.removeChild(e)},cc=(e,t=null)=>{const r=e.concatenatedMatrix,n=tt(e),i=he(n[0],n[1],n[2],n[3],r.rawData);if(k(n),T.release(r.rawData),!t){const c=new be(i[0],i[1],Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1]));return k(i),c}const s=t.concatenatedMatrix;s.invert();const a=he(i[0],i[1],i[2],i[3],s.rawData);k(i),T.release(s.rawData);const o=new be(a[0],a[1],Math.abs(a[2]-a[0]),Math.abs(a[3]-a[1]));return k(a),o},lc=(e,t)=>{const r=tt(e),n=e.concatenatedMatrix,i=he(r[0],r[1],r[2],r[3],n.rawData);k(r),T.release(n.rawData);const s=tt(t),a=t.concatenatedMatrix,o=he(s[0],s[1],s[2],s[3],a.rawData);k(s),T.release(a.rawData);const c=Math.max(i[0],o[0]),u=Math.max(i[1],o[1]),h=Math.min(i[2],o[2]),l=Math.min(i[3],o[3]);return k(i),k(o),h-c>=0&&l-u>=0};class Xt{_$bitmapData;_$matrix;_$repeat;_$smooth;constructor(t,r=null,n=!0,i=!1){this._$bitmapData=t,this._$matrix=r,this._$repeat=n,this._$smooth=i}clone(){return new Xt(this._$bitmapData.clone(),this._$matrix?this._$matrix.clone():null,this._$repeat,this._$smooth)}toArray(){return z(this._$bitmapData,this._$matrix,this._$repeat,this._$smooth)}}class zt{_$type;_$colors;_$alphas;_$ratios;_$matrix;_$spreadMethod;_$interpolationMethod;_$focalPointRatio;_$colorStops;constructor(t,r,n,i,s=null,a="pad",o="rgb",c=0){this._$type=t,this._$colors=r,this._$alphas=n,this._$ratios=i,this._$matrix=s,this._$spreadMethod=a,this._$interpolationMethod=o,this._$focalPointRatio=c,this._$colorStops=z()}get colorStops(){if(!this._$colorStops.length){const t=Math.min(Math.min(this._$alphas.length,this._$colors.length),this._$ratios.length);for(let r=0;r>>16&255,G:i>>>8&255,B:i&255,A:this._$alphas[r]*255&255}}}return this._$colorStops}toArray(){return z(this._$type,this.colorStops,this._$matrix?this._$matrix.rawData:xt,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}clone(){return new zt(this._$type,this._$colors.slice(),this._$alphas.slice(),this._$ratios.slice(),this._$matrix?this._$matrix.clone():null,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}}const uc=(e,t=0,r=0)=>{e.xMin=Math.min(e.xMin,t),e.xMax=Math.max(e.xMax,t),e.yMin=Math.min(e.yMin,r),e.yMax=Math.max(e.yMax,r)},Rn=(e,t=0,r=0,n=0,i=0,s=0,a="none")=>{e.xMin=Math.min(e.xMin,Math.min(t,n)),e.xMax=Math.max(e.xMax,Math.max(t,n)),e.yMin=Math.min(e.yMin,Math.min(r,i)),e.yMax=Math.max(e.yMax,Math.max(r,i));const o=n-t,c=i-r,u=Math.sqrt(o*o+c*c);if(!u)return;const h=o/u,l=c/u,f=-l,A=h,d=s/2,y=Math.min(t+f*d,t-f*d,n+f*d,n-f*d),g=Math.max(t+f*d,t-f*d,n+f*d,n-f*d),p=Math.min(r+A*d,r-A*d,i+A*d,i-A*d),$=Math.max(r+A*d,r-A*d,i+A*d,i-A*d);if(e.xMin=Math.min(e.xMin,y),e.xMax=Math.max(e.xMax,g),e.yMin=Math.min(e.yMin,p),e.yMax=Math.max(e.yMax,$),a==="round"||a==="square"){const w=t+d*-h,I=r+d*-l,P=Math.min(w+d*h+d*f,w-d*h+d*f,w+d*h-d*f,w-d*h-d*f),W=Math.max(w+d*h+d*f,w-d*h+d*f,w+d*h-d*f,w-d*h-d*f),C=Math.min(I+d*l+d*A,I+d*l-d*A,I-d*l-d*A,I-d*l+d*A),R=Math.max(I+d*l+d*A,I+d*l-d*A,I-d*l-d*A,I-d*l+d*A);e.xMin=Math.min(e.xMin,P),e.xMax=Math.max(e.xMax,W),e.yMin=Math.min(e.yMin,C),e.yMax=Math.max(e.yMax,R)}},ot=(e,t,r=0,n=0,i=0,s="none",...a)=>{for(let o=0;o{e.isConfirmed=!1,t&&n&&n.push(...s),r&&i&&i.push(...s)},hc=(e,t,r,n,i)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0,n=Math.round(n),i=Math.round(i);const s=n/2,a=i/2,o=t+s,c=r+a,u=t+n,h=r+i,l=4/3*(Math.SQRT2-1),f=l*s,A=l*a;return e.moveTo(o,r).cubicCurveTo(o+f,r,u,c-A,u,c).cubicCurveTo(u,c+A,o+f,h,o,h).cubicCurveTo(o-f,h,t,c+A,t,c).cubicCurveTo(t,c-A,o-f,r,o,r)},fc=(e,t,r,n,i)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0;const s=Math.round(t+n),a=Math.round(r+i);return e.moveTo(t,r).lineTo(t,a).lineTo(s,a).lineTo(s,r).lineTo(t,r)},dc=(e,t,r,n,i,s,a=NaN)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0,s=+s||0,a=+a||s,n=Math.round(n),i=Math.round(i),s=Math.round(s),a=Math.round(a);const o=s/2,c=a/2,u=4/3*(Math.SQRT2-1),h=u*o,l=u*c,f=t+o,A=t+n,d=A-o,y=r+c,g=r+i,p=g-c;return e.moveTo(f,r).lineTo(d,r).cubicCurveTo(d+h,r,A,y-l,A,y).lineTo(A,p).cubicCurveTo(A,p+l,d+h,g,d,g).lineTo(f,g).cubicCurveTo(f-h,g,t,p+l,t,p).lineTo(t,y).cubicCurveTo(t,y-l,f-h,r,f,r)},Lt=e=>{if(!e)return[];const t=z();for(let r=0;rl.ratio-f.ratio);for(let l=0;l0&&r>0}beginBitmapFill(t,r=null,n=!0,i=!1){return this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z()),this._$maxAlpha=1,this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(M.BEGIN_PATH),this._$fillType=M.BITMAP_FILL,this._$fillBitmap=new Xt(t,r,n,i),this}beginFill(t=0,r=1){this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z()),typeof t=="string"&&(t=Or(t)),t=me(t,0,16777215,0),r=me(r,0,1,1),this._$maxAlpha=Math.max(this._$maxAlpha,r),this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(M.BEGIN_PATH),this._$fillType=M.FILL_STYLE;const n=t>>>16&255,i=t>>>8&255,s=t&255;return this._$fillColor=n<<24|i<<16|s<<8|r*255,this}beginGradientFill(t,r,n,i,s=null,a="pad",o="rgb",c=0){this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z());for(let u=0;uthis._$fills.length)return this;switch(this.$recodes||(this.$recodes=z()),(this._$fills[2]!==this._$fills[this._$fills.length-2]||this._$fills[3]!==this._$fills[this._$fills.length-1])&&this._$fills.push(M.LINE_TO,this._$fills[2],this._$fills[3]),this.$recodes.push(...this._$fills),oe(this._$fills),this._$fills=null,this._$fillType){case M.FILL_STYLE:this.$recodes.push(this._$fillType,this._$fillColor>>>24&255,this._$fillColor>>>16&255,this._$fillColor>>>8&255,this._$fillColor&255,M.END_FILL);break;case M.GRADIENT_FILL:this._$fillGradient&&this.$recodes.push(this._$fillType,...this._$fillGradient.toArray());break;case M.BITMAP_FILL:this._$fillBitmap&&this.$recodes.push(this._$fillType,...this._$fillBitmap.toArray());break}return this._$fillType=0,this._$fillColor=0,this._$fillGradient=null,this._$fillBitmap=null,this._$hasFillEnabled=!1,this}endLine(){if(!this._$hasLineEnabled||!this._$lines)return this;switch(this.$recodes||(this.$recodes=z()),this.$recodes.push(...this._$lines),oe(this._$lines),this._$lines=null,this._$lineType){case M.STROKE_STYLE:this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineColor>>>24&255,this._$lineColor>>>16&255,this._$lineColor>>>8&255,this._$lineColor&255,M.END_STROKE);break;case M.GRADIENT_STROKE:this._$lineGradient&&this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,...this._$lineGradient.toArray());break;case M.BITMAP_STROKE:this._$fillBitmap&&this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,...this._$fillBitmap.toArray());break}return this._$lineType=0,this._$lineWidth=0,this._$lineGradient=null,this._$lineColor=0,this._$caps="none",this._$joints="round",this._$miterLimit=0,this._$hasLineEnabled=!1,this}lineBitmapStyle(t,r=null,n=!0,i=!1){return this._$hasLineEnabled?(this._$lines||(this._$lines=z()),this._$maxAlpha=1,this._$hasLineEnabled=!0,this._$isBeginning=!0,this._$lines.push(M.BEGIN_PATH),this._$lineType=M.BITMAP_STROKE,this._$fillBitmap=new Xt(t,r,n,i),this):this}lineGradientStyle(t,r,n,i,s=null,a="pad",o="rgb",c=0){if(!this._$hasLineEnabled)return this;this._$lines||(this._$lines=z());for(let u=0;u>>16&255,c=r>>>8&255,u=r&255;return this._$lineColor=o<<24|c<<16|u<<8|n*255,this._$lineWidth=t,this._$caps=`${i}`,this._$joints=`${s}`,this._$joints==="miter"&&(this._$miterLimit=a),this}lineTo(t,r){return t=+t||0,r=+r||0,this._$positionX===t&&this._$positionY===r?this:(ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r),ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.LINE_TO,t,r),this._$positionX=t,this._$positionY=r,this)}moveTo(t,r){t=+t||0,r=+r||0,this._$positionX=t,this._$positionY=r,ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r);let n=!1;return this._$hasFillEnabled&&this._$fills&&this._$fills[this._$fills.length-3]===M.MOVE_TO&&(n=!0,this._$fills[this._$fills.length-2]=t,this._$fills[this._$fills.length-1]=r),this._$hasLineEnabled&&this._$lines&&this._$lines[this._$lines.length-3]===M.MOVE_TO&&(n=!0,this._$lines[this._$lines.length-2]=t,this._$lines[this._$lines.length-1]=r),n||ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.MOVE_TO,t,r),this}get buffer(){if(this.isConfirmed&&this._$buffer)return this._$buffer;this._$hasLineEnabled&&this.endLine(),this._$hasFillEnabled&&this.endFill();const t=Lt(this.$recodes);return this._$buffer=new Float32Array(t),oe(t),this.isConfirmed=!0,this._$buffer}set buffer(t){this._$buffer=t,this.isConfirmed=!0,this._$isBeginning=!0,this._$maxAlpha=1}}const Ac=(e,t,r)=>{for(let n=0;n{const i=e.graphics,s=i.xMax-i.xMin,a=i.yMax-i.yMin;if(s<=0||a<=0)return!1;const o=_(e),c=o?T.multiply(r,o):r;t.beginPath(),t.setTransform(c[0],c[1],c[2],c[3],c[4],c[5]);let u=!1;return i.buffer.length?u=Ac(t,i.buffer,n):(t.moveTo(0,0),t.lineTo(s,0),t.lineTo(s,a),t.lineTo(0,a),t.lineTo(0,0),u=t.isPointInPath(n.x,n.y)),c!==r&&T.release(c),u},Yt=(e,t,r,n)=>{const i=Math.ceil(Math.abs(e.xMax-e.xMin)),s=Math.ceil(Math.abs(e.yMax-e.yMin));if(i<=0||s<=0)return!1;const a=_(e),o=a?T.multiply(r,a):r;return t.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,s),t.lineTo(0,s),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},Wt=(e,t,r,n)=>{const i=e.videoWidth,s=e.videoHeight;if(i<=0||s<=0)return!1;const a=_(e),o=a?T.multiply(r,a):r;return t.beginPath(),t.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,s),t.lineTo(0,s),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},He=(e,t,r,n,i=!0)=>{const s=e.children;if(!s.length)return!1;const a=_(e),o=a?T.multiply(r,a):r,c=z(),u=z(),h=io();let l=0,f=0;for(let g=0;gl&&(f=0,l=0),f&&h.set(p.instanceId,f),u.push(p))}}const A=e.mouseChildren&&i;if(e.isSprite&&e.hitArea){const g=He(e.hitArea,t,o,n,A);return g&&A&&e.mouseEnabled&&(e.buttonMode&&e.useHandCursor&&(n.pointer="pointer"),n.hit||(n.hit=e)),g}let d=!1;const y=e.mask;if(y){let g=!1;switch(!0){case y.isContainerEnabled:g=He(y,t,o,n,A);break;case y.isShape:g=Nt(y,t,o,n);break;case y.isText:g=Yt(y,t,o,n);break;case y.isVideo:g=Wt(y,t,o,n);break}if(!g)return!1}for(;u.length;){const g=u.pop();if(!g||g.isMask)continue;if(h.has(g.instanceId)){const $=h.get(g.instanceId);if(!$)continue;const w=c[$];if(!w)continue;let I=!1;switch(!0){case w.isContainerEnabled:I=He(w,t,o,n,A);break;case w.isShape:I=Nt(w,t,o,n);break;case w.isText:I=Yt(w,t,o,n);break;case w.isVideo:I=Wt(w,t,o,n);break}if(!I)continue}let p=!1;switch(!0){case g.isContainerEnabled:p=He(g,t,o,n,A);break;case g.isShape:p=Nt(g,t,o,n);break;case g.isText:p=Yt(g,t,o,n);break;case g.isVideo:p=Wt(g,t,o,n);break}if(p){if(d=!0,!A)break;if(g.isInteractive&&g.mouseEnabled){if(n.pointer==="auto")switch(!0){case g.isText:g.type==="input"&&(n.pointer="text");break;case g.isSprite:g.buttonMode&&g.useHandCursor&&(n.pointer="pointer");break;default:n.pointer="pointer";break}n.hit||(n.hit=g);break}}}return oe(c),oe(u),so(h),o!==r&&T.release(o),d},Ge={x:0,y:0,pointer:"",hit:null},pc=(e,t,r,n=!1)=>{if(n){const h=e.parent,l=h?h.concatenatedMatrix.rawData:xt;switch(Ie.setTransform(1,0,0,1,0,0),Ie.beginPath(),Ge.x=t,Ge.y=r,Ge.hit=null,!0){case e.isContainerEnabled:return He(e,Ie,l,Ge);case e.isShape:return Nt(e,Ie,l,Ge);case e.isText:return Yt(e,Ie,l,Ge);case e.isVideo:return Wt(e,Ie,l,Ge);default:return!1}}const i=tt(e),s=_(e),a=he(i[0],i[1],i[2],i[3],s||xt);k(i);const o=new be(a[0],a[1],Math.abs(a[2]-a[0]),Math.abs(a[3]-a[1]));k(a);const c=e.parent,u=c?c.globalToLocal(new se(t,r)):new se(t,r);return o.containsPoint(u)},mc=e=>{const t=_(e);return t?new T(t[0],t[1],t[2],t[3],t[4],t[5]):new T},gc=e=>{const t=Ve(e);return t?new U(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]):new U};class hr extends nt{instanceId;dictionaryId;isSprite;isInteractive;isContainerEnabled;isTimelineEnabled;isShape;isVideo;isText;placeId;placeObject;characterId;clipDepth;name;startFrame;endFrame;changed;$added;$addedToStage;uniqueKey;$matrix;$colorTransform;$filters;$blendMode;$scaleX;$scaleY;$rotation;$x;$y;$alpha;$cache;_$scale9Grid;_$visible;_$variables;isMask;parent;constructor(){super(),this.instanceId=yi(),this.dictionaryId=-1,this.uniqueKey="",this.isSprite=!1,this.isContainerEnabled=!1,this.isTimelineEnabled=!1,this.isShape=!1,this.isVideo=!1,this.isText=!1,this.isInteractive=!1,this.placeId=-1,this.placeObject=null,this.characterId=-1,this.clipDepth=0,this.name="",this.startFrame=1,this.endFrame=0,this.parent=null,this.isMask=!1,this.changed=!0,this.$added=!1,this.$addedToStage=!1,this.$matrix=null,this.$colorTransform=null,this.$filters=null,this.$blendMode=null,this._$visible=!0,this._$scale9Grid=null,this._$variables=null,this.$x=null,this.$y=null,this.$alpha=null,this.$scaleX=null,this.$scaleY=null,this.$rotation=null,this.$cache=null}get concatenatedMatrix(){return uo(this)}get alpha(){return ho(this)}set alpha(t){fo(this,t)}get blendMode(){return Wo(this)}set blendMode(t){Vo(this,t)}get filters(){return No(this)}set filters(t){Yo(this,t)}get dropTarget(){return lo()}get height(){return sc(this)}set height(t){ac(this,t)}get loaderInfo(){return Dt.has(this)?Dt.get(this):null}get colorTransform(){return gc(this)}set colorTransform(t){this.$colorTransform=t}get matrix(){return mc(this)}set matrix(t){this.$matrix=t}get mouseX(){return this.globalToLocal(bt).x}get mouseY(){return this.globalToLocal(bt).y}get root(){return we.has(this)?we.get(this):null}get rotation(){return this.$rotation===null?Qo(this):this.$rotation}set rotation(t){zo(this,t)}get scale9Grid(){return this._$scale9Grid}set scale9Grid(t){this._$scale9Grid!==t&&(this._$scale9Grid=t,j(this))}get scaleX(){return this.$scaleX===null?Ho(this):this.$scaleX}set scaleX(t){Pi(this,t)}get scaleY(){return this.$scaleY===null?Jo(this):this.$scaleY}set scaleY(t){Ri(this,t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$visible=t,j(this))}get width(){return tc(this)}set width(t){rc(this,t)}get x(){return this.$x===null?Zo(this):this.$x}set x(t){qo(this,t)}get y(){return this.$y===null?jo(this):this.$y}set y(t){ec(this,t)}getBounds(t=null){return cc(this,t)}globalToLocal(t){return ic(this,t)}hitTestObject(t){return lc(this,t)}hitTestPoint(t,r,n=!1){return pc(this,t,r,n)}localToGlobal(t){return nc(this,t)}getLocalVariable(t){if(!this._$variables)return null;if(this._$variables.has(t))return this._$variables.get(t)}setLocalVariable(t,r){this._$variables||(this._$variables=new Map),this._$variables.set(t,r)}hasLocalVariable(t){return this._$variables?this._$variables.has(t):!1}deleteLocalVariable(t){this._$variables&&this._$variables.has(t)&&(this._$variables.delete(t),this._$variables.size||(this._$variables=null))}getGlobalVariable(t){return Ue.has(t)?Ue.get(t):null}setGlobalVariable(t,r){Ue.set(t,r)}hasGlobalVariable(t){return Ue.has(t)}deleteGlobalVariable(t){Ue.has(t)&&Ue.delete(t)}clearGlobalVariable(){return Ue.clear()}remove(){oc(this)}$syncLoaderInfo(t){Dt.set(this,t)}}const Di=e=>{const t=e.children;for(let r=0;r{e.$addedToStage||!ge.has(e.instanceId)||(e.$addedToStage=!0,e.willTrigger(x.ADDED_TO_STAGE)&&e.dispatchEvent(new x(x.ADDED_TO_STAGE)))},Ni=e=>{const t=e.children;for(let r=0;r{e.$added||(e.$added=!0,e.willTrigger(x.ADDED)&&e.dispatchEvent(new x(x.ADDED,!0)))},On=(e,t,r=-1)=>{const n=t.parent;n&&n.removeChild(t);const i=e.children;return 0>r?i.push(t):i.splice(r,0,t),e.$container=null,t.parent=e,ge.has(e.instanceId)&&(we.set(t,e.root),ge.add(t.instanceId),t.isContainerEnabled&&Di(t)),bc(t),ge.has(e.instanceId)&&(Li(t),t.isContainerEnabled&&Ni(t)),j(t),t},Yi=e=>{const t=e.children;for(let r=0;r{e.$added&&(e.$added=!1,e.willTrigger(x.REMOVED)&&e.dispatchEvent(new x(x.REMOVED,!0)))},Wi=e=>{!e.$addedToStage||!ge.has(e.instanceId)||(e.$addedToStage=!1,e.willTrigger(x.REMOVED_FROM_STAGE)&&e.dispatchEvent(new x(x.REMOVED_FROM_STAGE)),e.uniqueKey&&O.has(e.uniqueKey)&&O.removeTimer(e.uniqueKey))},un=e=>{const t=e.children;for(let r=0;r{const r=t.parent;if(r&&r.instanceId!==e.instanceId)return;const n=e.children,i=n.indexOf(t);i>-1&&n.splice(i,1),e.$container=null,t.hasEventListener(x.ENTER_FRAME)&&t.removeAllEventListener(x.ENTER_FRAME),t.hasEventListener(V.KEY_DOWN)&&t.removeAllEventListener(V.KEY_DOWN),t.hasEventListener(V.KEY_UP)&&t.removeAllEventListener(V.KEY_UP),xc(t),ge.has(e.instanceId)&&(Wi(t),t.isContainerEnabled&&un(t)),ge.has(e.instanceId)&&(we.delete(t),ge.delete(t.instanceId),t.isVideo&&t.pause(),t.isContainerEnabled&&Yi(t)),t.parent=null,j(e)},Vi=(e,t)=>{const r=e.children;return t in r?r[t]:null},yc=(e,t)=>{const r=Vi(e,t);r&&hn(e,r)},$c=(e,t)=>{if(e.instanceId===t.instanceId)return!0;const r=e.children;for(let n=0;n{if(!t)return null;const r=e.children;for(let n=0;n{const r=e.children.slice();if(r.length)for(let n=0;n{const n=e.getChildIndex(t);if(n===-1||n===r)return;const i=e.children;i.splice(n,1),i.splice(r,0,t),j(e)},Bc=(e,t,r)=>{const n=e.getChildIndex(t),i=e.getChildIndex(r);if(n===-1||i===-1)return;const s=e.children;s[n]=r,s[i]=t,j(e)},Tc=(e,t,r)=>{const n=e.children,i=n[t],s=n[r];!i||!s||(n[t]=s,n[r]=i,j(e))};class fn extends hr{mouseEnabled;isInteractive;constructor(){super(),this.isInteractive=!0,this.mouseEnabled=!0}}class dn extends fn{_$children;_$mask;mouseChildren;$container;isContainerEnabled;constructor(){super(),this.isContainerEnabled=!0,this.mouseChildren=!0,this._$mask=null,this._$children=z(),this.$container=null}get children(){return this._$children}get numChildren(){return this.children.length}get mask(){return this._$mask}set mask(t){t!==this._$mask&&(this._$mask&&(this._$mask.isMask=!1,this._$mask=null),t&&(t.isMask=!0,this._$mask=t),j(this))}addChild(t){return On(this,t)}addChildAt(t,r){return On(this,t,r)}contains(t){return $c(this,t)}getChildAt(t){return Vi(this,t)}getChildByName(t){return vc(this,t)}getChildIndex(t){return this.children.indexOf(t)}removeChild(t){hn(this,t)}removeChildAt(t){yc(this,t)}removeChildren(...t){wc(this,t)}setChildIndex(t,r){Mc(this,t,r)}swapChildren(t,r){Bc(this,t,r)}swapChildrenAt(t,r){Tc(this,t,r)}}class Ki extends nt{name;frame;constructor(t,r){super(),this.name=`${t}`,this.frame=r|0}}class Sc extends nt{id;content;data;url;format;constructor(){super(),this.id=yi(),this.url="",this.content=null,this.data=null,this.format="json"}}const Ic=(e,t=!1,r=null)=>{const n=e.parent?e.parent.globalToLocal(bt):e.globalToLocal(bt);e.$lockCenter=t,e.$offsetX=e.x-n.x,e.$offsetY=e.y-n.y,e.$boundedRect=r,Bi(e)},Cc=e=>{e.$lockCenter=!1,e.$offsetX=0,e.$offsetY=0,e.$boundedRect=null,Bi(null)};class An extends dn{buttonMode;useHandCursor;isSprite;hitArea;_$soundTransform;$offsetX=0;$offsetY=0;$lockCenter=!1;$boundedRect=null;constructor(){super(),this.isSprite=!0,this.buttonMode=!1,this.useHandCursor=!0,this.hitArea=null,this.$offsetX=0,this.$offsetY=0,this.$lockCenter=!1,this.$boundedRect=null,this._$soundTransform=null}get soundTransform(){return this._$soundTransform}set soundTransform(t){this._$soundTransform=t}startDrag(t=!1,r=null){Ic(this,t,r)}stopDrag(){Cc(this)}}const Qi=e=>{e.isBitmap=!1,e.$bitmapBuffer=null,e.graphics.clear(),e.uniqueKey!==""&&O.has(e.uniqueKey)&&(O.removeById(e.uniqueKey),O.$removeIds.push(+e.uniqueKey)),j(e)},Xi=(e,t,r,n)=>{Qi(e),e.isBitmap=!0,e.$bitmapBuffer=n,e.graphics.xMin=0,e.graphics.yMin=0,e.graphics.xMax=t,e.graphics.yMax=r},Fc=(e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.addEventListener("load",()=>{const n=r.width,i=r.height,s=O.getCanvas();s.width=n,s.height=i;const a=s.getContext("2d",{willReadFrequently:!0});a.drawImage(r,0,0,n,i),Xi(e,n,i,new Uint8Array(a.getImageData(0,0,n,i).data)),O.destroy(a),e.hasEventListener(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE))}),r.src=t},Ec=(e,t)=>{const r=e.graphics,n=Math.ceil(Math.abs(t.bounds.xMax-t.bounds.xMin)),i=Math.ceil(Math.abs(t.bounds.yMax-t.bounds.yMin));switch(!0){case t.bitmapId>0:{const a=e.loaderInfo.data?.characters[t.bitmapId];if(!a)break;e.isBitmap=!0,a.imageBuffer||(a.imageBuffer=new Uint8Array(a.buffer),a.buffer=null);const o=Math.ceil(Math.abs(a.bounds.xMax-a.bounds.xMin)),c=Math.ceil(Math.abs(a.bounds.yMax-a.bounds.yMin));if(t.grid){if(t.recodes){const u=t.recodes.slice(0);u.splice(-6,6);const h=new _e(o,c);h.buffer=a.imageBuffer,u.push(M.BITMAP_FILL,h,null,!0,!1,9);const l=Lt(u);r.buffer=new Float32Array(l),oe(u),oe(l)}}else if(n===o&&i===c)e.setBitmapBuffer(Math.ceil(Math.abs(a.bounds.xMax-a.bounds.xMin)),Math.ceil(Math.abs(a.bounds.yMax-a.bounds.yMin)),a.imageBuffer);else{const u=new _e(o,c);if(u.buffer=a.imageBuffer,t.recodes)if(t.recodes[t.recodes.length-10]===M.BITMAP_STROKE){const l=t.recodes.slice(0);l.splice(-5,5),l.push(u,null,!0,!1);const f=Lt(l);r.buffer=new Float32Array(f),oe(l),oe(f)}else r.beginBitmapFill(u).drawRect(0,0,n,i)}}break;case t.inBitmap:{e.isBitmap=!0;const s=t.recodes,a=s[s.length-4];if(n===a.width&&i===a.height)e.setBitmapBuffer(a.width,a.height,a.buffer);else{const o=new _e(a.width,a.height);o.buffer=a.buffer,r.beginBitmapFill(o).drawRect(0,0,n,i)}}break;case"buffer"in t:t.imageBuffer||(t.imageBuffer=new Uint8Array(t.buffer),t.buffer=null),e.setBitmapBuffer(Math.ceil(Math.abs(r.xMax-r.xMin)),Math.ceil(Math.abs(r.yMax-r.yMin)),t.imageBuffer);break;default:t.recodes&&(t.recodeBuffer=new Float32Array(Lt(t.recodes)),oe(t.recodes),t.recodes=null),t.recodeBuffer&&(r.buffer=t.recodeBuffer);break}r.xMin=t.bounds.xMin,r.xMax=t.bounds.xMax,r.yMin=t.bounds.yMin,r.yMax=t.bounds.yMax,t.grid&&(e.scale9Grid=new be(t.grid.x,t.grid.y,t.grid.w,t.grid.h))},Pc=(e,t)=>new Promise(r=>{const n=()=>{e.removeEventListener(x.COMPLETE,n),r()};e.addEventListener(x.COMPLETE,n),e.src=t});class $t extends hr{_$graphics;_$src;isShape;cacheKey;cacheParams;isBitmap;$bitmapBuffer;constructor(){super(),this.isShape=!0,this.cacheKey=0,this.cacheParams=z(0,0,0),this._$graphics=null,this._$src="",this.$bitmapBuffer=null,this.isBitmap=!1}static get namespace(){return"next2d.display.Shape"}get namespace(){return"next2d.display.Shape"}get graphics(){return this._$graphics||(this._$graphics=new M,co.set(this._$graphics,this)),this._$graphics}get src(){return this._$src}set src(t){this._$src!==t&&(this._$src=t,Fc(this,t))}load(t){return Pc(this,t)}get bitmapData(){const t=new _e(this.width,this.height);return this.$bitmapBuffer&&(t.buffer=this.$bitmapBuffer),t}clearBitmapBuffer(){Qi(this)}setBitmapBuffer(t,r,n){Xi(this,t,r,n)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),Ec(this,t)}}let zi=null;const kn=e=>{zi=e},ke=()=>zi,de=document.createElement("textarea");de.tabIndex=-1;let Me="";Me+="position: fixed;";Me+="top: 0;";Me+="left: 0;";Me+="font-size: 16px;";Me+="border: 0;";Me+="resize: none;";Me+="opacity: 0;";Me+="z-index: -1;";Me+="pointer-events: none;";de.setAttribute("style",Me);const _r=document.createElement("canvas");_r.width=_r.height=1;const De=_r.getContext("2d");let Hi=0;const Et=()=>Hi,dt=e=>{Hi=e},Rc=e=>De?(De.fillStyle=e,+`0x${De.fillStyle.slice(1)}`):0,et=e=>isNaN(+e)?Rc(`${e}`):+e,Oc=(e,t=1)=>({R:(e&16711680)>>16,G:(e&65280)>>8,B:e&255,A:t*255}),pt=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};let Ji;const Ht=()=>Ji,Zi=e=>{Ji=e},Je={x:0,y:0};class ue{align;bold;color;font;italic;leading;leftMargin;letterSpacing;rightMargin;size;underline;constructor(t=null,r=null,n=null,i=null,s=null,a=null,o=null,c=null,u=null,h=null,l=null){this.font=t,this.size=r,this.color=n,this.bold=i,this.italic=s,this.underline=a,this.align=o,this.leftMargin=c,this.rightMargin=u,this.leading=h,this.letterSpacing=l}clone(){return new ue(this.font,this.size,this.color,this.bold,this.italic,this.underline,this.align,this.leftMargin,this.rightMargin,this.leading,this.letterSpacing)}toObject(){return{font:this.font,size:this.size,color:et(this.color),bold:this.bold,italic:this.italic,underline:this.underline,align:this.align,leftMargin:this.leftMargin,rightMargin:this.rightMargin,leading:this.leading,letterSpacing:this.letterSpacing}}}const kc=e=>{e.align="left",e.bold=!1,e.color=0,e.font="Times New Roman",e.italic=!1,e.leading=0,e.leftMargin=0,e.letterSpacing=0,e.rightMargin=0,e.size=12,e.underline=!1},Uc=e=>{let t="";if(e.font&&(t+=`font-family: ${e.font};`),e.size&&(t+=`font-size: ${e.size}px;`),e.color){const r=Oc(et(e.color)),n=r.R.toString(16).padStart(2,"0"),i=r.G.toString(16).padStart(2,"0"),s=r.B.toString(16).padStart(2,"0");t+=`color: #${n}${i}${s};`}return e.bold&&(t+="font-weight: bold;"),e.italic&&(t+="font-style: italic;"),e.underline&&(t+="text-decoration: underline;"),e.align&&(t+=`text-align: ${e.align};`),e.leftMargin&&(t+=`margin-left: ${e.leftMargin}px;`),e.rightMargin&&(t+=`margin-right: ${e.rightMargin}px;`),e.leading&&(t+=`margin-bottom: ${e.leading}px;`),e.letterSpacing&&(t+=`letter-spacing: ${e.letterSpacing}px;`),t};class Gc{_$textWidth;_$textHeight;heightTable;ascentTable;widthTable;textTable;lineTable;constructor(){this._$textWidth=-1,this._$textHeight=-1,this.widthTable=[],this.heightTable=[],this.ascentTable=[],this.textTable=[],this.lineTable=[]}get textWidth(){if(this._$textWidth!==-1)return this._$textWidth;this._$textWidth=0;for(let t=0;t{let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t});function Dc(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=_c.get(e))!==null&&t!==void 0?t:e}function qi(e){const t=typeof atob=="function"?atob(e):typeof Buffer.from=="function"?Buffer.from(e,"base64").toString("binary"):new Buffer(e,"base64").toString("binary"),r=t.length&-2,n=new Uint16Array(r/2);for(let i=0,s=0;i=X.ZERO&&e<=X.NINE}function Yc(e){return e>=X.UPPER_A&&e<=X.UPPER_F||e>=X.LOWER_A&&e<=X.LOWER_F}function Wc(e){return e>=X.UPPER_A&&e<=X.UPPER_Z||e>=X.LOWER_A&&e<=X.LOWER_Z||Dr(e)}function Vc(e){return e===X.EQUALS||Wc(e)}var ne;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(ne||(ne={}));var $e;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})($e||($e={}));class Kc{constructor(t,r,n){this.decodeTree=t,this.emitCodePoint=r,this.errors=n,this.state=ne.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=$e.Strict,this.runConsumed=0}startEntity(t){this.decodeMode=t,this.state=ne.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(t,r){switch(this.state){case ne.EntityStart:return t.charCodeAt(r)===X.NUM?(this.state=ne.NumericStart,this.consumed+=1,this.stateNumericStart(t,r+1)):(this.state=ne.NamedEntity,this.stateNamedEntity(t,r));case ne.NumericStart:return this.stateNumericStart(t,r);case ne.NumericDecimal:return this.stateNumericDecimal(t,r);case ne.NumericHex:return this.stateNumericHex(t,r);case ne.NamedEntity:return this.stateNamedEntity(t,r)}}stateNumericStart(t,r){return r>=t.length?-1:(t.charCodeAt(r)|Gn)===X.LOWER_X?(this.state=ne.NumericHex,this.consumed+=1,this.stateNumericHex(t,r+1)):(this.state=ne.NumericDecimal,this.stateNumericDecimal(t,r))}stateNumericHex(t,r){for(;r>14;for(;r>7;if(this.runConsumed===0){const c=i&le.JUMP_TABLE;if(t.charCodeAt(r)!==c)return this.result===0?0:this.emitNotTerminatedNamedEntity();r++,this.excess++,this.runConsumed++}for(;this.runConsumed=t.length)return-1;const c=this.runConsumed-1,u=n[this.treeIndex+1+(c>>1)],h=c%2===0?u&255:u>>8&255;if(t.charCodeAt(r)!==h)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();r++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(o>>1),i=n[this.treeIndex],s=(i&le.VALUE_LENGTH)>>14}if(r>=t.length)break;const a=t.charCodeAt(r);if(a===X.SEMI&&s!==0&&(i&le.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);if(this.treeIndex=Qc(n,i,this.treeIndex+Math.max(1,s),a),this.treeIndex<0)return this.result===0||this.decodeMode===$e.Attribute&&(s===0||Vc(a))?0:this.emitNotTerminatedNamedEntity();if(i=n[this.treeIndex],s=(i&le.VALUE_LENGTH)>>14,s!==0){if(a===X.SEMI)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);this.decodeMode!==$e.Strict&&(i&le.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}r++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var t;const{result:r,decodeTree:n}=this,i=(n[r]&le.VALUE_LENGTH)>>14;return this.emitNamedEntityData(r,i,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,r,n){const{decodeTree:i}=this;return this.emitCodePoint(r===1?i[t]&~(le.VALUE_LENGTH|le.FLAG13):i[t+1],n),r===3&&this.emitCodePoint(i[t+2],n),n}end(){var t;switch(this.state){case ne.NamedEntity:return this.result!==0&&(this.decodeMode!==$e.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case ne.NumericDecimal:return this.emitNumericEntity(0,2);case ne.NumericHex:return this.emitNumericEntity(0,3);case ne.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case ne.EntityStart:return 0}}}function Qc(e,t,r,n){const i=(t&le.BRANCH_LENGTH)>>7,s=t&le.JUMP_TABLE;if(i===0)return s!==0&&n===s?r:-1;if(s){const u=n-s;return u<0||u>=i?-1:e[r+u]-1}const a=i+1>>1;let o=0,c=i-1;for(;o<=c;){const u=o+c>>>1,h=u>>1,f=e[r+h]>>(u&1)*8&255;if(fn)c=u-1;else return e[r+a+u]}return-1}var E;(function(e){e[e.Tab=9]="Tab",e[e.NewLine=10]="NewLine",e[e.FormFeed=12]="FormFeed",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.ExclamationMark=33]="ExclamationMark",e[e.Number=35]="Number",e[e.Amp=38]="Amp",e[e.SingleQuote=39]="SingleQuote",e[e.DoubleQuote=34]="DoubleQuote",e[e.Dash=45]="Dash",e[e.Slash=47]="Slash",e[e.Zero=48]="Zero",e[e.Nine=57]="Nine",e[e.Semi=59]="Semi",e[e.Lt=60]="Lt",e[e.Eq=61]="Eq",e[e.Gt=62]="Gt",e[e.Questionmark=63]="Questionmark",e[e.UpperA=65]="UpperA",e[e.LowerA=97]="LowerA",e[e.UpperF=70]="UpperF",e[e.LowerF=102]="LowerF",e[e.UpperZ=90]="UpperZ",e[e.LowerZ=122]="LowerZ",e[e.LowerX=120]="LowerX",e[e.OpeningSquareBracket=91]="OpeningSquareBracket"})(E||(E={}));var m;(function(e){e[e.Text=1]="Text",e[e.BeforeTagName=2]="BeforeTagName",e[e.InTagName=3]="InTagName",e[e.InSelfClosingTag=4]="InSelfClosingTag",e[e.BeforeClosingTagName=5]="BeforeClosingTagName",e[e.InClosingTagName=6]="InClosingTagName",e[e.AfterClosingTagName=7]="AfterClosingTagName",e[e.BeforeAttributeName=8]="BeforeAttributeName",e[e.InAttributeName=9]="InAttributeName",e[e.AfterAttributeName=10]="AfterAttributeName",e[e.BeforeAttributeValue=11]="BeforeAttributeValue",e[e.InAttributeValueDq=12]="InAttributeValueDq",e[e.InAttributeValueSq=13]="InAttributeValueSq",e[e.InAttributeValueNq=14]="InAttributeValueNq",e[e.BeforeDeclaration=15]="BeforeDeclaration",e[e.InDeclaration=16]="InDeclaration",e[e.InProcessingInstruction=17]="InProcessingInstruction",e[e.BeforeComment=18]="BeforeComment",e[e.CDATASequence=19]="CDATASequence",e[e.InSpecialComment=20]="InSpecialComment",e[e.InCommentLike=21]="InCommentLike",e[e.BeforeSpecialS=22]="BeforeSpecialS",e[e.BeforeSpecialT=23]="BeforeSpecialT",e[e.SpecialStartSequence=24]="SpecialStartSequence",e[e.InSpecialTag=25]="InSpecialTag",e[e.InEntity=26]="InEntity"})(m||(m={}));function Se(e){return e===E.Space||e===E.NewLine||e===E.Tab||e===E.FormFeed||e===E.CarriageReturn}function Pt(e){return e===E.Slash||e===E.Gt||Se(e)}function Xc(e){return e>=E.LowerA&&e<=E.LowerZ||e>=E.UpperA&&e<=E.UpperZ}var ve;(function(e){e[e.NoValue=0]="NoValue",e[e.Unquoted=1]="Unquoted",e[e.Single=2]="Single",e[e.Double=3]="Double"})(ve||(ve={}));const te={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97]),XmpEnd:new Uint8Array([60,47,120,109,112])};class zc{constructor({xmlMode:t=!1,decodeEntities:r=!0},n){this.cbs=n,this.state=m.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=m.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=t,this.decodeEntities=r,this.entityDecoder=new Kc(t?Nc:Lc,(i,s)=>this.emitCodePoint(i,s))}reset(){this.state=m.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=m.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(t){this.offset+=this.buffer.length,this.buffer=t,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.indexthis.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=m.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&t===E.Amp&&this.startEntity()}stateSpecialStartSequence(t){const r=this.sequenceIndex===this.currentSequence.length;if(!(r?Pt(t):(t|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!r){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=m.InTagName,this.stateInTagName(t)}stateInSpecialTag(t){if(this.sequenceIndex===this.currentSequence.length){if(t===E.Gt||Se(t)){const r=this.index-this.currentSequence.length;if(this.sectionStart=0)this.state=this.baseState,r===0&&(this.index-=1);else{if(t=t||(this.state===m.InCommentLike?this.currentSequence===te.CdataEnd?this.cbs.oncdata(this.sectionStart,t,0):this.cbs.oncomment(this.sectionStart,t,0):this.state===m.InTagName||this.state===m.BeforeAttributeName||this.state===m.BeforeAttributeValue||this.state===m.AfterAttributeName||this.state===m.InAttributeName||this.state===m.InAttributeValueSq||this.state===m.InAttributeValueDq||this.state===m.InAttributeValueNq||this.state===m.InClosingTagName||this.cbs.ontext(this.sectionStart,t))}emitCodePoint(t,r){this.baseState!==m.Text&&this.baseState!==m.InSpecialTag?(this.sectionStart0&&a.has(this.stack[0]);){const o=this.stack.shift();(n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,o,!0)}this.isVoidElement(t)||(this.stack.unshift(t),this.htmlMode&&(Nn.has(t)?this.foreignContext.unshift(!0):Yn.has(t)&&this.foreignContext.unshift(!1))),(s=(i=this.cbs).onopentagname)===null||s===void 0||s.call(i,t),this.cbs.onopentag&&(this.attribs={})}endOpenTag(t){var r,n;this.startIndex=this.openTagStart,this.attribs&&((n=(r=this.cbs).onopentag)===null||n===void 0||n.call(r,this.tagname,this.attribs,t),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(t){this.endIndex=t,this.endOpenTag(!1),this.startIndex=t+1}onclosetag(t,r){var n,i,s,a,o,c,u,h;this.endIndex=r;let l=this.getSlice(t,r);if(this.lowerCaseTagNames&&(l=l.toLowerCase()),this.htmlMode&&(Nn.has(l)||Yn.has(l))&&this.foreignContext.shift(),this.isVoidElement(l))this.htmlMode&&l==="br"&&((a=(s=this.cbs).onopentagname)===null||a===void 0||a.call(s,"br"),(c=(o=this.cbs).onopentag)===null||c===void 0||c.call(o,"br",{},!0),(h=(u=this.cbs).onclosetag)===null||h===void 0||h.call(u,"br",!1));else{const f=this.stack.indexOf(l);if(f!==-1)for(let A=0;A<=f;A++){const d=this.stack.shift();(i=(n=this.cbs).onclosetag)===null||i===void 0||i.call(n,d,A!==f)}else this.htmlMode&&l==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=r+1}onselfclosingtag(t){this.endIndex=t,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=t+1):this.onopentagend(t)}closeCurrentTag(t){var r,n;const i=this.tagname;this.endOpenTag(t),this.stack[0]===i&&((n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,i,!t),this.stack.shift())}onattribname(t,r){this.startIndex=t;const n=this.getSlice(t,r);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(t,r){this.attribvalue+=this.getSlice(t,r)}onattribentity(t){this.attribvalue+=Un(t)}onattribend(t,r){var n,i;this.endIndex=r,(i=(n=this.cbs).onattribute)===null||i===void 0||i.call(n,this.attribname,this.attribvalue,t===ve.Double?'"':t===ve.Single?"'":t===ve.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(t){const r=t.search(Zc);let n=r<0?t:t.substr(0,r);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(t,r){this.endIndex=r;const n=this.getSlice(t,r);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${i}`,`!${n}`)}this.startIndex=r+1}onprocessinginstruction(t,r){this.endIndex=r;const n=this.getSlice(t,r);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${i}`,`?${n}`)}this.startIndex=r+1}oncomment(t,r,n){var i,s,a,o;this.endIndex=r,(s=(i=this.cbs).oncomment)===null||s===void 0||s.call(i,this.getSlice(t,r-n)),(o=(a=this.cbs).oncommentend)===null||o===void 0||o.call(a),this.startIndex=r+1}oncdata(t,r,n){var i,s,a,o,c,u,h,l,f,A;this.endIndex=r;const d=this.getSlice(t,r-n);!this.htmlMode||this.options.recognizeCDATA?((s=(i=this.cbs).oncdatastart)===null||s===void 0||s.call(i),(o=(a=this.cbs).ontext)===null||o===void 0||o.call(a,d),(u=(c=this.cbs).oncdataend)===null||u===void 0||u.call(c)):((l=(h=this.cbs).oncomment)===null||l===void 0||l.call(h,`[CDATA[${d}]]`),(A=(f=this.cbs).oncommentend)===null||A===void 0||A.call(f)),this.startIndex=r+1}onend(){var t,r;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let n=0;n=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(t-this.bufferOffset,r-this.bufferOffset);for(;r-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,r-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(t){var r,n;if(this.ended){(n=(r=this.cbs).onerror)===null||n===void 0||n.call(r,new Error(".write() after done!"));return}this.buffers.push(t),this.tokenizer.running&&(this.tokenizer.write(t),this.writeIndex++)}end(t){var r,n;if(this.ended){(n=(r=this.cbs).onerror)===null||n===void 0||n.call(r,new Error(".end() after done!"));return}t&&this.write(t),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(t){this.children=t}}class rs extends mn{constructor(){super(...arguments),this.type=G.CDATA}get nodeType(){return 4}}class Nr extends mn{constructor(){super(...arguments),this.type=G.Root}get nodeType(){return 9}}class ns extends mn{constructor(t,r,n=[],i=t==="script"?G.Script:t==="style"?G.Style:G.Tag){super(n),this.name=t,this.attribs=r,this.type=i}get nodeType(){return 1}get tagName(){return this.name}set tagName(t){this.name=t}get attributes(){return Object.keys(this.attribs).map(t=>{var r,n;return{name:t,value:this.attribs[t],namespace:(r=this["x-attribsNamespace"])===null||r===void 0?void 0:r[t],prefix:(n=this["x-attribsPrefix"])===null||n===void 0?void 0:n[t]}})}}function el(e){return jc(e)}function tl(e){return e.type===G.CDATA}function rl(e){return e.type===G.Text}function nl(e){return e.type===G.Comment}function il(e){return e.type===G.Directive}function sl(e){return e.type===G.Root}function is(e,t=!1){let r;if(rl(e))r=new Lr(e.data);else if(nl(e))r=new es(e.data);else if(el(e)){const n=t?Cr(e.children):[],i=new ns(e.name,{...e.attribs},n);n.forEach(s=>s.parent=i),e.namespace!=null&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]={...e["x-attribsNamespace"]}),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]={...e["x-attribsPrefix"]}),r=i}else if(tl(e)){const n=t?Cr(e.children):[],i=new rs(n);n.forEach(s=>s.parent=i),r=i}else if(sl(e)){const n=t?Cr(e.children):[],i=new Nr(n);n.forEach(s=>s.parent=i),e["x-mode"]&&(i["x-mode"]=e["x-mode"]),r=i}else if(il(e)){const n=new ts(e.name,e.data);e["x-name"]!=null&&(n["x-name"]=e["x-name"],n["x-publicId"]=e["x-publicId"],n["x-systemId"]=e["x-systemId"]),r=n}else throw new Error(`Not implemented yet: ${e.type}`);return r.startIndex=e.startIndex,r.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(r.sourceCodeLocation=e.sourceCodeLocation),r}function Cr(e){const t=e.map(r=>is(r,!0));for(let r=1;r{let t="";return e.italic&&(t="italic "),e.bold&&(t+="bold "),`${t}${e.size}px '${e.font}',sans-serif`},Yr=(e,t)=>{dt(0);const r=e.lineTable.length;De.font=ss(t);const n=De.measureText(""),i={mode:"break",text:"",x:0,y:0,w:0,h:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent,line:r,textFormat:t.toObject()};e.heightTable[r]=0,e.ascentTable[r]=0,e.widthTable[r]=0,e.lineTable.push(i),e.textTable.push(i)},cl=e=>{const t=e.heightTable.length-1;for(let r=1;r0)continue;const i=e.lineTable[r];i&&(e.heightTable[r]=i.h=e.heightTable[r-1])}},as=e=>{let t=0;return e.leftMargin&&(t+=e.leftMargin),e.rightMargin&&(t+=e.rightMargin),t},ll=(e,t,r,n)=>{let i=r.lineTable.length-1;const s=n.width-as(t)-4;for(let a=0;as){dt(l),i++,u.line=i;const A={mode:"wrap",text:"",x:0,y:0,w:0,h:0,line:i,textFormat:o.toObject()};let d=1,y=!0;const g=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;;){const p=r.textTable.length-d;if(0>=p){y=!1,d=0;break}const $=r.textTable[p];if(!$){y=!1,d=0;break}if($.mode!=="text"){y=!1;break}if($.text===" "){d--;break}if(!$.text.match(g)){d--;break}d++}if(r.widthTable[i]=0,r.heightTable[i]=0,r.ascentTable[i]=0,d>0&&y){const p=r.textTable.length-d;r.textTable.splice(p,0,A),r.lineTable.push(A);const $=i-1;r.widthTable[$]=0,r.heightTable[$]=0,r.ascentTable[$]=0;for(let w=0;w{const t=e.trim().split(";"),r=[];for(let n=0;n{for(let n=0;nt.size&&(t.size=1));break;case"color":t.color=et(i.value);break;case"letterSpacing":t.letterSpacing=parseInt(i.value);break;case"leading":t.leading=parseInt(i.value);break;case"leftMargin":t.leftMargin=parseInt(i.value);break;case"rightMargin":t.rightMargin=parseInt(i.value);break;case"underline":t.underline=!0;break;case"bold":t.bold=!0;break;case"italic":t.italic=!0;break}}},Vr=(e,t,r,n)=>{for(let i=0;i{const n=new Gc;if(!e)return n;const i=e.trim().replace(/\r?\n/g,"").replace(/\t/g,""),s=t.clone();return r.subFontSize&&r.subFontSize>0&&s.size&&(s.size-=r.subFontSize,1>s.size&&(s.size=1)),Yr(n,s),Vr(ol(i),s,n,r),cl(n),n},H=(e,t=0)=>(e.$textData||(e.$textData=hl(e.htmlText,e.defaultTextFormat,{width:e.width,multiline:e.multiline,wordWrap:e.wordWrap,subFontSize:t,textFormats:e.$textFormats})),e.$textData),K=e=>{e.changed=!0;const t=e.parent;t&&!t.changed&&K(t)},Kr=e=>{e.$textData=null,K(e),e.uniqueKey!==""&&O.has(e.uniqueKey)&&(O.removeById(e.uniqueKey),O.$removeIds.push(+e.uniqueKey))},fl=e=>{if(K(e),e.autoSize==="none"){e.xMin=e.bounds.xMin,e.yMin=e.bounds.yMin,e.xMax=e.bounds.xMax,e.yMax=e.bounds.yMax;return}const t=e.defaultTextFormat,r=e.textWidth+4+as(t);if(e.wordWrap)e.xMin=e.bounds.xMin,e.xMax=e.bounds.xMax;else switch(e.autoSize){case"left":e.xMax=r+e.xMin;break;case"center":e.xMax=r+e.xMin;break;case"right":e.xMax=e.bounds.xMax-(e.bounds.xMax-e.bounds.xMin-(r-e.bounds.xMin));break}e.yMax=e.textHeight+e.bounds.yMin+4},dl=e=>{let t=0;const r=H(e);for(let i=0;in&&e.textWidth+4>e.width;)Kr(e),H(e,n++);if(e.height&&e.textHeight)for(;t>n&&e.textHeight+4>e.height;)Kr(e),H(e,n++);K(e)},Be=e=>{Kr(e),H(e),e.autoSize==="none"&&e.autoFontSize&&dl(e),fl(e)},Al=(e,t)=>{const r=H(e);if(2>r.textTable.length)return;let n=2,i=0;for(let f=1;f=t){i=f;break}A.mode==="break"&&(d=!0,n=2),d&&i++}const s=r.textTable[i];if(!s)return;e.$scrollX=e.$scrollY=0;const a=s.line;let o=0;for(let f=0;f<=a;++f)o+=r.heightTable[f];const c=Math.abs(e.yMax-e.yMin);let u=0;for(let f=a;f>-1;--f){const A=r.heightTable[f];if(cc){const f=(e.textHeight-c)/c;e.$scrollY=Math.max(0,Math.min((o-u)/f,c))}const h=Math.abs(e.xMax-e.xMin);let l=0;for(let f=i;f>0;--f){const A=r.textTable[f];if(A.mode==="text"){if(hh){const f=(e.textWidth-h)/h;e.$scrollX=Math.max(0,Math.min((n-l)/f,h+.5))}K(e)},fe=()=>{const e=Ht();e!==void 0&&clearTimeout(e),Zi(void 0)},pl=window.devicePixelRatio,ml=e=>{const t=e.localToGlobal(new se),r=e.$textData;if(r){const i=r.textTable[e.focusIndex];if(i){for(let a=e.focusIndex-1;a>-1;--a){const o=r.textTable[a];if(!o||o.line!==i.line)break;t.x+=o.w}const s=i.mode==="break"?i.line-1:i.line;for(let a=0;a{e.focusVisible=!e.focusVisible,K(e),Zi(setTimeout(()=>pe(e),500)),ml(e)},gl=(e,t)=>{e.willTrigger(t)&&e.dispatchEvent(new Ne(t)),de.value="",e.focus?(setTimeout(()=>{de.focus()},300),Ht()===void 0&&(e.focusIndex===-1&&(e.focusIndex=1,e.selectIndex=-1),pe(e))):(e.focusIndex=-1,e.selectIndex=-1,e.focusVisible=!1,fe(),de.blur()),K(e)},bl=(e,t,r,n)=>e/n*r+t,xl=(e,t,r,n)=>(e/=n)*e*r+t,yl=(e,t,r,n)=>-(e/=n)*(e-2)*r+t,$l=(e,t,r,n)=>(e/=n/2)<1?e*e*r/2+t:-((e-=1)*(e-2)-1)*r/2+t,vl=(e,t,r,n)=>(e/=n)*e*e*r+t,wl=(e,t,r,n)=>(e/=n,(--e*e*e+1)*r+t),Ml=(e,t,r,n)=>(e/=n/2)<1?e*e*e*r/2+t:((e-=2)*e*e+2)*r/2+t,Bl=(e,t,r,n)=>(e/=n)*e*e*e*r+t,Tl=(e,t,r,n)=>(e/=n,(--e*e*e*e-1)*-r+t),Sl=(e,t,r,n)=>(e/=n/2)<1?e*e*e*e*r/2+t:((e-=2)*e*e*e-2)*-r/2+t,Il=(e,t,r,n)=>(e/=n)*e*e*e*e*r+t,Cl=(e,t,r,n)=>(e/=n,(--e*e*e*e*e+1)*r+t),Fl=(e,t,r,n)=>(e/=n/2)<1?e*e*e*e*e*r/2+t:((e-=2)*e*e*e*e+2)*r/2+t,El=(e,t,r,n)=>-r*Math.cos(e/n*(Math.PI/2))+r+t,Pl=(e,t,r,n)=>r*Math.sin(e/n*(Math.PI/2))+t,Rl=(e,t,r,n)=>-r/2*(Math.cos(Math.PI*e/n)-1)+t,Ol=(e,t,r,n)=>r*Math.pow(2,10*(e/n-1))+t,kl=(e,t,r,n)=>r*(-Math.pow(2,-10*e/n)+1)+t,Ul=(e,t,r,n)=>(e/=n/2)<1?r/2*Math.pow(2,10*(e-1))+t:r/2*(-Math.pow(2,-10*(e-1))+2)+t,Gl=(e,t,r,n)=>(1-Math.sqrt(1-(e/=n)*e))*r+t,_l=(e,t,r,n)=>(e/=n,Math.sqrt(1- --e*e)*r+t),Dl=(e,t,r,n)=>(e/=n*2)<1?(Math.sqrt(1-e*e)-1)/-2*r+t:(Math.sqrt(1-(e-=2)*e)+1)/2*r+t,Ll=(e,t,r,n)=>(2.70158*(e/=n)*e*e-1.70158*e*e)*r+t,Nl=(e,t,r,n)=>(1+2.70158*Math.pow((e/=n)-1,3)+1.70158*Math.pow(e-1,2))*r+t,Yl=(e,t,r,n)=>{let i=1.70158;return(e/=n/2)<1?e*e*(((i*=1.525)+1)*e-i)*r/2+t:((e-=2)*e*(((i*=1.525)+1)*e+i)+2)*r/2+t},Wl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:-Math.pow(2,(e*=10)-10)*Math.sin((e-10.75)*(2*Math.PI/3))*r+t,Vl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:(Math.pow(2,-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1)*r+t,Kl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:e<.5?-(Math.pow(2,20*e-10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5)))/2*r+t:(Math.pow(2,-20*e+10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5))/2+1)*r+t,Ql=(e,t,r,n)=>(e/=n)<1/2.75?7.5625*e*e*r+t:e<2/2.75?(7.5625*(e-=1.5/2.75)*e+.75)*r+t:e<2.5/2.75?(7.5625*(e-=2.25/2.75)*e+.9375)*r+t:(7.5625*(e-=2.625/2.75)*e+.984375)*r+t,Xl=(e,t,r,n)=>r-Ye.outBounce(n-e,0,r,n)+t,zl=(e,t,r,n)=>e{cancelAnimationFrame(e.$timerId),e.hasEventListener(ye.STOP)&&e.dispatchEvent(new ye(ye.STOP)),e.entries=null,e.stopFlag=!0},os=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({name:r,value:typeof n=="number"?n:os(n)});return t},cs=(e,t,r,n,i)=>{for(let s=0;se.currentTime?t[o]=e.ease(e.currentTime,c,n[o]-c,e.duration):t[o]=n[o]}},ls=(e,t)=>e.stopFlag||!e.entries?-1:(e.currentTime=(t-e.startTime)/1e3,cs(e,e.target,e.from,e.to,e.entries),e.hasEventListener(ye.UPDATE)&&e.dispatchEvent(new ye(ye.UPDATE)),e.currentTime>=e.duration?(e.hasEventListener(ye.COMPLETE)&&e.dispatchEvent(new ye(ye.COMPLETE)),e.nextJob&&e.nextJob.start(),-1):requestAnimationFrame(r=>{ls(e,r)})),Vn=e=>{e.stopFlag||(e.entries=os(e.from),e.entries&&(e.startTime=performance.now(),e.$timerId=ls(e,e.startTime)))},Jl=e=>{cancelAnimationFrame(e.$timerId),e.stopFlag=!1,e.delay?setTimeout(()=>{Vn(e)},e.delay*1e3):Vn(e)};class Zl extends nt{target;entries;startTime;stopFlag;$timerId;delay;duration;ease;from;to;currentTime;nextJob;constructor(t,r,n,i=0,s=1,a=null){super(),this.target=t,this.from=r,this.to=n,this.delay=i,this.duration=s,this.ease=a||Ye.linear,this.currentTime=0,this.nextJob=null,this.entries=null,this.startTime=0,this.stopFlag=!1,this.$timerId=-1}chain(t){return this.nextJob=t,t}start(){Jl(this)}stop(){Hl(this)}}class gn{static add(t,r,n,i=0,s=1,a=null){return new Zl(t,r,n,i,s,a)}}const ql=(e,t)=>{if(!e.scrollEnabled||e.autoSize!=="none"||e.yScrollShape.hasLocalVariable("job"))return;const r=e.width;if(t=pt(t,0,r,0),e.scrollX!==t){if(e.textWidth>r){K(e);const n=e.xScrollShape;n.width=r*r/e.textWidth;const i=e.parent;if(i){n.hasLocalVariable("job")&&n.getLocalVariable("job").stop(),n.alpha=.9,n.x=e.x+1+(r-1-n.width)/(r-1)*(t-1),n.y=e.y+e.height-n.height-.5,i.addChildAt(n,i.getChildIndex(e)+1);const s=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);s.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),s.start(),n.setLocalVariable("job",s)}e.$scrollX=t}e.willTrigger(x.SCROLL)&&e.dispatchEvent(new x(x.SCROLL,!0))}},jl=(e,t)=>{if(!e.scrollEnabled||e.autoSize!=="none"||!e.multiline&&!e.wordWrap||e.xScrollShape.hasLocalVariable("job"))return;const r=e.height;if(t=pt(t,0,r,0),e.scrollY!==t){if(e.textHeight>r){K(e);const n=e.yScrollShape;n.height=r*r/e.textHeight;const i=e.parent;if(i){n.hasLocalVariable("job")&&n.getLocalVariable("job").stop(),n.alpha=.9,n.x=e.x+e.width-n.width-.5,n.y=e.y+.5+(r-1-n.height)/(r-1)*(t-1),i.addChildAt(n,i.getChildIndex(e)+1);const s=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);s.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),s.start(),n.setLocalVariable("job",s),e.$scrollY=t}}e.willTrigger(x.SCROLL)&&e.dispatchEvent(new x(x.SCROLL,!0))}},eu=e=>{let t="";const r=H(e);for(let n=1;n{let r="";const n=H(e);for(let i=1;it)break;s.line===t&&s.mode==="text"&&(r+=s.text)}}return r},ru=(e,t,r,n)=>{if(0>r||r>n)return;const i=e.text,s=r?i.slice(0,r):"";e.text=s+t+i.slice(n,i.length)},nu=async e=>{if(e.focusIndex===-1||e.selectIndex===-1)return;let t="";const r=Math.min(e.focusIndex,e.selectIndex),n=Math.max(e.focusIndex,e.selectIndex)+1,i=H(e);for(let s=r;s{const t=await navigator.clipboard.readText();t===""||e.focusIndex===-1||e.insertText(t)},bn=e=>{if(e.compositionStartIndex>-1)return;let t=0,r=0;if(e.selectIndex>-1)t=Math.min(e.focusIndex,e.selectIndex),r=Math.max(e.focusIndex,e.selectIndex)+1,e.focusIndex=t;else{if(2>e.focusIndex)return;e.focusIndex--}const n=H(e),i=n.textTable[e.focusIndex];i&&i.mode==="wrap"&&e.focusIndex--;const s=[];let a="";for(let o=1;oo))switch(c.mode){case"break":s.push(new ue(...Object.values(c.textFormat))),a+=` -`;break;case"text":s.push(new ue(...Object.values(c.textFormat))),a+=c.text;break;default:continue}}if(n.textTable.length===e.focusIndex&&(s.pop(),a=a.slice(0,-1)),e.selectIndex=-1,!a)e.text="",e.focusIndex=1;else{const o=e.textWidth,c=e.textHeight;if(e.$textFormats=s,e.text=a,e.scrollX>0){const u=e.textWidth,h=e.width;switch(!0){case h>u:e.$scrollX=0;break;case o!==u:e.$scrollX-=(o-u)/(u/h);break}}if(e.scrollY>0){const u=e.textHeight,h=e.height;switch(!0){case h>u:e.$scrollY=0;break;case c!==u:e.$scrollY-=(c-u)/(u/h);break}}e.$textFormats=null}},us=(e,t)=>{if(e.focusIndex===-1||e.compositionStartIndex>-1)return;e.selectIndex>-1&&bn(e);const r=H(e);if(2>r.textTable.length){e.focusIndex=2,e.appendText(t);return}const n=[];let i="";for(let s=1;s{if(e.selectIndex===-1)return;const t=H(e);if(2>t.textTable.length)return;const r=t.textTable[e.selectIndex];if(!r)return;const n=r.mode==="text"?r.line:r.line-1,i=e.height,s=(e.textHeight-i)/i;let a=-e.scrollY*s-2,o=0;for(let d=0;di));++d)o++;a=-e.scrollY*s-2;let c=0;for(let d=0;d0));++d)c++;c>=r.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=t.heightTable[r.line]/s),r.line>=o&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=t.heightTable[r.line]/s);const u=e.width,h=(e.textWidth-u)/u;let l=2,f=e.scrollX*h-2+u;for(let d=1;e.selectIndex>=d;++d){const y=t.textTable[d];if(!y||y.line>n)break;if(y.line===n&&(e.selectIndex!==d&&(l+=y.w),f-=y.w,!(f>0))){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX+=y.w/h;break}}e.scrollX*h-2>l&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth))},su=(e,t,r,n=!1)=>{if(e.type!=="input")return;const i=H(e);if(2>i.textTable.length){e.focusIndex=1,e.selectIndex=-1,Ht()===void 0&&pe(e);return}const s=e.width,a=e.height;let o=0;e.scrollX>0&&(o+=e.scrollX*(e.textWidth-s)/s);let c=0;e.scrollY>0&&(c+=e.scrollY*(e.textHeight-a)/a);const u=e.globalToLocal(new se(t,r)),h=u.x+o,l=u.y+c;let f=2,A=2,d=A+i.heightTable[0];for(let y=1;yf&&l>A&&d>l&&s>h){const p=y;n?e.selectIndex!==p&&(e.selectIndex=p,e.focusVisible&&(e.focusVisible=!1,fe()),Kn(e),K(e)):(e.focusIndex!==p||e.selectIndex>-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e));return}f=2,A+=i.heightTable[g.line-1],d=A+i.heightTable[g.line];break;case"text":if(h>f&&l>A&&d>l&&f+g.w>h){let p=y;if(n)e.focusIndex>p?e.focusIndex===p+1?f+g.w/2h&&(p=-1):f+g.w/2>h&&(p-=1),e.selectIndex!==p&&(e.selectIndex=p,e.selectIndex>-1&&(e.focusVisible=!1,fe()),Kn(e),K(e));else{if(f+g.w/2-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e))}return}if(y===i.textTable.length-1&&h>f&&l>A&&d>l&&s>h){const p=i.textTable.length;n?e.selectIndex!==p&&(e.selectIndex=p,e.focusVisible&&(e.focusVisible=!1,fe()),K(e)):(e.focusIndex!==p||e.selectIndex>-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e));return}f+=g.w;break}if(!n)e.focusIndex=i.textTable.length,e.selectIndex=-1,Ht()===void 0?pe(e):K(e);else{let p=0;for(let $=0;i.heightTable.length>$;++$)p+=i.heightTable[$];(l>p||2>l)&&(e.selectIndex=2>l?1:i.textTable.length,e.focusVisible&&(e.focusVisible=!1,fe()),K(e))}}}},au=(e,t)=>{if(e.focusIndex===-1)return;const r=H(e);if(2>r.textTable.length)return;const n=r.textTable[e.focusIndex];if(!n)return;const i=n.mode==="text"?n.line:n.line-1;if(i===r.lineTable.length-1){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex=r.textTable.length;const f=e.width,A=(e.textWidth-f)/f;let d=0;for(let y=1;e.focusIndex>=y;++y){const g=r.textTable[y];if(!g||g.line>i)break;g.line===i&&(d+=g.w)}e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=(d-f)/A,fe(),pe(e);return}const s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let f=0;fs));++f)c++;let u=2;for(let f=1;fi)break;A.line!==i||A.mode!=="text"||(u+=A.w)}}let h=2;const l=i+1;for(let f=1;fl){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,A.line>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[A.line]/a),e.focusVisible=!1,e.focusIndex=A.mode==="text"?f-1:f,e.scrollX&&hu)){if(t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===f-1&&(e.selectIndex=-1):e.selectIndex=-1,A.line>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[A.line]/a),e.scrollX){const d=e.width,y=(e.textWidth-d)/d;e.scrollX*y-2>h&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((h-2)/e.textWidth))}e.focusVisible=!1,e.focusIndex=f,fe(),pe(e);return}}}t?e.selectIndex===-1&&(e.selectIndex=e.focusIndex):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex=r.textTable.length,fe(),pe(e)},ou=(e,t)=>{if(e.focusIndex===-1)return;const r=H(e);if(2>r.textTable.length)return;const n=r.textTable.length===e.focusIndex?e.focusIndex-1:e.focusIndex,i=r.textTable[n];if(!i||!i.line){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.focusVisible=!1,e.focusIndex=1,e.scrollX=0,fe(),pe(e);return}const s=i.mode==="text"?i.line:i.line-1,a=e.height,o=(e.textHeight-a)/a;let c=0,u=-e.scrollY*o-2;for(let A=0;A0));++A)c++;let h=2;for(let A=1;As)break;d.line!==s||d.mode!=="text"||(h+=d.w)}}let l=2;const f=s-1;for(let A=1;Af){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,c>=d.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[d.line]/o),e.scrollX&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth)),e.focusVisible=!1,e.focusIndex=d.mode==="text"?A-1:A,fe(),pe(e);return}if(!(d.line!==f||d.mode!=="text")&&(l+=d.w,l>h)){t?e.selectIndex===-1?e.selectIndex=e.focusIndex-1:e.selectIndex===A+1&&(e.selectIndex=-1):e.selectIndex=-1,c>d.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[d.line]/o),e.focusVisible=!1,e.focusIndex=A,fe(),pe(e);return}}}},cu=(e,t)=>{if(!e.focusIndex)return;const r=H(e);if(r.textTable.length&&e.focusIndex<2){e.focusIndex=1;return}e.focusIndex--,t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1;const n=r.textTable[e.focusIndex];if(n){const i=n.mode==="text"?n.line:n.line-1,s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let h=0;h0));++h)c++;c>i&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[n.line]/a);const u=r.textTable[e.focusIndex+1];if(u){const h=u.mode==="text"?u.line:u.line-1;let l=2;for(let y=1;e.focusIndex>y;++y){const g=r.textTable[y];if(!g||g.line>i)break;g.line===i&&(l+=g.w)}const f=e.width,A=(e.textWidth-f)/f,d=e.scrollX*A-2;if(l>f&&u&&il){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth);return}}}e.focusVisible=!1,fe(),pe(e)},lu=(e,t)=>{const r=H(e);if(r.textTable.length===e.focusIndex)return;t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex++,fe(),pe(e);const n=r.textTable[e.focusIndex];if(n){const i=n.mode==="text"?n.line:n.line-1,s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let d=0;ds));++d)c++;i>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[i]/a);const u=r.textTable[e.focusIndex-1],h=u.mode==="text"?u.line:u.line-1;if(u&&i>h){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=0;return}const l=e.width,f=(e.textWidth-l)/l;let A=e.scrollX*f-2+l;for(let d=1;e.focusIndex>=d;++d){const y=r.textTable[d];if(!y||y.line>i)break;if(y.line===i&&(A-=y.w,!(A>0))){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX+=y.w/f;break}}}},uu=(e,t)=>{if(e.focusIndex!==-1)switch(t.key){case"Backspace":case"Delete":e.deleteText();break;case"Enter":e.insertText(` -`);break;case"ArrowLeft":cu(e,t.shiftKey);break;case"ArrowRight":lu(e,t.shiftKey);break;case"ArrowUp":ou(e,t.shiftKey);break;case"ArrowDown":au(e,t.shiftKey);break;case"a":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.selectAll());break;case"c":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.copy());break;case"v":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.paste());break}},hu=e=>{const t=H(e);2>t.textTable.length||(e.selectIndex=1,e.focusIndex=t.textTable.length,K(e))},fu=(e,t)=>{const r=e.defaultTextFormat;switch(r.font=t.font,r.size=t.size,r.align=t.align,r.color=t.color,r.leading=t.leading,r.letterSpacing=t.letterSpacing,r.leftMargin=t.leftMargin,r.rightMargin=t.rightMargin,t.fontType){case 1:r.bold=!0;break;case 2:r.italic=!0;break;case 3:r.bold=!0,r.italic=!0;break}switch(e.defaultTextFormat=r,e.type=t.inputType,e.multiline=t.multiline,e.wordWrap=t.wordWrap,e.border=t.border,e.scrollEnabled=t.scroll,e.thickness=t.thickness,e.thicknessColor=t.thicknessColor,t.autoSize){case 1:e.autoSize=t.align;break;case 2:e.autoFontSize=!0;break}e.xMin=e.bounds.xMin=t.bounds.xMin,e.xMax=e.bounds.xMax=t.bounds.xMax,e.yMin=e.bounds.yMin=t.bounds.yMin,e.yMax=e.bounds.yMax=t.bounds.yMax+4,e.text=t.text};class Qr extends fn{isText;$textData;_$isHTML;xMin;yMin;xMax;yMax;bounds;scrollEnabled;xScrollShape;yScrollShape;focusVisible;focusIndex;selectIndex;maxChars;restrict;type;compositionStartIndex;compositionEndIndex;$textFormats;$scrollX;$scrollY;cacheKey;cacheParams;_$background;_$backgroundColor;_$border;_$borderColor;_$htmlText;_$multiline;_$text;_$wordWrap;_$defaultTextFormat;_$rawHtmlText;_$autoSize;_$autoFontSize;_$focus;_$thickness;_$thicknessColor;_$stopIndex;constructor(){super(),this.isText=!0,this.$textData=null,this._$background=!1,this._$backgroundColor=16777215,this._$border=!1,this._$borderColor=0,this._$htmlText="",this._$multiline=!1,this._$text="",this._$wordWrap=!1,this.$scrollX=0,this.$scrollY=0,this.$textFormats=null,this.maxChars=0,this._$stopIndex=-1,this.compositionStartIndex=-1,this.compositionEndIndex=-1;const t=new ue;kc(t),this._$defaultTextFormat=t,this._$rawHtmlText="",this.xMin=0,this.yMin=0,this.xMax=100,this.yMax=100,this.bounds={xMin:0,xMax:this.xMax,yMin:0,yMax:this.yMax},this.restrict="",this._$isHTML=!1,this._$autoSize="none",this._$autoFontSize=!1,this.focusVisible=!1,this.focusIndex=-1,this.selectIndex=-1,this.scrollEnabled=!0,this.xScrollShape=new $t,this.xScrollShape.graphics.beginFill("#000",.3).drawRoundRect(0,0,3,3,3),this.xScrollShape.scale9Grid=new be(1.5,1.5,.1,.1),this.yScrollShape=new $t,this.yScrollShape.graphics.beginFill("#000",.3).drawRoundRect(0,0,3,3,3),this.yScrollShape.scale9Grid=new be(1.5,1.5,.1,.1),this.type="static",this._$focus=!1,this._$thickness=0,this._$thicknessColor=0,this.cacheKey=0,this.cacheParams=[0,0,0]}static get namespace(){return"next2d.display.TextField"}get namespace(){return"next2d.display.TextField"}get autoFontSize(){return this._$autoFontSize}set autoFontSize(t){t!==this._$autoFontSize&&(this._$autoFontSize=!!t,Be(this))}get autoSize(){return this._$autoSize}set autoSize(t){t!==this._$autoSize&&(this._$autoSize=t,Be(this))}get background(){return this._$background}set background(t){t!==this._$background&&(this._$background=!!t,K(this))}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){t=pt(et(t),0,16777215,16777215),t!==this._$backgroundColor&&(this._$backgroundColor=t,K(this))}get border(){return this._$border}set border(t){t!==this._$border&&(this._$border=!!t,K(this))}get borderColor(){return this._$borderColor}set borderColor(t){t=pt(et(t),0,16777215,0),t!==this._$borderColor&&(this._$borderColor=t,K(this))}get stopIndex(){return this._$stopIndex}set stopIndex(t){t|=0,this._$stopIndex!==t&&(this._$stopIndex=t,Al(this,t))}get defaultTextFormat(){return this._$defaultTextFormat.clone()}set defaultTextFormat(t){this._$rawHtmlText="",this._$isHTML?this._$text="":this._$htmlText="",this._$defaultTextFormat=t,Be(this)}get focus(){return this._$focus}set focus(t){this._$focus!==t&&this.type==="input"&&(this._$focus=!!t,gl(this,this._$focus?Ne.FOCUS_IN:Ne.FOCUS_OUT))}get htmlText(){if(this._$htmlText)return this._$htmlText;const t=Uc(this.defaultTextFormat);return this._$htmlText=`${this._$text.replace(/\n/g,"
")}
`,this._$htmlText}set htmlText(t){this._$htmlText!==t&&(this._$htmlText=`${t}`,this._$rawHtmlText="",this._$text="",this._$isHTML=!0,Be(this),this.hasEventListener(x.CHANGE)&&this.dispatchEvent(new x(x.CHANGE)))}get length(){return this.text.length}get multiline(){return this._$multiline}set multiline(t){t!==this._$multiline&&(this._$multiline=!!t,Be(this))}get numLines(){return H(this).lineTable.length}get scrollX(){return this.$scrollX}set scrollX(t){ql(this,t)}get scrollY(){return this.$scrollY}set scrollY(t){jl(this,t)}get text(){return this._$isHTML?(this._$rawHtmlText||(this._$rawHtmlText=eu(this)),this._$rawHtmlText):this._$text}set text(t){t=`${t}`,t===""&&(this.scrollX&&(this.scrollX=0),this.scrollY&&(this.scrollY=0)),t!==this._$text&&(this._$htmlText="",this._$rawHtmlText="",this._$isHTML=!1,this._$text=t,Be(this),this.hasEventListener(x.CHANGE)&&this.dispatchEvent(new x(x.CHANGE)))}get textHeight(){return H(this).textHeight}get textWidth(){return H(this).textWidth}get thickness(){return this._$thickness}set thickness(t){t|=0,t!==this._$thickness&&(this._$thickness=t,K(this))}get thicknessColor(){return this._$thicknessColor}set thicknessColor(t){t=pt(et(t),0,16777215,0),t!==this._$thicknessColor&&(this._$thicknessColor=t,K(this))}get wordWrap(){return this._$wordWrap}set wordWrap(t){this._$wordWrap!==t&&(this._$wordWrap=!!t,Be(this))}get width(){return super.width}set width(t){if(t=+t,!isNaN(t)&&0>t)return;const r=t+this.bounds.xMin;r!==this.bounds.xMax&&(this.bounds.xMax=r,Be(this))}get height(){return super.height}set height(t){if(t=+t,!isNaN(t)&&0>t)return;const r=t+this.bounds.yMin;r!==this.bounds.yMax&&(this.bounds.yMax=r,Be(this))}appendText(t){const r=this.text;this.text=r+`${t}`}insertText(t){us(this,t)}deleteText(){bn(this)}getLineText(t){return this._$text||this._$htmlText?tu(this,t|0):""}replaceText(t,r,n){ru(this,t,r|0,n|0)}selectAll(){hu(this)}copy(){nu(this)}paste(){iu(this)}setFocusIndex(t,r,n=!1){su(this,t,r,n)}keyDown(t){uu(this,t)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),fu(this,t)}}const du=e=>{e.compositionStartIndex=e.focusIndex},Au=()=>{const e=ke();e&&du(e)},pu=(e,t)=>{if(e.compositionEndIndex>-1){const o=e.compositionStartIndex;e.focusIndex=e.compositionStartIndex,e.selectIndex=e.compositionEndIndex-1,e.compositionStartIndex=-1,bn(e),e.compositionStartIndex=o,e.selectIndex=-1}let r=H(e);const n=[],i=t.length;let s="";if(2>r.textTable.length)s=t,e.focusIndex=1,e.compositionStartIndex=1;else{for(let o=1;oe.compositionStartIndex&&a++}}e.compositionEndIndex=e.focusIndex=a},mu=e=>{const t=ke();t&&pu(t,e.data)},gu=e=>{if(e.compositionEndIndex>-1){const t=H(e);for(let r=e.compositionStartIndex;r{const e=ke();e&&gu(e)},xu=e=>{if(!e.data)return;const t=ke();t&&(us(t,e.data),t.hasEventListener(x.INPUT)&&t.dispatchEvent(new x(x.INPUT)))},yu=e=>{e.addEventListener("compositionstart",Au),e.addEventListener("compositionupdate",mu),e.addEventListener("compositionend",bu),e.addEventListener("input",xu)};yu(de);const hs=[],$u=()=>hs,vu=e=>{hs.push(e)};let Le=null;const wu=()=>!!Le,Mu=()=>{Le||(Le=new AudioContext),Le.resume()},fs=()=>(Le||(Le=new AudioContext),Le),Bu=e=>{let t=null;switch(e.method.toUpperCase()){case"GET":if(e.data){const n=e.url.split("?");n[1]=n.length===1?e.data.toString():`${n[1]}&${e.data.toString()}`,e.url=n.join("?")}break;case"PUT":case"POST":e.data&&(t=e.data.toString());break}const r=new XMLHttpRequest;if(r.open(e.method,e.url,!0),r.responseType=e.format,r.withCredentials=e.withCredentials,e.event){const n=Object.keys(e.event);for(let i=0;i{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};let ds=1;const Tu=()=>ds,Su=e=>{ds=xn(e,0,1,1)},Iu=[],Jt=()=>Iu,Cu=[],fr=()=>Cu,Fu=e=>{Su(e);const t=Jt();for(let n=0;n{const e=Jt();for(let r=0;r{e.canLoop?e.play():(e.stop(),e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE)))},Ru=(e,t)=>{e.willTrigger(x.OPEN)&&e.dispatchEvent(new x(x.OPEN)),e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},Ou=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},yn=async e=>{if(e.byteLength)try{return await fs().decodeAudioData(e)}catch{const t=new Uint8Array(e);let r=0;for(;r>t.byteLength&&(r=t.indexOf(255,r),!(r===-1||(t[r+1]&224)===224));)++r;return await yn(t.subarray(r).buffer)}},ku=async(e,t)=>{const r=t.target;if(r)if(e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total)),199r.status){const n=await yn(r.response);n&&(e.audioBuffer=n,e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE)))}else e.willTrigger(Re.IO_ERROR)&&e.dispatchEvent(new Re(Re.IO_ERROR,!1,r.statusText))},Uu=async(e,t)=>{await new Promise(r=>{Bu({format:"arraybuffer",url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:n=>{Ru(e,n)},progress:n=>{Ou(e,n)},loadend:async n=>{await ku(e,n),r()}}})})},Gu=async(e,t)=>{if(!t.audioBuffer){const r=new Uint8Array(t.buffer),n=await yn(r.buffer);if(!n)return;t.audioBuffer=n}e.audioBuffer=t.audioBuffer};class dr extends nt{_$source;_$gainNode;_$stopFlag;_$currentCount;_$volume;audioBuffer;loopCount;constructor(){super(),this.loopCount=0,this.audioBuffer=null,this._$volume=1,this._$currentCount=0,this._$stopFlag=!0,this._$source=null,this._$gainNode=null}get volume(){return this._$volume}set volume(t){this._$volume=xn(Math.min(rt.volume,t),0,1,1),this._$gainNode&&(this._$gainNode.gain.value=this._$volume)}get canLoop(){return!this._$stopFlag&&this.loopCount>=this._$currentCount}clone(){const t=new dr;return t.volume=this._$volume,t.loopCount=this.loopCount,t.audioBuffer=this.audioBuffer,t}async load(t){await Uu(this,t)}play(t=0){if(!this._$stopFlag||!this.audioBuffer)return;this.stop();const r=fs();this._$gainNode=r.createGain(),this._$gainNode.connect(r.destination),this._$gainNode.gain.value=Math.min(rt.volume,this._$volume),this._$source=r.createBufferSource(),this._$source.addEventListener("ended",()=>{Pu(this)}),this._$source.buffer=this.audioBuffer,this._$source.connect(this._$gainNode),this._$source.start(t),this._$stopFlag=!1,this._$currentCount++,Jt().push(this)}stop(){if(this._$stopFlag)return;this._$stopFlag=!0,this._$currentCount=0,this._$source&&(this._$source.disconnect(),this._$source=null),this._$gainNode&&(this._$gainNode.gain.value=0,this._$gainNode.disconnect(),this._$gainNode=null);const t=Jt(),r=t.indexOf(this);r>-1&&t.splice(r,1)}async $build(t){await Gu(this,t)}}class _u{volume;loopCount;constructor(t=1,r=0){this.volume=t,this.loopCount=r}}const Du=()=>{const e=document.createElement("video");return e.autoplay=!1,e.crossOrigin="anonymous",e.setAttribute("playsinline",""),e},$n=e=>{e.changed=!0;const t=e.parent;t&&!t.changed&&$n(t)},Lu=async e=>{e.autoPlay&&(wu()||(e.muted=!0,vu(e)),await e.play()),e.loaded=!0,$n(e),e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE))},Nu=(e,t)=>{t.currentTime=0,t.duration=e.duration,t.videoWidth=e.videoWidth,t.videoHeight=e.videoHeight;const r=new OffscreenCanvas(t.videoWidth,t.videoHeight);t.$context=r.getContext("2d"),t.$offscreenCanvas=r},Yu=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},Wu=e=>{if(e.willTrigger(Ae.ENDED)&&e.dispatchEvent(new Ae(Ae.ENDED)),e.loop){e.currentTime=0;return}e.ended=!0,e.changed=!1,e.pause()},Vu=(e,t)=>{e.addEventListener("loadedmetadata",()=>{Nu(e,t)},{once:!0}),e.addEventListener("progress",r=>{Yu(t,r)}),e.addEventListener("canplaythrough",async()=>{await Lu(t),e.volume=t.volume},{once:!0}),e.addEventListener("ended",()=>{Wu(t)})},As=e=>{if(e.paused||!e.loaded)return 0;e.willTrigger(Ae.PLAY)&&e.dispatchEvent(new Ae(Ae.PLAY)),$n(e);const t=fr();return t.indexOf(e)===-1&&t.push(e),requestAnimationFrame(()=>{As(e)})},Ku=(e,t)=>{t.videoData||(t.videoData=new Uint8Array(t.buffer),t.buffer=null),e.loop=t.loop,e.autoPlay=t.autoPlay,e.videoWidth=t.bounds.xMax,e.videoHeight=t.bounds.yMax,e.volume=t.volume,e.src=URL.createObjectURL(new Blob([t.videoData.buffer],{type:"video/mp4"}))};class Xr extends hr{duration;smoothing;loop;autoPlay;currentTime;videoWidth;videoHeight;loaded;ended;isVideo;$videoElement;$offscreenCanvas;$context;paused;_$timerId;_$volume;_$src;constructor(t=0,r=0){super(),this.videoWidth=t,this.videoHeight=r,this.isVideo=!0,this.duration=0,this.smoothing=!0,this.loop=!1,this.loaded=!1,this.ended=!1,this.paused=!0,this.autoPlay=!0,this.currentTime=0,this._$src="",this._$timerId=-1,this._$volume=1,this.$videoElement=null,this.$offscreenCanvas=null,this.$context=null}static get namespace(){return"next2d.media.Video"}get namespace(){return"next2d.media.Video"}get src(){return this._$src}set src(t){this._$src!==t&&(this.loaded=!1,this.currentTime=0,this.$videoElement=null,this.$offscreenCanvas=null,this.$context=null,this.$videoElement=Du(),Vu(this.$videoElement,this),this._$src=this.$videoElement.src=t,this.$videoElement.load())}get muted(){return this.$videoElement?this.$videoElement.muted:!1}set muted(t){this.$videoElement&&(this.$videoElement.muted=t)}get volume(){return this._$volume}set volume(t){this._$volume=xn(Math.min(rt.volume,t),0,1,1),this.$videoElement&&(this.$videoElement.volume=this._$volume)}pause(){if(!this.$videoElement||this.paused)return;this.paused=!0,this.$videoElement.pause(),cancelAnimationFrame(this._$timerId),this.willTrigger(Ae.PAUSE)&&this.dispatchEvent(new Ae(Ae.PAUSE));const t=fr(),r=t.indexOf(this);r>-1&&t.splice(r,1)}async play(){!this.$videoElement||!this.paused||(this.paused=!1,this.ended=!1,this.$videoElement.volume=this._$volume,await this.$videoElement.play(),this._$timerId=As(this))}seek(t){this.$videoElement&&(this.currentTime=this.$videoElement.currentTime=Math.min(this.duration,t),this.willTrigger(Ae.SEEK)&&this.dispatchEvent(new Ae(Ae.SEEK)))}$sync(t,r=null){r&&super.$syncLoaderInfo(r),Ku(this,t)}}const At=(e,t,r,n,i=-1)=>{const s=n.loaderInfo;if(!s)throw new Error("the loaderInfo or data is null.");e.parent=n,we.set(e,n.root),Dt.set(e,s),e.dictionaryId=t,e.characterId=r.characterId,e.clipDepth=r.clipDepth,e.startFrame=r.startFrame,e.endFrame=r.endFrame,e.name=r.name||"",e.placeId=i},Qn=(e,t,r,n,i=-1)=>{switch(r.extends){case qt.namespace:{const s=new qt;return At(s,e,t,n,i),s.$sync(r),s}case $t.namespace:{const s=new $t;return At(s,e,t,n,i),s.$sync(r),s}case Qr.namespace:{const s=new Qr;return At(s,e,t,n,i),s.$sync(r),s}case Xr.namespace:{const s=new Xr;return At(s,e,t,n,i),s.$sync(r),s}default:throw new Error(`Character extends not found: ${r.extends}`)}},Rt=new Map,Qu=(e,t)=>{const r=e.loaderInfo;if(!r||!r.data)return t;const n=r.data.characters[e.characterId];if(!n)return t;const i=e.currentFrame,s=n.controller[i];if(!s)return t;const a=[],o=n.dictionary;if(!t.length){for(let c=0;ci){Rt.set(u.dictionaryId,u);continue}u.uniqueKey&&O.has(u.uniqueKey)&&O.removeTimer(u.uniqueKey),u.willTrigger(x.REMOVED)&&u.dispatchEvent(new x(x.REMOVED,!0)),u.willTrigger(x.REMOVED_FROM_STAGE)&&u.dispatchEvent(new x(x.REMOVED_FROM_STAGE,!0)),u.isVideo&&u.pause(),u.isContainerEnabled&&un(u)}t.length=0;for(let c=0;c{e.$labels||(e.$labels=new Map),e.$labels.set(t.frame,t)},zu=e=>{if(!e.$labels)return null;const t=e.currentFrame;return e.$labels.has(t)&&e.$labels.get(t)||null},Hu=e=>!e.$labels||!e.$labels.size?null:Array.from(e.$labels.values()),Ju=(e,t)=>{if(!e.$labels||!e.$labels.size)return 0;for(const[r,n]of e.$labels)if(n.name===t)return r;return 0},Zu=(e,t=null)=>{if(!t||!t.size)return;const r=e.currentFrame;if(!t.has(r))return;const n=t.get(r);n.willTrigger(x.FRAME_LABEL)&&n.dispatchEvent(new x(x.FRAME_LABEL))},qu=(e,t=null)=>{if(!t||!t.size)return;const r=e.currentFrame;t.has(r)&&kr.push(e)},Zt=e=>{e.$canAction&&(e.$canAction=!1,Zu(e,e.$labels),qu(e,e.$actions))},Ar=(e,t)=>{if(e.totalFrames===1)return;let r=+t;if(isNaN(r)&&(r=Ju(e,`${t}`)),1>r&&(r=1),e.currentFrame!==r){if(r>e.totalFrames){if(e.currentFrame===e.totalFrames)return;e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,e.currentFrame=e.totalFrames,Zt(e),j(e);return}e.currentFrame=r,e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,j(e),Zt(e)}},ju=(e,t)=>{e.play(),Ar(e,t)},eh=(e,t)=>{e.stop(),Ar(e,t),e.$wait=!1},th=e=>{e.totalFrames<=e.currentFrame||(e.stop(),Ar(e,e.currentFrame+1))},rh=e=>{2>e.currentFrame||(e.stop(),Ar(e,e.currentFrame-1))},nh=(e,t)=>{for(let r=0;r{for(let r=0;r{const n=e.loaderInfo;if(!n)return;const i=n.data;if(!i)return;const s=i.characters;for(let a=0;a{t.actions&&(e.$actions||(e.$actions=new Map),nh(e.$actions,t.actions)),t.sounds&&(e.$sounds||(e.$sounds=new Map),sh(e,e.$sounds,t.sounds)),t.labels&&(e.$labels||(e.$labels=new Map),ih(e.$labels,t.labels)),e.totalFrames=t.totalFrame||1};class qt extends An{$labels;$actions;$sounds;$canAction;$wait;totalFrames;currentFrame;_$stopFlag;$canSound;$hasTimelineHeadMoved;isTimelineEnabled;constructor(){super(),this.currentFrame=1,this.totalFrames=1,this.isTimelineEnabled=!0,this.$actions=null,this.$labels=null,this.$sounds=null,this.$canAction=!0,this.$wait=!1,this.$canSound=!0,this.$hasTimelineHeadMoved=!0,this._$stopFlag=!1}static get namespace(){return"next2d.display.MovieClip"}get namespace(){return"next2d.display.MovieClip"}get children(){return!this.$hasTimelineHeadMoved||this.characterId===-1?this._$children:(this.$hasTimelineHeadMoved=!1,Qu(this,this._$children))}get currentFrameLabel(){return zu(this)}get currentLabels(){return Hu(this)}get isPlaying(){return!this._$stopFlag}gotoAndPlay(t){ju(this,t)}gotoAndStop(t){eh(this,t)}nextFrame(){th(this)}play(){this._$stopFlag=!1,j(this)}prevFrame(){rh(this)}stop(){this._$stopFlag=!0}addFrameLabel(t){Xu(this,t)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),ah(this,t)}}const Xn=async(e,t)=>{const r=new Map;if(t.symbols.length)for(let a=0;a>1|(v&21845)<<1;b=(b&52428)>>2|(b&13107)<<2,b=(b&61680)>>4|(b&3855)<<4,O[v]=((b&65280)>>8|(b&255)<<8)>>1}for(var m=(function(r,e,n){for(var i=r.length,f=0,g=new k(e);f>p]=C}else for(h=new k(i),f=0;f>15-r[f]);return h}),A=new l(288),v=0;v<144;++v)A[v]=8;for(var v=144;v<256;++v)A[v]=9;for(var v=256;v<280;++v)A[v]=7;for(var v=280;v<288;++v)A[v]=8;for(var j=new l(32),v=0;v<32;++v)j[v]=5;var hr=m(A,9,1),br=m(j,5,1),B=function(r){for(var e=r[0],n=1;ne&&(e=r[n]);return e},c=function(r,e,n){var i=e/8|0;return(r[i]|r[i+1]<<8)>>(e&7)&n},J=function(r,e){var n=e/8|0;return(r[n]|r[n+1]<<8|r[n+2]<<16)>>(e&7)},sr=function(r){return(r+7)/8|0},yr=function(r,e,n){return(n==null||n>r.length)&&(n=r.length),new l(r.subarray(e,n))},zr=["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"],t=function(r,e,n){var i=new Error(e||zr[r]);if(i.code=r,Error.captureStackTrace&&Error.captureStackTrace(i,t),!n)throw i;return i},N=function(r,e,n,i){var f=r.length,g=0;if(!f||e.f&&!e.l)return n||new l(0);var s=!n,h=s||e.i!=2,p=e.i;s&&(n=new l(f*3));var C=function(vr){var or=n.length;if(vr>or){var lr=new l(Math.max(or*2,vr));lr.set(n),n=lr}},y=e.f||0,a=e.p||0,o=e.b||0,F=e.l,D=e.d,E=e.m,T=e.n,R=f*8;do{if(!F){y=c(r,a,1);var _=c(r,a+1,3);if(a+=3,_)if(_==1)F=hr,D=br,E=9,T=5;else if(_==2){var H=c(r,a,31)+257,L=c(r,a+10,15)+4,d=H+c(r,a+5,31)+1;a+=14;for(var M=new l(d),K=new l(19),u=0;u>4;if(w<16)M[u++]=w;else{var x=0,I=0;for(w==16?(I=3+c(r,a,3),a+=2,x=M[u-1]):w==17?(I=3+c(r,a,7),a+=3):w==18&&(I=11+c(r,a,127),a+=7);I--;)M[u++]=x}}var nr=M.subarray(0,H),z=M.subarray(H);E=B(nr),T=B(z),F=m(nr,E,1),D=m(z,T,1)}else t(1);else{var w=sr(a)+4,q=r[w-4]|r[w-3]<<8,G=w+q;if(G>f){p&&t(0);break}h&&C(o+q),n.set(r.subarray(w,G),o),e.b=o+=q,e.p=a=G*8,e.f=y;continue}if(a>R){p&&t(0);break}}h&&C(o+131072);for(var Dr=(1<>4;if(a+=x&15,a>R){p&&t(0);break}if(x||t(2),S<256)n[o++]=S;else if(S==256){P=a,F=null;break}else{var ar=S-254;if(S>264){var u=S-257,U=W[u];ar=c(r,a,(1<>4;Q||t(3),a+=Q&15;var z=gr[V];if(V>3){var U=X[V];z+=J(r,a)&(1<R){p&&t(0);break}h&&C(o+131072);var ir=o+ar;if(o>3&1)+(e>>4&1);i>0;i-=!r[n++]);return n+(e&2)},pr=function(r){var e=r.length;return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0},xr=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&t(6,"invalid zlib data"),(r[1]>>5&1)==1&&t(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Sr(r,e){return N(r,{i:2},e,e)}function mr(r,e){var n=kr(r);return n+8>r.length&&t(6,"invalid gzip data"),N(r.subarray(n,-8),{i:2},new l(pr(r)),e)}function Ar(r,e){return N(r.subarray(xr(r),-4),{i:2},e,e)}function Cr(r,e){return r[0]==31&&r[1]==139&&r[2]==8?mr(r,e):(r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31?Sr(r,e):Ar(r,e)}var Er=typeof TextDecoder<"u"&&new TextDecoder,Tr=0;try{Er.decode(Fr,{stream:!0}),Tr=1}catch{}self.addEventListener("message",r=>{const e=Cr(r.data);let n="";for(let i=0;i{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ps),{name:e?.name})}}const Hn=new oh,ms=async(e,t)=>{t.type==="zlib"?await new Promise(r=>{Hn.onmessage=i=>{Xn(e,i.data),r()};const n=new Uint8Array(t.buffer);Hn.postMessage(n,[n.buffer])}):Xn(e,t)},ch=(e,t)=>{e.willTrigger(x.OPEN)&&e.dispatchEvent(new x(x.OPEN)),e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},lh=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},uh=async(e,t)=>{const r=t.target;if(!r)return;const n=e.contentLoaderInfo;if(n.willTrigger(Z.PROGRESS)&&n.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total)),n.willTrigger(Gt.HTTP_STATUS)){const i=oo(r.getAllResponseHeaders());n.dispatchEvent(new Gt(Gt.HTTP_STATUS,!1,r.status,r.responseURL,i))}199r.status?(await ms(e,r.response),n.willTrigger(x.COMPLETE)&&n.dispatchEvent(new x(x.COMPLETE))):n.willTrigger(Re.IO_ERROR)&&n.dispatchEvent(new Re(Re.IO_ERROR,!1,r.statusText))},hh=async(e,t)=>{await new Promise(r=>{ao({format:t.responseDataFormat,url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:n=>{ch(e.contentLoaderInfo,n)},progress:n=>{lh(e.contentLoaderInfo,n)},loadend:async n=>{await uh(e,n),r()}}})})};class gs{contentLoaderInfo;root;constructor(){this.root=null,this.contentLoaderInfo=new Sc}get content(){return this.contentLoaderInfo.content}get loaderInfo(){return this.contentLoaderInfo}async load(t){if(t.responseDataFormat!=="json")throw new Error("The only format that can be loaded by this function is `json` format.");this.contentLoaderInfo.url=t.url,this.contentLoaderInfo.format=t.responseDataFormat,await hh(this,t)}async loadJSON(t){await ms(this,t)}}const bs=()=>{for(;kr.length;){const e=kr.pop(),t=e.$actions;if(!t)continue;const r=e.currentFrame;if(!t.has(r))continue;const n=t.get(r);if(n)for(let i=0;i{for(;Ur.length;){const e=Ur.pop(),t=e.$sounds;if(!t)continue;const r=e.currentFrame;if(!t.has(r))continue;const n=t.get(r),i=e.soundTransform;for(let s=0;s{if(!t||!t.size)return;const r=e.currentFrame;t.has(r)&&Ur.push(e)},ys=e=>{e.$canSound&&(e.$canSound=!1,fh(e,e.$sounds))},$s=e=>{const t=e.children;for(let r=t.length-1;r>-1;--r){const n=t[r];n&&n.isContainerEnabled&&($s(n),n.isTimelineEnabled&&(ys(n),Zt(n)))}},dh=e=>{$s(e),xs(),bs()},Ah=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e);class ph{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...t){this.buffer.length{const t=new Uint32Array(e.buffer,e.byteOffset,e.length),r=t.length;let n=2166136261,i=0;const s=r&-8;for(;i>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619)}for(;i>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619)}return n>>>8^n&255&16777215},pr=e=>{switch(e){case"copy":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"normal":return 11;case"overlay":return 12;case"screen":return 13;case"subtract":return 14;default:return 11}},vs=(e,t,r,n,i)=>{if(!e.visible){b.push(0);return}const s=e.graphics,a=s.isDrawable;if(!a&&!e.isBitmap){b.push(0);return}const o=Ve(e),c=o&&(o[0]!==1||o[1]!==1||o[2]!==1||o[3]!==1||o[4]!==0||o[5]!==0||o[6]!==0||o[7]!==0)?U.multiply(r,o):r;if(!me(c[3]+c[7]/255,0,1,0)){c!==r&&U.release(c),b.push(0);return}const h=_(e),l=h&&(h[0]!==1||h[1]!==0||h[2]!==0||h[3]!==1||h[4]!==0||h[5]!==0)?T.multiply(t,h):t,f=he(s.xMin,s.yMin,s.xMax,s.yMax,l),A=f[0],d=f[1],y=f[2],g=f[3];k(f);const p=Math.ceil(Math.abs(y-A)),$=Math.ceil(Math.abs(g-d));switch(!0){case p===0:case $===0:case p===-1/0:case $===-1/0:case p===1/0:case $===1/0:c!==r&&U.release(c),l!==t&&T.release(l),b.push(0);return}if(0>A+p||0>d+$||A>n||d>i){c!==r&&U.release(c),l!==t&&T.release(l),b.push(0);return}const w=h&&e.scale9Grid?Math.abs(h[1])<.001&&Math.abs(h[2])<1e-4:!1;if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const J=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(J))}`,oe(J)}else e.uniqueKey=e.isBitmap?`${mt(new Float32Array(e.$bitmapBuffer.buffer))}`:`${mt(s.buffer)}`;const I=Math.sqrt(l[0]*l[0]+l[1]*l[1]),P=Math.sqrt(l[2]*l[2]+l[3]*l[3]),W=Math.round(I*100)/100,C=Math.round(P*100)/100;(!e.isBitmap&&!e.cacheKey||e.cacheParams[0]!==W||e.cacheParams[1]!==C||e.cacheParams[2]!==c[7])&&(e.cacheKey=O.generateKeys(W,C,c[7]),e.cacheParams[0]=W,e.cacheParams[1]=C,e.cacheParams[2]=c[7]);const R=e.isBitmap?0:e.cacheKey;if(b.pushShapeBuffer(1,xi,l[0],l[1],l[2],l[3],l[4],l[5],c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],A,d,y,g,s.xMin,s.yMin,s.xMax,s.yMax,+w,+a,+e.isBitmap,+e.uniqueKey,R,I,P,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null),e.$cache?e.$cache.get(`${R}`):O.get(e.uniqueKey,`${R}`))e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);else{if(b.push(0),w){const Y=v.rendererScale,ee=je(Y,0,0,Y,0,0),Q=T.multiply(ee,h||xt);Ft(ee);const ce=e.parent.concatenatedMatrix.rawData,ae=je(ce[0],ce[1],ce[2],ce[3],ce[4]*Y-A,ce[5]*Y-d);T.release(ce);const Ke=T.multiply(ae,Q),Qe=Ke[4]-(l[4]-A),ks=Ke[5]-(l[5]-d);Ft(Ke);const st=he(s.xMin,s.yMin,s.xMax,s.yMax,Q),Bn=st[0],Tn=st[1],Us=st[2],Gs=st[3];k(st);const Tt=Math.ceil(Math.abs(Us-Bn)),St=Math.ceil(Math.abs(Gs-Tn)),xe=e.scale9Grid,br=Math.abs(s.xMax-s.xMin),xr=Math.abs(s.yMax-s.yMin),It=xe.width>0?(xe.x-s.xMin)/br:1e-5,Ct=xe.height>0?(xe.y-s.yMin)/xr:1e-5,yr=xe.width>0?(xe.x+xe.width-s.xMin)/br:.99999,$r=xe.height>0?(xe.y+xe.height-s.yMin)/xr:.99999,Sn=Math.ceil(br*Y),In=Math.ceil(xr*Y);let vr=Sn*It/Tt,wr=In*Ct/St,Mr=(Tt-Sn*(1-yr))/Tt,Br=(St-In*(1-$r))/St;if(vr>=Mr){const at=It/(It+(1-yr));vr=Math.max(at-1e-5,0),Mr=Math.min(at+1e-5,1)}if(wr>=Br){const at=Ct/(Ct+(1-$r));wr=Math.max(at-1e-5,0),Br=Math.min(at+1e-5,1)}b.push(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5],ae[0],ae[1],ae[2],ae[3],ae[4]-Qe,ae[5]-ks,Bn,Tn,Tt,St,It,Ct,vr,wr,yr,$r,Mr,Br),Ft(ae),Ft(Q)}const J=a||w?s.buffer:e.$bitmapBuffer;b.push(J.length),b.set(J),O.set(e.uniqueKey,`${R}`,!0),e.$cache&&(e.$cache=null)}b.push(pr(e.blendMode));const N=e.filters;if(N){let J=!1;const Y=[],ee=re(0,0,0,0);for(let ce=0;ce0;Q?(b.push(+Q,+J,ee[0],ee[1],ee[2],ee[3],Y.length),b.set(new Float32Array(Y))):b.push(0),k(ee)}else b.push(0);c!==r&&U.release(c),l!==t&&T.release(l)},zr=(e,t)=>{const r=_(e),n=r?T.multiply(t,r):t;n!==t&&T.release(n);const i=r&&e.scale9Grid?Math.abs(r[1])<.001&&Math.abs(r[2])<1e-4:!1,s=e.graphics.buffer;b.push(xi,n[0],n[1],n[2],n[3],n[4],n[5],+i,s.length),b.set(s)},mh=new TextEncoder,ws=(e,t,r,n,i)=>{if(!e.visible){b.push(0);return}const s=Ve(e),a=s&&(s[0]!==1||s[1]!==1||s[2]!==1||s[3]!==1||s[4]!==0||s[5]!==0||s[6]!==0||s[7]!==0)?U.multiply(r,s):r;if(!me(a[3]+a[7]/255,0,1,0)){a!==r&&U.release(a),b.push(0);return}const c=_(e),u=c&&(c[0]!==1||c[1]!==0||c[2]!==0||c[3]!==1||c[4]!==0||c[5]!==0)?T.multiply(t,c):t,h=he(e.xMin,e.yMin,e.xMax,e.yMax,u),l=h[0],f=h[1],A=h[2],d=h[3];k(h);const y=Math.ceil(Math.abs(A-l)),g=Math.ceil(Math.abs(d-f));switch(!0){case y===0:case g===0:case y===-1/0:case g===-1/0:case y===1/0:case g===1/0:a!==r&&U.release(a),u!==t&&T.release(u),b.push(0);return}if(0>l+y||0>f+g||l>n||f>i){a!==r&&U.release(a),u!==t&&T.release(u),b.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const C=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(C))}`,oe(C)}else e.uniqueKey=`${e.instanceId}`;const p=Math.sqrt(u[0]*u[0]+u[1]*u[1]),$=Math.sqrt(u[2]*u[2]+u[3]*u[3]),w=Math.round(p*100)/100,I=Math.round($*100)/100;(e.changed&&!e.cacheKey||e.cacheParams[0]!==w||e.cacheParams[1]!==I||e.cacheParams[2]!==a[7])&&(e.cacheKey=O.generateKeys(w,I,a[7]),e.cacheParams[0]=w,e.cacheParams[1]=I,e.cacheParams[2]=a[7]);const P=e.cacheKey;b.pushTextFieldBuffer(1,eo,u[0],u[1],u[2],u[3],u[4],u[5],a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l,f,A,d,e.xMin,e.yMin,e.xMax,e.yMax,+e.uniqueKey,P,+e.changed,p,$,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);const W=e.$cache?e.$cache.get(`${P}`):O.get(e.uniqueKey,`${P}`);if(!W||e.changed){b.push(0,+W);const C=mh.encode(JSON.stringify(e.$textData));switch(b.push(C.length),b.set(C),e.autoSize){case"center":b.push(0);break;case"left":b.push(1);break;case"none":b.push(2);break;case"right":b.push(3);break}b.push(e.stopIndex,e.scrollX,e.scrollY,e.textWidth,e.textHeight,Math.abs(e.xMax-e.xMin),Math.abs(e.yMax-e.yMin),e.focusIndex,e.selectIndex,+e.focusVisible,e.thickness,e.thicknessColor,+e.wordWrap,+e.border,e.borderColor,+e.background,e.backgroundColor,e.defaultTextFormat.color||0,e.defaultTextFormat.size||0),W||O.set(e.uniqueKey,`${P}`,!0),e.$cache&&(e.$cache=null)}else e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);if(b.push(pr(e.blendMode)),e.filters?.length){let C=!1;const R=[],L=re(0,0,0,0);for(let J=0;J0;N?(b.push(+N,+C,L[0],L[1],L[2],L[3],R.length),b.set(new Float32Array(R))):b.push(0),k(L)}else b.push(0);a!==r&&U.release(a),u!==t&&T.release(u)},Ms=(e,t,r,n,i,s)=>{if(!e.visible||!e.$videoElement||!e.$offscreenCanvas||!e.loaded){b.push(0);return}const a=Ve(e),o=a&&(a[0]!==1||a[1]!==1||a[2]!==1||a[3]!==1||a[4]!==0||a[5]!==0||a[6]!==0||a[7]!==0)?U.multiply(n,a):n;if(!me(o[3]+o[7]/255,0,1,0)){o!==n&&U.release(o),b.push(0);return}const u=_(e),h=u&&(u[0]!==1||u[1]!==0||u[2]!==0||u[3]!==1||u[4]!==0||u[5]!==0)?T.multiply(r,u):r,l=he(0,0,e.videoWidth,e.videoHeight,h),f=l[0],A=l[1],d=l[2],y=l[3];k(l);const g=Math.ceil(Math.abs(d-f)),p=Math.ceil(Math.abs(y-A));switch(!0){case g===0:case p===0:case g===-1/0:case p===-1/0:case g===1/0:case p===1/0:o!==n&&U.release(o),h!==r&&T.release(h),b.push(0);return}if(0>f+g||0>A+p||f>i||A>s){o!==n&&U.release(o),h!==r&&T.release(h),b.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const w=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(w))}`,oe(w)}else e.uniqueKey=`${e.instanceId}`;b.pushVideoBuffer(1,to,h[0],h[1],h[2],h[3],h[4],h[5],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],f,A,d,y,0,0,e.videoWidth,e.videoHeight,+e.uniqueKey,+e.changed,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);const $=e.$cache?e.$cache.get("0"):O.get(e.uniqueKey,"0");if(!$||e.changed){b.push(0,+$);const w=e.$context;if(w){const I=e.videoWidth/2,P=e.videoHeight/2;w.save(),w.translate(I,P),w.rotate(Math.PI),w.scale(-1,1),w.drawImage(e.$videoElement,-I,-P,e.videoWidth,e.videoHeight),w.restore(),t.push(e.$offscreenCanvas.transferToImageBitmap())}$||O.set(e.uniqueKey,"0",!0),e.$cache&&(e.$cache=null)}else e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);if(b.push(pr(e.blendMode)),e.filters?.length){let w=!1;const I=[],P=re(0,0,0,0);for(let C=0;C0;W?(b.push(+W,+w,P[0],P[1],P[2],P[3],I.length),b.set(new Float32Array(I))):b.push(0),k(P)}else b.push(0);o!==n&&U.release(o),h!==r&&T.release(h)},Jn=(e,t,r,n)=>{let i=null;switch(!0){case e.isContainerEnabled:i=yt(e,t);break;case e.isShape:i=wt(e,t);break;case e.isText:i=Bt(e,t);break;case e.isVideo:i=Mt(e,t);break}if(!i)return null;const s=i[0],a=i[2],o=Math.abs(a-s);if(!o)return null;const c=i[1],u=i[3],h=Math.abs(u-c);return!h||0>s+o||0>c+h||s>r||c>n?null:i},Hr=(e,t)=>{const r=_(e),n=r?T.multiply(t,r):t,i=e.children;b.push(bi,i.length);for(let s=0;s{const r=wt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=Mt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=Bt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),i=n?t?T.multiply(t,n):n:t,s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{if(!e.visible){b.push(0);return}const a=Ve(e);let o=a&&(a[0]!==1||a[1]!==1||a[2]!==1||a[3]!==1||a[4]!==0||a[5]!==0||a[6]!==0||a[7]!==0)?U.multiply(n,a):n;if(!me(o[3]+o[7]/255,0,1,0)){o!==n&&U.release(o),b.push(0);return}const u=e.children;if(!u.length){o!==n&&U.release(o),b.push(0);return}const h=_(e);let l=h&&(h[0]!==1||h[1]!==0||h[2]!==0||h[3]!==1||h[4]!==0||h[5]!==0)?T.multiply(r,h):r;if(!l[0]&&!l[1]||!l[2]&&!l[3]){o!==n&&U.release(o),l!==r&&T.release(l),b.push(0);return}b.push(1,bi);const f=e.blendMode;b.push(pr(f));const A=e.filters;if(A){const p=O.generateFilterKeys(l[0],l[1],l[2],l[3]),$=O.get(`${e.instanceId}`,`${p}`);let w=!1;const I=[],P=re(0,0,0,0);for(let C=0;C0){w||(w=e.changed);const C=Bs(e,r);if($){if(!w){b.push(1,Math.ceil(Math.abs(C[2]-C[0])),Math.ceil(Math.abs(C[3]-C[1])),1,1,e.instanceId,p,P[0],P[1],P[2],P[3],l[0],l[1],l[2],l[3],C[0],C[1],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]),k(C),k(P),o!==n&&U.release(o),l!==r&&T.release(l);return}O.removeById(`${e.instanceId}`)}b.push(1,Math.ceil(Math.abs(C[2]-C[0])),Math.ceil(Math.abs(C[3]-C[1])),1,0,e.instanceId,p,P[0],P[1],P[2],P[3],l[0],l[1],l[2],l[3],C[0],C[1],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],I.length),b.set(new Float32Array(I));const R=l[0],L=l[1],N=l[2],J=l[3],Y=l[4]-C[0],ee=l[5]-C[1];l!==r&&T.release(l),l=je(R,L,N,J,Y,ee),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0),k(C),O.set(`${e.instanceId}`,`${p}`,!0)}else if(f==="normal")b.push(0);else{const C=yt(e,r),R=C[0],L=C[1];b.push(1,Math.ceil(Math.abs(C[2]-R)),Math.ceil(Math.abs(C[3]-L)),0,l[0],l[1],l[2],l[3],R,L,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]);const N=l[0],J=l[1],Y=l[2],ee=l[3],Q=l[4]-R,ce=l[5]-L;l!==r&&T.release(l),l=je(N,J,Y,ee,Q,ce),k(C),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0)}k(P)}else if(f==="normal")b.push(0);else{const p=yt(e,r),$=p[0],w=p[1];b.push(1,Math.ceil(Math.abs(p[2]-$)),Math.ceil(Math.abs(p[3]-w)),0,l[0],l[1],l[2],l[3],$,w,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]);const I=l[0],P=l[1],W=l[2],C=l[3],R=l[4]-$,L=l[5]-w;l!==r&&T.release(l),l=je(I,P,W,C,R,L),k(p),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0)}const d=e.mask;if(d){const p=Jn(d,l,i,s);if(!p)b.push(0);else switch(b.push(1,p[0],p[1],p[2],p[3]),!0){case d.isContainerEnabled:Hr(d,l);break;case d.isShape:zr(d,l);break}d.changed=!1}else b.push(0);b.push(u.length);let y=0,g=!0;for(let p=0;py&&(y=0,g=!0),!g){b.push(0),$.changed=!1;continue}if($.clipDepth){y=$.clipDepth;const w=Jn($,l,i,s);if(g=!!w,b.push(+g),!w){$.changed=!1;continue}switch(b.push(w[0],w[1],w[2],w[3]),!0){case $.isContainerEnabled:Hr($,l);break;case $.isShape:zr($,l);break}$.changed=!1;continue}switch(!0){case $.isContainerEnabled:Ts($,t,l,o,i,s);break;case $.isShape:vs($,l,o,i,s);break;case $.isText:ws($,l,o,i,s);break;case $.isVideo:Ms($,t,l,o,i,s);break}$.changed=!1}o!==n&&U.release(o),l!==r&&T.release(l)},yh=(e,t,r,n,i,s)=>{switch(b.push(v.backgroundColor),!0){case e.isContainerEnabled:Ts(e,t,r,n,i,s);break;case e.isShape:vs(e,r,n,i,s);break;case e.isText:ws(e,r,n,i,s);break;case e.isVideo:Ms(e,t,r,n,i,s);break}e.changed=!1},Zn=e=>{e.totalFrames===1||!e.isPlaying||(e.$wait||(++e.currentFrame,e.currentFrame>e.totalFrames&&(e.currentFrame=1)),e.$wait=!1,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,e.$container=null,ys(e),Zt(e),j(e))},Jr=e=>{const t=e.$container;if(t)for(let r=0;t.length>r;++r){const n=t[r];n.isTimelineEnabled&&Zn(n),Jr(n)}else{const r=[],n=e.children;for(let i=0;n.length>i;++i){const s=n[i];s.isContainerEnabled&&(s.isTimelineEnabled&&Zn(s),Jr(s),r.push(s))}e.$container=r}},$h=()=>{Jr(v),xs(),bs()};class vh extends dn{_$ready;stageWidth;stageHeight;frameRate;rendererScale;rendererWidth;rendererHeight;_$backgroundColor;constructor(){super(),this.stageWidth=0,this.stageHeight=0,this.frameRate=1,this.rendererScale=1,this.rendererWidth=0,this.rendererHeight=0,this._$ready=!1,this._$backgroundColor=-1}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){this._$backgroundColor=t==="transparent"?-1:parseInt(t.replace("#",""),16)}get pointer(){return bt}set ready(t){!t||this._$ready||(this._$ready=t,dh(this))}addChild(t){return ge.add(t.instanceId),we.set(this,t),super.addChild(t),we.delete(this),we.set(t,t),t}$ticker(){$h()}$generateRenderQueue(t,r,n,i){yh(t,r,n,i,this.rendererWidth,this.rendererHeight)}$mouseHit(t,r,n){He(this,t,r,n,!0)}}const v=new vh;ge.add(v.instanceId);const Fr={command:"resize",buffer:null},qn=[],Zr=(e=!0)=>{Fr.buffer=new Float32Array([B.rendererWidth,B.rendererHeight,e?1:0]),qn[0]=Fr.buffer.buffer,Ce.postMessage(Fr,qn)},jn=window.devicePixelRatio||1,vn=()=>{Je.x=0,Je.y=0;const e=vt();if(!e)return;const t=e.children[0];!t||t.localName!=="canvas"||(Je.x=(e.clientWidth-v.rendererWidth/jn)/2,Je.y=(e.clientHeight-v.rendererHeight/jn)/2)},mr=()=>{const e=vt();if(!e)return;const t=e.parentElement;if(!t)return;const r=B.fullScreen||t.tagName==="BODY"?window.innerWidth:t.clientWidth,n=B.fullScreen||t.tagName==="BODY"?window.innerHeight:t.clientHeight,i=e.style;if(i.width=`${r}px`,i.height=`${n}px`,!v.stageWidth||!v.stageHeight)return;const s=Math.min(r/v.stageWidth,n/v.stageHeight)*Ze,a=B.fullScreen?window.innerWidth*Ze:v.stageWidth*s|0,o=B.fullScreen?window.innerHeight*Ze:v.stageHeight*s|0;a===B.screenWidth&&o===B.screenHeight||(B.screenWidth=r,B.screenHeight=n,v.changed=!0,e.children.length>1&&e.children[1].dispatchEvent(new Event(`${on}_blur`)),vn(),!(a===B.rendererWidth&&o===B.rendererHeight)&&(v.rendererScale=B.rendererScale=s,v.rendererWidth=B.rendererWidth=a,v.rendererHeight=B.rendererHeight=o,ft[0]=ft[3]=s,ft[4]=(B.rendererWidth-v.stageWidth*s)/2,ft[5]=(B.rendererHeight-v.stageHeight*s)/2,O.reset(),Zr(),v.hasEventListener(x.RESIZE)&&v.dispatchEvent(new x(x.RESIZE))))},wh=new Float32Array([1,1,1,1,0,0,0,0]),lt=[],ut={command:"render",buffer:null,length:0,imageBitmaps:null},Ot=[];Ce.addEventListener("message",e=>{if(e.data.message!=="render")return;const t=e.data.buffer;b.buffer.length>t.length||(b.buffer=t)});const Ss=()=>{b.offset=0,Ot.length=0,lt.length=0,v.$generateRenderQueue(v,lt,ft,wh),b.offset&&(ut.buffer=b.buffer,ut.length=b.offset,Ot.push(b.buffer.buffer),ut.imageBitmaps=null,lt.length&&(ut.imageBitmaps=lt,Ot.push(...lt)),Ce.postMessage(ut,Ot))},ei={command:"removeCache",buffer:null},ti=[],ri=()=>{const e=new Float32Array(O.$removeIds);O.$removeIds.length=0,ei.buffer=e,ti[0]=e.buffer,Ce.postMessage(ei,ti)},Mh=new x(x.ENTER_FRAME),Is=e=>{if(B.stopFlag)return;O.$removeIds.length&&ri();const t=e-B.startTime;t>B.fps&&(B.startTime=e-t%B.fps,v.$ticker(),v.hasEventListener(x.ENTER_FRAME)&&v.dispatchEvent(Mh),v.changed&&Ss(),O.$removeCache&&(O.removeTimerScheduledCache(),O.$removeIds.length&&ri())),B.timerId=requestAnimationFrame(r=>{Is(r)})},Bh=()=>{B.stopFlag&&(B.stopFlag=!1,v.changed=!0,B.timerId>-1&&cancelAnimationFrame(B.timerId),B.fps=1e3/v.frameRate|0,B.startTime=performance.now(),B.timerId=requestAnimationFrame(e=>{Is(e)}))},Th=()=>{B.timerId>-1&&cancelAnimationFrame(B.timerId),B.stopFlag=!0,B.timerId=-1,rt.stopAll()},Sh=e=>{const t=ke();if(t){t.keyDown(e);return}v.hasEventListener(V.KEY_DOWN)&&(We(e),v.dispatchEvent(new V(V.KEY_DOWN)))},Ih=e=>{ke()||v.hasEventListener(V.KEY_UP)&&(We(e),v.dispatchEvent(new V(V.KEY_UP)))},Ch=()=>{window.addEventListener(V.KEY_DOWN,Sh),window.addEventListener(V.KEY_UP,Ih)};class Fh{rendererWidth;rendererHeight;screenWidth;screenHeight;rendererScale;fixedWidth;fixedHeight;stopFlag;startTime;fps;tagId;_$fullScreen;timerId;mouseState;constructor(){this.rendererWidth=0,this.rendererHeight=0,this.rendererScale=1,this.screenWidth=0,this.screenHeight=0,this.stopFlag=!0,this.startTime=0,this.fps=16,this.timerId=-1,this.mouseState="up",this.fixedWidth=0,this.fixedHeight=0,this.tagId="",this._$fullScreen=!1,Ch()}get fullScreen(){return this._$fullScreen}set fullScreen(t){this._$fullScreen!==t&&(this._$fullScreen=t,mr())}play(){Bh()}stop(){Th()}cacheClear(){O.reset(),Ce.postMessage({command:"cacheClear"})}setOptions(t=null){t&&(this.fixedWidth=t.width||this.fixedWidth,this.fixedHeight=t.height||this.fixedHeight,this.tagId=t.tagId||this.tagId,this._$fullScreen=!!t.fullScreen,t.bgColor&&(v.backgroundColor=t.bgColor))}}const B=new Fh;let ni="auto";const wn=()=>{B.stopFlag||(ie.x=v.pointer.x,ie.y=v.pointer.y,ie.pointer="auto",ie.hit=null,Tr.beginPath(),Tr.setTransform(1,0,0,1,0,0),v.$mouseHit(Tr,gt,ie),B.mouseState==="up"&&ni!==ie.pointer&&(ui().style.cursor=ni=ie.pointer))},Mn=e=>{let t=window.scrollX,r=window.scrollY;const n=vt();if(n){const c=n.getBoundingClientRect();t+=c.left,r+=c.top}const i=e.target;if(i){const c=i.getBoundingClientRect();t+=c.left,r+=c.top}const s=(B.rendererWidth-v.stageWidth*B.rendererScale)/2,a=(B.rendererHeight-v.stageHeight*B.rendererScale)/2,o=B.rendererScale/Ze;v.pointer.x=(e.pageX-t)/o-s/B.rendererScale,v.pointer.y=(e.pageY-r)/o-a/B.rendererScale},Eh=()=>{const e=ie.hit,t=ke();t&&(!e||t.instanceId!==e.instanceId)&&(t.focus=!1,kn(null)),e?(e.isText&&(e.focus?setTimeout(()=>{de.focus()},300):(e.focus=!0,kn(e)),e.setFocusIndex(ie.x-gt[4],ie.y-gt[5])),e.willTrigger(S.POINTER_DOWN)&&e.dispatchEvent(new S(S.POINTER_DOWN))):v.willTrigger(S.POINTER_DOWN)&&v.dispatchEvent(new S(S.POINTER_DOWN))},Ph=()=>{const e=ie.hit;e?e.willTrigger(S.DOUBLE_CLICK)&&e.dispatchEvent(new S(S.DOUBLE_CLICK)):v.willTrigger(S.DOUBLE_CLICK)&&v.dispatchEvent(new S(S.DOUBLE_CLICK))};let ii,kt=!1;const Rh=e=>{const t=e.target;t&&(B.mouseState="down",t.setPointerCapture(e.pointerId),We(e),Mn(e),wn(),ie.hit&&e.preventDefault(),clearTimeout(ii),kt?(kt=!1,Ph()):(kt=!0,ii=setTimeout(()=>{kt=!1},300),Eh()))},Oh=()=>{const e=v.dropTarget,t=ie.hit;t?(t.willTrigger(S.POINTER_UP)&&t.dispatchEvent(new S(S.POINTER_UP)),e&&e.instanceId!==t.instanceId&&e.willTrigger(S.POINTER_UP)&&e.dispatchEvent(new S(S.POINTER_UP))):e&&e.willTrigger(S.POINTER_UP)?e.dispatchEvent(new S(S.POINTER_UP)):v.willTrigger(S.POINTER_UP)&&v.dispatchEvent(new S(S.POINTER_UP))},si=e=>{const t=e.target;t&&(B.mouseState="up",t.releasePointerCapture(e.pointerId),We(e),Mn(e),wn(),Oh())},kh=()=>{const e=v.dropTarget;if(e){const i=e.parent?e.parent.globalToLocal(v.pointer):e.globalToLocal(v.pointer);let s=0,a=0;e.$lockCenter?(s=i.x-e.width/2,a=i.y-e.height/2):(s=i.x+e.$offsetX,a=i.y+e.$offsetY);const o=e.$boundedRect;o&&(s=Vt(s,o.left,o.right),a=Vt(a,o.top,o.bottom)),e.x=s,e.y=a}const t=ke();if(t&&B.mouseState==="down"){t.setFocusIndex(ie.x-gt[4],ie.y-gt[5],!0);return}const r=fi(),n=ie.hit;n?(n.willTrigger(S.POINTER_MOVE)&&n.dispatchEvent(new S(S.POINTER_MOVE)),r?r.instanceId!==n.instanceId&&(r.willTrigger(S.POINTER_OUT)&&r.dispatchEvent(new S(S.POINTER_OUT)),n.willTrigger(S.POINTER_OVER)&&n.dispatchEvent(new S(S.POINTER_OVER))):n.willTrigger(S.POINTER_OVER)&&n.dispatchEvent(new S(S.POINTER_OVER)),Cn(n)):(r&&(r.willTrigger(S.POINTER_OUT)&&r.dispatchEvent(new S(S.POINTER_OUT)),Cn(null)),v.hasEventListener(S.POINTER_MOVE)&&v.dispatchEvent(new S(S.POINTER_MOVE)))},Uh=e=>{e.target&&(We(e),Mn(e),wn(),ie.hit&&e.preventDefault(),kh())},Gh=e=>{We(e);const t=fi();t&&t.willTrigger(S.POINTER_LEAVE)&&(e.preventDefault(),t.dispatchEvent(new S(S.POINTER_LEAVE)))},_h=e=>{We(e);const t=ie.hit;if(t&&t.isText&&t.scrollEnabled){e.preventDefault(),e.deltaX&&(t.scrollX+=e.deltaX/(t.textWidth/t.width)),e.deltaY&&(t.scrollY+=e.deltaY/(t.textHeight/t.height));return}v.willTrigger(qe.WHEEL)&&(e.preventDefault(),v.dispatchEvent(new qe(qe.WHEEL)))},Dh=e=>{const t=()=>{Mu();const r=$u();for(let n=0;n{Object.defineProperty(qr,e,{get(){return t}})});const jr={Sprite:An,MovieClip:qt,BitmapData:_e,BlendMode:ua,DisplayObject:hr,DisplayObjectContainer:dn,FrameLabel:Ki,Graphics:M,InteractiveObject:fn,Loader:gs,Shape:$t,stage:v};Object.entries(jr).forEach(([e,t])=>{Object.defineProperty(jr,e,{get(){return t}})});const en={BevelFilter:rr,BlurFilter:nr,ColorMatrixFilter:ir,ConvolutionFilter:sr,DisplacementMapFilter:ar,DropShadowFilter:or,GlowFilter:cr,GradientBevelFilter:lr,GradientGlowFilter:ur};Object.entries(en).forEach(([e,t])=>{Object.defineProperty(en,e,{get(){return t}})});const tn={ColorTransform:U,Matrix:T,Point:se,Rectangle:be};Object.entries(tn).forEach(([e,t])=>{Object.defineProperty(tn,e,{get(){return t}})});const rn={Sound:dr,SoundMixer:rt,SoundTransform:_u,Video:Xr};Object.entries(rn).forEach(([e,t])=>{Object.defineProperty(rn,e,{get(){return t}})});class Cs{requestHeaders;url;contentType;data;method;responseDataFormat;withCredentials;constructor(t=""){this.url=`${t}`,this.contentType="application/json",this.data=null,this.method="GET",this.requestHeaders=[],this.responseDataFormat="json",this.withCredentials=!1}get headers(){const t=[];return t.push({name:"Content-Type",value:this.contentType}),this.requestHeaders.length&&t.push(...this.requestHeaders),t}}const nn={URLRequest:Cs};Object.entries(nn).forEach(([e,t])=>{Object.defineProperty(nn,e,{get(){return t}})});const sn={TextFormat:ue,TextField:Qr};Object.entries(sn).forEach(([e,t])=>{Object.defineProperty(sn,e,{get(){return t}})});const an={Easing:Ye,Tween:gn};Object.entries(an).forEach(([e,t])=>{Object.defineProperty(an,e,{get(){return t}})});const Fs=()=>{const e=vt();if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},Es=()=>{const e=vt();if(!e)return;const t=ui();t&&(e.appendChild(t),e.appendChild(de))},Ps=()=>{v.ready=!0,Ss(),B.play(),v.changed=!1},Lh=()=>{const e=document.createElement("div");if(_s(e),e.id=on,e.tabIndex=-1,!B.tagId)document.body.appendChild(e);else{const t=document.getElementById(B.tagId);if(!t)return alert(`Element not found with tag ID: ${B.tagId}`),e;t.appendChild(e)}return e},Nh=(e,t=0,r=0)=>{let n="";if(n+="display:flex;",n+="align-items:center;",n+="justify-content:center;",n+="background-color:transparent;",n+="overflow:hidden;",n+="padding:0;",n+="margin:0;",n+="user-select:none;",n+="outline:none;",t&&r)n+=`width:${t}px;`,n+=`height:${r}px;`;else{const i=e.parentElement;if(!i)throw new Error("parent element is null.");i.tagName==="BODY"?(n+=`width:${window.innerWidth}px;`,n+=`height:${window.innerHeight}px;`):(n+=`width:${i.clientWidth}px;`,n+=`height:${i.clientHeight}px;`)}e.setAttribute("style",n)},Yh=e=>{const t=`${on}_loading`;e.innerHTML=` -
`};let ai=-1;const Wh=()=>{window.addEventListener("resize",()=>{cancelAnimationFrame(ai),ai=requestAnimationFrame(mr)})},Rs=(e=null)=>{B.setOptions(e);const t=Lh();Nh(t,B.fixedWidth,B.fixedHeight),Yh(t),!B.fixedWidth&&!B.fixedHeight&&Wh(),mr()},Vh=async(e,t=null)=>{if(e==="develop"){const s=location.search.slice(1).split("&")[0];if(!s)return;e=`${location.origin}/${s}`}if(!e)return;e.charAt(1)==="/"&&(e=e.slice(1)),Rs(t);const r=new gs,n=r.contentLoaderInfo;if(n.addEventListener(Re.IO_ERROR,s=>{alert("Error: "+s.text)}),await r.load(new Cs(e)),!n.data)return;const i=n.data.stage;v.stageWidth=i.width,v.stageHeight=i.height,v.frameRate=Vt(i.fps,1,60,60),v.backgroundColor=t&&t.bgColor?t.bgColor:i.bgColor,v.addChild(n.content),mr(),Ps(),Fs(),Es(),vn()};let oi=!1;const Kh=(e=240,t=240,r=60,n=null)=>{if(oi)return v.getChildAt(0);oi=!0,v.stageWidth=e|0,v.stageHeight=t|0,v.frameRate=Vt(r,1,60,60),Rs(n);const i=v.addChild(new An);return Ps(),Fs(),Es(),vn(),i},Te={command:"capture",buffer:null,bgColor:16777215,bgAlpha:0,width:0,height:0,length:0,imageBitmaps:null},Ut=[],ht=[],Qh=async(e,t,r,n,i=0,s=0)=>await new Promise(a=>{if(b.offset=0,Ut.length=0,ht.length=0,v.$generateRenderQueue(e,ht,t,r),!b.offset)return a(n);Te.buffer=b.buffer,Te.width=n.width,Te.height=n.height,Te.bgColor=i,Te.bgAlpha=s,Te.length=b.offset,Ut.push(b.buffer.buffer),Te.imageBitmaps=null,ht.length&&(Te.imageBitmaps=ht,Ut.push(...ht));const o=c=>{if(c.data.message!=="capture")return;const u=c.data.buffer;return b.buffer.length{switch(!0){case e.isVideo:{const t=e.muted;e.muted=!0,await e.play(),e.pause(),e.muted=t,await new Promise(r=>{const n=async()=>{e.loaded?(e.seek(0),r()):requestAnimationFrame(n)};requestAnimationFrame(n)})}break;case e.isContainerEnabled:{const t=e.children;for(let r=0;r{t&&t.videoSync&&await Os(e);const r=t&&t.colorTransform?t.colorTransform.rawData:zh,n=new Float32Array([1,0,0,1,-e.width/2,-e.height/2]),i=t&&t.matrix?T.multiply(t.matrix.rawData,n):T.multiply(Xh,n),s=t&&t.canvas?t.canvas:O.getCanvas(),a=Math.sqrt(i[0]*i[0]+i[1]*i[1]),o=Math.sqrt(i[2]*i[2]+i[3]*i[3]),c=Math.ceil(e.width*a),u=Math.ceil(e.height*o);if(c<=0||u<=0)return s;i[4]+=c/2,i[5]+=u/2,s.width=c,s.height=u;const h=B.stopFlag;h||B.stop();let l=!1;const f=B.rendererWidth,A=B.rendererHeight,d=B.rendererScale;if(c>f||u>A){l=!0;const y=Math.min(c/v.stageWidth,u/v.stageHeight)*Ze;v.rendererScale=B.rendererScale=y,v.rendererWidth=B.rendererWidth=c,v.rendererHeight=B.rendererHeight=u,Zr(!1)}return await Qh(e,i,r,s,t&&t.bgColor?parseInt(t.bgColor.replace("#",""),16):0,t&&t.bgAlpha?t.bgAlpha:0),l&&(v.rendererScale=B.rendererScale=d,v.rendererWidth=B.rendererWidth=f,v.rendererHeight=B.rendererHeight=A,Zr(!1)),h||B.play(),T.release(i),t&&t.colorTransform&&U.release(r),s};class Jh{display;events;filters;geom;media;net;text;ui;_$promise;constructor(){this.display=jr,this.events=qr,this.filters=en,this.geom=tn,this.media=rn,this.net=nn,this.text=sn,this.ui=an,this._$promise=new Promise(t=>{document.readyState==="loading"?window.addEventListener("DOMContentLoaded",()=>t(),{once:!0}):t()})}async load(t,r=null){await Promise.all([this._$promise]),await Vh(t,r)}async createRootMovieClip(t=240,r=240,n=60,i=null){return await Promise.all([this._$promise]),Kh(t,r,n,i)}async captureToCanvas(t,r=null){return await Hh(t,r)}}"next2d"in window||(console.log("%c Next2D Player %c 3.0.1 %c https://next2d.app","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),window.next2d=new Jh); +
`},Xl=-1,Zl=()=>{window.addEventListener(`resize`,()=>{cancelAnimationFrame(Xl),Xl=requestAnimationFrame(Yc)})},Ql=(e=null)=>{$.setOptions(e);let t=ql();Jl(t,$.fixedWidth,$.fixedHeight),Yl(t),!$.fixedWidth&&!$.fixedHeight&&Zl(),Yc()},$l=async(e,t=null)=>{if(e===`develop`){let t=location.search.slice(1).split(`&`)[0];if(!t)return;e=`${location.origin}/${t}`}if(!e)return;e.charAt(1)===`/`&&(e=e.slice(1)),Ql(t);let r=new _c,i=r.contentLoaderInfo;if(i.addEventListener(me.IO_ERROR,e=>{alert(`Error: `+e.text)}),await r.load(new Bl(e)),!i.data)return;let a=i.data.stage;Q.stageWidth=a.width,Q.stageHeight=a.height,Q.frameRate=n(a.fps,1,60,60),Q.backgroundColor=t&&t.bgColor?t.bgColor:a.bgColor,Q.addChild(i.content),Yc(),Kl(),Wl(),Gl(),Jc()},eu=!1,tu=(e=240,t=240,r=60,i=null)=>{if(eu)return Q.getChildAt(0);eu=!0,Q.stageWidth=e|0,Q.stageHeight=t|0,Q.frameRate=n(r,1,60,60),Ql(i);let a=Q.addChild(new Ni);return Kl(),Wl(),Gl(),Jc(),a},nu={command:`capture`,buffer:null,bgColor:16777215,bgAlpha:0,width:0,height:0,length:0,imageBitmaps:null},ru=[],iu=[],au=async(e,t,n,r,i=0,a=0)=>await new Promise(o=>{if(Z.offset=0,ru.length=0,iu.length=0,Q.$generateRenderQueue(e,iu,t,n),!Z.offset)return o(r);nu.buffer=Z.buffer,nu.width=r.width,nu.height=r.height,nu.bgColor=i,nu.bgAlpha=a,nu.length=Z.offset,ru.push(Z.buffer.buffer),nu.imageBitmaps=null,iu.length&&(nu.imageBitmaps=iu,ru.push(...iu));let s=e=>{if(e.data.message!==`capture`)return;let t=e.data.buffer;return Z.buffer.length{switch(!0){case e.isVideo:{let t=e.muted;e.muted=!0,await e.play(),e.pause(),e.muted=t,await new Promise(t=>{let n=async()=>{e.loaded?(e.seek(0),t()):requestAnimationFrame(n)};requestAnimationFrame(n)})}break;case e.isContainerEnabled:{let t=e.children;for(let e=0;e{n&&n.videoSync&&await ou(e);let r=n&&n.colorTransform?n.colorTransform.rawData:cu,i=new Float32Array([1,0,0,1,-e.width/2,-e.height/2]),a=n&&n.matrix?P.multiply(n.matrix.rawData,i):P.multiply(su,i),o=n&&n.canvas?n.canvas:j.getCanvas(),s=Math.sqrt(a[0]*a[0]+a[1]*a[1]),c=Math.sqrt(a[2]*a[2]+a[3]*a[3]),l=Math.ceil(e.width*s),u=Math.ceil(e.height*c);if(l<=0||u<=0)return o;a[4]+=l/2,a[5]+=u/2,o.width=l,o.height=u;let d=$.stopFlag;d||$.stop();let f=!1,p=$.rendererWidth,m=$.rendererHeight,h=$.rendererScale;return(l>p||u>m)&&(f=!0,Q.rendererScale=$.rendererScale=Math.min(l/Q.stageWidth,u/Q.stageHeight)*t,Q.rendererWidth=$.rendererWidth=l,Q.rendererHeight=$.rendererHeight=u,Kc(!1)),await au(e,a,r,o,n&&n.bgColor?parseInt(n.bgColor.replace(`#`,``),16):0,n&&n.bgAlpha?n.bgAlpha:0),f&&(Q.rendererScale=$.rendererScale=h,Q.rendererWidth=$.rendererWidth=p,Q.rendererHeight=$.rendererHeight=m,Kc(!1)),d||$.play(),P.release(a),n&&n.colorTransform&&M.release(r),o},uu=class{display;events;filters;geom;media;net;text;ui;_$promise;constructor(){this.display=Il,this.events=Fl,this.filters=Ll,this.geom=Rl,this.media=zl,this.net=Vl,this.text=Hl,this.ui=Ul,this._$promise=new Promise(e=>{document.readyState===`loading`?window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e()})}async load(e,t=null){await Promise.all([this._$promise]),await $l(e,t)}async createRootMovieClip(e=240,t=240,n=60,r=null){return await Promise.all([this._$promise]),tu(e,t,n,r)}async captureToCanvas(e,t=null){return await lu(e,t)}};`next2d`in window||(console.log(`%c Next2D Player %c 3.8.2 %c https://next2d.app`,`color: #fff; background: #5f5f5f`,`color: #fff; background: #4bc729`,``),window.next2d=new uu); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index aa0a28b3..a67b13db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,20 @@ { "name": "next2d-web-site", - "version": "2.1.1", + "version": "2.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "next2d-web-site", - "version": "2.1.1", + "version": "2.1.2", "license": "Next2D", "dependencies": { - "@astrojs/markdown-remark": "^7.2.0" + "@astrojs/markdown-remark": "^7.2.1" }, "devDependencies": { "@astrojs/sitemap": "^3.7.3", "aos": "^2.3.4", - "astro": "^7.0.5", + "astro": "^7.0.6", "bootstrap": "^5.3.8", "bootstrap-icons": "^1.13.1", "typescript": "^6.0.3", @@ -221,9 +221,9 @@ } }, "node_modules/@astrojs/internal-helpers": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.10.0.tgz", - "integrity": "sha512-Ry2R3VPeIN4uPCSA4xQc+e+vsJXkalKpEbDc07hV+a/o5Bs2N/s/uDcPJH/05L19DKh9tAy7e6JM3YZ6Cxfezw==", + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/@astrojs/internal-helpers/-/internal-helpers-0.10.1.tgz", + "integrity": "sha512-5phcroT/vmOOrYuuAxtkbPixy5hePtlz9i8K4OeDv3dNK6/UQRuXPOSRTxIOBbUY5Sonw2UaxjbuVc43Mcir6Q==", "license": "MIT", "dependencies": { "@types/hast": "^3.0.4", @@ -237,12 +237,12 @@ } }, "node_modules/@astrojs/markdown-remark": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-7.2.0.tgz", - "integrity": "sha512-+YxmVQu1Bd+MFfSzjq1rOJvD9+nIOJzz5YIIhdIH01RrxRkKbyKoEgyIqP3yv51MhzMDgd79QaPv+kCVPT8vHw==", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-remark/-/markdown-remark-7.2.1.tgz", + "integrity": "sha512-jPVNIqTvk+yKviikszv/Y1U4jGUSKpp/Nw48QZV4qjWgp70j4Lkq3lhSDRbWwCfgKvEyO9GHuVbV1dM2WYXy1w==", "license": "MIT", "dependencies": { - "@astrojs/internal-helpers": "0.10.0", + "@astrojs/internal-helpers": "0.10.1", "@astrojs/prism": "4.0.2", "github-slugger": "^2.0.0", "hast-util-from-html": "^2.0.3", @@ -262,13 +262,13 @@ } }, "node_modules/@astrojs/markdown-satteri": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/@astrojs/markdown-satteri/-/markdown-satteri-0.3.2.tgz", - "integrity": "sha512-feXuUPy41gVfeM7EHT1ciUim8ozGr+YHXab9uUBc1Hk8y60DQosO8ldL+AoPXnCAoGj1OChwHfvXmmJ6XVnY9A==", + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@astrojs/markdown-satteri/-/markdown-satteri-0.3.3.tgz", + "integrity": "sha512-Lje33Ittd8UQGgbIIWQvhPkj5X5c4b1sZnZWX3JQV/AWpfbuQGxVi2ONt6+ScydcwfR4egilslEWyczMclrJ1g==", "dev": true, "license": "MIT", "dependencies": { - "@astrojs/internal-helpers": "0.10.0", + "@astrojs/internal-helpers": "0.10.1", "@astrojs/prism": "4.0.2", "github-slugger": "^2.0.0", "satteri": "^0.9.1" @@ -473,6 +473,29 @@ "node": ">=14.0.0" } }, + "node_modules/@bruits/satteri-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz", + "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@bruits/satteri-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz", + "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@bruits/satteri-win32-arm64-msvc": { "version": "0.9.4", "resolved": "https://registry.npmjs.org/@bruits/satteri-win32-arm64-msvc/-/satteri-win32-arm64-msvc-0.9.4.tgz", @@ -513,9 +536,9 @@ } }, "node_modules/@clack/core": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.4.2.tgz", - "integrity": "sha512-0Ty/1Gfm+Kb07sXcuESjyKfwEhSy4Ns1AgeEisHb/bDY5fWme0tTeTkU14T1Gmcs17YIjB/teiDe4uaCghbYqQ==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.4.3.tgz", + "integrity": "sha512-/kr3UWNtdJfxZtPgDqUOmG2pvwlmcLGheex5yiZKdwbzZJxhV+HMNR9QNmyY5cGwTNV6LrR7Jtp+KjhUAP1qBQ==", "dev": true, "license": "MIT", "dependencies": { @@ -527,13 +550,13 @@ } }, "node_modules/@clack/prompts": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.6.0.tgz", - "integrity": "sha512-EYlRokl8szrP9Z25qT5aepMdBjzBvHF9ZEhzIiUBc9guz/T31EqRgvD0QSgZcpE93xiwrr+OkB4nz0BZyF6fSA==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.7.0.tgz", + "integrity": "sha512-y7/yvZ2TPAnR9+jnc00klvNNLkJiXFFrQA/hlLCcxA9a2A4zQIOimyFQ9XfwYKiGD1fb5GY8vbKIIgO8d5Tb2A==", "dev": true, "license": "MIT", "dependencies": { - "@clack/core": "1.4.2", + "@clack/core": "1.4.3", "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", "sisteransi": "^1.0.5" @@ -543,21 +566,22 @@ } }, "node_modules/@emnapi/core": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz", - "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.2.tgz", + "integrity": "sha512-TC8MkTuZUtcTSiFeuC0ksCh9QIJ5+F21MvZ4Wn4ORfYaFJ/0dsiudv5tVkejgwZlwQ39jL9WWDe2lz8x0WglOA==", "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" } }, "node_modules/@emnapi/runtime": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz", - "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.2.tgz", + "integrity": "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA==", "dev": true, "license": "MIT", "optional": true, @@ -1890,6 +1914,29 @@ "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz", + "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.2", + "tslib": "^2.4.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz", + "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.1.4.tgz", @@ -1955,13 +2002,13 @@ } }, "node_modules/@shikijs/core": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.3.0.tgz", - "integrity": "sha512-EooU3i9F6IAE8kEu+AnGf9DFZWkQBZ+hJn3tLVbsH+61mtQiva5biai66fAA6nvFPXkLgvrh7BrR7YcJU83xQQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-4.3.1.tgz", + "integrity": "sha512-ANMDxuaPsNMdDC1m4vfvhlDmJweMwkE5XitTwrq2rWHx5jM+dlm4MmHt2PP6t0uejfR77SuhrhJ0zEijIF/uhA==", "license": "MIT", "dependencies": { - "@shikijs/primitive": "4.3.0", - "@shikijs/types": "4.3.0", + "@shikijs/primitive": "4.3.1", + "@shikijs/types": "4.3.1", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4", "hast-util-to-html": "^9.0.5" @@ -1971,12 +2018,12 @@ } }, "node_modules/@shikijs/engine-javascript": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.3.0.tgz", - "integrity": "sha512-hTv/KiFf2tpiqlACPiztGGurEARWIutB8YUhcrA1pUC7VzzwKO+g5crUocrLztrZ5ro5Z4hbXg7bYclETn3gSQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-4.3.1.tgz", + "integrity": "sha512-JBItcnPuYq7jVJdZo/vMj94r+szT7XEjHFX+mvFDGSEIbVAXAGyHAHzhbWzpGOwYidCZrErJLLgn2PVeiokHnQ==", "license": "MIT", "dependencies": { - "@shikijs/types": "4.3.0", + "@shikijs/types": "4.3.1", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^4.3.6" }, @@ -1985,12 +2032,12 @@ } }, "node_modules/@shikijs/engine-oniguruma": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.3.0.tgz", - "integrity": "sha512-1vMdN3gHfnKfLYwecUI2ITJI4RhHt96xEaJumVn7Heb0IlJ8WQMIH0Voak+2j22BpSNKdnOfB/pCTPnPm2gq7A==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-4.3.1.tgz", + "integrity": "sha512-OXyNMzg0pews+msMj4cHeqT4xiYKKvbnn6VbdAXxfoFl3SSx4fJTc8FadECuc5/H9p3BzhNAoAUXKwAu9rWYhg==", "license": "MIT", "dependencies": { - "@shikijs/types": "4.3.0", + "@shikijs/types": "4.3.1", "@shikijs/vscode-textmate": "^10.0.2" }, "engines": { @@ -1998,24 +2045,24 @@ } }, "node_modules/@shikijs/langs": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.3.0.tgz", - "integrity": "sha512-rnlqFbBRSys9bT4gl/5rw9RnS0W/I84ZldXPkO7cvlEMoV85TyF/aU01N7/NbSR776RNLjrJKjfFUXJR6wN1Cg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/langs/-/langs-4.3.1.tgz", + "integrity": "sha512-m0l9nsDqgBHvbZbk7A0/kXz/impK3uB/c6rAn6Gpg/uPtdZRQ+alsN/17MU5thb68XTj/4DxkZAotrM0GGSpDQ==", "license": "MIT", "dependencies": { - "@shikijs/types": "4.3.0" + "@shikijs/types": "4.3.1" }, "engines": { "node": ">=20" } }, "node_modules/@shikijs/primitive": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.3.0.tgz", - "integrity": "sha512-CPkz64PTa5diRW1ggzMZH9VM/du4RNChYgVtgqrFcgruvIybmCvySv8GkiHSczUHXYuuR8TdKEwFx+UnZMpgdg==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/primitive/-/primitive-4.3.1.tgz", + "integrity": "sha512-CXQRQOYy1leqQ8ceTeJdmXv/bsUY++6QyLpXJ94LZAAYj5X2SKRdc5ipguv4NPyGVKItB2PPwUpRNe0Sjh5S1A==", "license": "MIT", "dependencies": { - "@shikijs/types": "4.3.0", + "@shikijs/types": "4.3.1", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" }, @@ -2024,21 +2071,21 @@ } }, "node_modules/@shikijs/themes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.3.0.tgz", - "integrity": "sha512-Avgt05YiT+Y3prjIc9lmQxhJzHBcCfR6cjiFW4OyaMBbt2A6trX5rfjUzx+Vj/mE9qpArYjatnqo9XPjQNW/AQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/themes/-/themes-4.3.1.tgz", + "integrity": "sha512-dgpoJ4WqNi2yTmizQHBJ5zcX6j2lE6icN/0yt4l1kkf16jrY/pwPLoTb1ETsWMz0OBLf9ZNvwmxft+cH+N9qSA==", "license": "MIT", "dependencies": { - "@shikijs/types": "4.3.0" + "@shikijs/types": "4.3.1" }, "engines": { "node": ">=20" } }, "node_modules/@shikijs/types": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.3.0.tgz", - "integrity": "sha512-oc8b9U2SYvofKZk8e/737nIX0qwf6eV2vHFATeObAu7r+mUVpLs8Re0BmVkIjAWAYgkmG/CzLNo7rzuBzRu/wQ==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/@shikijs/types/-/types-4.3.1.tgz", + "integrity": "sha512-CHFxE0jztBIZRHH6gxXE7DXUCFXjReEGxZ/j0rfSLGKZuwp2xBYycEP14875DSa9KLL/6700oxIq6oO6ef9K2g==", "license": "MIT", "dependencies": { "@shikijs/vscode-textmate": "^10.0.2", @@ -2242,15 +2289,15 @@ } }, "node_modules/astro": { - "version": "7.0.5", - "resolved": "https://registry.npmjs.org/astro/-/astro-7.0.5.tgz", - "integrity": "sha512-KR/zBBgU6I+F5vDoTsuTbXbBmI565CToDOgPr0pPiL2Hgrvx4CV8Cg2wtT6VqqyOS7BIfBkdagKD+40SojGl7w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/astro/-/astro-7.0.6.tgz", + "integrity": "sha512-Myw0sFia+zs/Y0yqfZEsUYXfDPh3ELcLf1f0Q/qQzVXBh/af1qO62WNT+P89DCcfGVV51nMoQhEfkBYqJmoUOQ==", "dev": true, "license": "MIT", "dependencies": { "@astrojs/compiler-rs": "^0.3.0", - "@astrojs/internal-helpers": "0.10.0", - "@astrojs/markdown-satteri": "0.3.2", + "@astrojs/internal-helpers": "0.10.1", + "@astrojs/markdown-satteri": "0.3.3", "@astrojs/telemetry": "3.3.2", "@capsizecss/unpack": "^4.0.0", "@clack/prompts": "^1.1.0", @@ -2318,7 +2365,7 @@ "sharp": "^0.34.0 || ^0.35.0" }, "peerDependencies": { - "@astrojs/markdown-remark": "7.2.0" + "@astrojs/markdown-remark": "7.2.1" }, "peerDependenciesMeta": { "@astrojs/markdown-remark": { @@ -2728,6 +2775,19 @@ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" } }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/domelementtype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", @@ -2783,10 +2843,9 @@ } }, "node_modules/entities": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", - "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", - "dev": true, + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", + "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", "license": "BSD-2-Clause", "engines": { "node": ">=0.12" @@ -4624,9 +4683,9 @@ } }, "node_modules/p-queue": { - "version": "9.3.0", - "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.0.tgz", - "integrity": "sha512-7NED7xhQ74Ngp4JP/2e0VZHp7vSWfJfqeiR92jPgxsz6m0Se4P03YoTKa9dDXyZ3r6P616gUXttrB6nnHYKang==", + "version": "9.3.1", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.3.1.tgz", + "integrity": "sha512-POWdiIPmsUPGwb4FeQ4OBg46aqmcInSWe45CKDsGHiOBiVQM9chqfQTuqhuTzcg2Vz9faTI65at0KkVyVEiCHw==", "dev": true, "license": "MIT", "dependencies": { @@ -4690,18 +4749,6 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, - "node_modules/parse5/node_modules/entities": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/entities/-/entities-6.0.1.tgz", - "integrity": "sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=0.12" - }, - "funding": { - "url": "https://github.com/fb55/entities?sponsor=1" - } - }, "node_modules/piccolore": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/piccolore/-/piccolore-0.1.3.tgz", @@ -4717,9 +4764,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "license": "MIT", "engines": { "node": ">=12" @@ -5145,17 +5192,17 @@ } }, "node_modules/shiki": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.3.0.tgz", - "integrity": "sha512-NKKjWzR6LIGL3sXBrWDw9sDS9cxx42/DkysaNqJEeOWE8Kix5gpak0bc00OfDVEO4oyXSyz8+aRaqKoBD1yo7A==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/shiki/-/shiki-4.3.1.tgz", + "integrity": "sha512-oR+qDVi2OjX1tmDpyv+3KviX01KzO6Af+0NNnKnsp9491UEGz2YpxTuJboS/6VhYpTdqzmuJBuiTlrAWWJAssw==", "license": "MIT", "dependencies": { - "@shikijs/core": "4.3.0", - "@shikijs/engine-javascript": "4.3.0", - "@shikijs/engine-oniguruma": "4.3.0", - "@shikijs/langs": "4.3.0", - "@shikijs/themes": "4.3.0", - "@shikijs/types": "4.3.0", + "@shikijs/core": "4.3.1", + "@shikijs/engine-javascript": "4.3.1", + "@shikijs/engine-oniguruma": "4.3.1", + "@shikijs/langs": "4.3.1", + "@shikijs/themes": "4.3.1", + "@shikijs/types": "4.3.1", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" }, diff --git a/package.json b/package.json index 018b6807..1b4297b4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "next2d-web-site", "type": "module", "description": "Next2D project provides a WebGL/WebGPU 2D rendering engine, animation tools for creating animations, and a framework to support team development.", - "version": "2.1.1", + "version": "2.1.2", "author": "Toshiyuki Ienaga", "license": "Next2D", "scripts": { @@ -14,7 +14,7 @@ "devDependencies": { "@astrojs/sitemap": "^3.7.3", "aos": "^2.3.4", - "astro": "^7.0.5", + "astro": "^7.0.6", "bootstrap": "^5.3.8", "bootstrap-icons": "^1.13.1", "typescript": "^6.0.3", @@ -24,6 +24,6 @@ "lodash": "^4.17.21" }, "dependencies": { - "@astrojs/markdown-remark": "^7.2.0" + "@astrojs/markdown-remark": "^7.2.1" } } diff --git a/public/assets/js/next2d.js b/public/assets/js/next2d.js index 5a04e0ce..09b8e8ca 100644 --- a/public/assets/js/next2d.js +++ b/public/assets/js/next2d.js @@ -1,2358 +1,20 @@ -const on="__next2d__",Ze=Math.min(2,window.devicePixelRatio),Vt=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},Er=document.createElement("canvas");Er.width=Er.height=1;const Tr=Er.getContext("2d");let ci=null;const _s=e=>{ci=e};let li=null;const Ds=e=>{li=e},ui=()=>li,vt=()=>ci,ft=new Float32Array([1,0,0,1,0,0]),gt=new Float32Array([1,0,0,1,0,0]),ie={x:0,y:0,pointer:"",hit:null};let hi=null;const Cn=e=>{hi=e},fi=()=>hi,Ls=(e,t=1)=>{let r="";r+="-webkit-tap-highlight-color: rgba(0,0,0,0);",r+="backface-visibility: hidden;",r+="touch-action: none;",r+="user-select: none;",r+="-webkit-user-select: none;",r+="-webkit-touch-callout: none;",t>1&&(r+=`transform: scale(${1/t});`),e.width=1,e.height=1,e.setAttribute("style",r)},di=`(function(){"use strict";let ut=2048;const Xc=t=>{ut=Math.max(2048,t/2)};let bs=4;const Yc=t=>{bs=t};let p;const Wc=t=>{p=t};let O;const jc=t=>{O=t};let Pn=!1;const It=()=>{Pn||(Pn=!0,p.enable(p.SCISSOR_TEST))},yt=()=>{Pn&&(Pn=!1,p.disable(p.SCISSOR_TEST))};let An=!1;const Yr=()=>{An||(An=!0,p.enable(p.STENCIL_TEST))},Wr=()=>{An&&(An=!1,p.disable(p.STENCIL_TEST))},jr=(t,e,r,n=null)=>{const s=+t;return isNaN(s)&&n!==null?n:Math.min(Math.max(e,isNaN(s)?0:s),r)},li=[],Hr=(...t)=>{const e=li.pop()||[];return t.length&&e.push(...t),e},ui=(t=null)=>{t&&(t.length&&(t.length=0),li.push(t))},Fn=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),fi=[],hi=(t=0,e=0,r=0,n=0)=>{const s=fi.pop()||new Float32Array(4);return s[0]=t,s[1]=e,s[2]=r,s[3]=n,s},di=t=>{fi.push(t)},pi=[],xs=(t=0,e=0,r=0,n=0,s=0,o=0,i=0,l=0,c=0)=>{const u=pi.pop()||new Float32Array(9);return u[0]=t,u[1]=e,u[2]=r,u[3]=n,u[4]=s,u[5]=o,u[6]=i,u[7]=l,u[8]=c,u},Hc=t=>{pi.push(t)},mi=[],dr=(t=0,e=0,r=0,n=0,s=0,o=0)=>{const i=mi.pop()||new Float32Array(6);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i[4]=s,i[5]=o,i},Kr=t=>{mi.push(t)},ys=t=>{const e=1/(t[0]*t[4]-t[3]*t[1]),r=t[3]*t[7]-t[4]*t[6],n=t[1]*t[6]-t[0]*t[7];return xs(t[4]*e,0-t[1]*e,0,0-t[3]*e,t[0]*e,0,r*e,n*e,1)};let pt=0,mt=0;const Kc=(t,e)=>{pt=t,mt=e},qc=t=>{const e=-819.2*t[0]-819.2*t[2]+t[4],r=819.2*t[0]-819.2*t[2]+t[4],n=-819.2*t[0]+819.2*t[2]+t[4],s=-819.2*t[1]-819.2*t[3]+t[5],o=819.2*t[1]-819.2*t[3]+t[5],i=-819.2*t[1]+819.2*t[3]+t[5];let l=n-e,c=i-s;const u=Math.sqrt(l*l+c*c);u?(l=l/u,c=c/u):(l=0,c=0);const a=(r-e)*l+(o-s)*c;return hi(e+a*l,s+a*c,r,o)};let vt=1;const Qc=t=>{vt=t},Zc=(t,e)=>{const r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],l=t[5],c=e[0],u=e[1],a=e[2],h=e[3],d=e[4],g=e[5];return dr(r*c+s*u,n*c+o*u,r*a+s*h,n*a+o*h,r*d+s*g+i,n*d+o*g+l)},Jc=()=>typeof crypto?.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)}),me=Hr(),Kt=Hr(),pr=(t=!1)=>{const e=t?6:9;me.length>=e&&Kt.push(me.slice(0)),me.length=0;const r=[];for(let n=0;n=e&&r.push(s)}return Kt.length=0,r},el=()=>{for(me.length=0;Kt.length;)ui(Kt.pop())},mr=(t,e,r)=>{me.push(t,e,r)},qr=(t,e)=>{const r=me.length,n=+me[r-3],s=+me[r-2];return t===n&&e===s},tl=()=>{if(me.length<3){me.length=0;return}Kt.push(me.slice(0)),me.length=0},wn=(t,e)=>{if(!me.length){mr(t,e,!1);return}qr(t,e)||(tl(),mr(t,e,!1))},rl=(t,e)=>{me.length||wn(t,e),!qr(t,e)&&mr(t,e,!1)},gi=(t,e,r,n)=>{me.length||wn(0,0),!qr(r,n)&&(mr(t,e,!0),mr(r,n,!1))},nl=()=>{if(me.length<7)return;const t=+me[0],e=+me[1];qr(t,e)||mr(t,e,!1)};let Re=new Float32Array(64),bi=0;const vs=.5,Ms=2,sl=8,ol=(t,e,r,n,s,o,i,l)=>{const c=3*r-2*t-i,u=3*n-2*e-l,a=3*s-2*i-t,h=3*o-2*l-e;return Math.max(c*c+u*u,a*a+h*h)},il=(t,e,r,n,s,o,i,l)=>{const c=ol(t,e,r,n,s,o,i,l);if(c{Re.length{bi=t},Ss=[];let $s=0;const xi=()=>{$s=0},Se=()=>($s>=Ss.length&&Ss.push(new Float32Array(8)),Ss[$s++]),ft=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=1-c,d=h*t+c*r,g=h*e+c*n,m=h*r+c*s,f=h*n+c*o,b=h*s+c*i,x=h*o+c*l,y=h*d+c*m,P=h*g+c*f,S=h*m+c*b,M=h*f+c*x,$=h*y+c*S,T=h*P+c*M;u[0]=t,u[1]=e,u[2]=d,u[3]=g,u[4]=y,u[5]=P,u[6]=$,u[7]=T,a[0]=$,a[1]=T,a[2]=S,a[3]=M,a[4]=b,a[5]=x,a[6]=i,a[7]=l},Ye=(t,e,r,n,s,o,i,l,c,u)=>{const a=(3*r+3*s-t-i)*.25,h=(3*n+3*o-e-l)*.25;c[u]=a,c[u+1]=h,c[u+2]=i,c[u+3]=l},Mt=new Float32Array(8),St=new Float32Array(8),ll=(t,e,r,n,s,o,i,l)=>{const c=il(t,e,r,n,s,o,i,l),u=c*4;al(u);let a=0;if(c<=2)ft(t,e,r,n,s,o,i,l,.5,Mt,St),Ye(Mt[0],Mt[1],Mt[2],Mt[3],Mt[4],Mt[5],Mt[6],Mt[7],Re,a),a+=4,Ye(St[0],St[1],St[2],St[3],St[4],St[5],St[6],St[7],Re,a),a+=4;else if(c<=4){xi();const h=Se(),d=Se();ft(t,e,r,n,s,o,i,l,.5,h,d);const g=Se(),m=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,g,m),ft(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,f,b),Ye(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],Re,a),a+=4,Ye(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],Re,a),a+=4,Ye(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],Re,a),a+=4,Ye(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],Re,a),a+=4}else{xi();const h=Se(),d=Se();ft(t,e,r,n,s,o,i,l,.5,h,d);const g=Se(),m=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,g,m),ft(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,f,b);const x=Se(),y=Se(),P=Se(),S=Se(),M=Se(),$=Se(),T=Se(),w=Se();ft(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],.5,x,y),ft(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],.5,P,S),ft(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],.5,M,$),ft(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],.5,T,w),Ye(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],Re,a),a+=4,Ye(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],Re,a),a+=4,Ye(P[0],P[1],P[2],P[3],P[4],P[5],P[6],P[7],Re,a),a+=4,Ye(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],Re,a),a+=4,Ye(M[0],M[1],M[2],M[3],M[4],M[5],M[6],M[7],Re,a),a+=4,Ye($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],Re,a),a+=4,Ye(T[0],T[1],T[2],T[3],T[4],T[5],T[6],T[7],Re,a),a+=4,Ye(w[0],w[1],w[2],w[3],w[4],w[5],w[6],w[7],Re,a),a+=4}return cl(a/4),{buffer:Re,count:bi}},Qr=(t,e,r,n,s,o)=>{if(me.length||wn(0,0),qr(s,o))return;const i=me.length,l=+me[i-3],c=+me[i-2],u=ll(l,c,t,e,r,n,s,o),a=u.buffer,h=u.count;for(let d=0;d{const n=r,s=r*.5522847498307936;Qr(t+n,e+s,t+s,e+n,t,e+n),Qr(t-s,e+n,t-n,e+s,t-n,e),Qr(t-n,e-s,t-s,e-n,t,e-n),Qr(t+s,e-n,t+n,e-s,t+n,e)},fl=(t,e,r,n,s)=>{t.$clearColorR=jr(e,0,1,0),t.$clearColorG=jr(r,0,1,0),t.$clearColorB=jr(n,0,1,0),t.$clearColorA=jr(s,0,1,0)},hl=(t,e,r,n)=>{p.clearColor(t,e,r,n),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),p.clearColor(0,0,0,0)},$t=[],yi=t=>{let e=-1,r=$t.length;for(;Math.abs(r-e)>1;){const n=Math.floor((r+e)/2);t<=$t[n].area?r=n:e=n}return r},dl=t=>{if($t.indexOf(t)>-1)return;const e=yi(t.area);t.dirty=!0,$t.splice(e,0,t)},ae=t=>{p.deleteTexture(t.resource)},et=[],pl=t=>{if(!(et.indexOf(t)>-1)){if(et.length>10){p.deleteRenderbuffer(t.resource);return}t.dirty=!0,et.push(t)}},Ts=[];let Tt;const ml=t=>{Tt=t.createFramebuffer()};let vi=null;const gl=t=>{vi=t.createFramebuffer()};let On=null;const bl=(t,e)=>{On=t.createFramebuffer(),t.bindFramebuffer(t.FRAMEBUFFER,On),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.resource,0),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,On)};let Bs=null;const Mi=t=>{Bs=t};let Ps=!1;const As=t=>{Ps=t};let Fs=null,Zr=null,Si=null,$i=null;const xl=t=>{Zr=t.createFramebuffer(),Fs=t.createFramebuffer(),Si=t.createFramebuffer(),$i=t.createBuffer(),t.bindBuffer(t.PIXEL_PACK_BUFFER,$i)},be=(t,e=!0)=>{t.msaa?(dl(t.color),t.color=null,t.stencil=null):(e&&ae(t.texture),t.texture=null,pl(t.stencil),t.stencil=null),Ts.push(t)};let yl=0;const vl=()=>({id:yl++,width:0,height:0,clipLevel:0,msaa:!1,mask:!1,color:null,texture:null,stencil:null}),Ml=()=>{const t={id:0,resource:p.createRenderbuffer(),width:0,height:0,area:0,dirty:!1};return{resource:p.createRenderbuffer(),stencil:t,width:0,height:0,area:0,dirty:!1}},Sl=t=>{if(!$t.length)return Ml();const e=yi(t);if(e<$t.length){const n=$t[e];return $t.splice(e,1),n}const r=$t.shift();if(!r)throw new Error("the color buffer is void.");return r},$l=(t,e)=>{t=Math.max(256,Fn(t)),e=Math.max(256,Fn(e));const r=Sl(t*e);return(r.width({id:Tl++,resource:p.createRenderbuffer(),width:0,height:0,area:0,dirty:!1}),Pl=(t,e)=>{if(!et.length)return Bl();let r=-1,n=1/0;for(let s=0;s=t&&o.height>=e&&o.area{const r=Pl(t,e);return(r.width!==t||r.height!==e)&&(r.width=t,r.height=e,r.area=t*e,r.dirty=!1,p.bindRenderbuffer(p.RENDERBUFFER,r.resource),p.renderbufferStorage(p.RENDERBUFFER,p.STENCIL_INDEX8,t,e)),r};let Fl=0;const Ti=(t,e)=>({id:Fl++,resource:p.createTexture(),width:t,height:e,area:t*e,smooth:!1});let gr=-1;const Bi=t=>{gr=t},ws=[null,null,null],wl=(t,e=!1)=>{gr!==p.TEXTURE0&&(Bi(p.TEXTURE0),p.activeTexture(p.TEXTURE0)),ws[0]=t,p.bindTexture(p.TEXTURE_2D,t.resource),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,e?p.LINEAR:p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,e?p.LINEAR:p.NEAREST),p.texStorage2D(p.TEXTURE_2D,1,p.RGBA8,t.width,t.height)},Jr=(t,e,r=!1)=>{const n=Ti(t,e);return wl(n,r),n},we=(t,e,r=!1)=>{const n=Ts.length?Ts.pop():vl();return n.width=t,n.height=e,r?(n.msaa=!0,n.texture=null,n.color=$l(t,e),n.stencil=n.color.stencil):(n.msaa=!1,n.texture=Jr(t,e),n.color=null,n.stencil=Al(t,e)),n.mask=!1,n.clipLevel=0,n},Ol=()=>{Mi(null),Ps&&(As(!1),p.bindFramebuffer(p.FRAMEBUFFER,null))},El=()=>{const t=Ti(ut,ut);return p.activeTexture(p.TEXTURE3),p.bindTexture(p.TEXTURE_2D,t.resource),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.LINEAR),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texStorage2D(p.TEXTURE_2D,1,p.RGBA8,t.width,t.height),p.activeTexture(gr!==-1?gr:p.TEXTURE0),t},Os=Number.MAX_VALUE,Es=-Number.MAX_VALUE;let qt=0;const Qt=t=>{qt=t},En=[],Rl=()=>En,Cl=t=>{En[qt]=t},Ul=()=>(qt in En||Cl(we(ut,ut,!0)),En[qt]),br=[];let Rs=null;const Pi=()=>(Rs||(Rs=El()),Rs),en=[],Ai=t=>(t in en||(en[t]=new Float32Array([Os,Os,Es,Es])),en[t]),Gl=()=>{for(let t=0;t{Cs=t},Ll=()=>{br.length=0,Qt(0);const t=Rl();for(let e=0;e{if(t.clearArraysInstanced(),t.$stackAttachmentObject.length)for(let s=0;s{It(),p.scissor(t,e,r,n),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),yt()},Ke=(t,e,r=null,n=!1)=>{(gr===-1||e!==gr)&&(Bi(e),p.activeTexture(e));const s=ws[t];s!==null&&r!==null&&s.id===r.id||r===s||(ws[t]=r,p.bindTexture(p.TEXTURE_2D,r?r.resource:null),r&&r.smooth!==n&&(r.smooth=n,p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,n?p.LINEAR:p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,n?p.LINEAR:p.NEAREST)))},$e=(t,e=!1)=>{Ke(2,p.TEXTURE2,null),Ke(1,p.TEXTURE1,null),Ke(0,p.TEXTURE0,t,e)},_l=t=>{Mi(t),Ps||(As(!0),p.bindFramebuffer(p.FRAMEBUFFER,Tt)),t.msaa?(p.bindRenderbuffer(p.RENDERBUFFER,t.color.resource),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.RENDERBUFFER,t.color.resource)):($e(t.texture),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,t.texture.resource,0),Ke(0,p.TEXTURE0,null)),p.bindRenderbuffer(p.RENDERBUFFER,t.stencil.resource),p.framebufferRenderbuffer(p.FRAMEBUFFER,p.STENCIL_ATTACHMENT,p.RENDERBUFFER,t.stencil.resource)},Us=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=t.clipLevel;let r=0;for(let n=0;n{wi=t},Gs=()=>wi,tn=new Map,rn=new Map,Vl=t=>{!t&&Gs()?(Rn(!1),Wr(),yt()):t&&!Gs()&&(Rn(!0),Yr(),Us())},Dl=(t,e)=>{const r=Bs;if(r&&e.id===r.id)return;_l(e),(!r||r.width!==e.width||r.height!==e.height)&&(Kc(e.width,e.height),p.viewport(0,0,e.width,e.height));const n=e.msaa?e.color:e.stencil;n.dirty&&(n.dirty=!1,t.clearRect(0,0,e.width,e.height)),Vl(e.mask)},Nl=t=>{t.$stack.push(xs(...t.$matrix))},zl=t=>{if(!t.$stack.length)return;const e=t.$stack.pop();t.$matrix[0]=e[0],t.$matrix[1]=e[1],t.$matrix[3]=e[3],t.$matrix[4]=e[4],t.$matrix[6]=e[6],t.$matrix[7]=e[7],Hc(e)},Xl=(t,e,r,n,s,o,i)=>{t[0]=e,t[1]=r,t[3]=n,t[4]=s,t[6]=o,t[7]=i},Yl=(t,e,r,n,s,o,i)=>{const l=t.$matrix[0],c=t.$matrix[1],u=t.$matrix[3],a=t.$matrix[4],h=t.$matrix[6],d=t.$matrix[7];t.$matrix[0]=e*l+r*u,t.$matrix[1]=e*c+r*a,t.$matrix[3]=n*l+s*u,t.$matrix[4]=n*c+s*a,t.$matrix[6]=o*l+i*u+h,t.$matrix[7]=o*c+i*a+d},Wl=t=>{t.globalAlpha=1,t.globalCompositeOperation="normal",t.imageSmoothingEnabled=!1},jl=t=>{t.$fillStyle.fill(1),t.$strokeStyle.fill(1)},Hl=(t,e,r,n)=>{It(),p.scissor(t,e,r+1,n+1),p.clear(p.COLOR_BUFFER_BIT|p.STENCIL_BUFFER_BIT),p.scissor(t,e,r,n)},Kl=()=>{yt()},ql=(t,e,r,n,s,o,i,l,c,u,a,h,d)=>{const g=t.length-5;for(let m=3;m(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t);let nn=new Float32Array(128),xr=0;const Ql=()=>nn,Zl=()=>xr,yr=t=>{const e=t.length+xr;if(e>nn.length){const r=new Float32Array(Oi(e));r.set(nn),r.set(t,xr),nn=r}else nn.set(t,xr);xr+=t.length},We=[],Bt=[],Ei=()=>{Bt.length=0,xr=0,We.length=0};let Ls=new Float32Array(32);const Jl=t=>(Ls.length{const r=e==="fill"?O.$fillStyle:O.$strokeStyle,n=r[0],s=r[1],o=r[2],i=r[3],l=O.$matrix,c=pt,u=mt,a=l[0]/c,h=l[3]/c,d=l[6]/c,g=l[1]/u,m=l[4]/u,f=l[7]/u;let b=0;for(let P=0;P{const e=pr();if(!e.length)return;Bt.push(t);const r=Cn(e);yr(r.buffer),We.push(r.indexCount)},qe=[],tu=(t,e,r,n,s,o)=>{const i=pr();if(!i.length)return;Bt.push(t===0?"linear":"radial");const l=Cn(i);yr(l.buffer),We.push(l.indexCount),qe.push(e,r,n,s),t===1&&qe.push(o)},ru=(t,e,r)=>{const n=Math.sqrt(t*t+e*e);return{x:-(e/n)*r,y:t/n*r}},nu=(t,e,r)=>{const n={x:e.x-t.x,y:e.y-t.y},s=ru(n.x,n.y,r),o={x:t.x+s.x,y:t.y+s.y},i={x:e.x+s.x,y:e.y+s.y},l={x:t.x-s.x,y:t.y-s.y},c={x:e.x-s.x,y:e.y-s.y};return[o.x,o.y,!1,i.x,i.y,!1,c.x,c.y,!1,l.x,l.y,!1,o.x,o.y,!1]},ks=(t,e,r)=>({x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}),su=(t,e,r,n=.5)=>{const s=ks(t,e,n),o=ks(e,r,n),i=ks(s,o,n);return[[t,s,i],[i,o,r]]},ou=(t,e,r,n=4)=>{let s=[[t,e,r]];for(let o=0;o({x:(1-t)**2*e.x+2*(1-t)*t*r.x+t**2*n.x,y:(1-t)**2*e.y+2*(1-t)*t*r.y+t**2*n.y}),au=(t,e,r,n)=>({x:2*(1-t)*(r.x-e.x)+2*t*(n.x-r.x),y:2*(1-t)*(r.y-e.y)+2*t*(n.y-r.y)}),cu=t=>{const e=Math.sqrt(t.x*t.x+t.y*t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},Ri=(t,e,r,n)=>{const s=[0,.5,1],o=[];for(let i=0;i{const s=ou(t,e,r,5),o=[],i=[];for(let h=0;h{const s=[];for(let i=0;i1e-4||s.push(l,c)}return s},Mr=new OffscreenCanvas(1,1).getContext("2d"),Sr=(t,e)=>{Mr.beginPath(),Mr.moveTo(e[0],e[1]);for(let r=3;r{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=n[o].length>15,c=n[i].length>15;if(l&&c)return;const u=vr(t,e,r,n[o]),a=vr(t,e,r,n[i]),h=Sr(u,n[i]);if(!h)return;const d=Sr(a,n[o]);if(!d)return;const g=Math.atan2(h[1]-e,h[0]-t);let f=Math.atan2(d[1]-e,d[0]-t)-g;f>Math.PI?f-=2*Math.PI:f<-Math.PI&&(f+=2*Math.PI);const b=Math.abs(f);if(b<.1||b>Math.PI-.1)return;const x=8,y=f/x,P=[t,e,!1];for(let S=0;S<=x;S++){const M=g+S*y,$=t+r*Math.cos(M),T=e+r*Math.sin(M);P.push($,T,!1)}n.splice(-1,0,P)},Ui=(t,e,r,n,s=!1)=>{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=n[o].length>15,c=n[i].length>15;if(l&&c)return;const u=vr(t,e,r,n[o]),a=vr(t,e,r,n[i]);if(u[0]===a[0]&&u[1]===a[1]||u[0]===a[2]&&u[1]===a[3])return;const h=Sr(u,n[i]);if(!h)return;const d=Sr(a,n[o]);d&&n.splice(-1,0,[t,e,!1,h[0],h[1],!1,d[0],d[1],!1,t,e,!1])},uu=(t,e,r)=>{for(let n=0;n<2;++n){let s=0,o=0,i=0,l=0;n===0?(s=t[0],o=t[1],i=t[3],l=t[4]):(s=t[t.length-3],o=t[t.length-2],i=t[t.length-6],l=t[t.length-5]);const c=i-s,u=l-o,a=Math.atan2(u,c),h=a+Math.PI/2,d=a-Math.PI/2,g=16,m=(d-h)/g,f=[];for(let b=0;b<=g;b++){const x=d+m*b,y=s+e*Math.cos(x),P=o+e*Math.sin(x);f.push(y,P,!1)}n===0?r.unshift(f):r.push(f)}},fu=(t,e,r)=>{for(let n=0;n<2;++n){let s=0,o=0,i=0,l=0;n===0?(s=t[0],o=t[1],i=t[3],l=t[4]):(s=t[t.length-3],o=t[t.length-2],i=t[t.length-6],l=t[t.length-5]);const c=-(i-s),u=-(l-o),a=Math.sqrt(c*c+u*u);if(a===0)continue;const h=c/a,d=u/a,g=s+e*h,m=o+e*d,f=-d,b=h,x=[g+e*h+e*f,m+e*d+e*b,!1,g+e*h-e*f,m+e*d-e*b,!1,g-e*h-e*f,m-e*d-e*b,!1,g+e*h+e*f,m+e*d+e*b,!1,g-e*h-e*f,m-e*d-e*b,!1,g-e*h+e*f,m-e*d+e*b,!1];n===0?r.unshift(x):r.push(x)}},Gi=(t,e,r,n,s,o=!1)=>{const i=o?0:s.length-1,l=o?s.length-1:s.length-2,c=s[i].length>15,u=s[l].length>15;if(c&&u)return;const a=vr(t.x,t.y,n,s[i]),h=vr(t.x,t.y,n,s[l]);if(a[0]===h[0]&&a[1]===h[1]||a[0]===h[2]&&a[1]===h[3])return;const d=Sr(a,s[l]);if(!d)return;const g=Sr(h,s[i]);if(!g)return;const m=e.x-t.x,f=e.y-t.y,b=Math.hypot(m,f),x={x:m/b,y:f/b},y=r.x-t.x,P=r.y-t.y,S=Math.hypot(y,P),M={x:y/S,y:P/S},$=x.x,T=x.y,w=M.x,E=M.y,F=$*E-T*w;if(F===0){s.splice(-1,0,[t.x,t.y,!1,d[0],d[1],!1,g[0],g[1],!1]);return}const A=((g[0]-d[0])*E-(g[1]-d[1])*w)/F,R=d[0]+A*$,v=d[1]+A*T;s.splice(-1,0,[t.x,t.y,!1,d[0],d[1],!1,R,v,!1,t.x,t.y,!1,g[0],g[1],!1,R,v,!1])},hu={x:0,y:0},du={x:0,y:0},pu={x:0,y:0},mu={x:0,y:0},gu=(t,e)=>{const r=hu;r.x=t[0],r.y=t[1];const n=du;n.x=0,n.y=0;const s=pu;s.x=0,s.y=0;const o=mu;o.x=0,o.y=0;const i=[];for(let g=3;g1)switch(O.joints){case 0:Ui(r.x,r.y,e,i);break;case 1:o.x=t[g-6],o.y=t[g-5],Gi(r,s,o,e,i);break;case 2:Ci(r.x,r.y,e,i);break}r.x=s.x,r.y=s.y}const l=t[0],c=t[1],u=t[t.length-3],a=t[t.length-2],h=1e-4;if(Math.abs(l-u)1)switch(O.joints){case 0:Ui(l,c,e,i,!0);break;case 1:r.x=l,r.y=c,s.x=t[3],s.y=t[4],o.x=t[t.length-6],o.y=t[t.length-5],Gi(r,s,o,e,i,!0);break;case 2:Ci(l,c,e,i,!0);break}else switch(O.caps){case 1:uu(t,e,i);break;case 2:fu(t,e,i);break}return i},Is=t=>{const e=O.thickness/2,r=Hr();for(let s=0;s{const i=pr(!0);if(!i.length)return;Bt.push(t===0?"linear":"radial");const l=Is(i);yr(l.buffer),We.push(l.indexCount),qe.push(e,r,n,s),t===1&&qe.push(o)},$r=new Map,Li=()=>{$r.clear()},xu=t=>{$r.set(We.length,t)},Un=()=>({id:Jc(),resource:p.createVertexArray(),vertexBuffer:p.createBuffer(),vertexLength:0});let _s;const Pt=t=>{_s&&_s.id===t.id||(_s=t,p.bindVertexArray(t.resource))},yu=()=>{const t=Un();Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer);const e=new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]);return p.bufferData(p.ARRAY_BUFFER,e,p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),t},Gn=[],tt=new Float32Array([0,0,0,1,1,0,1,1]);let Vs;const vu=t=>{Vs=t.createBuffer()};let ki;const Mu=t=>{ki=t};let Ds;const Ln=()=>(Ds||(Ds=yu()),Ds),Su=()=>{if(Gn.length)return Gn.pop();const t=Un();return Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),p.enableVertexAttribArray(0),p.enableVertexAttribArray(1),p.enableVertexAttribArray(2),p.enableVertexAttribArray(3),p.enableVertexAttribArray(4),p.enableVertexAttribArray(5),p.vertexAttribPointer(0,2,p.FLOAT,!1,68,0),p.vertexAttribPointer(1,2,p.FLOAT,!1,68,8),p.vertexAttribPointer(2,4,p.FLOAT,!1,68,16),p.vertexAttribPointer(3,3,p.FLOAT,!1,68,32),p.vertexAttribPointer(4,3,p.FLOAT,!1,68,44),p.vertexAttribPointer(5,3,p.FLOAT,!1,68,56),t},Ii=()=>{const t=Su();Pt(t);const e=Ql(),r=Zl();return p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),t.vertexLength{Gn.indexOf(t)>-1||Gn.push(t)};let $u=0;const Tu=(t,e)=>{const r=p.createProgram(),n=p.createShader(p.VERTEX_SHADER);p.shaderSource(n,t),p.compileShader(n);const s=p.createShader(p.FRAGMENT_SHADER);return p.shaderSource(s,e),p.compileShader(s),p.attachShader(r,n),p.attachShader(r,s),p.linkProgram(r),p.detachShader(r,n),p.detachShader(r,s),p.deleteShader(n),p.deleteShader(s),{id:$u++,resource:r}},Bu=(t,e,r=!1)=>{const n=p.getProgramParameter(t,p.ACTIVE_UNIFORMS);for(let s=0;s{Vi!==t.id&&(Vi=t.id,p.useProgram(t.resource))},Au=t=>{for(const e of t.values())e.method===void 0||e.assign===void 0||(e.assign<0?e.method(e.array):e.assign>0&&(e.assign--,e.method(e.array)))};class _e{_$programObject;_$uniformMap;highp;mediump;textures;constructor(e,r,n=!1){this._$programObject=Tu(e,r),this._$uniformMap=new Map,Bu(this._$programObject.resource,this._$uniformMap,n);const s=new Float32Array(0);this.highp=this._$uniformMap.get("u_highp")?.array??s,this.mediump=this._$uniformMap.get("u_mediump")?.array??s,this.textures=this._$uniformMap.get("u_textures")?.array??s}useProgram(){Pu(this._$programObject)}bindUniform(){Au(this._$uniformMap)}}const At=new Map,Fu=()=>\` -vec2 applyMatrix(in vec2 vertex) { - mat3 matrix = mat3(a_matrix0, a_matrix1, a_matrix2); - return (matrix * vec3(vertex, 1.0)).xy; -}\`,wu=t=>\` -vec2 applyMatrix(in vec2 vertex) { - mat3 parent_matrix = mat3( - u_highp[\${t}].xyz, - u_highp[\${t+1}].xyz, - u_highp[\${t+2}].xyz - ); - mat3 ancestor_matrix = mat3( - u_highp[\${t+3}].xyz, - u_highp[\${t+4}].xyz, - u_highp[\${t+5}].xyz - ); - - vec2 parent_offset = vec2(u_highp[\${t+2}].w, u_highp[\${t+3}].w); - vec2 parent_size = vec2(u_highp[\${t+4}].w, u_highp[\${t+5}].w); - vec4 grid_min = u_highp[\${t+6}]; - vec4 grid_max = u_highp[\${t+7}]; - - vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy; - position = (position - parent_offset) / parent_size; - - vec4 ga = grid_min; - vec4 gb = grid_max - grid_min; - vec4 gc = vec4(1.0) - grid_max; - - vec2 pa = position; - vec2 pb = position - grid_min.st; - vec2 pc = position - grid_max.st; - - position = (ga.pq / ga.st) * min(pa, ga.st) - + (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st) - + (gc.pq / gc.st) * max(vec2(0.0), pc); - - position = position * parent_size + parent_offset; - position = (ancestor_matrix * vec3(position, 1.0)).xy; - - position = position + vec2(u_highp[\${t+8}].x, u_highp[\${t+8}].y); - return position / vec2(u_highp[0].w, u_highp[1].w); -}\`,Ou=()=>"layout (location = 1) in vec2 a_bezier;",Eu=()=>\`layout (location = 3) in vec3 a_matrix0; -layout (location = 4) in vec3 a_matrix1; -layout (location = 5) in vec3 a_matrix2;\`,Ru=()=>"out vec2 v_uv;",Cu=()=>"out vec2 v_bezier;",Uu=()=>\` - mat3 uv_matrix = mat3( - u_highp[0].xyz, - u_highp[1].xyz, - u_highp[2].xyz - ); - mat3 inverse_matrix = mat3( - u_highp[3].xyz, - u_highp[4].xyz, - vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w) - ); - v_uv = (inverse_matrix * uv_matrix * vec3(a_vertex, 1.0)).xy;\`,Gu=()=>"v_bezier = a_bezier;",Lu=()=>"layout (location = 2) in vec4 a_color;",ku=()=>"out vec4 v_color;",Iu=()=>"v_color = a_color;",kn=(t,e,r,n)=>{const s=r?Ou():"",o=r?Cu():e?Ru():"",i=r?Gu():e?Uu():"",l=n?wu(e?5:0):Fu(),c=r?"":Lu(),u=r?"":ku(),a=r?"":Iu(),h=n?"":Eu(),d=t>1?\`uniform vec4 u_highp[\${t}];\`:"";return\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -\${s} -\${c} -\${h} - -\${d} -\${o} -\${u} -\${l} - -void main() { - \${a} - \${i} - vec2 pos = applyMatrix(a_vertex); - pos = pos * 2.0 - 1.0; - gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0); -}\`},_u=()=>\`#version 300 es -layout (location = 0) in vec2 a_vertex; -void main() { - vec2 pos = a_vertex * 2.0 - 1.0; - gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0); -}\`,Vu=()=>\`#version 300 es -precision mediump float; - -in vec4 v_color; -out vec4 o_color; - -void main() { - o_color = vec4(v_color.rgb * v_color.a, v_color.a); -}\`,Du=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[1]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 uv = vec2(v_uv.x, u_mediump[0].y - v_uv.y) / u_mediump[0].xy; - - vec4 src = texture(u_texture, uv); - o_color = src; -}\`,Nu=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[1]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 uv = fract(vec2(v_uv.x, -v_uv.y) / u_mediump[0].xy); - - vec4 src = texture(u_texture, uv); - o_color = src; -}\`,zu=()=>\`#version 300 es -precision mediump float; - -in vec2 v_bezier; -out vec4 o_color; - -void main() { - float f_val = v_bezier.x * v_bezier.x - v_bezier.y; - - float dx = dFdx(f_val); - float dy = dFdy(f_val); - - float dist = f_val / length(vec2(dx, dy)); - float alpha = smoothstep(0.5, -0.5, dist); - - if (alpha > 0.001) { - o_color = vec4(min(alpha, 1.0)); - } else { - discard; - } -}\`,Xu=()=>\`#version 300 es -precision mediump float; -out vec4 o_color; -void main() { - o_color = vec4(1.0); -}\`,sn=t=>{const e=\`m\${t?"y":"n"}\`;if(At.has(e))return At.get(e);const r=new _e(kn(t?9:0,!1,!0,t),zu());return At.set(e,r),r},on=(t,e)=>{const r=t.highp;r[0]=e[0],r[1]=e[1],r[2]=0,r[4]=e[2],r[5]=e[3],r[6]=0,r[8]=e[4],r[9]=e[5],r[10]=1,r[12]=e[6],r[13]=e[7],r[14]=0,r[16]=e[8],r[17]=e[9],r[18]=0,r[20]=e[10],r[21]=e[11],r[22]=1,r[3]=pt,r[7]=mt,r[11]=e[12],r[15]=e[13],r[19]=e[14],r[23]=e[15],r[24]=e[16],r[25]=e[17],r[26]=e[18],r[27]=e[19],r[28]=e[20],r[29]=e[21],r[30]=e[22],r[31]=e[23],r[32]=e[24],r[33]=e[25]};let In="normal";const Di=t=>{In=t};let Ft=600;const _t=t=>{Ft=t},Ce=()=>{Ft!==613&&(_t(613),p.blendFunc(p.ONE,p.ONE_MINUS_SRC_ALPHA))},rt=(t,e,r,n)=>{t.useProgram(),t.bindUniform(),Ce(),Pt(e),p.drawArrays(p.TRIANGLES,r,n)},Ns=()=>{const t="rmnn";if(At.has(t))return At.get(t);const e=new _e(_u(),Xu());return At.set(t,e),e},Yu=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=1<{const t=O.currentAttachmentObject;if(!t)return;const e=tn.get(t.clipLevel),r=e[0],n=e[1],s=e[2],o=e[3],i=Math.ceil(Math.abs(s-r)),l=Math.ceil(Math.abs(o-n));It(),p.scissor(r,t.height-n-l,i,l);const c=Ii();let u=rn.get(t.clipLevel),a=0,h=null;const d=We.length;for(let g=0;g7&&(Yu(),u=t.clipLevel+1)}rn.set(t.clipLevel,u),_i(c),Ei(),Li(),yt()},ju=(t,e,r)=>{if(t.used){const l=t.left?.insert(e,r);return l||t.right?.insert(e,r)||null}if(e>t.w||r>t.h)return null;if(e===t.w&&r===t.h)return t.used=!0,t;const n=e+1,s=r+1,o=t.w-n,i=t.h-s;return o>i?(t.left=t.create(t.index,t.x,t.y,e,t.h),t.right=t.create(t.index,t.x+n,t.y,o,t.h)):(t.left=t.create(t.index,t.x,t.y,t.w,r),t.right=t.create(t.index,t.x,t.y+s,t.w,i)),t.used=!0,t.left.insert(e,r)},Hu=(t,e,r,n,s)=>t.left?.dispose(e,r,n,s)?(!t.left.used&&!t.right?.used&&(t.left&&t.left.release(),t.right&&t.right.release(),t.left=t.right=null,t.used=!1),!0):t.right?.dispose(e,r,n,s)?(!t.right.used&&!t.left?.used&&(t.left&&t.left.release(),t.right&&t.right.release(),t.left=t.right=null,t.used=!1),!0):e===t.x&&r===t.y&&n===t.w&&s===t.h?(t.used=!1,!0):!1,zs=[];class Xs{index;x;y;w;h;left;right;used;constructor(e,r,n,s,o){this.index=e,this.x=r,this.y=n,this.w=s,this.h=o,this.left=null,this.right=null,this.used=!1}insert(e,r){return ju(this,e,r)}dispose(e,r,n,s){return Hu(this,e,r,n,s)}create(e,r,n,s,o){const i=zs.length?zs.pop():new Xs(e,0,0,0,0);return i.index=e,i.x=r,i.y=n,i.w=s,i.h=o,i.left=null,i.right=null,i.used=!1,i}release(){this.left&&(this.left.release(),this.left=null),this.right&&(this.right.release(),this.right=null),this.used=!1,zs.push(this)}}class Ni{_$root;constructor(e,r,n){this._$root=new Xs(e,0,0,r,n)}insert(e,r){return this._$root.insert(e,r)}dispose(e,r,n,s){return this._$root.dispose(e,r,n,s)}}const Ys=(t,e)=>{const r=qt;br[r]||(br[r]=new Ni(r,ut,ut));const s=br[r].insert(t,e);if(s)return s;for(let o=0;o<10;o++){if(r===o)continue;Qt(o);const i=br[o];if(!i)return Ys(t,e);const l=i.insert(t,e);if(l)return l}return Ys(t,e)},Ku=t=>{const e=br[t.index];e&&e.dispose(t.x,t.y,t.w,t.h)},Ws=()=>\` -float isInside(in vec2 uv) { - return step(4.0, dot(step(vec4(0.0, uv.x, 0.0, uv.y), vec4(uv.x, 1.0, uv.y, 1.0)), vec4(1.0))); -}\`,zi=t=>\` - vec4 mul = u_mediump[\${t}]; - vec4 add = u_mediump[\${t+1}]; - - if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0 - || add.x != 0.0 || add.y != 0.0 || add.z != 0.0 - ) { - src.rgb /= max(0.0001, src.a); - src = clamp(src * mul + add, 0.0, 1.0); - src.rgb *= src.a; - } -\`,Xi=t=>{const e=t?"uniform vec4 u_mediump[2];":"",r=t?zi(0):"";return\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -\${e} - -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec4 src = texture(u_texture, v_coord); - \${r} - o_color = src; -}\`},qu=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; - -in vec4 v_mul; -in vec4 v_add; -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec4 src = texture(u_texture, v_coord); - - if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0 - || v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0 - ) { - src.rgb /= max(0.0001, src.a); - src = clamp(src * v_mul + v_add, 0.0, 1.0); - src.rgb *= src.a; - } - - o_color = src; -}\`,Qu=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t);class Zu{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...e){this.buffer.length\`#version 300 es - -layout (location = 0) in vec2 a_vertex; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - vec2 position = a_vertex * 2.0 - 1.0; - gl_Position = vec4(position, 0.0, 1.0); -}\`,ef=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -uniform vec4 u_highp[3]; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - mat3 matrix = mat3( - u_highp[0].x, u_highp[0].y, 0.0, - u_highp[0].z, u_highp[0].w, 0.0, - u_highp[1].x, u_highp[1].y, 1.0 - ); - - vec2 size = u_highp[1].zw; - vec2 viewport = vec2(u_highp[2].x, u_highp[2].y); - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * size; - position = (matrix * vec3(position, 1.0)).xy; - position /= viewport; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,tf=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -uniform vec4 u_highp[2]; - -out vec2 v_coord; - -void main() { - v_coord = a_vertex; - - vec2 offset = u_highp[0].xy; - vec2 size = u_highp[0].zw; - vec2 viewport = vec2(u_highp[1].x, u_highp[1].y); - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * size + offset; - position /= viewport; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,rf=()=>\`#version 300 es - -layout (location = 0) in vec2 a_vertex; -layout (location = 1) in vec4 a_rect; -layout (location = 2) in vec4 a_size; -layout (location = 3) in vec2 a_offset; -layout (location = 4) in vec4 a_matrix; -layout (location = 5) in vec4 a_mul; -layout (location = 6) in vec4 a_add; - -out vec2 v_coord; -out vec4 v_mul; -out vec4 v_add; - -void main() { - v_coord = a_vertex * a_rect.zw + a_rect.xy; - v_mul = a_mul; - v_add = a_add; - - vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y); - position = position * a_size.xy; - - mat3 matrix = mat3( - a_matrix.x, a_matrix.y, 0.0, - a_matrix.z, a_matrix.w, 0.0, - a_offset.x, a_offset.y, 1.0 - ); - - position = (matrix * vec3(position, 1.0)).xy; - position /= a_size.zw; - - position = position * 2.0 - 1.0; - gl_Position = vec4(position.x, -position.y, 0.0, 1.0); -}\`,nt=new Map,js=()=>{if(nt.has("i"))return nt.get("i");const e=new Ju(rf(),qu());return nt.set("i",e),e},nf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - return src + dst - dst * src.a; -}\`,sf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,of=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - vec4 c = src * dst; - - return a + b + c; -}\`,af=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,cf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,lf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 mul = src * dst; - vec3 c1 = 2.0 * mul.rgb; - vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0; - vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a); - c.rgb *= c.a; - - return a + b + c; -}\`,uf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 mul = src * dst; - vec3 c1 = 2.0 * mul.rgb; - vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0; - vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a); - c.rgb *= c.a; - - return a + b + c; -}\`,ff=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 a = src - src * dst.a; - vec4 b = dst - dst * src.a; - - src.rgb /= src.a; - dst.rgb /= dst.a; - - vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a); - c.rgb *= c.a; - - return a + b + c; -}\`,hf=()=>\` -vec4 blend (in vec4 src, in vec4 dst) { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - vec4 b = dst - dst * src.a; - vec4 c = vec4(src.a - dst.rgb * src.a, src.a); - - return b + c; -}\`,df=(t,e)=>{let r;switch(t){case"subtract":r=sf();break;case"multiply":r=of();break;case"lighten":r=af();break;case"darken":r=cf();break;case"overlay":r=lf();break;case"hardlight":r=uf();break;case"difference":r=ff();break;case"invert":r=hf();break;default:r=nf();break}const n="uniform vec4 u_mediump[2];",s=zi(0);return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[2]; -\${n} - -in vec2 v_coord; -out vec4 o_color; - -\${r} - -void main() { - vec4 dst = texture(u_textures[0], v_coord); - vec4 src = texture(u_textures[1], v_coord); - \${s} - o_color = blend(src, dst); -}\`},Yi=(t,e)=>{const r=\`i\${t}y\`;if(nt.has(r))return nt.get(r);const n=new _e(Zt(),df(t));return nt.set(r,n),n},Wi=()=>{if(!O.newDrawState)return;const t=O.currentAttachmentObject,e=O.atlasAttachmentObject;O.bind(e),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,On),As(!1);const n=Ai(qt);It(),p.scissor(n[0],n[1],n[2]-n[0],n[3]-n[1]),p.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,p.COLOR_BUFFER_BIT,p.NEAREST),yt(),t&&O.bind(t),O.newDrawState=!1},ji=t=>{const e=qt;Qt(t.index),Wi(),p.bindFramebuffer(p.FRAMEBUFFER,Fs);const r=Pi();p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,r.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,Zr);const n=Jr(t.w,t.h);return p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,n.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,null),p.bindFramebuffer(p.READ_FRAMEBUFFER,Fs),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,Zr),p.blitFramebuffer(t.x,t.y,t.x+t.w,t.y+t.h,0,0,t.w,t.h,p.COLOR_BUFFER_BIT,p.NEAREST),Qt(e),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.FRAMEBUFFER,Tt),n},_n=(t,e,r=!1)=>{Ke(2,p.TEXTURE2,null,r),Ke(1,p.TEXTURE1,e,r),Ke(0,p.TEXTURE0,t,r)},Jt=()=>{if(nt.has("p"))return nt.get("p");const e=new _e(tf(),Xi(!1));return nt.set("p",e),e},wt=(t,e,r)=>{const n=t.highp,s=O.$matrix;n[0]=s[6],n[1]=s[7],n[2]=e,n[3]=r,n[4]=pt,n[5]=mt},xe=t=>{t.useProgram(),t.bindUniform(),Pt(Ln()),p.drawArrays(p.TRIANGLES,0,6)};let er=null;const Hi=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=O.$mainAttachmentObject;return O.bind(o),p.bindFramebuffer(p.FRAMEBUFFER,Zr),(!er||er.width!==o.width||er.height!==o.height)&&(er=Jr(o.width,o.height)),$e(er),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,er.resource,0),p.bindFramebuffer(p.FRAMEBUFFER,null),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,Zr),It(),p.scissor(t,o.height-e-n,r+1,n+1),p.blitFramebuffer(0,0,o.width,o.height,0,0,o.width,o.height,p.COLOR_BUFFER_BIT,p.NEAREST),yt(),p.bindFramebuffer(p.FRAMEBUFFER,Tt),s&&O.bind(s),er},Vn=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=Hi(t,e,r,n),i=we(r,n,!1);O.bind(i),O.save(),O.setTransform(1,0,0,1,-t,-e);const l=Jt();wt(l,o.width,o.height),Ce(),$e(o),xe(l);const c=i.texture;return O.restore(),be(i,!1),s&&O.bind(s),c},Tr=()=>{Ft!==610&&(_t(610),p.blendFunc(p.ONE,p.ZERO))},Ki=t=>{$e(t),Tr();const e=Jt();wt(e,t.width,t.height),xe(e),Ce()},qi=(t,e,r,n,s,o,i,l,c)=>{const u=t.textures;u[0]=0,u[1]=1;const a=t.mediump;a[0]=e,a[1]=r,a[2]=n,a[3]=s,a[4]=o,a[5]=i,a[6]=l,a[7]=c},Dn=(t=!1)=>{const e=\`m\${t?"y":"n"}\`;if(nt.has(e))return nt.get(e);const r=new _e(ef(),Xi(t));return nt.set(e,r),r},Nn=(t,e,r)=>{const n=t.highp,s=O.$matrix;n[0]=s[0],n[1]=s[1],n[2]=s[3],n[3]=s[4],n[4]=s[6],n[5]=s[7],n[6]=e,n[7]=r,n[8]=pt,n[9]=mt},pf=(t,e,r,n,s,o)=>{const i=o[0],l=o[1],c=o[2],u=O.globalAlpha,a=o[4]/255,h=o[5]/255,d=o[6]/255,g=0,m=O.$matrix;switch(O.globalCompositeOperation){case"normal":case"layer":case"add":case"screen":case"alpha":case"erase":case"copy":{if(In!==O.globalCompositeOperation||Cs!==t.index){Qt(Cs);const b=O.globalCompositeOperation;O.globalCompositeOperation=In,O.newDrawState=!0,O.drawArraysInstanced(),O.newDrawState=!0,O.globalCompositeOperation=b,Di(O.globalCompositeOperation),Fi(t.index),Qt(t.index)}const f=js();Ve.pushDisplayObjectBuffer((t.x+.5)/ut,(t.y+.5)/ut,(t.w-1)/ut,(t.h-1)/ut,t.w,t.h,pt,mt,m[6],m[7],m[0],m[1],m[3],m[4],i,l,c,u,a,h,d,g),f.count++}break;default:{const f=O.currentAttachmentObject;O.drawArraysInstanced();const b=Math.ceil(Math.abs(n-e)),x=Math.ceil(Math.abs(s-r));let y=0,P=0,S=ji(t);if(m[0]!==1||m[1]!==0||m[3]!==0||m[4]!==1){const w=we(b,x,!1),E=dr(m[0],m[1],m[3],m[4],b/2,x/2),F=dr(1,0,0,1,-t.w/2,-t.h/2),A=dr(E[0]*F[0]+E[2]*F[1],E[1]*F[0]+E[3]*F[1],E[0]*F[2]+E[2]*F[3],E[1]*F[2]+E[3]*F[3],E[0]*F[4]+E[2]*F[5]+E[4],E[1]*F[4]+E[3]*F[5]+E[5]);O.save(),O.bind(w),O.setTransform(A[0],A[1],A[2],A[3],A[4],A[5]),y=A[4],P=A[5];const R=Dn();Nn(R,S.width,S.height),$e(S,!0),xe(R),ae(S),S=w.texture,be(w,!1),f&&O.bind(f),O.restore()}(y||P)&&(m[6]-=y,m[7]-=P);const M=Vn(m[6],m[7],b,x),$=we(b,x,!1);O.bind($),_n(M,S);const T=Yi(O.globalCompositeOperation);qi(T,i,l,c,u,a,h,d,g),xe(T),f&&O.bind(f),Ki($.texture),(y||P)&&(m[6]+=y,m[7]+=P),ae(S),ae(M),be($),Di(O.globalCompositeOperation),Fi(t.index),Qt(t.index)}break}},mf=()=>{js().clear()};let Hs=0;const gf=()=>{Pt(ki),p.bindBuffer(p.ARRAY_BUFFER,Vs),Ve.buffer.length>Hs&&(Hs=Ve.buffer.length,p.bufferData(p.ARRAY_BUFFER,Hs*4,p.STREAM_DRAW)),p.bufferSubData(p.ARRAY_BUFFER,0,Ve.buffer,0,Ve.offset)},bf=t=>{t.useProgram(),t.bindUniform(),gf(),p.drawArraysInstanced(p.TRIANGLES,0,6,t.count)},xf=()=>{Ft!==611&&(_t(611),p.blendFunc(p.ONE,p.ONE))},yf=()=>{Ft!==641&&(_t(641),p.blendFunc(p.ONE_MINUS_DST_COLOR,p.ONE))},vf=()=>{Ft!==606&&(_t(606),p.blendFunc(p.ZERO,p.SRC_ALPHA))},Ks=()=>{Ft!==603&&(_t(603),p.blendFunc(p.ZERO,p.ONE_MINUS_SRC_ALPHA))},Qi=t=>{switch(t){case"add":xf();break;case"screen":yf();break;case"alpha":vf();break;case"erase":Ks();break;case"copy":Tr();break;default:Ce();break}},Mf=()=>{const t=js();t.count&&(Wi(),Qi(In),bf(t),t.clear())},Sf=()=>{const t=Un();return Pt(t),p.bindBuffer(p.ARRAY_BUFFER,t.vertexBuffer),p.bufferData(p.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]),p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),p.bindBuffer(p.ARRAY_BUFFER,Vs),p.bufferData(p.ARRAY_BUFFER,Ve.buffer.length,p.STREAM_DRAW),p.enableVertexAttribArray(1),p.vertexAttribPointer(1,4,p.FLOAT,!1,88,0),p.vertexAttribDivisor(1,1),p.enableVertexAttribArray(2),p.vertexAttribPointer(2,4,p.FLOAT,!1,88,16),p.vertexAttribDivisor(2,1),p.enableVertexAttribArray(3),p.vertexAttribPointer(3,2,p.FLOAT,!1,88,32),p.vertexAttribDivisor(3,1),p.enableVertexAttribArray(4),p.vertexAttribPointer(4,4,p.FLOAT,!1,88,40),p.vertexAttribDivisor(4,1),p.enableVertexAttribArray(5),p.vertexAttribPointer(5,4,p.FLOAT,!1,88,56),p.vertexAttribDivisor(5,1),p.enableVertexAttribArray(6),p.vertexAttribPointer(6,4,p.FLOAT,!1,88,72),p.vertexAttribDivisor(6,1),t},$f=t=>{vu(t),Mu(Sf())},Tf=()=>{const t=O.$mainAttachmentObject;O.bind(t),p.bindFramebuffer(p.READ_FRAMEBUFFER,Tt),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,null);const e=t.width,r=t.height;p.blitFramebuffer(0,0,e,r,0,0,e,r,p.COLOR_BUFFER_BIT,p.NEAREST),p.bindFramebuffer(p.DRAW_FRAMEBUFFER,vi),p.bindFramebuffer(p.FRAMEBUFFER,Tt)},Bf=()=>{p.enable(p.BLEND),Ce()},Pf=()=>{const t=O.currentAttachmentObject;t&&(t.mask=!0,t.clipLevel++,rn.set(t.clipLevel,t.clipLevel),Gs()||(Rn(!0),Yr(),p.enable(p.SAMPLE_ALPHA_TO_COVERAGE),p.stencilFunc(p.ALWAYS,0,255),p.stencilOp(p.ZERO,p.INVERT,p.INVERT),p.colorMask(!1,!1,!1,!1)))},Af=(t,e,r,n)=>{const s=O.currentAttachmentObject;if(!s)return;tn.set(s.clipLevel,hi(t,e,r,n));const o=Math.ceil(Math.abs(r-t)),i=Math.ceil(Math.abs(n-e));It(),p.scissor(t,s.height-e-i,o,i)},Ff=()=>{const t=O.currentAttachmentObject;if(!t)return;const e=t.clipLevel,r=tn.get(e),n=r[0],s=r[1],o=r[2],i=r[3];tn.delete(e),rn.delete(e),di(r);const l=Math.ceil(Math.abs(o-n)),c=Math.ceil(Math.abs(i-s));if(It(),p.scissor(n,t.height-s-c,l,c),--t.clipLevel,!t.clipLevel){t.mask=!1,Rn(!1),p.clear(p.STENCIL_BUFFER_BIT),Wr(),yt(),rn.clear(),tn.clear();return}p.stencilMask(1<{const s=Jr(t,e,n);return p.texSubImage2D(p.TEXTURE_2D,0,0,0,t,e,p.RGBA,p.UNSIGNED_BYTE,r),s},wf=(t,e)=>{const r=qs(t.w,t.h,e),n=Jt();wt(n,t.w,t.h),Ce(),xe(n),ae(r)},Of=(t,e,r,n=!1)=>{const s=Jr(t,e,n);return p.texSubImage2D(p.TEXTURE_2D,0,0,0,p.RGBA,p.UNSIGNED_BYTE,r),s},Ef=(t,e)=>{const r=Of(t.w,t.h,e),n=Jt();wt(n,t.w,t.h),Ce(),xe(n),ae(r)},Vt=[],Rf=(t,e,r,n,s,o)=>{const i=pr();if(!i.length)return;Bt.push("bitmap");const l=Cn(i);yr(l.buffer),We.push(l.indexCount),Vt.push(t,e,r,n,s,o)},Cf=(t,e,r,n,s,o)=>{const i=pr(!0);if(!i.length)return;Bt.push("bitmap");const l=Is(i);yr(l.buffer),We.push(l.indexCount),Vt.push(t,e,r,n,s,o)},Uf=()=>{const t=pr(!0);if(!t.length)return;Bt.push("fill");const e=Is(t);yr(e.buffer),We.push(e.indexCount)},Gf=t=>{const e=t.toFixed(1);return\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump; - -in vec2 v_coord; -out vec4 o_color; - -void main() { - vec2 offset = u_mediump.xy; - float fraction = u_mediump.z; - float samples = u_mediump.w; - - vec4 color = texture(u_texture, v_coord); - - for (float i = 1.0; i < \${e}; i += 1.0) { - color += texture(u_texture, v_coord + offset * i); - color += texture(u_texture, v_coord - offset * i); - } - color += texture(u_texture, v_coord + offset * \${e}) * fraction; - color += texture(u_texture, v_coord - offset * \${e}) * fraction; - color /= samples; - - o_color = color; -}\`},De=new Map,Lf=t=>{const e=\`b\${t}\`;if(De.has(e))return De.get(e);const r=new _e(Zt(),Gf(t));return De.set(e,r),r},kf=(t,e,r,n,s,o)=>{const i=t.mediump;n?(i[0]=1/e,i[1]=0):(i[0]=0,i[1]=1/r),i[2]=s,i[3]=o},Zi=(t,e,r)=>{$e(t,!0);const n=Math.ceil(r*.5),s=1-(n-r*.5),o=1+r,i=Lf(n);kf(i,t.width,t.height,e,s,o),xe(i)},re={x:0,y:0},Br=(t,e,r)=>(t>>16)*(r?e:1)/255,Pr=(t,e,r)=>(t>>8&255)*(r?e:1)/255,Ar=(t,e,r)=>(t&255)*(r?e:1)/255,If=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],tr=(t,e,r=4,n=4,s=1,o=!0)=>{const i=O.currentAttachmentObject,l=Math.sqrt(e[0]*e[0]+e[1]*e[1]),c=Math.sqrt(e[2]*e[2]+e[3]*e[3]),u=vt,a=r*(l/u),h=n*(c/u),d=If[s-1],g=Math.round(a*d),m=Math.round(h*d);re.x+=g,re.y+=m;const f=t.width+g*2,b=t.height+m*2;let x=1,y=1;a>128?x=.0625:a>64?x=.125:a>32?x=.25:a>16&&(x=.5),h>128?y=.0625:h>64?y=.125:h>32?y=.25:h>16&&(y=.5);const P=Math.ceil(f*x),S=Math.ceil(b*y),M=we(P,S,!1),$=we(P,S,!1),T=[M,$];O.bind(M),O.reset(),O.setTransform(x,0,0,y,g*x,m*y),$e(t);const w=Dn();Nn(w,t.width,t.height),xe(w),o&&ae(t);const E=a*x,F=h*y;let A=0,R=M.texture;$e(R,!0),Tr();for(let v=0;v0){A=(A+1)%2;const U=T[A];O.bind(U),Zi(R,!0,E),R=U.texture}if(n>0){A=(A+1)%2;const U=T[A];O.bind(U),Zi(R,!1,F),R=U.texture}}if(Ce(),x!==1||y!==1){const v=we(f,b,!1);O.bind(v),O.setTransform(1/x,0,0,1/y,0,0),$e(R,!0),Nn(w,R.width,R.height),xe(w),R=v.texture,be(T[0]),be(T[1]),be(v,!1)}else A=(A+1)%2,be(T[A]),A=(A+1)%2,be(T[A],!1);return i&&O.bind(i),R},_f=()=>\`#version 300 es -precision mediump float; - -uniform sampler2D u_texture; -uniform vec4 u_mediump[5]; - -in vec2 v_coord; -out vec4 o_color; - -void main() { - mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]); - vec4 add = u_mediump[4]; - - vec4 color = texture(u_texture, v_coord); - - color.rgb /= max(0.0001, color.a); - color = clamp(color * mul + add, 0.0, 1.0); - color.rgb *= color.a; - - o_color = color; -}\`,Vf=()=>{if(De.has("m"))return De.get("m");const e=new _e(Zt(),_f());return De.set("m",e),e},Df=(t,e)=>{const r=t.mediump;r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[5],r[5]=e[6],r[6]=e[7],r[7]=e[8],r[8]=e[10],r[9]=e[11],r[10]=e[12],r[11]=e[13],r[12]=e[15],r[13]=e[16],r[14]=e[17],r[15]=e[18],r[16]=e[4]/255,r[17]=e[9]/255,r[18]=e[14]/255,r[19]=e[19]/255},Ji=(t,e)=>{const r=O.currentAttachmentObject,n=we(t.width,t.height,!1);O.bind(n),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t),Ce();const s=Vf();Df(s,e),xe(s);const o=n.texture;return ae(t),be(n,!1),r&&O.bind(r),o},Nf=(t,e,r=!1)=>{Ke(2,p.TEXTURE2,e,r),Ke(1,p.TEXTURE1,null),Ke(0,p.TEXTURE0,t,r)},zf=(t,e,r,n=!1)=>{Ke(2,p.TEXTURE2,r,n),Ke(1,p.TEXTURE1,e,n),Ke(0,p.TEXTURE0,t,n)},Xf=()=>{Ft!==670&&(_t(670),p.blendFunc(p.DST_ALPHA,p.ZERO))},Yf=()=>{Ft!==673&&(_t(673),p.blendFunc(p.DST_ALPHA,p.ONE_MINUS_SRC_ALPHA))},Wf=t=>\` - vec2 base_scale = u_mediump[\${t}].xy; - vec2 base_offset = u_mediump[\${t}].zw; - - vec2 uv = v_coord * base_scale - base_offset; - vec4 base = mix(vec4(0.0), texture(u_textures[1], uv), isInside(uv)); -\`,jf=()=>\` - vec4 blur = texture(u_textures[0], v_coord); -\`,Hf=t=>\` - vec2 blur_scale = u_mediump[\${t}].xy; - vec2 blur_offset = u_mediump[\${t}].zw; - - vec2 st = v_coord * blur_scale - blur_offset; - vec4 blur = mix(vec4(0.0), texture(u_textures[0], st), isInside(st)); -\`,Kf=t=>{const e=Math.floor(t/4),r=t%4;return\` - float strength = u_mediump[\${e}][\${r}]; - blur.a = clamp(blur.a * strength, 0.0, 1.0); -\`},qf=t=>\` - vec4 color = u_mediump[\${t}]; - blur = color * blur.a; -\`,Qf=t=>\` - blur = texture(u_textures[\${t?2:1}], vec2(blur.a, 0.5)); -\`,ea=(t,e,r,n,s,o)=>{const i=t?"blur.a = 1.0 - blur.a;":"",l=r?Kf(o):"",c=n?Qf(e):qf(s);return\` - \${i} - \${l} - \${c} -\`},Zf=()=>\` - vec4 blur2 = texture(u_textures[0], 1.0 - v_coord); -\`,Jf=()=>\` - vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset; - vec4 blur2 = mix(vec4(0.0), texture(u_textures[0], pq), isInside(pq)); -\`,eh=t=>{const e=Math.floor(t/4),r=t%4;return\` - float strength = u_mediump[\${e}][\${r}]; - highlight_alpha *= strength; - shadow_alpha *= strength; -\`},th=t=>\` - vec4 highlight_color = u_mediump[\${t}]; - vec4 shadow_color = u_mediump[\${t+1}]; - blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha; -\`,rh=t=>\` - blur = texture(u_textures[\${t?2:1}], vec2( - 0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha, - 0.5 - )); -\`,nh=(t,e,r,n,s,o,i,l,c)=>{let u=0;const a=r?Wf(u++):"",h=n?Hf(u++):jf(),d=o==="inner",g=u;let m=u*4,f;c?f=s?ea(!1,r,l,c,g,m):ta(r,n,l,c,g,m):s?(m+=4,f=ea(d,r,l,c,g,m)):(m+=8,f=ta(r,n,l,c,g,m));let b;switch(o){case"outer":b=i?"blur - blur * base.a":"base + blur - blur * base.a";break;case"full":b=i?"blur":"base - base * blur.a + blur";break;default:b="blur";break}return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[\${t}]; -uniform vec4 u_mediump[\${e}]; - -in vec2 v_coord; -out vec4 o_color; - -\${Ws()} - -void main() { - \${a} - \${h} - \${f} - o_color = \${b}; -}\`},ta=(t,e,r,n,s,o)=>{const i=e?Jf():Zf(),l=r?eh(o):"",c=n?rh(t):th(s);return\` - \${i} - float highlight_alpha = blur.a - blur2.a; - float shadow_alpha = blur2.a - blur.a; - \${l} - highlight_alpha = clamp(highlight_alpha, 0.0, 1.0); - shadow_alpha = clamp(shadow_alpha, 0.0, 1.0); - \${c} -\`},sh=(t,e,r,n,s,o,i)=>{const g=\`f\${t?"y":"n"}\${e?"y":"n"}\${r?"y":"n"}\${n}\${s?"y":"n"}\${o?"y":"n"}\${i?"y":"n"}\`;if(De.has(g))return De.get(g);let m=1;t&&m++,i&&m++;let f=(t?4:0)+(e?4:0)+(o?1:0);i||(f+=r?4:8),f=Math.ceil(f/4);const b=new _e(Zt(),nh(m,f,t,e,r,n,s,o,i));return De.set(g,b),b},oh=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b,x,y,P,S,M,$,T,w)=>{let E;M?(E=t.textures,E[0]=0,E[1]=1,w&&(E[2]=2)):w&&(E=t.textures,E[0]=0,E[1]=2);const F=t.mediump;let A=0;M&&(F[A++]=e/n,F[A++]=r/s,F[A++]=o/n,F[A++]=(r-s-i)/s),$&&(F[A++]=e/l,F[A++]=r/c,F[A++]=u/l,F[A++]=(r-c-a)/c),w||(h?(F[A++]=g,F[A++]=m,F[A++]=f,F[A++]=b):(F[A++]=g,F[A++]=m,F[A++]=f,F[A++]=b,F[A++]=x,F[A++]=y,F[A++]=P,F[A++]=S)),T&&(F[A]=d)},ih=16,zn=new Map,Dt=[],ah=(t,e)=>{const r=Dt.indexOf(t);for(r!==-1&&Dt.splice(r,1);zn.size>=ih&&Dt.length>0;){const n=Dt.shift();n&&zn.delete(n)}zn.set(t,e),Dt.push(t)},ch=t=>{const e=zn.get(t);if(e){const r=Dt.indexOf(t);r!==-1&&(Dt.splice(r,1),Dt.push(t))}return e},lh=(t,e,r)=>{let n="";for(let o=1;o{const s=\`l\${("00"+t).slice(-3)}\${e?"y":"n"}\`,o=ch(s);if(o)return o;const i=Math.ceil(t*5/4),l=new _e(Zt(),lh(i,t,e));return ah(s,l),l},uh=(t,e,r,n,s,o)=>{const i=t.mediump;let l=0;for(let c=s;c>16)/255,i[l++]=(u>>8&255)/255,i[l++]=(u&255)/255,i[l++]=n[c]}for(let c=s;c{const r=Un();return Pt(r),p.bindBuffer(p.ARRAY_BUFFER,r.vertexBuffer),tt[0]=t,tt[2]=t,tt[4]=e,tt[6]=e,p.bufferData(p.ARRAY_BUFFER,tt,p.STATIC_DRAW),p.enableVertexAttribArray(0),p.vertexAttribPointer(0,2,p.FLOAT,!1,0,0),r};let Qs;const hh=(t,e)=>(Qs?(tt[0]!==t||tt[4]!==e)&&(tt[0]=t,tt[2]=t,tt[4]=e,tt[6]=e,p.bufferSubData(p.ARRAY_BUFFER,0,tt)):Qs=fh(t,e),Qs),na=(t,e,r)=>{t.useProgram(),t.bindUniform(),Pt(hh(e,r)),p.drawArrays(p.TRIANGLE_STRIP,0,4)},Zs=new Map,dh=t=>t<=4?256:t<=8?512:1024,sa=t=>{if(!Zs.has(t)){const e=we(t,1,!1);Zs.set(t,e)}return Zs.get(t)},ph=()=>sa(512);let oa=0;const ia=()=>oa,mh=t=>{oa=Math.floor(t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS)*.75)},aa=new Float32Array(256),ca=new Float32Array(256);for(let t=0;t<256;++t){const e=t/255;aa[t]=Math.pow(e,2.23333333),ca[t]=e}const gh=(t,e,r)=>{const n=O.currentAttachmentObject,s=ph();O.bind(s);const o=t.length;Tr();const i=ia();for(let l=0;l{const A=O.currentAttachmentObject,R=we(r,n,!1);O.bind(R);const v=g==="inner",U=b!==null&&x!==null&&y!==null;let L=null;if(U&&(L=gh(b,x,y)),v){O.reset(),O.setTransform(1,0,0,1,0,0),$e(t,!0);const _=Jt();wt(_,t.width,t.height),xe(_),U&&L?Nf(e,L,!0):$e(e,!0)}else U&&L?zf(e,t,L,!0):_n(e,t,!0);const D=!(v||g==="full"&&m),G=!(r===c&&n===u&&a===0&&h===0),B=f!==1;v?m?Xf():Yf():Tr();const z=sh(D,G,d,g,m,B,U);oh(z,r,n,s,o,i,l,c,u,a,h,d,f,P,S,M,$,T,w,E,F,D,G,B,U),xe(z);const k=R.texture;return be(R,!1),Ce(),A&&O.bind(A),k},la=(t,e,r=0,n=1,s=4,o=4,i=1,l=1,c=!1,u=!1)=>{const a=O.currentAttachmentObject,h=t.width,d=t.height,g=re.x,m=re.y,f=tr(t,e,s,o,l,!1),b=f.width,x=f.height,y=re.x,P=re.y,S=c?h:b,M=c?d:x,$=y-g,T=P-m,w=c?0:$,E=c?0:T,F=c?-$:0,A=c?-T:0,v=an(t,f,S,M,h,d,w,E,b,x,F,A,!0,c?"inner":"outer",u,i,null,null,null,Br(r,n,!0),Pr(r,n,!0),Ar(r,n,!0),n,0,0,0,0);return ae(t),ae(f),a&&O.bind(a),v},bh=Math.PI/180,ua=(t,e,r=4,n=45,s=0,o=1,i=4,l=4,c=1,u=1,a=!1,h=!1,d=!1)=>{const g=O.currentAttachmentObject,m=t.width,f=t.height,b=re.x,x=re.y,y=tr(t,e,i,l,u,!1),P=y.width,S=y.height,M=re.x,$=re.y,T=M-b,w=$-x,E=Math.sqrt(e[0]*e[0]+e[1]*e[1]),F=Math.sqrt(e[2]*e[2]+e[3]*e[3]),A=vt,R=n*bh,v=Math.cos(R)*r*(E/A),U=Math.sin(R)*r*(F/A),L=a?m:P+Math.max(0,Math.abs(v)-T),D=a?f:S+Math.max(0,Math.abs(U)-w),G=Math.ceil(L),B=Math.ceil(D),z=(G-L)/2,k=(B-D)/2,_=a?0:Math.max(0,T-v)+z,I=a?0:Math.max(0,w-U)+k,V=a?v-M:(v>0?Math.max(0,v-T):0)+z,X=a?U-$:(U>0?Math.max(0,U-w):0)+k;let Y="",W;a?(Y="inner",W=h||d):!h&&d?(Y="full",W=!0):(Y="outer",W=h);const K=an(t,y,G,B,m,f,_,I,P,S,V,X,!0,Y,W,c,null,null,null,Br(s,o,!0),Pr(s,o,!0),Ar(s,o,!0),o,0,0,0,0);return ae(t),ae(y),g&&O.bind(g),K},xh=Math.PI/180,fa=(t,e,r=4,n=45,s=16777215,o=1,i=0,l=1,c=4,u=4,a=1,h=1,d=0,g=!1)=>{const m=t.width,f=t.height,b=re.x,x=re.y,y=Math.sqrt(e[0]*e[0]+e[1]*e[1]),P=Math.sqrt(e[2]*e[2]+e[3]*e[3]),S=vt,M=n*xh,$=Math.cos(M)*r*(y/S),T=Math.sin(M)*r*(P/S),w=O.currentAttachmentObject,E=we(m,f,!1);O.bind(E),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t);const F=Jt();wt(F,t.width,t.height),xe(F),O.setTransform(1,0,0,1,$*2,T*2),Ks(),wt(F,t.width,t.height),xe(F),Ce();const A=E.texture;w&&O.bind(w);const R=tr(A,e,c,u,h,!1);be(E);const v=R.width,U=R.height,L=Math.ceil(v+Math.abs($)*2),D=Math.ceil(U+Math.abs(T)*2);let G="";switch(d){case 0:G="full";break;case 1:G="inner";break;case 2:G="outer";break}const B=G==="inner",z=B?m:L,k=B?f:D,_=Math.abs($),I=Math.abs(T),V=(v-m)/2,X=(U-f)/2,Y=B?0:_+V,W=B?0:I+X,K=B?-V-$:_-$,q=B?-X-T:I-T,ce=an(t,R,z,k,m,f,Y,W,v,U,K,q,!1,G,g,a,null,null,null,Br(s,o,!0),Pr(s,o,!0),Ar(s,o,!0),o,Br(i,l,!0),Pr(i,l,!0),Ar(i,l,!0),l);return re.x=b+Y,re.y=x+W,ae(t),ae(R),ce},yh=Math.PI/180,ha=(t,e,r=4,n=45,s,o,i,l=4,c=4,u=1,a=1,h=0,d=!1)=>{const g=t.width,m=t.height,f=re.x,b=re.y,x=Math.sqrt(e[0]*e[0]+e[1]*e[1]),y=Math.sqrt(e[2]*e[2]+e[3]*e[3]),P=vt,S=n*yh,M=Math.cos(S)*r*(x/P),$=Math.sin(S)*r*(y/P),T=O.currentAttachmentObject,w=we(g,m,!1);O.bind(w),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t);const E=Jt();wt(E,t.width,t.height),xe(E),O.setTransform(1,0,0,1,M*2,$*2),Ks(),wt(E,t.width,t.height),xe(E),Ce();const F=w.texture;T&&O.bind(T);const A=tr(F,e,l,c,a,!1);be(w);const R=A.width,v=A.height,U=Math.ceil(R+Math.abs(M)*2),L=Math.ceil(v+Math.abs($)*2);let D="";switch(h){case 0:D="full";break;case 1:D="inner";break;case 2:D="outer";break}const G=D==="inner",B=G?g:U,z=G?m:L,k=Math.abs(M),_=Math.abs($),I=(R-g)/2,V=(v-m)/2,X=G?0:k+I,Y=G?0:_+V,W=G?-I-M:k-M,K=G?-V-$:_-$,q=an(t,A,B,z,g,m,X,Y,R,v,W,K,!1,D,d,u,i,s,o,0,0,0,0,0,0,0,0);return re.x=f+X,re.y=b+Y,ae(t),ae(A),q},vh=Math.PI/180,da=(t,e,r=4,n=45,s,o,i,l=4,c=4,u=1,a=1,h=0,d=!1)=>{const g=t.width,m=t.height,f=re.x,b=re.y,x=tr(t,e,l,c,a,!1),y=x.width,P=x.height,S=re.x,M=re.y,$=S-f,T=M-b,w=Math.sqrt(e[0]*e[0]+e[1]*e[1]),E=Math.sqrt(e[2]*e[2]+e[3]*e[3]),F=vt,A=n*vh,R=Math.cos(A)*r*(w/F),v=Math.sin(A)*r*(E/F),U=h===1,L=U?g:y+Math.max(0,Math.abs(R)-$),D=U?m:P+Math.max(0,Math.abs(v)-T),G=Math.ceil(L),B=Math.ceil(D),z=(G-L)/2,k=(B-D)/2,_=U?0:Math.max(0,$-R)+z,I=U?0:Math.max(0,T-v)+k,V=U?R-S:(R>0?Math.max(0,R-$):0)+z,X=U?v-M:(v>0?Math.max(0,v-T):0)+k;let Y="";switch(h){case 0:Y="full";break;case 1:Y="inner";break;case 2:Y="outer";break}const W=an(t,x,G,B,g,m,_,I,y,P,V,X,!0,Y,d,u,i,s,o,0,0,0,0,0,0,0,0);return re.x=f+_,re.y=b+I,ae(t),ae(x),W},Mh=(t,e,r,n,s)=>{const o=Math.floor(e*.5),i=Math.floor(r*.5),l=e*r;let c="";const u=s?1:2;for(let d=0;d{const s=("0"+t).slice(-2),o=("0"+e).slice(-2),c=\`c\${s}\${o}\${r?"y":"n"}\${n?"y":"n"}\`;if(De.has(c))return De.get(c);const u=(n?1:2)+Math.ceil(t*e/4),a=new _e(Zt(),Mh(u,t,e,r,n));return De.set(c,a),a},$h=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=t.mediump;h[0]=1/e,h[1]=1/r,h[2]=1/s,h[3]=o/255;let d=4;i||(h[d++]=l,h[d++]=c,h[d++]=u,h[d++]=a);const g=n.length;for(let m=0;m{const a=O.currentAttachmentObject,h=t.width,d=t.height,g=we(h,d,!1);O.bind(g),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t,!0),Ce();const m=Sh(e,r,i,l);$h(m,h,d,n,s,o,l,Br(c,u,!1),Pr(c,u,!1),Ar(c,u,!1),u),xe(m);const f=g.texture;return ae(t),be(g,!1),a&&O.bind(a),f},Th=(t,e,r,n)=>{let s,o,i;switch(e){case 1:s="map_color.r";break;case 2:s="map_color.g";break;case 4:s="map_color.b";break;case 8:s="map_color.a";break;default:s="0.5";break}switch(r){case 1:o="map_color.r";break;case 2:o="map_color.g";break;case 4:o="map_color.b";break;case 8:o="map_color.a";break;default:o="0.5";break}switch(n){case 0:i=\` - vec4 source_color = texture(u_textures[0], uv); -\`;break;case 3:i=\` - vec4 source_color =texture(u_textures[0], mix(v_coord, uv, step(abs(uv - vec2(0.5)), vec2(0.5)))); -\`;break;case 1:i=\` - vec4 substitute_color = u_mediump[2]; - vec4 source_color = mix(substitute_color, texture(u_textures[0], uv), isInside(uv)); -\`;break;default:i=\` - vec4 source_color = texture(u_textures[0], fract(uv)); -\`;break}return\`#version 300 es -precision mediump float; - -uniform sampler2D u_textures[2]; -uniform vec4 u_mediump[\${t}]; - -in vec2 v_coord; -out vec4 o_color; - -\${Ws()} - -void main() { - vec2 uv_to_st_scale = u_mediump[0].xy; - vec2 uv_to_st_offset = u_mediump[0].zw; - vec2 scale = u_mediump[1].xy; - - vec2 st = v_coord * uv_to_st_scale - uv_to_st_offset; - vec4 map_color = texture(u_textures[1], st); - - vec2 offset = vec2(\${s}, \${o}) - 0.5; - vec2 uv = v_coord + offset * scale; - \${i} - - o_color = mix(texture(u_textures[0], v_coord), source_color, isInside(st)); -}\`},Bh=(t,e,r)=>{const n=\`d\${t}\${e}\${r}\`;if(De.has(n))return De.get(n);const s=r===1?3:2,o=new _e(Zt(),Th(s,t,e,r));return De.set(n,o),o},Ph=(t,e,r,n,s,o,i,l,c,u,a,h,d,g)=>{const m=t.textures;m[0]=0,m[1]=1;const f=t.mediump;f[0]=n/e,f[1]=s/r,f[2]=o/e,f[3]=(s-r-i)/r,f[4]=l/n,f[5]=-c/s,u===1&&(f[8]=a,f[9]=h,f[10]=d,f[11]=g)},ma=(t,e,r=0,n=0,s=0,o=0,i=0,l=0,c=0,u=0,a=2,h=0,d=0)=>{const g=O.currentAttachmentObject,m=t.width,f=t.height,b=we(m,f,!1);O.bind(b);const x=qs(r,n,e);_n(t,x);const y=Bh(i,l,a);Ph(y,r,n,r,n,s,o,c,u,a,Br(h,d,!0),Pr(h,d,!0),Ar(h,d,!0),d),Ce(),xe(y);const P=b.texture;return g&&O.bind(g),ae(t),ae(x),be(b,!1),P},Ah=(t,e,r,n)=>{const s=t.highp,o=O.$matrix;s[0]=o[0],s[1]=o[1],s[2]=o[3],s[3]=o[4],s[4]=o[6],s[5]=o[7],s[6]=r,s[7]=n,s[8]=pt,s[9]=mt;const i=t.mediump;i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=e[3],i[4]=e[4],i[5]=e[5],i[6]=e[6],i[7]=e[7]},Xn=(t,e,r,n)=>{const s=O.currentAttachmentObject,o=t.width,i=t.height;switch(O.globalCompositeOperation){case"normal":case"layer":case"add":case"screen":case"alpha":case"erase":case"copy":{O.bind(O.$mainAttachmentObject),O.setTransform(1,0,0,1,r,n);const l=Dn(!0);Ah(l,e,o,i),$e(t),Qi(O.globalCompositeOperation),xe(l)}break;default:{const l=Vn(r,n,o,i),c=we(o,i,!1);O.bind(c),_n(l,t);const u=Yi(O.globalCompositeOperation);qi(u,e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),xe(u),O.bind(O.$mainAttachmentObject),O.reset(),O.setTransform(1,0,0,1,r,n),Ki(c.texture),ae(l),be(c)}break}s&&O.bind(s),Ce()},ga=[],Yn=t=>{t.size&&t.clear(),ga.push(t)},Fh=()=>ga.pop()||new Map,wh=(t,e,r)=>{r.clear(),t.$timerId!==null&&clearTimeout(t.$timerId);for(const n of e.values()){for(const s of n.values())s&&t.destroy(s);Yn(n)}e.clear()},Oh=(t,e)=>{if(!(!e||typeof e!="object")&&"canvas"in e){const r=e.canvas,n=r.width,s=r.height;e.clearRect(0,0,n+1,s+1),r.width=r.height=1,t.push(r)}},Eh=(t,e,r)=>{if(!t.has(e))return;const n=t.get(e);n.has(r)&&(n.delete(r),n.size||(Yn(n),t.delete(e)))},Rh=(t,e,r)=>{if(!e.has(r))return;const n=e.get(r);for(const s of n.values())t.destroy(s);e.delete(r),Yn(n)},Ch=(t,e,r)=>{const n=t.get(e)||null;return n?(n.delete("trash"),n.get(r)||null):null},Uh=(t,e,r,n,s=null)=>{e.has(r)||e.set(r,Fh());const o=e.get(r);if(s===null){if(!o.has(n))return;t.destroy(o.get(n)),o.delete(n),o.size||(e.delete(r),Yn(o));return}o.set(n,s)},Gh=(t,e,r="")=>r?t.has(e)?t.get(e).has(r):!1:t.has(e),Lh=(t,e,r)=>{let n=2166136261,s=t*100|0;return n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619),s=e*100|0,n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619),r&&(s=r*100|0,n^=s&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>24,n=Math.imul(n,16777619)),(n>>>0)%16777216},kh=(t,e,r,n)=>{let s=2166136261,o=t*100|0;return s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=e*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=r*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),o=n*100|0,s^=o&255,s=Math.imul(s,16777619),s^=o>>>8&255,s=Math.imul(s,16777619),s^=o>>>16&255,s=Math.imul(s,16777619),s^=o>>>24,s=Math.imul(s,16777619),(s>>>0)%16777216},Ih=(t,e,r,n)=>{if(r.has(n))return;const s=e.get(n);s&&(s.set("trash",!0),r.set(n,s),t.$timerId!==null&&clearTimeout(t.$timerId),t.$removeCache=!1,t.$timerId=setTimeout(()=>{t.$removeCache=!0,t.$timerId=null},1e3))},_h=(t,e)=>{if(e.size){for(const[r,n]of e)n.has("trash")&&(t.removeById(r),t.$removeIds.push(+r));e.clear(),t.$removeCache=!1}};class Vh{_$pool;_$store;_$trash;$timerId;$removeCache;$removeIds;constructor(){this._$pool=[],this._$store=new Map,this._$trash=new Map,this.$timerId=null,this.$removeIds=[],this.$removeCache=!1}reset(){wh(this,this._$store,this._$trash)}destroy(e=null){Oh(this._$pool,e)}getCanvas(){return this._$pool.pop()||document.createElement("canvas")}remove(e,r){Eh(this._$store,e,r)}removeTimer(e){Ih(this,this._$store,this._$trash,e)}removeTimerScheduledCache(){_h(this,this._$trash)}removeById(e){Rh(this,this._$store,e)}getById(e){return this._$store.get(e)}get(e,r){return Ch(this._$store,e,r)}set(e,r,n=null){Uh(this,this._$store,e,r,n)}has(e,r=""){return Gh(this._$store,e,r)}generateKeys(e,r,n){return Lh(e,r,n)}generateFilterKeys(e,r,n,s){return kh(e,r,n,s)}}const ee=new Vh,ba=new Float32Array(20),Dh=(t,e,r,n,s,o,i,l,c,u,a)=>{const h=O.currentAttachmentObject;let d=null;const g=Math.sqrt(i[0]*i[0]+i[1]*i[1]),m=Math.sqrt(i[2]*i[2]+i[3]*i[3]),f=ee.generateFilterKeys(i[0],i[1],i[2],i[3]);let b=!1;if(ee.get(e,"fKey")===f){const S=ee.get(e,"fTexture");r?ae(S):(b=!0,d=S)}let y=0,P=0;if(b)y=ee.get(e,"offsetX"),P=ee.get(e,"offsetY");else{d=ji(t);const S=Math.atan2(i[1],i[0]),M=Math.atan2(-i[2],i[3]),$=o?g*Math.cos(S):Math.cos(S),T=o?g*Math.sin(S):Math.sin(S),w=o?-m*Math.sin(M):-Math.sin(M),E=o?m*Math.cos(M):Math.cos(M),F=dr($,T,w,E,n/2,s/2),A=dr(1,0,0,1,-t.w/2,-t.h/2),R=Zc(F,A);if(Kr(F),Kr(A),R[0]!==1||R[1]!==0||R[2]!==0||R[3]!==1){const v=we(n,s,!1);O.bind(v),O.reset(),O.setTransform(R[0],R[1],R[2],R[3],R[4],R[5]),y=R[4],P=R[5],$e(d);const U=Dn();Nn(U,d.width,d.height),xe(U),ae(d),d=v.texture,be(v,!1),h&&O.bind(h)}Kr(R),re.x=0,re.y=0;for(let v=0;a.length>v;)switch(a[v++]){case 0:d=fa(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++]);break;case 1:d=tr(d,i,a[v++],a[v++],a[v++]);break;case 2:for(let L=0;L<20;++L)ba[L]=a[v++];d=Ji(d,ba);break;case 3:{const L=a[v++],D=a[v++],G=L*D,B=a.subarray(v,v+G);v+=G,d=pa(d,L,D,B,a[v++],a[v++],!!a[v++],!!a[v++],a[v++],a[v++])}break;case 4:{const L=a[v++],D=new Uint8Array(L);D.set(a.subarray(v,v+L)),v+=L,d=ma(d,D,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++])}break;case 5:d=ua(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++],!!a[v++],!!a[v++]);break;case 6:d=la(d,i,a[v++],a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++],!!a[v++]);break;case 7:{const L=a[v++],D=a[v++];let G=a[v++];const B=a.subarray(v,v+G);v+=G,G=a[v++];const z=a.subarray(v,v+G);v+=G,G=a[v++];const k=a.subarray(v,v+G);v+=G,d=ha(d,i,L,D,B,z,k,a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++])}break;case 8:{const L=a[v++],D=a[v++];let G=a[v++];const B=a.subarray(v,v+G);v+=G,G=a[v++];const z=a.subarray(v,v+G);v+=G,G=a[v++];const k=a.subarray(v,v+G);v+=G,d=da(d,i,L,D,B,z,k,a[v++],a[v++],a[v++],a[v++],a[v++],!!a[v++])}break}}if(d){const S=vt,M=u[0]*(g/S),$=u[1]*(m/S);O.reset(),O.setTransform(1,0,0,1,0,0),O.globalCompositeOperation=c,Xn(d,l,-y+M+i[4],-P+$+i[5])}b||(ee.set(e,"fKey",f),ee.set(e,"fTexture",d),ee.set(e,"offsetX",y),ee.set(e,"offsetY",P)),h&&O.bind(h)},Js=[],Nh=(t,e)=>{O.drawArraysInstanced();const r=O.$mainAttachmentObject;Js.push(r);const n=we(t,e,!1);O.$mainAttachmentObject=n,O.bind(n)},xa=new Float32Array(20),zh=(t,e,r,n,s,o,i,l)=>{O.drawArraysInstanced();const c=O.$mainAttachmentObject;let u=null;if(n&&s&&o){u=Vn(0,0,c.width,c.height),O.$mainAttachmentObject=Js.pop(),be(c),O.bind(O.$mainAttachmentObject),re.x=0,re.y=0;for(let a=0;o.length>a;)switch(o[a++]){case 0:u=fa(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++]);break;case 1:u=tr(u,e,o[a++],o[a++],o[a++]);break;case 2:for(let d=0;d<20;++d)xa[d]=o[a++];u=Ji(u,xa);break;case 3:{const d=o[a++],g=o[a++],m=d*g,f=o.subarray(a,a+m);a+=m,u=pa(u,d,g,f,o[a++],o[a++],!!o[a++],!!o[a++],o[a++],o[a++])}break;case 4:{const d=o[a++],g=new Uint8Array(d);g.set(o.subarray(a,a+d)),a+=d,u=ma(u,g,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++])}break;case 5:u=ua(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++],!!o[a++],!!o[a++]);break;case 6:u=la(u,e,o[a++],o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++],!!o[a++]);break;case 7:{const d=o[a++],g=o[a++];let m=o[a++];const f=o.subarray(a,a+m);a+=m,m=o[a++];const b=o.subarray(a,a+m);a+=m,m=o[a++];const x=o.subarray(a,a+m);a+=m,u=ha(u,e,d,g,f,b,x,o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++])}break;case 8:{const d=o[a++],g=o[a++];let m=o[a++];const f=o.subarray(a,a+m);a+=m,m=o[a++];const b=o.subarray(a,a+m);a+=m,m=o[a++];const x=o.subarray(a,a+m);a+=m,u=da(u,e,d,g,f,b,x,o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++])}break}if(i&&(ee.set(i,"fKey",l),ee.set(i,"fTexture",u)),u){const a=Math.sqrt(e[0]*e[0]+e[1]*e[1]),h=Math.sqrt(e[2]*e[2]+e[3]*e[3]),d=vt,g=s[0]*(a/d),m=s[1]*(h/d);O.reset(),O.globalCompositeOperation=t,Xn(u,r,g+e[4],m+e[5])}}else u=Vn(0,0,c.width,c.height),O.$mainAttachmentObject=Js.pop(),be(c),O.bind(O.$mainAttachmentObject),u&&(O.reset(),O.globalCompositeOperation=t,Xn(u,r,e[4],e[5]),ae(u));O.bind(O.$mainAttachmentObject)},Xh=(t,e,r,n,s,o)=>{if(ee.get(s,"fKey")!==o)return;const l=ee.get(s,"fTexture");if(!l)return;const c=Math.sqrt(e[0]*e[0]+e[1]*e[1]),u=Math.sqrt(e[2]*e[2]+e[3]*e[3]),a=vt,h=n[0]*(c/a),d=n[1]*(u/a);O.drawArraysInstanced(),O.reset(),O.globalCompositeOperation=t,Xn(l,r,h+e[4],d+e[5])},ya=t=>{const e=Ai(t.index),r=e[0],n=e[1],s=e[2],o=e[3];e[0]=Math.min(t.x,r),e[1]=Math.min(t.y,n),e[2]=Math.max(t.x+t.w+1,s),e[3]=Math.max(t.y+t.h+1,o)},Yh=t=>{const e=\`s\${t?"y":"n"}\`;if(At.has(e))return At.get(e);const r=new _e(kn(t?9:0,!1,!1,t),Vu());return At.set(e,r),r},Wh=(t,e)=>{const r=t.highp;r[0]=e[0],r[1]=e[1],r[2]=0,r[4]=e[2],r[5]=e[3],r[6]=0,r[8]=e[4],r[9]=e[5],r[10]=1,r[12]=e[6],r[13]=e[7],r[14]=0,r[16]=e[8],r[17]=e[9],r[18]=0,r[20]=e[10],r[21]=e[11],r[22]=1,r[3]=pt,r[7]=mt,r[11]=e[12],r[15]=e[13],r[19]=e[14],r[23]=e[15],r[24]=e[16],r[25]=e[17],r[26]=e[18],r[27]=e[19],r[28]=e[20],r[29]=e[21],r[30]=e[22],r[31]=e[23],r[32]=e[24],r[33]=e[25]};let Wn=0;const va=1,Ma=2,Sa=t=>{Wn=t},jh=()=>{Wn=0};let eo=!0;const to=t=>{eo=t};let ro=!1;const no=t=>{ro=t},jn=()=>{Wn!==va&&(Sa(va),p.stencilFunc(p.ALWAYS,0,255),p.stencilOpSeparate(p.FRONT,p.KEEP,p.KEEP,p.INCR_WRAP),p.stencilOpSeparate(p.BACK,p.KEEP,p.KEEP,p.DECR_WRAP)),eo&&(to(!1),p.colorMask(!1,!1,!1,!1))},Hn=()=>{Wn!==Ma&&(Sa(Ma),p.stencilFunc(p.NOTEQUAL,0,255),p.stencilOp(p.KEEP,p.ZERO,p.ZERO)),eo||(to(!0),p.colorMask(!0,!0,!0,!0))},Kn=()=>{ro||(no(!0),p.enable(p.SAMPLE_ALPHA_TO_COVERAGE))},qn=()=>{ro&&(no(!1),p.disable(p.SAMPLE_ALPHA_TO_COVERAGE))},Hh=(t,e,r,n)=>{jn();const s=!!n,o=sn(s);n&&on(o,n),Kn(),rt(o,t,e,r),qn(),Hn();const i=Yh(s);n&&Wh(i,n),rt(i,t,e,r)},Kh=(t,e,r,n,s)=>{const o=t.mediump;let i=0;for(let l=r;l{const r=O.currentAttachmentObject,n=p.getParameter(p.SCISSOR_BOX);yt();const s=e===0,o=t.length/5,i=dh(o),l=sa(i);O.bind(l);const c=s?aa:ca;Tr();const u=ia();for(let a=0;a{const s=t?"y":"n",o=e?"y":"n",i=e&&r?"y":"n",l=\`\${n}\`;return\`\${s}\${o}\${i}\${l}\`},Qh=t=>\` - vec2 focal = vec2(u_highp[\${t}][1], 0.0); - - vec2 diff = coord - focal; - float lenDiff = length(diff); - vec2 dir = diff / lenDiff; - float b = 2.0 * dot(dir, focal); - float c = dot(focal, focal) - 1.0; - float x = (-b + sqrt(max(b * b - 4.0 * c, 0.0))) * 0.5; - - float t = lenDiff / abs(x);\`,Zh=()=>"float t = length(coord);",Jh=(t,e)=>{const r=e?Qh(t):Zh();return\` - float radius = u_highp[\${t}][0]; - vec2 coord = p / radius; - \${r} -\`},ed=t=>\` - vec2 a = u_highp[\${t}].xy; - vec2 b = u_highp[\${t}].zw; - - vec2 ab = b - a; - vec2 ap = p - a; - - float t = dot(ab, ap) / dot(ab, ab);\`,td=(t,e,r,n,s)=>{const o=r?Jh(e,n):ed(e);let i;switch(s){case 0:i="1.0 - abs(fract(t * 0.5) * 2.0 - 1.0)";break;case 1:i="fract(t)";break;default:i="clamp(t, 0.0, 1.0)";break}return\`#version 300 es -precision highp float; - -uniform sampler2D u_texture; -uniform vec4 u_highp[\${t}]; - -in vec2 v_uv; -out vec4 o_color; - -void main() { - vec2 p = v_uv; - \${o} - t = \${i}; - o_color = texture(u_texture, vec2(t, 0.5)); -}\`},Ta=(t,e,r,n)=>{const s=qh(n,t,e,r);if(so.has(s))return so.get(s);const o=(n?14:5)+1,i=o-1,l=new _e(kn(o,!0,!1,n),td(o,i,t,e,r));return so.set(s,l),l},Ba=(t,e,r,n,s=0,o=null,i=null)=>{const l=t.highp;l[0]=r[0],l[1]=r[1],l[2]=r[2],l[4]=r[3],l[5]=r[4],l[6]=r[5],l[8]=r[6],l[9]=r[7],l[10]=r[8],l[12]=n[0],l[13]=n[1],l[14]=n[2],l[16]=n[3],l[17]=n[4],l[18]=n[5],l[11]=n[6],l[15]=n[7],l[19]=n[8],l[3]=pt,l[7]=mt;let c=20;i&&(l[20]=i[0],l[21]=i[1],l[22]=0,l[24]=i[2],l[25]=i[3],l[26]=0,l[28]=i[4],l[29]=i[5],l[30]=1,l[32]=i[6],l[33]=i[7],l[34]=0,l[36]=i[8],l[37]=i[9],l[38]=0,l[40]=i[10],l[41]=i[11],l[42]=1,l[31]=i[12],l[35]=i[13],l[39]=i[14],l[43]=i[15],l[44]=i[16],l[45]=i[17],l[46]=i[18],l[47]=i[19],l[48]=i[20],l[49]=i[21],l[50]=i[22],l[51]=i[23],l[52]=i[24],l[53]=i[25],c=56),e===0?(l[c++]=o[0],l[c++]=o[1],l[c++]=o[2],l[c]=o[3]):(l[c++]=819.2,l[c]=jr(s,-.975,.975,0))},Qn=()=>{jh(),to(!0),no(!1)},rd=(t,e,r,n)=>{const s=qe.shift(),o=qe.shift(),i=qe.shift(),l=qe.shift();Qn(),Wr();const c=$a(s,l);$e(c),Yr(),p.stencilMask(255),jn();const u=!!n,a=sn(u);n&&on(a,n),Kn(),rt(a,t,e,r),qn(),Hn();const h=Ta(!1,!1,i,u),d=qc(o),g=ys(O.$matrix);Ba(h,0,O.$matrix,g,0,d,n),di(d),Kr(g),rt(h,t,e,r)},nd=(t,e,r,n)=>{const s=qe.shift(),o=qe.shift(),i=qe.shift(),l=qe.shift(),c=qe.shift();Qn(),Wr();const u=$a(s,l);$e(u),Yr(),p.stencilMask(255),jn();const a=!!n,h=sn(a);n&&on(h,n),Kn(),rt(h,t,e,r),qn(),Hn(),O.save(),O.transform(o[0],o[1],o[2],o[3],o[4],o[5]);const d=O.$stack[O.$stack.length-1],g=ys(O.$matrix),m=Ta(!0,!!c,i,a);Ba(m,1,d,g,c,n),O.restore(),Kr(g),rt(m,t,e,r)},oo=new Map,sd=(t,e)=>{const r=\`b\${t?"y":"n"}\${e?"y":"n"}\`;if(oo.has(r))return oo.get(r);const n=t?Nu():Du(),s=new _e(kn(e?14:5,!0,!1,e),n);return oo.set(r,s),s},od=(t,e,r,n)=>{const s=t.highp,o=O.$stack[O.$stack.length-1];s[0]=o[0],s[1]=o[1],s[2]=o[2],s[4]=o[3],s[5]=o[4],s[6]=o[5],s[8]=o[6],s[9]=o[7],s[10]=o[8];const i=ys(O.$matrix);s[12]=i[0],s[13]=i[1],s[14]=i[2],s[16]=i[3],s[17]=i[4],s[18]=i[5],s[11]=i[6],s[15]=i[7],s[19]=i[8],s[3]=pt,s[7]=mt,n&&(s[20]=n[0],s[21]=n[1],s[22]=0,s[24]=n[2],s[25]=n[3],s[26]=0,s[28]=n[4],s[29]=n[5],s[30]=1,s[32]=n[6],s[33]=n[7],s[34]=0,s[36]=n[8],s[37]=n[9],s[38]=0,s[40]=n[10],s[41]=n[11],s[42]=1,s[31]=n[12],s[35]=n[13],s[39]=n[14],s[43]=n[15],s[44]=n[16],s[45]=n[17],s[46]=n[18],s[47]=n[19],s[48]=n[20],s[49]=n[21],s[50]=n[22],s[51]=n[23],s[52]=n[24],s[53]=n[25]);const l=t.mediump;l[0]=e,l[1]=r},id=(t,e,r,n)=>{jn();const s=!!n,o=sn(s);n&&on(o,n),Kn(),rt(o,t,e,r),qn();const i=Vt.shift(),l=Vt.shift(),c=Vt.shift(),u=Vt.shift(),a=Vt.shift(),h=Vt.shift(),d=qs(c,u,i,h);O.save(),O.transform(l[0],l[1],l[2],l[3],l[4],l[5]),Hn();const g=sd(a,s);od(g,c,u,n),rt(g,t,e,r),O.restore(),ae(d)},ad=()=>{const t=Ii();Yr(),p.stencilMask(255),Qn();let e=0,r=null;for(let n=0;n{const r=Hi(0,0,t,e);$e(r),p.bindFramebuffer(p.FRAMEBUFFER,Si),p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,r.resource,0);const n=new Uint8Array(t*e*4),s=O.$mainAttachmentObject;n.byteLength>io&&(io=Fn(n.byteLength),p.bufferData(p.PIXEL_PACK_BUFFER,io,p.STREAM_READ)),p.readPixels(0,s.height-e,t,e,p.RGBA,p.UNSIGNED_BYTE,0);const o=p.fenceSync(p.SYNC_GPU_COMMANDS_COMPLETE,0);await new Promise(i=>{const l=()=>{if(p.clientWaitSync(o,p.SYNC_FLUSH_COMMANDS_BIT,0)===p.TIMEOUT_EXPIRED){requestAnimationFrame(l);return}return p.deleteSync(o),p.getBufferSubData(p.PIXEL_PACK_BUFFER,0,n),i()};l()}),p.bindFramebuffer(p.FRAMEBUFFER,Tt);for(let i=0;i0?le.float32Array4Pool.pop():new Float32Array(4)}static poolFloat32Array4(e){e.length===4&&le.float32Array4Pool.push(e)}}let st=null;const ud=t=>{st=t},fd=()=>le.getFloat32Array4(),hd=t=>{le.poolFloat32Array4(t)},dd=(t,e,r,n)=>{const s=n.x-t.x,o=n.y-t.y,i=s*s+o*o;if(i<1e-10){const h=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y),d=(r.x-t.x)*(r.x-t.x)+(r.y-t.y)*(r.y-t.y);return Math.max(h,d)}const l=(e.x-t.x)*o-(e.y-t.y)*s,c=l*l/i,u=(r.x-t.x)*o-(r.y-t.y)*s,a=u*u/i;return Math.max(c,a)},pd=(t,e,r,n)=>{const s={x:(t.x+e.x)*.5,y:(t.y+e.y)*.5},o={x:(e.x+r.x)*.5,y:(e.y+r.y)*.5},i={x:(r.x+n.x)*.5,y:(r.y+n.y)*.5},l={x:(s.x+o.x)*.5,y:(s.y+o.y)*.5},c={x:(o.x+i.x)*.5,y:(o.y+i.y)*.5},u={x:(l.x+c.x)*.5,y:(l.y+c.y)*.5};return{first:[t,s,l,u],second:[u,c,i,n]}},Aa=.25,md=8,gd=(t,e,r,n,s=Aa)=>{const o=[],i=(l,c,u,a,h)=>{if(dd(l,c,u,a)<=s||h>=md){const m={x:(c.x+u.x)*.5,y:(c.y+u.y)*.5};o.push({ctrl:m,end:a});return}const g=pd(l,c,u,a);i(g.first[0],g.first[1],g.first[2],g.first[3],h+1),i(g.second[0],g.second[1],g.second[2],g.second[3],h+1)};return i(t,e,r,n,0),o},bd=t=>{const r=Aa/(t*t);return Math.max(.0625,Math.min(4,r))};class xd{$currentPath;$vertices;$currentX;$currentY;$startX;$startY;constructor(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}beginPath(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}moveTo(e,r){this.$currentPath.length>=6&&this.$vertices.push(this.$currentPath),this.$currentPath=[e,r,!1],this.$currentX=e,this.$currentY=r,this.$startX=e,this.$startY=r}lineTo(e,r){e===this.$currentX&&r===this.$currentY||(this.$currentPath.push(e,r,!1),this.$currentX=e,this.$currentY=r)}quadraticCurveTo(e,r,n,s){this.$currentPath.push(e,r,!0),this.$currentPath.push(n,s,!1),this.$currentX=n,this.$currentY=s}$flatnessThreshold=.25;setScale(e){this.$flatnessThreshold=bd(e)}bezierCurveTo(e,r,n,s,o,i){const l={x:this.$currentX,y:this.$currentY},h=gd(l,{x:e,y:r},{x:n,y:s},{x:o,y:i},this.$flatnessThreshold);for(const d of h)this.$currentPath.push(d.ctrl.x,d.ctrl.y,!0),this.$currentPath.push(d.end.x,d.end.y,!1);this.$currentX=o,this.$currentY=i}arc(e,r,n){const s=n,o=n*.5522847498307936;this.bezierCurveTo(e+s,r+o,e+o,r+s,e,r+s),this.bezierCurveTo(e-o,r+s,e-s,r+o,e-s,r),this.bezierCurveTo(e-s,r-o,e-o,r-s,e,r-s),this.bezierCurveTo(e+o,r-s,e+s,r-o,e+s,r);const i=this.$currentPath.length;i>=3&&(this.$currentPath[i-3]=this.$startX,this.$currentPath[i-2]=this.$startY),this.$currentX=this.$startX,this.$currentY=this.$startY}closePath(){this.$currentPath.length>=3&&(this.$currentX!==this.$startX||this.$currentY!==this.$startY)&&this.$currentPath.push(this.$startX,this.$startY,!1)}get $getVertices(){const e=[...this.$vertices];return this.$currentPath.length>=9&&e.push(this.$currentPath),e}generateVertices(){const e=this.$getVertices,r=[];for(const n of e){if(n.length<9)continue;const s=[];for(let o=0;o0&&e.push(n)}if(this.$currentPath.length>=3){const r=[];for(let n=0;n0&&e.push(r)}return e}getVerticesForStroke(){const e=[...this.$vertices];return this.$currentPath.length>=6&&e.push(this.$currentPath),e}reset(){this.$currentPath=[],this.$vertices=[],this.$currentX=0,this.$currentY=0,this.$startX=0,this.$startY=0}}const yd=(t,e,r,n)=>new Float32Array([t,e,0,0,t+r,e,1,0,t,e+n,0,1,t+r,e,1,0,t+r,e+n,1,1,t,e+n,0,1]),vd=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t+1),Md=(t,e,r,n)=>{const s=vd(r),o=e.get(s);let i;return o&&o.length>0?(i=o.pop(),n&&t.queue.writeBuffer(i,0,n.buffer,n.byteOffset,n.byteLength)):n?(i=t.createBuffer({size:s,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),new Float32Array(i.getMappedRange()).set(n),i.unmap()):i=t.createBuffer({size:s,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),i},Sd=(t,e,r)=>{const n=Math.ceil(r/16)*16,s=e.get(n);return s&&s.length>0?s.pop():t.createBuffer({size:n,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})},$d=32,Fa=(t,e)=>{const r=e.size;let n=t.get(r);if(n||(n=[],t.set(r,n)),n.length>=$d){e.destroy();return}n.push(e)},Td=32,wa=(t,e)=>{const r=e.size;let n=t.get(r);if(n||(n=[],t.set(r,n)),n.length>=Td){e.destroy();return}n.push(e)},Bd=(t,e)=>t.createBuffer({size:e.size,usage:e.usage|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,label:e.label||"storage_buffer"}),Pd=(t,e,r,n)=>{const s=Math.ceil(r/256)*256;let o=null,i=1/0;for(const u of e)if(!u.inUse&&u.size>=s){const a=u.size-s;a{for(const r of t)if(r.buffer===e){r.inUse=!1;return}},Fd=(t,e,r=60)=>{for(let n=t.length-1;n>=0;n--){const s=t[n];!s.inUse&&e-s.lastUsedFrame>r&&(s.buffer.destroy(),t.splice(n,1))}},Oa=(t,e,r,n=0,s=0)=>{const o=new Uint32Array([e,r,n,s]),i=t.createBuffer({size:o.byteLength,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_DST,mappedAtCreation:!0,label:"indirect_buffer"});return new Uint32Array(i.getMappedRange()).set(o),i.unmap(),i},Ea=(t,e,r,n,s=0,o=0)=>{const i=new Uint32Array([r,n,s,o]);t.queue.writeBuffer(e,0,i)};class wd{device;buffer=null;offset=0;capacity;alignment=256;pendingDestroyBuffers=[];stagingBuffer;stagingFloat32;dirtyEnd=0;constructor(e,r=65536){this.device=e,this.capacity=r,this.stagingBuffer=new ArrayBuffer(r),this.stagingFloat32=new Float32Array(this.stagingBuffer)}resetFrame(){this.offset=0,this.dirtyEnd=0;for(const e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}getBuffer(){return this.buffer||(this.buffer=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})),this.buffer}allocate(e){this.buffer||this.getBuffer();const r=this.offset,n=e.byteLength;if(r+n>this.capacity){this.flush(),this.capacity*=2;const o=this.buffer;this.buffer=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),o&&this.pendingDestroyBuffers.push(o),this.stagingBuffer=new ArrayBuffer(this.capacity),this.stagingFloat32=new Float32Array(this.stagingBuffer)}this.stagingFloat32.set(e,r/4);const s=r+n;return s>this.dirtyEnd&&(this.dirtyEnd=s),this.offset=r+Math.ceil(n/this.alignment)*this.alignment,r}flush(){this.dirtyEnd>0&&this.buffer&&(this.device.queue.writeBuffer(this.buffer,0,this.stagingBuffer,0,this.dirtyEnd),this.dirtyEnd=0)}dispose(){this.buffer&&(this.buffer.destroy(),this.buffer=null);for(const e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}}class Od{device;vertexBuffers;uniformBuffers;vertexBufferBuckets;uniformBufferBuckets;storageBufferPool;indirectBuffer;indirectBufferPool;frameIndirectBuffers;frameNumber;unitRectBuffer;frameVertexPoolBuffers;frameUniformPoolBuffers;dynamicUniform;constructor(e){this.device=e,this.vertexBuffers=new Map,this.uniformBuffers=new Map,this.vertexBufferBuckets=new Map,this.uniformBufferBuckets=new Map,this.storageBufferPool=[],this.indirectBuffer=null,this.indirectBufferPool=[],this.frameIndirectBuffers=[],this.frameNumber=0,this.unitRectBuffer=null,this.frameVertexPoolBuffers=[],this.frameUniformPoolBuffers=[],this.dynamicUniform=new wd(e)}createVertexBuffer(e,r){const n=this.device.createBuffer({size:r.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0});return new Float32Array(n.getMappedRange()).set(r),n.unmap(),this.vertexBuffers.set(e,n),n}createUniformBuffer(e,r){const n=this.device.createBuffer({size:r,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return this.uniformBuffers.set(e,n),n}updateUniformBuffer(e,r){const n=this.uniformBuffers.get(e);n&&this.device.queue.writeBuffer(n,0,r.buffer,r.byteOffset,r.byteLength)}getVertexBuffer(e){return this.vertexBuffers.get(e)}getUniformBuffer(e){return this.uniformBuffers.get(e)}createRectVertices(e,r,n,s){return yd(e,r,n,s)}acquireVertexBuffer(e,r){const n=Md(this.device,this.vertexBufferBuckets,e,r);return this.frameVertexPoolBuffers.push(n),n}releaseVertexBuffer(e){Fa(this.vertexBufferBuckets,e)}acquireUniformBuffer(e){const r=Sd(this.device,this.uniformBufferBuckets,e);return this.frameUniformPoolBuffers.push(r),r}acquireAndWriteUniformBuffer(e,r){const n=r??e.byteLength,s=this.acquireUniformBuffer(n);return this.device.queue.writeBuffer(s,0,e.buffer,e.byteOffset,n),s}releaseUniformBuffer(e){wa(this.uniformBufferBuckets,e)}destroyBuffer(e){const r=this.vertexBuffers.get(e);r&&(r.destroy(),this.vertexBuffers.delete(e));const n=this.uniformBuffers.get(e);n&&(n.destroy(),this.uniformBuffers.delete(e))}dispose(){for(const e of this.vertexBuffers.values())e.destroy();this.vertexBuffers.clear();for(const e of this.uniformBuffers.values())e.destroy();this.uniformBuffers.clear();for(const e of this.vertexBufferBuckets.values())for(const r of e)r.destroy();this.vertexBufferBuckets.clear();for(const e of this.uniformBufferBuckets.values())for(const r of e)r.destroy();this.uniformBufferBuckets.clear();for(const e of this.storageBufferPool)e.buffer.destroy();this.storageBufferPool=[],this.indirectBuffer&&(this.indirectBuffer.destroy(),this.indirectBuffer=null);for(const e of this.indirectBufferPool)e.destroy();this.indirectBufferPool=[];for(const e of this.frameIndirectBuffers)e.destroy();this.frameIndirectBuffers=[],this.unitRectBuffer&&(this.unitRectBuffer.destroy(),this.unitRectBuffer=null),this.frameVertexPoolBuffers.length=0,this.frameUniformPoolBuffers.length=0,this.dynamicUniform.dispose()}getPoolStats(){let e=0;for(const n of this.vertexBufferBuckets.values())e+=n.length;let r=0;for(const n of this.uniformBufferBuckets.values())r+=n.length;return{vertexPoolSize:e,uniformPoolSize:r}}clearFrameBuffers(){for(const e of this.vertexBuffers.values())e.destroy();this.vertexBuffers.clear();for(const e of this.uniformBuffers.values())e.destroy();this.uniformBuffers.clear();for(const e of this.frameVertexPoolBuffers)Fa(this.vertexBufferBuckets,e);this.frameVertexPoolBuffers.length=0;for(const e of this.frameUniformPoolBuffers)wa(this.uniformBufferBuckets,e);this.frameUniformPoolBuffers.length=0;for(const e of this.frameIndirectBuffers)this.indirectBufferPool.push(e);this.frameIndirectBuffers.length=0,this.releaseAllStorageBuffers(),this.dynamicUniform.resetFrame(),this.frameNumber++,this.frameNumber%60===0&&Fd(this.storageBufferPool,this.frameNumber)}releaseAllStorageBuffers(){for(const e of this.storageBufferPool)e.inUse=!1}acquireStorageBuffer(e){return Pd(this.device,this.storageBufferPool,e,this.frameNumber)}releaseStorageBuffer(e){Ad(this.storageBufferPool,e)}writeStorageBuffer(e,r){this.device.queue.writeBuffer(e,0,r.buffer,r.byteOffset,r.byteLength)}getOrCreateIndirectBuffer(e,r,n=0,s=0){return this.indirectBuffer?Ea(this.device,this.indirectBuffer,e,r,n,s):this.indirectBuffer=Oa(this.device,e,r,n,s),this.indirectBuffer}createIndirectBuffer(e,r,n=0,s=0){let o=this.indirectBufferPool.pop();return o?Ea(this.device,o,e,r,n,s):o=Oa(this.device,e,r,n,s),this.frameIndirectBuffers.push(o),o}getUnitRectBuffer(){if(!this.unitRectBuffer){const e=this.createRectVertices(0,0,1,1);this.unitRectBuffer=this.device.createBuffer({size:e.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),new Float32Array(this.unitRectBuffer.getMappedRange()).set(e),this.unitRectBuffer.unmap()}return this.unitRectBuffer}getFrameNumber(){return this.frameNumber}getStoragePoolStats(){const e=this.storageBufferPool.filter(r=>r.inUse).length;return{storagePoolSize:this.storageBufferPool.length,storagePoolInUse:e}}}const Ed=(t,e)=>{const r=t.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("linear",r);const n=t.createSampler({magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("nearest",n);const s=t.createSampler({magFilter:"nearest",minFilter:"linear",mipmapFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});e.set("atlas_instanced_sampler",s);const o=t.createSampler({magFilter:"linear",minFilter:"linear",mipmapFilter:"linear",addressModeU:"repeat",addressModeV:"repeat"});e.set("repeat",o)},Rd=(t,e,r,n,s,o)=>{const i=t.createTexture({size:{width:s,height:o},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return t.queue.writeTexture({texture:i},n.buffer,{bytesPerRow:s*4,offset:n.byteOffset},{width:s,height:o}),e.set(r,i),i},Cd=(t,e,r,n)=>{const s=t.createTexture({size:{width:n.width,height:n.height},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return t.queue.copyExternalImageToTexture({source:n,flipY:!0},{texture:s,premultipliedAlpha:!0},{width:n.width,height:n.height}),e.set(r,s),s};class Ud{device;textures;samplers;constructor(e){this.device=e,this.textures=new Map,this.samplers=new Map,Ed(e,this.samplers)}createTexture(e,r,n,s="rgba8unorm"){const o=this.device.createTexture({size:{width:r,height:n},format:s,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return this.textures.set(e,o),o}createTextureFromPixels(e,r,n,s){return Rd(this.device,this.textures,e,r,n,s)}createTextureFromImageBitmap(e,r){return Cd(this.device,this.textures,e,r)}updateTexture(e,r,n,s){const o=this.textures.get(e);o&&this.device.queue.writeTexture({texture:o},r.buffer,{bytesPerRow:n*4,offset:r.byteOffset},{width:n,height:s})}getTexture(e){return this.textures.get(e)}getSampler(e){return this.samplers.get(e)}createSampler(e,r=!0){const n=this.samplers.get(e);if(n)return n;const s=this.device.createSampler({magFilter:r?"linear":"nearest",minFilter:r?"linear":"nearest",mipmapFilter:r?"linear":"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"});return this.samplers.set(e,s),s}destroyTexture(e){const r=this.textures.get(e);r&&(r.destroy(),this.textures.delete(e))}dispose(){for(const e of this.textures.values())e.destroy();this.textures.clear(),this.samplers.clear()}}const Gd=(t,e,r,n,s,o,i,l,c)=>{const u=n==="atlas"||n.startsWith("atlas_"),a=u||n.startsWith("temp_")?"rgba8unorm":e,h=i||u&&ao>1,d=h?ao:1,g=t.createTexture({size:{width:s,height:o},format:a,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),m=g.createView(),f={id:c.textureId++,resource:g,view:m,width:s,height:o,area:s*o,smooth:!0};let b=null;if(h){const S=t.createTexture({size:{width:s,height:o},format:a,sampleCount:d,usage:GPUTextureUsage.RENDER_ATTACHMENT}),M=S.createView();b={id:c.textureId++,resource:S,view:M,width:s,height:o,area:s*o,smooth:!0}}let x=null,y=null;if(u||n==="main"||l){const S=t.createTexture({size:{width:s,height:o},format:"stencil8",usage:GPUTextureUsage.RENDER_ATTACHMENT}),M=S.createView();if(x={id:c.stencilId++,resource:S,view:M,width:s,height:o,area:s*o,dirty:!1},h){const $=t.createTexture({size:{width:s,height:o},format:"stencil8",sampleCount:d,usage:GPUTextureUsage.RENDER_ATTACHMENT}),T=$.createView();y={id:c.stencilId++,resource:$,view:T,width:s,height:o,area:s*o,dirty:!1}}}const P={id:c.nextId++,width:s,height:o,clipLevel:0,msaa:h,mask:l,color:null,texture:f,stencil:x,msaaTexture:b,msaaStencil:y};return r.set(n,P),P},Ld=(t,e,r)=>{for(const[n,s]of t.entries())if(s.id===r.id){t.delete(n),e.push(s);break}},cn={r:0,g:0,b:0,a:0},Zn={view:null,clearValue:cn,loadOp:"clear",storeOp:"store"},kd={colorAttachments:[Zn]},Id=(t,e=0,r=0,n=0,s=0,o="clear",i=null)=>(Zn.view=t,cn.r=e,cn.g=r,cn.b=n,cn.a=s,Zn.loadOp=o,Zn.resolveTarget=i??void 0,kd),Jn={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:"load",storeOp:"store"},co={view:null,stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},_d={colorAttachments:[Jn],depthStencilAttachment:co},Vd=(t,e,r="load",n="clear",s=null)=>(Jn.view=t,Jn.loadOp=r,Jn.resolveTarget=s??void 0,co.view=e,co.stencilLoadOp=n,_d),Dd=(t,e,r)=>\`\${t}_\${e}_\${r}\`,Nd=(t,e,r,n,s,o,i,l,c)=>{const u=Dd(r,n,s),a=e.get(u);if(a)for(let g=0;g=l){let g=1/0,m="",f=-1;for(const[b,x]of e)for(let y=0;y=0){const b=e.get(m);b[f].texture.destroy(),b.splice(f,1),b.length===0&&e.delete(m),c[0]--}}const h=t.createTexture({size:{width:r,height:n},format:s,usage:o}),d={texture:h,width:r,height:n,format:s,lastUsedFrame:i,inUse:!0};return a?a.push(d):e.set(u,[d]),c[0]++,h},zd=(t,e,r)=>{for(const n of t.values())for(let s=0;s{const s=e-r;for(const[o,i]of t){for(let l=i.length-1;l>=0;l--){const c=i[l];!c.inUse&&c.lastUsedFrame({id:t.attachmentId++,width:0,height:0,clipLevel:0,msaa:!1,mask:!1,color:null,texture:null,stencil:null,msaaTexture:null,msaaStencil:null}),qd=(t,e,r,n)=>{const s=t.createTexture({size:{width:e,height:r},format:"depth24plus-stencil8",usage:GPUTextureUsage.RENDER_ATTACHMENT});return{id:n.stencilId++,resource:s,view:s.createView(),width:e,height:r,area:e*r,dirty:!1}},Qd=(t,e,r,n,s)=>{for(let o=0;o=r&&i.height>=n)return e.splice(o,1),i.dirty=!1,i}return qd(t,r,n,s)},Zd=(t,e,r,n)=>{const s=t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST});return{resource:s,view:s.createView(),stencil:n,width:e,height:r,area:e*r,dirty:!1}},Jd=(t,e,r,n,s)=>{for(let o=0;o=r&&i.height>=n)return e.splice(o,1),i.stencil=s,i.dirty=!1,i}return Zd(t,r,n,s)},ep=(t,e,r,n,s)=>{const o=t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),i=o.createView();return{id:s.textureId++,resource:o,view:i,width:e,height:r,area:e*r,smooth:n}},tp=(t,e,r,n,s,o)=>{const i=\`\${r}x\${n}_smooth\`;if(e.has(i)){const l=e.get(i);if(l.length>0)return l.pop()}return ep(t,r,n,s,o)},rp=(t,e,r,n,s,o,i,l,c)=>{const u=e.length>0?e.pop():Kd(c);u.width=o,u.height=i,u.msaa=l,u.mask=!1,u.clipLevel=0;const a=Qd(t,s,o,i,c),h=Jd(t,n,o,i,a);u.color=h,u.stencil=a;const d=tp(t,r,o,i,!0,c);return u.texture=d,u},np=(t,e)=>{const r=\`\${e.width}x\${e.height}_\${e.smooth?"smooth":"nearest"}\`;t.has(r)||t.set(r,[]),t.get(r).push(e)},sp=(t,e,r,n,s)=>{s.texture&&(np(e,s.texture),s.texture=null),s.color&&(r.push(s.color),s.color=null),s.stencil&&(n.push(s.stencil),s.stencil=null),t.push(s)},ln={r:0,g:0,b:0,a:0},lo={view:null,loadOp:"clear",storeOp:"store",clearValue:ln},Ra={view:null,depthLoadOp:"clear",depthStoreOp:"store",depthClearValue:1,stencilLoadOp:"clear",stencilStoreOp:"store",stencilClearValue:0},uo={colorAttachments:[lo]},op=(t,e,r,n,s,o="clear")=>{const i=t.color?.view??t.texture?.view;if(!i)throw new Error("No color view available for render pass");return lo.view=i,lo.loadOp=o,ln.r=e,ln.g=r,ln.b=n,ln.a=s,t.stencil?.view?(Ra.view=t.stencil.view,uo.depthStencilAttachment=Ra):uo.depthStencilAttachment=void 0,uo};class ip{device;attachmentPool;texturePool;colorBufferPool;stencilBufferPool;idCounter;currentAttachment;constructor(e){this.device=e,this.attachmentPool=[],this.texturePool=new Map,this.colorBufferPool=[],this.stencilBufferPool=[],this.idCounter={attachmentId:0,textureId:0,stencilId:0},this.currentAttachment=null}getAttachmentObject(e,r,n=!1){return rp(this.device,this.attachmentPool,this.texturePool,this.colorBufferPool,this.stencilBufferPool,e,r,n,this.idCounter)}bindAttachment(e){this.currentAttachment=e}getCurrentAttachment(){return this.currentAttachment}get currentAttachmentObject(){return this.currentAttachment}unbindAttachment(){this.currentAttachment=null}releaseAttachment(e){sp(this.attachmentPool,this.texturePool,this.colorBufferPool,this.stencilBufferPool,e)}createRenderPassDescriptor(e,r,n,s,o,i="clear"){return op(e,r,n,s,o,i)}dispose(){for(const e of this.texturePool.values())for(const r of e)r.resource.destroy();this.texturePool.clear();for(const e of this.colorBufferPool)e.resource.destroy();this.colorBufferPool=[];for(const e of this.stencilBufferPool)e.resource.destroy();this.stencilBufferPool=[];for(const e of this.attachmentPool)e.texture&&e.texture.resource.destroy(),e.color&&e.color.resource.destroy(),e.stencil&&e.stencil.resource.destroy();this.attachmentPool=[]}}const Ca=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.bezier = input.bezier; - output.color = uniforms.color; - return output; -} -\`,Ua=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.bezier = input.bezier; - return output; -} -\`,Ga=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) color: vec4, -} - -struct FillUniforms { - color: vec4, - matrix0: vec4, - matrix1: vec4, - matrix2: vec4, -} - -@group(0) @binding(0) var uniforms: FillUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz); - let transformed = matrix * vec3(input.position, 1.0); - let ndc = transformed.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.color = uniforms.color; - return output; -} -\`,ap=\` -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -struct Uniforms { - viewportSize: vec2, - _padding0: vec2, - matrixCol0: vec3, - _padding1: f32, - matrixCol1: vec3, - _padding2: f32, - matrixCol2: vec3, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: Uniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(uniforms.matrixCol0, uniforms.matrixCol1, uniforms.matrixCol2); - let transformed = matrix * vec3(input.position, 1.0); - let pos = transformed.xy; - let ndc = pos * 2.0 - 1.0; - output.position = vec4(ndc.x, -ndc.y, 0.0, 1.0); - output.bezier = input.bezier; - return output; -} -\`,La=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) texCoord: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -struct Uniforms { - matrix: mat3x3, - color: vec4, - alpha: f32, -} - -@group(0) @binding(0) var uniforms: Uniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let pos = uniforms.matrix * vec3(input.position, 1.0); - let ndc = pos.xy * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - output.texCoord = input.texCoord; - let premultipliedColor = vec4( - uniforms.color.rgb * uniforms.color.a * uniforms.alpha, - uniforms.color.a * uniforms.alpha - ); - output.color = premultipliedColor; - return output; -} -\`,cp=\` -struct VertexInput { - @location(0) position: vec2, - @location(1) texCoord: vec2, -} - -struct InstanceInput { - @location(2) textureRect: vec4, - @location(3) textureDim: vec4, - @location(4) matrixTx: vec4, - @location(5) matrixScale: vec4, - @location(6) mulColor: vec4, - @location(7) addColor: vec4, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) mulColor: vec4, - @location(2) addColor: vec4, -} - -@vertex -fn main( - input: VertexInput, - instance: InstanceInput, - @builtin(instance_index) instanceIdx: u32 -) -> VertexOutput { - var output: VertexOutput; - let texX = instance.textureRect.x + input.texCoord.x * instance.textureRect.z; - let texY = instance.textureRect.y + input.texCoord.y * instance.textureRect.w; - output.texCoord = vec2(texX, texY); - var pos = vec2(input.position.x, 1.0 - input.position.y); - pos = pos * vec2(instance.textureDim.x, instance.textureDim.y); - let scale0 = instance.matrixScale.x; - let rotate0 = instance.matrixScale.y; - let scale1 = instance.matrixScale.z; - let rotate1 = instance.matrixScale.w; - let transformedX = pos.x * scale0 + pos.y * scale1 + instance.matrixTx.x; - let transformedY = pos.x * rotate0 + pos.y * rotate1 + instance.matrixTx.y; - var position = vec2(transformedX, transformedY) / vec2(instance.textureDim.z, instance.textureDim.w); - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - output.mulColor = instance.mulColor; - output.addColor = instance.addColor; - return output; -} -\`,ka=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} - -struct GradientUniforms { - inverseMatrix: mat3x3, - gradientType: f32, - focal: f32, - spread: f32, - radius: f32, - linearPoints: vec4, - color: vec4, - contextMatrix0: vec4, - contextMatrix1: vec4, - contextMatrix2: vec4, -} - -@group(0) @binding(0) var gradient: GradientUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let contextMatrix = mat3x3(gradient.contextMatrix0.xyz, gradient.contextMatrix1.xyz, gradient.contextMatrix2.xyz); - let pos = contextMatrix * vec3(input.position, 1.0); - let ndc = vec2(pos.x * 2.0 - 1.0, pos.y * 2.0 - 1.0); - output.position = vec4(ndc.x, ndc.y * yFlipSign, 0.0, 1.0); - let uvPos = gradient.inverseMatrix * vec3(input.position, 1.0); - output.v_uv = uvPos.xy; - output.bezier = input.bezier; - output.color = gradient.color; - return output; -} -\`,Ia=\` -override yFlipSign: f32 = 1.0; - -struct VertexInput { - @location(0) position: vec2, - @location(1) bezier: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, - @location(2) worldPos: vec2, -} - -struct BitmapUniforms { - bitmapMatrix: mat3x3, - width: f32, - height: f32, - repeat: f32, - _pad: f32, - color: vec4, - contextMatrix0: vec4, - contextMatrix1: vec4, - contextMatrix2: vec4, -} - -@group(0) @binding(0) var bitmap: BitmapUniforms; - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let matrix = mat3x3(bitmap.contextMatrix0.xyz, bitmap.contextMatrix1.xyz, bitmap.contextMatrix2.xyz); - let transformedPos = matrix * vec3(input.position, 1.0); - let clipX = transformedPos.x * 2.0 - 1.0; - let clipY = (transformedPos.y * 2.0 - 1.0) * yFlipSign; - output.position = vec4(clipX, clipY, 0.0, 1.0); - output.bezier = input.bezier; - output.color = bitmap.color; - output.worldPos = input.position; - return output; -} -\`,Nt=\` -fn isInside(uv: vec2) -> f32 { - let s = step(vec2(0.0), uv) * step(uv, vec2(1.0)); - return s.x * s.y; -}\`,lp=\` - const positions = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2(-1.0, 1.0), - vec2(-1.0, 1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0) - );\`,es=\` - const vertices = array, 6>( - vec2(0.0, 0.0), - vec2(1.0, 0.0), - vec2(0.0, 1.0), - vec2(0.0, 1.0), - vec2(1.0, 0.0), - vec2(1.0, 1.0) - );\`,Be=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -}\`,fo=t=>\` -\${Be} - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${lp} - var texCoords = array, 6>( - vec2(0.0, \${t?"1.0":"0.0"}), - vec2(1.0, \${t?"1.0":"0.0"}), - vec2(0.0, \${t?"0.0":"1.0"}), - vec2(0.0, \${t?"0.0":"1.0"}), - vec2(1.0, \${t?"1.0":"0.0"}), - vec2(1.0, \${t?"0.0":"1.0"}) - ); - output.position = vec4(positions[vertexIndex], 0.0, 1.0); - output.texCoord = texCoords[vertexIndex]; - return output; -} -\`,up=fo(!0),fp=fo(!1),hp=fo(!1),dp=\` -struct VertexInput { - @location(0) position: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, -} - -@vertex -fn main(input: VertexInput) -> VertexOutput { - var output: VertexOutput; - let ndc = input.position * 2.0 - 1.0; - output.position = vec4(ndc.x, ndc.y, 0.0, 1.0); - return output; -} -\`,pp=\` -struct PositionUniforms { - offset: vec2, - size: vec2, - viewport: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: PositionUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = vec2(vertex.x, 1.0 - vertex.y); - var position = vertex * uniforms.size + uniforms.offset; - position = position / uniforms.viewport; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - return output; -} -\`,mp=\` -struct BitmapSyncUniforms { - nodeRect: vec4, - textureSize: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: BitmapSyncUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - let pixelPos = vec2( - uniforms.nodeRect.x + vertex.x * uniforms.nodeRect.z, - uniforms.nodeRect.y + vertex.y * uniforms.nodeRect.w - ); - let ndc = pixelPos / uniforms.textureSize * 2.0 - 1.0; - output.position = vec4(ndc.x, -ndc.y, 0.0, 1.0); - output.texCoord = pixelPos / uniforms.textureSize; - return output; -} -\`,gp=\` -struct ScaleUniforms { - matrix: vec4, - translate: vec2, - srcSize: vec2, - dstSize: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: ScaleUniforms; -\`,bp=\` - var pos = vertex * uniforms.srcSize; - let a = uniforms.matrix.x; - let b = uniforms.matrix.y; - let c = uniforms.matrix.z; - let d = uniforms.matrix.w; - let tx = uniforms.translate.x; - let ty = uniforms.translate.y; - let transformedX = pos.x * a + pos.y * c + tx; - let transformedY = pos.x * b + pos.y * d + ty; - var position = vec2(transformedX, transformedY) / uniforms.dstSize; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); -\`,ho=t=>\` -\${gp} - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = \${t?"vec2(vertex.x, 1.0 - vertex.y)":"vertex"}; -\${bp} - return output; -} -\`,xp=ho(!1),yp=ho(!0),vp=ho(!1),_a=t=>\` -struct PositionUniforms { - offset: vec2, - size: vec2, - viewport: vec2, - padding: vec2, -} - -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, -} - -@group(0) @binding(0) var uniforms: PositionUniforms; - -@vertex -fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var output: VertexOutput; -\${es} - let vertex = vertices[vertexIndex]; - output.texCoord = \${t?"vec2(vertex.x, 1.0 - vertex.y)":"vertex"}; - var position = vertex * uniforms.size + uniforms.offset; - position = position / uniforms.viewport; - position = position * 2.0 - 1.0; - output.position = vec4(position.x, -position.y, 0.0, 1.0); - return output; -} -\`,Mp=_a(!1),Sp=_a(!0),$p=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let f_val = input.bezier.x * input.bezier.x - input.bezier.y; - let dx = dpdx(f_val); - let dy = dpdy(f_val); - - if (input.bezier.x == 0.5 && input.bezier.y == 0.5) { - return vec4(input.color.rgb * input.color.a, input.color.a); - } - - let dist = f_val * inverseSqrt(dx * dx + dy * dy); - let coverage = smoothstep(0.5, -0.5, dist); - - if (coverage <= 0.001) { - discard; - } - - let finalAlpha = input.color.a * min(coverage, 1.0); - return vec4(input.color.rgb * finalAlpha, finalAlpha); -} -\`,Tp=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let f_val = input.bezier.x * input.bezier.x - input.bezier.y; - let dx = dpdx(f_val); - let dy = dpdy(f_val); - let dist = f_val * inverseSqrt(dx * dx + dy * dy); - let alpha = smoothstep(0.5, -0.5, dist); - - if (alpha <= 0.001) { - discard; - } - - return vec4(0.0, 0.0, 0.0, min(alpha, 1.0)); -} -\`,Bp=\` -struct FragmentInput { - @builtin(position) position: vec4, - @location(0) color: vec4, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let a = input.color.a; - return vec4(input.color.r * a, input.color.g * a, input.color.b * a, a); -} -\`,Pp=\` -struct FragmentInput { - @location(0) bezier: vec2, -} - -@fragment -fn main(input: FragmentInput) -> @location(0) vec4 { - let px = dpdx(input.bezier); - let py = dpdy(input.bezier); - let f = (2.0 * input.bezier.x) * vec2(px.x, py.x) - vec2(px.y, py.y); - let alpha = 0.5 - (input.bezier.x * input.bezier.x - input.bezier.y) / length(f); - if (alpha <= 0.0) { - discard; - } - return vec4(min(alpha, 1.0)); -} -\`,Ap=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return input.color; -} -\`,Fp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var textureData: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let textureColor = textureSampleLevel(textureData, textureSampler, input.texCoord, 0); - return textureColor * input.color; -} -\`,wp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) mulColor: vec4, - @location(2) addColor: vec4, -} - -@group(0) @binding(0) var textureSampler: sampler; -@group(0) @binding(1) var textureData: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var src = textureSample(textureData, textureSampler, input.texCoord); - src = vec4(src.rgb / max(0.0001, src.a), src.a); - src = clamp(src * input.mulColor + input.addColor, vec4(0.0), vec4(1.0)); - src = vec4(src.rgb * src.a, src.a); - return src; -} -\`,po=\` -struct GradientUniforms { - inverseMatrix: mat3x3, - gradientType: f32, - focal: f32, - spread: f32, - radius: f32, - linearPoints: vec4, -} - -@group(0) @binding(0) var gradient: GradientUniforms; -@group(0) @binding(1) var gradientSampler: sampler; -@group(0) @binding(2) var gradientTexture: texture_2d; - -override GRADIENT_TYPE: u32 = 0u; -override SPREAD_MODE: u32 = 2u; - -fn applySpread(t: f32) -> f32 { - if (SPREAD_MODE == 0u) { - return 1.0 - abs(fract(t * 0.5) * 2.0 - 1.0); - } else if (SPREAD_MODE == 1u) { - return fract(t); - } else { - return clamp(t, 0.0, 1.0); - } -} -\`,mo=\` - var t: f32; - if (GRADIENT_TYPE == 0u) { - let a = gradient.linearPoints.xy; - let b = gradient.linearPoints.zw; - let ab = b - a; - let ap = p - a; - let dotAB = dot(ab, ab); - if (dotAB < 0.0001) { - t = 0.0; - } else { - t = dot(ab, ap) / dotAB; - } - } else { - let r = gradient.radius; - let coord = p / r; - let focalRatio = gradient.focal; - - if (abs(focalRatio) < 0.001) { - t = length(coord); - } else { - let focal = vec2(focalRatio, 0.0); - let diff = coord - focal; - let lenDiff = length(diff); - - if (lenDiff < 0.0001) { - t = 0.0; - } else { - let dir = diff / lenDiff; - - // Solve quadratic equation for unit circle intersection (a=1 since dir is normalized) - let b_coef = 2.0 * dot(dir, focal); - let c_coef = dot(focal, focal) - 1.0; - let discriminant = b_coef * b_coef - 4.0 * c_coef; - let x = (-b_coef + sqrt(max(discriminant, 0.0))) * 0.5; - t = lenDiff / abs(x); - } - } - } - t = applySpread(t); - let gradientColor = textureSampleLevel(gradientTexture, gradientSampler, vec2(t, 0.5), 0); -\`,Op=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.v_uv; -\${mo} - let result = gradientColor * input.color; - return vec4(result.rgb * result.a, result.a); -} -\`,Ep=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) v_uv: vec2, - @location(1) bezier: vec2, - @location(2) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.v_uv; -\${mo} - return vec4(gradientColor.rgb * gradientColor.a, gradientColor.a); -} -\`,Rp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} -\${po} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let p = input.texCoord; -\${mo} - let result = gradientColor * input.color; - return vec4(result.rgb * result.a, result.a); -} -\`,Cp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) bezier: vec2, - @location(1) color: vec4, - @location(2) worldPos: vec2, -} - -struct BitmapUniforms { - bitmapMatrix: mat3x3, - textureWidth: f32, - textureHeight: f32, - repeat: f32, - _pad: f32, -} - -@group(0) @binding(0) var uniforms: BitmapUniforms; -@group(0) @binding(1) var bitmapSampler: sampler; -@group(0) @binding(2) var bitmapTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let u = input.bezier.x; - let v = input.bezier.y; - if (abs(u - 0.5) > 0.001 || abs(v - 0.5) > 0.001) { - let d = u * u - v; - if (d > 0.0) { - discard; - } - } - let transformedPos = uniforms.bitmapMatrix * vec3(input.worldPos, 1.0); - var uv = vec2( - transformedPos.x / uniforms.textureWidth, - transformedPos.y / uniforms.textureHeight - ); - if (uniforms.repeat > 0.5) { - uv = fract(uv); - } - let bitmapColor = textureSampleLevel(bitmapTexture, bitmapSampler, uv, 0); - let alpha = bitmapColor.a * input.color.a; - return vec4(bitmapColor.rgb * input.color.a, alpha); -} -\`,Up=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - return textureSampleLevel(inputTexture, textureSampler, uv, 0); -} -\`,Gp=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = (input.texCoord - uniforms.offset) * uniforms.scale; - let clampedUv = clamp(uv, vec2(0.0), vec2(1.0)); - let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0); - let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0; - return select(vec4(0.0, 0.0, 0.0, 0.0), color, inBounds); -} -\`,Lp=\` -\${Be} - -struct CopyUniforms { - scale: vec2, - offset: vec2, -} - -@group(0) @binding(0) var uniforms: CopyUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - let clampedUv = clamp(uv, vec2(0.0), vec2(1.0)); - let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0); - let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0; - return select(vec4(0.0, 0.0, 0.0, 0.0), color, inBounds); -} -\`,kp=\` -\${Be} - -struct ColorTransformUniforms { - mul: vec4, - add: vec4, -} - -@group(0) @binding(0) var ct: ColorTransformUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - color = clamp(color * ct.mul + ct.add, vec4(0.0), vec4(1.0)); - color = vec4(color.rgb * color.a, color.a); - - return color; -} -\`,Ip=\` -\${Be} - -struct YFlipCTUniforms { - scale: vec2, - offset: vec2, - mul: vec4, - add: vec4, -} - -@group(0) @binding(0) var uniforms: YFlipCTUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let uv = input.texCoord * uniforms.scale + uniforms.offset; - var color = textureSampleLevel(inputTexture, textureSampler, uv, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - color = clamp(color * uniforms.mul + uniforms.add, vec4(0.0), vec4(1.0)); - color = vec4(color.rgb * color.a, color.a); - - return color; -} -\`,_p=\` -\${Be} - -struct ColorMatrixUniforms { - matrix: mat4x4, - offset: vec4, -} - -@group(0) @binding(0) var uniforms: ColorMatrixUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); - - color = vec4(color.rgb / max(vec3(0.0001), vec3(color.a)), color.a); - var result = uniforms.matrix * color + uniforms.offset; - result = clamp(result, vec4(0.0), vec4(1.0)); - result = vec4(result.rgb * result.a, result.a); - - return result; -} -\`,Vp=\` -@fragment -fn main() -> @location(0) vec4 { - return vec4(0.0, 0.0, 0.0, 0.0); -} -\`,Dp=\` -\${Be} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); -} -\`,Np=\` -\${Be} - -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0); -} -\`,zp=\` -struct VertexOutput { - @builtin(position) position: vec4, - @location(0) texCoord: vec2, - @location(1) color: vec4, -} - -struct BlendUniforms { - blendMode: f32, -} - -@group(0) @binding(1) var blend: BlendUniforms; -@group(0) @binding(2) var srcSampler: sampler; -@group(0) @binding(3) var srcTexture: texture_2d; -@group(0) @binding(4) var dstSampler: sampler; -@group(0) @binding(5) var dstTexture: texture_2d; - -fn blendNormal(src: vec4, dst: vec4) -> vec4 { - return src; -} - -fn blendMultiply(src: vec4, dst: vec4) -> vec4 { - return src * dst; -} - -fn blendScreen(src: vec4, dst: vec4) -> vec4 { - return src + dst - src * dst; -} - -fn blendAdd(src: vec4, dst: vec4) -> vec4 { - return min(src + dst, vec4(1.0)); -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let src = textureSampleLevel(srcTexture, srcSampler, input.texCoord, 0); - let dst = textureSampleLevel(dstTexture, dstSampler, input.texCoord, 0); - var result: vec4; - if (blend.blendMode < 0.5) { - result = blendNormal(src, dst); - } else if (blend.blendMode < 1.5) { - result = blendMultiply(src, dst); - } else if (blend.blendMode < 2.5) { - result = blendScreen(src, dst); - } else { - result = blendAdd(src, dst); - } - return result * input.color; -} -\`,Xp=\` -\${Be} - -override IS_INNER: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GlowUniforms { - color: vec4, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: GlowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blurColor = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - var rawAlpha = blurColor.a; - if (IS_INNER == 1u) { - rawAlpha = 1.0 - rawAlpha; - } - let glowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0); - let glowColor = vec4(uniforms.color.rgb * glowAlpha, uniforms.color.a * glowAlpha); - if (IS_INNER == 1u) { - let innerGlow = glowColor * baseColor.a; - if (IS_KNOCKOUT == 1u) { - return innerGlow; - } else { - return innerGlow + baseColor * (1.0 - glowColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - return glowColor * (1.0 - baseColor.a); - } else { - return baseColor + glowColor * (1.0 - baseColor.a); - } - } -} -\`,Yp=\` -\${Be} - -override IS_INNER: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; -override IS_HIDE_OBJECT: u32 = 0u; - -struct DropShadowUniforms { - color: vec4, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, -} - -@group(0) @binding(0) var uniforms: DropShadowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - var rawAlpha = blur.a; - if (IS_INNER == 1u) { - rawAlpha = 1.0 - rawAlpha; - } - let shadowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0); - let shadowColor = vec4(uniforms.color.rgb * shadowAlpha, uniforms.color.a * shadowAlpha); - - if (IS_INNER == 1u) { - let innerShadow = shadowColor * baseColor.a; - if (IS_KNOCKOUT == 1u) { - return innerShadow; - } else { - return innerShadow + baseColor * (1.0 - shadowColor.a); - } - } else { - if (IS_HIDE_OBJECT == 1u) { - return shadowColor; - } else if (IS_KNOCKOUT == 1u) { - return shadowColor * (1.0 - baseColor.a); - } else { - return shadowColor * (1.0 - baseColor.a) + baseColor; - } - } -} -\`,Wp=\` -\${Be} - -override GLOW_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GradientGlowUniforms { - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: GradientGlowUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -@group(0) @binding(4) var gradientLUT: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - var blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - blur.a = clamp(blur.a * uniforms.strength, 0.0, 1.0); - let glowColor = textureSampleLevel(gradientLUT, textureSampler, vec2(blur.a, 0.5), 0); - var result: vec4; - if (GLOW_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = glowColor; - } else { - result = base - base * glowColor.a + glowColor; - } - } else if (GLOW_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = glowColor * base.a; - } else { - result = glowColor * base.a + base * (1.0 - glowColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = glowColor - glowColor * base.a; - } else { - result = base + glowColor - glowColor * base.a; - } - } - return result; -} -\`,jp=\` -\${Be} - -override BEVEL_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct GradientBevelUniforms { - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: GradientBevelUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -@group(0) @binding(4) var gradientLUT: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset; - let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV); - - var highlightAlpha = blur1.a - blur2.a; - var shadowAlpha = blur2.a - blur1.a; - highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0); - shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0); - - let lutCoord = 0.5019607843137255 - 0.5019607843137255 * shadowAlpha + 0.4980392156862745 * highlightAlpha; - let bevelColor = textureSampleLevel(gradientLUT, textureSampler, vec2(lutCoord, 0.5), 0); - - var result: vec4; - if (BEVEL_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor; - } else { - result = base - base * bevelColor.a + bevelColor; - } - } else if (BEVEL_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor * base.a; - } else { - result = bevelColor * base.a + base * (1.0 - bevelColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = bevelColor - bevelColor * base.a; - } else { - result = base + bevelColor - bevelColor * base.a; - } - } - - return result; -} -\`,Hp=\` -\${Be} - -override BEVEL_TYPE: u32 = 0u; -override IS_KNOCKOUT: u32 = 0u; - -struct BevelUniforms { - highlightColor: vec4, - shadowColor: vec4, - strength: f32, - _padding1: f32, - _padding2: f32, - _padding3: f32, - baseScale: vec2, - baseOffset: vec2, - blurScale: vec2, - blurOffset: vec2, -} - -@group(0) @binding(0) var uniforms: BevelUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var blurTexture: texture_2d; -@group(0) @binding(3) var baseTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset; - let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV); - - let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset; - let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV); - - let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset; - let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV); - - var highlightAlpha = blur1.a - blur2.a; - var shadowAlpha = blur2.a - blur1.a; - highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0); - shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0); - - let bevelColor = uniforms.highlightColor * highlightAlpha + uniforms.shadowColor * shadowAlpha; - var result: vec4; - if (BEVEL_TYPE == 0u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor; - } else { - result = base - base * bevelColor.a + bevelColor; - } - } else if (BEVEL_TYPE == 1u) { - if (IS_KNOCKOUT == 1u) { - result = bevelColor * base.a; - } else { - result = bevelColor * base.a + base * (1.0 - bevelColor.a); - } - } else { - if (IS_KNOCKOUT == 1u) { - result = bevelColor - bevelColor * base.a; - } else { - result = base + bevelColor - bevelColor * base.a; - } - } - - return result; -} -\`,Kp=\` -\${Be} - -struct BevelBaseUniforms { - offset: vec2, - _padding: vec2, -} - -@group(0) @binding(0) var uniforms: BevelBaseUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var sourceTexture: texture_2d; -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let original = textureSampleLevel(sourceTexture, textureSampler, input.texCoord, 0); - let shiftedUV = input.texCoord - uniforms.offset; - let shifted = textureSampleLevel(sourceTexture, textureSampler, shiftedUV, 0) * isInside(shiftedUV); - return original * (1.0 - shifted.a); -} -\`;class N{static getFillVertexShader(){return Ca}static getFillMainVertexShader(){return Ca}static getFillFragmentShader(){return $p}static getStencilWriteVertexShader(){return Ua}static getStencilWriteMainVertexShader(){return Ua}static getStencilWriteFragmentShader(){return Tp}static getStencilFillVertexShader(){return Ga}static getStencilFillMainVertexShader(){return Ga}static getStencilFillFragmentShader(){return Bp}static getMaskVertexShader(){return ap}static getMaskFragmentShader(){return Pp}static getBasicVertexShader(){return La}static getBasicMainVertexShader(){return La}static getBasicFragmentShader(){return Ap}static getTextureFragmentShader(){return Fp}static getInstancedVertexShader(){return cp}static getInstancedFragmentShader(){return wp}static getGradientFillVertexShader(){return ka}static getGradientFillMainVertexShader(){return ka}static getGradientFillFragmentShader(){return Op}static getGradientFillStencilFragmentShader(){return Ep}static getGradientFragmentShader(){return Rp}static getBitmapFillVertexShader(){return Ia}static getBitmapFillMainVertexShader(){return Ia}static getBitmapFillFragmentShader(){return Cp}static getBlendFragmentShader(){return zp}static getBlurFilterVertexShader(){return up}static getBitmapSyncVertexShader(){return mp}static getBitmapSyncFragmentShader(){return Np}static getBlurFilterFragmentShader(e){const r=e.toFixed(1);return\` -\${Be} - -struct BlurUniforms { - offset: vec2, - fraction: f32, - samples: f32, -} - -@group(0) @binding(0) var uniforms: BlurUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var inputTexture: texture_2d; - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let offset = uniforms.offset; - let fraction = uniforms.fraction; - let samples = uniforms.samples; - var color = textureSample(inputTexture, textureSampler, input.texCoord); - for (var i: f32 = 1.0; i < \${r}; i += 1.0) { - color += textureSample(inputTexture, textureSampler, input.texCoord + offset * i); - color += textureSample(inputTexture, textureSampler, input.texCoord - offset * i); - } - color += textureSample(inputTexture, textureSampler, input.texCoord + offset * \${r}) * fraction; - color += textureSample(inputTexture, textureSampler, input.texCoord - offset * \${r}) * fraction; - color /= samples; - return color; -} -\`}static getTextureCopyFragmentShader(){return Up}static getBlurTextureCopyFragmentShader(){return Gp}static getFilterOutputFragmentShader(){return Lp}static getColorTransformFragmentShader(){return kp}static getYFlipColorTransformFragmentShader(){return Ip}static getColorMatrixFilterFragmentShader(){return _p}static getGlowFilterFragmentShader(){return Xp}static getDropShadowFilterFragmentShader(){return Yp}static getGradientGlowFilterFragmentShader(){return Wp}static getGradientBevelFilterFragmentShader(){return jp}static getBevelFilterFragmentShader(){return Hp}static getBevelBaseFragmentShader(){return Kp}static getConvolutionFilterFragmentShader(e,r,n=!0,s=!0){const o=Math.floor(e*.5),i=Math.floor(r*.5),l=e*r;let c="";for(let h=0;h, - rcpDivisor: f32, - bias: f32, - substituteColor: vec4, - matrix: array, \${Math.ceil(l/4)}>, -} - -@group(0) @binding(0) var uniforms: ConvolutionUniforms; -@group(0) @binding(1) var sourceSampler: sampler; -@group(0) @binding(2) var sourceTexture: texture_2d; - -\${Be} - -\${Nt} - -fn getMatrixWeight(index: i32) -> f32 { - let vecIndex = index / 4; - let component = index % 4; - let vec = uniforms.matrix[vecIndex]; - if (component == 0) { return vec.x; } - else if (component == 1) { return vec.y; } - else if (component == 2) { return vec.z; } - else { return vec.w; } -} - -fn getWeightedColor(i: i32, weight: f32) -> vec4 { - let rcpSize = uniforms.rcpSize; - let iDivX = i / \${e}; - let iModX = i - \${e} * iDivX; - let offset = vec2(f32(iModX - \${o}), f32(\${i} - iDivX)); - var uv = input.texCoord + offset * rcpSize; - var color = textureSample(sourceTexture, sourceSampler, uv); - color = vec4(color.rgb / max(0.0001, color.a), color.a); - \${a} - return color * weight; -} - -var input: VertexOutput; - -@vertex -fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput { - var positions = array, 6>( - vec2(-1.0, -1.0), - vec2(1.0, -1.0), - vec2(-1.0, 1.0), - vec2(-1.0, 1.0), - vec2(1.0, -1.0), - vec2(1.0, 1.0) - ); - var texCoords = array, 6>( - vec2(0.0, 1.0), - vec2(1.0, 1.0), - vec2(0.0, 0.0), - vec2(0.0, 0.0), - vec2(1.0, 1.0), - vec2(1.0, 0.0) - ); - var output: VertexOutput; - output.position = vec4(positions[vertexIndex], 0.0, 1.0); - output.texCoord = texCoords[vertexIndex]; - return output; -} - -@fragment -fn fs_main(fragInput: VertexOutput) -> @location(0) vec4 { - input = fragInput; - let rcpDivisor = uniforms.rcpDivisor; - let bias = uniforms.bias; - var result = vec4(0.0); - \${c} - result = clamp(result * rcpDivisor + bias, vec4(0.0), vec4(1.0)); - \${u} - result = vec4(result.rgb * result.a, result.a); - return result; -} -\`}static getComplexBlendFragmentShader(){return N.getUnifiedComplexBlendFragmentShader()}static getBlendModeIndex(e){switch(e){case"subtract":return 0;case"multiply":return 1;case"lighten":return 2;case"darken":return 3;case"overlay":return 4;case"hardlight":return 5;case"difference":return 6;case"invert":return 7;default:return 1}}static getUnifiedComplexBlendFragmentShader(){return\` -\${Be} - -struct BlendUniforms { - mulColor: vec4, - addColor: vec4, - blendMode: f32, - _pad0: f32, - _pad1: f32, - _pad2: f32, -} - -@group(0) @binding(0) var uniforms: BlendUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var dstTexture: texture_2d; -@group(0) @binding(3) var srcTexture: texture_2d; - -fn blend(src: vec4, dst: vec4, mode: i32) -> vec4 { - if (src.a == 0.0) { return dst; } - if (dst.a == 0.0) { return src; } - - let a = src - src * dst.a; - let b = dst - dst * src.a; - - if (mode == 1) { - let c = src * dst; - return a + b + c; - } - - let srcRgb = src.rgb / src.a; - let dstRgb = dst.rgb / dst.a; - - var blended: vec3; - - switch (mode) { - case 0: { - blended = dstRgb - srcRgb; - } - case 2: { - blended = mix(srcRgb, dstRgb, step(srcRgb, dstRgb)); - } - case 3: { - blended = mix(srcRgb, dstRgb, step(dstRgb, srcRgb)); - } - case 4: { - let mul = srcRgb * dstRgb; - let c1 = 2.0 * mul; - let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0; - blended = mix(c1, c2, step(vec3(0.5), dstRgb)); - } - case 5: { - let mul = srcRgb * dstRgb; - let c1 = 2.0 * mul; - let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0; - blended = mix(c1, c2, step(vec3(0.5), srcRgb)); - } - case 6: { - blended = abs(srcRgb - dstRgb); - } - case 7: { - let ib = dst - dst * src.a; - let ic = vec4(src.a - dst.rgb * src.a, src.a); - return ib + ic; - } - default: { - blended = srcRgb; - } - } - - var c = vec4(blended, src.a * dst.a); - c = vec4(c.rgb * c.a, c.a); - return a + b + c; -} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - var dst = textureSample(dstTexture, textureSampler, input.texCoord); - var src = textureSample(srcTexture, textureSampler, input.texCoord); - let mul = uniforms.mulColor; - let add = uniforms.addColor; - if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0 - || add.x != 0.0 || add.y != 0.0 || add.z != 0.0) { - src = vec4(src.rgb / max(vec3(0.0001), vec3(src.a)), src.a); - src = clamp(src * mul + add, vec4(0.0), vec4(1.0)); - src = vec4(src.rgb * src.a, src.a); - } - return blend(src, dst, i32(uniforms.blendMode)); -} -\`}static getDisplacementMapFilterFragmentShader(e,r,n){let s,o;switch(e){case 1:s="mapColor.r";break;case 2:s="mapColor.g";break;case 4:s="mapColor.b";break;case 8:s="mapColor.a";break;default:s="0.5";break}switch(r){case 1:o="mapColor.r";break;case 2:o="mapColor.g";break;case 4:o="mapColor.b";break;case 8:o="mapColor.a";break;default:o="0.5";break}let i,l=!1;switch(n){case 0:i=\` -sourceColor = textureSample(srcTexture, textureSampler, uv); -\`;break;case 1:l=!0,i=\` -sourceColor = mix(uniforms.substituteColor, textureSample(srcTexture, textureSampler, uv), isInside(uv)); -\`;break;case 2:i=\` -sourceColor = textureSample(srcTexture, textureSampler, fract(uv)); -\`;break;case 3:i=\` -let insideUV = step(abs(uv - vec2(0.5)), vec2(0.5)); -sourceColor = textureSample(srcTexture, textureSampler, mix(input.texCoord, uv, insideUV)); -\`;break;default:i=\` -sourceColor = textureSample(srcTexture, textureSampler, fract(uv)); -\`;break}return\` -\${Be} - -\${l?\`struct DisplacementUniforms { - uvToStScale: vec2, - uvToStOffset: vec2, - scale: vec2, - padding: vec2, - substituteColor: vec4, -}\`:\`struct DisplacementUniforms { - uvToStScale: vec2, - uvToStOffset: vec2, - scale: vec2, - padding: vec2, -}\`} - -@group(0) @binding(0) var uniforms: DisplacementUniforms; -@group(0) @binding(1) var textureSampler: sampler; -@group(0) @binding(2) var srcTexture: texture_2d; -@group(0) @binding(3) var mapTexture: texture_2d; - -\${Nt} - -@fragment -fn main(input: VertexOutput) -> @location(0) vec4 { - let stCoord = vec2(input.texCoord.x, 1.0 - input.texCoord.y); - let st = stCoord * uniforms.uvToStScale - uniforms.uvToStOffset; - let mapColor = textureSample(mapTexture, textureSampler, vec2(st.x, 1.0 - st.y)); - let offset = vec2(\${s}, \${o}) - 0.5; - let uv = input.texCoord + offset * uniforms.scale; - var sourceColor: vec4; - \${i} - return mix(textureSample(srcTexture, textureSampler, input.texCoord), sourceColor, isInside(st)); -} -\`}static getNodeClearVertexShader(){return dp}static getNodeClearFragmentShader(){return Vp}static getPositionedTextureVertexShader(){return pp}static getTextureScaleVertexShader(){return xp}static getTextureScaleBlendVertexShader(){return yp}static getComplexBlendScaleVertexShader(){return vp}static getComplexBlendVertexShader(){return fp}static getComplexBlendCopyVertexShader(){return hp}static getComplexBlendOutputVertexShader(){return Mp}static getFilterComplexBlendOutputVertexShader(){return Sp}static getPositionedTextureFragmentShader(){return Dp}}const rr={arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},un={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};class qp{device;format;pipelines;bindGroupLayouts;sampleCount;shaderModuleCache=new Map;filterBindGroupLayouts=new Map;constructor(e,r){this.device=e,this.format=r,this.pipelines=new Map,this.bindGroupLayouts=new Map,this.sampleCount=ao,this.initialize()}getOrCreateShaderModule(e,r){let n=this.shaderModuleCache.get(e);return n||(n=this.device.createShaderModule({code:r}),this.shaderModuleCache.set(e,n)),n}initialize(){this.createFillPipeline(),this.createStencilFillPipelines(),this.createClipPipeline(),this.createMaskUnionPipelines(),this.createMaskPipeline(),this.createBasicPipeline(),this.createTexturePipeline(),this.createInstancedPipeline(),this.createGradientPipeline(),this.createBitmapFillPipeline(),this.createBlendPipeline(),this.createNodeClearPipeline()}lazyInitGroups=new Set;lazyGroupMap=new Map([...Array.from({length:16},(e,r)=>[\`blur_filter_\${r+1}\`,"blur_filter"]),["blur_filter","blur_filter"],["texture_copy","texture_copy"],["texture_copy_rgba8","texture_copy"],["color_transform","texture_copy"],["y_flip_color_transform","texture_copy"],["texture_erase","texture_copy"],["blur_texture_copy","texture_copy"],["filter_blend","texture_copy"],["texture_copy_bgra","texture_copy"],["filter_output","texture_copy"],["filter_output_add","texture_copy"],["filter_output_screen","texture_copy"],["filter_output_alpha","texture_copy"],["filter_output_erase","texture_copy"],["texture_copy_bgra_msaa","texture_copy"],["filter_output_msaa","texture_copy"],["filter_output_add_msaa","texture_copy"],["filter_output_screen_msaa","texture_copy"],["filter_output_alpha_msaa","texture_copy"],["filter_output_erase_msaa","texture_copy"],["positioned_texture","texture_copy"],["positioned_texture_rgba","texture_copy"],["bitmap_render_msaa","texture_copy"],["bitmap_render","texture_copy"],["texture_scale","texture_copy"],["texture_scale_blend","texture_copy"],["bitmap_sync","bitmap_sync"],["color_matrix_filter","filter"],["bevel_base","filter"],["glow_filter","filter"],["drop_shadow_filter","filter"],["bevel_filter","filter"],["gradient_glow_filter","filter"],["gradient_bevel_filter","filter"],["complex_blend","complex_blend"],["complex_blend_copy","complex_blend"],["complex_blend_scale","complex_blend"],["complex_blend_output","complex_blend"],["complex_blend_output_msaa","complex_blend"],["filter_complex_blend_output","complex_blend"],["filter_complex_blend_output_msaa","complex_blend"]]);ensureLazyGroup(e){const r=this.lazyGroupMap.get(e);if(!(!r||this.lazyInitGroups.has(r)))switch(this.lazyInitGroups.add(r),r){case"blur_filter":this.createBlurFilterPipeline();break;case"texture_copy":this.createTextureCopyPipeline();break;case"bitmap_sync":this.createBitmapSyncPipeline();break;case"filter":this.createColorMatrixFilterPipeline();break;case"complex_blend":this.createComplexBlendPipelines();break}}preloadLazyGroups(){const e=["blur_filter","texture_copy","bitmap_sync","filter","complex_blend"];for(const r of e)this.ensureLazyGroup(r)}createFillPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform",hasDynamicOffset:!0}}]});this.bindGroupLayouts.set("fill_dynamic",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("fillVertex",N.getFillVertexShader()),s=this.getOrCreateShaderModule("fillFragment",N.getFillFragmentShader()),o=rr,i=un,l=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}}),c=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("fill",l),this.pipelines.set("fill_bgra",c);const u=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[o],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:i}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:255,stencilWriteMask:0},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("fill_bgra_stencil",u)}createStencilFillPipelines(){const e=rr,r=this.bindGroupLayouts.get("fill_dynamic"),n=this.device.createPipelineLayout({bindGroupLayouts:[r]}),s=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write",s);const o=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill",o);const i=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write_atlas",i);const l=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:this.format,writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none",frontFace:"ccw"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"increment-wrap"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"decrement-wrap"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set("stencil_write_main",l);const c=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"max"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_atlas",c);const u=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:this.format,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"max"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_main",u);const a=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilFillVertex",N.getStencilFillVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilFillFragment",N.getStencilFillFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"greater",failOp:"keep",depthFailOp:"replace",passOp:"replace"},stencilBack:{compare:"greater",failOp:"keep",depthFailOp:"replace",passOp:"replace"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("stencil_fill_masked",a)}createClipPipeline(){const e=rr,r=this.bindGroupLayouts.get("fill_dynamic"),n=this.device.createPipelineLayout({bindGroupLayouts:[r]}),s=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"zero",depthFailOp:"invert",passOp:"invert"},stencilBack:{compare:"always",failOp:"zero",depthFailOp:"invert",passOp:"invert"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("clip_write",s);const o=this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),i=this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader());for(let l=1;l<=8;l++){const c=1<1){const g={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}};this.pipelines.set("texture_copy_bgra_msaa",this.createFullscreenQuadPipeline(r,n,s,this.format,g,this.sampleCount));const m={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};this.pipelines.set("filter_output_msaa",this.createFullscreenQuadPipeline(r,n,h,this.format,m,this.sampleCount));for(const[f,b]of d)this.pipelines.set(\`\${f}_msaa\`,this.createFullscreenQuadPipeline(r,n,h,this.format,b,this.sampleCount))}this.createPositionedTexturePipeline(),this.createTextureScalePipeline()}createPositionedTexturePipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("positioned_texture",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("positionedTextureVertex",N.getPositionedTextureVertexShader()),s=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("positioned_texture",o);const i=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("positioned_texture_rgba",i);const l=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:4},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"}}});this.pipelines.set("bitmap_render_msaa",l);const c=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"}}});this.pipelines.set("bitmap_render",c)}createTextureScalePipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("texture_scale",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("textureScaleVertex",N.getTextureScaleVertexShader()),s=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("texture_scale",o);const i=this.getOrCreateShaderModule("textureScaleBlendVertex",N.getTextureScaleBlendVertexShader()),l=this.device.createRenderPipeline({layout:r,vertex:{module:i,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("texture_scale_blend",l)}createBitmapSyncPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}}]});this.bindGroupLayouts.set("bitmap_sync",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("bitmapSyncVertex",N.getBitmapSyncVertexShader()),s=this.getOrCreateShaderModule("bitmapSyncFragment",N.getBitmapSyncFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:4}});this.pipelines.set("bitmap_sync",o)}createColorMatrixFilterPipeline(){const e={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},r={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}};this.createFilterPipelineWithLayout("color_matrix_filter",N.getColorMatrixFilterFragmentShader(),1,e),this.createFilterPipelineWithLayout("bevel_base",N.getBevelBaseFragmentShader(),1,e),this.createFilterPipelineWithLayout("glow_filter",N.getGlowFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("drop_shadow_filter",N.getDropShadowFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("bevel_filter",N.getBevelFilterFragmentShader(),2,r),this.createFilterPipelineWithLayout("gradient_glow_filter",N.getGradientGlowFilterFragmentShader(),3,r),this.createFilterPipelineWithLayout("gradient_bevel_filter",N.getGradientBevelFilterFragmentShader(),3,r)}createComplexBlendPipelines(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("complex_blend",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("complexBlendVertex",N.getComplexBlendVertexShader()),s=this.getOrCreateShaderModule("unifiedComplexBlendFragment",N.getUnifiedComplexBlendFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}});this.pipelines.set("complex_blend",o),this.createComplexBlendCopyPipeline(),this.createComplexBlendOutputPipeline()}createComplexBlendCopyPipeline(){const e={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},r=this.bindGroupLayouts.get("texture_copy");if(r){const s=this.device.createPipelineLayout({bindGroupLayouts:[r]}),o=this.getOrCreateShaderModule("complexBlendCopyVertex",N.getComplexBlendCopyVertexShader()),i=this.getOrCreateShaderModule("textureCopyFragment",N.getTextureCopyFragmentShader());this.pipelines.set("complex_blend_copy",this.createFullscreenQuadPipeline(s,o,i,"rgba8unorm",e))}const n=this.bindGroupLayouts.get("texture_scale");if(n){const s=this.device.createPipelineLayout({bindGroupLayouts:[n]}),o=this.getOrCreateShaderModule("complexBlendScaleVertex",N.getComplexBlendScaleVertexShader()),i=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader());this.pipelines.set("complex_blend_scale",this.createFullscreenQuadPipeline(s,o,i,"rgba8unorm",e))}}createComplexBlendOutputPipeline(){const e=this.bindGroupLayouts.get("positioned_texture");if(!e)return;const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("positionedTextureFragment",N.getPositionedTextureFragmentShader()),s={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},o=this.getOrCreateShaderModule("complexBlendOutputVertex",N.getComplexBlendOutputVertexShader());this.pipelines.set("complex_blend_output",this.createFullscreenQuadPipeline(r,o,n,this.format,s)),this.sampleCount>1&&this.pipelines.set("complex_blend_output_msaa",this.createFullscreenQuadPipeline(r,o,n,this.format,s,this.sampleCount));const i=this.getOrCreateShaderModule("filterComplexBlendOutputVertex",N.getFilterComplexBlendOutputVertexShader());this.pipelines.set("filter_complex_blend_output",this.createFullscreenQuadPipeline(r,i,n,this.format,s)),this.sampleCount>1&&this.pipelines.set("filter_complex_blend_output_msaa",this.createFullscreenQuadPipeline(r,i,n,this.format,s,this.sampleCount))}createFilterPipelineWithLayout(e,r,n,s){let o=this.filterBindGroupLayouts.get(n);if(!o){const u=[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}}];for(let a=0;a1&&(c.multisample={count:i}),l&&(c.depthStencil=l),this.device.createRenderPipeline(c)}getPipeline(e){let r=this.pipelines.get(e);return r||(this.ensureLazyGroup(e),r=this.pipelines.get(e)),r}getFilterPipeline(e,r){const s=Object.keys(r).sort().map(h=>\`\${h}\${r[h]}\`).join("_"),o=\`\${e}_\${s}\`;let i=this.pipelines.get(o);if(i)return i;this.ensureLazyGroup(e);const l=this.shaderModuleCache.get(\`filter_\${e}\`),c=this.shaderModuleCache.get("blurFilterVertex"),u=this.bindGroupLayouts.get(e);if(!l||!c||!u)return this.pipelines.get(e);const a=this.device.createPipelineLayout({bindGroupLayouts:[u]});return i=this.device.createRenderPipeline({layout:a,vertex:{module:c,entryPoint:"main",buffers:[]},fragment:{module:l,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}],constants:r},primitive:{topology:"triangle-list",cullMode:"none"}}),this.pipelines.set(o,i),i}getGradientPipeline(e,r,n){const s=\`\${e}_t\${r}s\${n}\`;let o=this.pipelines.get(s);return o||(this.gradientPipelineLayout?(o=this.createGradientVariant(e,r,n),o?(this.pipelines.set(s,o),o):this.getPipeline(e)):this.getPipeline(e))}gradientPipelineLayout=null;gradientVertexShaderModule=null;gradientFragmentShaderModule=null;gradientStencilFragmentShaderModule=null;createGradientVariant(e,r,n){if(!this.gradientPipelineLayout)return;const s={GRADIENT_TYPE:r,SPREAD_MODE:n},o=rr,i=un,c=e.includes("stencil_atlas")||e==="gradient_fill_stencil_main"?this.gradientStencilFragmentShaderModule:this.gradientFragmentShaderModule,a=e.includes("bgra")||e==="gradient_fill_stencil_main"?this.format:"rgba8unorm",h=e.includes("bgra")||e==="gradient_fill_stencil_main",d={};h&&(d.yFlipSign=-1);let g,m=this.sampleCount;e.includes("stroke")?g={format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0}:e==="gradient_fill_stencil"||e==="gradient_fill_stencil_atlas"?g={format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255}:e==="gradient_fill_stencil_main"?(g={format:"stencil8",stencilFront:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"not-equal",failOp:"keep",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},m=1):e==="gradient_fill_bgra_stencil"?g={format:"stencil8",stencilFront:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"equal",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:255,stencilWriteMask:0}:e==="gradient_fill_bgra_no_msaa"&&(m=1);const f={layout:this.gradientPipelineLayout,vertex:{module:this.gradientVertexShaderModule,entryPoint:"main",buffers:[o],constants:Object.keys(d).length>0?d:void 0},fragment:{module:c,entryPoint:"main",targets:[{format:a,blend:i}],constants:s},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:m}};return g&&(f.depthStencil=g),this.device.createRenderPipeline(f)}getBindGroupLayout(e){let r=this.bindGroupLayouts.get(e);return r||(this.ensureLazyGroup(e),r=this.bindGroupLayouts.get(e)),r}createNodeClearPipeline(){const e={arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},r=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.getOrCreateShaderModule("nodeClearVertex",N.getNodeClearVertexShader()),entryPoint:"main",buffers:[e]},fragment:{module:this.getOrCreateShaderModule("nodeClearFragment",N.getNodeClearFragmentShader()),entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},writeMask:GPUColorWrite.ALL}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"zero",depthFailOp:"zero",passOp:"zero"},stencilBack:{compare:"always",failOp:"zero",depthFailOp:"zero",passOp:"zero"},stencilReadMask:255,stencilWriteMask:255},multisample:{count:this.sampleCount}});this.pipelines.set("node_clear_atlas",r)}dispose(){this.pipelines.clear(),this.bindGroupLayouts.clear(),this.shaderModuleCache.clear(),this.filterBindGroupLayouts.clear()}}class Qp{device;pipelines;bindGroupLayouts;constructor(e){this.device=e,this.pipelines=new Map,this.bindGroupLayouts=new Map,this.initializeBlurPipelines()}initializeBlurPipelines(){const e=this.device.createBindGroupLayout({label:"blur_compute_bind_group_layout",entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,texture:{sampleType:"float"}},{binding:1,visibility:GPUShaderStage.COMPUTE,storageTexture:{access:"write-only",format:"rgba8unorm"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}}]});this.bindGroupLayouts.set("blur_compute",e),this.createBlurComputePipeline("blur_compute_horizontal"),this.createBlurComputePipeline("blur_compute_vertical"),this.createBlurComputePipeline("blur_compute_shared_horizontal",!0),this.createBlurComputePipeline("blur_compute_shared_vertical",!0)}createBlurComputePipeline(e,r=!1){const n=this.device.createShaderModule({label:\`\${e}_shader\`,code:r?this.getSharedBlurComputeShaderCode():this.getBlurComputeShaderCode()}),s=this.device.createPipelineLayout({label:\`\${e}_layout\`,bindGroupLayouts:[this.bindGroupLayouts.get("blur_compute")]}),o=this.device.createComputePipeline({label:e,layout:s,compute:{module:n,entryPoint:"main"}});this.pipelines.set(e,o)}getBlurComputeShaderCode(){return\` -struct BlurParams { - direction: vec2, // (1,0) or (0,1) - radius: f32, // ブラー半径 - fraction: f32, // 端ピクセルのブレンド割合 - texSize: vec2, // テクスチャサイズ - samples: f32, // サンプル数 - padding: f32, // パディング(16バイトアライメント) -} - -@group(0) @binding(0) var inputTexture: texture_2d; -@group(0) @binding(1) var outputTexture: texture_storage_2d; -@group(0) @binding(2) var params: BlurParams; - -const WORKGROUP_SIZE: u32 = 16u; - -@compute @workgroup_size(16, 16, 1) -fn main( - @builtin(global_invocation_id) globalId: vec3 -) { - let texSize = vec2(u32(params.texSize.x), u32(params.texSize.y)); - let radius = i32(params.radius); - - let outCoord = globalId.xy; - - if (outCoord.x >= texSize.x || outCoord.y >= texSize.y) { - return; - } - - let direction = vec2(i32(params.direction.x), i32(params.direction.y)); - let samples = params.samples; - let fraction = params.fraction; - - var color = vec4(0.0); - - for (var i = -radius; i <= radius; i = i + 1) { - var sampleCoord = vec2(outCoord) + direction * i; - - sampleCoord.x = clamp(sampleCoord.x, 0, i32(texSize.x) - 1); - sampleCoord.y = clamp(sampleCoord.y, 0, i32(texSize.y) - 1); - - let sample = textureLoad(inputTexture, vec2(sampleCoord), 0); - - // 端ピクセルにfraction重みを適用(Fragment Shaderと同じロジック) - if (i == -radius || i == radius) { - color = color + sample * fraction; - } else { - color = color + sample; - } - } - - color = color / samples; - - textureStore(outputTexture, outCoord, color); -} -\`}getSharedBlurComputeShaderCode(){return\` -struct BlurParams { - direction: vec2, - radius: f32, - fraction: f32, - texSize: vec2, - samples: f32, - padding: f32, -} - -@group(0) @binding(0) var inputTexture: texture_2d; -@group(0) @binding(1) var outputTexture: texture_storage_2d; -@group(0) @binding(2) var params: BlurParams; - -const TILE: u32 = 16u; -const MAX_APRON: u32 = 24u; -const SHARED_W: u32 = TILE + 2u * MAX_APRON; - -var tile: array, 1024>; - -@compute @workgroup_size(16, 16, 1) -fn main( - @builtin(global_invocation_id) globalId: vec3, - @builtin(local_invocation_id) localId: vec3, - @builtin(workgroup_id) workgroupId: vec3 -) { - let texSize = vec2(u32(params.texSize.x), u32(params.texSize.y)); - let radius = u32(params.radius); - let apron = min(radius, MAX_APRON); - let isHorizontal = params.direction.x > 0.5; - let fraction = params.fraction; - let samples = params.samples; - - let threadIdx = localId.x + localId.y * TILE; - let totalThreads = TILE * TILE; - - if (isHorizontal) { - let sharedWidth = TILE + 2u * apron; - let baseX = workgroupId.x * TILE; - let y = globalId.y; - let clampedY = clamp(y, 0u, max(texSize.y, 1u) - 1u); - - // 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード) - var idx = threadIdx; - loop { - if (idx >= sharedWidth) { break; } - let gx = i32(baseX) + i32(idx) - i32(apron); - let cx = u32(clamp(gx, 0, i32(max(texSize.x, 1u)) - 1)); - tile[localId.y * SHARED_W + idx] = textureLoad(inputTexture, vec2(cx, clampedY), 0); - idx += totalThreads; - } - - // 全スレッドがバリアに到達(早期returnなし) - workgroupBarrier(); - - // 範囲内のスレッドのみ出力 - let outX = globalId.x; - if (outX < texSize.x && y < texSize.y) { - let iRadius = i32(radius); - var color = vec4(0.0); - for (var i = -iRadius; i <= iRadius; i = i + 1) { - let tileIdx = i32(localId.x) + i32(apron) + i; - let s = tile[localId.y * SHARED_W + u32(clamp(tileIdx, 0, i32(sharedWidth) - 1))]; - if (i == -iRadius || i == iRadius) { - color += s * fraction; - } else { - color += s; - } - } - textureStore(outputTexture, vec2(outX, y), color / samples); - } - } else { - let sharedHeight = TILE + 2u * apron; - let baseY = workgroupId.y * TILE; - let x = globalId.x; - let clampedX = clamp(x, 0u, max(texSize.x, 1u) - 1u); - - // 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード) - var idx = threadIdx; - loop { - if (idx >= sharedHeight) { break; } - let gy = i32(baseY) + i32(idx) - i32(apron); - let cy = u32(clamp(gy, 0, i32(max(texSize.y, 1u)) - 1)); - tile[idx * TILE + localId.x] = textureLoad(inputTexture, vec2(clampedX, cy), 0); - idx += totalThreads; - } - - // 全スレッドがバリアに到達(早期returnなし) - workgroupBarrier(); - - // 範囲内のスレッドのみ出力 - let outY = globalId.y; - if (x < texSize.x && outY < texSize.y) { - let iRadius = i32(radius); - var color = vec4(0.0); - for (var i = -iRadius; i <= iRadius; i = i + 1) { - let tileIdx = i32(localId.y) + i32(apron) + i; - let s = tile[u32(clamp(tileIdx, 0, i32(sharedHeight) - 1)) * TILE + localId.x]; - if (i == -iRadius || i == iRadius) { - color += s * fraction; - } else { - color += s; - } - } - textureStore(outputTexture, vec2(x, outY), color / samples); - } - } -} -\`}getPipeline(e){return this.pipelines.get(e)}getBindGroupLayout(e){return this.bindGroupLayouts.get(e)}destroy(){this.pipelines.clear(),this.bindGroupLayouts.clear()}}const Va=Number.MAX_VALUE,Da=-Number.MAX_VALUE;let Fr=0;const wr=t=>{Fr=t},Zp=()=>Fr,zt=[],Jp=t=>{zt[Fr]=t};let go=null;const em=t=>{go=t},Ne=()=>{if(!(Fr in zt))if(go){const t=go(Fr);Jp(t)}else return null;return zt[Fr]},bo=t=>t in zt?zt[t]:null,fn=[],Na=[],za=[],tm=()=>{for(let t=0;t{Xa=t},yo=()=>Xa,rm=()=>{fn.length=0,wr(0);for(let t=0;t{ts=t},sm=new Set(["normal","layer","add","screen","alpha","erase","copy"]),hn=[],vo=[],Mo=[],om=()=>hn,So=()=>{for(let t=0;t{const t="blend_instanced";return $o.has(t)||$o.set(t,new nm),$o.get(t)},im=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const d=o[0],g=o[1],m=o[2],f=h,b=o[4]/255,x=o[5]/255,y=o[6]/255,P=0;if(sm.has(l)){(ts!==l||yo()!==t.index)&&(st&&(wr(yo()),st.drawArraysInstanced()),Ya(l),xo(t.index),wr(t.index));const S=rs();Ve.pushInstanceBuffer((t.x+.5)/a,(t.y+.5)/a,(t.w-1)/a,(t.h-1)/a,t.w,t.h,c,u,i[6],i[7],0,0,i[0],i[1],i[3],i[4],d,g,m,f,b,x,y,P),S.count++}else{st&&(wr(yo()),st.drawArraysInstanced());const S=vo.length>0?vo.pop():new Float32Array(8);S.set(o);const M=Mo.length>0?Mo.pop():new Float32Array(9);M.set(i),hn.push({node:t,x_min:e,y_min:r,x_max:n,y_max:s,color_transform:S,matrix:M,blend_mode:l,viewport_width:c,viewport_height:u,render_max_size:a,global_alpha:h}),Ya(l),xo(t.index),wr(t.index)}};let To=!1;const Bo=t=>{To=t},nr=()=>To;let Po=!1,Ao=0;const Wa=t=>{Po=t},gt=()=>Po,ja=t=>{Ao=t},Or=()=>Ao,Er=new Map,Rr=new Map,am=()=>{To=!1,Po=!1,Ao=0,Er.clear(),Rr.clear()},cm=()=>{const t=st.currentAttachmentObject;t&&(t.mask=!0,t.clipLevel++,Rr.set(t.clipLevel,t.clipLevel),nr()||Bo(!0))},lm=(t,e,r,n)=>{const s=st.currentAttachmentObject;if(!s)return;const o=s.clipLevel;let i=Er.get(o);i?(i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],r),i[3]=Math.max(i[3],n)):(i=fd(),i[0]=t,i[1]=e,i[2]=r,i[3]=n,Er.set(o,i))},Ha=()=>{const t=st.currentAttachmentObject;if(!t)return;const r=(1<{const t=st.currentAttachmentObject;if(!t)return;const e=t.clipLevel,r=Er.get(e);if(r&&(Er.delete(e),hd(r)),Rr.delete(e),--t.clipLevel,!t.clipLevel){t.mask=!1,Bo(!1),Wa(!1),ja(0),t.needsStencilClear=!0,Rr.clear(),Er.clear();return}t.pendingStencilClearLevel=t.clipLevel,Ha()},fm=(t,e,r)=>{const n=t.length-5;for(let s=3;s(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),dn=t=>{let e=0;for(const o of t){const i=o.length-5;for(let l=3;l{const n=Math.sqrt(t*t+e*e);return n===0?{x:0,y:0}:{x:-(e/n)*r,y:t/n*r}},wo=(t,e,r)=>({x:t.x+(e.x-t.x)*r,y:t.y+(e.y-t.y)*r}),xm=t=>{const e=Math.sqrt(t.x*t.x+t.y*t.y);return e===0?{x:0,y:0}:{x:t.x/e,y:t.y/e}},ym=(t,e,r,n)=>({x:(1-t)**2*e.x+2*(1-t)*t*r.x+t**2*n.x,y:(1-t)**2*e.y+2*(1-t)*t*r.y+t**2*n.y}),vm=(t,e,r,n)=>({x:2*(1-t)*(r.x-e.x)+2*t*(n.x-r.x),y:2*(1-t)*(r.y-e.y)+2*t*(n.y-r.y)}),Mm=(t,e,r,n=.5)=>{const s=wo(t,e,n),o=wo(e,r,n),i=wo(s,o,n);return[[t,s,i],[i,o,r]]},Sm=(t,e,r,n=4)=>{let s=[[t,e,r]];for(let o=0;o{const s=[0,.5,1],o=[];for(const i of s){const l=ym(i,t,e,r),c=vm(i,t,e,r),u=xm({x:-c.y,y:c.x});o.push({x:l.x+u.x*n,y:l.y+u.y*n})}return o},$m=(t,e,r,n)=>{const s=Sm(t,e,r,5),o=[],i=[];for(const h of s)o.push(Ka(h[0],h[1],h[2],+n)),i.push(Ka(h[0],h[1],h[2],-n));for(let h=0;h{const n={x:e.x-t.x,y:e.y-t.y},s=bm(n.x,n.y,r),o={x:t.x+s.x,y:t.y+s.y},i={x:e.x+s.x,y:e.y+s.y},l={x:e.x-s.x,y:e.y-s.y},c={x:t.x-s.x,y:t.y-s.y};return[o.x,o.y,!1,i.x,i.y,!1,l.x,l.y,!1,c.x,c.y,!1,o.x,o.y,!1]},Ur=(t,e,r,n)=>{const s=[];for(let i=0;i1e-4||s.push(l,c)}return s},Gr=(t,e)=>{Cr.beginPath(),Cr.moveTo(e[0],e[1]);for(let r=3;r{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=Ur(t,e,r,n[o]),c=Ur(t,e,r,n[i]);if(l[0]===c[0]&&l[1]===c[1]||l[0]===c[2]&&l[1]===c[3])return;const u=Gr(l,n[i]);if(!u)return;const a=Gr(c,n[o]);a&&n.splice(-1,0,[t,e,!1,u[0],u[1],!1,a[0],a[1],!1,t,e,!1])},Qa=(t,e,r,n,s=!1)=>{const o=s?0:n.length-1,i=s?n.length-1:n.length-2,l=Ur(t,e,r,n[o]),c=Ur(t,e,r,n[i]),u=Gr(l,n[i]);if(!u)return;const a=Gr(c,n[o]);if(!a)return;const h=Math.atan2(u[1]-e,u[0]-t);let g=Math.atan2(a[1]-e,a[0]-t)-h;g>Math.PI?g-=2*Math.PI:g<-Math.PI&&(g+=2*Math.PI);const m=8,f=g/m,b=[t,e,!1];for(let x=0;x<=m;x++){const y=h+x*f,P=t+r*Math.cos(y),S=e+r*Math.sin(y);b.push(P,S,!1)}n.splice(-1,0,b)},Za=(t,e,r,n,s,o=!1)=>{const i=o?0:s.length-1,l=o?s.length-1:s.length-2,c=Ur(t.x,t.y,n,s[i]),u=Ur(t.x,t.y,n,s[l]);if(c[0]===u[0]&&c[1]===u[1]||c[0]===u[2]&&c[1]===u[3])return;const a=Gr(c,s[l]);if(!a)return;const h=Gr(u,s[i]);if(!h)return;const d=e.x-t.x,g=e.y-t.y,m=Math.hypot(d,g),f={x:d/m,y:g/m},b=r.x-t.x,x=r.y-t.y,y=Math.hypot(b,x),P={x:b/y,y:x/y},S=f.x,M=f.y,$=P.x,T=P.y,w=S*T-M*$;if(w===0){s.splice(-1,0,[t.x,t.y,!1,a[0],a[1],!1,h[0],h[1],!1]);return}const E=((h[0]-a[0])*T-(h[1]-a[1])*$)/w,F=a[0]+E*S,A=a[1]+E*M;s.splice(-1,0,[t.x,t.y,!1,a[0],a[1],!1,F,A,!1,t.x,t.y,!1,h[0],h[1],!1,F,A,!1])},Bm=(t,e,r)=>{const n=t[0],s=t[1],o=t[3],i=t[4],l=Math.atan2(s-i,n-o),c=[n,s,!1],u=8;for(let b=0;b<=u;b++){const x=l-Math.PI/2+b*Math.PI/u;c.push(n+e*Math.cos(x),s+e*Math.sin(x),!1)}r.unshift(c);const a=t[t.length-3],h=t[t.length-2],d=t[t.length-6],g=t[t.length-5],m=Math.atan2(h-g,a-d),f=[a,h,!1];for(let b=0;b<=u;b++){const x=m-Math.PI/2+b*Math.PI/u;f.push(a+e*Math.cos(x),h+e*Math.sin(x),!1)}r.push(f)},Pm=(t,e,r)=>{const n=t[0],s=t[1],o=t[3],i=t[4],l=n-o,c=s-i,u=Math.hypot(l,c);if(u>0){const x=l/u,y=c/u,P=n+x*e,S=s+y*e,M=[n-y*e,s+x*e,!1,P-y*e,S+x*e,!1,P+y*e,S-x*e,!1,n+y*e,s-x*e,!1,n-y*e,s+x*e,!1];r.unshift(M)}const a=t[t.length-3],h=t[t.length-2],d=t[t.length-6],g=t[t.length-5],m=a-d,f=h-g,b=Math.hypot(m,f);if(b>0){const x=m/b,y=f/b,P=a+x*e,S=h+y*e,M=[a-y*e,h+x*e,!1,P-y*e,S+x*e,!1,P+y*e,S-x*e,!1,a+y*e,h-x*e,!1,a-y*e,h+x*e,!1];r.push(M)}},Oo=(t,e)=>{const r=dm;r.x=t[0],r.y=t[1];const n=pm;n.x=0,n.y=0;const s=mm;s.x=0,s.y=0;const o=gm;o.x=0,o.y=0;const i=[];for(let g=3;g1)switch(st.joints){case 0:qa(r.x,r.y,e,i);break;case 1:o.x=t[g-6],o.y=t[g-5],Za(r,s,o,e,i);break;case 2:Qa(r.x,r.y,e,i);break}r.x=s.x,r.y=s.y}const l=t[0],c=t[1],u=t[t.length-3],a=t[t.length-2],h=1e-4;if(Math.abs(l-u)1)switch(st.joints){case 0:qa(l,c,e,i,!0);break;case 1:r.x=l,r.y=c,s.x=t[3],s.y=t[4],o.x=t[t.length-6],o.y=t[t.length-5],Za(r,s,o,e,i,!0);break;case 2:Qa(l,c,e,i,!0);break}else if(i.length>0)switch(st.caps){case 1:Bm(t,e,i);break;case 2:Pm(t,e,i);break}return i},Am=(t,e)=>{const r=e/2,n=[];for(const s of t){if(s.length<6)continue;const o=Oo(s,r);for(const i of o)n.push(i)}return n},Ja=new Map;let ec=0;const Fm=()=>{Ja.clear(),ec=0},tc=new WeakMap,Eo=t=>{let e=tc.get(t);return e||(e=t.createView(),tc.set(t,e)),e},wm=6,Om=22,pn=new Map,mn=new Map,ns=(t,e,r)=>{const n=\`\${e}_\${r}\`,s=pn.get(n);return s&&s.length>0?s.pop():t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:wm})},Ot=t=>{const e=\`\${t.width}_\${t.height}\`;let r=pn.get(e);r||(r=[],pn.set(e,r)),r.push(t)},Ro=(t,e,r)=>{const n=\`\${e}_\${r}\`,s=mn.get(n);return s&&s.length>0?s.pop():t.createTexture({size:{width:e,height:r},format:"rgba8unorm",usage:Om})},Xt=t=>{const e=\`\${t.width}_\${t.height}\`;let r=mn.get(e);r||(r=[],mn.set(e,r)),r.push(t)},Em=()=>{for(const[,t]of pn)for(const e of t)e.destroy();pn.clear();for(const[,t]of mn)for(const e of t)e.destroy();mn.clear()},rc=new Map,Rm=()=>{for(const t of rc.values())t.texture?.resource&&t.texture.resource.destroy();rc.clear()},Lr=new Map;let gn=0;const Cm=60,nc=(t,e,r)=>\`\${e}_\${r}_\${t.join(",")}\`,sc=(t,e,r)=>{const n=nc(t,e,r),s=Lr.get(n);return s?(s.lastUsedFrame=gn,s):null},oc=(t,e,r,n,s)=>{const o=nc(t,e,r);Lr.set(o,{texture:n,view:s,lastUsedFrame:gn})},Um=()=>{gn++;for(const[t,e]of Lr)gn-e.lastUsedFrame>Cm&&(Ot(e.texture),Lr.delete(t))},Gm=()=>{for(const t of Lr.values())Ot(t.texture);Lr.clear(),gn=0};let Co=null;const Lm=()=>{Co?.texture?.resource&&Co.texture.resource.destroy(),Co=null},km=(t,e,r,n,s,o)=>{const i=e.getPipeline("stencil_write_atlas");i&&(t.setPipeline(i),t.setStencilReference(0),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0));const l=e.getPipeline("stencil_fill_atlas");l&&(t.setPipeline(l),t.setStencilReference(0),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0))},Im=(t,e,r,n,s,o)=>{const i=e.getPipeline("stencil_write_main");i&&(t.setPipeline(i),t.setStencilReference(0),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0));const l=e.getPipeline("stencil_fill_main");l&&(t.setPipeline(l),t.setStencilReference(0),t.setBindGroup(0,s,[o]),t.draw(n,1,0,0))},_m=(t,e,r,n,s,o,i,l=!1,c=1)=>{let u;if(i)u="fill";else if(l){if(nr())return;u="fill_bgra_stencil"}else u="fill_bgra";const a=e.getPipeline(u);if(!a){console.error(\`[WebGPU] \${u} pipeline not found\`);return}t.setPipeline(a),t.setVertexBuffer(0,r),t.setBindGroup(0,s,[o]),l&&!i&&!nr()&&t.setStencilReference(Or()),t.draw(n,1,0,0)},Uo=t=>t<=4?256:t<=8?512:1024,ic=(t,e,r)=>{const n=t.length/5,s=Uo(n),o=new Uint8Array(s*4);for(let i=0;i{const n=t.length/5;let s=0,o=0;for(let x=0;x=e&&o===0){o=x;break}}if(o===0&&(o=n-1),s===o){const x=s*5;return{r:t[x+1],g:t[x+2],b:t[x+3],a:t[x+4]}}const i=t[s*5],l=t[o*5],c=(e-i)/(l-i),u=t[s*5+1],a=t[s*5+2],h=t[s*5+3],d=t[s*5+4],g=t[o*5+1],m=t[o*5+2],f=t[o*5+3],b=t[o*5+4];return r===0?{r:Go(ot(kr(u/255),kr(g/255),c))*255,g:Go(ot(kr(a/255),kr(m/255),c))*255,b:Go(ot(kr(h/255),kr(f/255),c))*255,a:ot(d,b,c)}:{r:ot(u,g,c),g:ot(a,m,c),b:ot(h,f,c),a:ot(d,b,c)}},ot=(t,e,r)=>t+(e-t)*r,kr=t=>Math.pow(t,2.23333333),Go=t=>Math.pow(t,.45454545),ac=(t,e,r)=>{const s=new Uint8Array(1024),o=t.length,i=[];for(let l=0;l>16&255)/255,g:(c>>8&255)/255,b:(c&255)/255,a:r[l]})}for(let l=0;l<256;l++){const c=l/255;let u=0,a=o-1;for(let P=0;P=c){u=P,a=P+1;break}const h=i[u],d=i[a];let g=0;d.offset!==h.offset&&(g=(c-h.offset)/(d.offset-h.offset));const m=ot(h.r,d.r,g),f=ot(h.g,d.g,g),b=ot(h.b,d.b,g),x=ot(h.a,d.a,g),y=l*4;s[y+0]=Math.round(m*x*255),s[y+1]=Math.round(f*x*255),s[y+2]=Math.round(b*x*255),s[y+3]=Math.round(x*255)}return s},cc=(t,e,r)=>{const n=t[0],s=t[1],o=t[2],i=t[3],l=t[4],c=t[5];if(r===0){const y=-819.2*n-819.2*o+l,P=819.2*n-819.2*o+l,S=-819.2*n+819.2*o+l,M=-819.2*s-819.2*i+c,$=819.2*s-819.2*i+c,T=-819.2*s+819.2*i+c;let w=S-y,E=T-M;const F=Math.sqrt(w*w+E*E);F?(w=w/F,E=E/F):(w=0,E=0);const A=(P-y)*w+($-M)*E,R=new Float32Array([y+A*w,M+A*E,P,$]);return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:R}}const u=n*i-s*o;if(Math.abs(u)<1e-10)return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:null};const a=1/u,h=i*a,d=-s*a,g=-o*a,m=n*a,f=(o*c-i*l)*a,b=(s*l-n*c)*a;return{inverseMatrix:new Float32Array([h,d,0,g,m,0,f,b,1]),linearPoints:null}};let Lo=null;const j=new Float32Array(36),Ue=new Float32Array(16);let ko=null,lc=null;const ss=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Dm=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b=!1,x=1)=>{const y=dn(s);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer);let S,M;const $=sc(c,a,h);if($)S=$.texture,M=$.view;else{const V=ic(c,a,h),X=c.length/5,Y=Uo(X);S=ns(t,Y,1),t.queue.writeTexture({texture:S},V,{bytesPerRow:Y*4,rowsPerImage:1},{width:Y,height:1}),M=S.createView(),oc(c,a,h,S,M)}const T=cc(u,o,l),w=i[3]>0?i[3]:1,E=o[0],F=o[1],A=o[3],R=o[4],v=o[6],U=o[7];j[0]=T.inverseMatrix[0],j[1]=T.inverseMatrix[3],j[2]=0,j[3]=0,j[4]=T.inverseMatrix[1],j[5]=T.inverseMatrix[4],j[6]=0,j[7]=0,j[8]=T.inverseMatrix[6],j[9]=T.inverseMatrix[7],j[10]=1,j[11]=0,j[12]=l,j[13]=Math.max(-.975,Math.min(.975,d)),j[14]=a,j[15]=819.2,T.linearPoints?(j[16]=T.linearPoints[0],j[17]=T.linearPoints[1],j[18]=T.linearPoints[2],j[19]=T.linearPoints[3]):(j[16]=0,j[17]=0,j[18]=0,j[19]=0),j[20]=1,j[21]=1,j[22]=1,j[23]=w,j[24]=E/g,j[25]=F/m,j[26]=0,j[27]=0,j[28]=A/g,j[29]=R/m,j[30]=0,j[31]=0,j[32]=v/g,j[33]=U/m,j[34]=1,j[35]=0;const L=r.acquireAndWriteUniformBuffer(j);Lo||(Lo=t.createSampler({magFilter:"linear",minFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}));const D=Lo,G=n.getBindGroupLayout("gradient_fill");if(!G)return console.error("[WebGPU] gradient_fill bind group layout not found"),null;ss[0].resource.buffer=L,ss[1].resource=D,ss[2].resource=M;const B=t.createBindGroup({layout:G,entries:ss}),z=()=>{const V=n.getBindGroupLayout("fill_dynamic");if(!V)return null;Ue[0]=1,Ue[1]=1,Ue[2]=1,Ue[3]=w,Ue[4]=E/g,Ue[5]=F/m,Ue[6]=0,Ue[7]=0,Ue[8]=A/g,Ue[9]=R/m,Ue[10]=0,Ue[11]=0,Ue[12]=v/g,Ue[13]=U/m,Ue[14]=1,Ue[15]=0;const X=r.dynamicUniform.allocate(Ue),Y=r.dynamicUniform.getBuffer();return(!ko||lc!==Y)&&(ko=t.createBindGroup({layout:V,entries:[{binding:0,resource:{buffer:Y,size:256}}]}),lc=Y),{bindGroup:ko,offset:X}};if(f){const V=n.getPipeline("stencil_write_atlas");if(V){const Y=z();e.setPipeline(V),e.setStencilReference(0),e.setVertexBuffer(0,P),Y&&e.setBindGroup(0,Y.bindGroup,[Y.offset]),e.draw(y.indexCount,1,0,0)}const X=n.getGradientPipeline("gradient_fill_stencil_atlas",l,a);return X&&(e.setPipeline(X),e.setStencilReference(0),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0)),null}if(b&&nr())return null;const k=n.getPipeline("stencil_write_main");if(k){const V=z();e.setPipeline(k),e.setStencilReference(0),e.setVertexBuffer(0,P),V&&e.setBindGroup(0,V.bindGroup,[V.offset]),e.draw(y.indexCount,1,0,0)}const _=b?"gradient_fill_bgra_stencil_masked":"gradient_fill_stencil_main",I=n.getGradientPipeline(_,l,a);return I&&(e.setPipeline(I),e.setStencilReference(b?Or():0),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0)),null},uc=(t,e)=>{const r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],l=t[5],c=e[0],u=e[1],a=e[3],h=e[4],d=e[6],g=e[7],m=c*r+a*n,f=c*s+a*o,b=u*r+h*n,x=u*s+h*o,y=c*i+a*l+d,P=u*i+h*l+g,S=m*x-f*b;if(Math.abs(S)<1e-10)return new Float32Array([1,0,0,0,1,0,0,0,1]);const M=1/S,$=x*M,T=-f*M,w=-b*M,E=m*M,F=(f*P-x*y)*M,A=(b*y-m*P)*M,R=$*c+T*u,v=$*a+T*h,U=w*c+E*u,L=w*a+E*h,D=$*d+T*g+F,G=w*d+E*g+A;return new Float32Array([R,U,0,v,L,0,D,G,1])},fc=new Map,Z=new Float32Array(32),Ge=new Float32Array(16);let Io=null,hc=null;const os=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Nm=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f,b=!1,x=1)=>{const y=dn(s);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer),S=ns(t,u,a);t.queue.writeTexture({texture:S},l.buffer,{bytesPerRow:u*4,rowsPerImage:a,offset:l.byteOffset},{width:u,height:a});const M=uc(c,o),$=i[0],T=i[1],w=i[2],E=i[3],F=o[0],A=o[1],R=o[3],v=o[4],U=o[6],L=o[7];Z[0]=M[0],Z[1]=M[1],Z[2]=M[2],Z[3]=0,Z[4]=M[3],Z[5]=M[4],Z[6]=M[5],Z[7]=0,Z[8]=M[6],Z[9]=M[7],Z[10]=M[8],Z[11]=0,Z[12]=u,Z[13]=a,Z[14]=h?1:0,Z[15]=0,Z[16]=$,Z[17]=T,Z[18]=w,Z[19]=E,Z[20]=F/g,Z[21]=A/m,Z[22]=0,Z[23]=0,Z[24]=R/g,Z[25]=v/m,Z[26]=0,Z[27]=0,Z[28]=U/g,Z[29]=L/m,Z[30]=1,Z[31]=0;const D=r.acquireAndWriteUniformBuffer(Z),G=\`bitmap_\${d?"s":"n"}_\${h?"r":"c"}\`;let B=fc.get(G);B||(B=t.createSampler({magFilter:d?"linear":"nearest",minFilter:d?"linear":"nearest",addressModeU:h?"repeat":"clamp-to-edge",addressModeV:h?"repeat":"clamp-to-edge"}),fc.set(G,B));const z=n.getBindGroupLayout("bitmap_fill");if(!z)return console.error("[WebGPU] bitmap_fill bind group layout not found"),Ot(S),null;os[0].resource.buffer=D,os[1].resource=B,os[2].resource=S.createView();const k=t.createBindGroup({layout:z,entries:os}),_=()=>{const I=n.getBindGroupLayout("fill_dynamic");if(!I)return null;Ge[0]=$,Ge[1]=T,Ge[2]=w,Ge[3]=E,Ge[4]=F/g,Ge[5]=A/m,Ge[6]=0,Ge[7]=0,Ge[8]=R/g,Ge[9]=v/m,Ge[10]=0,Ge[11]=0,Ge[12]=U/g,Ge[13]=L/m,Ge[14]=1,Ge[15]=0;const V=r.dynamicUniform.allocate(Ge),X=r.dynamicUniform.getBuffer();return(!Io||hc!==X)&&(Io=t.createBindGroup({layout:I,entries:[{binding:0,resource:{buffer:X,size:256}}]}),hc=X),{bindGroup:Io,offset:V}};if(f&&b){const I=n.getPipeline("stencil_write");if(I){const X=_();X&&(e.setPipeline(I),e.setStencilReference(0),e.setVertexBuffer(0,P),e.setBindGroup(0,X.bindGroup,[X.offset]),e.draw(y.indexCount,1,0,0))}const V=n.getPipeline("bitmap_fill_stencil");V&&(e.setPipeline(V),e.setStencilReference(0),e.setBindGroup(0,k),e.draw(y.indexCount,1,0,0))}else{let I;if(f)I="bitmap_fill";else if(b){if(nr())return Ot(S),null;I="bitmap_fill_bgra_stencil"}else I="bitmap_fill_bgra";const V=n.getPipeline(I);if(!V)return console.error(\`[WebGPU] \${I} pipeline not found\`),Ot(S),null;e.setPipeline(V),e.setVertexBuffer(0,P),e.setBindGroup(0,k),b&&!f&&!nr()&&e.setStencilReference(Or()),e.draw(y.indexCount,1,0,0)}return S},dc=(t,e,r)=>{const n=t.length-5;for(let s=3;s(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),Xm=(t,e)=>{const r=e/2,n=[];for(const c of t){const u=Oo(c,r);for(const a of u)n.push(a)}let s=0;for(const c of n){const u=c.length-5;for(let a=3;a{const y=Xm(s,o);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer);let S,M;const $=sc(u,h,d);if($)S=$.texture,M=$.view;else{const _=ic(u,h,d),I=u.length/5,V=Uo(I);S=ns(t,V,1),t.queue.writeTexture({texture:S},_,{bytesPerRow:V*4,rowsPerImage:1},{width:V,height:1}),M=S.createView(),oc(u,h,d,S,M)}const T=cc(a,i,c),w=l[3]>0?l[3]:1,E=i[0],F=i[1],A=i[3],R=i[4],v=i[6],U=i[7];H[0]=T.inverseMatrix[0],H[1]=T.inverseMatrix[3],H[2]=0,H[3]=0,H[4]=T.inverseMatrix[1],H[5]=T.inverseMatrix[4],H[6]=0,H[7]=0,H[8]=T.inverseMatrix[6],H[9]=T.inverseMatrix[7],H[10]=1,H[11]=0,H[12]=c,H[13]=Math.max(-.975,Math.min(.975,g)),H[14]=h,H[15]=819.2,T.linearPoints?(H[16]=T.linearPoints[0],H[17]=T.linearPoints[1],H[18]=T.linearPoints[2],H[19]=T.linearPoints[3]):(H[16]=0,H[17]=0,H[18]=0,H[19]=0),H[20]=1,H[21]=1,H[22]=1,H[23]=w,H[24]=E/m,H[25]=F/f,H[26]=0,H[27]=0,H[28]=A/m,H[29]=R/f,H[30]=0,H[31]=0,H[32]=v/m,H[33]=U/f,H[34]=1,H[35]=0;const L=r.acquireAndWriteUniformBuffer(H);Vo||(Vo=t.createSampler({magFilter:"linear",minFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}));const D=Vo,G=n.getBindGroupLayout("gradient_fill");if(!G)return console.error("[WebGPU] gradient_fill bind group layout not found"),null;is[0].resource.buffer=L,is[1].resource=D,is[2].resource=M;const B=t.createBindGroup({layout:G,entries:is}),z=x?b?"gradient_stroke_atlas":"gradient_stroke_bgra":b?"gradient_fill":"gradient_fill_bgra",k=n.getGradientPipeline(z,c,h);return k?(e.setPipeline(k),e.setVertexBuffer(0,P),e.setBindGroup(0,B),e.draw(y.indexCount,1,0,0),null):(console.error(\`[WebGPU] \${z} pipeline not found\`),null)};let Do=new Float32Array(32);const Wm=t=>(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t++,t),jm=(t,e)=>{const r=e/2,n=[];for(const c of t){const u=Oo(c,r);for(const a of u)n.push(a)}let s=0;for(const c of n){const u=c.length-5;for(let a=3;a{const y=jm(s,o);if(y.indexCount===0)return null;const P=r.acquireVertexBuffer(y.buffer.byteLength,y.buffer),S=ns(t,a,h);t.queue.writeTexture({texture:S},c.buffer,{bytesPerRow:a*4,rowsPerImage:h,offset:c.byteOffset},{width:a,height:h});const M=uc(u,i),$=1,T=1,w=1,E=l[3]>0?l[3]:1,F=i[0],A=i[1],R=i[3],v=i[4],U=i[6],L=i[7];J[0]=M[0],J[1]=M[1],J[2]=M[2],J[3]=0,J[4]=M[3],J[5]=M[4],J[6]=M[5],J[7]=0,J[8]=M[6],J[9]=M[7],J[10]=M[8],J[11]=0,J[12]=a,J[13]=h,J[14]=d?1:0,J[15]=0,J[16]=$,J[17]=T,J[18]=w,J[19]=E,J[20]=F/m,J[21]=A/f,J[22]=0,J[23]=0,J[24]=R/m,J[25]=v/f,J[26]=0,J[27]=0,J[28]=U/m,J[29]=L/f,J[30]=1,J[31]=0;const D=r.acquireAndWriteUniformBuffer(J),G=\`bitmap_\${g?"s":"n"}_\${d?"r":"c"}\`;let B=pc.get(G);B||(B=t.createSampler({magFilter:g?"linear":"nearest",minFilter:g?"linear":"nearest",addressModeU:d?"repeat":"clamp-to-edge",addressModeV:d?"repeat":"clamp-to-edge"}),pc.set(G,B));const z=n.getBindGroupLayout("bitmap_fill");if(!z)return console.error("[WebGPU] bitmap_fill bind group layout not found"),Ot(S),null;as[0].resource.buffer=D,as[1].resource=B,as[2].resource=S.createView();const k=t.createBindGroup({layout:z,entries:as}),_=x?b?"bitmap_stroke_atlas":"bitmap_stroke_bgra":b?"bitmap_fill":"bitmap_fill_bgra",I=n.getPipeline(_);return I?(e.setPipeline(I),e.setVertexBuffer(0,P),e.setBindGroup(0,k),e.draw(y.indexCount,1,0,0),S):(console.error(\`[WebGPU] \${_} pipeline not found\`),Ot(S),null)},mc=new Float32Array([-1,-1,.5,.5,1,-1,.5,.5,-1,1,.5,.5,-1,1,.5,.5,1,-1,.5,.5,1,1,.5,.5]),Km=new Float32Array([1,1,1,1,.5,0,0,0,0,.5,0,0,.5,.5,1,0]),qm=(t,e,r,n,s)=>{if(!s)return;const o=s.clipLevel,i=1<{const a=s.clipLevel,h=s.width,d=s.height,g=l[0],m=l[1],f=l[2],b=l[3]*c;if(o.length===0)return;const x=dn(o);if(x.indexCount===0)return;const y=r.acquireVertexBuffer(x.buffer.byteLength,x.buffer),P=i[0],S=i[1],M=i[3],$=i[4],T=i[6],w=i[7];Le[0]=g,Le[1]=m,Le[2]=f,Le[3]=b,Le[4]=P/h,Le[5]=S/d,Le[6]=0,Le[7]=0,Le[8]=M/h,Le[9]=$/d,Le[10]=0,Le[11]=0,Le[12]=T/h,Le[13]=w/d,Le[14]=1,Le[15]=0;const E=r.dynamicUniform.allocate(Le);let F=Rr.get(a)??a,A;u?A=\`clip_write_main_\${Math.min(8,Math.max(1,F))}\`:A="clip_write";const R=n.getPipeline(A);if(!R){console.error(\`[WebGPU] \${A} pipeline not found\`);return}const v=n.getBindGroupLayout("fill_dynamic");if(!v)return;const U=t.createBindGroup({layout:v,entries:[{binding:0,resource:{buffer:r.dynamicUniform.getBuffer(),size:256}}]});e.setPipeline(R),e.setStencilReference(0),e.setVertexBuffer(0,y),e.setBindGroup(0,U,[E]),e.draw(x.indexCount,1,0,0),F++,F>8&&(qm(t,e,r,n,s),F=a+1),Rr.set(a,F)};let No=null,gc=null;const Zm=(t,e,r,n,s,o,i,l)=>{const c=rs();if(c.count===0)return r;r&&(r.end(),r=null);const u=gt(),a=Or(),g=(F=>{switch(F){case"add":return"instanced_add";case"screen":return"instanced_screen";case"alpha":return"instanced_alpha";case"erase":return"instanced_erase";case"copy":return"instanced_copy";default:return"instanced"}})(ts),m=l.getPipeline(g),f=l.getPipeline("instanced_masked"),b=u&&f&&(n.msaaStencil?.view||n.stencil?.view),x=b?f:m;if(!x)return console.error("[WebGPU] Instanced pipeline not found"),null;let y;if(b){const F=n.msaa&&n.msaaTexture?.view,A=F?n.msaaTexture.view:n.texture.view,R=F&&n.msaaStencil?.view?n.msaaStencil.view:n.stencil.view,v=F?n.texture.view:null,U=o.createStencilRenderPassDescriptor(A,R,"load","load",v);y=e.beginRenderPass(U)}else{const F=n.msaa&&n.msaaTexture?.view,A=F?n.msaaTexture.view:n.texture.view,R=F?n.texture.view:null,v=o.createRenderPassDescriptor(A,0,0,0,0,"load",R);y=e.beginRenderPass(v)}y.setPipeline(x),b&&y.setStencilReference(a);const P=new Float32Array(Ve.buffer.buffer,Ve.buffer.byteOffset,Ve.offset),S=s.acquireVertexBuffer(P.byteLength,P),M=s.getUnitRectBuffer(),$=Ne()||o.getAttachment("atlas");if(!$)return console.error("[WebGPU] Atlas attachment not found"),y.end(),null;const T=i.createSampler("atlas_instanced_sampler",!1),w=l.getBindGroupLayout("instanced");if(!w)return console.error("[WebGPU] Instanced bind group layout not found"),y.end(),null;const E=$.texture.view;return(!No||gc!==E)&&(No=t.createBindGroup({layout:w,entries:[{binding:0,resource:T},{binding:1,resource:E}]}),gc=E),y.setVertexBuffer(0,M),y.setVertexBuffer(1,S),y.setBindGroup(0,No),y.draw(6,c.count,0,0),y.end(),c.clear(),null};let zo=null,bc=null;const Jm=(t,e,r,n,s,o,i,l,c=!0,u=!0)=>{const a=rs();if(a.count===0)return r;r&&(r.end(),r=null);const h=gt(),d=Or(),f=(R=>{switch(R){case"add":return"instanced_add";case"screen":return"instanced_screen";case"alpha":return"instanced_alpha";case"erase":return"instanced_erase";case"copy":return"instanced_copy";default:return"instanced"}})(ts),b=l.getPipeline(f),x=l.getPipeline("instanced_masked"),y=h&&x&&(n.msaaStencil?.view||n.stencil?.view),P=y?x:b;if(!P)return console.error("[WebGPU] Instanced pipeline not found"),null;let S;if(y){const R=n.msaa&&n.msaaTexture?.view,v=R?n.msaaTexture.view:n.texture.view,U=R&&n.msaaStencil?.view?n.msaaStencil.view:n.stencil.view,L=R?n.texture.view:null,D=o.createStencilRenderPassDescriptor(v,U,"load","load",L);S=e.beginRenderPass(D)}else{const R=n.msaa&&n.msaaTexture?.view,v=R?n.msaaTexture.view:n.texture.view,U=R?n.texture.view:null,L=o.createRenderPassDescriptor(v,0,0,0,0,"load",U);S=e.beginRenderPass(L)}S.setPipeline(P),y&&S.setStencilReference(d);const M=new Float32Array(Ve.buffer.buffer,Ve.buffer.byteOffset,Ve.offset);let $;u?($=s.acquireStorageBuffer(M.byteLength),s.writeStorageBuffer($,M)):$=s.acquireVertexBuffer(M.byteLength,M);const T=s.getUnitRectBuffer(),w=Ne()||o.getAttachment("atlas");if(!w)return console.error("[WebGPU] Atlas attachment not found"),S.end(),null;const E=i.createSampler("atlas_instanced_sampler",!1),F=l.getBindGroupLayout("instanced");if(!F)return console.error("[WebGPU] Instanced bind group layout not found"),S.end(),null;const A=w.texture.view;if((!zo||bc!==A)&&(zo=t.createBindGroup({layout:F,entries:[{binding:0,resource:E},{binding:1,resource:A}]}),bc=A),S.setVertexBuffer(0,T),S.setVertexBuffer(1,$),S.setBindGroup(0,zo),c){const R=s.createIndirectBuffer(6,a.count,0,0);S.drawIndirect(R,0)}else S.draw(6,a.count,0,0);return S.end(),a.clear(),null},je=new Float32Array(12),bn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Xo=(t,e,r,n,s)=>{const{device:o,commandEncoder:i,frameBufferManager:l,pipelineManager:c,textureManager:u}=s,a=Math.max(t.width,e.width),h=Math.max(t.height,e.height),d=l.createTemporaryAttachment(a,h),g=c.getPipeline("complex_blend"),m=c.getBindGroupLayout("complex_blend");if(!g||!m)return console.error(\`[WebGPU ComplexBlend] Pipeline not found for blend mode: \${r}\`),t;const f=u.createSampler("complex_blend_sampler",!0),b=N.getBlendModeIndex(r);je[0]=n[0],je[1]=n[1],je[2]=n[2],je[3]=n[3],je[4]=n[4],je[5]=n[5],je[6]=n[6],je[7]=n[7],je[8]=b,je[9]=0,je[10]=0,je[11]=0;const x=s.bufferManager?s.bufferManager.acquireAndWriteUniformBuffer(je):o.createBuffer({size:48,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});s.bufferManager||o.queue.writeBuffer(x,0,je),bn[0].resource.buffer=x,bn[1].resource=f,bn[2].resource=e.texture.view,bn[3].resource=t.texture.view;const y=o.createBindGroup({layout:m,entries:bn}),P=l.createRenderPassDescriptor(d.texture.view,0,0,0,0,"clear"),S=i.beginRenderPass(P);return S.setPipeline(g),S.setBindGroup(0,y),S.draw(6,1,0,0),S.end(),d},xn=new Float32Array(4),it=new Float32Array(6),Oe=new Float32Array(8),Qe=new Float32Array(12),at=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],e0=(t,e,r,n,s,o,i,l,c,u,a,h,d,g)=>{const m=d.getPipeline("complex_blend_copy"),f=d.getBindGroupLayout("texture_copy");if(!m||!f)return;xn[0]=c/i,xn[1]=u/l,xn[2]=s/i,xn[3]=o/l;const b=g.acquireAndWriteUniformBuffer(xn),x=h.createSampler("complex_blend_copy_sampler",!1);at[0].resource.buffer=b,at[1].resource=x,at[2].resource=r;const y=t.createBindGroup({layout:f,entries:at}),P=a.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),S=e.beginRenderPass(P);S.setPipeline(m),S.setBindGroup(0,y),S.draw(6,1,0,0),S.end()},t0=(t,e,r,n,s,o,i,l,c,u)=>{const a=n.msaa&&n.msaaTexture?.view,h=a?"complex_blend_output_msaa":"complex_blend_output",d=c.getPipeline(h),g=c.getBindGroupLayout("positioned_texture");if(!d||!g)return;Oe[0]=s,Oe[1]=o,Oe[2]=r.width,Oe[3]=r.height,Oe[4]=n.width,Oe[5]=n.height,Oe[6]=0,Oe[7]=0;const m=u.acquireAndWriteUniformBuffer(Oe),f=l.createSampler("complex_blend_output_sampler",!1);at[0].resource.buffer=m,at[1].resource=f,at[2].resource=r.texture.view;const b=t.createBindGroup({layout:g,entries:at}),x=a?n.msaaTexture.view:n.texture.view,y=a?n.texture.view:null,P=i.createRenderPassDescriptor(x,0,0,0,0,"load",y),S=e.beginRenderPass(P);S.setPipeline(d),S.setBindGroup(0,b),S.draw(6,1,0,0),S.end()},r0=(t,e,r,n,s,o,i)=>{const l=om();if(l.length===0)return;if(!r||!r.texture){So();return}const c=Ne()||n.getAttachment("atlas");if(!c||!c.texture){So();return}for(const u of l){const{node:a,x_min:h,y_min:d,x_max:g,y_max:m,color_transform:f,matrix:b,blend_mode:x,global_alpha:y}=u,P=Math.ceil(Math.abs(g-h)),S=Math.ceil(Math.abs(m-d));if(P<=0||S<=0)continue;const M=Math.max(0,Math.floor(b[6])),$=Math.max(0,Math.floor(b[7]));if(M>=r.width||$>=r.height)continue;const T=b[0]!==1||b[1]!==0||b[3]!==0||b[4]!==1,w=T?P:a.w,E=T?S:a.h,F=Math.min(w,r.width-M),A=Math.min(E,r.height-$);if(F<=0||A<=0)continue;let R;if(T){R=n.createTemporaryAttachment(w,E);const L=o.getPipeline("complex_blend_scale"),D=o.getBindGroupLayout("texture_scale");if(L&&D){const G=w/2,B=E/2,z=a.w/2,k=a.h/2;it[0]=b[0],it[1]=b[1],it[2]=b[3],it[3]=b[4],it[4]=-z*b[0]-k*b[3]+G,it[5]=-z*b[1]-k*b[4]+B;const _=n.createTemporaryAttachment(a.w,a.h);e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:_.texture.resource,origin:{x:0,y:0,z:0}},{width:a.w,height:a.h}),Qe[0]=it[0],Qe[1]=it[1],Qe[2]=it[2],Qe[3]=it[3],Qe[4]=it[4],Qe[5]=it[5],Qe[6]=a.w,Qe[7]=a.h,Qe[8]=w,Qe[9]=E,Qe[10]=0,Qe[11]=0;const I=i.acquireAndWriteUniformBuffer(Qe,48),V=s.createSampler("scale_sampler",!0);at[0].resource.buffer=I,at[1].resource=V,at[2].resource=_.texture.view;const X=t.createBindGroup({layout:D,entries:at}),Y=n.createRenderPassDescriptor(R.texture.view,0,0,0,0,"clear"),W=e.beginRenderPass(Y);W.setPipeline(L),W.setBindGroup(0,X),W.draw(6,1,0,0),W.end(),n.releaseTemporaryAttachment(_)}else e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:R.texture.resource,origin:{x:0,y:0,z:0}},{width:Math.min(a.w,w),height:Math.min(a.h,E)})}else R=n.createTemporaryAttachment(w,E),e.copyTextureToTexture({texture:c.texture.resource,origin:{x:a.x,y:a.y,z:0}},{texture:R.texture.resource,origin:{x:0,y:0,z:0}},{width:w,height:E});const v=n.createTemporaryAttachment(w,E);e0(t,e,r.texture.view,v,M,$,r.width,r.height,w,E,n,s,o,i),Oe[0]=f[0],Oe[1]=f[1],Oe[2]=f[2],Oe[3]=y,Oe[4]=f[4],Oe[5]=f[5],Oe[6]=f[6],Oe[7]=0;const U=Xo(R,v,x,Oe,{device:t,commandEncoder:e,bufferManager:i,frameBufferManager:n,pipelineManager:o,textureManager:s});t0(t,e,U,r,M,$,n,s,o,i),n.releaseTemporaryAttachment(R),n.releaseTemporaryAttachment(v),n.releaseTemporaryAttachment(U)}So()},ne={x:0,y:0},xc=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],n0=(t,e,r,n,s)=>{const o=Math.sqrt(t[0]*t[0]+t[1]*t[1]),i=Math.sqrt(t[2]*t[2]+t[3]*t[3]),l=e*(o/s),c=r*(i/s),u=xc[Math.min(n-1,xc.length-1)],a=Math.round(l*u),h=Math.round(c*u);let d=1,g=1;return l>128?d=.0625:l>64?d=.125:l>32?d=.25:l>16&&(d=.5),c>128?g=.0625:c>64?g=.125:c>32?g=.25:c>16&&(g=.5),{baseBlurX:l,baseBlurY:c,offsetX:a,offsetY:h,bufferScaleX:d,bufferScaleY:g}},s0=(t,e,r,n)=>{const s=Math.ceil(e*.5),o=1-(s-e*.5),i=1+e,l=t?1/r:0,c=t?0:1/n;return{offsetX:l,offsetY:c,fraction:o,samples:i,halfBlur:s}},ht=new Float32Array(8),cs=[{binding:0,resource:null},{binding:1,resource:null},{binding:2,resource:{buffer:null}}],o0={label:"blur_compute_pass_h"},i0={label:"blur_compute_pass_v"},yc=(t,e,r,n,s,o,i,l)=>{const c=Math.ceil(i*.5),a=c>=8&&c<=24?o?"blur_compute_shared_horizontal":"blur_compute_shared_vertical":o?"blur_compute_horizontal":"blur_compute_vertical",h=r.getPipeline(a),d=r.getBindGroupLayout("blur_compute");if(!h||!d)return;const g=1-(c-i*.5),m=1+i;ht[0]=o?1:0,ht[1]=o?0:1,ht[2]=c,ht[3]=g,ht[4]=n.width,ht[5]=n.height,ht[6]=m,ht[7]=0;const f=l?l.acquireAndWriteUniformBuffer(ht):(()=>{const S=t.createBuffer({size:ht.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});return t.queue.writeBuffer(S,0,ht),S})();cs[0].resource=n.texture.view,cs[1].resource=s.texture.view,cs[2].resource.buffer=f;const b=t.createBindGroup({layout:d,entries:cs}),x=e.beginComputePass(o?o0:i0);x.setPipeline(h),x.setBindGroup(0,b);const y=Math.ceil(s.width/16),P=Math.ceil(s.height/16);x.dispatchWorkgroups(y,P,1),x.end()},a0=(t,e,r,n)=>{const i=Math.max(t,e),l=Math.min(r,n);return i>=4&&l>=128},ye=new Float32Array(4),ct=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],sr=(t,e,r,n,s,o,i)=>{const{device:l,commandEncoder:c,frameBufferManager:u,pipelineManager:a,textureManager:h}=i,d=n0(e,r,n,s,o),{baseBlurX:g,baseBlurY:m,offsetX:f,offsetY:b,bufferScaleX:x,bufferScaleY:y}=d;ne.x+=f,ne.y+=b;const P=t.width+f*2,S=t.height+b*2,M=Math.ceil(P*x),$=Math.ceil(S*y),T=u.createTemporaryAttachment(M,$),w=u.createTemporaryAttachment(M,$),E=h.createSampler("blur_sampler",!0);c0(l,c,u,a,t,T,E,x,y,f*x,b*y,i.bufferManager);const F=g*x,A=m*y,R=i.computePipelineManager&&a0(g,m,M,$),v=[T,w];let U=0;for(let D=0;D0){const G=U;U=(U+1)%2,R?yc(l,c,i.computePipelineManager,v[G],v[U],!0,F,i.bufferManager):vc(l,c,u,a,v[G],v[U],E,!0,F,i.bufferManager)}if(n>0){const G=U;U=(U+1)%2,R?yc(l,c,i.computePipelineManager,v[G],v[U],!1,A,i.bufferManager):vc(l,c,u,a,v[G],v[U],E,!1,A,i.bufferManager)}}let L=v[U];if(x!==1||y!==1){const D=u.createTemporaryAttachment(P,S);l0(l,c,u,a,L,D,E,1/x,1/y,i.bufferManager),u.releaseTemporaryAttachment(T),u.releaseTemporaryAttachment(w),L=D}else{const D=(U+1)%2;u.releaseTemporaryAttachment(v[D])}return L},c0=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const d=n.getPipeline("texture_copy_rgba8"),g=n.getBindGroupLayout("texture_copy");if(!d||!g){console.error("[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found");return}const m=s.width*l,f=s.height*c,b=1,x=1,y=0,P=0;ye[0]=b,ye[1]=x,ye[2]=y,ye[3]=P;const S=h?h.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h||t.queue.writeBuffer(S,0,ye),ct[0].resource.buffer=S,ct[1].resource=i,ct[2].resource=s.texture.view;const M=t.createBindGroup({layout:g,entries:ct}),$=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),T=e.beginRenderPass($);T.setPipeline(d),T.setBindGroup(0,M),T.setViewport(u,a,m,f,0,1),T.setScissorRect(Math.floor(u),Math.floor(a),Math.ceil(m),Math.ceil(f)),T.draw(6,1,0,0),T.end()},vc=(t,e,r,n,s,o,i,l,c,u)=>{const a=s0(l,c,s.width,s.height),{offsetX:h,offsetY:d,fraction:g,samples:m,halfBlur:f}=a,b=Math.max(1,Math.min(16,f)),x=n.getPipeline(\`blur_filter_\${b}\`),y=n.getBindGroupLayout("blur_filter");if(!x||!y){console.error(\`[WebGPU BlurFilter] blur_filter_\${b} pipeline not found\`);return}ye[0]=h,ye[1]=d,ye[2]=g,ye[3]=m;const P=u?u.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});u||t.queue.writeBuffer(P,0,ye),ct[0].resource.buffer=P,ct[1].resource=i,ct[2].resource=s.texture.view;const S=t.createBindGroup({layout:y,entries:ct}),M=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),$=e.beginRenderPass(M);$.setPipeline(x),$.setBindGroup(0,S),$.draw(6,1,0,0),$.end()},l0=(t,e,r,n,s,o,i,l,c,u)=>{const a=n.getPipeline("texture_copy_rgba8"),h=n.getBindGroupLayout("texture_copy");if(!a||!h){console.error("[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found");return}ye[0]=1,ye[1]=1,ye[2]=0,ye[3]=0;const d=u?u.acquireAndWriteUniformBuffer(ye):t.createBuffer({size:ye.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});u||t.queue.writeBuffer(d,0,ye),ct[0].resource.buffer=d,ct[1].resource=i,ct[2].resource=s.texture.view;const g=t.createBindGroup({layout:h,entries:ct}),m=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),f=e.beginRenderPass(m);f.setPipeline(a),f.setBindGroup(0,g),f.draw(6,1,0,0),f.end()},de=new Float32Array(20),ls=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Mc=(t,e,r)=>{const{device:n,commandEncoder:s,frameBufferManager:o,pipelineManager:i,textureManager:l}=r,c=o.createTemporaryAttachment(t.width,t.height),u=i.getPipeline("color_matrix_filter"),a=i.getBindGroupLayout("color_matrix_filter");if(!u||!a)return console.error("[WebGPU ColorMatrixFilter] Pipeline not found"),t;const h=l.createSampler("color_matrix_sampler",!0);de[0]=e[0],de[1]=e[5],de[2]=e[10],de[3]=e[15],de[4]=e[1],de[5]=e[6],de[6]=e[11],de[7]=e[16],de[8]=e[2],de[9]=e[7],de[10]=e[12],de[11]=e[17],de[12]=e[3],de[13]=e[8],de[14]=e[13],de[15]=e[18],de[16]=e[4]/255,de[17]=e[9]/255,de[18]=e[14]/255,de[19]=e[19]/255;const d=r.bufferManager?r.bufferManager.acquireAndWriteUniformBuffer(de):n.createBuffer({size:de.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});r.bufferManager||n.queue.writeBuffer(d,0,de),ls[0].resource.buffer=d,ls[1].resource=h,ls[2].resource=t.texture.view;const g=n.createBindGroup({layout:a,entries:ls}),m=o.createRenderPassDescriptor(c.texture.view,0,0,0,0,"clear"),f=s.beginRenderPass(m);return f.setPipeline(u),f.setBindGroup(0,g),f.draw(6,1,0,0),f.end(),c},Pe=new Float32Array(16),yn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],u0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Sc=(t,e,r,n,s,o,i,l,c,u,a,h)=>{const{device:d,commandEncoder:g,frameBufferManager:m,pipelineManager:f,textureManager:b}=h,x=ne.x,y=ne.y,P=t.width,S=t.height,M=sr(t,e,s,o,l,a,h),$=M.width,T=M.height,w=ne.x,E=ne.y,F=c?P:$,A=c?S:T,R=w-x,v=E-y,U=c?0:R,L=c?0:v,D=c?-R:0,G=c?-v:0,B=F/P,z=A/S,k=U/P,_=L/S,I=F/$,V=A/T,X=D/$,Y=G/T,W=m.createTemporaryAttachment(F,A),K=f.getFilterPipeline("glow_filter",{IS_INNER:c?1:0,IS_KNOCKOUT:u?1:0}),q=f.getBindGroupLayout("glow_filter");if(!K||!q)return console.error("[WebGPU GlowFilter] Pipeline not found"),m.releaseTemporaryAttachment(M),t;const ce=b.createSampler("glow_sampler",!0),[te,se,ue,Fe]=u0(r,n);Pe[0]=te,Pe[1]=se,Pe[2]=ue,Pe[3]=Fe,Pe[4]=B,Pe[5]=z,Pe[6]=k,Pe[7]=_,Pe[8]=I,Pe[9]=V,Pe[10]=X,Pe[11]=Y,Pe[12]=i,Pe[13]=c?1:0,Pe[14]=u?1:0,Pe[15]=0;const ge=h.bufferManager?h.bufferManager.acquireAndWriteUniformBuffer(Pe):d.createBuffer({size:Pe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.bufferManager||d.queue.writeBuffer(ge,0,Pe),yn[0].resource.buffer=ge,yn[1].resource=ce,yn[2].resource=M.texture.view,yn[3].resource=t.texture.view;const Q=d.createBindGroup({layout:q,entries:yn}),Ct=m.createRenderPassDescriptor(W.texture.view,0,0,0,0,"clear"),Je=g.beginRenderPass(Ct);return Je.setPipeline(K),Je.setBindGroup(0,Q),Je.draw(6,1,0,0),Je.end(),m.releaseTemporaryAttachment(M),W},f0=Math.PI/180,Ae=new Float32Array(16),vn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],h0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},$c=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,i,l,u,g,m),E=w.width,F=w.height,A=ne.x,R=ne.y,v=A-S,U=R-M,L=Math.sqrt(e[0]*e[0]+e[1]*e[1]),D=Math.sqrt(e[2]*e[2]+e[3]*e[3]),G=n*f0,B=Math.cos(G)*r*(L/g),z=Math.sin(G)*r*(D/g),k=a?$:E+Math.max(0,Math.abs(B)-v),_=a?T:F+Math.max(0,Math.abs(z)-U),I=Math.ceil(k),V=Math.ceil(_),X=(I-k)/2,Y=(V-_)/2,W=a?0:Math.max(0,v-B)+X,K=a?0:Math.max(0,U-z)+Y,q=a?B-A:(B>0?Math.max(0,B-v):0)+X,ce=a?z-R:(z>0?Math.max(0,z-U):0)+Y,te=x.createTemporaryAttachment(I,V),se=a;let ue=h,Fe=d;a?ue=h||d:!h&&d&&(ue=!0,Fe=!0);const ge=y.getFilterPipeline("drop_shadow_filter",{IS_INNER:se?1:0,IS_KNOCKOUT:ue?1:0,IS_HIDE_OBJECT:Fe?1:0}),Q=y.getBindGroupLayout("drop_shadow_filter");if(!ge||!Q)return console.error("[WebGPU DropShadowFilter] Pipeline not found"),x.releaseTemporaryAttachment(w),t;const Ct=P.createSampler("drop_shadow_sampler",!0),[Je,Ut,lr,ur]=h0(s,o),Yt=I/$,Gt=V/T,Lt=W/$,Wt=K/T,fr=I/E,jt=V/F,hr=q/E,Ht=ce/F;Ae[0]=Je,Ae[1]=Ut,Ae[2]=lr,Ae[3]=ur,Ae[4]=Yt,Ae[5]=Gt,Ae[6]=Lt,Ae[7]=Wt,Ae[8]=fr,Ae[9]=jt,Ae[10]=hr,Ae[11]=Ht,Ae[12]=c,Ae[13]=se?1:0,Ae[14]=ue?1:0,Ae[15]=Fe?1:0;const lt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Ae):f.createBuffer({size:Ae.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(lt,0,Ae),vn[0].resource.buffer=lt,vn[1].resource=Ct,vn[2].resource=w.texture.view,vn[3].resource=t.texture.view;const zr=f.createBindGroup({layout:Q,entries:vn}),Bn=x.createRenderPassDescriptor(te.texture.view,0,0,0,0,"clear"),kt=b.beginRenderPass(Bn);return kt.setPipeline(ge),kt.setBindGroup(0,zr),kt.draw(6,1,0,0),kt.end(),x.releaseTemporaryAttachment(w),te},d0=Math.PI/180,dt=new Float32Array(8),pe=new Float32Array(20),us=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Mn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Tc=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Bc=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f)=>{const{device:b,commandEncoder:x,frameBufferManager:y,pipelineManager:P,textureManager:S}=f,M=ne.x,$=ne.y,T=t.width,w=t.height,E=Math.sqrt(e[0]*e[0]+e[1]*e[1]),F=Math.sqrt(e[2]*e[2]+e[3]*e[3]),A=n*d0,R=Math.cos(A)*r*(E/m),v=Math.sin(A)*r*(F/m),U=y.createTemporaryAttachment(T,w);x.copyTextureToTexture({texture:t.texture.resource,origin:{x:0,y:0,z:0}},{texture:U.texture.resource,origin:{x:0,y:0,z:0}},{width:T,height:w});const L=P.getPipeline("texture_erase"),D=P.getBindGroupLayout("texture_copy");if(L&&D){const fg=S.createSampler("erase_sampler",!0),hg=R*2/T,dg=v*2/w;dt[0]=1,dt[1]=1,dt[2]=hg,dt[3]=dg,dt[4]=0,dt[5]=0,dt[6]=0,dt[7]=0;const zc=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(dt):b.createBuffer({size:dt.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(zc,0,dt),us[0].resource.buffer=zc,us[1].resource=fg,us[2].resource=t.texture.view;const pg=b.createBindGroup({layout:D,entries:us}),mg=y.createRenderPassDescriptor(U.texture.view,0,0,0,0,"load"),gs=x.beginRenderPass(mg);gs.setPipeline(L),gs.setBindGroup(0,pg),gs.draw(6,1,0,0),gs.end()}const G=sr(U,e,c,u,h,m,f);y.releaseTemporaryAttachment(U);const B=G.width,z=G.height,k=Math.abs(R),_=Math.abs(v),I=d===1,V=Math.ceil(B+k*2),X=Math.ceil(z+_*2),Y=I?T:V,W=I?w:X,K=(B-T)/2,q=(z-w)/2,ce=I?0:Math.floor(k+K),te=I?0:Math.floor(_+q),se=Math.floor(I?-K-R:k-R),ue=Math.floor(I?-q-v:_-v),Fe=Y/T,ge=W/w,Q=ce/T,Ct=te/w,Je=Y/B,Ut=W/z,lr=se/B,ur=ue/z,Yt=y.createTemporaryAttachment(Y,W),Gt=P.getFilterPipeline("bevel_filter",{BEVEL_TYPE:d,IS_KNOCKOUT:g?1:0}),Lt=P.getBindGroupLayout("bevel_filter");if(!Gt||!Lt)return console.error("[WebGPU BevelFilter] Pipeline not found"),y.releaseTemporaryAttachment(G),t;const Wt=S.createSampler("bevel_sampler",!0),[fr,jt,hr,Ht]=Tc(s,o),[lt,zr,Bn,kt]=Tc(i,l);pe[0]=fr,pe[1]=jt,pe[2]=hr,pe[3]=Ht,pe[4]=lt,pe[5]=zr,pe[6]=Bn,pe[7]=kt,pe[8]=a,pe[9]=I?1:0,pe[10]=g?1:0,pe[11]=d,pe[12]=Fe,pe[13]=ge,pe[14]=Q,pe[15]=Ct,pe[16]=Je,pe[17]=Ut,pe[18]=lr,pe[19]=ur;const ps=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(pe):b.createBuffer({size:pe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(ps,0,pe),Mn[0].resource.buffer=ps,Mn[1].resource=Wt,Mn[2].resource=G.texture.view,Mn[3].resource=t.texture.view;const ci=b.createBindGroup({layout:Lt,entries:Mn}),Xr=y.createRenderPassDescriptor(Yt.texture.view,0,0,0,0,"clear"),ms=x.beginRenderPass(Xr);return ms.setPipeline(Gt),ms.setBindGroup(0,ci),ms.draw(6,1,0,0),ms.end(),y.releaseTemporaryAttachment(G),ne.x=M+ce,ne.y=$+te,Yt},fs=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],p0=(t,e)=>{const r=(t>>16&255)/255,n=(t>>8&255)/255,s=(t&255)/255;return[r,n,s,e]},Pc=new Map,Ac=(t,e,r,n,s,o,i,l,c,u,a)=>{const{device:h,commandEncoder:d,frameBufferManager:g,textureManager:m}=a,f=t.width,b=t.height,x=g.createTemporaryAttachment(f,b),y=\`\${e},\${r},\${i},\${l}\`;let P=Pc.get(y);if(!P){const B=N.getConvolutionFilterFragmentShader(e,r,i,l),z=h.createShaderModule({code:B}),k=h.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]}),_=h.createPipelineLayout({bindGroupLayouts:[k]});P={pipeline:h.createRenderPipeline({layout:_,vertex:{module:z,entryPoint:"vs_main",buffers:[]},fragment:{module:z,entryPoint:"fs_main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}}),bindGroupLayout:k},Pc.set(y,P)}const S=m.createSampler("convolution_sampler",!0),M=e*r,$=Math.ceil(M/4),[T,w,E,F]=p0(c,u),A=new Float32Array($*4);for(let B=0;B{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=Math.sqrt(e[0]*e[0]+e[1]*e[1]),E=Math.sqrt(e[2]*e[2]+e[3]*e[3]),F=n*m0,A=Math.cos(F)*r*(w/g),R=Math.sin(F)*r*(E/g),v=y.getPipeline("bevel_base"),U=y.getBindGroupLayout("bevel_base");if(!v||!U)return console.error("[WebGPU GradientBevelFilter] bevel_base pipeline not found"),t;const L=x.createTemporaryAttachment($,T),D=P.createSampler("bevel_base_sampler",!0);or[0]=2*A/$,or[1]=2*R/T,or[2]=0,or[3]=0;const G=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(or):f.createBuffer({size:or.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(G,0,or),hs[0].resource.buffer=G,hs[1].resource=D,hs[2].resource=t.texture.view;const B=f.createBindGroup({layout:U,entries:hs}),z=x.createRenderPassDescriptor(L.texture.view,0,0,0,0,"clear"),k=b.beginRenderPass(z);k.setPipeline(v),k.setBindGroup(0,B),k.draw(6,1,0,0),k.end();const _=sr(L,e,l,c,a,g,m);x.releaseTemporaryAttachment(L);const I=_.width,V=_.height,X=h===1,Y=Math.abs(A),W=Math.abs(R),K=(I-$)/2,q=(V-T)/2,ce=Math.ceil(I+Y*2),te=Math.ceil(V+W*2),se=X?$:ce,ue=X?T:te,Fe=X?0:Y+K,ge=X?0:W+q,Q=X?-K-A:Y-A,Ct=X?-q-R:W-R,Je=ac(i,s,o),Ut=f.createTexture({size:{width:256,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});f.queue.writeTexture({texture:Ut},Je.buffer,{bytesPerRow:256*4,offset:Je.byteOffset},{width:256,height:1});const lr=Ut.createView(),ur=se/$,Yt=ue/T,Gt=Fe/$,Lt=ge/T,Wt=se/I,fr=ue/V,jt=Q/I,hr=Ct/V,Ht=x.createTemporaryAttachment(se,ue),lt=y.getFilterPipeline("gradient_bevel_filter",{BEVEL_TYPE:h,IS_KNOCKOUT:d?1:0}),zr=y.getBindGroupLayout("gradient_bevel_filter");if(!lt||!zr)return console.error("[WebGPU GradientBevelFilter] Pipeline not found"),x.releaseTemporaryAttachment(_),t;const Bn=P.createSampler("gradient_bevel_sampler",!0);ze[0]=u,ze[1]=X?1:0,ze[2]=d?1:0,ze[3]=h,ze[4]=ur,ze[5]=Yt,ze[6]=Gt,ze[7]=Lt,ze[8]=Wt,ze[9]=fr,ze[10]=jt,ze[11]=hr;const kt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(ze):f.createBuffer({size:ze.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(kt,0,ze),Ir[0].resource.buffer=kt,Ir[1].resource=Bn,Ir[2].resource=_.texture.view,Ir[3].resource=t.texture.view,Ir[4].resource=lr;const ps=f.createBindGroup({layout:zr,entries:Ir}),ci=x.createRenderPassDescriptor(Ht.texture.view,0,0,0,0,"clear"),Xr=b.beginRenderPass(ci);return Xr.setPipeline(lt),Xr.setBindGroup(0,ps),Xr.draw(6,1,0,0),Xr.end(),m.frameTextures.push(Ut),x.releaseTemporaryAttachment(_),ne.x=S+Fe,ne.y=M+ge,Ht},g0=Math.PI/180,Xe=new Float32Array(12),_r=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null},{binding:4,resource:null}],wc=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=m,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,l,c,a,g,m),E=w.width,F=w.height,A=ne.x,R=ne.y,v=A-S,U=R-M,L=Math.sqrt(e[0]*e[0]+e[1]*e[1]),D=Math.sqrt(e[2]*e[2]+e[3]*e[3]),G=n*g0,B=Math.cos(G)*r*(L/g),z=Math.sin(G)*r*(D/g),k=h===1,_=k?$:E+Math.max(0,Math.abs(B)-v),I=k?T:F+Math.max(0,Math.abs(z)-U),V=Math.ceil(_),X=Math.ceil(I),Y=(V-_)/2,W=(X-I)/2,K=k?0:Math.max(0,v-B)+Y,q=k?0:Math.max(0,U-z)+W,ce=k?B-A:(B>0?Math.max(0,B-v):0)+Y,te=k?z-R:(z>0?Math.max(0,z-U):0)+W,se=ac(i,s,o),ue=f.createTexture({size:{width:256,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});f.queue.writeTexture({texture:ue},se.buffer,{bytesPerRow:256*4,offset:se.byteOffset},{width:256,height:1});const Fe=ue.createView(),ge=V/$,Q=X/T,Ct=K/$,Je=q/T,Ut=V/E,lr=X/F,ur=ce/E,Yt=te/F,Gt=x.createTemporaryAttachment(V,X),Lt=y.getFilterPipeline("gradient_glow_filter",{GLOW_TYPE:h,IS_KNOCKOUT:d?1:0}),Wt=y.getBindGroupLayout("gradient_glow_filter");if(!Lt||!Wt)return console.error("[WebGPU GradientGlowFilter] Pipeline not found"),x.releaseTemporaryAttachment(w),t;const fr=P.createSampler("gradient_glow_sampler",!0);Xe[0]=u,Xe[1]=k?1:0,Xe[2]=d?1:0,Xe[3]=h,Xe[4]=ge,Xe[5]=Q,Xe[6]=Ct,Xe[7]=Je,Xe[8]=Ut,Xe[9]=lr,Xe[10]=ur,Xe[11]=Yt;const jt=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Xe):f.createBuffer({size:Xe.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||f.queue.writeBuffer(jt,0,Xe),_r[0].resource.buffer=jt,_r[1].resource=fr,_r[2].resource=w.texture.view,_r[3].resource=t.texture.view,_r[4].resource=Fe;const hr=f.createBindGroup({layout:Wt,entries:_r}),Ht=x.createRenderPassDescriptor(Gt.texture.view,0,0,0,0,"clear"),lt=b.beginRenderPass(Ht);return lt.setPipeline(Lt),lt.setBindGroup(0,hr),lt.draw(6,1,0,0),lt.end(),m.frameTextures.push(ue),x.releaseTemporaryAttachment(w),ne.x=S+K,ne.y=M+q,Gt},He=new Float32Array(12),Sn=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],b0=(t,e)=>{const r=(t>>16&255)/255*e,n=(t>>8&255)/255*e,s=(t&255)/255*e;return[r,n,s,e]},Oc=new Map,Ec=(t,e,r,n,s,o,i,l,c,u,a,h,d,g,m,f)=>{const{device:b,commandEncoder:x,frameBufferManager:y,textureManager:P}=f,S=t.width,M=t.height,$=n,T=s,w=y.createTemporaryAttachment(S,M),E=b.createTexture({size:{width:n,height:s},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});b.queue.writeTexture({texture:E},r.buffer,{bytesPerRow:n*4,offset:r.byteOffset},{width:n,height:s});const F=\`\${l},\${c},\${h}\`;let A=Oc.get(F);if(!A){const z=N.getDisplacementMapFilterFragmentShader(l,c,h),k=b.createShaderModule({code:N.getBlurFilterVertexShader()}),_=b.createShaderModule({code:z}),I=b.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}}]}),V=b.createPipelineLayout({bindGroupLayouts:[I]});A={pipeline:b.createRenderPipeline({layout:V,vertex:{module:k,entryPoint:"main",buffers:[]},fragment:{module:_,entryPoint:"main",targets:[{format:"rgba8unorm",blend:{color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}}]},primitive:{topology:"triangle-list",cullMode:"none"}}),bindGroupLayout:I},Oc.set(F,A)}const R=P.createSampler("displacement_sampler",!0),v=h===1,U=v?48:32;if(He[0]=$/n,He[1]=T/s,He[2]=o/n,He[3]=(T-s-i)/s,He[4]=u/$,He[5]=a/T,He[6]=0,He[7]=0,v){const[z,k,_,I]=b0(d,g);He[8]=z,He[9]=k,He[10]=_,He[11]=I}const L=f.bufferManager?f.bufferManager.acquireAndWriteUniformBuffer(He,U):b.createBuffer({size:U,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});f.bufferManager||b.queue.writeBuffer(L,0,He,0,U/4),Sn[0].resource.buffer=L,Sn[1].resource=R,Sn[2].resource=t.texture.view,Sn[3].resource=E.createView();const D=b.createBindGroup({layout:A.bindGroupLayout,entries:Sn}),G=y.createRenderPassDescriptor(w.texture.view,0,0,0,0,"clear"),B=x.beginRenderPass(G);return B.setPipeline(A.pipeline),B.setBindGroup(0,D),B.draw(6,1,0,0),B.end(),f.frameTextures.push(E),w},bt=new Float32Array(4),Te=new Float32Array(6),Ee=new Float32Array(6),oe=new Float32Array(8),Ze=new Float32Array(12),ve=new Float32Array(20),fe=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],x0=new Set(["normal","layer","add","screen","alpha","erase","copy"]),y0=new Float32Array([1,-1,0,1]),v0=t=>t[0]===1&&t[1]===1&&t[2]===1&&t[3]===1&&t[4]===0&&t[5]===0&&t[6]===0&&t[7]===0,M0=(t,e,r)=>{const n=t.frameBufferManager.createTemporaryAttachment(e.width,e.height),s=t.pipelineManager.getPipeline("color_transform"),o=t.pipelineManager.getBindGroupLayout("texture_copy");if(!s||!o||!e.texture||!n.texture)return e;oe[0]=r[0],oe[1]=r[1],oe[2]=r[2],oe[3]=r[3],oe[4]=r[4],oe[5]=r[5],oe[6]=r[6],oe[7]=0;const i=t.bufferManager.acquireAndWriteUniformBuffer(oe),l=t.textureManager.createSampler("color_transform_sampler",!1);fe[0].resource.buffer=i,fe[1].resource=l,fe[2].resource=e.texture.view;const c=t.device.createBindGroup({layout:o,entries:fe}),u=t.frameBufferManager.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),a=t.commandEncoder.beginRenderPass(u);return a.setPipeline(s),a.setBindGroup(0,c),a.draw(6,1,0,0),a.end(),n},S0=(t,e,r)=>{const n=r.createTemporaryAttachment(t.w,t.h),s=Ne()||r.getAttachment("atlas");return s&&s.texture&&n.texture?e.copyTextureToTexture({texture:s.texture.resource,origin:{x:t.x,y:t.y,z:0}},{texture:n.texture.resource,origin:{x:0,y:0,z:0}},{width:t.w,height:t.h}):console.error("[WebGPU Filter] getTextureFromNode: FAILED - missing atlas or textures"),n},$0=t=>x0.has(t),T0=(t,e,r,n,s,o)=>{const i=t.frameBufferManager.createTemporaryAttachment(s,o),l=t.pipelineManager.getPipeline("complex_blend_copy"),c=t.pipelineManager.getBindGroupLayout("texture_copy");if(!l||!c||!e.texture||!i.texture)return i;const u=s/e.width,a=o/e.height,h=r/e.width,d=n/e.height;bt[0]=u,bt[1]=a,bt[2]=h,bt[3]=d;const g=t.bufferManager.acquireAndWriteUniformBuffer(bt),m=t.textureManager.createSampler("filter_copy_sampler",!1);fe[0].resource.buffer=g,fe[1].resource=m,fe[2].resource=e.texture.view;const f=t.device.createBindGroup({layout:c,entries:fe}),b=t.frameBufferManager.createRenderPassDescriptor(i.texture.view,0,0,0,0,"clear"),x=t.commandEncoder.beginRenderPass(b);return x.setPipeline(l),x.setBindGroup(0,f),x.draw(6,1,0,0),x.end(),i},B0=(t,e,r,n,s)=>{const o=r.msaa&&r.msaaTexture?.view,i=o?"filter_complex_blend_output_msaa":"filter_complex_blend_output",l=t.pipelineManager.getPipeline(i),c=t.pipelineManager.getBindGroupLayout("positioned_texture");if(!l||!c||!e.texture||!r.texture)return;oe[0]=n,oe[1]=s,oe[2]=e.width,oe[3]=e.height,oe[4]=r.width,oe[5]=r.height,oe[6]=0,oe[7]=0;const u=t.bufferManager.acquireAndWriteUniformBuffer(oe),a=t.textureManager.createSampler("filter_blend_output_sampler",!1);fe[0].resource.buffer=u,fe[1].resource=a,fe[2].resource=e.texture.view;const h=t.device.createBindGroup({layout:c,entries:fe}),d=o?r.msaaTexture.view:r.texture.view,g=o?r.texture.view:null,m=t.frameBufferManager.createRenderPassDescriptor(d,0,0,0,0,"load",g),f=t.commandEncoder.beginRenderPass(m);f.setPipeline(l),f.setBindGroup(0,h),f.draw(6,1,0,0),f.end()},P0=(t,e,r,n,s,o,i,l)=>{const c=t.mainAttachment||t.frameBufferManager.getAttachment("main");if(!c||!c.texture||!e.texture)return;let u=s,a=o,h=e.width,d=e.height,g=0,m=0;if(u<0&&(g=-u/e.width,h+=u,u=0),a<0&&(m=-a/e.height,d+=a,a=0),h<=0||d<=0)return;const f=c.width,b=c.height;if(u+h>f&&(h=f-u),a+d>b&&(d=b-a),$0(n)){const x=c.msaa&&c.msaaTexture?.view;let y;switch(n){case"add":y=x?"filter_output_add_msaa":"filter_output_add";break;case"screen":y=x?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":y=x?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":y=x?"filter_output_erase_msaa":"filter_output_erase";break;case"copy":y=x?"texture_copy_bgra_msaa":"texture_copy_bgra";break;default:y=x?"filter_output_msaa":"filter_output";break}let P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("texture_copy");if((!P||!S)&&(y=x?"filter_output_msaa":"filter_output",P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("texture_copy"),!P||!S))return;const M=t.textureManager.createSampler("filter_output_sampler",!0),$=h/e.width,T=d/e.height;bt[0]=$,bt[1]=T,bt[2]=g,bt[3]=m;const w=t.bufferManager.acquireAndWriteUniformBuffer(bt);fe[0].resource.buffer=w,fe[1].resource=M,fe[2].resource=e.texture.view;const E=t.device.createBindGroup({layout:S,entries:fe}),F=x?c.msaaTexture.view:c.texture.view,A=x?c.texture.view:null,R=t.frameBufferManager.createRenderPassDescriptor(F,0,0,0,0,"load",A),v=Math.max(0,u),U=Math.max(0,a),L=Math.max(1,h),D=Math.max(1,d),G=Math.max(0,Math.floor(v)),B=Math.max(0,Math.floor(U)),z=Math.max(1,Math.min(Math.ceil(v+L)-G,f-G)),k=Math.max(1,Math.min(Math.ceil(U+D)-B,b-B));if(z<=0||k<=0||G>=f||B>=b)return;const _=t.commandEncoder.beginRenderPass(R);_.setPipeline(P),_.setBindGroup(0,E),_.setViewport(v,U,L,D,0,1),_.setScissorRect(G,B,z,k),_.draw(6,1,0,0),_.end()}else{const x=T0(t,c,u,a,h,d);oe[0]=r[0],oe[1]=r[1],oe[2]=r[2],oe[3]=r[3],oe[4]=r[4],oe[5]=r[5],oe[6]=r[6],oe[7]=0;const y=Xo(e,x,n,oe,{device:t.device,commandEncoder:t.commandEncoder,bufferManager:t.bufferManager,frameBufferManager:t.frameBufferManager,pipelineManager:t.pipelineManager,textureManager:t.textureManager,frameTextures:t.frameTextures});B0(t,y,c,u,a),t.frameBufferManager.releaseTemporaryAttachment(x),t.frameBufferManager.releaseTemporaryAttachment(y)}},A0=(t,e,r,n,s,o,i,l,c,u,a,h)=>{ne.x=0,ne.y=0;let d=S0(t,u.commandEncoder,u.frameBufferManager);if(d.texture){const B=u.frameBufferManager.createTemporaryAttachment(t.w,t.h),z=u.pipelineManager.getPipeline("texture_copy_rgba8"),k=u.pipelineManager.getBindGroupLayout("texture_copy");if(z&&k&&B.texture){const _=u.textureManager.createSampler("filter_flip_sampler",!1),I=u.bufferManager.acquireAndWriteUniformBuffer(y0);fe[0].resource.buffer=I,fe[1].resource=_,fe[2].resource=d.texture.view;const V=u.device.createBindGroup({layout:k,entries:fe}),X=u.frameBufferManager.createRenderPassDescriptor(B.texture.view,0,0,0,0,"clear"),Y=u.commandEncoder.beginRenderPass(X);Y.setPipeline(z),Y.setBindGroup(0,V),Y.draw(6,1,0,0),Y.end(),u.frameBufferManager.releaseTemporaryAttachment(d),d=B}}const g=le.getDevicePixelRatio(),m=Math.sqrt(s[0]*s[0]+s[1]*s[1]),f=Math.sqrt(s[2]*s[2]+s[3]*s[3]),b=Math.atan2(s[1],s[0]),x=Math.atan2(-s[2],s[3]),y=n?m*Math.cos(b):Math.cos(b),P=n?m*Math.sin(b):Math.sin(b),S=n?-f*Math.sin(x):-Math.sin(x),M=n?f*Math.cos(x):Math.cos(x);Te[0]=y,Te[1]=P,Te[2]=S,Te[3]=M,Te[4]=e/2,Te[5]=r/2,Ee[0]=1,Ee[1]=0,Ee[2]=0,Ee[3]=1,Ee[4]=-t.w/2,Ee[5]=-t.h/2;const $=Te[0]*Ee[0]+Te[2]*Ee[1],T=Te[1]*Ee[0]+Te[3]*Ee[1],w=Te[0]*Ee[2]+Te[2]*Ee[3],E=Te[1]*Ee[2]+Te[3]*Ee[3],F=Te[0]*Ee[4]+Te[2]*Ee[5]+Te[4],A=Te[1]*Ee[4]+Te[3]*Ee[5]+Te[5];let R=0,v=0;if($!==1||T!==0||w!==0||E!==1){const B=u.frameBufferManager.createTemporaryAttachment(e,r),k=u.pipelineManager.getPipeline("texture_scale"),_=u.pipelineManager.getBindGroupLayout("texture_scale");if(k&&_){Ze[0]=$,Ze[1]=T,Ze[2]=w,Ze[3]=E,Ze[4]=F,Ze[5]=A,Ze[6]=t.w,Ze[7]=t.h,Ze[8]=e,Ze[9]=r,Ze[10]=0,Ze[11]=0;const I=u.bufferManager.acquireAndWriteUniformBuffer(Ze,48),V=u.textureManager.createSampler("filter_scale_sampler",!0);fe[0].resource.buffer=I,fe[1].resource=V,fe[2].resource=d.texture.view;const X=u.device.createBindGroup({layout:_,entries:fe}),Y=u.frameBufferManager.createRenderPassDescriptor(B.texture.view,0,0,0,0,"clear"),W=u.commandEncoder.beginRenderPass(Y);W.setPipeline(k),W.setBindGroup(0,X),W.draw(6,1,0,0),W.end(),R=F,v=A,u.frameBufferManager.releaseTemporaryAttachment(d),d=B}}for(let B=0;c.length>B;)switch(c[B++]){case 0:{const k=c[B++],_=c[B++],I=c[B++],V=c[B++],X=c[B++],Y=c[B++],W=c[B++],K=c[B++],q=c[B++],ce=c[B++],te=c[B++],se=!!c[B++],ue=Bc(d,s,k,_,I,V,X,Y,W,K,q,ce,te,se,g,u);d!==ue&&u.frameBufferManager.releaseTemporaryAttachment(d),d=ue}break;case 1:{const k=c[B++],_=c[B++],I=c[B++],V=sr(d,s,k,_,I,g,u);d!==V&&u.frameBufferManager.releaseTemporaryAttachment(d),d=V}break;case 2:{ve[0]=c[B++],ve[1]=c[B++],ve[2]=c[B++],ve[3]=c[B++],ve[4]=c[B++],ve[5]=c[B++],ve[6]=c[B++],ve[7]=c[B++],ve[8]=c[B++],ve[9]=c[B++],ve[10]=c[B++],ve[11]=c[B++],ve[12]=c[B++],ve[13]=c[B++],ve[14]=c[B++],ve[15]=c[B++],ve[16]=c[B++],ve[17]=c[B++],ve[18]=c[B++],ve[19]=c[B++];const k=Mc(d,ve,u);d!==k&&u.frameBufferManager.releaseTemporaryAttachment(d),d=k}break;case 3:{const k=c[B++],_=c[B++],I=k*_,V=new Float32Array(I);for(let se=0;set?t[0]===1&&t[1]===1&&t[2]===1&&t[3]===1&&t[4]===0&&t[5]===0&&t[6]===0&&t[7]===0:!0,Cc=(t,e,r)=>{const n=t.frameBufferManager.createTemporaryAttachment(e.width,e.height),s=t.pipelineManager.getPipeline("color_transform"),o=t.pipelineManager.getBindGroupLayout("texture_copy");if(!s||!o||!e.texture||!n.texture)return e;ie[0]=r[0],ie[1]=r[1],ie[2]=r[2],ie[3]=r[3],ie[4]=r[4],ie[5]=r[5],ie[6]=r[6],ie[7]=0;const i=t.bufferManager.acquireAndWriteUniformBuffer(ie),l=t.textureManager.createSampler("container_ct_sampler",!1);Ie[0].resource.buffer=i,Ie[1].resource=l,Ie[2].resource=e.texture.view;const c=t.device.createBindGroup({layout:o,entries:Ie}),u=t.frameBufferManager.createRenderPassDescriptor(n.texture.view,0,0,0,0,"clear"),a=t.commandEncoder.beginRenderPass(u);return a.setPipeline(s),a.setBindGroup(0,c),a.draw(6,1,0,0),a.end(),n},Yo=(t,e,r,n,s,o)=>{const i=t.frameBufferManager.createTemporaryAttachment(s,o),l=t.pipelineManager.getPipeline("complex_blend_copy"),c=t.pipelineManager.getBindGroupLayout("texture_copy");if(!l||!c||!e.texture||!i.texture)return i;const u=s/e.width,a=r/e.width,h=-(o/e.height),d=(n+o)/e.height;xt[0]=u,xt[1]=h,xt[2]=a,xt[3]=d;const g=t.bufferManager.acquireAndWriteUniformBuffer(xt),m=t.textureManager.createSampler("container_copy_sampler",!1);Ie[0].resource.buffer=g,Ie[1].resource=m,Ie[2].resource=e.texture.view;const f=t.device.createBindGroup({layout:c,entries:Ie}),b=t.frameBufferManager.createRenderPassDescriptor(i.texture.view,0,0,0,0,"clear"),x=t.commandEncoder.beginRenderPass(b);return x.setPipeline(l),x.setBindGroup(0,f),x.draw(6,1,0,0),x.end(),i},Uc=(t,e,r,n,s,o,i)=>{if(!r.texture||!e.texture)return;let l=s,c=o,u=e.width,a=e.height,h=0,d=0;if(l<0&&(h=-l/e.width,u+=l,l=0),c<0&&(d=-c/e.height,a+=c,c=0),u<=0||a<=0)return;const g=r.width,m=r.height;if(l+u>g&&(u=g-l),c+a>m&&(a=m-c),F0.has(n)){const f=r.msaa&&r.msaaTexture?.view;let b;switch(n){case"add":b=f?"filter_output_add_msaa":"filter_output_add";break;case"screen":b=f?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":b=f?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":b=f?"filter_output_erase_msaa":"filter_output_erase";break;case"copy":b=f?"texture_copy_bgra_msaa":"texture_copy_bgra";break;default:b=f?"filter_output_msaa":"filter_output";break}const x=t.pipelineManager.getPipeline(b),y=t.pipelineManager.getBindGroupLayout("texture_copy");if(!x||!y)return;const P=t.textureManager.createSampler("container_output_sampler",!0),S=u/e.width,M=a/e.height;xt[0]=S,xt[1]=M,xt[2]=h,xt[3]=d;const $=i.acquireAndWriteUniformBuffer(xt);Ie[0].resource.buffer=$,Ie[1].resource=P,Ie[2].resource=e.texture.view;const T=t.device.createBindGroup({layout:y,entries:Ie}),w=f?r.msaaTexture.view:r.texture.view,E=f?r.texture.view:null,F=t.frameBufferManager.createRenderPassDescriptor(w,0,0,0,0,"load",E),A=Math.max(0,l),R=Math.max(0,c),v=Math.max(1,u),U=Math.max(1,a),L=Math.max(0,Math.floor(A)),D=Math.max(0,Math.floor(R)),G=Math.max(1,Math.min(Math.ceil(A+v)-L,g-L)),B=Math.max(1,Math.min(Math.ceil(R+U)-D,m-D));if(G<=0||B<=0||L>=g||D>=m)return;const z=t.commandEncoder.beginRenderPass(F);z.setPipeline(x),z.setBindGroup(0,T),z.setViewport(A,R,v,U,0,1),z.setScissorRect(L,D,G,B),z.draw(6,1,0,0),z.end()}else{const f=Yo(t,r,l,c,u,a);ie[0]=ir[0],ie[1]=ir[1],ie[2]=ir[2],ie[3]=ir[3],ie[4]=ir[4]/255,ie[5]=ir[5]/255,ie[6]=ir[6]/255,ie[7]=0;const b=Xo(e,f,n,ie,{device:t.device,commandEncoder:t.commandEncoder,bufferManager:t.bufferManager,frameBufferManager:t.frameBufferManager,pipelineManager:t.pipelineManager,textureManager:t.textureManager,frameTextures:t.frameTextures}),x=r.msaa&&r.msaaTexture?.view,y=x?"filter_complex_blend_output_msaa":"filter_complex_blend_output",P=t.pipelineManager.getPipeline(y),S=t.pipelineManager.getBindGroupLayout("positioned_texture");if(P&&S&&b.texture&&r.texture){ie[0]=l,ie[1]=c,ie[2]=b.width,ie[3]=b.height,ie[4]=r.width,ie[5]=r.height,ie[6]=0,ie[7]=0;const M=i.acquireAndWriteUniformBuffer(ie),$=t.textureManager.createSampler("container_blend_output_sampler",!1);Ie[0].resource.buffer=M,Ie[1].resource=$,Ie[2].resource=b.texture.view;const T=t.device.createBindGroup({layout:S,entries:Ie}),w=x?r.msaaTexture.view:r.texture.view,E=x?r.texture.view:null,F=t.frameBufferManager.createRenderPassDescriptor(w,0,0,0,0,"load",E),A=t.commandEncoder.beginRenderPass(F);A.setPipeline(P),A.setBindGroup(0,T),A.draw(6,1,0,0),A.end()}t.frameBufferManager.releaseTemporaryAttachment(f),t.frameBufferManager.releaseTemporaryAttachment(b)}},w0=(t,e,r,n,s)=>{ne.x=0,ne.y=0;for(let o=0;r.length>o;)switch(r[o++]){case 0:{const l=Bc(t,e,r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],r[o++],!!r[o++],n,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 1:{const l=sr(t,e,r[o++],r[o++],r[o++],n,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 2:{Me[0]=r[o++],Me[1]=r[o++],Me[2]=r[o++],Me[3]=r[o++],Me[4]=r[o++],Me[5]=r[o++],Me[6]=r[o++],Me[7]=r[o++],Me[8]=r[o++],Me[9]=r[o++],Me[10]=r[o++],Me[11]=r[o++],Me[12]=r[o++],Me[13]=r[o++],Me[14]=r[o++],Me[15]=r[o++],Me[16]=r[o++],Me[17]=r[o++],Me[18]=r[o++],Me[19]=r[o++];const l=Mc(t,Me,s);t!==l&&s.frameBufferManager.releaseTemporaryAttachment(t),t=l}break;case 3:{const l=r[o++],c=r[o++],u=l*c,a=new Float32Array(u);for(let d=0;d{if(i&&s&&l&&c){let f=Yo(g,t,0,0,t.width,t.height);g.frameBufferManager.releaseTemporaryAttachment(t);const b=le.getDevicePixelRatio();if(f=w0(f,s,c,b,g),u&&(ee.set(u,"fKey",a),ee.set(u,"fTexture",f)),f){let x=f,y=null;Rc(o)||(y=Cc(g,f,o),x=y);const P=Math.sqrt(s[0]*s[0]+s[1]*s[1]),S=Math.sqrt(s[2]*s[2]+s[3]*s[3]),M=l[0]*(P/b),$=l[1]*(S/b),T=M+s[4],w=$+s[5];Uc(g,x,e,n,T,w,m),y&&g.frameBufferManager.releaseTemporaryAttachment(y),u||g.frameBufferManager.releaseTemporaryAttachment(f)}}else{let f=Yo(g,t,0,0,t.width,t.height);if(g.frameBufferManager.releaseTemporaryAttachment(t),!Rc(o)){const b=Cc(g,f,o);g.frameBufferManager.releaseTemporaryAttachment(f),f=b}Uc(g,f,e,n,s[4],s[5],m),g.frameBufferManager.releaseTemporaryAttachment(f)}},$n=new Float32Array([1,1,0,0]),Wo=[],Gc=new Float32Array([0,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,0,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,1,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1,0,1,.5,.5,1,1,1,1,1,0,0,0,1,0,0,0,1]),Lc=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]),Et=new Float32Array(8),ke=new Float32Array(16);let jo=null,kc=null,ds=null;const Ic={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:"clear",storeOp:"store"},E0={colorAttachments:[Ic]},he=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Tn={r:0,g:0,b:0,a:0},Ho={view:null,clearValue:Tn,loadOp:"clear",storeOp:"store",resolveTarget:void 0},_c={view:null,stencilClearValue:0,stencilLoadOp:"clear",stencilStoreOp:"store"},Ko={colorAttachments:[Ho]},ar={view:null,resolveTarget:void 0,loadOp:"load",storeOp:"store"},Vr={view:null,stencilLoadOp:"load",stencilStoreOp:"store"},Rt={colorAttachments:[ar]};class R0{$stack;$matrix;$clearColorR;$clearColorG;$clearColorB;$clearColorA;$mainAttachmentObject;$stackAttachmentObject;globalAlpha;globalCompositeOperation;imageSmoothingEnabled;$fillStyle;$strokeStyle;maskBounds;thickness;caps;joints;miterLimit;device;canvasContext;preferredFormat;commandEncoder=null;renderPassEncoder=null;mainTexture=null;mainTextureView=null;frameStarted=!1;frameTextures=[];pooledTextures=[];pooledRenderTextures=[];currentRenderTarget=null;viewportWidth=0;viewportHeight=0;pathCommand;bufferManager;textureManager;frameBufferManager;pipelineManager;computePipelineManager;attachmentManager;newDrawState=!1;$containerLayerStack=[];containerLayerContentSizes=[];inMaskMode=!1;nodeAreaCleared=!1;currentNodeScissor=null;nodeRenderPassAtlasIndex=-1;fillDynamicBindGroup=null;fillDynamicBindGroupBuffer=null;nodeClearQuadBuffer=null;useOptimizedInstancing=!0;$uniformData8=new Float32Array(8);$scissorRect={x:0,y:0,w:0,h:0};$filterConfig;constructor(e,r,n,s=1){this.device=e,this.canvasContext=r,this.preferredFormat=n,le.setDevice(e),le.setDevicePixelRatio(s);const o=e.limits.maxTextureDimension2D,i=Math.max(2048,o/2);le.setRenderMaxSize(i),this.$stack=le.createArray(),this.$stackAttachmentObject=le.createArray(),this.$matrix=le.createFloat32Array(9),this.$matrix.set([1,0,0,0,1,0,0,0,1]),this.$clearColorR=0,this.$clearColorG=0,this.$clearColorB=0,this.$clearColorA=0,this.thickness=1,this.caps=0,this.joints=2,this.miterLimit=0,this.$mainAttachmentObject=null,this.globalAlpha=1,this.globalCompositeOperation="normal",this.imageSmoothingEnabled=!1,this.$fillStyle=new Float32Array([1,1,1,1]),this.$strokeStyle=new Float32Array([1,1,1,1]),this.maskBounds={xMin:0,yMin:0,xMax:0,yMax:0},r.configure({device:e,format:n,alphaMode:"premultiplied"}),this.viewportWidth=r.canvas.width,this.viewportHeight=r.canvas.height,this.pathCommand=new xd,this.bufferManager=new Od(e),this.textureManager=new Ud(e),this.frameBufferManager=new Hd(e,n),this.pipelineManager=new qp(e,n),this.pipelineManager.preloadLazyGroups(),this.computePipelineManager=new Qp(e),this.attachmentManager=new ip(e),em(l=>{const c=le.getRenderMaxSize();return this.frameBufferManager.createAttachment(\`atlas_\${l}\`,c,c,!1,!0)}),this.$filterConfig={device:this.device,commandEncoder:null,bufferManager:this.bufferManager,frameBufferManager:this.frameBufferManager,pipelineManager:this.pipelineManager,textureManager:this.textureManager,computePipelineManager:this.computePipelineManager,frameTextures:this.frameTextures},ud(this)}clearTransferBounds(){this.beginFrame()}updateBackgroundColor(e,r,n,s){this.$clearColorR=e,this.$clearColorG=r,this.$clearColorB=n,this.$clearColorA=s}fillBackgroundColor(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture)return;this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view;Ho.view=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,Ho.resolveTarget=e?this.$mainAttachmentObject.texture.view:void 0,Tn.r=this.$clearColorR,Tn.g=this.$clearColorG,Tn.b=this.$clearColorB,Tn.a=this.$clearColorA;const r=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil?.view;r?(_c.view=r,Ko.depthStencilAttachment=_c):Ko.depthStencilAttachment=void 0,this.renderPassEncoder=this.commandEncoder.beginRenderPass(Ko),this.renderPassEncoder.end(),this.renderPassEncoder=null}resize(e,r,n=!0){this.clearArraysInstanced();for(const o of this.frameTextures)o.destroy();this.frameTextures.length=0;for(const o of this.pooledTextures)Ot(o);this.pooledTextures.length=0;for(const o of this.pooledRenderTextures)Xt(o);this.pooledRenderTextures.length=0,Em(),this.frameStarted=!1,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,am();const s=this.canvasContext.canvas;if(s&&"width"in s&&"height"in s&&(s.width=e,s.height=r),this.$stackAttachmentObject.length){for(let o=0;o0?Wo.pop():new Float32Array(9);e.set(this.$matrix),this.$stack.push(e)}restore(){const e=this.$stack.pop();e&&(this.$matrix.set(e),Wo.push(e))}setTransform(e,r,n,s,o,i){this.$matrix[0]=e,this.$matrix[1]=r,this.$matrix[3]=n,this.$matrix[4]=s,this.$matrix[6]=o,this.$matrix[7]=i}transform(e,r,n,s,o,i){const l=this.$matrix,c=l[0],u=l[1],a=l[3],h=l[4],d=l[6],g=l[7];l[0]=e*c+r*a,l[1]=e*u+r*h,l[3]=n*c+s*a,l[4]=n*u+s*h,l[6]=o*c+i*a+d,l[7]=o*u+i*h+g}reset(){this.$matrix.set([1,0,0,0,1,0,0,0,1]),this.$stack.length=0,this.$stackAttachmentObject.length=0,this.globalAlpha=1,this.globalCompositeOperation="normal",this.imageSmoothingEnabled=!1}beginPath(){this.pathCommand.beginPath()}moveTo(e,r){this.pathCommand.moveTo(e,r)}lineTo(e,r){this.pathCommand.lineTo(e,r)}quadraticCurveTo(e,r,n,s){this.pathCommand.quadraticCurveTo(e,r,n,s)}fillStyle(e,r,n,s){this.$fillStyle[0]=e,this.$fillStyle[1]=r,this.$fillStyle[2]=n,this.$fillStyle[3]=s}strokeStyle(e,r,n,s){this.$strokeStyle[0]=e,this.$strokeStyle[1]=r,this.$strokeStyle[2]=n,this.$strokeStyle[3]=s}closePath(){this.pathCommand.closePath()}arc(e,r,n){this.pathCommand.arc(e,r,n)}bezierCurveTo(e,r,n,s,o,i){this.pathCommand.bezierCurveTo(e,r,n,s,o,i)}ensureFillRenderPass(){if(this.frameStarted||this.beginFrame(),this.ensureCommandEncoder(),this.renderPassEncoder){this.currentRenderTarget&&this.ensureNodeAreaCleared();return}{const e=this.getCurrentTextureView(),r=Ne(),n=r?.msaa&&r?.msaaTexture?.view,s=n?r.msaaTexture.view:e,o=n?e:null;if(this.currentRenderTarget&&r?.stencil?.view){const i=n&&r?.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,l=this.frameBufferManager.createStencilRenderPassDescriptor(s,i,"load","clear",o);this.renderPassEncoder=this.commandEncoder.beginRenderPass(l)}else if(!this.currentRenderTarget&&(gt()||nr())&&this.$mainAttachmentObject?.stencil?.view){const i=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,l=i?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,c=i&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,u=i?this.$mainAttachmentObject.texture.view:null,a=this.frameBufferManager.createStencilRenderPassDescriptor(l,c,"load","load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a),gt()&&this.renderPassEncoder.setStencilReference(Or())}else if(!this.currentRenderTarget&&this.$mainAttachmentObject){const i=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,l=i?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,c=i?this.$mainAttachmentObject.texture.view:null;if(this.$mainAttachmentObject.stencil?.view){const u=i&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,a=this.frameBufferManager.createStencilRenderPassDescriptor(l,u,"load","clear",c);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}else{const u=this.frameBufferManager.createRenderPassDescriptor(l,0,0,0,0,"load",c);this.renderPassEncoder=this.commandEncoder.beginRenderPass(u)}}else{const i=this.frameBufferManager.createRenderPassDescriptor(s,0,0,0,0,"load",o);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i)}}this.currentRenderTarget&&this.ensureNodeAreaCleared()}fill(){const e=this.pathCommand.$getVertices;if(e.length===0)return;this.ensureFillRenderPass();const r=this.viewportWidth,n=this.viewportHeight,s=dn(e);if(s.indexCount===0)return;const o=this.bufferManager.acquireVertexBuffer(s.buffer.byteLength,s.buffer),i=this.writeFillUniform(this.$fillStyle[0],this.$fillStyle[1],this.$fillStyle[2],this.$fillStyle[3],this.$matrix[0],this.$matrix[1],this.$matrix[3],this.$matrix[4],this.$matrix[6],this.$matrix[7],r,n),l=this.getOrCreateFillDynamicBindGroup(),c=Ne();if(this.currentRenderTarget&&c?.stencil?.view)this.fillWithStencil(o,s.indexCount,l,i);else if(!this.currentRenderTarget&&!this.inMaskMode&&!gt()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(o,s.indexCount,l,i);else{const u=(this.inMaskMode||gt())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(o,s.indexCount,u,l,i)}}getOrCreateFillDynamicBindGroup(){const e=this.bufferManager.dynamicUniform.getBuffer();if(!this.fillDynamicBindGroup||this.fillDynamicBindGroupBuffer!==e){const r=this.pipelineManager.getBindGroupLayout("fill_dynamic");if(!r)throw new Error("[WebGPU] fill_dynamic bind group layout not found");this.fillDynamicBindGroup=this.device.createBindGroup({layout:r,entries:[{binding:0,resource:{buffer:e,size:256}}]}),this.fillDynamicBindGroupBuffer=e}return this.fillDynamicBindGroup}writeFillUniform(e,r,n,s,o,i,l,c,u,a,h,d){return ke[0]=e,ke[1]=r,ke[2]=n,ke[3]=s,ke[4]=o/h,ke[5]=i/d,ke[6]=0,ke[7]=0,ke[8]=l/h,ke[9]=c/d,ke[10]=0,ke[11]=0,ke[12]=u/h,ke[13]=a/d,ke[14]=1,ke[15]=0,this.bufferManager.dynamicUniform.allocate(ke)}fillWithStencil(e,r,n,s){km(this.renderPassEncoder,this.pipelineManager,e,r,n,s)}fillWithStencilMain(e,r,n,s){Im(this.renderPassEncoder,this.pipelineManager,e,r,n,s)}fillSimple(e,r,n,s,o){const i=this.$mainAttachmentObject?.clipLevel??1;_m(this.renderPassEncoder,this.pipelineManager,e,r,s,o,!!this.currentRenderTarget,n,i)}bindAttachment(e){this.attachmentManager.bindAttachment(e);const r=e.color?.view??e.texture?.view;r&&(this.currentRenderTarget=r)}unbindAttachment(){this.attachmentManager.unbindAttachment(),this.currentRenderTarget=null}getAttachmentObject(e,r,n=!1){return this.attachmentManager.getAttachmentObject(e,r,n)}releaseAttachment(e){this.attachmentManager.releaseAttachment(e)}stroke(){const e=this.pathCommand.getVerticesForStroke();if(e.length===0)return;this.ensureFillRenderPass();const r=this.viewportWidth,n=this.viewportHeight,s=Am(e,this.thickness);if(s.length===0)return;const o=dn(s);if(o.indexCount===0)return;const i=this.bufferManager.acquireVertexBuffer(o.buffer.byteLength,o.buffer),l=this.writeFillUniform(this.$strokeStyle[0],this.$strokeStyle[1],this.$strokeStyle[2],this.$strokeStyle[3],this.$matrix[0],this.$matrix[1],this.$matrix[3],this.$matrix[4],this.$matrix[6],this.$matrix[7],r,n),c=this.getOrCreateFillDynamicBindGroup(),u=Ne();if(this.currentRenderTarget&&u?.stencil?.view)this.fillWithStencil(i,o.indexCount,c,l);else if(!this.currentRenderTarget&&!this.inMaskMode&&!gt()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(i,o.indexCount,c,l);else{const a=(this.inMaskMode||gt())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(i,o.indexCount,a,c,l)}this.pathCommand.reset()}gradientFill(e,r,n,s,o,i){const l=this.pathCommand.$getVertices;if(l.length===0)return;this.ensureFillRenderPass();const c=this.viewportWidth,u=this.viewportHeight,h=!!((this.inMaskMode||gt())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),d=!!this.currentRenderTarget,g=Dm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.$matrix,this.$fillStyle,e,r,n,s,o,i,c,u,d,h,this.$mainAttachmentObject?.clipLevel??1);g&&this.addFrameTexture(g),this.beginPath()}bitmapFill(e,r,n,s,o,i){const l=this.pathCommand.$getVertices;if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!((this.inMaskMode||gt())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),h=u||a,d=this.$mainAttachmentObject?.clipLevel??1,g=Nm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.$matrix,this.$fillStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,!!h,d);g&&this.addFrameTexture(g),this.beginPath()}gradientStroke(e,r,n,s,o,i){const l=this.pathCommand.getVerticesForStroke();if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),h=u||a,d=Ym(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.thickness,this.$matrix,this.$strokeStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,h);d&&this.addFrameTexture(d),this.pathCommand.reset()}bitmapStroke(e,r,n,s,o,i){const l=this.pathCommand.getVerticesForStroke();if(l.length===0)return;this.ensureFillRenderPass();const c=Ne(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),h=u||a,d=Hm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,l,this.thickness,this.$matrix,this.$strokeStyle,e,r,n,s,o,i,this.viewportWidth,this.viewportHeight,!!this.currentRenderTarget,h);d&&this.addFrameTexture(d),this.pathCommand.reset()}clip(){let e=this.frameBufferManager.getCurrentAttachment();const r=!e||e===this.$mainAttachmentObject;if(!e&&this.$mainAttachmentObject&&(e=this.$mainAttachmentObject),!e||!e.stencil)return;const n=this.pathCommand.$getVertices;if(n.length!==0){if(!this.renderPassEncoder)if(this.ensureCommandEncoder(),r&&this.$mainAttachmentObject?.stencil?.view){const s=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,o=s?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,i=s&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,l=this.frameBufferManager.createStencilRenderPassDescriptor(o,i,"load","load");this.renderPassEncoder=this.commandEncoder.beginRenderPass(l)}else return;Qm(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,e,n,this.$matrix,this.$fillStyle,this.globalAlpha,r)}}bind(e){this.frameBufferManager.setCurrentAttachment(e),this.viewportWidth=e.width,this.viewportHeight=e.height}get currentAttachmentObject(){return this.frameBufferManager.getCurrentAttachment()||this.$mainAttachmentObject}get atlasAttachmentObject(){return Ne()}useGrid(e){Ja.set(ec,e)}beginNodeRendering(e){this.nodeAreaCleared=!1,this.frameStarted||this.beginFrame();const r=bo(e.index)||Ne();if(r&&r.texture){if(this.renderPassEncoder&&this.nodeRenderPassAtlasIndex===e.index)this.currentRenderTarget=r.texture.view,this.viewportWidth=r.width,this.viewportHeight=r.height;else{this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.currentRenderTarget=r.texture.view,this.viewportWidth=r.width,this.viewportHeight=r.height,this.ensureCommandEncoder();const l=r.msaa&&r.msaaTexture?.view,c=l?r.msaaTexture.view:r.texture.view,u=l?r.texture.view:null;if(r.stencil?.view){const a=l&&r.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,h=this.frameBufferManager.createStencilRenderPassDescriptor(c,a,"load","load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(h)}else{const a=this.frameBufferManager.createRenderPassDescriptor(c,0,0,0,0,"load",u);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}this.nodeRenderPassAtlasIndex=e.index}let n=Math.max(0,e.x),s=Math.max(0,e.y),o=Math.min(e.w,r.width-n),i=Math.min(e.h,r.height-s);if(n=Math.min(n,r.width),s=Math.min(s,r.height),o=Math.max(0,Math.min(o,r.width-n)),i=Math.max(0,Math.min(i,r.height-s)),this.$scissorRect.x=n,this.$scissorRect.y=s,this.$scissorRect.w=o,this.$scissorRect.h=i,this.currentNodeScissor=this.$scissorRect,o>0&&i>0){const l=Math.min(o+1,r.width-n),c=Math.min(i+1,r.height-s);this.renderPassEncoder.setScissorRect(n,s,l,c)}}}ensureNodeAreaCleared(){this.nodeAreaCleared||(this.nodeAreaCleared=!0,this.clearNodeArea())}clearNodeArea(){if(!this.renderPassEncoder)return;const e=this.pipelineManager.getPipeline("node_clear_atlas");if(!e)return;if(!this.nodeClearQuadBuffer){const n=this.device.createBuffer({size:Lc.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0});new Float32Array(n.getMappedRange()).set(Lc),n.unmap(),this.nodeClearQuadBuffer=n}const r=this.nodeClearQuadBuffer;this.renderPassEncoder.setPipeline(e),this.renderPassEncoder.setVertexBuffer(0,r),this.renderPassEncoder.draw(6),this.currentNodeScissor&&this.renderPassEncoder.setScissorRect(this.currentNodeScissor.x,this.currentNodeScissor.y,this.currentNodeScissor.w,this.currentNodeScissor.h)}endNodeRendering(){this.currentRenderTarget=null,this.currentNodeScissor=null,this.viewportWidth=this.canvasContext.canvas.width,this.viewportHeight=this.canvasContext.canvas.height}drawFill(){Fm()}drawDisplayObject(e,r,n,s,o,i){const l=le.getRenderMaxSize();im(e,r,n,s,o,i,this.$matrix,this.globalCompositeOperation,this.viewportWidth,this.viewportHeight,l,this.globalAlpha)}drawArraysInstanced(){this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$mainAttachmentObject&&(this.useOptimizedInstancing?this.renderPassEncoder=Jm(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager,!0,!0):this.renderPassEncoder=Zm(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager),this.processComplexBlendQueue())}setOptimizedInstancing(e){this.useOptimizedInstancing=e}isOptimizedInstancingEnabled(){return this.useOptimizedInstancing}processComplexBlendQueue(){this.ensureCommandEncoder(),r0(this.device,this.commandEncoder,this.$mainAttachmentObject,this.frameBufferManager,this.textureManager,this.pipelineManager,this.bufferManager)}clearArraysInstanced(){rs().clear()}drawPixels(e,r){const n=bo(e.index)||Ne();if(!n||!n.texture)return;const s=e.w,o=e.h;if(this.renderPassEncoder&&(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,n.msaa&&n.msaaTexture?.view)this.drawPixelsToMsaa(n,e,r,s,o);else{const i=s*4;this.device.queue.writeTexture({texture:n.texture.resource,origin:{x:e.x,y:e.y,z:0}},r,{bytesPerRow:i,rowsPerImage:o,offset:0},{width:s,height:o,depthOrArrayLayers:1})}}drawPixelsToMsaa(e,r,n,s,o){const i=Ro(this.device,s,o),l=s*4;this.device.queue.writeTexture({texture:i},n,{bytesPerRow:l,rowsPerImage:o},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render_msaa");if(!c){Xt(i);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(i);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(i);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.msaaTexture.view,ar.resolveTarget=e.texture.view;const f=e.msaaStencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(i)}drawElement(e,r,n=!1){const s=bo(e.index)||Ne();if(!s||!s.texture)return;const o=e.w,i=e.h;this.renderPassEncoder&&(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,s.msaa&&s.msaaTexture?.view?this.drawElementToMsaa(s,e,r,o,i,n):this.drawElementToTexture(s,e,r,o,i,n)}drawElementToMsaa(e,r,n,s,o,i){const l=Ro(this.device,s,o);this.device.queue.copyExternalImageToTexture({source:n,flipY:i},{texture:l,premultipliedAlpha:!0},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render_msaa");if(!c){Xt(l);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(l);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.msaaTexture.view,ar.resolveTarget=e.texture.view;const f=e.msaaStencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(l)}drawElementToTexture(e,r,n,s,o,i){const l=Ro(this.device,s,o);this.device.queue.copyExternalImageToTexture({source:n,flipY:i},{texture:l,premultipliedAlpha:!0},{width:s,height:o});const c=this.pipelineManager.getPipeline("bitmap_render");if(!c){Xt(l);return}const u=this.pipelineManager.getBindGroupLayout("positioned_texture");if(!u){Xt(l);return}const a=this.$uniformData8;a[0]=r.x,a[1]=r.y,a[2]=s,a[3]=o,a[4]=e.width,a[5]=e.height,a[6]=0,a[7]=0;const h=this.bufferManager.acquireAndWriteUniformBuffer(a),d=this.textureManager.createSampler("linear_sampler",!0),g=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=g;const m=this.device.createBindGroup({layout:u,entries:he});this.ensureCommandEncoder(),ar.view=e.texture.view,ar.resolveTarget=void 0;const f=e.stencil?.view;f?(Vr.view=f,Rt.depthStencilAttachment=Vr):Rt.depthStencilAttachment=void 0;const b=this.commandEncoder.beginRenderPass(Rt);b.setViewport(0,0,e.width,e.height,0,1),b.setScissorRect(r.x,r.y,s,o),b.setPipeline(c),b.setBindGroup(0,m),b.draw(6),b.end(),this.pooledRenderTextures.push(l)}applyFilter(e,r,n,s,o,i,l,c,u,a,h){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=this.$mainAttachmentObject,A0(e,s,o,i,l,c,u,a,h,this.$filterConfig,this.mainTextureView,this.bufferManager)}containerBeginLayer(e,r){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null);const n=this.$mainAttachmentObject;this.$containerLayerStack.push(n),this.containerLayerContentSizes.push({width:e,height:r});const s=this.frameBufferManager.createAttachment("container_layer",e,r,n.msaa,!0);this.$mainAttachmentObject=s,this.bind(s)}containerEndLayer(e,r,n,s,o,i,l,c){this.drawArraysInstanced(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const u=this.$mainAttachmentObject,a=this.containerLayerContentSizes.pop()||{width:u.width,height:u.height};this.$mainAttachmentObject=this.$containerLayerStack.pop(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=void 0,O0(u,this.$mainAttachmentObject,"container_layer",e,r,n,s,o,i,l,c,a.width,a.height,this.$filterConfig,this.bufferManager),this.bind(this.$mainAttachmentObject)}containerDrawCachedFilter(e,r,n,s,o,i){if(ee.get(o,"fKey")!==i)return;const c=ee.get(o,"fTexture");if(!c||!c.texture)return;this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();const u=this.$mainAttachmentObject;if(!u||!u.texture)return;let a=c,h=null;if(!(n[0]===1&&n[1]===1&&n[2]===1&&n[3]===1&&n[4]===0&&n[5]===0&&n[6]===0&&n[7]===0)){h=this.frameBufferManager.createTemporaryAttachment(c.width,c.height);const V=this.pipelineManager.getPipeline("color_transform"),X=this.pipelineManager.getBindGroupLayout("texture_copy");if(V&&X&&h.texture){Et[0]=n[0],Et[1]=n[1],Et[2]=n[2],Et[3]=n[3],Et[4]=n[4],Et[5]=n[5],Et[6]=n[6],Et[7]=0;const Y=Et,W=this.bufferManager.acquireAndWriteUniformBuffer(Y),K=this.textureManager.createSampler("cached_ct_sampler",!1);he[0].resource.buffer=W,he[1].resource=K,he[2].resource=c.texture.view;const q=this.device.createBindGroup({layout:X,entries:he}),ce=this.frameBufferManager.createRenderPassDescriptor(h.texture.view,0,0,0,0,"clear"),te=this.commandEncoder.beginRenderPass(ce);te.setPipeline(V),te.setBindGroup(0,q),te.draw(6,1,0,0),te.end(),a=h}}const g=le.getDevicePixelRatio(),m=Math.sqrt(r[0]*r[0]+r[1]*r[1]),f=Math.sqrt(r[2]*r[2]+r[3]*r[3]),b=s[0]*(m/g),x=s[1]*(f/g),y=Math.floor(b+r[4]),P=Math.floor(x+r[5]),S=u.msaa&&u.msaaTexture?.view;let M;switch(e){case"add":M=S?"filter_output_add_msaa":"filter_output_add";break;case"screen":M=S?"filter_output_screen_msaa":"filter_output_screen";break;case"alpha":M=S?"filter_output_alpha_msaa":"filter_output_alpha";break;case"erase":M=S?"filter_output_erase_msaa":"filter_output_erase";break;default:M=S?"filter_output_msaa":"filter_output";break}const $=this.pipelineManager.getPipeline(M),T=this.pipelineManager.getBindGroupLayout("texture_copy");if(!$||!T)return;const w=this.textureManager.createSampler("cached_filter_sampler",!0),E=this.bufferManager.acquireAndWriteUniformBuffer($n);he[0].resource.buffer=E,he[1].resource=w,he[2].resource=a.texture.view;const F=this.device.createBindGroup({layout:T,entries:he}),A=S?u.msaaTexture.view:u.texture.view,R=S?u.texture.view:null,v=this.frameBufferManager.createRenderPassDescriptor(A,0,0,0,0,"load",R),U=Math.max(0,y),L=Math.max(0,P),D=Math.max(1,a.width),G=Math.max(1,a.height),B=u.width,z=u.height,k=Math.max(1,Math.min(D,B-U)),_=Math.max(1,Math.min(G,z-L));if(k<=0||_<=0||U>=B||L>=z){h&&this.frameBufferManager.releaseTemporaryAttachment(h);return}const I=this.commandEncoder.beginRenderPass(v);I.setPipeline($),I.setBindGroup(0,F),I.setViewport(U,L,D,G,0,1),I.setScissorRect(U,L,k,_),I.draw(6,1,0,0),I.end(),h&&this.frameBufferManager.releaseTemporaryAttachment(h),this.bind(u)}ensureMainTexture(){this.mainTexture||(this.mainTexture=this.canvasContext.getCurrentTexture(),this.mainTextureView=this.mainTexture.createView())}getCurrentTextureView(){return this.currentRenderTarget?this.currentRenderTarget:(this.ensureMainTexture(),this.mainTextureView)}ensureCommandEncoder(){this.commandEncoder||(this.commandEncoder=this.device.createCommandEncoder())}beginFrame(){this.frameStarted||(this.ensureMainTexture(),this.ensureCommandEncoder(),this.frameStarted=!0,this.frameBufferManager.beginFrame())}addFrameTexture(e){this.pooledTextures.push(e)}endFrame(){if(this.frameStarted){if(this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.bufferManager.dynamicUniform.flush(),this.commandEncoder)try{const e=this.commandEncoder.finish();this.device.queue.submit([e])}catch(e){console.error("Failed to submit frame commands:",e)}this.frameBufferManager.flushPendingReleases(),this.bufferManager.clearFrameBuffers();for(const e of this.frameTextures)e.destroy();this.frameTextures.length=0;for(const e of this.pooledTextures)Ot(e);this.pooledTextures.length=0;for(const e of this.pooledRenderTextures)Xt(e);this.pooledRenderTextures.length=0,Um(),this.fillDynamicBindGroup=null,this.fillDynamicBindGroupBuffer=null,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,this.nodeRenderPassAtlasIndex=-1,this.mainTexture=null,this.mainTextureView=null,this.frameStarted=!1}}submit(){this.endFrame()}createNode(e,r){const n=Zp();if(!fn[n]){const i=le.getRenderMaxSize();fn[n]=new Ni(n,i,i)}const o=fn[n].insert(e,r);return o||(wr(n+1),this.createNode(e,r))}removeNode(e){const r=e.index,n=fn[r];n&&n.dispose(e.x,e.y,e.w,e.h)}transferMainCanvas(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture){this.endFrame();return}this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder(),this.ensureMainTexture();const e=this.pipelineManager.getPipeline("texture_copy_bgra"),r=this.pipelineManager.getBindGroupLayout("texture_copy");if(!e||!r){console.error("[WebGPU] texture_copy_bgra pipeline not found"),this.endFrame();return}const n=this.$mainAttachmentObject.texture.view;if(!jo||kc!==n){ds||(ds=this.device.createBuffer({size:$n.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.device.queue.writeBuffer(ds,0,$n.buffer,$n.byteOffset,$n.byteLength));const i=this.textureManager.createSampler("transfer_sampler",!1);he[0].resource={buffer:ds},he[1].resource=i,he[2].resource=n,jo=this.device.createBindGroup({layout:r,entries:he}),kc=n}const s=jo;Ic.view=this.mainTextureView;const o=this.commandEncoder.beginRenderPass(E0);o.setPipeline(e),o.setBindGroup(0,s),o.draw(6,1,0,0),o.end(),this.endFrame()}async createImageBitmap(e,r){const n=Ne();if(!n)throw new Error("[WebGPU] Atlas attachment not found");this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null);const o=Math.ceil(e*4/256)*256,i=o*r,l=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),c=this.device.createCommandEncoder();if(!n.texture)throw new Error("Attachment texture is null");c.copyTextureToBuffer({texture:n.texture.resource,mipLevel:0,origin:{x:0,y:0,z:0}},{buffer:l,bytesPerRow:o,rowsPerImage:r},{width:e,height:r,depthOrArrayLayers:1}),this.device.queue.submit([c.finish()]),await l.mapAsync(GPUMapMode.READ);const u=l.getMappedRange(),a=new Uint8Array(u),h=new Uint8Array(e*r*4);for(let m=0;m1&&i){const u=\`clip_clear_main_\${Math.min(8,Math.max(1,r))}\`,a=this.pipelineManager.getPipeline(u);if(a){const h=this.frameBufferManager.createStencilRenderPassDescriptor(o,i,"load","load"),d=this.commandEncoder.beginRenderPass(h),g=this.bufferManager.acquireVertexBuffer(Gc.byteLength,Gc);d.setPipeline(a),d.setStencilReference(0),d.setVertexBuffer(0,g),d.draw(6,1,0,0),d.end()}}}}const C0=4;let C;const Vc=t=>{C=t};let qo;const U0=t=>{qo=t};let Qo=0;const G0=()=>Qo;let Zo=0;const L0=()=>Zo;let Jo=!1;const k0=(t,e)=>{Jo=!0,Qo=t,Zo=e},I0=()=>Jo,_0=()=>{qo.width=Qo,qo.height=Zo,Jo=!1},V0=[],Dc=(...t)=>{const e=V0.pop()||[];return t.length&&e.push(...t),e},Dr=(t,e=1)=>({R:(t&16711680)>>16,G:(t&65280)>>8,B:t&255,A:e*255}),D0=async(t,e)=>{if(U0(t),"gpu"in navigator){const r=navigator.gpu,n=await r.requestAdapter();if(!n)throw new Error("WebGPU adapter not available");const s=await n.requestDevice();if(!s)throw new Error("WebGPU device not available");const o=t.getContext("webgpu");if(!o)throw new Error("WebGPU context not available");const i=r.getPreferredCanvasFormat();Vc(new R0(s,o,i,e))}else{const r=t.getContext("webgl2",{stencil:!0,premultipliedAlpha:!0,antialias:!1,depth:!1});if(!r)throw new Error("webgl2 is not supported.");Vc(new ld(r,C0,e))}},N0=(t,e,r=!0)=>{G0()===t&&L0()===e||(k0(t,e),C.resize(t,e,r),r&&ee.reset())},z0=0,X0=1,Y0=2,W0=3,j0=4,H0=5,K0=6,q0=7,Q0=8,Z0=9,J0=10,eg=11,tg=12,rg=13,ng=14,ei=(t,e=!1)=>{let r=0;for(;t.length>r;)switch(t[r++]){case Z0:C.beginPath();break;case z0:C.moveTo(t[r++],t[r++]);break;case Y0:C.lineTo(t[r++],t[r++]);break;case X0:C.quadraticCurveTo(t[r++],t[r++],t[r++],t[r++]);break;case H0:if(e){r+=4;break}C.fillStyle(t[r++]/255,t[r++]/255,t[r++]/255,t[r++]/255);break;case q0:C.fill();break;case K0:if(e){r+=8;break}C.thickness=t[r++],C.caps=t[r++],C.joints=t[r++],C.miterLimit=t[r++],C.strokeStyle(t[r++]/255,t[r++]/255,t[r++]/255,t[r++]/255);break;case Q0:if(e)break;C.stroke();break;case tg:C.closePath();break;case j0:C.arc(t[r++],t[r++],t[r++]);break;case W0:C.bezierCurveTo(t[r++],t[r++],t[r++],t[r++],t[r++],t[r++]);break;case J0:{if(e){r+=1;const a=t[r++];r+=a*5,r+=9,C.fill();break}const n=t[r++],s=Dc(),o=t[r++];for(let a=0;a{switch(t){case 0:return"copy";case 1:return"add";case 2:return"alpha";case 3:return"darken";case 4:return"difference";case 5:return"erase";case 6:return"hardlight";case 7:return"invert";case 8:return"layer";case 9:return"lighten";case 10:return"multiply";case 11:return"normal";case 12:return"overlay";case 13:return"screen";case 14:return"subtract";default:return"normal"}},ti=(t,e)=>{const r=t.subarray(e,e+6);e+=6;const n=t.subarray(e,e+8);e+=8;const s=t.subarray(e,e+4);e+=4;const o=t[e++],i=t[e++],l=t[e++],c=t[e++],u=!!t[e++],a=!!t[e++],h=!!t[e++],d=\`\${t[e++]}\`,g=t[e++],m=t[e++],f=t[e++],b=\`\${t[e++]}\`;let x;if(t[e++]){if(x=ee.get(d,\`\${g}\`),!x)return e}else{const M=u?new Float32Array(28):null;M&&(M.set(t.subarray(e,e+24)),e+=24),C.useGrid(M);const $=t[e++],T=t.subarray(e,e+$);if(h&&!u){const w=Math.ceil(Math.abs(l-o)),E=Math.ceil(Math.abs(c-i));x=C.createNode(w,E),ee.set(d,\`\${g}\`,x);const F=C.currentAttachmentObject,A=C.atlasAttachmentObject;A&&C.bind(A),C.reset(),C.beginNodeRendering(x);const R=A?A.height-x.y-E:0;C.setTransform(1,0,0,1,x.x,R),a?(ei(T),C.drawFill()):C.drawPixels(x,new Uint8Array(T)),C.endNodeRendering(),F&&C.bind(F)}else{const w=Math.ceil(Math.abs(l-o)*m),E=Math.ceil(Math.abs(c-i)*f);x=C.createNode(w,E),ee.set(d,\`\${g}\`,x);const F=C.currentAttachmentObject,A=C.atlasAttachmentObject;A&&C.bind(A),C.reset(),C.beginNodeRendering(x);const R=A?A.height-x.y-E:0;C.setTransform(m,0,0,f,-o*m+x.x,-i*f+R),M&&(M[24]=x.x,M[25]=R),ei(T),C.drawFill(),C.endNodeRendering(),F&&C.bind(F)}e+=$}const P=t[e++];if(!!t[e++]){const M=!!t[e++],$=t.subarray(e,e+4);e+=4;const T=t[e++],w=t.subarray(e,e+T),E=Math.ceil(Math.abs(s[2]-s[0])),F=Math.ceil(Math.abs(s[3]-s[1]));return C.applyFilter(x,b,M,E,F,h,r,n,cr(P),$,w),e+=T,e}if(C.globalAlpha=Math.min(Math.max(0,n[3]+n[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(P),h&&!u)C.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),C.drawDisplayObject(x,s[0],s[1],s[2],s[3],n);else{const M=Math.atan2(r[1],r[0]),$=Math.atan2(-r[2],r[3]);if(M||$){const T=o*m,w=i*f,E=Math.cos(M),F=Math.sin(M),A=Math.cos($),R=Math.sin($);C.setTransform(E,F,-R,A,T*E-w*R+r[4],T*F+w*A+r[5])}else C.setTransform(1,0,0,1,s[0],s[1]);C.drawDisplayObject(x,s[0],s[1],s[2],s[3],n)}return e},ri=(t,e)=>{const r=t.subarray(e,e+6);e+=6,C.reset(),C.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]);const s=!!t[e++]?new Float32Array(28):null;C.useGrid(s),s&&(s.set(t.subarray(e,e+24)),e+=24);const o=t[e++],i=t.subarray(e,e+o);return ei(i,!0),e+=o,C.clip(),e},Nc=(t,e,r)=>{const n=t.widthTable[e.line]||0,s=e.textFormat,o=s.leftMargin||0;if(!r.wordWrap&&n>r.rawWidth)return Math.max(0,o);const i=s.rightMargin||0;return s.align==="center"||r.autoSize==="center"?Math.max(0,r.rawWidth/2-o-i-n/2-2):s.align==="right"||r.autoSize==="right"?Math.max(0,r.rawWidth-o-n-i-4):Math.max(0,o)},sg=t=>{let e="";return t.italic&&(e+="italic "),t.bold&&(e+="bold "),\`\${e}\${t.size}px '\${t.font}','sans-serif'\`},og=(t,e,r,n)=>{const s=new OffscreenCanvas(e.width,e.height),o=s.getContext("2d");if(!o)return s;const i=Math.min(1,Math.max(r,n));if(e.background||e.border){if(o.beginPath(),o.moveTo(0,0),o.lineTo(e.width,0),o.lineTo(e.width,e.height),o.lineTo(0,e.height),o.lineTo(0,0),e.background){const M=Dr(e.backgroundColor);o.fillStyle=\`rgba(\${M.R},\${M.G},\${M.B},\${M.A})\`,o.fill()}if(e.border){const M=Dr(e.borderColor);o.lineWidth=i,o.strokeStyle=\`rgba(\${M.R},\${M.G},\${M.B},\${M.A})\`,o.stroke()}}if(!t)return s;o.save(),o.beginPath(),o.moveTo(2,2),o.lineTo(e.width-2,2),o.lineTo(e.width-2,e.height-2),o.lineTo(2,e.height-2),o.lineTo(2,2),o.clip();let l=2;if(e.scrollX>0){const M=(e.textWidth+4-e.rawWidth)/e.rawWidth;l+=-e.scrollX*M}let c=2;if(e.scrollY>0){const M=(e.textHeight+2-e.rawHeight)/e.rawHeight;c+=-e.scrollY*M}if(o.setTransform(r,0,0,n,l*r,c*n),o.beginPath(),e.selectIndex>-1&&e.focusIndex>-1){const M=t.textTable.length-1;let $=0,T=0;e.focusIndex<=e.selectIndex?($=Math.min(e.focusIndex,M),T=Math.min(e.selectIndex,M)):($=Math.min(e.selectIndex,M),T=Math.min(e.focusIndex-1,M));const w=t.textTable[$],E=t.lineTable[w.line],F=Nc(t,E,e);let A=0;if($&&w.mode==="text"){let v=$;for(;v;){const U=t.textTable[--v];if(U.mode!=="text")break;A+=U.w}}o.fillStyle="#b4d7ff";let R=0;for(let v=$;v<=T;++v){const U=t.textTable[v];if(U.mode==="text"&&(R+=U.w,v!==T))continue;let L=0;const D=U.mode==="text"?U.line:U.line-1;for(let G=0;G0){const M=(e.textWidth-u)/u;a=e.scrollX*M}const h=u+a,d=e.rawHeight;let g=0;if(e.scrollY>0){const M=(e.textHeight-d)/d;g=e.scrollY*M}const m=d+g;let f=0,b=0,x=0,y=0,P=!1,S=-1;for(let M=0;M-1&&S>e.stopIndex))break;if(P&&$.mode==="text")continue;const T=$.textFormat;if(e.autoSize==="none"){if(b>m)break;if($.mode==="text"&&(a>f+$.w||f>h)){f+=$.w;continue}}const w=Dr(T.color||0);if(o.fillStyle=\`rgba(\${w.R},\${w.G},\${w.B},\${w.A})\`,e.focusVisible&&e.focusIndex===M){const F=f+x+.1;let A=$.line,R=$.y,v=t.ascentTable[A];$.mode!=="text"&&(R=$.mode==="break"?$.h:t.ascentTable[A-1],A>0?(A=$.line-1,v=t.ascentTable[A]):v=$.h),A>0&&t.ascentTable[A]===0&&A++;for(let U=0;Ub+t.heightTable[E]){P=!0;continue}y=t.ascentTable[E],x=Nc(t,$,e),P=!1;break;case"text":{o.beginPath(),o.font=sg(T);const F=f+x,A=b+y;if(T.underline){const R=Dr(T.color||0);o.lineWidth=i,o.strokeStyle=\`rgba(\${R.R},\${R.G},\${R.B},\${R.A})\`,o.beginPath(),o.moveTo(F,A+2),o.lineTo(F+$.w,A+2),o.stroke()}e.thickness&&o.strokeText($.text,F,A),o.fillText($.text,F,A),f+=$.w}break}}if(e.focusVisible&&e.focusIndex>=t.textTable.length){const M=t.textTable[e.focusIndex-1];if(M){const $=Dr(M.textFormat.color||0);o.strokeStyle=\`rgba(\${$.R},\${$.G},\${$.B},\${$.A})\`;const T=f+x+.1,w=b+y;o.beginPath(),M.mode==="text"?o.moveTo(T,w-M.y):o.moveTo(T,w+M.h),o.lineTo(T,w),o.stroke()}}return o.restore(),s},ig=new TextDecoder,ni=(t,e)=>{const r=t.subarray(e,e+6);e+=6;const n=t.subarray(e,e+8);e+=8;const s=t.subarray(e,e+4);e+=4;const o=t[e++],i=t[e++],l=t[e++],c=t[e++],u=\`\${t[e++]}\`,a=t[e++],h=!!t[e++],d=t[e++],g=t[e++],m=\`\${t[e++]}\`;let f;if(t[e++]){if(f=ee.get(u,\`\${a}\`),!f)return e}else{const M=Math.ceil(Math.abs(l-o)*d),$=Math.ceil(Math.abs(c-i)*g),T=!!t[e++];f=T?ee.get(u,\`\${a}\`):C.createNode(M,$),T||ee.set(u,\`\${a}\`,f);const w=t[e++],E=new Uint8Array(t.subarray(e,e+w));e+=w;let F="none";switch(t[e++]){case 0:F="center";break;case 1:F="left";break;case 2:F="none";break;case 3:F="right";break}const A={width:M,height:$,autoSize:F,stopIndex:t[e++],scrollX:t[e++],scrollY:t[e++],textWidth:t[e++],textHeight:t[e++],rawWidth:t[e++],rawHeight:t[e++],focusIndex:t[e++],selectIndex:t[e++],focusVisible:!!t[e++],thickness:t[e++],thicknessColor:t[e++],wordWrap:!!t[e++],border:!!t[e++],borderColor:t[e++],background:!!t[e++],backgroundColor:t[e++],defaultColor:t[e++],defaultSize:t[e++]},R=og(JSON.parse(ig.decode(E)),A,d,g),v=C.currentAttachmentObject,U=C.atlasAttachmentObject;U&&C.bind(U),C.reset(),C.beginNodeRendering(f);const L=U?U.height-f.y-$:0;C.setTransform(1,0,0,1,f.x,L),C.drawElement(f,R),C.endNodeRendering(),v&&C.bind(v)}const x=t[e++];if(!!t[e++]){const M=!!t[e++],$=t.subarray(e,e+4);e+=4;const T=t[e++],w=t.subarray(e,e+T),E=Math.ceil(Math.abs(s[2]-s[0])),F=Math.ceil(Math.abs(s[3]-s[1]));return C.applyFilter(f,m,!!Math.max(+h,+M),E,F,!1,r,n,cr(x),$,w),e+=T,e}C.globalAlpha=Math.min(Math.max(0,n[3]+n[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(x);const P=Math.atan2(r[1],r[0]),S=Math.atan2(-r[2],r[3]);if(P||S){const M=o*d,$=i*g,T=Math.cos(P),w=Math.sin(P),E=Math.cos(S),F=Math.sin(S);C.setTransform(T,w,-F,E,M*T-$*F+r[4],M*w+$*E+r[5])}else C.setTransform(1,0,0,1,s[0],s[1]);return C.drawDisplayObject(f,s[0],s[1],s[2],s[3],n),e},si=(t,e,r)=>{const n=t.subarray(e,e+6);e+=6;const s=t.subarray(e,e+8);e+=8;const o=t.subarray(e,e+4);e+=4;const i=t[e++],l=t[e++],c=t[e++],u=t[e++],a=\`\${t[e++]}\`,h="0",d=!!t[e++],g=\`\${t[e++]}\`;let m;if(t[e++]){if(m=ee.get(a,\`\${h}\`),!m)return e}else{const y=Math.abs(c-i),P=Math.abs(u-l),S=!!t[e++];if(m=S?ee.get(a,\`\${h}\`):C.createNode(y,P),S||ee.set(a,\`\${h}\`,m),r&&r.length){const M=C.currentAttachmentObject,$=C.atlasAttachmentObject;$&&C.bind($),C.reset(),C.beginNodeRendering(m);const T=$?$.height-m.y-P:0;C.setTransform(1,0,0,1,m.x,T);const w=r.shift();C.drawElement(m,w,!0),C.endNodeRendering(),M&&C.bind(M)}}const b=t[e++];if(!!t[e++]){const y=!!t[e++],P=t.subarray(e,e+4);e+=4;const S=t[e++],M=t.subarray(e,e+S),$=Math.ceil(Math.abs(o[2]-o[0])),T=Math.ceil(Math.abs(o[3]-o[1]));return C.applyFilter(m,g,!!Math.max(+d,+y),$,T,!0,n,s,cr(b),P,M),e+=S,e}return C.globalAlpha=Math.min(Math.max(0,s[3]+s[7]/255),1),C.imageSmoothingEnabled=!0,C.globalCompositeOperation=cr(b),C.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]),C.drawDisplayObject(m,o[0],o[1],o[2],o[3],s),e},oi=(t,e)=>{const r=t[e++];for(let n=0;n{let n=0,s=!0;const o=cr(t[e++]),i=!!t[e++];let l=0,c=0,u=!1,a="",h="",d=null,g=null,m=null,f=null;if(i)if(l=t[e++],c=t[e++],u=!!t[e++],u){const y=!!t[e++];if(a=\`\${t[e++]}\`,h=\`\${t[e++]}\`,y)return d=t.subarray(e,e+4),e+=4,m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8,C.containerDrawCachedFilter(o,m,f,d,a,h),e;d=t.subarray(e,e+4),e+=4,m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8;const P=t[e++];g=t.subarray(e,e+P),e+=P}else m=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8;i&&C.containerBeginLayer(l,c);const b=!!t[e++];if(b){switch(C.drawArraysInstanced(),C.save(),C.beginMask(),C.setMaskBounds(t[e++],t[e++],t[e++],t[e++]),t[e++]){case 0:e=oi(t,e);break;case 1:e=ri(t,e);break}C.endMask()}const x=t[e++];for(let y=0;x>y;y++){const P=t[e++],S=t[e++];if(n&&P>n&&(s&&(C.restore(),C.leaveMask()),n=0,s=!0),!s)continue;if(S){if(n=S,s=!!t[e++],!s)continue;switch(C.drawArraysInstanced(),C.save(),C.beginMask(),C.setMaskBounds(t[e++],t[e++],t[e++],t[e++]),t[e++]){case 0:e=oi(t,e);break;case 1:e=ri(t,e);break}C.endMask();continue}if(!t[e++])continue;switch(t[e++]){case 0:e=ii(t,e,r);break;case 1:e=ti(t,e);break;case 2:e=ni(t,e);break;case 3:e=si(t,e,r);break}}return(n||b)&&(C.restore(),C.leaveMask()),i&&C.containerEndLayer(o,m,f,u,d,g,a,h),e};let Nr=-1;const ag=(t,e)=>{C.clearTransferBounds();let r=0;const n=t[r++];for(Nr!==n&&(Nr=n,Nr===-1?C.updateBackgroundColor(0,0,0,0):C.updateBackgroundColor((Nr>>16&255)/255,(Nr>>8&255)/255,(Nr&255)/255,1)),C.reset(),C.setTransform(1,0,0,1,0,0),C.fillBackgroundColor();t.length>r;){if(!t[r++])continue;const s=t[r++];switch(s){case 0:r=ii(t,r,e);break;case 1:r=ti(t,r);break;case 2:r=ni(t,r);break;case 3:r=si(t,r,e);break;default:console.error("unknown type",s);break}}C.drawArraysInstanced(),I0()&&_0(),C.transferMainCanvas()},cg=t=>{for(let e=0;e{C.clearTransferBounds();let i=1;C.reset(),C.setTransform(1,0,0,1,0,0);const l=C.$clearColorR,c=C.$clearColorG,u=C.$clearColorB,a=C.$clearColorA;for(C.updateBackgroundColor((n>>16&255)/255,(n>>8&255)/255,(n&255)/255,s),C.fillBackgroundColor();t.length>i;){if(!t[i++])continue;const d=t[i++];switch(d){case 0:i=ii(t,i,o);break;case 1:i=ti(t,i);break;case 2:i=ni(t,i);break;case 3:i=si(t,i,o);break;default:console.error("unknown type",d);break}}C.drawArraysInstanced();const h=await C.createImageBitmap(e,r);return C.updateBackgroundColor(l,c,u,a),h};class ug{state;queue;constructor(){this.state="deactivate",this.queue=[]}async execute(){for(this.state="active";this.queue.length;){const e=this.queue.shift();if(e)switch(e.command){case"render":ag(e.buffer.subarray(0,e.length),e.imageBitmaps),globalThis.postMessage({message:"render",buffer:e.buffer},[e.buffer.buffer]);break;case"resize":N0(e.buffer[0],e.buffer[1],!!e.buffer[2]);break;case"initialize":await D0(e.canvas,e.devicePixelRatio);break;case"removeCache":cg(e.buffer);break;case"cacheClear":ee.reset();break;case"capture":{const r=await lg(e.buffer.subarray(0,e.length),e.width,e.height,e.bgColor,e.bgAlpha,e.imageBitmaps);globalThis.postMessage({message:"capture",buffer:e.buffer,imageBitmap:r},[e.buffer.buffer,r])}break}}this.state="deactivate"}}const ai=new ug;self.addEventListener("message",async t=>{ai.queue.push(t.data),ai.state==="deactivate"&&await ai.execute()})})(); -`,Fn=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",di],{type:"text/javascript;charset=utf-8"});function Ns(e){let t;try{if(t=Fn&&(self.URL||self.webkitURL).createObjectURL(Fn),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(di),{name:e?.name})}}const Ce=new Ns,Ys=e=>{const t=e.transferControlToOffscreen();Ce.postMessage({command:"initialize",canvas:t,devicePixelRatio:window.devicePixelRatio},[t])};class ze{static get AT_TARGET(){return 2}static get BUBBLING_PHASE(){return 3}static get CAPTURING_PHASE(){return 1}}let x=class{type;bubbles;listener;target;currentTarget;eventPhase;_$stopImmediatePropagation;_$stopPropagation;constructor(t,r=!1){this.type=`${t}`,this.bubbles=r,this.target=null,this.currentTarget=null,this.eventPhase=ze.AT_TARGET,this.listener=null,this._$stopImmediatePropagation=!1,this._$stopPropagation=!1}static get ADDED(){return"added"}static get ADDED_TO_STAGE(){return"addedToStage"}static get CHANGE(){return"change"}static get COMPLETE(){return"complete"}static get ENDED(){return"ended"}static get ENTER_FRAME(){return"enterFrame"}static get FRAME_LABEL(){return"frameLabel"}static get INPUT(){return"input"}static get OPEN(){return"open"}static get REMOVED(){return"removed"}static get REMOVED_FROM_STAGE(){return"removedFromStage"}static get RESIZE(){return"resize"}static get SCROLL(){return"scroll"}stopImmediatePropagation(){this._$stopImmediatePropagation=!0}stopPropagation(){this._$stopPropagation=!0}};const q=new Map,Kt=[],Qt=()=>Kt.length?Kt.pop():[],Pe=e=>{10>Kt.length&&(e.length=0,Kt.push(e))};let Ai=null;const We=e=>{Ai=e},jt=()=>Ai;class V extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case V.KEY_DOWN:case V.KEY_UP:return i in s?$event[i]:void 0;default:return}}})}static get KEY_DOWN(){return"keydown"}static get KEY_UP(){return"keyup"}}const Ws=(e,t,r,n=!1,i=0)=>{let s;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:(!q.size||!q.has(t))&&q.set(t,Qt()),s=q.get(t);break;default:e._$events||(e._$events=new Map),(!e._$events.size||!e._$events.has(t))&&e._$events.set(t,Qt()),s=e._$events.get(t);break}const a=s.length;let o=0;for(;o1&&s.sort((c,u)=>{switch(!0){case c.priority>u.priority:return-1;case c.priority{switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:return!!(q.size&&q.has(t));default:return!!(e._$events&&e._$events.size&&e._$events.has(t))}},Ks=(e,t,r,n=!1)=>{let i;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:if(!q.size||!q.has(t))return;i=q.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;i=e._$events.get(t);break}if(i){for(let s=0;s1&&i.sort((s,a)=>{switch(!0){case s.priority>a.priority:return-1;case s.priority{let n;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:if(!q.size||!q.has(t))return;n=q.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;n=e._$events.get(t);break}if(!n)return;const i=Qt();for(let s=0;s1&&i.sort((s,a)=>{switch(!0){case s.priority>a.priority:return-1;case s.priority{if(e.hasEventListener(t))return!0;if("parent"in e){let r=e.parent;for(;r;){if(r.hasEventListener(t))return!0;if(!("parent"in r))break;r=r.parent}}return!1},zs=(e,t)=>{switch(t.type){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:{if(!q.size||!q.has(t.type))return!1;const r=q.get(t.type);if(!r.length)return!1;for(let n=0;n-1;--i){const s=n[i];for(let a=0;a{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case Ne.FOCUS_IN:case Ne.FOCUS_OUT:return i in s?$event[i]:void 0;default:return}}})}static get FOCUS_IN(){return"focusin"}static get FOCUS_OUT(){return"focusout"}}class Gt extends x{status;responseHeaders;responseURL;constructor(t,r=!1,n=0,i="",s=[]){super(t,r),this.status=n|0,this.responseHeaders=s,this.responseURL=i}static get HTTP_STATUS(){return"httpStatus"}}class Re extends x{text;constructor(t,r=!1,n=""){super(t,r),this.text=`${n}`}static get IO_ERROR(){return"ioError"}}class S extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s)switch(s.type){case S.POINTER_DOWN:case S.POINTER_MOVE:case S.POINTER_UP:case S.POINTER_LEAVE:case S.POINTER_OVER:case S.POINTER_OUT:return i in s?$event[i]:void 0;default:return}}})}static get DOUBLE_CLICK(){return"dblclick"}static get POINTER_DOWN(){return"pointerdown"}static get POINTER_LEAVE(){return"pointerleave"}static get POINTER_MOVE(){return"pointermove"}static get POINTER_OUT(){return"pointerout"}static get POINTER_OVER(){return"pointerover"}static get POINTER_UP(){return"pointerup"}static get POINTER_CANCEL(){return"pointercancel"}}class Z extends x{bytesLoaded;bytesTotal;constructor(t,r=!1,n=0,i=0){super(t,r),this.bytesLoaded=n|0,this.bytesTotal=i|0}static get PROGRESS(){return"progress"}}class Ae extends x{static get PLAY(){return"play"}static get PLAYING(){return"playing"}static get PAUSE(){return"pause"}static get SEEK(){return"seek"}}class ye extends x{static get UPDATE(){return"jobupdate"}static get STOP(){return"jobstop"}}class qe extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,i)=>{if(i in n)return n[i];const s=jt();if(s&&s.type===qe.WHEEL)return i in s?$event[i]:void 0}})}static get WHEEL(){return"wheel"}}const pi=[],er=e=>{e.size&&e.clear(),pi.push(e)},Hs=()=>pi.pop()||new Map,Js=(e,t,r)=>{r.clear(),e.$timerId!==null&&clearTimeout(e.$timerId);for(const n of t.values()){for(const i of n.values())i&&e.destroy(i);er(n)}t.clear()},Zs=(e,t)=>{if(!(!t||typeof t!="object")&&"canvas"in t){const r=t.canvas,n=r.width,i=r.height;t.clearRect(0,0,n+1,i+1),r.width=r.height=1,e.push(r)}},qs=(e,t,r)=>{if(!e.has(t))return;const n=e.get(t);n.has(r)&&(n.delete(r),n.size||(er(n),e.delete(t)))},js=(e,t,r)=>{if(!t.has(r))return;const n=t.get(r);for(const i of n.values())e.destroy(i);t.delete(r),er(n)},ea=(e,t,r)=>{const n=e.get(t)||null;return n?(n.delete("trash"),n.get(r)||null):null},ta=(e,t,r,n,i=null)=>{t.has(r)||t.set(r,Hs());const s=t.get(r);if(i===null){if(!s.has(n))return;e.destroy(s.get(n)),s.delete(n),s.size||(t.delete(r),er(s));return}s.set(n,i)},ra=(e,t,r="")=>r?e.has(t)?e.get(t).has(r):!1:e.has(t),na=(e,t,r)=>{let n=2166136261,i=e*100|0;return n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619),i=t*100|0,n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619),r&&(i=r*100|0,n^=i&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>24,n=Math.imul(n,16777619)),(n>>>0)%16777216},ia=(e,t,r,n)=>{let i=2166136261,s=e*100|0;return i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=t*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=r*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),s=n*100|0,i^=s&255,i=Math.imul(i,16777619),i^=s>>>8&255,i=Math.imul(i,16777619),i^=s>>>16&255,i=Math.imul(i,16777619),i^=s>>>24,i=Math.imul(i,16777619),(i>>>0)%16777216},sa=(e,t,r,n)=>{if(r.has(n))return;const i=t.get(n);i&&(i.set("trash",!0),r.set(n,i),e.$timerId!==null&&clearTimeout(e.$timerId),e.$removeCache=!1,e.$timerId=setTimeout(()=>{e.$removeCache=!0,e.$timerId=null},1e3))},aa=(e,t)=>{if(t.size){for(const[r,n]of t)n.has("trash")&&(e.removeById(r),e.$removeIds.push(+r));t.clear(),e.$removeCache=!1}};class oa{_$pool;_$store;_$trash;$timerId;$removeCache;$removeIds;constructor(){this._$pool=[],this._$store=new Map,this._$trash=new Map,this.$timerId=null,this.$removeIds=[],this.$removeCache=!1}reset(){Js(this,this._$store,this._$trash)}destroy(t=null){Zs(this._$pool,t)}getCanvas(){return this._$pool.pop()||document.createElement("canvas")}remove(t,r){qs(this._$store,t,r)}removeTimer(t){sa(this,this._$store,this._$trash,t)}removeTimerScheduledCache(){aa(this,this._$trash)}removeById(t){js(this,this._$store,t)}getById(t){return this._$store.get(t)}get(t,r){return ea(this._$store,t,r)}set(t,r,n=null){ta(this,this._$store,t,r,n)}has(t,r=""){return ra(this._$store,t,r)}generateKeys(t,r,n){return na(t,r,n)}generateFilterKeys(t,r,n,i){return ia(t,r,n,i)}}const O=new oa,ca=e=>{const t=O.getCanvas();t.width=e.width,t.height=e.height;const r=t.getContext("2d",{willReadFrequently:!0});r.drawImage(e,0,0);const n=r.getImageData(0,0,e.width,e.height),i=new Uint8Array(n.data.buffer);return O.destroy(r),i},la=e=>{const t=O.getCanvas();t.width=e.width,t.height=e.height;const r=t.getContext("2d");r.setTransform(1,0,0,1,0,0),r.drawImage(e,0,0);const n=r.getImageData(0,0,e.width,e.height),i=new Uint8Array(n.data.buffer);return O.destroy(r),i};class _e{width;height;buffer;constructor(t=0,r=0){this.width=t|0,this.height=r|0,this.buffer=null}set image(t){if(!t){this.width=0,this.height=0,this.buffer=null;return}this.buffer=ca(t),this.width=t.width,this.height=t.height}set canvas(t){if(!t){this.width=0,this.height=0,this.buffer=null;return}this.buffer=la(t),this.width=t.width,this.height=t.height}clone(){const t=new _e(this.width,this.height);return this.buffer!==null&&(t.buffer=this.buffer.slice()),t}}class ua{static get ADD(){return"add"}static get ALPHA(){return"alpha"}static get DARKEN(){return"darken"}static get DIFFERENCE(){return"difference"}static get ERASE(){return"erase"}static get HARDLIGHT(){return"hardlight"}static get INVERT(){return"invert"}static get LAYER(){return"layer"}static get LIGHTEN(){return"lighten"}static get MULTIPLY(){return"multiply"}static get NORMAL(){return"normal"}static get OVERLAY(){return"overlay"}static get SCREEN(){return"screen"}static get SUBTRACT(){return"subtract"}}const j=e=>{e.changed=!0;let t=e.parent;for(;t&&!t.changed;)t.changed=!0,t=t.parent},ha=(e,t)=>{const r=U.multiply(e._$colorTransform,t._$colorTransform);e._$colorTransform[0]=r[0],e._$colorTransform[1]=r[1],e._$colorTransform[2]=r[2],e._$colorTransform[3]=r[3],e._$colorTransform[4]=r[4],e._$colorTransform[5]=r[5],e._$colorTransform[6]=r[6],e._$colorTransform[7]=r[7],U.release(r)},mi=[],En=(e=1,t=0,r=0,n=1,i=0,s=0)=>{const a=mi.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=i,a[5]=s,a},fa=e=>{mi.push(e)},gi=[],Pn=(e=1,t=1,r=1,n=1,i=0,s=0,a=0,o=0)=>{const c=gi.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=s,c[6]=a,c[7]=o,c},da=e=>{gi.push(e)},Ee=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};class U{_$colorTransform;constructor(t=1,r=1,n=1,i=1,s=0,a=0,o=0,c=0){this._$colorTransform=Pn(t,r,n,i,s,a,o,c)}get rawData(){return this._$colorTransform}get alphaMultiplier(){return this._$colorTransform[3]}set alphaMultiplier(t){this._$colorTransform[3]=Ee(t,0,1,1)}get alphaOffset(){return this._$colorTransform[7]}set alphaOffset(t){this._$colorTransform[7]=Ee(t,-255,255,0)}get blueMultiplier(){return this._$colorTransform[2]}set blueMultiplier(t){this._$colorTransform[2]=Ee(t,0,1,1)}get blueOffset(){return this._$colorTransform[6]}set blueOffset(t){this._$colorTransform[6]=Ee(t,-255,255,0)}get greenMultiplier(){return this._$colorTransform[1]}set greenMultiplier(t){this._$colorTransform[1]=Ee(t,0,1,1)}get greenOffset(){return this._$colorTransform[5]}set greenOffset(t){this._$colorTransform[5]=Ee(t,-255,255,0)}get redMultiplier(){return this._$colorTransform[0]}set redMultiplier(t){this._$colorTransform[0]=Ee(t,0,1,1)}get redOffset(){return this._$colorTransform[4]}set redOffset(t){this._$colorTransform[4]=Ee(t,-255,255,0)}clone(){return new U(...this._$colorTransform)}concat(t){ha(this,t)}static multiply(t,r){return Pn(t[0]*r[0],t[1]*r[1],t[2]*r[2],t[3]*r[3],t[0]*r[4]+t[4],t[1]*r[5]+t[5],t[2]*r[6]+t[6],t[3]*r[7]+t[7])}static release(t){da(t)}}const Aa=e=>new T(e._$matrix[0],e._$matrix[1],e._$matrix[2],e._$matrix[3],e._$matrix[4],e._$matrix[5]),pa=(e,t)=>{const r=e._$matrix,n=t._$matrix;let i=r[0]*n[0],s=0,a=0,o=r[3]*n[3],c=r[4]*n[0]+n[4],u=r[5]*n[3]+n[5];(r[1]||r[2]||n[1]||n[2])&&(i+=r[1]*n[2],o+=r[2]*n[1],s+=r[0]*n[1]+r[1]*n[3],a+=r[2]*n[0]+r[3]*n[2],c+=r[5]*n[2],u+=r[4]*n[1]),r[0]=i,r[1]=s,r[2]=a,r[3]=o,r[4]=c,r[5]=u},ma=(e,t)=>{e._$matrix[0]=t._$matrix[0],e._$matrix[1]=t._$matrix[1],e._$matrix[2]=t._$matrix[2],e._$matrix[3]=t._$matrix[3],e._$matrix[4]=t._$matrix[4],e._$matrix[5]=t._$matrix[5]},ga=(e,t,r,n=0,i=0,s=0)=>{e.identity(),e.rotate(n),e.scale(t,r),e.translate(i,s)},ba=(e,t,r,n=0,i=0,s=0)=>{const a=e._$matrix;if(a[0]=t/1638.4,a[3]=r/1638.4,n){const o=Math.cos(n),c=Math.sin(n);a[1]=c*a[3],a[2]=-c*a[0],a[0]*=o,a[3]*=o}else a[1]=0,a[2]=0;a[4]=i+t/2,a[5]=s+r/2},xa=(e,t)=>new se(e.x+t.x,e.y+t.y),ya=e=>new se(e.x,e.y),$a=(e,t)=>{e.x=t.x,e.y=t.y},va=(e,t)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),wa=(e,t)=>e.x===t.x&&e.y===t.y,Ma=(e,t,r)=>new se(e.x+(t.x-e.x)*(1-r),e.y+(t.y-e.y)*(1-r)),Ba=(e,t)=>{const r=t/e.length;e.x*=r,e.y*=r},Ta=(e,t,r)=>{e.x+=t,e.y+=r},Sa=(e,t)=>new se(e*Math.cos(t),e*Math.sin(t)),Ia=(e,t,r)=>{e.x=t,e.y=r},Ca=(e,t)=>new se(e.x-t.x,e.y-t.y);class se{x;y;constructor(t=0,r=0){this.x=t,this.y=r}get length(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2))}add(t){return xa(this,t)}clone(){return ya(this)}copyFrom(t){$a(this,t)}static distance(t,r){return va(t,r)}equals(t){return wa(this,t)}static interpolate(t,r,n){return Ma(t,r,n)}normalize(t){Ba(this,t)}offset(t,r){Ta(this,t,r)}static polar(t,r){return Sa(t,r)}setTo(t,r){Ia(this,t,r)}subtract(t){return Ca(this,t)}}const Fa=(e,t)=>new se(t.x*e._$matrix[0]+t.y*e._$matrix[2],t.x*e._$matrix[1]+t.y*e._$matrix[3]),Ea=e=>{e._$matrix[0]=1,e._$matrix[1]=0,e._$matrix[2]=0,e._$matrix[3]=1,e._$matrix[4]=0,e._$matrix[5]=0},Pa=e=>{const t=e._$matrix[0],r=e._$matrix[1],n=e._$matrix[2],i=e._$matrix[3],s=e._$matrix[4],a=e._$matrix[5];if(r===0&&n===0)e._$matrix[0]=1/t,e._$matrix[1]=0,e._$matrix[2]=0,e._$matrix[3]=1/i,e._$matrix[4]=-e._$matrix[0]*s,e._$matrix[5]=-e._$matrix[3]*a;else{const o=t*i-r*n;if(o){const c=1/o;e._$matrix[0]=i*c,e._$matrix[1]=-r*c,e._$matrix[2]=-n*c,e._$matrix[3]=t*c,e._$matrix[4]=-(e._$matrix[0]*s+e._$matrix[2]*a),e._$matrix[5]=-(e._$matrix[1]*s+e._$matrix[3]*a)}}},Ra=(e,t)=>{const r=e._$matrix,n=r[0],i=r[1],s=r[2],a=r[3],o=r[4],c=r[5];r[0]=n*Math.cos(t)-i*Math.sin(t),r[1]=n*Math.sin(t)+i*Math.cos(t),r[2]=s*Math.cos(t)-a*Math.sin(t),r[3]=s*Math.sin(t)+a*Math.cos(t),r[4]=o*Math.cos(t)-c*Math.sin(t),r[5]=o*Math.sin(t)+c*Math.cos(t)},Oa=(e,t,r)=>{const n=e._$matrix;n[0]*=t,n[2]*=t,n[4]*=t,n[1]*=r,n[3]*=r,n[5]*=r},ka=(e,t,r,n,i,s,a)=>{const o=e._$matrix;o[0]=t,o[1]=r,o[2]=n,o[3]=i,o[4]=s,o[5]=a},Ua=(e,t)=>{const r=t.x,n=t.y,i=e._$matrix;return new se(r*i[0]+n*i[2]+i[4],r*i[1]+n*i[3]+i[5])},Ga=(e,t,r)=>{e.tx+=t,e.ty+=r};class T{_$matrix;constructor(t=1,r=0,n=0,i=1,s=0,a=0){this._$matrix=En(t,r,n,i,s,a)}get a(){return this._$matrix[0]}set a(t){this._$matrix[0]=t}get b(){return this._$matrix[1]}set b(t){this._$matrix[1]=t}get c(){return this._$matrix[2]}set c(t){this._$matrix[2]=t}get d(){return this._$matrix[3]}set d(t){this._$matrix[3]=t}get tx(){return this._$matrix[4]}set tx(t){this._$matrix[4]=t}get ty(){return this._$matrix[5]}set ty(t){this._$matrix[5]=t}get rawData(){return this._$matrix}clone(){return Aa(this)}concat(t){pa(this,t)}copyFrom(t){ma(this,t)}createBox(t,r,n=0,i=0,s=0){ga(this,t,r,n,i,s)}createGradientBox(t,r,n=0,i=0,s=0){ba(this,t,r,n,i,s)}deltaTransformPoint(t){return Fa(this,t)}identity(){Ea(this)}invert(){Pa(this)}rotate(t){Ra(this,t)}scale(t,r){Oa(this,t,r)}setTo(t,r,n,i,s,a){ka(this,t,r,n,i,s,a)}transformPoint(t){return Ua(this,t)}translate(t,r){Ga(this,t,r)}static multiply(t,r){const n=t[0],i=t[1],s=t[2],a=t[3],o=t[4],c=t[5],u=r[0],h=r[1],l=r[2],f=r[3],A=r[4],d=r[5];return En(n*u+s*h,i*u+a*h,n*l+s*f,i*l+a*f,n*A+s*d+o,i*A+a*d+c)}static release(t){fa(t)}}const _a=e=>new be(e.x,e.y,e.width,e.height),Da=(e,t,r)=>e.x<=t&&e.y<=r&&e.right>t&&e.bottom>r,La=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>t.x&&e.bottom>t.y,Na=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>=t.right&&e.bottom>=t.bottom,Ya=(e,t)=>{e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},Wa=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Va=(e,t,r)=>{e.x-=t,e.width+=2*t,e.y-=r,e.height+=2*r},Ka=(e,t)=>{e.x-=t.x,e.width+=2*t.x,e.y-=t.y,e.height+=2*t.y},Qa=(e,t)=>{const r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom),a=i-r,o=s-n;return a>0&&o>0?new be(r,n,a,o):new be(0,0,0,0)},Xa=(e,t)=>{const r=Math.max(e.x,t.x),n=Math.max(e.y,t.y),i=Math.min(e.right,t.right),s=Math.min(e.bottom,t.bottom);return i-r>0&&s-n>0},za=e=>e.width<=0||e.height<=0,Ha=(e,t,r)=>{e.x+=t,e.y+=r},Ja=(e,t)=>{e.x+=t.x,e.y+=t.y},Za=e=>{e.x=e.y=e.width=e.height=0},qa=(e,t,r,n,i)=>{e.x=t,e.y=r,e.width=n,e.height=i},ja=(e,t)=>e.isEmpty()?t.clone():t.isEmpty()?e.clone():new be(Math.min(e.x,t.x),Math.min(e.y,t.y),Math.max(e.right-t.left,t.right-e.left),Math.max(e.bottom-t.top,t.bottom-e.top));class be{x;y;width;height;constructor(t=0,r=0,n=0,i=0){this.x=t,this.y=r,this.width=n,this.height=i}get bottom(){return this.y+this.height}set bottom(t){this.height=t-this.y}get bottomRight(){return new se(this.right,this.bottom)}set bottomRight(t){this.right=t.x,this.bottom=t.y}get left(){return this.x}set left(t){this.width=this.right-t,this.x=t}get right(){return this.x+this.width}set right(t){this.width=t-this.x}get size(){return new se(this.width,this.height)}set size(t){this.width=t.x,this.height=t.y}get top(){return this.y}set top(t){this.height=this.bottom-t,this.y=t}get topLeft(){return new se(this.x,this.y)}set topLeft(t){this.left=t.x,this.top=t.y}clone(){return _a(this)}contains(t,r){return Da(this,t,r)}containsPoint(t){return La(this,t)}containsRect(t){return Na(this,t)}copyFrom(t){Ya(this,t)}equals(t){return Wa(this,t)}inflate(t,r){Va(this,t,r)}inflatePoint(t){Ka(this,t)}intersection(t){return Qa(this,t)}intersects(t){return Xa(this,t)}isEmpty(){return za(this)}offset(t,r){Ha(this,t,r)}offsetPoint(t){Ja(this,t)}setEmpty(){Za(this)}setTo(t,r,n,i){qa(this,t,r,n,i)}union(t){return ja(this,t)}}const tr=e=>{if(e.placeObject)return e.placeObject;const t=e.placeId;if(t===-1)return null;const r=e.parent;if(!r)return null;const n=r.loaderInfo;if(!n||!n.data)return null;const i=n.data.characters[r.characterId],s=r.isTimelineEnabled?r.currentFrame:1,a=i.placeMap[s];if(!a||!(t in a))return null;const o=a[t],c=i.placeObjects[o];return c?(e.placeObject=c,c):null},bt=new se,bi=0,xi=1,eo=2,to=3,xt=new Float32Array([1,0,0,1,0,0]);let ro=0;const yi=()=>ro++,$i=[],Pr=[],vi=[],no=[],je=(e=0,t=0,r=0,n=0,i=0,s=0)=>{const a=vi.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=i,a[5]=s,a},Ft=e=>{vi.push(e)},_t=(e=1,t=1,r=1,n=1,i=0,s=0,a=0,o=0)=>{const c=no.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=s,c[6]=a,c[7]=o,c},wi=[],io=()=>wi.pop()||new Map,so=e=>{e.clear(),wi.push(e)},z=(...e)=>{const t=$i.pop()||[];return e.length&&t.push(...e),t},oe=e=>{e.length&&(e.length=0),$i.push(e)},re=(e,t,r,n)=>{const i=Pr.length?Pr.pop():new Float32Array(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i},k=e=>{Pr.push(e)},ao=e=>{let t=null;switch(e.method.toUpperCase()){case"GET":if(e.data){const n=e.url.split("?");n[1]=n.length===1?e.data.toString():`${n[1]}&${e.data.toString()}`,e.url=n.join("?")}break;case"PUT":case"POST":e.data&&(t=e.data.toString());break}const r=new XMLHttpRequest;if(r.open(e.method,e.url,!0),r.responseType=e.format,r.withCredentials=e.withCredentials,e.event){const n=Object.keys(e.event);for(let i=0;i{const t=z();if(e){const r=e.trim().split(` -`);for(let n=0;nIe?(Ie.fillStyle=e,+`0x${Ie.fillStyle.slice(1)}`):0,me=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},kr=[],Ur=[],Ue=new Map;let Mi=null;const Bi=e=>{Mi=e},lo=()=>Mi,_=e=>{if(e.$matrix)return e.$matrix.rawData;const t=tr(e);if(!t||!t.matrix)return null;if(!t.typedMatrix){const r=t.matrix;t.typedMatrix=je(r[0],r[1],r[2],r[3],r[4],r[5])}return t.typedMatrix},uo=e=>{const t=_(e);let r=t||xt,n=e.parent;for(;n;){const i=_(n);i&&(r=T.multiply(i,r)),n=n.parent}return new T(r[0],r[1],r[2],r[3],r[4],r[5])},Ve=e=>{if(e.$colorTransform)return e.$colorTransform.rawData;const t=tr(e);if(!t||!t.colorTransform)return null;if(!t.typedColorTransform){const r=t.colorTransform;t.typedColorTransform=_t(r[0],r[1],r[2],r[3],r[4],r[5],r[6],r[7])}return t.typedColorTransform},ho=e=>{if(e.$alpha!==null)return e.$alpha;if(e.$colorTransform){const r=e.$colorTransform.rawData;return r[3]+r[7]/255}const t=Ve(e);return t?t[3]+t[7]/255:1},fo=(e,t)=>{if(t=me(t,0,1),e.$alpha===t)return;e.$alpha=t;let r=e.$colorTransform;if(!r){const n=Ve(e);r=n?new U(...n):new U}r.alphaMultiplier=t,r.alphaOffset=0,e.$colorTransform=r,j(e)};class Fe{$updated;constructor(){this.$updated=!0}canApplyFilter(){return!0}getBounds(t){return t}}const F=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)},Gr=document.createElement("canvas");Gr.width=Gr.height=1;const Sr=Gr.getContext("2d"),Oe=e=>Sr?(Sr.fillStyle=e,+`0x${Sr.fillStyle.slice(1)}`):0,cn=Math.PI/180,ln=e=>{switch(e){case"full":return 0;case"inner":return 1;case"outer":return 2;default:return 0}},Ti=e=>e.strength>0&&e.distance!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Si=e=>e.blurX>0&&e.blurY>0&&e.quality>0,Ao=[.5,1.05,1.4,1.55,1.75,1.9,2,2.15,2.2,2.3,2.5,3,3,3.5,3.5],it=(e,t)=>{if(!Si(e))return t;const r=Ao[e.quality-1],n=Math.round(e.blurX*r),i=Math.round(e.blurY*r);return t[0]-=n,t[2]+=n,t[1]-=i,t[3]+=i,t},po=(e,t)=>{if(!Ti(e)||e.type==="inner")return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.abs(Math.cos(r)*n),s=Math.abs(Math.sin(r)*n);return t[0]-=i,t[2]+=i,t[1]-=s,t[3]+=s,t},mo=e=>[e.$filterType,e.distance,e.angle,e.highlightColor,e.highlightAlpha,e.shadowColor,e.shadowAlpha,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],go=e=>new Float32Array([e.$filterType,e.distance,e.angle,e.highlightColor,e.highlightAlpha,e.shadowColor,e.shadowAlpha,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout]);class rr extends Fe{$filterType=0;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$highlightColor;_$highlightAlpha;_$shadowColor;_$shadowAlpha;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=16777215,i=1,s=0,a=1,o=4,c=4,u=1,h=1,l="inner",f=!1){super(),this._$distance=4,this._$angle=45,this._$highlightColor=16777215,this._$highlightAlpha=1,this._$blurX=4,this._$blurY=4,this._$quality=1,this._$shadowColor=0,this._$shadowAlpha=1,this._$strength=1,this._$type="inner",this._$knockout=!1,this.blurX=o,this.blurY=c,this.quality=h,this.distance=t,this.angle=r,this.highlightColor=n,this.highlightAlpha=i,this.shadowColor=s,this.shadowAlpha=a,this.strength=u,this.type=l,this.knockout=f}get angle(){return this._$angle}set angle(t){t=F(t%360,-360,360,45),t!==this._$angle&&(this._$angle=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get distance(){return this._$distance}set distance(t){t=F(+t,-255,255,4),t!==this._$distance&&(this._$distance=t,this.$updated=!0)}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(t){t=F(+t,0,1,0),t!==this._$highlightAlpha&&(this._$highlightAlpha=t,this.$updated=!0)}get highlightColor(){return this._$highlightColor}set highlightColor(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,16777215),t!==this._$highlightColor&&(this._$highlightColor=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get shadowAlpha(){return this._$shadowAlpha}set shadowAlpha(t){t=F(t,0,1,0),t!==this._$shadowAlpha&&(this._$shadowAlpha=t,this.$updated=!0)}get shadowColor(){return this._$shadowColor}set shadowColor(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$shadowColor&&(this._$shadowColor=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}get type(){return this._$type}set type(t){if(t=`${t}`.toLowerCase(),t!==this._$type){switch(t){case"inner":case"outer":case"full":break;default:return}this._$type=t,this.$updated=!0}}clone(){return new rr(this._$distance,this._$angle,this._$highlightColor,this._$highlightAlpha,this._$shadowColor,this._$shadowAlpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return mo(this)}toNumberArray(){return go(this)}canApplyFilter(){return Ti(this)}getBounds(t){return po(this,t)}}const bo=e=>[e.$filterType,e.blurX,e.blurY,e.quality],xo=e=>new Float32Array([e.$filterType,e.blurX,e.blurY,e.quality]);class nr extends Fe{$filterType=1;_$blurX;_$blurY;_$quality;constructor(t=4,r=4,n=1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this.blurX=t,this.blurY=r,this.quality=n}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}clone(){return new nr(this._$blurX,this._$blurY,this._$quality)}toArray(){return bo(this)}toNumberArray(){return xo(this)}canApplyFilter(){return Si(this)}getBounds(t){return it(this,t)}}const yo=e=>[e.$filterType,e.matrix],$o=e=>new Float32Array([e.$filterType,...e.matrix]);class ir extends Fe{$filterType=2;_$matrix;constructor(t=null){super(),this._$matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],t&&t.length===20&&(this.matrix=t)}get matrix(){return this._$matrix}set matrix(t){if(this._$matrix!==t&&!(!Array.isArray(t)||t.length!==20)){for(let r=0;r<20;r++)if(t[r]!==this._$matrix[r]){this.$updated=!0;break}this.$updated&&(this._$matrix=t)}}clone(){return new ir(this._$matrix)}toArray(){return yo(this)}toNumberArray(){return $o(this)}}const vo=e=>e.matrix!==null&&e.matrixX*e.matrixY===e.matrix.length,wo=e=>[e.$filterType,e.matrixX,e.matrixY,e.matrix,e.divisor,e.bias,e.preserveAlpha,e.clamp,e.color,e.alpha],Mo=e=>{const t=e.matrix||[];return new Float32Array([e.$filterType,e.matrixX,e.matrixY,...t,e.divisor,e.bias,+e.preserveAlpha,+e.clamp,e.color,e.alpha])};class sr extends Fe{$filterType=3;_$matrixX;_$matrixY;_$matrix;_$divisor;_$bias;_$preserveAlpha;_$clamp;_$color;_$alpha;constructor(t=0,r=0,n=null,i=1,s=0,a=!0,o=!0,c=0,u=0){super(),this._$matrixX=0,this._$matrixY=0,this._$matrix=null,this._$divisor=1,this._$bias=0,this._$preserveAlpha=!0,this._$clamp=!0,this._$color=0,this._$alpha=0,this.matrixX=t,this.matrixY=r,this.matrix=n,this.divisor=i,this.bias=s,this.preserveAlpha=a,this.clamp=o,this.color=c,this.alpha=u}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get bias(){return this._$bias}set bias(t){t|=0,t!==this._$bias&&(this._$bias=t,this.$updated=!0)}get clamp(){return this._$clamp}set clamp(t){t=!!t,t!==this._$clamp&&(this._$clamp=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$color&&(this._$color=t,this.$updated=!0)}get divisor(){return this._$divisor}set divisor(t){t|=0,t!==this._$divisor&&(this._$divisor=t,this.$updated=!0)}get matrix(){return this._$matrix}set matrix(t){this._$matrix!==t&&(this._$matrix=t,this.$updated=!0)}get matrixX(){return this._$matrixX}set matrixX(t){t=F(t|0,0,15,0)|0,t!==this._$matrixX&&(this._$matrixX=t,this.$updated=!0)}get matrixY(){return this._$matrixY}set matrixY(t){t=F(t|0,0,15,0)|0,t!==this._$matrixY&&(this._$matrixY=t,this.$updated=!0)}get preserveAlpha(){return this._$preserveAlpha}set preserveAlpha(t){t=!!t,t!==this._$preserveAlpha&&(this._$preserveAlpha=t,this.$updated=!0)}clone(){return new sr(this._$matrixX,this._$matrixY,this._$matrix?this._$matrix.slice():null,this._$divisor,this._$bias,this._$preserveAlpha,this._$clamp,this._$color,this._$alpha)}toArray(){return wo(this)}toNumberArray(){return Mo(this)}canApplyFilter(){return vo(this)}}const Bo=e=>e.bitmapBuffer!==null&&e.componentX>0&&e.componentY>0&&e.scaleX!==0&&e.scaleY!==0,To=e=>[e.$filterType,e.bitmapBuffer?Array.from(e.bitmapBuffer):null,e.bitmapWidth,e.bitmapHeight,e.mapPointX,e.mapPointY,e.componentX,e.componentY,e.scaleX,e.scaleY,e.mode,e.color,e.alpha],So=e=>{let t=2;switch(e.mode){case"clamp":t=0;break;case"color":t=1;break;case"wrap":t=2;break;case"ignore":t=3;break;default:t=2;break}const r=e.bitmapBuffer||new Uint8Array,n=[e.$filterType,r.length];for(let i=0;i[e.$filterType,e.distance,e.angle,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout,e.hideObject],Co=e=>new Float32Array([e.$filterType,e.distance,e.angle,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,+e.inner,+e.knockout,+e.hideObject]),Ii=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Fo=(e,t)=>{if(!Ii(e)||e.inner)return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.cos(r)*n,s=Math.sin(r)*n;return t[0]=Math.min(t[0],i),i>0&&(t[2]+=i),t[1]=Math.min(t[1],s),s>0&&(t[3]+=s),t};class or extends Fe{$filterType=5;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$color;_$alpha;_$strength;_$inner;_$knockout;_$hideObject;constructor(t=4,r=45,n=0,i=1,s=4,a=4,o=1,c=1,u=!1,h=!1,l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this._$hideObject=!1,this.blurX=s,this.blurY=a,this.quality=c,this.distance=t,this.angle=r,this.color=n,this.alpha=i,this.strength=o,this.inner=u,this.knockout=h,this.hideObject=l}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get angle(){return this._$angle}set angle(t){t=F(t%360,-360,360,45),t!==this._$angle&&(this._$angle=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,0),t!==this._$color&&(this._$color=t,this.$updated=!0)}get distance(){return this._$distance}set distance(t){t=F(+t,-255,255,4),t!==this._$distance&&(this._$distance=t,this.$updated=!0)}get hideObject(){return this._$hideObject}set hideObject(t){t=!!t,t!==this._$hideObject&&(this._$hideObject=t,this.$updated=!0)}get inner(){return this._$inner}set inner(t){t=!!t,t!==this._$inner&&(this._$inner=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}clone(){return new or(this._$distance,this._$angle,this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout,this._$hideObject)}toArray(){return Io(this)}toNumberArray(){return Co(this)}canApplyFilter(){return Ii(this)}getBounds(t){return Fo(this,t)}}const Eo=e=>[e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout],Po=e=>new Float32Array([e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,+e.inner,+e.knockout]),Ci=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Ro=(e,t)=>!Ci(e)||e.inner?t:it(e,t);class cr extends Fe{$filterType=6;_$blurX;_$blurY;_$quality;_$color;_$alpha;_$strength;_$inner;_$knockout;constructor(t=0,r=1,n=4,i=4,s=1,a=1,o=!1,c=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$color=0,this._$alpha=1,this._$strength=1,this._$inner=!1,this._$knockout=!1,this.blurX=n,this.blurY=i,this.quality=a,this.color=t,this.alpha=r,this.strength=s,this.inner=o,this.knockout=c}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=t,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(t){t=F(+t,0,255,0),t!==this._$blurX&&(this._$blurX=t,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(t){t=F(+t,0,255,0),t!==this._$blurY&&(this._$blurY=t,this.$updated=!0)}get color(){return this._$color}set color(t){t=F(typeof t=="string"?Oe(t):t,0,16777215,4),t!==this._$color&&(this._$color=t,this.$updated=!0)}get inner(){return this._$inner}set inner(t){t=!!t,t!==this._$inner&&(this._$inner=t,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(t){t=!!t,t!==this._$knockout&&(this._$knockout=t,this.$updated=!0)}get quality(){return this._$quality}set quality(t){t=F(t|0,0,15,1),t!==this._$quality&&(this._$quality=t,this.$updated=!0)}get strength(){return this._$strength}set strength(t){t=F(t|0,0,255,0),t!==this._$strength&&(this._$strength=t,this.$updated=!0)}clone(){return new cr(this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout)}toArray(){return Eo(this)}toNumberArray(){return Po(this)}canApplyFilter(){return Ci(this)}getBounds(t){return Ro(this,t)}}const Fi=e=>e.strength>0&&e.distance>0&&e.alphas!==null&&e.ratios!==null&&e.colors!==null&&e.blurX>0&&e.blurY>0&&e.quality>0,Oo=e=>[e.$filterType,e.distance,e.angle,e.colors,e.alphas,e.ratios,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],ko=e=>{const t=e.colors?e.colors:[],r=e.alphas?e.alphas:[],n=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,r.length,...r,n.length,...n,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout])},Uo=(e,t)=>{if(!Fi(e)||e.type==="inner")return t;it(e,t);const r=e.angle*cn,n=e.distance,i=Math.abs(Math.cos(r)*n),s=Math.abs(Math.sin(r)*n);return t[0]-=i,t[2]+=i,t[1]-=s,t[3]+=s,t};class lr extends Fe{$filterType=7;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=null,i=null,s=null,a=4,o=4,c=1,u=1,h="inner",l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type="inner",this._$knockout=!1,this.blurX=a,this.blurY=o,this.quality=u,this.distance=t,this.angle=r,this.colors=n,this.alphas=i,this.ratios=s,this.strength=c,this.type=h,this.knockout=l}get alphas(){return this._$alphas}set alphas(t){if(t!==this._$alphas){if(Array.isArray(t))for(let r=0;r[e.$filterType,e.distance,e.angle,e.colors,e.alphas,e.ratios,e.blurX,e.blurY,e.strength,e.quality,e.type,e.knockout],Ei=e=>e.strength>0&&e.distance>0&&e.alphas!==null&&e.ratios!==null&&e.colors!==null&&e.blurX>0&&e.blurY>0&&e.quality>0,_o=e=>{const t=e.colors?e.colors:[],r=e.alphas?e.alphas:[],n=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,r.length,...r,n.length,...n,e.blurX,e.blurY,e.strength,e.quality,ln(e.type),+e.knockout])},Do=(e,t)=>!Ei(e)||e.type==="inner"?t:it(e,t);class ur extends Fe{$filterType=8;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(t=4,r=45,n=null,i=null,s=null,a=4,o=4,c=1,u=1,h="outer",l=!1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this._$distance=4,this._$angle=45,this._$colors=null,this._$alphas=null,this._$ratios=null,this._$strength=1,this._$type="outer",this._$knockout=!1,this.blurX=a,this.blurY=o,this.quality=u,this.distance=t,this.angle=r,this.colors=n,this.alphas=i,this.ratios=s,this.strength=c,this.type=h,this.knockout=l}get alphas(){return this._$alphas}set alphas(t){if(t!==this._$alphas){if(Array.isArray(t))for(let r=0;r{const t=z();for(let r=0;r{if(e.$filters)return e.$filters;const t=tr(e);return t&&t.surfaceFilterList?(t.filters||(t.filters=Lo(t.surfaceFilterList)),t.filters):null},Yo=(e,t)=>{e.$filters=t,j(e)},Wo=e=>{if(e.$blendMode)return e.$blendMode;const t=tr(e);return t&&t.blendMode?t.blendMode:"normal"},Vo=(e,t)=>{e.$blendMode!==t&&(e.$blendMode=t,j(e))},Ko=180/Math.PI,Qo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?Math.atan2(t[1],t[0])*Ko:0},Xo=Math.PI/180,zo=(e,t)=>{if(t=me(t%360,-360,360,0),e.$rotation===t)return;let r=e.$matrix;if(!r){const s=_(e);e.$matrix=r=s?new T(...s):new T}const n=Math.sqrt(r.a*r.a+r.b*r.b),i=Math.sqrt(r.c*r.c+r.d*r.d);if(t===0)r.a=n,r.b=0,r.c=0,r.d=i;else{let s=Math.atan2(r.b,r.a),a=Math.atan2(-r.c,r.d);const o=t*Xo;a=a+o-s,s=o,r.b=n*Math.sin(s),r.b===1||r.b===-1?r.a=0:r.a=n*Math.cos(s),r.c=-i*Math.sin(a),r.c===1||r.c===-1?r.d=0:r.d=i*Math.cos(a)}e.$scaleX=null,e.$scaleY=null,e.$rotation=t,j(e)},Ho=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);if(!t)return 1;const n=(Math.abs(t[0])>=1e-12?Math.sign(t[0]):Math.sign(t[1]))||1,i=Math.hypot(t[0],t[1]);return Math.round(i*n*1e4)/1e4},Pi=(e,t)=>{t=me(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);const r=Math.round(t*1e4)/1e4;if(e.$scaleX===r)return;let n=e.$matrix;if(!n){const i=_(e);e.$matrix=n=i?new T(...i):new T}if(n.b===0||isNaN(n.b))n.a=r;else{const s=Math.atan2(n.b,n.a),a=Math.hypot(n.a,n.b),o=(Math.abs(n.a)>=1e-12?Math.sign(n.a):Math.sign(n.b))||1,h=(a*o>=0?s:s-Math.PI)+(r<0?Math.PI:0),l=Math.abs(r);n.a=l*Math.cos(h),n.b=l*Math.sin(h)}e.$scaleX=r,e.$rotation=null,j(e)},Jo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);if(!t)return 1;const r=1e-12,n=Math.hypot(t[0],t[1]),i=(Math.abs(t[0])>=r?Math.sign(t[0]):Math.sign(t[1]))||1;return Math.round((t[0]*t[3]-t[1]*t[2])/(n*i)*1e4)/1e4},Ri=(e,t)=>{t=me(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);const r=Math.round(t*1e4)/1e4;if(e.$scaleY===r)return;let n=e.$matrix;if(!n){const i=_(e);e.$matrix=n=i?new T(...i):new T}if(n.c===0||isNaN(n.c))n.d=r;else{const i=Math.max(0,Math.abs(r)),s=1e-12;let a=Math.atan2(n.b,n.a);(n.a<0||Math.abs(n.a)Math.PI&&(a-=2*Math.PI);const o=a+(r<0?Math.PI:0);n.c=-i*Math.sin(o),n.d=i*Math.cos(o)}e.$scaleY=r,e.$rotation=null,j(e)},Zo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?t[4]:0},qo=(e,t)=>{let r=e.$matrix;if(!r){const n=_(e);e.$matrix=r=n?new T(...n):new T}e.$x!==t&&(e.$x=r.tx=t,j(e))},jo=e=>{const t=e.$matrix?e.$matrix.rawData:_(e);return t?t[5]:0},ec=(e,t)=>{let r=e.$matrix;if(!r){const n=_(e);e.$matrix=r=n?new T(...n):new T}e.$y!==t&&(e.$y=r.ty=t,j(e))},he=(e,t,r,n,i)=>{const s=i[0],a=i[1],o=i[2],c=i[3],u=i[4],h=i[5],l=r*s+n*o+u,f=r*s+t*o+u,A=e*s+n*o+u,d=e*s+t*o+u,y=r*a+n*c+h,g=r*a+t*c+h,p=e*a+n*c+h,$=e*a+t*c+h;return re(Math.min(l,f,A,d),Math.min(y,g,p,$),Math.max(l,f,A,d),Math.max(y,g,p,$))},Oi=e=>{const t=e.graphics;return re(t.xMin,t.yMin,t.xMax,t.yMax)},wt=(e,t=null)=>{const r=Oi(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},ki=e=>re(0,0,e.videoWidth,e.videoHeight),Mt=(e,t=null)=>{const r=ki(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},Ui=e=>re(e.xMin,e.yMin,e.xMax,e.yMax),Bt=(e,t=null)=>{const r=Ui(e),n=_(e);if(!n){if(t){const s=he(r[0],r[1],r[2],r[3],t);return k(r),s}return r}const i=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),i},yt=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),i=n?t?T.multiply(t,n):n:t,s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{switch(!0){case e.isContainerEnabled:return yt(e);case e.isShape:return wt(e);case e.isText:return Bt(e);case e.isVideo:return Mt(e);default:return re(0,0,0,0)}},tc=e=>{const t=Gi(e),r=Math.abs(t[2]-t[0]);switch(k(t),!0){case r===0:case r===1/0:case r===-1/0:return 0;default:return Math.round(r*100)/100}},_i=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e);let i=t;n&&(i=t?T.multiply(t,n):n);const s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{switch(!0){case e.isContainerEnabled:return _i(e);case e.isShape:return Oi(e);case e.isText:return Ui(e);case e.isVideo:return ki(e);default:return re(0,0,0,0)}},rc=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;const r=tt(e);let n=Math.abs(r[2]-r[0]);switch(!0){case n===0:case n===1/0:case n===-1/0:return;default:n=Math.round(n*100)/100;break}Pi(e,t/n)},nc=(e,t)=>{const r=e.concatenatedMatrix,n=new se(t.x*r.a+t.y*r.c+r.tx,t.x*r.b+t.y*r.d+r.ty);return T.release(r.rawData),n},ic=(e,t)=>{const r=e.concatenatedMatrix;r.invert();const n=new se(t.x*r.a+t.y*r.c+r.tx,t.x*r.b+t.y*r.d+r.ty);return T.release(r.rawData),n},sc=e=>{const t=Gi(e),r=Math.abs(t[3]-t[1]);switch(k(t),!0){case r===0:case r===1/0:case r===-1/0:return 0;default:return Math.round(r*100)/100}},ac=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;const r=tt(e);let n=Math.abs(r[3]-r[1]);switch(!0){case n===0:case n===1/0:case n===-1/0:return;default:n=Math.round(n*100)/100;break}Ri(e,t/n)},oc=e=>{const t=e.parent;t&&t.removeChild(e)},cc=(e,t=null)=>{const r=e.concatenatedMatrix,n=tt(e),i=he(n[0],n[1],n[2],n[3],r.rawData);if(k(n),T.release(r.rawData),!t){const c=new be(i[0],i[1],Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1]));return k(i),c}const s=t.concatenatedMatrix;s.invert();const a=he(i[0],i[1],i[2],i[3],s.rawData);k(i),T.release(s.rawData);const o=new be(a[0],a[1],Math.abs(a[2]-a[0]),Math.abs(a[3]-a[1]));return k(a),o},lc=(e,t)=>{const r=tt(e),n=e.concatenatedMatrix,i=he(r[0],r[1],r[2],r[3],n.rawData);k(r),T.release(n.rawData);const s=tt(t),a=t.concatenatedMatrix,o=he(s[0],s[1],s[2],s[3],a.rawData);k(s),T.release(a.rawData);const c=Math.max(i[0],o[0]),u=Math.max(i[1],o[1]),h=Math.min(i[2],o[2]),l=Math.min(i[3],o[3]);return k(i),k(o),h-c>=0&&l-u>=0};class Xt{_$bitmapData;_$matrix;_$repeat;_$smooth;constructor(t,r=null,n=!0,i=!1){this._$bitmapData=t,this._$matrix=r,this._$repeat=n,this._$smooth=i}clone(){return new Xt(this._$bitmapData.clone(),this._$matrix?this._$matrix.clone():null,this._$repeat,this._$smooth)}toArray(){return z(this._$bitmapData,this._$matrix,this._$repeat,this._$smooth)}}class zt{_$type;_$colors;_$alphas;_$ratios;_$matrix;_$spreadMethod;_$interpolationMethod;_$focalPointRatio;_$colorStops;constructor(t,r,n,i,s=null,a="pad",o="rgb",c=0){this._$type=t,this._$colors=r,this._$alphas=n,this._$ratios=i,this._$matrix=s,this._$spreadMethod=a,this._$interpolationMethod=o,this._$focalPointRatio=c,this._$colorStops=z()}get colorStops(){if(!this._$colorStops.length){const t=Math.min(Math.min(this._$alphas.length,this._$colors.length),this._$ratios.length);for(let r=0;r>>16&255,G:i>>>8&255,B:i&255,A:this._$alphas[r]*255&255}}}return this._$colorStops}toArray(){return z(this._$type,this.colorStops,this._$matrix?this._$matrix.rawData:xt,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}clone(){return new zt(this._$type,this._$colors.slice(),this._$alphas.slice(),this._$ratios.slice(),this._$matrix?this._$matrix.clone():null,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}}const uc=(e,t=0,r=0)=>{e.xMin=Math.min(e.xMin,t),e.xMax=Math.max(e.xMax,t),e.yMin=Math.min(e.yMin,r),e.yMax=Math.max(e.yMax,r)},Rn=(e,t=0,r=0,n=0,i=0,s=0,a="none")=>{e.xMin=Math.min(e.xMin,Math.min(t,n)),e.xMax=Math.max(e.xMax,Math.max(t,n)),e.yMin=Math.min(e.yMin,Math.min(r,i)),e.yMax=Math.max(e.yMax,Math.max(r,i));const o=n-t,c=i-r,u=Math.sqrt(o*o+c*c);if(!u)return;const h=o/u,l=c/u,f=-l,A=h,d=s/2,y=Math.min(t+f*d,t-f*d,n+f*d,n-f*d),g=Math.max(t+f*d,t-f*d,n+f*d,n-f*d),p=Math.min(r+A*d,r-A*d,i+A*d,i-A*d),$=Math.max(r+A*d,r-A*d,i+A*d,i-A*d);if(e.xMin=Math.min(e.xMin,y),e.xMax=Math.max(e.xMax,g),e.yMin=Math.min(e.yMin,p),e.yMax=Math.max(e.yMax,$),a==="round"||a==="square"){const w=t+d*-h,I=r+d*-l,P=Math.min(w+d*h+d*f,w-d*h+d*f,w+d*h-d*f,w-d*h-d*f),W=Math.max(w+d*h+d*f,w-d*h+d*f,w+d*h-d*f,w-d*h-d*f),C=Math.min(I+d*l+d*A,I+d*l-d*A,I-d*l-d*A,I-d*l+d*A),R=Math.max(I+d*l+d*A,I+d*l-d*A,I-d*l-d*A,I-d*l+d*A);e.xMin=Math.min(e.xMin,P),e.xMax=Math.max(e.xMax,W),e.yMin=Math.min(e.yMin,C),e.yMax=Math.max(e.yMax,R)}},ot=(e,t,r=0,n=0,i=0,s="none",...a)=>{for(let o=0;o{e.isConfirmed=!1,t&&n&&n.push(...s),r&&i&&i.push(...s)},hc=(e,t,r,n,i)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0,n=Math.round(n),i=Math.round(i);const s=n/2,a=i/2,o=t+s,c=r+a,u=t+n,h=r+i,l=4/3*(Math.SQRT2-1),f=l*s,A=l*a;return e.moveTo(o,r).cubicCurveTo(o+f,r,u,c-A,u,c).cubicCurveTo(u,c+A,o+f,h,o,h).cubicCurveTo(o-f,h,t,c+A,t,c).cubicCurveTo(t,c-A,o-f,r,o,r)},fc=(e,t,r,n,i)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0;const s=Math.round(t+n),a=Math.round(r+i);return e.moveTo(t,r).lineTo(t,a).lineTo(s,a).lineTo(s,r).lineTo(t,r)},dc=(e,t,r,n,i,s,a=NaN)=>{t=+t||0,r=+r||0,n=+n||0,i=+i||0,s=+s||0,a=+a||s,n=Math.round(n),i=Math.round(i),s=Math.round(s),a=Math.round(a);const o=s/2,c=a/2,u=4/3*(Math.SQRT2-1),h=u*o,l=u*c,f=t+o,A=t+n,d=A-o,y=r+c,g=r+i,p=g-c;return e.moveTo(f,r).lineTo(d,r).cubicCurveTo(d+h,r,A,y-l,A,y).lineTo(A,p).cubicCurveTo(A,p+l,d+h,g,d,g).lineTo(f,g).cubicCurveTo(f-h,g,t,p+l,t,p).lineTo(t,y).cubicCurveTo(t,y-l,f-h,r,f,r)},Lt=e=>{if(!e)return[];const t=z();for(let r=0;rl.ratio-f.ratio);for(let l=0;l0&&r>0}beginBitmapFill(t,r=null,n=!0,i=!1){return this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z()),this._$maxAlpha=1,this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(M.BEGIN_PATH),this._$fillType=M.BITMAP_FILL,this._$fillBitmap=new Xt(t,r,n,i),this}beginFill(t=0,r=1){this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z()),typeof t=="string"&&(t=Or(t)),t=me(t,0,16777215,0),r=me(r,0,1,1),this._$maxAlpha=Math.max(this._$maxAlpha,r),this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(M.BEGIN_PATH),this._$fillType=M.FILL_STYLE;const n=t>>>16&255,i=t>>>8&255,s=t&255;return this._$fillColor=n<<24|i<<16|s<<8|r*255,this}beginGradientFill(t,r,n,i,s=null,a="pad",o="rgb",c=0){this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z());for(let u=0;uthis._$fills.length)return this;switch(this.$recodes||(this.$recodes=z()),(this._$fills[2]!==this._$fills[this._$fills.length-2]||this._$fills[3]!==this._$fills[this._$fills.length-1])&&this._$fills.push(M.LINE_TO,this._$fills[2],this._$fills[3]),this.$recodes.push(...this._$fills),oe(this._$fills),this._$fills=null,this._$fillType){case M.FILL_STYLE:this.$recodes.push(this._$fillType,this._$fillColor>>>24&255,this._$fillColor>>>16&255,this._$fillColor>>>8&255,this._$fillColor&255,M.END_FILL);break;case M.GRADIENT_FILL:this._$fillGradient&&this.$recodes.push(this._$fillType,...this._$fillGradient.toArray());break;case M.BITMAP_FILL:this._$fillBitmap&&this.$recodes.push(this._$fillType,...this._$fillBitmap.toArray());break}return this._$fillType=0,this._$fillColor=0,this._$fillGradient=null,this._$fillBitmap=null,this._$hasFillEnabled=!1,this}endLine(){if(!this._$hasLineEnabled||!this._$lines)return this;switch(this.$recodes||(this.$recodes=z()),this.$recodes.push(...this._$lines),oe(this._$lines),this._$lines=null,this._$lineType){case M.STROKE_STYLE:this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,this._$lineColor>>>24&255,this._$lineColor>>>16&255,this._$lineColor>>>8&255,this._$lineColor&255,M.END_STROKE);break;case M.GRADIENT_STROKE:this._$lineGradient&&this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,...this._$lineGradient.toArray());break;case M.BITMAP_STROKE:this._$fillBitmap&&this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,...this._$fillBitmap.toArray());break}return this._$lineType=0,this._$lineWidth=0,this._$lineGradient=null,this._$lineColor=0,this._$caps="none",this._$joints="round",this._$miterLimit=0,this._$hasLineEnabled=!1,this}lineBitmapStyle(t,r=null,n=!0,i=!1){return this._$hasLineEnabled?(this._$lines||(this._$lines=z()),this._$maxAlpha=1,this._$hasLineEnabled=!0,this._$isBeginning=!0,this._$lines.push(M.BEGIN_PATH),this._$lineType=M.BITMAP_STROKE,this._$fillBitmap=new Xt(t,r,n,i),this):this}lineGradientStyle(t,r,n,i,s=null,a="pad",o="rgb",c=0){if(!this._$hasLineEnabled)return this;this._$lines||(this._$lines=z());for(let u=0;u>>16&255,c=r>>>8&255,u=r&255;return this._$lineColor=o<<24|c<<16|u<<8|n*255,this._$lineWidth=t,this._$caps=`${i}`,this._$joints=`${s}`,this._$joints==="miter"&&(this._$miterLimit=a),this}lineTo(t,r){return t=+t||0,r=+r||0,this._$positionX===t&&this._$positionY===r?this:(ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r),ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.LINE_TO,t,r),this._$positionX=t,this._$positionY=r,this)}moveTo(t,r){t=+t||0,r=+r||0,this._$positionX=t,this._$positionY=r,ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r);let n=!1;return this._$hasFillEnabled&&this._$fills&&this._$fills[this._$fills.length-3]===M.MOVE_TO&&(n=!0,this._$fills[this._$fills.length-2]=t,this._$fills[this._$fills.length-1]=r),this._$hasLineEnabled&&this._$lines&&this._$lines[this._$lines.length-3]===M.MOVE_TO&&(n=!0,this._$lines[this._$lines.length-2]=t,this._$lines[this._$lines.length-1]=r),n||ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.MOVE_TO,t,r),this}get buffer(){if(this.isConfirmed&&this._$buffer)return this._$buffer;this._$hasLineEnabled&&this.endLine(),this._$hasFillEnabled&&this.endFill();const t=Lt(this.$recodes);return this._$buffer=new Float32Array(t),oe(t),this.isConfirmed=!0,this._$buffer}set buffer(t){this._$buffer=t,this.isConfirmed=!0,this._$isBeginning=!0,this._$maxAlpha=1}}const Ac=(e,t,r)=>{for(let n=0;n{const i=e.graphics,s=i.xMax-i.xMin,a=i.yMax-i.yMin;if(s<=0||a<=0)return!1;const o=_(e),c=o?T.multiply(r,o):r;t.beginPath(),t.setTransform(c[0],c[1],c[2],c[3],c[4],c[5]);let u=!1;return i.buffer.length?u=Ac(t,i.buffer,n):(t.moveTo(0,0),t.lineTo(s,0),t.lineTo(s,a),t.lineTo(0,a),t.lineTo(0,0),u=t.isPointInPath(n.x,n.y)),c!==r&&T.release(c),u},Yt=(e,t,r,n)=>{const i=Math.ceil(Math.abs(e.xMax-e.xMin)),s=Math.ceil(Math.abs(e.yMax-e.yMin));if(i<=0||s<=0)return!1;const a=_(e),o=a?T.multiply(r,a):r;return t.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,s),t.lineTo(0,s),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},Wt=(e,t,r,n)=>{const i=e.videoWidth,s=e.videoHeight;if(i<=0||s<=0)return!1;const a=_(e),o=a?T.multiply(r,a):r;return t.beginPath(),t.setTransform(o[0],o[1],o[2],o[3],o[4],o[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,s),t.lineTo(0,s),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},He=(e,t,r,n,i=!0)=>{const s=e.children;if(!s.length)return!1;const a=_(e),o=a?T.multiply(r,a):r,c=z(),u=z(),h=io();let l=0,f=0;for(let g=0;gl&&(f=0,l=0),f&&h.set(p.instanceId,f),u.push(p))}}const A=e.mouseChildren&&i;if(e.isSprite&&e.hitArea){const g=He(e.hitArea,t,o,n,A);return g&&A&&e.mouseEnabled&&(e.buttonMode&&e.useHandCursor&&(n.pointer="pointer"),n.hit||(n.hit=e)),g}let d=!1;const y=e.mask;if(y){let g=!1;switch(!0){case y.isContainerEnabled:g=He(y,t,o,n,A);break;case y.isShape:g=Nt(y,t,o,n);break;case y.isText:g=Yt(y,t,o,n);break;case y.isVideo:g=Wt(y,t,o,n);break}if(!g)return!1}for(;u.length;){const g=u.pop();if(!g||g.isMask)continue;if(h.has(g.instanceId)){const $=h.get(g.instanceId);if(!$)continue;const w=c[$];if(!w)continue;let I=!1;switch(!0){case w.isContainerEnabled:I=He(w,t,o,n,A);break;case w.isShape:I=Nt(w,t,o,n);break;case w.isText:I=Yt(w,t,o,n);break;case w.isVideo:I=Wt(w,t,o,n);break}if(!I)continue}let p=!1;switch(!0){case g.isContainerEnabled:p=He(g,t,o,n,A);break;case g.isShape:p=Nt(g,t,o,n);break;case g.isText:p=Yt(g,t,o,n);break;case g.isVideo:p=Wt(g,t,o,n);break}if(p){if(d=!0,!A)break;if(g.isInteractive&&g.mouseEnabled){if(n.pointer==="auto")switch(!0){case g.isText:g.type==="input"&&(n.pointer="text");break;case g.isSprite:g.buttonMode&&g.useHandCursor&&(n.pointer="pointer");break;default:n.pointer="pointer";break}n.hit||(n.hit=g);break}}}return oe(c),oe(u),so(h),o!==r&&T.release(o),d},Ge={x:0,y:0,pointer:"",hit:null},pc=(e,t,r,n=!1)=>{if(n){const h=e.parent,l=h?h.concatenatedMatrix.rawData:xt;switch(Ie.setTransform(1,0,0,1,0,0),Ie.beginPath(),Ge.x=t,Ge.y=r,Ge.hit=null,!0){case e.isContainerEnabled:return He(e,Ie,l,Ge);case e.isShape:return Nt(e,Ie,l,Ge);case e.isText:return Yt(e,Ie,l,Ge);case e.isVideo:return Wt(e,Ie,l,Ge);default:return!1}}const i=tt(e),s=_(e),a=he(i[0],i[1],i[2],i[3],s||xt);k(i);const o=new be(a[0],a[1],Math.abs(a[2]-a[0]),Math.abs(a[3]-a[1]));k(a);const c=e.parent,u=c?c.globalToLocal(new se(t,r)):new se(t,r);return o.containsPoint(u)},mc=e=>{const t=_(e);return t?new T(t[0],t[1],t[2],t[3],t[4],t[5]):new T},gc=e=>{const t=Ve(e);return t?new U(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]):new U};class hr extends nt{instanceId;dictionaryId;isSprite;isInteractive;isContainerEnabled;isTimelineEnabled;isShape;isVideo;isText;placeId;placeObject;characterId;clipDepth;name;startFrame;endFrame;changed;$added;$addedToStage;uniqueKey;$matrix;$colorTransform;$filters;$blendMode;$scaleX;$scaleY;$rotation;$x;$y;$alpha;$cache;_$scale9Grid;_$visible;_$variables;isMask;parent;constructor(){super(),this.instanceId=yi(),this.dictionaryId=-1,this.uniqueKey="",this.isSprite=!1,this.isContainerEnabled=!1,this.isTimelineEnabled=!1,this.isShape=!1,this.isVideo=!1,this.isText=!1,this.isInteractive=!1,this.placeId=-1,this.placeObject=null,this.characterId=-1,this.clipDepth=0,this.name="",this.startFrame=1,this.endFrame=0,this.parent=null,this.isMask=!1,this.changed=!0,this.$added=!1,this.$addedToStage=!1,this.$matrix=null,this.$colorTransform=null,this.$filters=null,this.$blendMode=null,this._$visible=!0,this._$scale9Grid=null,this._$variables=null,this.$x=null,this.$y=null,this.$alpha=null,this.$scaleX=null,this.$scaleY=null,this.$rotation=null,this.$cache=null}get concatenatedMatrix(){return uo(this)}get alpha(){return ho(this)}set alpha(t){fo(this,t)}get blendMode(){return Wo(this)}set blendMode(t){Vo(this,t)}get filters(){return No(this)}set filters(t){Yo(this,t)}get dropTarget(){return lo()}get height(){return sc(this)}set height(t){ac(this,t)}get loaderInfo(){return Dt.has(this)?Dt.get(this):null}get colorTransform(){return gc(this)}set colorTransform(t){this.$colorTransform=t}get matrix(){return mc(this)}set matrix(t){this.$matrix=t}get mouseX(){return this.globalToLocal(bt).x}get mouseY(){return this.globalToLocal(bt).y}get root(){return we.has(this)?we.get(this):null}get rotation(){return this.$rotation===null?Qo(this):this.$rotation}set rotation(t){zo(this,t)}get scale9Grid(){return this._$scale9Grid}set scale9Grid(t){this._$scale9Grid!==t&&(this._$scale9Grid=t,j(this))}get scaleX(){return this.$scaleX===null?Ho(this):this.$scaleX}set scaleX(t){Pi(this,t)}get scaleY(){return this.$scaleY===null?Jo(this):this.$scaleY}set scaleY(t){Ri(this,t)}get visible(){return this._$visible}set visible(t){t=!!t,this._$visible!==t&&(this._$visible=t,j(this))}get width(){return tc(this)}set width(t){rc(this,t)}get x(){return this.$x===null?Zo(this):this.$x}set x(t){qo(this,t)}get y(){return this.$y===null?jo(this):this.$y}set y(t){ec(this,t)}getBounds(t=null){return cc(this,t)}globalToLocal(t){return ic(this,t)}hitTestObject(t){return lc(this,t)}hitTestPoint(t,r,n=!1){return pc(this,t,r,n)}localToGlobal(t){return nc(this,t)}getLocalVariable(t){if(!this._$variables)return null;if(this._$variables.has(t))return this._$variables.get(t)}setLocalVariable(t,r){this._$variables||(this._$variables=new Map),this._$variables.set(t,r)}hasLocalVariable(t){return this._$variables?this._$variables.has(t):!1}deleteLocalVariable(t){this._$variables&&this._$variables.has(t)&&(this._$variables.delete(t),this._$variables.size||(this._$variables=null))}getGlobalVariable(t){return Ue.has(t)?Ue.get(t):null}setGlobalVariable(t,r){Ue.set(t,r)}hasGlobalVariable(t){return Ue.has(t)}deleteGlobalVariable(t){Ue.has(t)&&Ue.delete(t)}clearGlobalVariable(){return Ue.clear()}remove(){oc(this)}$syncLoaderInfo(t){Dt.set(this,t)}}const Di=e=>{const t=e.children;for(let r=0;r{e.$addedToStage||!ge.has(e.instanceId)||(e.$addedToStage=!0,e.willTrigger(x.ADDED_TO_STAGE)&&e.dispatchEvent(new x(x.ADDED_TO_STAGE)))},Ni=e=>{const t=e.children;for(let r=0;r{e.$added||(e.$added=!0,e.willTrigger(x.ADDED)&&e.dispatchEvent(new x(x.ADDED,!0)))},On=(e,t,r=-1)=>{const n=t.parent;n&&n.removeChild(t);const i=e.children;return 0>r?i.push(t):i.splice(r,0,t),e.$container=null,t.parent=e,ge.has(e.instanceId)&&(we.set(t,e.root),ge.add(t.instanceId),t.isContainerEnabled&&Di(t)),bc(t),ge.has(e.instanceId)&&(Li(t),t.isContainerEnabled&&Ni(t)),j(t),t},Yi=e=>{const t=e.children;for(let r=0;r{e.$added&&(e.$added=!1,e.willTrigger(x.REMOVED)&&e.dispatchEvent(new x(x.REMOVED,!0)))},Wi=e=>{!e.$addedToStage||!ge.has(e.instanceId)||(e.$addedToStage=!1,e.willTrigger(x.REMOVED_FROM_STAGE)&&e.dispatchEvent(new x(x.REMOVED_FROM_STAGE)),e.uniqueKey&&O.has(e.uniqueKey)&&O.removeTimer(e.uniqueKey))},un=e=>{const t=e.children;for(let r=0;r{const r=t.parent;if(r&&r.instanceId!==e.instanceId)return;const n=e.children,i=n.indexOf(t);i>-1&&n.splice(i,1),e.$container=null,t.hasEventListener(x.ENTER_FRAME)&&t.removeAllEventListener(x.ENTER_FRAME),t.hasEventListener(V.KEY_DOWN)&&t.removeAllEventListener(V.KEY_DOWN),t.hasEventListener(V.KEY_UP)&&t.removeAllEventListener(V.KEY_UP),xc(t),ge.has(e.instanceId)&&(Wi(t),t.isContainerEnabled&&un(t)),ge.has(e.instanceId)&&(we.delete(t),ge.delete(t.instanceId),t.isVideo&&t.pause(),t.isContainerEnabled&&Yi(t)),t.parent=null,j(e)},Vi=(e,t)=>{const r=e.children;return t in r?r[t]:null},yc=(e,t)=>{const r=Vi(e,t);r&&hn(e,r)},$c=(e,t)=>{if(e.instanceId===t.instanceId)return!0;const r=e.children;for(let n=0;n{if(!t)return null;const r=e.children;for(let n=0;n{const r=e.children.slice();if(r.length)for(let n=0;n{const n=e.getChildIndex(t);if(n===-1||n===r)return;const i=e.children;i.splice(n,1),i.splice(r,0,t),j(e)},Bc=(e,t,r)=>{const n=e.getChildIndex(t),i=e.getChildIndex(r);if(n===-1||i===-1)return;const s=e.children;s[n]=r,s[i]=t,j(e)},Tc=(e,t,r)=>{const n=e.children,i=n[t],s=n[r];!i||!s||(n[t]=s,n[r]=i,j(e))};class fn extends hr{mouseEnabled;isInteractive;constructor(){super(),this.isInteractive=!0,this.mouseEnabled=!0}}class dn extends fn{_$children;_$mask;mouseChildren;$container;isContainerEnabled;constructor(){super(),this.isContainerEnabled=!0,this.mouseChildren=!0,this._$mask=null,this._$children=z(),this.$container=null}get children(){return this._$children}get numChildren(){return this.children.length}get mask(){return this._$mask}set mask(t){t!==this._$mask&&(this._$mask&&(this._$mask.isMask=!1,this._$mask=null),t&&(t.isMask=!0,this._$mask=t),j(this))}addChild(t){return On(this,t)}addChildAt(t,r){return On(this,t,r)}contains(t){return $c(this,t)}getChildAt(t){return Vi(this,t)}getChildByName(t){return vc(this,t)}getChildIndex(t){return this.children.indexOf(t)}removeChild(t){hn(this,t)}removeChildAt(t){yc(this,t)}removeChildren(...t){wc(this,t)}setChildIndex(t,r){Mc(this,t,r)}swapChildren(t,r){Bc(this,t,r)}swapChildrenAt(t,r){Tc(this,t,r)}}class Ki extends nt{name;frame;constructor(t,r){super(),this.name=`${t}`,this.frame=r|0}}class Sc extends nt{id;content;data;url;format;constructor(){super(),this.id=yi(),this.url="",this.content=null,this.data=null,this.format="json"}}const Ic=(e,t=!1,r=null)=>{const n=e.parent?e.parent.globalToLocal(bt):e.globalToLocal(bt);e.$lockCenter=t,e.$offsetX=e.x-n.x,e.$offsetY=e.y-n.y,e.$boundedRect=r,Bi(e)},Cc=e=>{e.$lockCenter=!1,e.$offsetX=0,e.$offsetY=0,e.$boundedRect=null,Bi(null)};class An extends dn{buttonMode;useHandCursor;isSprite;hitArea;_$soundTransform;$offsetX=0;$offsetY=0;$lockCenter=!1;$boundedRect=null;constructor(){super(),this.isSprite=!0,this.buttonMode=!1,this.useHandCursor=!0,this.hitArea=null,this.$offsetX=0,this.$offsetY=0,this.$lockCenter=!1,this.$boundedRect=null,this._$soundTransform=null}get soundTransform(){return this._$soundTransform}set soundTransform(t){this._$soundTransform=t}startDrag(t=!1,r=null){Ic(this,t,r)}stopDrag(){Cc(this)}}const Qi=e=>{e.isBitmap=!1,e.$bitmapBuffer=null,e.graphics.clear(),e.uniqueKey!==""&&O.has(e.uniqueKey)&&(O.removeById(e.uniqueKey),O.$removeIds.push(+e.uniqueKey)),j(e)},Xi=(e,t,r,n)=>{Qi(e),e.isBitmap=!0,e.$bitmapBuffer=n,e.graphics.xMin=0,e.graphics.yMin=0,e.graphics.xMax=t,e.graphics.yMax=r},Fc=(e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.addEventListener("load",()=>{const n=r.width,i=r.height,s=O.getCanvas();s.width=n,s.height=i;const a=s.getContext("2d",{willReadFrequently:!0});a.drawImage(r,0,0,n,i),Xi(e,n,i,new Uint8Array(a.getImageData(0,0,n,i).data)),O.destroy(a),e.hasEventListener(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE))}),r.src=t},Ec=(e,t)=>{const r=e.graphics,n=Math.ceil(Math.abs(t.bounds.xMax-t.bounds.xMin)),i=Math.ceil(Math.abs(t.bounds.yMax-t.bounds.yMin));switch(!0){case t.bitmapId>0:{const a=e.loaderInfo.data?.characters[t.bitmapId];if(!a)break;e.isBitmap=!0,a.imageBuffer||(a.imageBuffer=new Uint8Array(a.buffer),a.buffer=null);const o=Math.ceil(Math.abs(a.bounds.xMax-a.bounds.xMin)),c=Math.ceil(Math.abs(a.bounds.yMax-a.bounds.yMin));if(t.grid){if(t.recodes){const u=t.recodes.slice(0);u.splice(-6,6);const h=new _e(o,c);h.buffer=a.imageBuffer,u.push(M.BITMAP_FILL,h,null,!0,!1,9);const l=Lt(u);r.buffer=new Float32Array(l),oe(u),oe(l)}}else if(n===o&&i===c)e.setBitmapBuffer(Math.ceil(Math.abs(a.bounds.xMax-a.bounds.xMin)),Math.ceil(Math.abs(a.bounds.yMax-a.bounds.yMin)),a.imageBuffer);else{const u=new _e(o,c);if(u.buffer=a.imageBuffer,t.recodes)if(t.recodes[t.recodes.length-10]===M.BITMAP_STROKE){const l=t.recodes.slice(0);l.splice(-5,5),l.push(u,null,!0,!1);const f=Lt(l);r.buffer=new Float32Array(f),oe(l),oe(f)}else r.beginBitmapFill(u).drawRect(0,0,n,i)}}break;case t.inBitmap:{e.isBitmap=!0;const s=t.recodes,a=s[s.length-4];if(n===a.width&&i===a.height)e.setBitmapBuffer(a.width,a.height,a.buffer);else{const o=new _e(a.width,a.height);o.buffer=a.buffer,r.beginBitmapFill(o).drawRect(0,0,n,i)}}break;case"buffer"in t:t.imageBuffer||(t.imageBuffer=new Uint8Array(t.buffer),t.buffer=null),e.setBitmapBuffer(Math.ceil(Math.abs(r.xMax-r.xMin)),Math.ceil(Math.abs(r.yMax-r.yMin)),t.imageBuffer);break;default:t.recodes&&(t.recodeBuffer=new Float32Array(Lt(t.recodes)),oe(t.recodes),t.recodes=null),t.recodeBuffer&&(r.buffer=t.recodeBuffer);break}r.xMin=t.bounds.xMin,r.xMax=t.bounds.xMax,r.yMin=t.bounds.yMin,r.yMax=t.bounds.yMax,t.grid&&(e.scale9Grid=new be(t.grid.x,t.grid.y,t.grid.w,t.grid.h))},Pc=(e,t)=>new Promise(r=>{const n=()=>{e.removeEventListener(x.COMPLETE,n),r()};e.addEventListener(x.COMPLETE,n),e.src=t});class $t extends hr{_$graphics;_$src;isShape;cacheKey;cacheParams;isBitmap;$bitmapBuffer;constructor(){super(),this.isShape=!0,this.cacheKey=0,this.cacheParams=z(0,0,0),this._$graphics=null,this._$src="",this.$bitmapBuffer=null,this.isBitmap=!1}static get namespace(){return"next2d.display.Shape"}get namespace(){return"next2d.display.Shape"}get graphics(){return this._$graphics||(this._$graphics=new M,co.set(this._$graphics,this)),this._$graphics}get src(){return this._$src}set src(t){this._$src!==t&&(this._$src=t,Fc(this,t))}load(t){return Pc(this,t)}get bitmapData(){const t=new _e(this.width,this.height);return this.$bitmapBuffer&&(t.buffer=this.$bitmapBuffer),t}clearBitmapBuffer(){Qi(this)}setBitmapBuffer(t,r,n){Xi(this,t,r,n)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),Ec(this,t)}}let zi=null;const kn=e=>{zi=e},ke=()=>zi,de=document.createElement("textarea");de.tabIndex=-1;let Me="";Me+="position: fixed;";Me+="top: 0;";Me+="left: 0;";Me+="font-size: 16px;";Me+="border: 0;";Me+="resize: none;";Me+="opacity: 0;";Me+="z-index: -1;";Me+="pointer-events: none;";de.setAttribute("style",Me);const _r=document.createElement("canvas");_r.width=_r.height=1;const De=_r.getContext("2d");let Hi=0;const Et=()=>Hi,dt=e=>{Hi=e},Rc=e=>De?(De.fillStyle=e,+`0x${De.fillStyle.slice(1)}`):0,et=e=>isNaN(+e)?Rc(`${e}`):+e,Oc=(e,t=1)=>({R:(e&16711680)>>16,G:(e&65280)>>8,B:e&255,A:t*255}),pt=(e,t,r,n=null)=>{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};let Ji;const Ht=()=>Ji,Zi=e=>{Ji=e},Je={x:0,y:0};class ue{align;bold;color;font;italic;leading;leftMargin;letterSpacing;rightMargin;size;underline;constructor(t=null,r=null,n=null,i=null,s=null,a=null,o=null,c=null,u=null,h=null,l=null){this.font=t,this.size=r,this.color=n,this.bold=i,this.italic=s,this.underline=a,this.align=o,this.leftMargin=c,this.rightMargin=u,this.leading=h,this.letterSpacing=l}clone(){return new ue(this.font,this.size,this.color,this.bold,this.italic,this.underline,this.align,this.leftMargin,this.rightMargin,this.leading,this.letterSpacing)}toObject(){return{font:this.font,size:this.size,color:et(this.color),bold:this.bold,italic:this.italic,underline:this.underline,align:this.align,leftMargin:this.leftMargin,rightMargin:this.rightMargin,leading:this.leading,letterSpacing:this.letterSpacing}}}const kc=e=>{e.align="left",e.bold=!1,e.color=0,e.font="Times New Roman",e.italic=!1,e.leading=0,e.leftMargin=0,e.letterSpacing=0,e.rightMargin=0,e.size=12,e.underline=!1},Uc=e=>{let t="";if(e.font&&(t+=`font-family: ${e.font};`),e.size&&(t+=`font-size: ${e.size}px;`),e.color){const r=Oc(et(e.color)),n=r.R.toString(16).padStart(2,"0"),i=r.G.toString(16).padStart(2,"0"),s=r.B.toString(16).padStart(2,"0");t+=`color: #${n}${i}${s};`}return e.bold&&(t+="font-weight: bold;"),e.italic&&(t+="font-style: italic;"),e.underline&&(t+="text-decoration: underline;"),e.align&&(t+=`text-align: ${e.align};`),e.leftMargin&&(t+=`margin-left: ${e.leftMargin}px;`),e.rightMargin&&(t+=`margin-right: ${e.rightMargin}px;`),e.leading&&(t+=`margin-bottom: ${e.leading}px;`),e.letterSpacing&&(t+=`letter-spacing: ${e.letterSpacing}px;`),t};class Gc{_$textWidth;_$textHeight;heightTable;ascentTable;widthTable;textTable;lineTable;constructor(){this._$textWidth=-1,this._$textHeight=-1,this.widthTable=[],this.heightTable=[],this.ascentTable=[],this.textTable=[],this.lineTable=[]}get textWidth(){if(this._$textWidth!==-1)return this._$textWidth;this._$textWidth=0;for(let t=0;t{let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t});function Dc(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=_c.get(e))!==null&&t!==void 0?t:e}function qi(e){const t=typeof atob=="function"?atob(e):typeof Buffer.from=="function"?Buffer.from(e,"base64").toString("binary"):new Buffer(e,"base64").toString("binary"),r=t.length&-2,n=new Uint16Array(r/2);for(let i=0,s=0;i=X.ZERO&&e<=X.NINE}function Yc(e){return e>=X.UPPER_A&&e<=X.UPPER_F||e>=X.LOWER_A&&e<=X.LOWER_F}function Wc(e){return e>=X.UPPER_A&&e<=X.UPPER_Z||e>=X.LOWER_A&&e<=X.LOWER_Z||Dr(e)}function Vc(e){return e===X.EQUALS||Wc(e)}var ne;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(ne||(ne={}));var $e;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})($e||($e={}));class Kc{constructor(t,r,n){this.decodeTree=t,this.emitCodePoint=r,this.errors=n,this.state=ne.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=$e.Strict,this.runConsumed=0}startEntity(t){this.decodeMode=t,this.state=ne.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(t,r){switch(this.state){case ne.EntityStart:return t.charCodeAt(r)===X.NUM?(this.state=ne.NumericStart,this.consumed+=1,this.stateNumericStart(t,r+1)):(this.state=ne.NamedEntity,this.stateNamedEntity(t,r));case ne.NumericStart:return this.stateNumericStart(t,r);case ne.NumericDecimal:return this.stateNumericDecimal(t,r);case ne.NumericHex:return this.stateNumericHex(t,r);case ne.NamedEntity:return this.stateNamedEntity(t,r)}}stateNumericStart(t,r){return r>=t.length?-1:(t.charCodeAt(r)|Gn)===X.LOWER_X?(this.state=ne.NumericHex,this.consumed+=1,this.stateNumericHex(t,r+1)):(this.state=ne.NumericDecimal,this.stateNumericDecimal(t,r))}stateNumericHex(t,r){for(;r>14;for(;r>7;if(this.runConsumed===0){const c=i&le.JUMP_TABLE;if(t.charCodeAt(r)!==c)return this.result===0?0:this.emitNotTerminatedNamedEntity();r++,this.excess++,this.runConsumed++}for(;this.runConsumed=t.length)return-1;const c=this.runConsumed-1,u=n[this.treeIndex+1+(c>>1)],h=c%2===0?u&255:u>>8&255;if(t.charCodeAt(r)!==h)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();r++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(o>>1),i=n[this.treeIndex],s=(i&le.VALUE_LENGTH)>>14}if(r>=t.length)break;const a=t.charCodeAt(r);if(a===X.SEMI&&s!==0&&(i&le.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);if(this.treeIndex=Qc(n,i,this.treeIndex+Math.max(1,s),a),this.treeIndex<0)return this.result===0||this.decodeMode===$e.Attribute&&(s===0||Vc(a))?0:this.emitNotTerminatedNamedEntity();if(i=n[this.treeIndex],s=(i&le.VALUE_LENGTH)>>14,s!==0){if(a===X.SEMI)return this.emitNamedEntityData(this.treeIndex,s,this.consumed+this.excess);this.decodeMode!==$e.Strict&&(i&le.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}r++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var t;const{result:r,decodeTree:n}=this,i=(n[r]&le.VALUE_LENGTH)>>14;return this.emitNamedEntityData(r,i,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,r,n){const{decodeTree:i}=this;return this.emitCodePoint(r===1?i[t]&~(le.VALUE_LENGTH|le.FLAG13):i[t+1],n),r===3&&this.emitCodePoint(i[t+2],n),n}end(){var t;switch(this.state){case ne.NamedEntity:return this.result!==0&&(this.decodeMode!==$e.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case ne.NumericDecimal:return this.emitNumericEntity(0,2);case ne.NumericHex:return this.emitNumericEntity(0,3);case ne.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case ne.EntityStart:return 0}}}function Qc(e,t,r,n){const i=(t&le.BRANCH_LENGTH)>>7,s=t&le.JUMP_TABLE;if(i===0)return s!==0&&n===s?r:-1;if(s){const u=n-s;return u<0||u>=i?-1:e[r+u]-1}const a=i+1>>1;let o=0,c=i-1;for(;o<=c;){const u=o+c>>>1,h=u>>1,f=e[r+h]>>(u&1)*8&255;if(fn)c=u-1;else return e[r+a+u]}return-1}var E;(function(e){e[e.Tab=9]="Tab",e[e.NewLine=10]="NewLine",e[e.FormFeed=12]="FormFeed",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.ExclamationMark=33]="ExclamationMark",e[e.Number=35]="Number",e[e.Amp=38]="Amp",e[e.SingleQuote=39]="SingleQuote",e[e.DoubleQuote=34]="DoubleQuote",e[e.Dash=45]="Dash",e[e.Slash=47]="Slash",e[e.Zero=48]="Zero",e[e.Nine=57]="Nine",e[e.Semi=59]="Semi",e[e.Lt=60]="Lt",e[e.Eq=61]="Eq",e[e.Gt=62]="Gt",e[e.Questionmark=63]="Questionmark",e[e.UpperA=65]="UpperA",e[e.LowerA=97]="LowerA",e[e.UpperF=70]="UpperF",e[e.LowerF=102]="LowerF",e[e.UpperZ=90]="UpperZ",e[e.LowerZ=122]="LowerZ",e[e.LowerX=120]="LowerX",e[e.OpeningSquareBracket=91]="OpeningSquareBracket"})(E||(E={}));var m;(function(e){e[e.Text=1]="Text",e[e.BeforeTagName=2]="BeforeTagName",e[e.InTagName=3]="InTagName",e[e.InSelfClosingTag=4]="InSelfClosingTag",e[e.BeforeClosingTagName=5]="BeforeClosingTagName",e[e.InClosingTagName=6]="InClosingTagName",e[e.AfterClosingTagName=7]="AfterClosingTagName",e[e.BeforeAttributeName=8]="BeforeAttributeName",e[e.InAttributeName=9]="InAttributeName",e[e.AfterAttributeName=10]="AfterAttributeName",e[e.BeforeAttributeValue=11]="BeforeAttributeValue",e[e.InAttributeValueDq=12]="InAttributeValueDq",e[e.InAttributeValueSq=13]="InAttributeValueSq",e[e.InAttributeValueNq=14]="InAttributeValueNq",e[e.BeforeDeclaration=15]="BeforeDeclaration",e[e.InDeclaration=16]="InDeclaration",e[e.InProcessingInstruction=17]="InProcessingInstruction",e[e.BeforeComment=18]="BeforeComment",e[e.CDATASequence=19]="CDATASequence",e[e.InSpecialComment=20]="InSpecialComment",e[e.InCommentLike=21]="InCommentLike",e[e.BeforeSpecialS=22]="BeforeSpecialS",e[e.BeforeSpecialT=23]="BeforeSpecialT",e[e.SpecialStartSequence=24]="SpecialStartSequence",e[e.InSpecialTag=25]="InSpecialTag",e[e.InEntity=26]="InEntity"})(m||(m={}));function Se(e){return e===E.Space||e===E.NewLine||e===E.Tab||e===E.FormFeed||e===E.CarriageReturn}function Pt(e){return e===E.Slash||e===E.Gt||Se(e)}function Xc(e){return e>=E.LowerA&&e<=E.LowerZ||e>=E.UpperA&&e<=E.UpperZ}var ve;(function(e){e[e.NoValue=0]="NoValue",e[e.Unquoted=1]="Unquoted",e[e.Single=2]="Single",e[e.Double=3]="Double"})(ve||(ve={}));const te={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97]),XmpEnd:new Uint8Array([60,47,120,109,112])};class zc{constructor({xmlMode:t=!1,decodeEntities:r=!0},n){this.cbs=n,this.state=m.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=m.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=t,this.decodeEntities=r,this.entityDecoder=new Kc(t?Nc:Lc,(i,s)=>this.emitCodePoint(i,s))}reset(){this.state=m.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=m.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(t){this.offset+=this.buffer.length,this.buffer=t,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.indexthis.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=m.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&t===E.Amp&&this.startEntity()}stateSpecialStartSequence(t){const r=this.sequenceIndex===this.currentSequence.length;if(!(r?Pt(t):(t|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!r){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=m.InTagName,this.stateInTagName(t)}stateInSpecialTag(t){if(this.sequenceIndex===this.currentSequence.length){if(t===E.Gt||Se(t)){const r=this.index-this.currentSequence.length;if(this.sectionStart=0)this.state=this.baseState,r===0&&(this.index-=1);else{if(t=t||(this.state===m.InCommentLike?this.currentSequence===te.CdataEnd?this.cbs.oncdata(this.sectionStart,t,0):this.cbs.oncomment(this.sectionStart,t,0):this.state===m.InTagName||this.state===m.BeforeAttributeName||this.state===m.BeforeAttributeValue||this.state===m.AfterAttributeName||this.state===m.InAttributeName||this.state===m.InAttributeValueSq||this.state===m.InAttributeValueDq||this.state===m.InAttributeValueNq||this.state===m.InClosingTagName||this.cbs.ontext(this.sectionStart,t))}emitCodePoint(t,r){this.baseState!==m.Text&&this.baseState!==m.InSpecialTag?(this.sectionStart0&&a.has(this.stack[0]);){const o=this.stack.shift();(n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,o,!0)}this.isVoidElement(t)||(this.stack.unshift(t),this.htmlMode&&(Nn.has(t)?this.foreignContext.unshift(!0):Yn.has(t)&&this.foreignContext.unshift(!1))),(s=(i=this.cbs).onopentagname)===null||s===void 0||s.call(i,t),this.cbs.onopentag&&(this.attribs={})}endOpenTag(t){var r,n;this.startIndex=this.openTagStart,this.attribs&&((n=(r=this.cbs).onopentag)===null||n===void 0||n.call(r,this.tagname,this.attribs,t),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(t){this.endIndex=t,this.endOpenTag(!1),this.startIndex=t+1}onclosetag(t,r){var n,i,s,a,o,c,u,h;this.endIndex=r;let l=this.getSlice(t,r);if(this.lowerCaseTagNames&&(l=l.toLowerCase()),this.htmlMode&&(Nn.has(l)||Yn.has(l))&&this.foreignContext.shift(),this.isVoidElement(l))this.htmlMode&&l==="br"&&((a=(s=this.cbs).onopentagname)===null||a===void 0||a.call(s,"br"),(c=(o=this.cbs).onopentag)===null||c===void 0||c.call(o,"br",{},!0),(h=(u=this.cbs).onclosetag)===null||h===void 0||h.call(u,"br",!1));else{const f=this.stack.indexOf(l);if(f!==-1)for(let A=0;A<=f;A++){const d=this.stack.shift();(i=(n=this.cbs).onclosetag)===null||i===void 0||i.call(n,d,A!==f)}else this.htmlMode&&l==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=r+1}onselfclosingtag(t){this.endIndex=t,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=t+1):this.onopentagend(t)}closeCurrentTag(t){var r,n;const i=this.tagname;this.endOpenTag(t),this.stack[0]===i&&((n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,i,!t),this.stack.shift())}onattribname(t,r){this.startIndex=t;const n=this.getSlice(t,r);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(t,r){this.attribvalue+=this.getSlice(t,r)}onattribentity(t){this.attribvalue+=Un(t)}onattribend(t,r){var n,i;this.endIndex=r,(i=(n=this.cbs).onattribute)===null||i===void 0||i.call(n,this.attribname,this.attribvalue,t===ve.Double?'"':t===ve.Single?"'":t===ve.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(t){const r=t.search(Zc);let n=r<0?t:t.substr(0,r);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(t,r){this.endIndex=r;const n=this.getSlice(t,r);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${i}`,`!${n}`)}this.startIndex=r+1}onprocessinginstruction(t,r){this.endIndex=r;const n=this.getSlice(t,r);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${i}`,`?${n}`)}this.startIndex=r+1}oncomment(t,r,n){var i,s,a,o;this.endIndex=r,(s=(i=this.cbs).oncomment)===null||s===void 0||s.call(i,this.getSlice(t,r-n)),(o=(a=this.cbs).oncommentend)===null||o===void 0||o.call(a),this.startIndex=r+1}oncdata(t,r,n){var i,s,a,o,c,u,h,l,f,A;this.endIndex=r;const d=this.getSlice(t,r-n);!this.htmlMode||this.options.recognizeCDATA?((s=(i=this.cbs).oncdatastart)===null||s===void 0||s.call(i),(o=(a=this.cbs).ontext)===null||o===void 0||o.call(a,d),(u=(c=this.cbs).oncdataend)===null||u===void 0||u.call(c)):((l=(h=this.cbs).oncomment)===null||l===void 0||l.call(h,`[CDATA[${d}]]`),(A=(f=this.cbs).oncommentend)===null||A===void 0||A.call(f)),this.startIndex=r+1}onend(){var t,r;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let n=0;n=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(t-this.bufferOffset,r-this.bufferOffset);for(;r-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,r-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(t){var r,n;if(this.ended){(n=(r=this.cbs).onerror)===null||n===void 0||n.call(r,new Error(".write() after done!"));return}this.buffers.push(t),this.tokenizer.running&&(this.tokenizer.write(t),this.writeIndex++)}end(t){var r,n;if(this.ended){(n=(r=this.cbs).onerror)===null||n===void 0||n.call(r,new Error(".end() after done!"));return}t&&this.write(t),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(t){this.children=t}}class rs extends mn{constructor(){super(...arguments),this.type=G.CDATA}get nodeType(){return 4}}class Nr extends mn{constructor(){super(...arguments),this.type=G.Root}get nodeType(){return 9}}class ns extends mn{constructor(t,r,n=[],i=t==="script"?G.Script:t==="style"?G.Style:G.Tag){super(n),this.name=t,this.attribs=r,this.type=i}get nodeType(){return 1}get tagName(){return this.name}set tagName(t){this.name=t}get attributes(){return Object.keys(this.attribs).map(t=>{var r,n;return{name:t,value:this.attribs[t],namespace:(r=this["x-attribsNamespace"])===null||r===void 0?void 0:r[t],prefix:(n=this["x-attribsPrefix"])===null||n===void 0?void 0:n[t]}})}}function el(e){return jc(e)}function tl(e){return e.type===G.CDATA}function rl(e){return e.type===G.Text}function nl(e){return e.type===G.Comment}function il(e){return e.type===G.Directive}function sl(e){return e.type===G.Root}function is(e,t=!1){let r;if(rl(e))r=new Lr(e.data);else if(nl(e))r=new es(e.data);else if(el(e)){const n=t?Cr(e.children):[],i=new ns(e.name,{...e.attribs},n);n.forEach(s=>s.parent=i),e.namespace!=null&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]={...e["x-attribsNamespace"]}),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]={...e["x-attribsPrefix"]}),r=i}else if(tl(e)){const n=t?Cr(e.children):[],i=new rs(n);n.forEach(s=>s.parent=i),r=i}else if(sl(e)){const n=t?Cr(e.children):[],i=new Nr(n);n.forEach(s=>s.parent=i),e["x-mode"]&&(i["x-mode"]=e["x-mode"]),r=i}else if(il(e)){const n=new ts(e.name,e.data);e["x-name"]!=null&&(n["x-name"]=e["x-name"],n["x-publicId"]=e["x-publicId"],n["x-systemId"]=e["x-systemId"]),r=n}else throw new Error(`Not implemented yet: ${e.type}`);return r.startIndex=e.startIndex,r.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(r.sourceCodeLocation=e.sourceCodeLocation),r}function Cr(e){const t=e.map(r=>is(r,!0));for(let r=1;r{let t="";return e.italic&&(t="italic "),e.bold&&(t+="bold "),`${t}${e.size}px '${e.font}',sans-serif`},Yr=(e,t)=>{dt(0);const r=e.lineTable.length;De.font=ss(t);const n=De.measureText(""),i={mode:"break",text:"",x:0,y:0,w:0,h:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent,line:r,textFormat:t.toObject()};e.heightTable[r]=0,e.ascentTable[r]=0,e.widthTable[r]=0,e.lineTable.push(i),e.textTable.push(i)},cl=e=>{const t=e.heightTable.length-1;for(let r=1;r0)continue;const i=e.lineTable[r];i&&(e.heightTable[r]=i.h=e.heightTable[r-1])}},as=e=>{let t=0;return e.leftMargin&&(t+=e.leftMargin),e.rightMargin&&(t+=e.rightMargin),t},ll=(e,t,r,n)=>{let i=r.lineTable.length-1;const s=n.width-as(t)-4;for(let a=0;as){dt(l),i++,u.line=i;const A={mode:"wrap",text:"",x:0,y:0,w:0,h:0,line:i,textFormat:o.toObject()};let d=1,y=!0;const g=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;;){const p=r.textTable.length-d;if(0>=p){y=!1,d=0;break}const $=r.textTable[p];if(!$){y=!1,d=0;break}if($.mode!=="text"){y=!1;break}if($.text===" "){d--;break}if(!$.text.match(g)){d--;break}d++}if(r.widthTable[i]=0,r.heightTable[i]=0,r.ascentTable[i]=0,d>0&&y){const p=r.textTable.length-d;r.textTable.splice(p,0,A),r.lineTable.push(A);const $=i-1;r.widthTable[$]=0,r.heightTable[$]=0,r.ascentTable[$]=0;for(let w=0;w{const t=e.trim().split(";"),r=[];for(let n=0;n{for(let n=0;nt.size&&(t.size=1));break;case"color":t.color=et(i.value);break;case"letterSpacing":t.letterSpacing=parseInt(i.value);break;case"leading":t.leading=parseInt(i.value);break;case"leftMargin":t.leftMargin=parseInt(i.value);break;case"rightMargin":t.rightMargin=parseInt(i.value);break;case"underline":t.underline=!0;break;case"bold":t.bold=!0;break;case"italic":t.italic=!0;break}}},Vr=(e,t,r,n)=>{for(let i=0;i{const n=new Gc;if(!e)return n;const i=e.trim().replace(/\r?\n/g,"").replace(/\t/g,""),s=t.clone();return r.subFontSize&&r.subFontSize>0&&s.size&&(s.size-=r.subFontSize,1>s.size&&(s.size=1)),Yr(n,s),Vr(ol(i),s,n,r),cl(n),n},H=(e,t=0)=>(e.$textData||(e.$textData=hl(e.htmlText,e.defaultTextFormat,{width:e.width,multiline:e.multiline,wordWrap:e.wordWrap,subFontSize:t,textFormats:e.$textFormats})),e.$textData),K=e=>{e.changed=!0;const t=e.parent;t&&!t.changed&&K(t)},Kr=e=>{e.$textData=null,K(e),e.uniqueKey!==""&&O.has(e.uniqueKey)&&(O.removeById(e.uniqueKey),O.$removeIds.push(+e.uniqueKey))},fl=e=>{if(K(e),e.autoSize==="none"){e.xMin=e.bounds.xMin,e.yMin=e.bounds.yMin,e.xMax=e.bounds.xMax,e.yMax=e.bounds.yMax;return}const t=e.defaultTextFormat,r=e.textWidth+4+as(t);if(e.wordWrap)e.xMin=e.bounds.xMin,e.xMax=e.bounds.xMax;else switch(e.autoSize){case"left":e.xMax=r+e.xMin;break;case"center":e.xMax=r+e.xMin;break;case"right":e.xMax=e.bounds.xMax-(e.bounds.xMax-e.bounds.xMin-(r-e.bounds.xMin));break}e.yMax=e.textHeight+e.bounds.yMin+4},dl=e=>{let t=0;const r=H(e);for(let i=0;in&&e.textWidth+4>e.width;)Kr(e),H(e,n++);if(e.height&&e.textHeight)for(;t>n&&e.textHeight+4>e.height;)Kr(e),H(e,n++);K(e)},Be=e=>{Kr(e),H(e),e.autoSize==="none"&&e.autoFontSize&&dl(e),fl(e)},Al=(e,t)=>{const r=H(e);if(2>r.textTable.length)return;let n=2,i=0;for(let f=1;f=t){i=f;break}A.mode==="break"&&(d=!0,n=2),d&&i++}const s=r.textTable[i];if(!s)return;e.$scrollX=e.$scrollY=0;const a=s.line;let o=0;for(let f=0;f<=a;++f)o+=r.heightTable[f];const c=Math.abs(e.yMax-e.yMin);let u=0;for(let f=a;f>-1;--f){const A=r.heightTable[f];if(cc){const f=(e.textHeight-c)/c;e.$scrollY=Math.max(0,Math.min((o-u)/f,c))}const h=Math.abs(e.xMax-e.xMin);let l=0;for(let f=i;f>0;--f){const A=r.textTable[f];if(A.mode==="text"){if(hh){const f=(e.textWidth-h)/h;e.$scrollX=Math.max(0,Math.min((n-l)/f,h+.5))}K(e)},fe=()=>{const e=Ht();e!==void 0&&clearTimeout(e),Zi(void 0)},pl=window.devicePixelRatio,ml=e=>{const t=e.localToGlobal(new se),r=e.$textData;if(r){const i=r.textTable[e.focusIndex];if(i){for(let a=e.focusIndex-1;a>-1;--a){const o=r.textTable[a];if(!o||o.line!==i.line)break;t.x+=o.w}const s=i.mode==="break"?i.line-1:i.line;for(let a=0;a{e.focusVisible=!e.focusVisible,K(e),Zi(setTimeout(()=>pe(e),500)),ml(e)},gl=(e,t)=>{e.willTrigger(t)&&e.dispatchEvent(new Ne(t)),de.value="",e.focus?(setTimeout(()=>{de.focus()},300),Ht()===void 0&&(e.focusIndex===-1&&(e.focusIndex=1,e.selectIndex=-1),pe(e))):(e.focusIndex=-1,e.selectIndex=-1,e.focusVisible=!1,fe(),de.blur()),K(e)},bl=(e,t,r,n)=>e/n*r+t,xl=(e,t,r,n)=>(e/=n)*e*r+t,yl=(e,t,r,n)=>-(e/=n)*(e-2)*r+t,$l=(e,t,r,n)=>(e/=n/2)<1?e*e*r/2+t:-((e-=1)*(e-2)-1)*r/2+t,vl=(e,t,r,n)=>(e/=n)*e*e*r+t,wl=(e,t,r,n)=>(e/=n,(--e*e*e+1)*r+t),Ml=(e,t,r,n)=>(e/=n/2)<1?e*e*e*r/2+t:((e-=2)*e*e+2)*r/2+t,Bl=(e,t,r,n)=>(e/=n)*e*e*e*r+t,Tl=(e,t,r,n)=>(e/=n,(--e*e*e*e-1)*-r+t),Sl=(e,t,r,n)=>(e/=n/2)<1?e*e*e*e*r/2+t:((e-=2)*e*e*e-2)*-r/2+t,Il=(e,t,r,n)=>(e/=n)*e*e*e*e*r+t,Cl=(e,t,r,n)=>(e/=n,(--e*e*e*e*e+1)*r+t),Fl=(e,t,r,n)=>(e/=n/2)<1?e*e*e*e*e*r/2+t:((e-=2)*e*e*e*e+2)*r/2+t,El=(e,t,r,n)=>-r*Math.cos(e/n*(Math.PI/2))+r+t,Pl=(e,t,r,n)=>r*Math.sin(e/n*(Math.PI/2))+t,Rl=(e,t,r,n)=>-r/2*(Math.cos(Math.PI*e/n)-1)+t,Ol=(e,t,r,n)=>r*Math.pow(2,10*(e/n-1))+t,kl=(e,t,r,n)=>r*(-Math.pow(2,-10*e/n)+1)+t,Ul=(e,t,r,n)=>(e/=n/2)<1?r/2*Math.pow(2,10*(e-1))+t:r/2*(-Math.pow(2,-10*(e-1))+2)+t,Gl=(e,t,r,n)=>(1-Math.sqrt(1-(e/=n)*e))*r+t,_l=(e,t,r,n)=>(e/=n,Math.sqrt(1- --e*e)*r+t),Dl=(e,t,r,n)=>(e/=n*2)<1?(Math.sqrt(1-e*e)-1)/-2*r+t:(Math.sqrt(1-(e-=2)*e)+1)/2*r+t,Ll=(e,t,r,n)=>(2.70158*(e/=n)*e*e-1.70158*e*e)*r+t,Nl=(e,t,r,n)=>(1+2.70158*Math.pow((e/=n)-1,3)+1.70158*Math.pow(e-1,2))*r+t,Yl=(e,t,r,n)=>{let i=1.70158;return(e/=n/2)<1?e*e*(((i*=1.525)+1)*e-i)*r/2+t:((e-=2)*e*(((i*=1.525)+1)*e+i)+2)*r/2+t},Wl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:-Math.pow(2,(e*=10)-10)*Math.sin((e-10.75)*(2*Math.PI/3))*r+t,Vl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:(Math.pow(2,-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1)*r+t,Kl=(e,t,r,n)=>(e/=n)===0?t:e===1?r+t:e<.5?-(Math.pow(2,20*e-10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5)))/2*r+t:(Math.pow(2,-20*e+10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5))/2+1)*r+t,Ql=(e,t,r,n)=>(e/=n)<1/2.75?7.5625*e*e*r+t:e<2/2.75?(7.5625*(e-=1.5/2.75)*e+.75)*r+t:e<2.5/2.75?(7.5625*(e-=2.25/2.75)*e+.9375)*r+t:(7.5625*(e-=2.625/2.75)*e+.984375)*r+t,Xl=(e,t,r,n)=>r-Ye.outBounce(n-e,0,r,n)+t,zl=(e,t,r,n)=>e{cancelAnimationFrame(e.$timerId),e.hasEventListener(ye.STOP)&&e.dispatchEvent(new ye(ye.STOP)),e.entries=null,e.stopFlag=!0},os=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({name:r,value:typeof n=="number"?n:os(n)});return t},cs=(e,t,r,n,i)=>{for(let s=0;se.currentTime?t[o]=e.ease(e.currentTime,c,n[o]-c,e.duration):t[o]=n[o]}},ls=(e,t)=>e.stopFlag||!e.entries?-1:(e.currentTime=(t-e.startTime)/1e3,cs(e,e.target,e.from,e.to,e.entries),e.hasEventListener(ye.UPDATE)&&e.dispatchEvent(new ye(ye.UPDATE)),e.currentTime>=e.duration?(e.hasEventListener(ye.COMPLETE)&&e.dispatchEvent(new ye(ye.COMPLETE)),e.nextJob&&e.nextJob.start(),-1):requestAnimationFrame(r=>{ls(e,r)})),Vn=e=>{e.stopFlag||(e.entries=os(e.from),e.entries&&(e.startTime=performance.now(),e.$timerId=ls(e,e.startTime)))},Jl=e=>{cancelAnimationFrame(e.$timerId),e.stopFlag=!1,e.delay?setTimeout(()=>{Vn(e)},e.delay*1e3):Vn(e)};class Zl extends nt{target;entries;startTime;stopFlag;$timerId;delay;duration;ease;from;to;currentTime;nextJob;constructor(t,r,n,i=0,s=1,a=null){super(),this.target=t,this.from=r,this.to=n,this.delay=i,this.duration=s,this.ease=a||Ye.linear,this.currentTime=0,this.nextJob=null,this.entries=null,this.startTime=0,this.stopFlag=!1,this.$timerId=-1}chain(t){return this.nextJob=t,t}start(){Jl(this)}stop(){Hl(this)}}class gn{static add(t,r,n,i=0,s=1,a=null){return new Zl(t,r,n,i,s,a)}}const ql=(e,t)=>{if(!e.scrollEnabled||e.autoSize!=="none"||e.yScrollShape.hasLocalVariable("job"))return;const r=e.width;if(t=pt(t,0,r,0),e.scrollX!==t){if(e.textWidth>r){K(e);const n=e.xScrollShape;n.width=r*r/e.textWidth;const i=e.parent;if(i){n.hasLocalVariable("job")&&n.getLocalVariable("job").stop(),n.alpha=.9,n.x=e.x+1+(r-1-n.width)/(r-1)*(t-1),n.y=e.y+e.height-n.height-.5,i.addChildAt(n,i.getChildIndex(e)+1);const s=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);s.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),s.start(),n.setLocalVariable("job",s)}e.$scrollX=t}e.willTrigger(x.SCROLL)&&e.dispatchEvent(new x(x.SCROLL,!0))}},jl=(e,t)=>{if(!e.scrollEnabled||e.autoSize!=="none"||!e.multiline&&!e.wordWrap||e.xScrollShape.hasLocalVariable("job"))return;const r=e.height;if(t=pt(t,0,r,0),e.scrollY!==t){if(e.textHeight>r){K(e);const n=e.yScrollShape;n.height=r*r/e.textHeight;const i=e.parent;if(i){n.hasLocalVariable("job")&&n.getLocalVariable("job").stop(),n.alpha=.9,n.x=e.x+e.width-n.width-.5,n.y=e.y+.5+(r-1-n.height)/(r-1)*(t-1),i.addChildAt(n,i.getChildIndex(e)+1);const s=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);s.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),s.start(),n.setLocalVariable("job",s),e.$scrollY=t}}e.willTrigger(x.SCROLL)&&e.dispatchEvent(new x(x.SCROLL,!0))}},eu=e=>{let t="";const r=H(e);for(let n=1;n{let r="";const n=H(e);for(let i=1;it)break;s.line===t&&s.mode==="text"&&(r+=s.text)}}return r},ru=(e,t,r,n)=>{if(0>r||r>n)return;const i=e.text,s=r?i.slice(0,r):"";e.text=s+t+i.slice(n,i.length)},nu=async e=>{if(e.focusIndex===-1||e.selectIndex===-1)return;let t="";const r=Math.min(e.focusIndex,e.selectIndex),n=Math.max(e.focusIndex,e.selectIndex)+1,i=H(e);for(let s=r;s{const t=await navigator.clipboard.readText();t===""||e.focusIndex===-1||e.insertText(t)},bn=e=>{if(e.compositionStartIndex>-1)return;let t=0,r=0;if(e.selectIndex>-1)t=Math.min(e.focusIndex,e.selectIndex),r=Math.max(e.focusIndex,e.selectIndex)+1,e.focusIndex=t;else{if(2>e.focusIndex)return;e.focusIndex--}const n=H(e),i=n.textTable[e.focusIndex];i&&i.mode==="wrap"&&e.focusIndex--;const s=[];let a="";for(let o=1;oo))switch(c.mode){case"break":s.push(new ue(...Object.values(c.textFormat))),a+=` -`;break;case"text":s.push(new ue(...Object.values(c.textFormat))),a+=c.text;break;default:continue}}if(n.textTable.length===e.focusIndex&&(s.pop(),a=a.slice(0,-1)),e.selectIndex=-1,!a)e.text="",e.focusIndex=1;else{const o=e.textWidth,c=e.textHeight;if(e.$textFormats=s,e.text=a,e.scrollX>0){const u=e.textWidth,h=e.width;switch(!0){case h>u:e.$scrollX=0;break;case o!==u:e.$scrollX-=(o-u)/(u/h);break}}if(e.scrollY>0){const u=e.textHeight,h=e.height;switch(!0){case h>u:e.$scrollY=0;break;case c!==u:e.$scrollY-=(c-u)/(u/h);break}}e.$textFormats=null}},us=(e,t)=>{if(e.focusIndex===-1||e.compositionStartIndex>-1)return;e.selectIndex>-1&&bn(e);const r=H(e);if(2>r.textTable.length){e.focusIndex=2,e.appendText(t);return}const n=[];let i="";for(let s=1;s{if(e.selectIndex===-1)return;const t=H(e);if(2>t.textTable.length)return;const r=t.textTable[e.selectIndex];if(!r)return;const n=r.mode==="text"?r.line:r.line-1,i=e.height,s=(e.textHeight-i)/i;let a=-e.scrollY*s-2,o=0;for(let d=0;di));++d)o++;a=-e.scrollY*s-2;let c=0;for(let d=0;d0));++d)c++;c>=r.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=t.heightTable[r.line]/s),r.line>=o&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=t.heightTable[r.line]/s);const u=e.width,h=(e.textWidth-u)/u;let l=2,f=e.scrollX*h-2+u;for(let d=1;e.selectIndex>=d;++d){const y=t.textTable[d];if(!y||y.line>n)break;if(y.line===n&&(e.selectIndex!==d&&(l+=y.w),f-=y.w,!(f>0))){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX+=y.w/h;break}}e.scrollX*h-2>l&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth))},su=(e,t,r,n=!1)=>{if(e.type!=="input")return;const i=H(e);if(2>i.textTable.length){e.focusIndex=1,e.selectIndex=-1,Ht()===void 0&&pe(e);return}const s=e.width,a=e.height;let o=0;e.scrollX>0&&(o+=e.scrollX*(e.textWidth-s)/s);let c=0;e.scrollY>0&&(c+=e.scrollY*(e.textHeight-a)/a);const u=e.globalToLocal(new se(t,r)),h=u.x+o,l=u.y+c;let f=2,A=2,d=A+i.heightTable[0];for(let y=1;yf&&l>A&&d>l&&s>h){const p=y;n?e.selectIndex!==p&&(e.selectIndex=p,e.focusVisible&&(e.focusVisible=!1,fe()),Kn(e),K(e)):(e.focusIndex!==p||e.selectIndex>-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e));return}f=2,A+=i.heightTable[g.line-1],d=A+i.heightTable[g.line];break;case"text":if(h>f&&l>A&&d>l&&f+g.w>h){let p=y;if(n)e.focusIndex>p?e.focusIndex===p+1?f+g.w/2h&&(p=-1):f+g.w/2>h&&(p-=1),e.selectIndex!==p&&(e.selectIndex=p,e.selectIndex>-1&&(e.focusVisible=!1,fe()),Kn(e),K(e));else{if(f+g.w/2-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e))}return}if(y===i.textTable.length-1&&h>f&&l>A&&d>l&&s>h){const p=i.textTable.length;n?e.selectIndex!==p&&(e.selectIndex=p,e.focusVisible&&(e.focusVisible=!1,fe()),K(e)):(e.focusIndex!==p||e.selectIndex>-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e));return}f+=g.w;break}if(!n)e.focusIndex=i.textTable.length,e.selectIndex=-1,Ht()===void 0?pe(e):K(e);else{let p=0;for(let $=0;i.heightTable.length>$;++$)p+=i.heightTable[$];(l>p||2>l)&&(e.selectIndex=2>l?1:i.textTable.length,e.focusVisible&&(e.focusVisible=!1,fe()),K(e))}}}},au=(e,t)=>{if(e.focusIndex===-1)return;const r=H(e);if(2>r.textTable.length)return;const n=r.textTable[e.focusIndex];if(!n)return;const i=n.mode==="text"?n.line:n.line-1;if(i===r.lineTable.length-1){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex=r.textTable.length;const f=e.width,A=(e.textWidth-f)/f;let d=0;for(let y=1;e.focusIndex>=y;++y){const g=r.textTable[y];if(!g||g.line>i)break;g.line===i&&(d+=g.w)}e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=(d-f)/A,fe(),pe(e);return}const s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let f=0;fs));++f)c++;let u=2;for(let f=1;fi)break;A.line!==i||A.mode!=="text"||(u+=A.w)}}let h=2;const l=i+1;for(let f=1;fl){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,A.line>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[A.line]/a),e.focusVisible=!1,e.focusIndex=A.mode==="text"?f-1:f,e.scrollX&&hu)){if(t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===f-1&&(e.selectIndex=-1):e.selectIndex=-1,A.line>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[A.line]/a),e.scrollX){const d=e.width,y=(e.textWidth-d)/d;e.scrollX*y-2>h&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((h-2)/e.textWidth))}e.focusVisible=!1,e.focusIndex=f,fe(),pe(e);return}}}t?e.selectIndex===-1&&(e.selectIndex=e.focusIndex):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex=r.textTable.length,fe(),pe(e)},ou=(e,t)=>{if(e.focusIndex===-1)return;const r=H(e);if(2>r.textTable.length)return;const n=r.textTable.length===e.focusIndex?e.focusIndex-1:e.focusIndex,i=r.textTable[n];if(!i||!i.line){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.focusVisible=!1,e.focusIndex=1,e.scrollX=0,fe(),pe(e);return}const s=i.mode==="text"?i.line:i.line-1,a=e.height,o=(e.textHeight-a)/a;let c=0,u=-e.scrollY*o-2;for(let A=0;A0));++A)c++;let h=2;for(let A=1;As)break;d.line!==s||d.mode!=="text"||(h+=d.w)}}let l=2;const f=s-1;for(let A=1;Af){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,c>=d.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[d.line]/o),e.scrollX&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth)),e.focusVisible=!1,e.focusIndex=d.mode==="text"?A-1:A,fe(),pe(e);return}if(!(d.line!==f||d.mode!=="text")&&(l+=d.w,l>h)){t?e.selectIndex===-1?e.selectIndex=e.focusIndex-1:e.selectIndex===A+1&&(e.selectIndex=-1):e.selectIndex=-1,c>d.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[d.line]/o),e.focusVisible=!1,e.focusIndex=A,fe(),pe(e);return}}}},cu=(e,t)=>{if(!e.focusIndex)return;const r=H(e);if(r.textTable.length&&e.focusIndex<2){e.focusIndex=1;return}e.focusIndex--,t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1;const n=r.textTable[e.focusIndex];if(n){const i=n.mode==="text"?n.line:n.line-1,s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let h=0;h0));++h)c++;c>i&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=r.heightTable[n.line]/a);const u=r.textTable[e.focusIndex+1];if(u){const h=u.mode==="text"?u.line:u.line-1;let l=2;for(let y=1;e.focusIndex>y;++y){const g=r.textTable[y];if(!g||g.line>i)break;g.line===i&&(l+=g.w)}const f=e.width,A=(e.textWidth-f)/f,d=e.scrollX*A-2;if(l>f&&u&&il){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((l-2)/e.textWidth);return}}}e.focusVisible=!1,fe(),pe(e)},lu=(e,t)=>{const r=H(e);if(r.textTable.length===e.focusIndex)return;t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex++,fe(),pe(e);const n=r.textTable[e.focusIndex];if(n){const i=n.mode==="text"?n.line:n.line-1,s=e.height,a=(e.textHeight-s)/s;let o=-e.scrollY*a-2,c=0;for(let d=0;ds));++d)c++;i>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[i]/a);const u=r.textTable[e.focusIndex-1],h=u.mode==="text"?u.line:u.line-1;if(u&&i>h){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=0;return}const l=e.width,f=(e.textWidth-l)/l;let A=e.scrollX*f-2+l;for(let d=1;e.focusIndex>=d;++d){const y=r.textTable[d];if(!y||y.line>i)break;if(y.line===i&&(A-=y.w,!(A>0))){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX+=y.w/f;break}}}},uu=(e,t)=>{if(e.focusIndex!==-1)switch(t.key){case"Backspace":case"Delete":e.deleteText();break;case"Enter":e.insertText(` -`);break;case"ArrowLeft":cu(e,t.shiftKey);break;case"ArrowRight":lu(e,t.shiftKey);break;case"ArrowUp":ou(e,t.shiftKey);break;case"ArrowDown":au(e,t.shiftKey);break;case"a":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.selectAll());break;case"c":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.copy());break;case"v":(t.metaKey||t.ctrlKey)&&(t.preventDefault(),e.paste());break}},hu=e=>{const t=H(e);2>t.textTable.length||(e.selectIndex=1,e.focusIndex=t.textTable.length,K(e))},fu=(e,t)=>{const r=e.defaultTextFormat;switch(r.font=t.font,r.size=t.size,r.align=t.align,r.color=t.color,r.leading=t.leading,r.letterSpacing=t.letterSpacing,r.leftMargin=t.leftMargin,r.rightMargin=t.rightMargin,t.fontType){case 1:r.bold=!0;break;case 2:r.italic=!0;break;case 3:r.bold=!0,r.italic=!0;break}switch(e.defaultTextFormat=r,e.type=t.inputType,e.multiline=t.multiline,e.wordWrap=t.wordWrap,e.border=t.border,e.scrollEnabled=t.scroll,e.thickness=t.thickness,e.thicknessColor=t.thicknessColor,t.autoSize){case 1:e.autoSize=t.align;break;case 2:e.autoFontSize=!0;break}e.xMin=e.bounds.xMin=t.bounds.xMin,e.xMax=e.bounds.xMax=t.bounds.xMax,e.yMin=e.bounds.yMin=t.bounds.yMin,e.yMax=e.bounds.yMax=t.bounds.yMax+4,e.text=t.text};class Qr extends fn{isText;$textData;_$isHTML;xMin;yMin;xMax;yMax;bounds;scrollEnabled;xScrollShape;yScrollShape;focusVisible;focusIndex;selectIndex;maxChars;restrict;type;compositionStartIndex;compositionEndIndex;$textFormats;$scrollX;$scrollY;cacheKey;cacheParams;_$background;_$backgroundColor;_$border;_$borderColor;_$htmlText;_$multiline;_$text;_$wordWrap;_$defaultTextFormat;_$rawHtmlText;_$autoSize;_$autoFontSize;_$focus;_$thickness;_$thicknessColor;_$stopIndex;constructor(){super(),this.isText=!0,this.$textData=null,this._$background=!1,this._$backgroundColor=16777215,this._$border=!1,this._$borderColor=0,this._$htmlText="",this._$multiline=!1,this._$text="",this._$wordWrap=!1,this.$scrollX=0,this.$scrollY=0,this.$textFormats=null,this.maxChars=0,this._$stopIndex=-1,this.compositionStartIndex=-1,this.compositionEndIndex=-1;const t=new ue;kc(t),this._$defaultTextFormat=t,this._$rawHtmlText="",this.xMin=0,this.yMin=0,this.xMax=100,this.yMax=100,this.bounds={xMin:0,xMax:this.xMax,yMin:0,yMax:this.yMax},this.restrict="",this._$isHTML=!1,this._$autoSize="none",this._$autoFontSize=!1,this.focusVisible=!1,this.focusIndex=-1,this.selectIndex=-1,this.scrollEnabled=!0,this.xScrollShape=new $t,this.xScrollShape.graphics.beginFill("#000",.3).drawRoundRect(0,0,3,3,3),this.xScrollShape.scale9Grid=new be(1.5,1.5,.1,.1),this.yScrollShape=new $t,this.yScrollShape.graphics.beginFill("#000",.3).drawRoundRect(0,0,3,3,3),this.yScrollShape.scale9Grid=new be(1.5,1.5,.1,.1),this.type="static",this._$focus=!1,this._$thickness=0,this._$thicknessColor=0,this.cacheKey=0,this.cacheParams=[0,0,0]}static get namespace(){return"next2d.display.TextField"}get namespace(){return"next2d.display.TextField"}get autoFontSize(){return this._$autoFontSize}set autoFontSize(t){t!==this._$autoFontSize&&(this._$autoFontSize=!!t,Be(this))}get autoSize(){return this._$autoSize}set autoSize(t){t!==this._$autoSize&&(this._$autoSize=t,Be(this))}get background(){return this._$background}set background(t){t!==this._$background&&(this._$background=!!t,K(this))}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){t=pt(et(t),0,16777215,16777215),t!==this._$backgroundColor&&(this._$backgroundColor=t,K(this))}get border(){return this._$border}set border(t){t!==this._$border&&(this._$border=!!t,K(this))}get borderColor(){return this._$borderColor}set borderColor(t){t=pt(et(t),0,16777215,0),t!==this._$borderColor&&(this._$borderColor=t,K(this))}get stopIndex(){return this._$stopIndex}set stopIndex(t){t|=0,this._$stopIndex!==t&&(this._$stopIndex=t,Al(this,t))}get defaultTextFormat(){return this._$defaultTextFormat.clone()}set defaultTextFormat(t){this._$rawHtmlText="",this._$isHTML?this._$text="":this._$htmlText="",this._$defaultTextFormat=t,Be(this)}get focus(){return this._$focus}set focus(t){this._$focus!==t&&this.type==="input"&&(this._$focus=!!t,gl(this,this._$focus?Ne.FOCUS_IN:Ne.FOCUS_OUT))}get htmlText(){if(this._$htmlText)return this._$htmlText;const t=Uc(this.defaultTextFormat);return this._$htmlText=`${this._$text.replace(/\n/g,"
")}
`,this._$htmlText}set htmlText(t){this._$htmlText!==t&&(this._$htmlText=`${t}`,this._$rawHtmlText="",this._$text="",this._$isHTML=!0,Be(this),this.hasEventListener(x.CHANGE)&&this.dispatchEvent(new x(x.CHANGE)))}get length(){return this.text.length}get multiline(){return this._$multiline}set multiline(t){t!==this._$multiline&&(this._$multiline=!!t,Be(this))}get numLines(){return H(this).lineTable.length}get scrollX(){return this.$scrollX}set scrollX(t){ql(this,t)}get scrollY(){return this.$scrollY}set scrollY(t){jl(this,t)}get text(){return this._$isHTML?(this._$rawHtmlText||(this._$rawHtmlText=eu(this)),this._$rawHtmlText):this._$text}set text(t){t=`${t}`,t===""&&(this.scrollX&&(this.scrollX=0),this.scrollY&&(this.scrollY=0)),t!==this._$text&&(this._$htmlText="",this._$rawHtmlText="",this._$isHTML=!1,this._$text=t,Be(this),this.hasEventListener(x.CHANGE)&&this.dispatchEvent(new x(x.CHANGE)))}get textHeight(){return H(this).textHeight}get textWidth(){return H(this).textWidth}get thickness(){return this._$thickness}set thickness(t){t|=0,t!==this._$thickness&&(this._$thickness=t,K(this))}get thicknessColor(){return this._$thicknessColor}set thicknessColor(t){t=pt(et(t),0,16777215,0),t!==this._$thicknessColor&&(this._$thicknessColor=t,K(this))}get wordWrap(){return this._$wordWrap}set wordWrap(t){this._$wordWrap!==t&&(this._$wordWrap=!!t,Be(this))}get width(){return super.width}set width(t){if(t=+t,!isNaN(t)&&0>t)return;const r=t+this.bounds.xMin;r!==this.bounds.xMax&&(this.bounds.xMax=r,Be(this))}get height(){return super.height}set height(t){if(t=+t,!isNaN(t)&&0>t)return;const r=t+this.bounds.yMin;r!==this.bounds.yMax&&(this.bounds.yMax=r,Be(this))}appendText(t){const r=this.text;this.text=r+`${t}`}insertText(t){us(this,t)}deleteText(){bn(this)}getLineText(t){return this._$text||this._$htmlText?tu(this,t|0):""}replaceText(t,r,n){ru(this,t,r|0,n|0)}selectAll(){hu(this)}copy(){nu(this)}paste(){iu(this)}setFocusIndex(t,r,n=!1){su(this,t,r,n)}keyDown(t){uu(this,t)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),fu(this,t)}}const du=e=>{e.compositionStartIndex=e.focusIndex},Au=()=>{const e=ke();e&&du(e)},pu=(e,t)=>{if(e.compositionEndIndex>-1){const o=e.compositionStartIndex;e.focusIndex=e.compositionStartIndex,e.selectIndex=e.compositionEndIndex-1,e.compositionStartIndex=-1,bn(e),e.compositionStartIndex=o,e.selectIndex=-1}let r=H(e);const n=[],i=t.length;let s="";if(2>r.textTable.length)s=t,e.focusIndex=1,e.compositionStartIndex=1;else{for(let o=1;oe.compositionStartIndex&&a++}}e.compositionEndIndex=e.focusIndex=a},mu=e=>{const t=ke();t&&pu(t,e.data)},gu=e=>{if(e.compositionEndIndex>-1){const t=H(e);for(let r=e.compositionStartIndex;r{const e=ke();e&&gu(e)},xu=e=>{if(!e.data)return;const t=ke();t&&(us(t,e.data),t.hasEventListener(x.INPUT)&&t.dispatchEvent(new x(x.INPUT)))},yu=e=>{e.addEventListener("compositionstart",Au),e.addEventListener("compositionupdate",mu),e.addEventListener("compositionend",bu),e.addEventListener("input",xu)};yu(de);const hs=[],$u=()=>hs,vu=e=>{hs.push(e)};let Le=null;const wu=()=>!!Le,Mu=()=>{Le||(Le=new AudioContext),Le.resume()},fs=()=>(Le||(Le=new AudioContext),Le),Bu=e=>{let t=null;switch(e.method.toUpperCase()){case"GET":if(e.data){const n=e.url.split("?");n[1]=n.length===1?e.data.toString():`${n[1]}&${e.data.toString()}`,e.url=n.join("?")}break;case"PUT":case"POST":e.data&&(t=e.data.toString());break}const r=new XMLHttpRequest;if(r.open(e.method,e.url,!0),r.responseType=e.format,r.withCredentials=e.withCredentials,e.event){const n=Object.keys(e.event);for(let i=0;i{const i=+e;return isNaN(i)&&n!==null?n:Math.min(Math.max(t,isNaN(i)?0:i),r)};let ds=1;const Tu=()=>ds,Su=e=>{ds=xn(e,0,1,1)},Iu=[],Jt=()=>Iu,Cu=[],fr=()=>Cu,Fu=e=>{Su(e);const t=Jt();for(let n=0;n{const e=Jt();for(let r=0;r{e.canLoop?e.play():(e.stop(),e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE)))},Ru=(e,t)=>{e.willTrigger(x.OPEN)&&e.dispatchEvent(new x(x.OPEN)),e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},Ou=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},yn=async e=>{if(e.byteLength)try{return await fs().decodeAudioData(e)}catch{const t=new Uint8Array(e);let r=0;for(;r>t.byteLength&&(r=t.indexOf(255,r),!(r===-1||(t[r+1]&224)===224));)++r;return await yn(t.subarray(r).buffer)}},ku=async(e,t)=>{const r=t.target;if(r)if(e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total)),199r.status){const n=await yn(r.response);n&&(e.audioBuffer=n,e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE)))}else e.willTrigger(Re.IO_ERROR)&&e.dispatchEvent(new Re(Re.IO_ERROR,!1,r.statusText))},Uu=async(e,t)=>{await new Promise(r=>{Bu({format:"arraybuffer",url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:n=>{Ru(e,n)},progress:n=>{Ou(e,n)},loadend:async n=>{await ku(e,n),r()}}})})},Gu=async(e,t)=>{if(!t.audioBuffer){const r=new Uint8Array(t.buffer),n=await yn(r.buffer);if(!n)return;t.audioBuffer=n}e.audioBuffer=t.audioBuffer};class dr extends nt{_$source;_$gainNode;_$stopFlag;_$currentCount;_$volume;audioBuffer;loopCount;constructor(){super(),this.loopCount=0,this.audioBuffer=null,this._$volume=1,this._$currentCount=0,this._$stopFlag=!0,this._$source=null,this._$gainNode=null}get volume(){return this._$volume}set volume(t){this._$volume=xn(Math.min(rt.volume,t),0,1,1),this._$gainNode&&(this._$gainNode.gain.value=this._$volume)}get canLoop(){return!this._$stopFlag&&this.loopCount>=this._$currentCount}clone(){const t=new dr;return t.volume=this._$volume,t.loopCount=this.loopCount,t.audioBuffer=this.audioBuffer,t}async load(t){await Uu(this,t)}play(t=0){if(!this._$stopFlag||!this.audioBuffer)return;this.stop();const r=fs();this._$gainNode=r.createGain(),this._$gainNode.connect(r.destination),this._$gainNode.gain.value=Math.min(rt.volume,this._$volume),this._$source=r.createBufferSource(),this._$source.addEventListener("ended",()=>{Pu(this)}),this._$source.buffer=this.audioBuffer,this._$source.connect(this._$gainNode),this._$source.start(t),this._$stopFlag=!1,this._$currentCount++,Jt().push(this)}stop(){if(this._$stopFlag)return;this._$stopFlag=!0,this._$currentCount=0,this._$source&&(this._$source.disconnect(),this._$source=null),this._$gainNode&&(this._$gainNode.gain.value=0,this._$gainNode.disconnect(),this._$gainNode=null);const t=Jt(),r=t.indexOf(this);r>-1&&t.splice(r,1)}async $build(t){await Gu(this,t)}}class _u{volume;loopCount;constructor(t=1,r=0){this.volume=t,this.loopCount=r}}const Du=()=>{const e=document.createElement("video");return e.autoplay=!1,e.crossOrigin="anonymous",e.setAttribute("playsinline",""),e},$n=e=>{e.changed=!0;const t=e.parent;t&&!t.changed&&$n(t)},Lu=async e=>{e.autoPlay&&(wu()||(e.muted=!0,vu(e)),await e.play()),e.loaded=!0,$n(e),e.willTrigger(x.COMPLETE)&&e.dispatchEvent(new x(x.COMPLETE))},Nu=(e,t)=>{t.currentTime=0,t.duration=e.duration,t.videoWidth=e.videoWidth,t.videoHeight=e.videoHeight;const r=new OffscreenCanvas(t.videoWidth,t.videoHeight);t.$context=r.getContext("2d"),t.$offscreenCanvas=r},Yu=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},Wu=e=>{if(e.willTrigger(Ae.ENDED)&&e.dispatchEvent(new Ae(Ae.ENDED)),e.loop){e.currentTime=0;return}e.ended=!0,e.changed=!1,e.pause()},Vu=(e,t)=>{e.addEventListener("loadedmetadata",()=>{Nu(e,t)},{once:!0}),e.addEventListener("progress",r=>{Yu(t,r)}),e.addEventListener("canplaythrough",async()=>{await Lu(t),e.volume=t.volume},{once:!0}),e.addEventListener("ended",()=>{Wu(t)})},As=e=>{if(e.paused||!e.loaded)return 0;e.willTrigger(Ae.PLAY)&&e.dispatchEvent(new Ae(Ae.PLAY)),$n(e);const t=fr();return t.indexOf(e)===-1&&t.push(e),requestAnimationFrame(()=>{As(e)})},Ku=(e,t)=>{t.videoData||(t.videoData=new Uint8Array(t.buffer),t.buffer=null),e.loop=t.loop,e.autoPlay=t.autoPlay,e.videoWidth=t.bounds.xMax,e.videoHeight=t.bounds.yMax,e.volume=t.volume,e.src=URL.createObjectURL(new Blob([t.videoData.buffer],{type:"video/mp4"}))};class Xr extends hr{duration;smoothing;loop;autoPlay;currentTime;videoWidth;videoHeight;loaded;ended;isVideo;$videoElement;$offscreenCanvas;$context;paused;_$timerId;_$volume;_$src;constructor(t=0,r=0){super(),this.videoWidth=t,this.videoHeight=r,this.isVideo=!0,this.duration=0,this.smoothing=!0,this.loop=!1,this.loaded=!1,this.ended=!1,this.paused=!0,this.autoPlay=!0,this.currentTime=0,this._$src="",this._$timerId=-1,this._$volume=1,this.$videoElement=null,this.$offscreenCanvas=null,this.$context=null}static get namespace(){return"next2d.media.Video"}get namespace(){return"next2d.media.Video"}get src(){return this._$src}set src(t){this._$src!==t&&(this.loaded=!1,this.currentTime=0,this.$videoElement=null,this.$offscreenCanvas=null,this.$context=null,this.$videoElement=Du(),Vu(this.$videoElement,this),this._$src=this.$videoElement.src=t,this.$videoElement.load())}get muted(){return this.$videoElement?this.$videoElement.muted:!1}set muted(t){this.$videoElement&&(this.$videoElement.muted=t)}get volume(){return this._$volume}set volume(t){this._$volume=xn(Math.min(rt.volume,t),0,1,1),this.$videoElement&&(this.$videoElement.volume=this._$volume)}pause(){if(!this.$videoElement||this.paused)return;this.paused=!0,this.$videoElement.pause(),cancelAnimationFrame(this._$timerId),this.willTrigger(Ae.PAUSE)&&this.dispatchEvent(new Ae(Ae.PAUSE));const t=fr(),r=t.indexOf(this);r>-1&&t.splice(r,1)}async play(){!this.$videoElement||!this.paused||(this.paused=!1,this.ended=!1,this.$videoElement.volume=this._$volume,await this.$videoElement.play(),this._$timerId=As(this))}seek(t){this.$videoElement&&(this.currentTime=this.$videoElement.currentTime=Math.min(this.duration,t),this.willTrigger(Ae.SEEK)&&this.dispatchEvent(new Ae(Ae.SEEK)))}$sync(t,r=null){r&&super.$syncLoaderInfo(r),Ku(this,t)}}const At=(e,t,r,n,i=-1)=>{const s=n.loaderInfo;if(!s)throw new Error("the loaderInfo or data is null.");e.parent=n,we.set(e,n.root),Dt.set(e,s),e.dictionaryId=t,e.characterId=r.characterId,e.clipDepth=r.clipDepth,e.startFrame=r.startFrame,e.endFrame=r.endFrame,e.name=r.name||"",e.placeId=i},Qn=(e,t,r,n,i=-1)=>{switch(r.extends){case qt.namespace:{const s=new qt;return At(s,e,t,n,i),s.$sync(r),s}case $t.namespace:{const s=new $t;return At(s,e,t,n,i),s.$sync(r),s}case Qr.namespace:{const s=new Qr;return At(s,e,t,n,i),s.$sync(r),s}case Xr.namespace:{const s=new Xr;return At(s,e,t,n,i),s.$sync(r),s}default:throw new Error(`Character extends not found: ${r.extends}`)}},Rt=new Map,Qu=(e,t)=>{const r=e.loaderInfo;if(!r||!r.data)return t;const n=r.data.characters[e.characterId];if(!n)return t;const i=e.currentFrame,s=n.controller[i];if(!s)return t;const a=[],o=n.dictionary;if(!t.length){for(let c=0;ci){Rt.set(u.dictionaryId,u);continue}u.uniqueKey&&O.has(u.uniqueKey)&&O.removeTimer(u.uniqueKey),u.willTrigger(x.REMOVED)&&u.dispatchEvent(new x(x.REMOVED,!0)),u.willTrigger(x.REMOVED_FROM_STAGE)&&u.dispatchEvent(new x(x.REMOVED_FROM_STAGE,!0)),u.isVideo&&u.pause(),u.isContainerEnabled&&un(u)}t.length=0;for(let c=0;c{e.$labels||(e.$labels=new Map),e.$labels.set(t.frame,t)},zu=e=>{if(!e.$labels)return null;const t=e.currentFrame;return e.$labels.has(t)&&e.$labels.get(t)||null},Hu=e=>!e.$labels||!e.$labels.size?null:Array.from(e.$labels.values()),Ju=(e,t)=>{if(!e.$labels||!e.$labels.size)return 0;for(const[r,n]of e.$labels)if(n.name===t)return r;return 0},Zu=(e,t=null)=>{if(!t||!t.size)return;const r=e.currentFrame;if(!t.has(r))return;const n=t.get(r);n.willTrigger(x.FRAME_LABEL)&&n.dispatchEvent(new x(x.FRAME_LABEL))},qu=(e,t=null)=>{if(!t||!t.size)return;const r=e.currentFrame;t.has(r)&&kr.push(e)},Zt=e=>{e.$canAction&&(e.$canAction=!1,Zu(e,e.$labels),qu(e,e.$actions))},Ar=(e,t)=>{if(e.totalFrames===1)return;let r=+t;if(isNaN(r)&&(r=Ju(e,`${t}`)),1>r&&(r=1),e.currentFrame!==r){if(r>e.totalFrames){if(e.currentFrame===e.totalFrames)return;e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,e.currentFrame=e.totalFrames,Zt(e),j(e);return}e.currentFrame=r,e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,j(e),Zt(e)}},ju=(e,t)=>{e.play(),Ar(e,t)},eh=(e,t)=>{e.stop(),Ar(e,t),e.$wait=!1},th=e=>{e.totalFrames<=e.currentFrame||(e.stop(),Ar(e,e.currentFrame+1))},rh=e=>{2>e.currentFrame||(e.stop(),Ar(e,e.currentFrame-1))},nh=(e,t)=>{for(let r=0;r{for(let r=0;r{const n=e.loaderInfo;if(!n)return;const i=n.data;if(!i)return;const s=i.characters;for(let a=0;a{t.actions&&(e.$actions||(e.$actions=new Map),nh(e.$actions,t.actions)),t.sounds&&(e.$sounds||(e.$sounds=new Map),sh(e,e.$sounds,t.sounds)),t.labels&&(e.$labels||(e.$labels=new Map),ih(e.$labels,t.labels)),e.totalFrames=t.totalFrame||1};class qt extends An{$labels;$actions;$sounds;$canAction;$wait;totalFrames;currentFrame;_$stopFlag;$canSound;$hasTimelineHeadMoved;isTimelineEnabled;constructor(){super(),this.currentFrame=1,this.totalFrames=1,this.isTimelineEnabled=!0,this.$actions=null,this.$labels=null,this.$sounds=null,this.$canAction=!0,this.$wait=!1,this.$canSound=!0,this.$hasTimelineHeadMoved=!0,this._$stopFlag=!1}static get namespace(){return"next2d.display.MovieClip"}get namespace(){return"next2d.display.MovieClip"}get children(){return!this.$hasTimelineHeadMoved||this.characterId===-1?this._$children:(this.$hasTimelineHeadMoved=!1,Qu(this,this._$children))}get currentFrameLabel(){return zu(this)}get currentLabels(){return Hu(this)}get isPlaying(){return!this._$stopFlag}gotoAndPlay(t){ju(this,t)}gotoAndStop(t){eh(this,t)}nextFrame(){th(this)}play(){this._$stopFlag=!1,j(this)}prevFrame(){rh(this)}stop(){this._$stopFlag=!0}addFrameLabel(t){Xu(this,t)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),ah(this,t)}}const Xn=async(e,t)=>{const r=new Map;if(t.symbols.length)for(let a=0;a>1|(v&21845)<<1;b=(b&52428)>>2|(b&13107)<<2,b=(b&61680)>>4|(b&3855)<<4,O[v]=((b&65280)>>8|(b&255)<<8)>>1}for(var m=(function(r,e,n){for(var i=r.length,f=0,g=new k(e);f>p]=C}else for(h=new k(i),f=0;f>15-r[f]);return h}),A=new l(288),v=0;v<144;++v)A[v]=8;for(var v=144;v<256;++v)A[v]=9;for(var v=256;v<280;++v)A[v]=7;for(var v=280;v<288;++v)A[v]=8;for(var j=new l(32),v=0;v<32;++v)j[v]=5;var hr=m(A,9,1),br=m(j,5,1),B=function(r){for(var e=r[0],n=1;ne&&(e=r[n]);return e},c=function(r,e,n){var i=e/8|0;return(r[i]|r[i+1]<<8)>>(e&7)&n},J=function(r,e){var n=e/8|0;return(r[n]|r[n+1]<<8|r[n+2]<<16)>>(e&7)},sr=function(r){return(r+7)/8|0},yr=function(r,e,n){return(n==null||n>r.length)&&(n=r.length),new l(r.subarray(e,n))},zr=["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"],t=function(r,e,n){var i=new Error(e||zr[r]);if(i.code=r,Error.captureStackTrace&&Error.captureStackTrace(i,t),!n)throw i;return i},N=function(r,e,n,i){var f=r.length,g=0;if(!f||e.f&&!e.l)return n||new l(0);var s=!n,h=s||e.i!=2,p=e.i;s&&(n=new l(f*3));var C=function(vr){var or=n.length;if(vr>or){var lr=new l(Math.max(or*2,vr));lr.set(n),n=lr}},y=e.f||0,a=e.p||0,o=e.b||0,F=e.l,D=e.d,E=e.m,T=e.n,R=f*8;do{if(!F){y=c(r,a,1);var _=c(r,a+1,3);if(a+=3,_)if(_==1)F=hr,D=br,E=9,T=5;else if(_==2){var H=c(r,a,31)+257,L=c(r,a+10,15)+4,d=H+c(r,a+5,31)+1;a+=14;for(var M=new l(d),K=new l(19),u=0;u>4;if(w<16)M[u++]=w;else{var x=0,I=0;for(w==16?(I=3+c(r,a,3),a+=2,x=M[u-1]):w==17?(I=3+c(r,a,7),a+=3):w==18&&(I=11+c(r,a,127),a+=7);I--;)M[u++]=x}}var nr=M.subarray(0,H),z=M.subarray(H);E=B(nr),T=B(z),F=m(nr,E,1),D=m(z,T,1)}else t(1);else{var w=sr(a)+4,q=r[w-4]|r[w-3]<<8,G=w+q;if(G>f){p&&t(0);break}h&&C(o+q),n.set(r.subarray(w,G),o),e.b=o+=q,e.p=a=G*8,e.f=y;continue}if(a>R){p&&t(0);break}}h&&C(o+131072);for(var Dr=(1<>4;if(a+=x&15,a>R){p&&t(0);break}if(x||t(2),S<256)n[o++]=S;else if(S==256){P=a,F=null;break}else{var ar=S-254;if(S>264){var u=S-257,U=W[u];ar=c(r,a,(1<>4;Q||t(3),a+=Q&15;var z=gr[V];if(V>3){var U=X[V];z+=J(r,a)&(1<R){p&&t(0);break}h&&C(o+131072);var ir=o+ar;if(o>3&1)+(e>>4&1);i>0;i-=!r[n++]);return n+(e&2)},pr=function(r){var e=r.length;return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0},xr=function(r,e){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&t(6,"invalid zlib data"),(r[1]>>5&1)==1&&t(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Sr(r,e){return N(r,{i:2},e,e)}function mr(r,e){var n=kr(r);return n+8>r.length&&t(6,"invalid gzip data"),N(r.subarray(n,-8),{i:2},new l(pr(r)),e)}function Ar(r,e){return N(r.subarray(xr(r),-4),{i:2},e,e)}function Cr(r,e){return r[0]==31&&r[1]==139&&r[2]==8?mr(r,e):(r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31?Sr(r,e):Ar(r,e)}var Er=typeof TextDecoder<"u"&&new TextDecoder,Tr=0;try{Er.decode(Fr,{stream:!0}),Tr=1}catch{}self.addEventListener("message",r=>{const e=Cr(r.data);let n="";for(let i=0;i{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ps),{name:e?.name})}}const Hn=new oh,ms=async(e,t)=>{t.type==="zlib"?await new Promise(r=>{Hn.onmessage=i=>{Xn(e,i.data),r()};const n=new Uint8Array(t.buffer);Hn.postMessage(n,[n.buffer])}):Xn(e,t)},ch=(e,t)=>{e.willTrigger(x.OPEN)&&e.dispatchEvent(new x(x.OPEN)),e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},lh=(e,t)=>{e.willTrigger(Z.PROGRESS)&&e.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total))},uh=async(e,t)=>{const r=t.target;if(!r)return;const n=e.contentLoaderInfo;if(n.willTrigger(Z.PROGRESS)&&n.dispatchEvent(new Z(Z.PROGRESS,!1,t.loaded,t.total)),n.willTrigger(Gt.HTTP_STATUS)){const i=oo(r.getAllResponseHeaders());n.dispatchEvent(new Gt(Gt.HTTP_STATUS,!1,r.status,r.responseURL,i))}199r.status?(await ms(e,r.response),n.willTrigger(x.COMPLETE)&&n.dispatchEvent(new x(x.COMPLETE))):n.willTrigger(Re.IO_ERROR)&&n.dispatchEvent(new Re(Re.IO_ERROR,!1,r.statusText))},hh=async(e,t)=>{await new Promise(r=>{ao({format:t.responseDataFormat,url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:n=>{ch(e.contentLoaderInfo,n)},progress:n=>{lh(e.contentLoaderInfo,n)},loadend:async n=>{await uh(e,n),r()}}})})};class gs{contentLoaderInfo;root;constructor(){this.root=null,this.contentLoaderInfo=new Sc}get content(){return this.contentLoaderInfo.content}get loaderInfo(){return this.contentLoaderInfo}async load(t){if(t.responseDataFormat!=="json")throw new Error("The only format that can be loaded by this function is `json` format.");this.contentLoaderInfo.url=t.url,this.contentLoaderInfo.format=t.responseDataFormat,await hh(this,t)}async loadJSON(t){await ms(this,t)}}const bs=()=>{for(;kr.length;){const e=kr.pop(),t=e.$actions;if(!t)continue;const r=e.currentFrame;if(!t.has(r))continue;const n=t.get(r);if(n)for(let i=0;i{for(;Ur.length;){const e=Ur.pop(),t=e.$sounds;if(!t)continue;const r=e.currentFrame;if(!t.has(r))continue;const n=t.get(r),i=e.soundTransform;for(let s=0;s{if(!t||!t.size)return;const r=e.currentFrame;t.has(r)&&Ur.push(e)},ys=e=>{e.$canSound&&(e.$canSound=!1,fh(e,e.$sounds))},$s=e=>{const t=e.children;for(let r=t.length-1;r>-1;--r){const n=t[r];n&&n.isContainerEnabled&&($s(n),n.isTimelineEnabled&&(ys(n),Zt(n)))}},dh=e=>{$s(e),xs(),bs()},Ah=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e);class ph{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...t){this.buffer.length{const t=new Uint32Array(e.buffer,e.byteOffset,e.length),r=t.length;let n=2166136261,i=0;const s=r&-8;for(;i>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619),a=t[i++],n=Math.imul(n^a&255,16777619),n=Math.imul(n^a>>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619)}for(;i>8&255,16777619),n=Math.imul(n^a>>16&255,16777619),n=Math.imul(n^a>>>24,16777619)}return n>>>8^n&255&16777215},pr=e=>{switch(e){case"copy":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"normal":return 11;case"overlay":return 12;case"screen":return 13;case"subtract":return 14;default:return 11}},vs=(e,t,r,n,i)=>{if(!e.visible){b.push(0);return}const s=e.graphics,a=s.isDrawable;if(!a&&!e.isBitmap){b.push(0);return}const o=Ve(e),c=o&&(o[0]!==1||o[1]!==1||o[2]!==1||o[3]!==1||o[4]!==0||o[5]!==0||o[6]!==0||o[7]!==0)?U.multiply(r,o):r;if(!me(c[3]+c[7]/255,0,1,0)){c!==r&&U.release(c),b.push(0);return}const h=_(e),l=h&&(h[0]!==1||h[1]!==0||h[2]!==0||h[3]!==1||h[4]!==0||h[5]!==0)?T.multiply(t,h):t,f=he(s.xMin,s.yMin,s.xMax,s.yMax,l),A=f[0],d=f[1],y=f[2],g=f[3];k(f);const p=Math.ceil(Math.abs(y-A)),$=Math.ceil(Math.abs(g-d));switch(!0){case p===0:case $===0:case p===-1/0:case $===-1/0:case p===1/0:case $===1/0:c!==r&&U.release(c),l!==t&&T.release(l),b.push(0);return}if(0>A+p||0>d+$||A>n||d>i){c!==r&&U.release(c),l!==t&&T.release(l),b.push(0);return}const w=h&&e.scale9Grid?Math.abs(h[1])<.001&&Math.abs(h[2])<1e-4:!1;if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const J=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(J))}`,oe(J)}else e.uniqueKey=e.isBitmap?`${mt(new Float32Array(e.$bitmapBuffer.buffer))}`:`${mt(s.buffer)}`;const I=Math.sqrt(l[0]*l[0]+l[1]*l[1]),P=Math.sqrt(l[2]*l[2]+l[3]*l[3]),W=Math.round(I*100)/100,C=Math.round(P*100)/100;(!e.isBitmap&&!e.cacheKey||e.cacheParams[0]!==W||e.cacheParams[1]!==C||e.cacheParams[2]!==c[7])&&(e.cacheKey=O.generateKeys(W,C,c[7]),e.cacheParams[0]=W,e.cacheParams[1]=C,e.cacheParams[2]=c[7]);const R=e.isBitmap?0:e.cacheKey;if(b.pushShapeBuffer(1,xi,l[0],l[1],l[2],l[3],l[4],l[5],c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],A,d,y,g,s.xMin,s.yMin,s.xMax,s.yMax,+w,+a,+e.isBitmap,+e.uniqueKey,R,I,P,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null),e.$cache?e.$cache.get(`${R}`):O.get(e.uniqueKey,`${R}`))e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);else{if(b.push(0),w){const Y=v.rendererScale,ee=je(Y,0,0,Y,0,0),Q=T.multiply(ee,h||xt);Ft(ee);const ce=e.parent.concatenatedMatrix.rawData,ae=je(ce[0],ce[1],ce[2],ce[3],ce[4]*Y-A,ce[5]*Y-d);T.release(ce);const Ke=T.multiply(ae,Q),Qe=Ke[4]-(l[4]-A),ks=Ke[5]-(l[5]-d);Ft(Ke);const st=he(s.xMin,s.yMin,s.xMax,s.yMax,Q),Bn=st[0],Tn=st[1],Us=st[2],Gs=st[3];k(st);const Tt=Math.ceil(Math.abs(Us-Bn)),St=Math.ceil(Math.abs(Gs-Tn)),xe=e.scale9Grid,br=Math.abs(s.xMax-s.xMin),xr=Math.abs(s.yMax-s.yMin),It=xe.width>0?(xe.x-s.xMin)/br:1e-5,Ct=xe.height>0?(xe.y-s.yMin)/xr:1e-5,yr=xe.width>0?(xe.x+xe.width-s.xMin)/br:.99999,$r=xe.height>0?(xe.y+xe.height-s.yMin)/xr:.99999,Sn=Math.ceil(br*Y),In=Math.ceil(xr*Y);let vr=Sn*It/Tt,wr=In*Ct/St,Mr=(Tt-Sn*(1-yr))/Tt,Br=(St-In*(1-$r))/St;if(vr>=Mr){const at=It/(It+(1-yr));vr=Math.max(at-1e-5,0),Mr=Math.min(at+1e-5,1)}if(wr>=Br){const at=Ct/(Ct+(1-$r));wr=Math.max(at-1e-5,0),Br=Math.min(at+1e-5,1)}b.push(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5],ae[0],ae[1],ae[2],ae[3],ae[4]-Qe,ae[5]-ks,Bn,Tn,Tt,St,It,Ct,vr,wr,yr,$r,Mr,Br),Ft(ae),Ft(Q)}const J=a||w?s.buffer:e.$bitmapBuffer;b.push(J.length),b.set(J),O.set(e.uniqueKey,`${R}`,!0),e.$cache&&(e.$cache=null)}b.push(pr(e.blendMode));const N=e.filters;if(N){let J=!1;const Y=[],ee=re(0,0,0,0);for(let ce=0;ce0;Q?(b.push(+Q,+J,ee[0],ee[1],ee[2],ee[3],Y.length),b.set(new Float32Array(Y))):b.push(0),k(ee)}else b.push(0);c!==r&&U.release(c),l!==t&&T.release(l)},zr=(e,t)=>{const r=_(e),n=r?T.multiply(t,r):t;n!==t&&T.release(n);const i=r&&e.scale9Grid?Math.abs(r[1])<.001&&Math.abs(r[2])<1e-4:!1,s=e.graphics.buffer;b.push(xi,n[0],n[1],n[2],n[3],n[4],n[5],+i,s.length),b.set(s)},mh=new TextEncoder,ws=(e,t,r,n,i)=>{if(!e.visible){b.push(0);return}const s=Ve(e),a=s&&(s[0]!==1||s[1]!==1||s[2]!==1||s[3]!==1||s[4]!==0||s[5]!==0||s[6]!==0||s[7]!==0)?U.multiply(r,s):r;if(!me(a[3]+a[7]/255,0,1,0)){a!==r&&U.release(a),b.push(0);return}const c=_(e),u=c&&(c[0]!==1||c[1]!==0||c[2]!==0||c[3]!==1||c[4]!==0||c[5]!==0)?T.multiply(t,c):t,h=he(e.xMin,e.yMin,e.xMax,e.yMax,u),l=h[0],f=h[1],A=h[2],d=h[3];k(h);const y=Math.ceil(Math.abs(A-l)),g=Math.ceil(Math.abs(d-f));switch(!0){case y===0:case g===0:case y===-1/0:case g===-1/0:case y===1/0:case g===1/0:a!==r&&U.release(a),u!==t&&T.release(u),b.push(0);return}if(0>l+y||0>f+g||l>n||f>i){a!==r&&U.release(a),u!==t&&T.release(u),b.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const C=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(C))}`,oe(C)}else e.uniqueKey=`${e.instanceId}`;const p=Math.sqrt(u[0]*u[0]+u[1]*u[1]),$=Math.sqrt(u[2]*u[2]+u[3]*u[3]),w=Math.round(p*100)/100,I=Math.round($*100)/100;(e.changed&&!e.cacheKey||e.cacheParams[0]!==w||e.cacheParams[1]!==I||e.cacheParams[2]!==a[7])&&(e.cacheKey=O.generateKeys(w,I,a[7]),e.cacheParams[0]=w,e.cacheParams[1]=I,e.cacheParams[2]=a[7]);const P=e.cacheKey;b.pushTextFieldBuffer(1,eo,u[0],u[1],u[2],u[3],u[4],u[5],a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l,f,A,d,e.xMin,e.yMin,e.xMax,e.yMax,+e.uniqueKey,P,+e.changed,p,$,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);const W=e.$cache?e.$cache.get(`${P}`):O.get(e.uniqueKey,`${P}`);if(!W||e.changed){b.push(0,+W);const C=mh.encode(JSON.stringify(e.$textData));switch(b.push(C.length),b.set(C),e.autoSize){case"center":b.push(0);break;case"left":b.push(1);break;case"none":b.push(2);break;case"right":b.push(3);break}b.push(e.stopIndex,e.scrollX,e.scrollY,e.textWidth,e.textHeight,Math.abs(e.xMax-e.xMin),Math.abs(e.yMax-e.yMin),e.focusIndex,e.selectIndex,+e.focusVisible,e.thickness,e.thicknessColor,+e.wordWrap,+e.border,e.borderColor,+e.background,e.backgroundColor,e.defaultTextFormat.color||0,e.defaultTextFormat.size||0),W||O.set(e.uniqueKey,`${P}`,!0),e.$cache&&(e.$cache=null)}else e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);if(b.push(pr(e.blendMode)),e.filters?.length){let C=!1;const R=[],L=re(0,0,0,0);for(let J=0;J0;N?(b.push(+N,+C,L[0],L[1],L[2],L[3],R.length),b.set(new Float32Array(R))):b.push(0),k(L)}else b.push(0);a!==r&&U.release(a),u!==t&&T.release(u)},Ms=(e,t,r,n,i,s)=>{if(!e.visible||!e.$videoElement||!e.$offscreenCanvas||!e.loaded){b.push(0);return}const a=Ve(e),o=a&&(a[0]!==1||a[1]!==1||a[2]!==1||a[3]!==1||a[4]!==0||a[5]!==0||a[6]!==0||a[7]!==0)?U.multiply(n,a):n;if(!me(o[3]+o[7]/255,0,1,0)){o!==n&&U.release(o),b.push(0);return}const u=_(e),h=u&&(u[0]!==1||u[1]!==0||u[2]!==0||u[3]!==1||u[4]!==0||u[5]!==0)?T.multiply(r,u):r,l=he(0,0,e.videoWidth,e.videoHeight,h),f=l[0],A=l[1],d=l[2],y=l[3];k(l);const g=Math.ceil(Math.abs(d-f)),p=Math.ceil(Math.abs(y-A));switch(!0){case g===0:case p===0:case g===-1/0:case p===-1/0:case g===1/0:case p===1/0:o!==n&&U.release(o),h!==r&&T.release(h),b.push(0);return}if(0>f+g||0>A+p||f>i||A>s){o!==n&&U.release(o),h!==r&&T.release(h),b.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){const w=z(e.loaderInfo.id,e.characterId);e.uniqueKey=`${mt(new Float32Array(w))}`,oe(w)}else e.uniqueKey=`${e.instanceId}`;b.pushVideoBuffer(1,to,h[0],h[1],h[2],h[3],h[4],h[5],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],f,A,d,y,0,0,e.videoWidth,e.videoHeight,+e.uniqueKey,+e.changed,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);const $=e.$cache?e.$cache.get("0"):O.get(e.uniqueKey,"0");if(!$||e.changed){b.push(0,+$);const w=e.$context;if(w){const I=e.videoWidth/2,P=e.videoHeight/2;w.save(),w.translate(I,P),w.rotate(Math.PI),w.scale(-1,1),w.drawImage(e.$videoElement,-I,-P,e.videoWidth,e.videoHeight),w.restore(),t.push(e.$offscreenCanvas.transferToImageBitmap())}$||O.set(e.uniqueKey,"0",!0),e.$cache&&(e.$cache=null)}else e.$cache||(e.$cache=O.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),b.push(1);if(b.push(pr(e.blendMode)),e.filters?.length){let w=!1;const I=[],P=re(0,0,0,0);for(let C=0;C0;W?(b.push(+W,+w,P[0],P[1],P[2],P[3],I.length),b.set(new Float32Array(I))):b.push(0),k(P)}else b.push(0);o!==n&&U.release(o),h!==r&&T.release(h)},Jn=(e,t,r,n)=>{let i=null;switch(!0){case e.isContainerEnabled:i=yt(e,t);break;case e.isShape:i=wt(e,t);break;case e.isText:i=Bt(e,t);break;case e.isVideo:i=Mt(e,t);break}if(!i)return null;const s=i[0],a=i[2],o=Math.abs(a-s);if(!o)return null;const c=i[1],u=i[3],h=Math.abs(u-c);return!h||0>s+o||0>c+h||s>r||c>n?null:i},Hr=(e,t)=>{const r=_(e),n=r?T.multiply(t,r):t,i=e.children;b.push(bi,i.length);for(let s=0;s{const r=wt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=Mt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=Bt(e,t),n=e.filters;if(n){const i=re(0,0,0,0);for(let s=0;s{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),i=n?t?T.multiply(t,n):n:t,s=Number.MAX_VALUE;let a=s,o=-s,c=s,u=-s;for(let h=0;h{if(!e.visible){b.push(0);return}const a=Ve(e);let o=a&&(a[0]!==1||a[1]!==1||a[2]!==1||a[3]!==1||a[4]!==0||a[5]!==0||a[6]!==0||a[7]!==0)?U.multiply(n,a):n;if(!me(o[3]+o[7]/255,0,1,0)){o!==n&&U.release(o),b.push(0);return}const u=e.children;if(!u.length){o!==n&&U.release(o),b.push(0);return}const h=_(e);let l=h&&(h[0]!==1||h[1]!==0||h[2]!==0||h[3]!==1||h[4]!==0||h[5]!==0)?T.multiply(r,h):r;if(!l[0]&&!l[1]||!l[2]&&!l[3]){o!==n&&U.release(o),l!==r&&T.release(l),b.push(0);return}b.push(1,bi);const f=e.blendMode;b.push(pr(f));const A=e.filters;if(A){const p=O.generateFilterKeys(l[0],l[1],l[2],l[3]),$=O.get(`${e.instanceId}`,`${p}`);let w=!1;const I=[],P=re(0,0,0,0);for(let C=0;C0){w||(w=e.changed);const C=Bs(e,r);if($){if(!w){b.push(1,Math.ceil(Math.abs(C[2]-C[0])),Math.ceil(Math.abs(C[3]-C[1])),1,1,e.instanceId,p,P[0],P[1],P[2],P[3],l[0],l[1],l[2],l[3],C[0],C[1],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]),k(C),k(P),o!==n&&U.release(o),l!==r&&T.release(l);return}O.removeById(`${e.instanceId}`)}b.push(1,Math.ceil(Math.abs(C[2]-C[0])),Math.ceil(Math.abs(C[3]-C[1])),1,0,e.instanceId,p,P[0],P[1],P[2],P[3],l[0],l[1],l[2],l[3],C[0],C[1],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],I.length),b.set(new Float32Array(I));const R=l[0],L=l[1],N=l[2],J=l[3],Y=l[4]-C[0],ee=l[5]-C[1];l!==r&&T.release(l),l=je(R,L,N,J,Y,ee),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0),k(C),O.set(`${e.instanceId}`,`${p}`,!0)}else if(f==="normal")b.push(0);else{const C=yt(e,r),R=C[0],L=C[1];b.push(1,Math.ceil(Math.abs(C[2]-R)),Math.ceil(Math.abs(C[3]-L)),0,l[0],l[1],l[2],l[3],R,L,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]);const N=l[0],J=l[1],Y=l[2],ee=l[3],Q=l[4]-R,ce=l[5]-L;l!==r&&T.release(l),l=je(N,J,Y,ee,Q,ce),k(C),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0)}k(P)}else if(f==="normal")b.push(0);else{const p=yt(e,r),$=p[0],w=p[1];b.push(1,Math.ceil(Math.abs(p[2]-$)),Math.ceil(Math.abs(p[3]-w)),0,l[0],l[1],l[2],l[3],$,w,o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7]);const I=l[0],P=l[1],W=l[2],C=l[3],R=l[4]-$,L=l[5]-w;l!==r&&T.release(l),l=je(I,P,W,C,R,L),k(p),o!==n&&U.release(o),o=_t(1,1,1,1,0,0,0,0)}const d=e.mask;if(d){const p=Jn(d,l,i,s);if(!p)b.push(0);else switch(b.push(1,p[0],p[1],p[2],p[3]),!0){case d.isContainerEnabled:Hr(d,l);break;case d.isShape:zr(d,l);break}d.changed=!1}else b.push(0);b.push(u.length);let y=0,g=!0;for(let p=0;py&&(y=0,g=!0),!g){b.push(0),$.changed=!1;continue}if($.clipDepth){y=$.clipDepth;const w=Jn($,l,i,s);if(g=!!w,b.push(+g),!w){$.changed=!1;continue}switch(b.push(w[0],w[1],w[2],w[3]),!0){case $.isContainerEnabled:Hr($,l);break;case $.isShape:zr($,l);break}$.changed=!1;continue}switch(!0){case $.isContainerEnabled:Ts($,t,l,o,i,s);break;case $.isShape:vs($,l,o,i,s);break;case $.isText:ws($,l,o,i,s);break;case $.isVideo:Ms($,t,l,o,i,s);break}$.changed=!1}o!==n&&U.release(o),l!==r&&T.release(l)},yh=(e,t,r,n,i,s)=>{switch(b.push(v.backgroundColor),!0){case e.isContainerEnabled:Ts(e,t,r,n,i,s);break;case e.isShape:vs(e,r,n,i,s);break;case e.isText:ws(e,r,n,i,s);break;case e.isVideo:Ms(e,t,r,n,i,s);break}e.changed=!1},Zn=e=>{e.totalFrames===1||!e.isPlaying||(e.$wait||(++e.currentFrame,e.currentFrame>e.totalFrames&&(e.currentFrame=1)),e.$wait=!1,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,e.$container=null,ys(e),Zt(e),j(e))},Jr=e=>{const t=e.$container;if(t)for(let r=0;t.length>r;++r){const n=t[r];n.isTimelineEnabled&&Zn(n),Jr(n)}else{const r=[],n=e.children;for(let i=0;n.length>i;++i){const s=n[i];s.isContainerEnabled&&(s.isTimelineEnabled&&Zn(s),Jr(s),r.push(s))}e.$container=r}},$h=()=>{Jr(v),xs(),bs()};class vh extends dn{_$ready;stageWidth;stageHeight;frameRate;rendererScale;rendererWidth;rendererHeight;_$backgroundColor;constructor(){super(),this.stageWidth=0,this.stageHeight=0,this.frameRate=1,this.rendererScale=1,this.rendererWidth=0,this.rendererHeight=0,this._$ready=!1,this._$backgroundColor=-1}get backgroundColor(){return this._$backgroundColor}set backgroundColor(t){this._$backgroundColor=t==="transparent"?-1:parseInt(t.replace("#",""),16)}get pointer(){return bt}set ready(t){!t||this._$ready||(this._$ready=t,dh(this))}addChild(t){return ge.add(t.instanceId),we.set(this,t),super.addChild(t),we.delete(this),we.set(t,t),t}$ticker(){$h()}$generateRenderQueue(t,r,n,i){yh(t,r,n,i,this.rendererWidth,this.rendererHeight)}$mouseHit(t,r,n){He(this,t,r,n,!0)}}const v=new vh;ge.add(v.instanceId);const Fr={command:"resize",buffer:null},qn=[],Zr=(e=!0)=>{Fr.buffer=new Float32Array([B.rendererWidth,B.rendererHeight,e?1:0]),qn[0]=Fr.buffer.buffer,Ce.postMessage(Fr,qn)},jn=window.devicePixelRatio||1,vn=()=>{Je.x=0,Je.y=0;const e=vt();if(!e)return;const t=e.children[0];!t||t.localName!=="canvas"||(Je.x=(e.clientWidth-v.rendererWidth/jn)/2,Je.y=(e.clientHeight-v.rendererHeight/jn)/2)},mr=()=>{const e=vt();if(!e)return;const t=e.parentElement;if(!t)return;const r=B.fullScreen||t.tagName==="BODY"?window.innerWidth:t.clientWidth,n=B.fullScreen||t.tagName==="BODY"?window.innerHeight:t.clientHeight,i=e.style;if(i.width=`${r}px`,i.height=`${n}px`,!v.stageWidth||!v.stageHeight)return;const s=Math.min(r/v.stageWidth,n/v.stageHeight)*Ze,a=B.fullScreen?window.innerWidth*Ze:v.stageWidth*s|0,o=B.fullScreen?window.innerHeight*Ze:v.stageHeight*s|0;a===B.screenWidth&&o===B.screenHeight||(B.screenWidth=r,B.screenHeight=n,v.changed=!0,e.children.length>1&&e.children[1].dispatchEvent(new Event(`${on}_blur`)),vn(),!(a===B.rendererWidth&&o===B.rendererHeight)&&(v.rendererScale=B.rendererScale=s,v.rendererWidth=B.rendererWidth=a,v.rendererHeight=B.rendererHeight=o,ft[0]=ft[3]=s,ft[4]=(B.rendererWidth-v.stageWidth*s)/2,ft[5]=(B.rendererHeight-v.stageHeight*s)/2,O.reset(),Zr(),v.hasEventListener(x.RESIZE)&&v.dispatchEvent(new x(x.RESIZE))))},wh=new Float32Array([1,1,1,1,0,0,0,0]),lt=[],ut={command:"render",buffer:null,length:0,imageBitmaps:null},Ot=[];Ce.addEventListener("message",e=>{if(e.data.message!=="render")return;const t=e.data.buffer;b.buffer.length>t.length||(b.buffer=t)});const Ss=()=>{b.offset=0,Ot.length=0,lt.length=0,v.$generateRenderQueue(v,lt,ft,wh),b.offset&&(ut.buffer=b.buffer,ut.length=b.offset,Ot.push(b.buffer.buffer),ut.imageBitmaps=null,lt.length&&(ut.imageBitmaps=lt,Ot.push(...lt)),Ce.postMessage(ut,Ot))},ei={command:"removeCache",buffer:null},ti=[],ri=()=>{const e=new Float32Array(O.$removeIds);O.$removeIds.length=0,ei.buffer=e,ti[0]=e.buffer,Ce.postMessage(ei,ti)},Mh=new x(x.ENTER_FRAME),Is=e=>{if(B.stopFlag)return;O.$removeIds.length&&ri();const t=e-B.startTime;t>B.fps&&(B.startTime=e-t%B.fps,v.$ticker(),v.hasEventListener(x.ENTER_FRAME)&&v.dispatchEvent(Mh),v.changed&&Ss(),O.$removeCache&&(O.removeTimerScheduledCache(),O.$removeIds.length&&ri())),B.timerId=requestAnimationFrame(r=>{Is(r)})},Bh=()=>{B.stopFlag&&(B.stopFlag=!1,v.changed=!0,B.timerId>-1&&cancelAnimationFrame(B.timerId),B.fps=1e3/v.frameRate|0,B.startTime=performance.now(),B.timerId=requestAnimationFrame(e=>{Is(e)}))},Th=()=>{B.timerId>-1&&cancelAnimationFrame(B.timerId),B.stopFlag=!0,B.timerId=-1,rt.stopAll()},Sh=e=>{const t=ke();if(t){t.keyDown(e);return}v.hasEventListener(V.KEY_DOWN)&&(We(e),v.dispatchEvent(new V(V.KEY_DOWN)))},Ih=e=>{ke()||v.hasEventListener(V.KEY_UP)&&(We(e),v.dispatchEvent(new V(V.KEY_UP)))},Ch=()=>{window.addEventListener(V.KEY_DOWN,Sh),window.addEventListener(V.KEY_UP,Ih)};class Fh{rendererWidth;rendererHeight;screenWidth;screenHeight;rendererScale;fixedWidth;fixedHeight;stopFlag;startTime;fps;tagId;_$fullScreen;timerId;mouseState;constructor(){this.rendererWidth=0,this.rendererHeight=0,this.rendererScale=1,this.screenWidth=0,this.screenHeight=0,this.stopFlag=!0,this.startTime=0,this.fps=16,this.timerId=-1,this.mouseState="up",this.fixedWidth=0,this.fixedHeight=0,this.tagId="",this._$fullScreen=!1,Ch()}get fullScreen(){return this._$fullScreen}set fullScreen(t){this._$fullScreen!==t&&(this._$fullScreen=t,mr())}play(){Bh()}stop(){Th()}cacheClear(){O.reset(),Ce.postMessage({command:"cacheClear"})}setOptions(t=null){t&&(this.fixedWidth=t.width||this.fixedWidth,this.fixedHeight=t.height||this.fixedHeight,this.tagId=t.tagId||this.tagId,this._$fullScreen=!!t.fullScreen,t.bgColor&&(v.backgroundColor=t.bgColor))}}const B=new Fh;let ni="auto";const wn=()=>{B.stopFlag||(ie.x=v.pointer.x,ie.y=v.pointer.y,ie.pointer="auto",ie.hit=null,Tr.beginPath(),Tr.setTransform(1,0,0,1,0,0),v.$mouseHit(Tr,gt,ie),B.mouseState==="up"&&ni!==ie.pointer&&(ui().style.cursor=ni=ie.pointer))},Mn=e=>{let t=window.scrollX,r=window.scrollY;const n=vt();if(n){const c=n.getBoundingClientRect();t+=c.left,r+=c.top}const i=e.target;if(i){const c=i.getBoundingClientRect();t+=c.left,r+=c.top}const s=(B.rendererWidth-v.stageWidth*B.rendererScale)/2,a=(B.rendererHeight-v.stageHeight*B.rendererScale)/2,o=B.rendererScale/Ze;v.pointer.x=(e.pageX-t)/o-s/B.rendererScale,v.pointer.y=(e.pageY-r)/o-a/B.rendererScale},Eh=()=>{const e=ie.hit,t=ke();t&&(!e||t.instanceId!==e.instanceId)&&(t.focus=!1,kn(null)),e?(e.isText&&(e.focus?setTimeout(()=>{de.focus()},300):(e.focus=!0,kn(e)),e.setFocusIndex(ie.x-gt[4],ie.y-gt[5])),e.willTrigger(S.POINTER_DOWN)&&e.dispatchEvent(new S(S.POINTER_DOWN))):v.willTrigger(S.POINTER_DOWN)&&v.dispatchEvent(new S(S.POINTER_DOWN))},Ph=()=>{const e=ie.hit;e?e.willTrigger(S.DOUBLE_CLICK)&&e.dispatchEvent(new S(S.DOUBLE_CLICK)):v.willTrigger(S.DOUBLE_CLICK)&&v.dispatchEvent(new S(S.DOUBLE_CLICK))};let ii,kt=!1;const Rh=e=>{const t=e.target;t&&(B.mouseState="down",t.setPointerCapture(e.pointerId),We(e),Mn(e),wn(),ie.hit&&e.preventDefault(),clearTimeout(ii),kt?(kt=!1,Ph()):(kt=!0,ii=setTimeout(()=>{kt=!1},300),Eh()))},Oh=()=>{const e=v.dropTarget,t=ie.hit;t?(t.willTrigger(S.POINTER_UP)&&t.dispatchEvent(new S(S.POINTER_UP)),e&&e.instanceId!==t.instanceId&&e.willTrigger(S.POINTER_UP)&&e.dispatchEvent(new S(S.POINTER_UP))):e&&e.willTrigger(S.POINTER_UP)?e.dispatchEvent(new S(S.POINTER_UP)):v.willTrigger(S.POINTER_UP)&&v.dispatchEvent(new S(S.POINTER_UP))},si=e=>{const t=e.target;t&&(B.mouseState="up",t.releasePointerCapture(e.pointerId),We(e),Mn(e),wn(),Oh())},kh=()=>{const e=v.dropTarget;if(e){const i=e.parent?e.parent.globalToLocal(v.pointer):e.globalToLocal(v.pointer);let s=0,a=0;e.$lockCenter?(s=i.x-e.width/2,a=i.y-e.height/2):(s=i.x+e.$offsetX,a=i.y+e.$offsetY);const o=e.$boundedRect;o&&(s=Vt(s,o.left,o.right),a=Vt(a,o.top,o.bottom)),e.x=s,e.y=a}const t=ke();if(t&&B.mouseState==="down"){t.setFocusIndex(ie.x-gt[4],ie.y-gt[5],!0);return}const r=fi(),n=ie.hit;n?(n.willTrigger(S.POINTER_MOVE)&&n.dispatchEvent(new S(S.POINTER_MOVE)),r?r.instanceId!==n.instanceId&&(r.willTrigger(S.POINTER_OUT)&&r.dispatchEvent(new S(S.POINTER_OUT)),n.willTrigger(S.POINTER_OVER)&&n.dispatchEvent(new S(S.POINTER_OVER))):n.willTrigger(S.POINTER_OVER)&&n.dispatchEvent(new S(S.POINTER_OVER)),Cn(n)):(r&&(r.willTrigger(S.POINTER_OUT)&&r.dispatchEvent(new S(S.POINTER_OUT)),Cn(null)),v.hasEventListener(S.POINTER_MOVE)&&v.dispatchEvent(new S(S.POINTER_MOVE)))},Uh=e=>{e.target&&(We(e),Mn(e),wn(),ie.hit&&e.preventDefault(),kh())},Gh=e=>{We(e);const t=fi();t&&t.willTrigger(S.POINTER_LEAVE)&&(e.preventDefault(),t.dispatchEvent(new S(S.POINTER_LEAVE)))},_h=e=>{We(e);const t=ie.hit;if(t&&t.isText&&t.scrollEnabled){e.preventDefault(),e.deltaX&&(t.scrollX+=e.deltaX/(t.textWidth/t.width)),e.deltaY&&(t.scrollY+=e.deltaY/(t.textHeight/t.height));return}v.willTrigger(qe.WHEEL)&&(e.preventDefault(),v.dispatchEvent(new qe(qe.WHEEL)))},Dh=e=>{const t=()=>{Mu();const r=$u();for(let n=0;n{Object.defineProperty(qr,e,{get(){return t}})});const jr={Sprite:An,MovieClip:qt,BitmapData:_e,BlendMode:ua,DisplayObject:hr,DisplayObjectContainer:dn,FrameLabel:Ki,Graphics:M,InteractiveObject:fn,Loader:gs,Shape:$t,stage:v};Object.entries(jr).forEach(([e,t])=>{Object.defineProperty(jr,e,{get(){return t}})});const en={BevelFilter:rr,BlurFilter:nr,ColorMatrixFilter:ir,ConvolutionFilter:sr,DisplacementMapFilter:ar,DropShadowFilter:or,GlowFilter:cr,GradientBevelFilter:lr,GradientGlowFilter:ur};Object.entries(en).forEach(([e,t])=>{Object.defineProperty(en,e,{get(){return t}})});const tn={ColorTransform:U,Matrix:T,Point:se,Rectangle:be};Object.entries(tn).forEach(([e,t])=>{Object.defineProperty(tn,e,{get(){return t}})});const rn={Sound:dr,SoundMixer:rt,SoundTransform:_u,Video:Xr};Object.entries(rn).forEach(([e,t])=>{Object.defineProperty(rn,e,{get(){return t}})});class Cs{requestHeaders;url;contentType;data;method;responseDataFormat;withCredentials;constructor(t=""){this.url=`${t}`,this.contentType="application/json",this.data=null,this.method="GET",this.requestHeaders=[],this.responseDataFormat="json",this.withCredentials=!1}get headers(){const t=[];return t.push({name:"Content-Type",value:this.contentType}),this.requestHeaders.length&&t.push(...this.requestHeaders),t}}const nn={URLRequest:Cs};Object.entries(nn).forEach(([e,t])=>{Object.defineProperty(nn,e,{get(){return t}})});const sn={TextFormat:ue,TextField:Qr};Object.entries(sn).forEach(([e,t])=>{Object.defineProperty(sn,e,{get(){return t}})});const an={Easing:Ye,Tween:gn};Object.entries(an).forEach(([e,t])=>{Object.defineProperty(an,e,{get(){return t}})});const Fs=()=>{const e=vt();if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},Es=()=>{const e=vt();if(!e)return;const t=ui();t&&(e.appendChild(t),e.appendChild(de))},Ps=()=>{v.ready=!0,Ss(),B.play(),v.changed=!1},Lh=()=>{const e=document.createElement("div");if(_s(e),e.id=on,e.tabIndex=-1,!B.tagId)document.body.appendChild(e);else{const t=document.getElementById(B.tagId);if(!t)return alert(`Element not found with tag ID: ${B.tagId}`),e;t.appendChild(e)}return e},Nh=(e,t=0,r=0)=>{let n="";if(n+="display:flex;",n+="align-items:center;",n+="justify-content:center;",n+="background-color:transparent;",n+="overflow:hidden;",n+="padding:0;",n+="margin:0;",n+="user-select:none;",n+="outline:none;",t&&r)n+=`width:${t}px;`,n+=`height:${r}px;`;else{const i=e.parentElement;if(!i)throw new Error("parent element is null.");i.tagName==="BODY"?(n+=`width:${window.innerWidth}px;`,n+=`height:${window.innerHeight}px;`):(n+=`width:${i.clientWidth}px;`,n+=`height:${i.clientHeight}px;`)}e.setAttribute("style",n)},Yh=e=>{const t=`${on}_loading`;e.innerHTML=` -
`};let ai=-1;const Wh=()=>{window.addEventListener("resize",()=>{cancelAnimationFrame(ai),ai=requestAnimationFrame(mr)})},Rs=(e=null)=>{B.setOptions(e);const t=Lh();Nh(t,B.fixedWidth,B.fixedHeight),Yh(t),!B.fixedWidth&&!B.fixedHeight&&Wh(),mr()},Vh=async(e,t=null)=>{if(e==="develop"){const s=location.search.slice(1).split("&")[0];if(!s)return;e=`${location.origin}/${s}`}if(!e)return;e.charAt(1)==="/"&&(e=e.slice(1)),Rs(t);const r=new gs,n=r.contentLoaderInfo;if(n.addEventListener(Re.IO_ERROR,s=>{alert("Error: "+s.text)}),await r.load(new Cs(e)),!n.data)return;const i=n.data.stage;v.stageWidth=i.width,v.stageHeight=i.height,v.frameRate=Vt(i.fps,1,60,60),v.backgroundColor=t&&t.bgColor?t.bgColor:i.bgColor,v.addChild(n.content),mr(),Ps(),Fs(),Es(),vn()};let oi=!1;const Kh=(e=240,t=240,r=60,n=null)=>{if(oi)return v.getChildAt(0);oi=!0,v.stageWidth=e|0,v.stageHeight=t|0,v.frameRate=Vt(r,1,60,60),Rs(n);const i=v.addChild(new An);return Ps(),Fs(),Es(),vn(),i},Te={command:"capture",buffer:null,bgColor:16777215,bgAlpha:0,width:0,height:0,length:0,imageBitmaps:null},Ut=[],ht=[],Qh=async(e,t,r,n,i=0,s=0)=>await new Promise(a=>{if(b.offset=0,Ut.length=0,ht.length=0,v.$generateRenderQueue(e,ht,t,r),!b.offset)return a(n);Te.buffer=b.buffer,Te.width=n.width,Te.height=n.height,Te.bgColor=i,Te.bgAlpha=s,Te.length=b.offset,Ut.push(b.buffer.buffer),Te.imageBitmaps=null,ht.length&&(Te.imageBitmaps=ht,Ut.push(...ht));const o=c=>{if(c.data.message!=="capture")return;const u=c.data.buffer;return b.buffer.length{switch(!0){case e.isVideo:{const t=e.muted;e.muted=!0,await e.play(),e.pause(),e.muted=t,await new Promise(r=>{const n=async()=>{e.loaded?(e.seek(0),r()):requestAnimationFrame(n)};requestAnimationFrame(n)})}break;case e.isContainerEnabled:{const t=e.children;for(let r=0;r{t&&t.videoSync&&await Os(e);const r=t&&t.colorTransform?t.colorTransform.rawData:zh,n=new Float32Array([1,0,0,1,-e.width/2,-e.height/2]),i=t&&t.matrix?T.multiply(t.matrix.rawData,n):T.multiply(Xh,n),s=t&&t.canvas?t.canvas:O.getCanvas(),a=Math.sqrt(i[0]*i[0]+i[1]*i[1]),o=Math.sqrt(i[2]*i[2]+i[3]*i[3]),c=Math.ceil(e.width*a),u=Math.ceil(e.height*o);if(c<=0||u<=0)return s;i[4]+=c/2,i[5]+=u/2,s.width=c,s.height=u;const h=B.stopFlag;h||B.stop();let l=!1;const f=B.rendererWidth,A=B.rendererHeight,d=B.rendererScale;if(c>f||u>A){l=!0;const y=Math.min(c/v.stageWidth,u/v.stageHeight)*Ze;v.rendererScale=B.rendererScale=y,v.rendererWidth=B.rendererWidth=c,v.rendererHeight=B.rendererHeight=u,Zr(!1)}return await Qh(e,i,r,s,t&&t.bgColor?parseInt(t.bgColor.replace("#",""),16):0,t&&t.bgAlpha?t.bgAlpha:0),l&&(v.rendererScale=B.rendererScale=d,v.rendererWidth=B.rendererWidth=f,v.rendererHeight=B.rendererHeight=A,Zr(!1)),h||B.play(),T.release(i),t&&t.colorTransform&&U.release(r),s};class Jh{display;events;filters;geom;media;net;text;ui;_$promise;constructor(){this.display=jr,this.events=qr,this.filters=en,this.geom=tn,this.media=rn,this.net=nn,this.text=sn,this.ui=an,this._$promise=new Promise(t=>{document.readyState==="loading"?window.addEventListener("DOMContentLoaded",()=>t(),{once:!0}):t()})}async load(t,r=null){await Promise.all([this._$promise]),await Vh(t,r)}async createRootMovieClip(t=240,r=240,n=60,i=null){return await Promise.all([this._$promise]),Kh(t,r,n,i)}async captureToCanvas(t,r=null){return await Hh(t,r)}}"next2d"in window||(console.log("%c Next2D Player %c 3.0.1 %c https://next2d.app","color: #fff; background: #5f5f5f","color: #fff; background: #4bc729",""),window.next2d=new Jh); +
`},Xl=-1,Zl=()=>{window.addEventListener(`resize`,()=>{cancelAnimationFrame(Xl),Xl=requestAnimationFrame(Yc)})},Ql=(e=null)=>{$.setOptions(e);let t=ql();Jl(t,$.fixedWidth,$.fixedHeight),Yl(t),!$.fixedWidth&&!$.fixedHeight&&Zl(),Yc()},$l=async(e,t=null)=>{if(e===`develop`){let t=location.search.slice(1).split(`&`)[0];if(!t)return;e=`${location.origin}/${t}`}if(!e)return;e.charAt(1)===`/`&&(e=e.slice(1)),Ql(t);let r=new _c,i=r.contentLoaderInfo;if(i.addEventListener(me.IO_ERROR,e=>{alert(`Error: `+e.text)}),await r.load(new Bl(e)),!i.data)return;let a=i.data.stage;Q.stageWidth=a.width,Q.stageHeight=a.height,Q.frameRate=n(a.fps,1,60,60),Q.backgroundColor=t&&t.bgColor?t.bgColor:a.bgColor,Q.addChild(i.content),Yc(),Kl(),Wl(),Gl(),Jc()},eu=!1,tu=(e=240,t=240,r=60,i=null)=>{if(eu)return Q.getChildAt(0);eu=!0,Q.stageWidth=e|0,Q.stageHeight=t|0,Q.frameRate=n(r,1,60,60),Ql(i);let a=Q.addChild(new Ni);return Kl(),Wl(),Gl(),Jc(),a},nu={command:`capture`,buffer:null,bgColor:16777215,bgAlpha:0,width:0,height:0,length:0,imageBitmaps:null},ru=[],iu=[],au=async(e,t,n,r,i=0,a=0)=>await new Promise(o=>{if(Z.offset=0,ru.length=0,iu.length=0,Q.$generateRenderQueue(e,iu,t,n),!Z.offset)return o(r);nu.buffer=Z.buffer,nu.width=r.width,nu.height=r.height,nu.bgColor=i,nu.bgAlpha=a,nu.length=Z.offset,ru.push(Z.buffer.buffer),nu.imageBitmaps=null,iu.length&&(nu.imageBitmaps=iu,ru.push(...iu));let s=e=>{if(e.data.message!==`capture`)return;let t=e.data.buffer;return Z.buffer.length{switch(!0){case e.isVideo:{let t=e.muted;e.muted=!0,await e.play(),e.pause(),e.muted=t,await new Promise(t=>{let n=async()=>{e.loaded?(e.seek(0),t()):requestAnimationFrame(n)};requestAnimationFrame(n)})}break;case e.isContainerEnabled:{let t=e.children;for(let e=0;e{n&&n.videoSync&&await ou(e);let r=n&&n.colorTransform?n.colorTransform.rawData:cu,i=new Float32Array([1,0,0,1,-e.width/2,-e.height/2]),a=n&&n.matrix?P.multiply(n.matrix.rawData,i):P.multiply(su,i),o=n&&n.canvas?n.canvas:j.getCanvas(),s=Math.sqrt(a[0]*a[0]+a[1]*a[1]),c=Math.sqrt(a[2]*a[2]+a[3]*a[3]),l=Math.ceil(e.width*s),u=Math.ceil(e.height*c);if(l<=0||u<=0)return o;a[4]+=l/2,a[5]+=u/2,o.width=l,o.height=u;let d=$.stopFlag;d||$.stop();let f=!1,p=$.rendererWidth,m=$.rendererHeight,h=$.rendererScale;return(l>p||u>m)&&(f=!0,Q.rendererScale=$.rendererScale=Math.min(l/Q.stageWidth,u/Q.stageHeight)*t,Q.rendererWidth=$.rendererWidth=l,Q.rendererHeight=$.rendererHeight=u,Kc(!1)),await au(e,a,r,o,n&&n.bgColor?parseInt(n.bgColor.replace(`#`,``),16):0,n&&n.bgAlpha?n.bgAlpha:0),f&&(Q.rendererScale=$.rendererScale=h,Q.rendererWidth=$.rendererWidth=p,Q.rendererHeight=$.rendererHeight=m,Kc(!1)),d||$.play(),P.release(a),n&&n.colorTransform&&M.release(r),o},uu=class{display;events;filters;geom;media;net;text;ui;_$promise;constructor(){this.display=Il,this.events=Fl,this.filters=Ll,this.geom=Rl,this.media=zl,this.net=Vl,this.text=Hl,this.ui=Ul,this._$promise=new Promise(e=>{document.readyState===`loading`?window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e()})}async load(e,t=null){await Promise.all([this._$promise]),await $l(e,t)}async createRootMovieClip(e=240,t=240,n=60,r=null){return await Promise.all([this._$promise]),tu(e,t,n,r)}async captureToCanvas(e,t=null){return await lu(e,t)}};`next2d`in window||(console.log(`%c Next2D Player %c 3.8.2 %c https://next2d.app`,`color: #fff; background: #5f5f5f`,`color: #fff; background: #4bc729`,``),window.next2d=new uu); \ No newline at end of file