@next2d/player 3.0.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/next2d.js +11 -2349
- package/package.json +29 -35
- package/src/index.js +1 -1
package/next2d.js
CHANGED
|
@@ -1,2358 +1,20 @@
|
|
|
1
|
-
const on="__next2d__",Ze=Math.min(2,window.devicePixelRatio),Vt=(e,t,r,n=null)=>{const s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),r)},Er=document.createElement("canvas");Er.width=Er.height=1;const Tr=Er.getContext("2d");let cs=null;const _i=e=>{cs=e};let ls=null;const Di=e=>{ls=e},us=()=>ls,vt=()=>cs,ft=new Float32Array([1,0,0,1,0,0]),gt=new Float32Array([1,0,0,1,0,0]),se={x:0,y:0,pointer:"",hit:null};let hs=null;const Cn=e=>{hs=e},fs=()=>hs,Li=(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)},ds=`(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],m=e[5];return dr(r*c+s*u,n*c+o*u,r*a+s*h,n*a+o*h,r*d+s*m+i,n*d+o*m+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<Kt.length;n++){const s=Kt[n];s.length>=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<vs*vs)return Ms;const u=Math.ceil(Math.log2(Math.sqrt(c)/vs)/2);return Math.min(Math.max(u+Ms,Ms),sl)},al=t=>{Re.length<t&&(Re=new Float32Array(t*2))},cl=t=>{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,m=h*e+c*n,g=h*r+c*s,f=h*n+c*o,b=h*s+c*i,x=h*o+c*l,y=h*d+c*g,P=h*m+c*f,S=h*g+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]=m,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},Xe=(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),Xe(Mt[0],Mt[1],Mt[2],Mt[3],Mt[4],Mt[5],Mt[6],Mt[7],Re,a),a+=4,Xe(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 m=Se(),g=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,m,g),ft(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,f,b),Xe(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],Re,a),a+=4,Xe(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],Re,a),a+=4,Xe(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],Re,a),a+=4,Xe(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 m=Se(),g=Se(),f=Se(),b=Se();ft(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],.5,m,g),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(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],.5,x,y),ft(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[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),Xe(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],Re,a),a+=4,Xe(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],Re,a),a+=4,Xe(P[0],P[1],P[2],P[3],P[4],P[5],P[6],P[7],Re,a),a+=4,Xe(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],Re,a),a+=4,Xe(M[0],M[1],M[2],M[3],M[4],M[5],M[6],M[7],Re,a),a+=4,Xe($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],Re,a),a+=4,Xe(T[0],T[1],T[2],T[3],T[4],T[5],T[6],T[7],Re,a),a+=4,Xe(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<h*4;)gi(a[d++],a[d++],a[d++],a[d++])},ul=(t,e,r)=>{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<t||r.height<e)&&(t=Math.max(t,r.width),e=Math.max(e,r.height),r.width=t,r.height=e,r.area=t*e,p.bindRenderbuffer(p.RENDERBUFFER,r.resource),p.renderbufferStorageMultisample(p.RENDERBUFFER,bs,p.RGBA8,t,e),p.bindRenderbuffer(p.RENDERBUFFER,r.stencil.resource),p.renderbufferStorageMultisample(p.RENDERBUFFER,bs,p.STENCIL_INDEX8,t,e)),r.dirty=!0,r};let Tl=0;const Bl=()=>({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<et.length;++s){const o=et[s];o.width>=t&&o.height>=e&&o.area<n&&(n=o.area,r=s)}if(r!==-1){const s=et[r];return et[r]=et[et.length-1],et.pop(),s}return et.pop()},Al=(t,e)=>{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<en.length;++t){const e=en[t];e&&(e[0]=e[1]=Os,e[2]=e[3]=Es)}};let Cs=0;const Fi=t=>{Cs=t},Ll=()=>{br.length=0,Qt(0);const t=Rl();for(let e=0;e<t.length;e++)be(t[e]);t.length=0},kl=(t,e,r,n=!0)=>{if(t.clearArraysInstanced(),t.$stackAttachmentObject.length)for(let s=0;s<t.$stackAttachmentObject.length;++s){const o=t.$stackAttachmentObject[s];o&&be(o)}else t.$mainAttachmentObject&&be(t.$mainAttachmentObject);n&&Ll(),Ol(),t.$mainAttachmentObject=we(e,r,!0),t.bind(t.$mainAttachmentObject)},Il=(t,e,r,n)=>{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<e;++n)r|=(1<<e-n)-1;p.stencilMask(255),p.stencilFunc(p.EQUAL,r&255,r),p.stencilOp(p.KEEP,p.KEEP,p.KEEP),p.colorMask(!0,!0,!0,!0),p.disable(p.SAMPLE_ALPHA_TO_COVERAGE),yt()};let wi=!1;const Rn=t=>{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 m=t.length-5;for(let g=3;g<m;g+=3){let f=r*17;t[g+2]?(e[f++]=t[g-3],e[f++]=t[g-2],e[f++]=0,e[f++]=0,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g],e[f++]=t[g+1],e[f++]=.5,e[f++]=0,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g+3],e[f++]=t[g+4],e[f++]=1,e[f++]=1,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0):t[g+5]?(e[f++]=t[0],e[f++]=t[1],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g],e[f++]=t[g+1],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g+6],e[f++]=t[g+7],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0):(e[f++]=t[0],e[f++]=t[1],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g],e[f++]=t[g+1],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0,e[f++]=t[g+3],e[f++]=t[g+4],e[f++]=.5,e[f++]=.5,e[f++]=u,e[f++]=a,e[f++]=h,e[f++]=d,e[f++]=n,e[f++]=s,e[f++]=0,e[f++]=o,e[f++]=i,e[f++]=0,e[f++]=l,e[f++]=c,e[f++]=0),r+=3}return r},Oi=t=>(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},Ye=[],Bt=[],Ei=()=>{Bt.length=0,xr=0,Ye.length=0};let Ls=new Float32Array(32);const Jl=t=>(Ls.length<t&&(Ls=new Float32Array(Oi(t))),Ls),Cn=(t,e="fill")=>{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,m=l[1]/u,g=l[4]/u,f=l[7]/u;let b=0;for(let P=0;P<t.length;++P)b+=(t[P].length/3-2)*51;const x=Jl(b);let y=0;for(let P=0;P<t.length;++P)y=ql(t[P],x,y,a,m,h,g,d,f,n,s,o,i);return{buffer:x.subarray(0,b),indexCount:y}},eu=t=>{const e=pr();if(!e.length)return;Bt.push(t);const r=Cn(e);yr(r.buffer),Ye.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),Ye.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<n;++o){const i=[];for(let l=0;l<s.length;++l){const c=s[l];if(!c)continue;const u=su(c[0],c[1],c[2],.5);i.push(u[0],u[1])}s=i}return s},iu=(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}),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<s.length;++i){const l=s[i],c=iu(l,t,e,r),u=au(l,t,e,r),a=cu({x:-u.y,y:u.x});o.push({x:c.x+a.x*n,y:c.y+a.y*n})}return o},lu=(t,e,r,n)=>{const s=ou(t,e,r,5),o=[],i=[];for(let h=0;h<s.length;++h){const[d,m,g]=s[h];o.push(Ri(d,m,g,+n)),i.push(Ri(d,m,g,-n))}const l=o[0][0],c=[l.x,l.y,!1];for(let h=0;h<o.length;++h){const d=o[h];c.push(d[1].x,d[1].y,!0,d[2].x,d[2].y,!1)}const u=[...i].reverse();for(let h=0;h<u.length;++h){const[d,m,g]=u[h];u[h]=[g,m,d]}const a=u[0][0];c.push(a.x,a.y,!1);for(let h=0;h<u.length;++h){const d=u[h];c.push(d[1].x,d[1].y,!0,d[2].x,d[2].y,!1)}return c},vr=(t,e,r,n)=>{const s=[];for(let i=0;i<n.length;i+=3){if(n[i+2])continue;const l=n[i],c=n[i+1],u=Math.sqrt(Math.pow(l-t,2)+Math.pow(c-e,2));Math.abs(u-r)>1e-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<e.length;r+=3)e[r+2]?(Mr.quadraticCurveTo(e[r],e[r+1],e[r+3],e[r+4]),r+=3):Mr.lineTo(e[r],e[r+1]);Mr.closePath();for(let r=0;r<t.length;r+=2){const n=t[r],s=t[r+1];if(!Mr.isPointInPath(n,s))return[n,s]}return null},Ci=(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]),h=Sr(u,n[i]);if(!h)return;const d=Sr(a,n[o]);if(!d)return;const m=Math.atan2(h[1]-e,h[0]-t);let f=Math.atan2(d[1]-e,d[0]-t)-m;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=m+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,m=16,g=(d-h)/m,f=[];for(let b=0;b<=m;b++){const x=d+g*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,m=s+e*h,g=o+e*d,f=-d,b=h,x=[m+e*h+e*f,g+e*d+e*b,!1,m+e*h-e*f,g+e*d-e*b,!1,m-e*h-e*f,g-e*d-e*b,!1,m+e*h+e*f,g+e*d+e*b,!1,m-e*h-e*f,g-e*d-e*b,!1,m-e*h+e*f,g-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 m=Sr(h,s[i]);if(!m)return;const g=e.x-t.x,f=e.y-t.y,b=Math.hypot(g,f),x={x:g/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,m[0],m[1],!1]);return}const A=((m[0]-d[0])*E-(m[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,m[0],m[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 m=3;m<t.length;m+=3){const g=t[m],f=t[m+1];if(t[m+2]){n.x=g,n.y=f;continue}if(s.x=g,s.y=f,t[m-1]?i.push(lu(r,n,s,e)):i.push(nu(r,s,e)),i.length>1)switch(O.joints){case 0:Ui(r.x,r.y,e,i);break;case 1:o.x=t[m-6],o.y=t[m-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)<h&&Math.abs(c-a)<h&&i.length>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<t.length;++s){const o=gu(t[s],e);for(let i=0;i<o.length;++i)r.push(o[i])}const n=Cn(r,"stroke");return r.length=0,ui(r),n},bu=(t,e,r,n,s,o)=>{const i=pr(!0);if(!i.length)return;Bt.push(t===0?"linear":"radial");const l=Is(i);yr(l.buffer),Ye.push(l.indexCount),qe.push(e,r,n,s),t===1&&qe.push(o)},$r=new Map,Li=()=>{$r.clear()},xu=t=>{$r.set(Ye.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<e.length&&(t.vertexLength=Fn(e.length),p.bufferData(p.ARRAY_BUFFER,t.vertexLength*4,p.STREAM_DRAW)),p.bufferSubData(p.ARRAY_BUFFER,0,e.subarray(0,r)),t},_i=t=>{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<n;++s){const o=p.getActiveUniform(t,s),i=o.name.endsWith("[0]")?o.name.slice(0,-3):o.name,l=p.getUniformLocation(t,i);if(o.type===p.SAMPLER_2D&&o.size===1&&!r)continue;const c={};switch(o.type){case p.FLOAT_VEC4:c.method=p.uniform4fv.bind(p,l),c.array=new Float32Array(4*o.size),c.assign=-1;break;case p.INT_VEC4:c.method=p.uniform4iv.bind(p,l),c.array=new Int32Array(4*o.size),c.assign=-1;break;case p.SAMPLER_2D:c.method=r?p.uniform1i.bind(p,l,3):p.uniform1iv.bind(p,l),c.array=new Int32Array(o.size),c.assign=1;break;case p.FLOAT:case p.FLOAT_VEC2:case p.FLOAT_VEC3:case p.FLOAT_MAT2:case p.FLOAT_MAT3:case p.FLOAT_MAT4:case p.INT:case p.INT_VEC2:case p.INT_VEC3:default:throw new Error("Use gl.FLOAT_VEC4 or gl.INT_VEC4 instead")}e.set(i,c)}};let Vi=-1;const Pu=t=>{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=()=>\`
|
|
2
|
-
vec2 applyMatrix(in vec2 vertex) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
mat3 parent_matrix = mat3(
|
|
8
|
-
|
|
9
|
-
u_highp[\${t+1}].xyz,
|
|
10
|
-
u_highp[\${t+2}].xyz
|
|
11
|
-
);
|
|
12
|
-
mat3 ancestor_matrix = mat3(
|
|
13
|
-
u_highp[\${t+3}].xyz,
|
|
14
|
-
u_highp[\${t+4}].xyz,
|
|
15
|
-
u_highp[\${t+5}].xyz
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
vec2 parent_offset = vec2(u_highp[\${t+2}].w, u_highp[\${t+3}].w);
|
|
19
|
-
vec2 parent_size = vec2(u_highp[\${t+4}].w, u_highp[\${t+5}].w);
|
|
20
|
-
vec4 grid_min = u_highp[\${t+6}];
|
|
21
|
-
vec4 grid_max = u_highp[\${t+7}];
|
|
22
|
-
|
|
23
|
-
vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy;
|
|
24
|
-
position = (position - parent_offset) / parent_size;
|
|
25
|
-
|
|
26
|
-
vec4 ga = grid_min;
|
|
27
|
-
vec4 gb = grid_max - grid_min;
|
|
28
|
-
vec4 gc = vec4(1.0) - grid_max;
|
|
29
|
-
|
|
30
|
-
vec2 pa = position;
|
|
31
|
-
vec2 pb = position - grid_min.st;
|
|
32
|
-
vec2 pc = position - grid_max.st;
|
|
33
|
-
|
|
34
|
-
position = (ga.pq / ga.st) * min(pa, ga.st)
|
|
35
|
-
+ (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st)
|
|
36
|
-
+ (gc.pq / gc.st) * max(vec2(0.0), pc);
|
|
37
|
-
|
|
38
|
-
position = position * parent_size + parent_offset;
|
|
39
|
-
position = (ancestor_matrix * vec3(position, 1.0)).xy;
|
|
40
|
-
|
|
41
|
-
position = position + vec2(u_highp[\${t+8}].x, u_highp[\${t+8}].y);
|
|
42
|
-
return position / vec2(u_highp[0].w, u_highp[1].w);
|
|
43
|
-
}\`,Ou=()=>"layout (location = 1) in vec2 a_bezier;",Eu=()=>\`layout (location = 3) in vec3 a_matrix0;
|
|
44
|
-
layout (location = 4) in vec3 a_matrix1;
|
|
45
|
-
layout (location = 5) in vec3 a_matrix2;\`,Ru=()=>"out vec2 v_uv;",Cu=()=>"out vec2 v_bezier;",Uu=()=>\`
|
|
46
|
-
mat3 uv_matrix = mat3(
|
|
47
|
-
u_highp[0].xyz,
|
|
48
|
-
u_highp[1].xyz,
|
|
49
|
-
u_highp[2].xyz
|
|
50
|
-
);
|
|
51
|
-
mat3 inverse_matrix = mat3(
|
|
52
|
-
u_highp[3].xyz,
|
|
53
|
-
u_highp[4].xyz,
|
|
54
|
-
vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w)
|
|
55
|
-
);
|
|
56
|
-
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
|
|
57
|
-
|
|
58
|
-
layout (location = 0) in vec2 a_vertex;
|
|
59
|
-
\${s}
|
|
60
|
-
\${c}
|
|
61
|
-
\${h}
|
|
62
|
-
|
|
63
|
-
\${d}
|
|
64
|
-
\${o}
|
|
65
|
-
\${u}
|
|
66
|
-
\${l}
|
|
67
|
-
|
|
68
|
-
void main() {
|
|
69
|
-
\${a}
|
|
70
|
-
\${i}
|
|
71
|
-
vec2 pos = applyMatrix(a_vertex);
|
|
72
|
-
pos = pos * 2.0 - 1.0;
|
|
73
|
-
gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);
|
|
74
|
-
}\`},_u=()=>\`#version 300 es
|
|
75
|
-
layout (location = 0) in vec2 a_vertex;
|
|
76
|
-
void main() {
|
|
77
|
-
vec2 pos = a_vertex * 2.0 - 1.0;
|
|
78
|
-
gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);
|
|
79
|
-
}\`,Vu=()=>\`#version 300 es
|
|
80
|
-
precision mediump float;
|
|
81
|
-
|
|
82
|
-
in vec4 v_color;
|
|
83
|
-
out vec4 o_color;
|
|
84
|
-
|
|
85
|
-
void main() {
|
|
86
|
-
o_color = vec4(v_color.rgb * v_color.a, v_color.a);
|
|
87
|
-
}\`,Du=()=>\`#version 300 es
|
|
88
|
-
precision mediump float;
|
|
89
|
-
|
|
90
|
-
uniform sampler2D u_texture;
|
|
91
|
-
uniform vec4 u_mediump[1];
|
|
92
|
-
|
|
93
|
-
in vec2 v_uv;
|
|
94
|
-
out vec4 o_color;
|
|
95
|
-
|
|
96
|
-
void main() {
|
|
97
|
-
vec2 uv = vec2(v_uv.x, u_mediump[0].y - v_uv.y) / u_mediump[0].xy;
|
|
98
|
-
|
|
99
|
-
vec4 src = texture(u_texture, uv);
|
|
100
|
-
o_color = src;
|
|
101
|
-
}\`,Nu=()=>\`#version 300 es
|
|
102
|
-
precision mediump float;
|
|
103
|
-
|
|
104
|
-
uniform sampler2D u_texture;
|
|
105
|
-
uniform vec4 u_mediump[1];
|
|
106
|
-
|
|
107
|
-
in vec2 v_uv;
|
|
108
|
-
out vec4 o_color;
|
|
109
|
-
|
|
110
|
-
void main() {
|
|
111
|
-
vec2 uv = fract(vec2(v_uv.x, -v_uv.y) / u_mediump[0].xy);
|
|
112
|
-
|
|
113
|
-
vec4 src = texture(u_texture, uv);
|
|
114
|
-
o_color = src;
|
|
115
|
-
}\`,zu=()=>\`#version 300 es
|
|
116
|
-
precision mediump float;
|
|
117
|
-
|
|
118
|
-
in vec2 v_bezier;
|
|
119
|
-
out vec4 o_color;
|
|
120
|
-
|
|
121
|
-
void main() {
|
|
122
|
-
float f_val = v_bezier.x * v_bezier.x - v_bezier.y;
|
|
123
|
-
|
|
124
|
-
float dx = dFdx(f_val);
|
|
125
|
-
float dy = dFdy(f_val);
|
|
126
|
-
|
|
127
|
-
float dist = f_val / length(vec2(dx, dy));
|
|
128
|
-
float alpha = smoothstep(0.5, -0.5, dist);
|
|
129
|
-
|
|
130
|
-
if (alpha > 0.001) {
|
|
131
|
-
o_color = vec4(min(alpha, 1.0));
|
|
132
|
-
} else {
|
|
133
|
-
discard;
|
|
134
|
-
}
|
|
135
|
-
}\`,Xu=()=>\`#version 300 es
|
|
136
|
-
precision mediump float;
|
|
137
|
-
out vec4 o_color;
|
|
138
|
-
void main() {
|
|
139
|
-
o_color = vec4(1.0);
|
|
140
|
-
}\`,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<<t.clipLevel-1;p.stencilMask(~e-1),p.stencilFunc(p.LEQUAL,e,255),p.stencilOp(p.ZERO,p.REPLACE,p.REPLACE),rt(Ns(),Ln(),0,6),p.stencilMask(1<<t.clipLevel),p.stencilFunc(p.ALWAYS,0,255),p.stencilOp(p.REPLACE,p.REPLACE,p.REPLACE),rt(Ns(),Ln(),0,6),p.stencilMask(255),p.stencilOp(p.ZERO,p.INVERT,p.INVERT)},Wu=()=>{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=Ye.length;for(let m=0;m<d;m++){p.stencilMask(1<<u-1);const g=Ye[m];$r.has(m)&&(h=$r.get(m));const b=sn(!!h);h&&on(b,h),rt(b,c,a,g),a+=g,++u,u>7&&(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=()=>\`
|
|
141
|
-
float isInside(in vec2 uv) {
|
|
142
|
-
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)));
|
|
143
|
-
}\`,zi=t=>\`
|
|
144
|
-
vec4 mul = u_mediump[\${t}];
|
|
145
|
-
vec4 add = u_mediump[\${t+1}];
|
|
146
|
-
|
|
147
|
-
if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0
|
|
148
|
-
|| add.x != 0.0 || add.y != 0.0 || add.z != 0.0
|
|
149
|
-
) {
|
|
150
|
-
src.rgb /= max(0.0001, src.a);
|
|
151
|
-
src = clamp(src * mul + add, 0.0, 1.0);
|
|
152
|
-
src.rgb *= src.a;
|
|
153
|
-
}
|
|
154
|
-
\`,Xi=t=>{const e=t?"uniform vec4 u_mediump[2];":"",r=t?zi(0):"";return\`#version 300 es
|
|
155
|
-
precision mediump float;
|
|
156
|
-
|
|
157
|
-
uniform sampler2D u_texture;
|
|
158
|
-
\${e}
|
|
159
|
-
|
|
160
|
-
in vec2 v_coord;
|
|
161
|
-
out vec4 o_color;
|
|
162
|
-
|
|
163
|
-
void main() {
|
|
164
|
-
vec4 src = texture(u_texture, v_coord);
|
|
165
|
-
\${r}
|
|
166
|
-
o_color = src;
|
|
167
|
-
}\`},qu=()=>\`#version 300 es
|
|
168
|
-
precision mediump float;
|
|
169
|
-
|
|
170
|
-
uniform sampler2D u_texture;
|
|
171
|
-
|
|
172
|
-
in vec4 v_mul;
|
|
173
|
-
in vec4 v_add;
|
|
174
|
-
in vec2 v_coord;
|
|
175
|
-
out vec4 o_color;
|
|
176
|
-
|
|
177
|
-
void main() {
|
|
178
|
-
vec4 src = texture(u_texture, v_coord);
|
|
179
|
-
|
|
180
|
-
if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0
|
|
181
|
-
|| v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0
|
|
182
|
-
) {
|
|
183
|
-
src.rgb /= max(0.0001, src.a);
|
|
184
|
-
src = clamp(src * v_mul + v_add, 0.0, 1.0);
|
|
185
|
-
src.rgb *= src.a;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
o_color = src;
|
|
189
|
-
}\`,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<this.offset+e.length&&this.resize(e.length);for(let r=0;r<e.length;r++)this.buffer[this.offset++]=e[r]}pushDisplayObjectBuffer(e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x,y,P,S,M,$){this.buffer.length<this.offset+22&&this.resize(22),this.buffer[this.offset++]=e,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=o,this.buffer[this.offset++]=i,this.buffer[this.offset++]=l,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=a,this.buffer[this.offset++]=h,this.buffer[this.offset++]=d,this.buffer[this.offset++]=m,this.buffer[this.offset++]=g,this.buffer[this.offset++]=f,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=y,this.buffer[this.offset++]=P,this.buffer[this.offset++]=S,this.buffer[this.offset++]=M,this.buffer[this.offset++]=$}pushInstanceBuffer(e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x,y,P,S,M,$,T,w){this.buffer.length<this.offset+24&&this.resize(24),this.buffer[this.offset++]=e,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=o,this.buffer[this.offset++]=i,this.buffer[this.offset++]=l,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=a,this.buffer[this.offset++]=h,this.buffer[this.offset++]=d,this.buffer[this.offset++]=m,this.buffer[this.offset++]=g,this.buffer[this.offset++]=f,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=y,this.buffer[this.offset++]=P,this.buffer[this.offset++]=S,this.buffer[this.offset++]=M,this.buffer[this.offset++]=$,this.buffer[this.offset++]=T,this.buffer[this.offset++]=w}pushShapeBuffer(e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x,y,P,S,M,$,T,w,E,F,A,R,v,U,L,D){this.buffer.length<this.offset+32&&this.resize(32),this.buffer[this.offset++]=e,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=o,this.buffer[this.offset++]=i,this.buffer[this.offset++]=l,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=a,this.buffer[this.offset++]=h,this.buffer[this.offset++]=d,this.buffer[this.offset++]=m,this.buffer[this.offset++]=g,this.buffer[this.offset++]=f,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=y,this.buffer[this.offset++]=P,this.buffer[this.offset++]=S,this.buffer[this.offset++]=M,this.buffer[this.offset++]=$,this.buffer[this.offset++]=T,this.buffer[this.offset++]=w,this.buffer[this.offset++]=E,this.buffer[this.offset++]=F,this.buffer[this.offset++]=A,this.buffer[this.offset++]=R,this.buffer[this.offset++]=v,this.buffer[this.offset++]=U,this.buffer[this.offset++]=L,this.buffer[this.offset++]=D}pushTextFieldBuffer(e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x,y,P,S,M,$,T,w,E,F,A,R,v,U){this.buffer.length<this.offset+30&&this.resize(30),this.buffer[this.offset++]=e,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=o,this.buffer[this.offset++]=i,this.buffer[this.offset++]=l,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=a,this.buffer[this.offset++]=h,this.buffer[this.offset++]=d,this.buffer[this.offset++]=m,this.buffer[this.offset++]=g,this.buffer[this.offset++]=f,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=y,this.buffer[this.offset++]=P,this.buffer[this.offset++]=S,this.buffer[this.offset++]=M,this.buffer[this.offset++]=$,this.buffer[this.offset++]=T,this.buffer[this.offset++]=w,this.buffer[this.offset++]=E,this.buffer[this.offset++]=F,this.buffer[this.offset++]=A,this.buffer[this.offset++]=R,this.buffer[this.offset++]=v,this.buffer[this.offset++]=U}pushVideoBuffer(e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x,y,P,S,M,$,T,w,E,F,A){this.buffer.length<this.offset+27&&this.resize(27),this.buffer[this.offset++]=e,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=o,this.buffer[this.offset++]=i,this.buffer[this.offset++]=l,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=a,this.buffer[this.offset++]=h,this.buffer[this.offset++]=d,this.buffer[this.offset++]=m,this.buffer[this.offset++]=g,this.buffer[this.offset++]=f,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=y,this.buffer[this.offset++]=P,this.buffer[this.offset++]=S,this.buffer[this.offset++]=M,this.buffer[this.offset++]=$,this.buffer[this.offset++]=T,this.buffer[this.offset++]=w,this.buffer[this.offset++]=E,this.buffer[this.offset++]=F,this.buffer[this.offset++]=A}set(e){this.buffer.length<this.offset+e.length&&this.resize(e.length),this.buffer.set(e,this.offset),this.offset+=e.length}resize(e){const r=new Float32Array(Qu(this.offset+e));this.buffer.length&&r.set(this.buffer),this.buffer=r}}const Ve=new Zu;let Ju=class extends _e{count;constructor(e,r,n=!0){super(e,r,n),this.count=0}clear(){this.count=Ve.offset=0}};const Zt=()=>\`#version 300 es
|
|
190
|
-
|
|
191
|
-
layout (location = 0) in vec2 a_vertex;
|
|
192
|
-
|
|
193
|
-
out vec2 v_coord;
|
|
194
|
-
|
|
195
|
-
void main() {
|
|
196
|
-
v_coord = a_vertex;
|
|
197
|
-
|
|
198
|
-
vec2 position = a_vertex * 2.0 - 1.0;
|
|
199
|
-
gl_Position = vec4(position, 0.0, 1.0);
|
|
200
|
-
}\`,ef=()=>\`#version 300 es
|
|
201
|
-
|
|
202
|
-
layout (location = 0) in vec2 a_vertex;
|
|
203
|
-
uniform vec4 u_highp[3];
|
|
204
|
-
|
|
205
|
-
out vec2 v_coord;
|
|
206
|
-
|
|
207
|
-
void main() {
|
|
208
|
-
v_coord = a_vertex;
|
|
209
|
-
|
|
210
|
-
mat3 matrix = mat3(
|
|
211
|
-
u_highp[0].x, u_highp[0].y, 0.0,
|
|
212
|
-
u_highp[0].z, u_highp[0].w, 0.0,
|
|
213
|
-
u_highp[1].x, u_highp[1].y, 1.0
|
|
214
|
-
);
|
|
215
|
-
|
|
216
|
-
vec2 size = u_highp[1].zw;
|
|
217
|
-
vec2 viewport = vec2(u_highp[2].x, u_highp[2].y);
|
|
218
|
-
|
|
219
|
-
vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);
|
|
220
|
-
position = position * size;
|
|
221
|
-
position = (matrix * vec3(position, 1.0)).xy;
|
|
222
|
-
position /= viewport;
|
|
223
|
-
|
|
224
|
-
position = position * 2.0 - 1.0;
|
|
225
|
-
gl_Position = vec4(position.x, -position.y, 0.0, 1.0);
|
|
226
|
-
}\`,tf=()=>\`#version 300 es
|
|
227
|
-
|
|
228
|
-
layout (location = 0) in vec2 a_vertex;
|
|
229
|
-
uniform vec4 u_highp[2];
|
|
230
|
-
|
|
231
|
-
out vec2 v_coord;
|
|
232
|
-
|
|
233
|
-
void main() {
|
|
234
|
-
v_coord = a_vertex;
|
|
235
|
-
|
|
236
|
-
vec2 offset = u_highp[0].xy;
|
|
237
|
-
vec2 size = u_highp[0].zw;
|
|
238
|
-
vec2 viewport = vec2(u_highp[1].x, u_highp[1].y);
|
|
239
|
-
|
|
240
|
-
vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);
|
|
241
|
-
position = position * size + offset;
|
|
242
|
-
position /= viewport;
|
|
243
|
-
|
|
244
|
-
position = position * 2.0 - 1.0;
|
|
245
|
-
gl_Position = vec4(position.x, -position.y, 0.0, 1.0);
|
|
246
|
-
}\`,rf=()=>\`#version 300 es
|
|
247
|
-
|
|
248
|
-
layout (location = 0) in vec2 a_vertex;
|
|
249
|
-
layout (location = 1) in vec4 a_rect;
|
|
250
|
-
layout (location = 2) in vec4 a_size;
|
|
251
|
-
layout (location = 3) in vec2 a_offset;
|
|
252
|
-
layout (location = 4) in vec4 a_matrix;
|
|
253
|
-
layout (location = 5) in vec4 a_mul;
|
|
254
|
-
layout (location = 6) in vec4 a_add;
|
|
255
|
-
|
|
256
|
-
out vec2 v_coord;
|
|
257
|
-
out vec4 v_mul;
|
|
258
|
-
out vec4 v_add;
|
|
259
|
-
|
|
260
|
-
void main() {
|
|
261
|
-
v_coord = a_vertex * a_rect.zw + a_rect.xy;
|
|
262
|
-
v_mul = a_mul;
|
|
263
|
-
v_add = a_add;
|
|
264
|
-
|
|
265
|
-
vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);
|
|
266
|
-
position = position * a_size.xy;
|
|
267
|
-
|
|
268
|
-
mat3 matrix = mat3(
|
|
269
|
-
a_matrix.x, a_matrix.y, 0.0,
|
|
270
|
-
a_matrix.z, a_matrix.w, 0.0,
|
|
271
|
-
a_offset.x, a_offset.y, 1.0
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
position = (matrix * vec3(position, 1.0)).xy;
|
|
275
|
-
position /= a_size.zw;
|
|
276
|
-
|
|
277
|
-
position = position * 2.0 - 1.0;
|
|
278
|
-
gl_Position = vec4(position.x, -position.y, 0.0, 1.0);
|
|
279
|
-
}\`,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=()=>\`
|
|
280
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
281
|
-
return src + dst - dst * src.a;
|
|
282
|
-
}\`,sf=()=>\`
|
|
283
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
284
|
-
if (src.a == 0.0) { return dst; }
|
|
285
|
-
if (dst.a == 0.0) { return src; }
|
|
286
|
-
|
|
287
|
-
vec4 a = src - src * dst.a;
|
|
288
|
-
vec4 b = dst - dst * src.a;
|
|
289
|
-
|
|
290
|
-
src.rgb /= src.a;
|
|
291
|
-
dst.rgb /= dst.a;
|
|
292
|
-
|
|
293
|
-
vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a);
|
|
294
|
-
c.rgb *= c.a;
|
|
295
|
-
|
|
296
|
-
return a + b + c;
|
|
297
|
-
}\`,of=()=>\`
|
|
298
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
299
|
-
vec4 a = src - src * dst.a;
|
|
300
|
-
vec4 b = dst - dst * src.a;
|
|
301
|
-
vec4 c = src * dst;
|
|
302
|
-
|
|
303
|
-
return a + b + c;
|
|
304
|
-
}\`,af=()=>\`
|
|
305
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
306
|
-
if (src.a == 0.0) { return dst; }
|
|
307
|
-
if (dst.a == 0.0) { return src; }
|
|
308
|
-
|
|
309
|
-
vec4 a = src - src * dst.a;
|
|
310
|
-
vec4 b = dst - dst * src.a;
|
|
311
|
-
|
|
312
|
-
src.rgb /= src.a;
|
|
313
|
-
dst.rgb /= dst.a;
|
|
314
|
-
|
|
315
|
-
vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a);
|
|
316
|
-
c.rgb *= c.a;
|
|
317
|
-
|
|
318
|
-
return a + b + c;
|
|
319
|
-
}\`,cf=()=>\`
|
|
320
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
321
|
-
if (src.a == 0.0) { return dst; }
|
|
322
|
-
if (dst.a == 0.0) { return src; }
|
|
323
|
-
|
|
324
|
-
vec4 a = src - src * dst.a;
|
|
325
|
-
vec4 b = dst - dst * src.a;
|
|
326
|
-
|
|
327
|
-
src.rgb /= src.a;
|
|
328
|
-
dst.rgb /= dst.a;
|
|
329
|
-
|
|
330
|
-
vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a);
|
|
331
|
-
c.rgb *= c.a;
|
|
332
|
-
|
|
333
|
-
return a + b + c;
|
|
334
|
-
}\`,lf=()=>\`
|
|
335
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
336
|
-
if (src.a == 0.0) { return dst; }
|
|
337
|
-
if (dst.a == 0.0) { return src; }
|
|
338
|
-
|
|
339
|
-
vec4 a = src - src * dst.a;
|
|
340
|
-
vec4 b = dst - dst * src.a;
|
|
341
|
-
|
|
342
|
-
src.rgb /= src.a;
|
|
343
|
-
dst.rgb /= dst.a;
|
|
344
|
-
|
|
345
|
-
vec4 mul = src * dst;
|
|
346
|
-
vec3 c1 = 2.0 * mul.rgb;
|
|
347
|
-
vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;
|
|
348
|
-
vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a);
|
|
349
|
-
c.rgb *= c.a;
|
|
350
|
-
|
|
351
|
-
return a + b + c;
|
|
352
|
-
}\`,uf=()=>\`
|
|
353
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
354
|
-
if (src.a == 0.0) { return dst; }
|
|
355
|
-
if (dst.a == 0.0) { return src; }
|
|
356
|
-
|
|
357
|
-
vec4 a = src - src * dst.a;
|
|
358
|
-
vec4 b = dst - dst * src.a;
|
|
359
|
-
|
|
360
|
-
src.rgb /= src.a;
|
|
361
|
-
dst.rgb /= dst.a;
|
|
362
|
-
|
|
363
|
-
vec4 mul = src * dst;
|
|
364
|
-
vec3 c1 = 2.0 * mul.rgb;
|
|
365
|
-
vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;
|
|
366
|
-
vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a);
|
|
367
|
-
c.rgb *= c.a;
|
|
368
|
-
|
|
369
|
-
return a + b + c;
|
|
370
|
-
}\`,ff=()=>\`
|
|
371
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
372
|
-
if (src.a == 0.0) { return dst; }
|
|
373
|
-
if (dst.a == 0.0) { return src; }
|
|
374
|
-
|
|
375
|
-
vec4 a = src - src * dst.a;
|
|
376
|
-
vec4 b = dst - dst * src.a;
|
|
377
|
-
|
|
378
|
-
src.rgb /= src.a;
|
|
379
|
-
dst.rgb /= dst.a;
|
|
380
|
-
|
|
381
|
-
vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a);
|
|
382
|
-
c.rgb *= c.a;
|
|
383
|
-
|
|
384
|
-
return a + b + c;
|
|
385
|
-
}\`,hf=()=>\`
|
|
386
|
-
vec4 blend (in vec4 src, in vec4 dst) {
|
|
387
|
-
if (src.a == 0.0) { return dst; }
|
|
388
|
-
if (dst.a == 0.0) { return src; }
|
|
389
|
-
|
|
390
|
-
vec4 b = dst - dst * src.a;
|
|
391
|
-
vec4 c = vec4(src.a - dst.rgb * src.a, src.a);
|
|
392
|
-
|
|
393
|
-
return b + c;
|
|
394
|
-
}\`,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
|
|
395
|
-
precision mediump float;
|
|
396
|
-
|
|
397
|
-
uniform sampler2D u_textures[2];
|
|
398
|
-
\${n}
|
|
399
|
-
|
|
400
|
-
in vec2 v_coord;
|
|
401
|
-
out vec4 o_color;
|
|
402
|
-
|
|
403
|
-
\${r}
|
|
404
|
-
|
|
405
|
-
void main() {
|
|
406
|
-
vec4 dst = texture(u_textures[0], v_coord);
|
|
407
|
-
vec4 src = texture(u_textures[1], v_coord);
|
|
408
|
-
\${s}
|
|
409
|
-
o_color = blend(src, dst);
|
|
410
|
-
}\`},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,m=0,g=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,g[6],g[7],g[0],g[1],g[3],g[4],i,l,c,u,a,h,d,m),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(g[0]!==1||g[1]!==0||g[3]!==0||g[4]!==1){const w=we(b,x,!1),E=dr(g[0],g[1],g[3],g[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)&&(g[6]-=y,g[7]-=P);const M=Vn(g[6],g[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,m),xe(T),f&&O.bind(f),Ki($.texture),(y||P)&&(g[6]+=y,g[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<<t.clipLevel),p.stencilFunc(p.ALWAYS,0,255),p.stencilOp(p.REPLACE,p.REPLACE,p.REPLACE),p.colorMask(!1,!1,!1,!1),rt(Ns(),Ln(),0,6),Us()},qs=(t,e,r,n=!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),Ye.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),Ye.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),Ye.push(e.indexCount)},Gf=t=>{const e=t.toFixed(1);return\`#version 300 es
|
|
411
|
-
precision mediump float;
|
|
412
|
-
|
|
413
|
-
uniform sampler2D u_texture;
|
|
414
|
-
uniform vec4 u_mediump;
|
|
415
|
-
|
|
416
|
-
in vec2 v_coord;
|
|
417
|
-
out vec4 o_color;
|
|
418
|
-
|
|
419
|
-
void main() {
|
|
420
|
-
vec2 offset = u_mediump.xy;
|
|
421
|
-
float fraction = u_mediump.z;
|
|
422
|
-
float samples = u_mediump.w;
|
|
423
|
-
|
|
424
|
-
vec4 color = texture(u_texture, v_coord);
|
|
425
|
-
|
|
426
|
-
for (float i = 1.0; i < \${e}; i += 1.0) {
|
|
427
|
-
color += texture(u_texture, v_coord + offset * i);
|
|
428
|
-
color += texture(u_texture, v_coord - offset * i);
|
|
429
|
-
}
|
|
430
|
-
color += texture(u_texture, v_coord + offset * \${e}) * fraction;
|
|
431
|
-
color += texture(u_texture, v_coord - offset * \${e}) * fraction;
|
|
432
|
-
color /= samples;
|
|
433
|
-
|
|
434
|
-
o_color = color;
|
|
435
|
-
}\`},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],m=Math.round(a*d),g=Math.round(h*d);re.x+=m,re.y+=g;const f=t.width+m*2,b=t.height+g*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,m*x,g*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;v<s;++v){if(r>0){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
|
|
436
|
-
precision mediump float;
|
|
437
|
-
|
|
438
|
-
uniform sampler2D u_texture;
|
|
439
|
-
uniform vec4 u_mediump[5];
|
|
440
|
-
|
|
441
|
-
in vec2 v_coord;
|
|
442
|
-
out vec4 o_color;
|
|
443
|
-
|
|
444
|
-
void main() {
|
|
445
|
-
mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]);
|
|
446
|
-
vec4 add = u_mediump[4];
|
|
447
|
-
|
|
448
|
-
vec4 color = texture(u_texture, v_coord);
|
|
449
|
-
|
|
450
|
-
color.rgb /= max(0.0001, color.a);
|
|
451
|
-
color = clamp(color * mul + add, 0.0, 1.0);
|
|
452
|
-
color.rgb *= color.a;
|
|
453
|
-
|
|
454
|
-
o_color = color;
|
|
455
|
-
}\`,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=>\`
|
|
456
|
-
vec2 base_scale = u_mediump[\${t}].xy;
|
|
457
|
-
vec2 base_offset = u_mediump[\${t}].zw;
|
|
458
|
-
|
|
459
|
-
vec2 uv = v_coord * base_scale - base_offset;
|
|
460
|
-
vec4 base = mix(vec4(0.0), texture(u_textures[1], uv), isInside(uv));
|
|
461
|
-
\`,jf=()=>\`
|
|
462
|
-
vec4 blur = texture(u_textures[0], v_coord);
|
|
463
|
-
\`,Hf=t=>\`
|
|
464
|
-
vec2 blur_scale = u_mediump[\${t}].xy;
|
|
465
|
-
vec2 blur_offset = u_mediump[\${t}].zw;
|
|
466
|
-
|
|
467
|
-
vec2 st = v_coord * blur_scale - blur_offset;
|
|
468
|
-
vec4 blur = mix(vec4(0.0), texture(u_textures[0], st), isInside(st));
|
|
469
|
-
\`,Kf=t=>{const e=Math.floor(t/4),r=t%4;return\`
|
|
470
|
-
float strength = u_mediump[\${e}][\${r}];
|
|
471
|
-
blur.a = clamp(blur.a * strength, 0.0, 1.0);
|
|
472
|
-
\`},qf=t=>\`
|
|
473
|
-
vec4 color = u_mediump[\${t}];
|
|
474
|
-
blur = color * blur.a;
|
|
475
|
-
\`,Qf=t=>\`
|
|
476
|
-
blur = texture(u_textures[\${t?2:1}], vec2(blur.a, 0.5));
|
|
477
|
-
\`,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\`
|
|
478
|
-
\${i}
|
|
479
|
-
\${l}
|
|
480
|
-
\${c}
|
|
481
|
-
\`},Zf=()=>\`
|
|
482
|
-
vec4 blur2 = texture(u_textures[0], 1.0 - v_coord);
|
|
483
|
-
\`,Jf=()=>\`
|
|
484
|
-
vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset;
|
|
485
|
-
vec4 blur2 = mix(vec4(0.0), texture(u_textures[0], pq), isInside(pq));
|
|
486
|
-
\`,eh=t=>{const e=Math.floor(t/4),r=t%4;return\`
|
|
487
|
-
float strength = u_mediump[\${e}][\${r}];
|
|
488
|
-
highlight_alpha *= strength;
|
|
489
|
-
shadow_alpha *= strength;
|
|
490
|
-
\`},th=t=>\`
|
|
491
|
-
vec4 highlight_color = u_mediump[\${t}];
|
|
492
|
-
vec4 shadow_color = u_mediump[\${t+1}];
|
|
493
|
-
blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha;
|
|
494
|
-
\`,rh=t=>\`
|
|
495
|
-
blur = texture(u_textures[\${t?2:1}], vec2(
|
|
496
|
-
0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha,
|
|
497
|
-
0.5
|
|
498
|
-
));
|
|
499
|
-
\`,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",m=u;let g=u*4,f;c?f=s?ea(!1,r,l,c,m,g):ta(r,n,l,c,m,g):s?(g+=4,f=ea(d,r,l,c,m,g)):(g+=8,f=ta(r,n,l,c,m,g));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
|
|
500
|
-
precision mediump float;
|
|
501
|
-
|
|
502
|
-
uniform sampler2D u_textures[\${t}];
|
|
503
|
-
uniform vec4 u_mediump[\${e}];
|
|
504
|
-
|
|
505
|
-
in vec2 v_coord;
|
|
506
|
-
out vec4 o_color;
|
|
507
|
-
|
|
508
|
-
\${Ws()}
|
|
509
|
-
|
|
510
|
-
void main() {
|
|
511
|
-
\${a}
|
|
512
|
-
\${h}
|
|
513
|
-
\${f}
|
|
514
|
-
o_color = \${b};
|
|
515
|
-
}\`},ta=(t,e,r,n,s,o)=>{const i=e?Jf():Zf(),l=r?eh(o):"",c=n?rh(t):th(s);return\`
|
|
516
|
-
\${i}
|
|
517
|
-
float highlight_alpha = blur.a - blur2.a;
|
|
518
|
-
float shadow_alpha = blur2.a - blur.a;
|
|
519
|
-
\${l}
|
|
520
|
-
highlight_alpha = clamp(highlight_alpha, 0.0, 1.0);
|
|
521
|
-
shadow_alpha = clamp(shadow_alpha, 0.0, 1.0);
|
|
522
|
-
\${c}
|
|
523
|
-
\`},sh=(t,e,r,n,s,o,i)=>{const m=\`f\${t?"y":"n"}\${e?"y":"n"}\${r?"y":"n"}\${n}\${s?"y":"n"}\${o?"y":"n"}\${i?"y":"n"}\`;if(De.has(m))return De.get(m);let g=1;t&&g++,i&&g++;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(g,f,t,e,r,n,s,o,i));return De.set(m,b),b},oh=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g,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++]=m,F[A++]=g,F[A++]=f,F[A++]=b):(F[A++]=m,F[A++]=g,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<e;++o){const i=o-1,l=o,c=\`u_mediump[\${e+Math.floor(i/4)}][\${i%4}]\`,u=\`u_mediump[\${e+Math.floor(l/4)}][\${l%4}]\`,a=\`u_mediump[\${i}]\`,h=\`u_mediump[\${l}]\`;n+=\`
|
|
524
|
-
if (t <= \${u}) {
|
|
525
|
-
return mix(\${a}, \${h}, (t - \${c}) / (\${u} - \${c}));
|
|
526
|
-
}
|
|
527
|
-
\`}const s=r?"color = pow(color, vec4(0.45454545));":"";return\`#version 300 es
|
|
528
|
-
precision mediump float;
|
|
529
|
-
|
|
530
|
-
uniform vec4 u_mediump[\${t}];
|
|
531
|
-
|
|
532
|
-
in vec2 v_coord;
|
|
533
|
-
out vec4 o_color;
|
|
534
|
-
|
|
535
|
-
vec4 getGradientColor(in float t) {
|
|
536
|
-
if (t <= u_mediump[\${e}][0]) {
|
|
537
|
-
return u_mediump[0];
|
|
538
|
-
}
|
|
539
|
-
\${n}
|
|
540
|
-
return u_mediump[\${e-1}];
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
void main() {
|
|
544
|
-
vec4 color = getGradientColor(v_coord.x);
|
|
545
|
-
\${s}
|
|
546
|
-
color.rgb *= color.a;
|
|
547
|
-
|
|
548
|
-
o_color = color;
|
|
549
|
-
}\`},ra=(t,e)=>{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<o;c++){const u=r[c];i[l++]=(u>>16)/255,i[l++]=(u>>8&255)/255,i[l++]=(u&255)/255,i[l++]=n[c]}for(let c=s;c<o;c++)i[l++]=e[c]/255},fh=(t,e)=>{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<o;l+=i-1){const c=Math.min(l+i,o),u=ra(c-l,!1);uh(u,t,e,r,l,c),na(u,t[l]/255,t[c-1]/255)}return Ce(),n&&O.bind(n),s.texture},an=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b=null,x=null,y=null,P=0,S=0,M=0,$=0,T=0,w=0,E=0,F=0)=>{const A=O.currentAttachmentObject,R=we(r,n,!1);O.bind(R);const v=m==="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||m==="full"&&g),G=!(r===c&&n===u&&a===0&&h===0),B=f!==1;v?g?Xf():Yf():Tr();const z=sh(D,G,d,m,g,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,m=re.x,g=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-m,T=P-g,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 m=O.currentAttachmentObject,g=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?g: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,g,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),m&&O.bind(m),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,m=!1)=>{const g=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(g,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?g:L,k=B?f:D,_=Math.abs($),I=Math.abs(T),V=(v-g)/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,g,f,Y,W,v,U,K,q,!1,G,m,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 m=t.width,g=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(m,g,!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?m:U,z=G?g:L,k=Math.abs(M),_=Math.abs($),I=(R-m)/2,V=(v-g)/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,m,g,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 m=t.width,g=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?m:y+Math.max(0,Math.abs(R)-$),D=U?g: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,m,g,_,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<l;++d){const m=u+Math.floor(d/4),g=d%4;c+=\`
|
|
550
|
-
result += getWeightedColor(\${d}, u_mediump[\${m}][\${g}]);
|
|
551
|
-
\`}const a=n?"result.a = texture(u_texture, v_coord).a;":"",h=s?"":\`
|
|
552
|
-
vec4 substitute_color = u_mediump[1];
|
|
553
|
-
color = mix(substitute_color, color, isInside(uv));
|
|
554
|
-
\`;return\`#version 300 es
|
|
555
|
-
precision mediump float;
|
|
556
|
-
|
|
557
|
-
uniform sampler2D u_texture;
|
|
558
|
-
uniform vec4 u_mediump[\${t}];
|
|
559
|
-
|
|
560
|
-
in vec2 v_coord;
|
|
561
|
-
out vec4 o_color;
|
|
562
|
-
|
|
563
|
-
\${Ws()}
|
|
564
|
-
|
|
565
|
-
vec4 getWeightedColor (in int i, in float weight) {
|
|
566
|
-
vec2 rcp_size = u_mediump[0].xy;
|
|
567
|
-
|
|
568
|
-
int i_div_x = i / \${e};
|
|
569
|
-
int i_mod_x = i - \${e} * i_div_x;
|
|
570
|
-
vec2 offset = vec2(i_mod_x - \${o}, \${i} - i_div_x);
|
|
571
|
-
vec2 uv = v_coord + offset * rcp_size;
|
|
572
|
-
|
|
573
|
-
vec4 color = texture(u_texture, uv);
|
|
574
|
-
color.rgb /= max(0.0001, color.a);
|
|
575
|
-
\${h}
|
|
576
|
-
|
|
577
|
-
return color * weight;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
void main() {
|
|
581
|
-
float rcp_divisor = u_mediump[0].z;
|
|
582
|
-
float bias = u_mediump[0].w;
|
|
583
|
-
|
|
584
|
-
vec4 result = vec4(0.0);
|
|
585
|
-
\${c}
|
|
586
|
-
result = clamp(result * rcp_divisor + bias, 0.0, 1.0);
|
|
587
|
-
\${a}
|
|
588
|
-
|
|
589
|
-
result.rgb *= result.a;
|
|
590
|
-
o_color = result;
|
|
591
|
-
}\`},Sh=(t,e,r,n)=>{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 m=n.length;for(let g=0;g<m;g++)h[d++]=n[g]},pa=(t,e=0,r=0,n,s=1,o=0,i=!0,l=!0,c=0,u=0)=>{const a=O.currentAttachmentObject,h=t.width,d=t.height,m=we(h,d,!1);O.bind(m),O.reset(),O.setTransform(1,0,0,1,0,0),$e(t,!0),Ce();const g=Sh(e,r,i,l);$h(g,h,d,n,s,o,l,Br(c,u,!1),Pr(c,u,!1),Ar(c,u,!1),u),xe(g);const f=m.texture;return ae(t),be(m,!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=\`
|
|
592
|
-
vec4 source_color = texture(u_textures[0], uv);
|
|
593
|
-
\`;break;case 3:i=\`
|
|
594
|
-
vec4 source_color =texture(u_textures[0], mix(v_coord, uv, step(abs(uv - vec2(0.5)), vec2(0.5))));
|
|
595
|
-
\`;break;case 1:i=\`
|
|
596
|
-
vec4 substitute_color = u_mediump[2];
|
|
597
|
-
vec4 source_color = mix(substitute_color, texture(u_textures[0], uv), isInside(uv));
|
|
598
|
-
\`;break;default:i=\`
|
|
599
|
-
vec4 source_color = texture(u_textures[0], fract(uv));
|
|
600
|
-
\`;break}return\`#version 300 es
|
|
601
|
-
precision mediump float;
|
|
602
|
-
|
|
603
|
-
uniform sampler2D u_textures[2];
|
|
604
|
-
uniform vec4 u_mediump[\${t}];
|
|
605
|
-
|
|
606
|
-
in vec2 v_coord;
|
|
607
|
-
out vec4 o_color;
|
|
608
|
-
|
|
609
|
-
\${Ws()}
|
|
610
|
-
|
|
611
|
-
void main() {
|
|
612
|
-
vec2 uv_to_st_scale = u_mediump[0].xy;
|
|
613
|
-
vec2 uv_to_st_offset = u_mediump[0].zw;
|
|
614
|
-
vec2 scale = u_mediump[1].xy;
|
|
615
|
-
|
|
616
|
-
vec2 st = v_coord * uv_to_st_scale - uv_to_st_offset;
|
|
617
|
-
vec4 map_color = texture(u_textures[1], st);
|
|
618
|
-
|
|
619
|
-
vec2 offset = vec2(\${s}, \${o}) - 0.5;
|
|
620
|
-
vec2 uv = v_coord + offset * scale;
|
|
621
|
-
\${i}
|
|
622
|
-
|
|
623
|
-
o_color = mix(texture(u_textures[0], v_coord), source_color, isInside(st));
|
|
624
|
-
}\`},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,m)=>{const g=t.textures;g[0]=0,g[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]=m)},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 m=O.currentAttachmentObject,g=t.width,f=t.height,b=we(g,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 m&&O.bind(m),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 m=Math.sqrt(i[0]*i[0]+i[1]*i[1]),g=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?m*Math.cos(S):Math.cos(S),T=o?m*Math.sin(S):Math.sin(S),w=o?-g*Math.sin(M):-Math.sin(M),E=o?g*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]*(m/S),$=u[1]*(g/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++],m=o[a++],g=d*m,f=o.subarray(a,a+g);a+=g,u=pa(u,d,m,f,o[a++],o[a++],!!o[a++],!!o[a++],o[a++],o[a++])}break;case 4:{const d=o[a++],m=new Uint8Array(d);m.set(o.subarray(a,a+d)),a+=d,u=ma(u,m,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++],m=o[a++];let g=o[a++];const f=o.subarray(a,a+g);a+=g,g=o[a++];const b=o.subarray(a,a+g);a+=g,g=o[a++];const x=o.subarray(a,a+g);a+=g,u=ha(u,e,d,m,f,b,x,o[a++],o[a++],o[a++],o[a++],o[a++],!!o[a++])}break;case 8:{const d=o[a++],m=o[a++];let g=o[a++];const f=o.subarray(a,a+g);a+=g,g=o[a++];const b=o.subarray(a,a+g);a+=g,g=o[a++];const x=o.subarray(a,a+g);a+=g,u=da(u,e,d,m,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,m=s[0]*(a/d),g=s[1]*(h/d);O.reset(),O.globalCompositeOperation=t,Xn(u,r,m+e[4],g+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<n;++l){const c=l*5;o[i++]=s[e[c+1]],o[i++]=s[e[c+2]],o[i++]=s[e[c+3]],o[i++]=s[e[c+4]]}for(let l=r;l<n;++l)o[i++]=e[l*5]},$a=(t,e)=>{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<o;a+=u-1){const h=Math.min(a+u,o),d=ra(h-a,s);Kh(d,t,a,h,c),na(d,t[0],t[t.length-5])}return Ce(),r&&O.bind(r),It(),p.scissor(n[0],n[1],n[2],n[3]),l.texture},so=new Map,qh=(t,e,r,n)=>{const s=t?"y":"n",o=e?"y":"n",i=e&&r?"y":"n",l=\`\${n}\`;return\`\${s}\${o}\${i}\${l}\`},Qh=t=>\`
|
|
625
|
-
vec2 focal = vec2(u_highp[\${t}][1], 0.0);
|
|
626
|
-
|
|
627
|
-
vec2 diff = coord - focal;
|
|
628
|
-
float lenDiff = length(diff);
|
|
629
|
-
vec2 dir = diff / lenDiff;
|
|
630
|
-
float b = 2.0 * dot(dir, focal);
|
|
631
|
-
float c = dot(focal, focal) - 1.0;
|
|
632
|
-
float x = (-b + sqrt(max(b * b - 4.0 * c, 0.0))) * 0.5;
|
|
633
|
-
|
|
634
|
-
float t = lenDiff / abs(x);\`,Zh=()=>"float t = length(coord);",Jh=(t,e)=>{const r=e?Qh(t):Zh();return\`
|
|
635
|
-
float radius = u_highp[\${t}][0];
|
|
636
|
-
vec2 coord = p / radius;
|
|
637
|
-
\${r}
|
|
638
|
-
\`},ed=t=>\`
|
|
639
|
-
vec2 a = u_highp[\${t}].xy;
|
|
640
|
-
vec2 b = u_highp[\${t}].zw;
|
|
641
|
-
|
|
642
|
-
vec2 ab = b - a;
|
|
643
|
-
vec2 ap = p - a;
|
|
644
|
-
|
|
645
|
-
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
|
|
646
|
-
precision highp float;
|
|
647
|
-
|
|
648
|
-
uniform sampler2D u_texture;
|
|
649
|
-
uniform vec4 u_highp[\${t}];
|
|
650
|
-
|
|
651
|
-
in vec2 v_uv;
|
|
652
|
-
out vec4 o_color;
|
|
653
|
-
|
|
654
|
-
void main() {
|
|
655
|
-
vec2 p = v_uv;
|
|
656
|
-
\${o}
|
|
657
|
-
t = \${i};
|
|
658
|
-
o_color = texture(u_texture, vec2(t, 0.5));
|
|
659
|
-
}\`},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),m=ys(O.$matrix);Ba(h,0,O.$matrix,m,0,d,n),di(d),Kr(m),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],m=ys(O.$matrix),g=Ta(!0,!!c,i,a);Ba(g,1,d,m,c,n),O.restore(),Kr(m),rt(g,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 m=sd(a,s);od(m,c,u,n),rt(m,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<Bt.length;n++)switch($r.has(n)&&(r=$r.get(n)),Bt[n]){case"fill":{const o=Ye.shift();Hh(t,e,o,r),e+=o}break;case"linear":{const o=Ye.shift();rd(t,e,o,r),e+=o}break;case"radial":{const o=Ye.shift();nd(t,e,o,r),e+=o}break;case"bitmap":{const o=Ye.shift();id(t,e,o,r),e+=o}break}Wr(),Qn(),_i(t),Ei(),Li()};let io=0;const Pa=new Float32Array(256);for(let t=1;t<256;t++)Pa[t]=255/t;const cd=async(t,e)=>{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;i<n.length;i+=4){const l=n[i+3];if(l===0||l===255)continue;const c=Pa[l];n[i]=Math.min(255,Math.round(n[i]*c)),n[i+1]=Math.min(255,Math.round(n[i+1]*c)),n[i+2]=Math.min(255,Math.round(n[i+2]*c))}return await createImageBitmap(new ImageData(new Uint8ClampedArray(n),t,e),{imageOrientation:"flipY",premultiplyAlpha:"none",colorSpaceConversion:"none"})};let ld=class{$stack;$matrix;$clearColorR;$clearColorG;$clearColorB;$clearColorA;$mainAttachmentObject;$stackAttachmentObject;globalAlpha;globalCompositeOperation;imageSmoothingEnabled;$fillStyle;$strokeStyle;maskBounds;thickness;caps;joints;miterLimit;newDrawState=!1;constructor(e,r,n=1){Wc(e),Xc(e.getParameter(e.MAX_TEXTURE_SIZE)),Yc(r),Qc(n),this.$stack=Hr(),this.$stackAttachmentObject=Hr(),this.$matrix=xs(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},e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.clearColor(0,0,0,0),e.frontFace(e.CCW),ml(e),gl(e),bl(e,Pi()),xl(e),$f(e),Bf(),mh(e),jc(this)}clearTransferBounds(){Gl()}updateBackgroundColor(e,r,n,s){fl(this,e,r,n,s)}fillBackgroundColor(){hl(this.$clearColorR,this.$clearColorG,this.$clearColorB,this.$clearColorA)}resize(e,r,n=!0){kl(this,e,r,n)}clearRect(e,r,n,s){Il(e,r,n,s)}bind(e){Dl(this,e)}save(){Nl(this)}restore(){zl(this)}setTransform(e,r,n,s,o,i){Xl(this.$matrix,e,r,n,s,o,i)}transform(e,r,n,s,o,i){Yl(this,e,r,n,s,o,i)}reset(){Wl(this)}beginPath(){jl(this),el()}moveTo(e,r){wn(e,r)}lineTo(e,r){rl(e,r)}quadraticCurveTo(e,r,n,s){gi(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(){nl()}arc(e,r,n){ul(e,r,n)}bezierCurveTo(e,r,n,s,o,i){Qr(e,r,n,s,o,i)}fill(){eu("fill")}gradientFill(e,r,n,s,o,i){tu(e,r,n,s,o,i)}bitmapFill(e,r,n,s,o,i){Rf(e,r,n,s,o,i)}stroke(){Uf()}gradientStroke(e,r,n,s,o,i){bu(e,r,n,s,o,i)}bitmapStroke(e,r,n,s,o,i){Cf(e,r,n,s,o,i)}clip(){Wu()}get currentAttachmentObject(){return Bs}get atlasAttachmentObject(){return Ul()}createNode(e,r){return Ys(e,r)}removeNode(e){Ku(e)}beginNodeRendering(e){this.newDrawState=!0,ya(e),Hl(e.x,e.y,e.w,e.h)}endNodeRendering(){Kl()}drawFill(){ad()}drawDisplayObject(e,r,n,s,o,i){ya(e),pf(e,r,n,s,o,i)}drawArraysInstanced(){Mf()}clearArraysInstanced(){mf()}transferMainCanvas(){Tf()}drawPixels(e,r){wf(e,r)}drawElement(e,r,n=!1){Ef(e,r)}beginMask(){Pf()}setMaskBounds(e,r,n,s){Af(e,r,n,s)}endMask(){Us()}leaveMask(){this.drawArraysInstanced(),Ff()}useGrid(e){xu(e)}applyFilter(e,r,n,s,o,i,l,c,u,a,h){this.drawArraysInstanced(),Dh(e,r,n,s,o,i,l,c,u,a,h)}containerBeginLayer(e,r){this.drawArraysInstanced(),Nh(e,r)}containerEndLayer(e,r,n,s,o,i,l,c){zh(e,r,n,s,o,i,l,c)}containerDrawCachedFilter(e,r,n,s,o,i){Xh(e,r,n,s,o,i)}async createImageBitmap(e,r){return await cd(e,r)}},ao=4;class le{static device=null;static devicePixelRatio=1;static renderMaxSize=8192;static float32Array4Pool=[];static setDevice(e){le.device=e}static getDevice(){if(!le.device)throw new Error("GPUDevice is not initialized");return le.device}static setDevicePixelRatio(e){le.devicePixelRatio=e}static getDevicePixelRatio(){return le.devicePixelRatio}static setRenderMaxSize(e){le.renderMaxSize=e}static getRenderMaxSize(){return le.renderMaxSize}static createFloat32Array(e){return new Float32Array(e)}static createArray(){return[]}static getFloat32Array4(){return le.float32Array4Pool.length>0?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 g={x:(c.x+u.x)*.5,y:(c.y+u.y)*.5};o.push({ctrl:g,end:a});return}const m=pd(l,c,u,a);i(m.first[0],m.first[1],m.first[2],m.first[3],h+1),i(m.second[0],m.second[1],m.second[2],m.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;o<n.length;o+=3)s.push({x:n[o],y:n[o+1]});for(let o=1;o<s.length-1;o++)r.push(s[0].x,s[0].y,s[o].x,s[o].y,s[o+1].x,s[o+1].y)}return new Float32Array(r)}getCurrentPath(){const e=[];for(let r=0;r<this.$currentPath.length;r+=3)e.push({x:this.$currentPath[r],y:this.$currentPath[r+1]});return e}getAllPaths(){const e=[];for(const r of this.$vertices){const n=[];for(let s=0;s<r.length;s+=3)n.push({x:r[s],y:r[s+1]});n.length>0&&e.push(n)}if(this.$currentPath.length>=3){const r=[];for(let n=0;n<this.$currentPath.length;n+=3)r.push({x:this.$currentPath[n],y:this.$currentPath[n+1]});r.length>0&&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<i&&(o=u,i=a)}if(o)return o.inUse=!0,o.lastUsedFrame=n,o.buffer;const l=Math.max(s,16384),c=Bd(t,{size:l,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,label:\`storage_buffer_\${e.length}\`});return e.push({buffer:c,size:l,inUse:!0,lastUsedFrame:n}),c},Ad=(t,e)=>{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,m=t.createTexture({size:{width:s,height:o},format:a,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),g=m.createView(),f={id:c.textureId++,resource:m,view:g,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 m=0;m<a.length;m++){const g=a[m];if(!g.inUse)return g.inUse=!0,g.lastUsedFrame=i,g.texture}if(c[0]>=l){let m=1/0,g="",f=-1;for(const[b,x]of e)for(let y=0;y<x.length;y++){const P=x[y];!P.inUse&&P.lastUsedFrame<m&&(m=P.lastUsedFrame,g=b,f=y)}if(f>=0){const b=e.get(g);b[f].texture.destroy(),b.splice(f,1),b.length===0&&e.delete(g),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<n.length;s++)if(n[s].texture===e){n[s].inUse=!1,n[s].lastUsedFrame=r;return}},Xd=(t,e,r,n)=>{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<s&&(c.texture.destroy(),i.splice(l,1),n[0]--)}i.length===0&&t.delete(o)}},Yd=32,Wd=180;class jd{device;buckets;currentFrame;totalCount;constructor(e){this.device=e,this.buckets=new Map,this.currentFrame=0,this.totalCount=[0]}beginFrame(){this.currentFrame++,this.currentFrame%60===0&&Xd(this.buckets,this.currentFrame,Wd,this.totalCount)}acquire(e,r,n="rgba8unorm",s=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT){return Nd(this.device,this.buckets,e,r,n,s,this.currentFrame,Yd,this.totalCount)}release(e){zd(this.buckets,e,this.currentFrame)}getStats(){let e=0,r=0;for(const n of this.buckets.values())for(const s of n)s.inUse?e++:r++;return{total:this.totalCount[0],inUse:e,available:r}}dispose(){for(const e of this.buckets.values())for(const r of e)r.texture.destroy();this.buckets.clear(),this.totalCount[0]=0}}class Hd{device;format;attachments;currentAttachment;idCounter;texturePool;pendingReleases=[];constructor(e,r){this.device=e,this.format=r,this.attachments=new Map,this.currentAttachment=null,this.idCounter={nextId:1,textureId:1,stencilId:1},this.texturePool=new jd(e)}beginFrame(){this.texturePool.beginFrame()}createAttachment(e,r,n,s=!1,o=!1){return Gd(this.device,this.format,this.attachments,e,r,n,s,o,this.idCounter)}getAttachment(e){return this.attachments.get(e)}setCurrentAttachment(e){this.currentAttachment=e}getCurrentAttachment(){return this.currentAttachment}createRenderPassDescriptor(e,r=0,n=0,s=0,o=0,i="clear",l=null){return Id(e,r,n,s,o,i,l)}createStencilRenderPassDescriptor(e,r,n="load",s="clear",o=null){return Vd(e,r,n,s,o)}destroyAttachment(e){const r=this.attachments.get(e);r&&(r.texture&&r.texture.resource.destroy(),r.stencil&&r.stencil.resource.destroy(),this.attachments.delete(e))}resizeAttachment(e,r,n){return this.destroyAttachment(e),this.createAttachment(e,r,n)}createTemporaryAttachment(e,r){const n=\`temp_\${this.idCounter.nextId}\`,s=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING,o=this.texturePool.acquire(e,r,"rgba8unorm",s),i=o.createView(),l={id:this.idCounter.textureId++,resource:o,view:i,width:e,height:r,area:e*r,smooth:!0},c={id:this.idCounter.nextId++,width:e,height:r,clipLevel:0,msaa:!1,mask:!1,color:null,texture:l,stencil:null,msaaTexture:null,msaaStencil:null};return this.attachments.set(n,c),c}releaseTemporaryAttachment(e){Ld(this.attachments,this.pendingReleases,e)}flushPendingReleases(){for(const e of this.pendingReleases)e.texture&&this.texturePool.release(e.texture.resource),e.msaaTexture&&e.msaaTexture.resource.destroy(),e.stencil&&e.stencil.resource.destroy(),e.msaaStencil&&e.msaaStencil.resource.destroy();this.pendingReleases=[]}dispose(){for(const e of this.attachments.values())e.texture&&e.texture.resource.destroy(),e.stencil&&e.stencil.resource.destroy();this.attachments.clear(),this.currentAttachment=null,this.texturePool.dispose()}}const Kd=t=>({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<e.length;o++){const i=e[o];if(i.width>=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<e.length;o++){const i=e[o];if(i.width>=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=\`
|
|
660
|
-
override yFlipSign: f32 = 1.0;
|
|
661
|
-
|
|
662
|
-
struct VertexInput {
|
|
663
|
-
@location(0) position: vec2<f32>,
|
|
664
|
-
@location(1) bezier: vec2<f32>,
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
struct VertexOutput {
|
|
668
|
-
@builtin(position) position: vec4<f32>,
|
|
669
|
-
@location(0) bezier: vec2<f32>,
|
|
670
|
-
@location(1) color: vec4<f32>,
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
struct FillUniforms {
|
|
674
|
-
color: vec4<f32>,
|
|
675
|
-
matrix0: vec4<f32>,
|
|
676
|
-
matrix1: vec4<f32>,
|
|
677
|
-
matrix2: vec4<f32>,
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
@group(0) @binding(0) var<uniform> uniforms: FillUniforms;
|
|
681
|
-
|
|
682
|
-
@vertex
|
|
683
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
684
|
-
var output: VertexOutput;
|
|
685
|
-
let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);
|
|
686
|
-
let transformed = matrix * vec3<f32>(input.position, 1.0);
|
|
687
|
-
let ndc = transformed.xy * 2.0 - 1.0;
|
|
688
|
-
output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);
|
|
689
|
-
output.bezier = input.bezier;
|
|
690
|
-
output.color = uniforms.color;
|
|
691
|
-
return output;
|
|
692
|
-
}
|
|
693
|
-
\`,Ua=\`
|
|
694
|
-
override yFlipSign: f32 = 1.0;
|
|
695
|
-
|
|
696
|
-
struct VertexInput {
|
|
697
|
-
@location(0) position: vec2<f32>,
|
|
698
|
-
@location(1) bezier: vec2<f32>,
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
struct VertexOutput {
|
|
702
|
-
@builtin(position) position: vec4<f32>,
|
|
703
|
-
@location(0) bezier: vec2<f32>,
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
struct FillUniforms {
|
|
707
|
-
color: vec4<f32>,
|
|
708
|
-
matrix0: vec4<f32>,
|
|
709
|
-
matrix1: vec4<f32>,
|
|
710
|
-
matrix2: vec4<f32>,
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
@group(0) @binding(0) var<uniform> uniforms: FillUniforms;
|
|
714
|
-
|
|
715
|
-
@vertex
|
|
716
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
717
|
-
var output: VertexOutput;
|
|
718
|
-
let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);
|
|
719
|
-
let transformed = matrix * vec3<f32>(input.position, 1.0);
|
|
720
|
-
let ndc = transformed.xy * 2.0 - 1.0;
|
|
721
|
-
output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);
|
|
722
|
-
output.bezier = input.bezier;
|
|
723
|
-
return output;
|
|
724
|
-
}
|
|
725
|
-
\`,Ga=\`
|
|
726
|
-
override yFlipSign: f32 = 1.0;
|
|
727
|
-
|
|
728
|
-
struct VertexInput {
|
|
729
|
-
@location(0) position: vec2<f32>,
|
|
730
|
-
@location(1) bezier: vec2<f32>,
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
struct VertexOutput {
|
|
734
|
-
@builtin(position) position: vec4<f32>,
|
|
735
|
-
@location(0) color: vec4<f32>,
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
struct FillUniforms {
|
|
739
|
-
color: vec4<f32>,
|
|
740
|
-
matrix0: vec4<f32>,
|
|
741
|
-
matrix1: vec4<f32>,
|
|
742
|
-
matrix2: vec4<f32>,
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
@group(0) @binding(0) var<uniform> uniforms: FillUniforms;
|
|
746
|
-
|
|
747
|
-
@vertex
|
|
748
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
749
|
-
var output: VertexOutput;
|
|
750
|
-
let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);
|
|
751
|
-
let transformed = matrix * vec3<f32>(input.position, 1.0);
|
|
752
|
-
let ndc = transformed.xy * 2.0 - 1.0;
|
|
753
|
-
output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);
|
|
754
|
-
output.color = uniforms.color;
|
|
755
|
-
return output;
|
|
756
|
-
}
|
|
757
|
-
\`,ap=\`
|
|
758
|
-
struct VertexInput {
|
|
759
|
-
@location(0) position: vec2<f32>,
|
|
760
|
-
@location(1) bezier: vec2<f32>,
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
struct VertexOutput {
|
|
764
|
-
@builtin(position) position: vec4<f32>,
|
|
765
|
-
@location(0) bezier: vec2<f32>,
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
struct Uniforms {
|
|
769
|
-
viewportSize: vec2<f32>,
|
|
770
|
-
_padding0: vec2<f32>,
|
|
771
|
-
matrixCol0: vec3<f32>,
|
|
772
|
-
_padding1: f32,
|
|
773
|
-
matrixCol1: vec3<f32>,
|
|
774
|
-
_padding2: f32,
|
|
775
|
-
matrixCol2: vec3<f32>,
|
|
776
|
-
_padding3: f32,
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
|
|
780
|
-
|
|
781
|
-
@vertex
|
|
782
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
783
|
-
var output: VertexOutput;
|
|
784
|
-
let matrix = mat3x3<f32>(uniforms.matrixCol0, uniforms.matrixCol1, uniforms.matrixCol2);
|
|
785
|
-
let transformed = matrix * vec3<f32>(input.position, 1.0);
|
|
786
|
-
let pos = transformed.xy;
|
|
787
|
-
let ndc = pos * 2.0 - 1.0;
|
|
788
|
-
output.position = vec4<f32>(ndc.x, -ndc.y, 0.0, 1.0);
|
|
789
|
-
output.bezier = input.bezier;
|
|
790
|
-
return output;
|
|
791
|
-
}
|
|
792
|
-
\`,La=\`
|
|
793
|
-
override yFlipSign: f32 = 1.0;
|
|
794
|
-
|
|
795
|
-
struct VertexInput {
|
|
796
|
-
@location(0) position: vec2<f32>,
|
|
797
|
-
@location(1) texCoord: vec2<f32>,
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
struct VertexOutput {
|
|
801
|
-
@builtin(position) position: vec4<f32>,
|
|
802
|
-
@location(0) texCoord: vec2<f32>,
|
|
803
|
-
@location(1) color: vec4<f32>,
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
struct Uniforms {
|
|
807
|
-
matrix: mat3x3<f32>,
|
|
808
|
-
color: vec4<f32>,
|
|
809
|
-
alpha: f32,
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
|
|
813
|
-
|
|
814
|
-
@vertex
|
|
815
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
816
|
-
var output: VertexOutput;
|
|
817
|
-
let pos = uniforms.matrix * vec3<f32>(input.position, 1.0);
|
|
818
|
-
let ndc = pos.xy * 2.0 - 1.0;
|
|
819
|
-
output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);
|
|
820
|
-
output.texCoord = input.texCoord;
|
|
821
|
-
let premultipliedColor = vec4<f32>(
|
|
822
|
-
uniforms.color.rgb * uniforms.color.a * uniforms.alpha,
|
|
823
|
-
uniforms.color.a * uniforms.alpha
|
|
824
|
-
);
|
|
825
|
-
output.color = premultipliedColor;
|
|
826
|
-
return output;
|
|
827
|
-
}
|
|
828
|
-
\`,cp=\`
|
|
829
|
-
struct VertexInput {
|
|
830
|
-
@location(0) position: vec2<f32>,
|
|
831
|
-
@location(1) texCoord: vec2<f32>,
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
struct InstanceInput {
|
|
835
|
-
@location(2) textureRect: vec4<f32>,
|
|
836
|
-
@location(3) textureDim: vec4<f32>,
|
|
837
|
-
@location(4) matrixTx: vec4<f32>,
|
|
838
|
-
@location(5) matrixScale: vec4<f32>,
|
|
839
|
-
@location(6) mulColor: vec4<f32>,
|
|
840
|
-
@location(7) addColor: vec4<f32>,
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
struct VertexOutput {
|
|
844
|
-
@builtin(position) position: vec4<f32>,
|
|
845
|
-
@location(0) texCoord: vec2<f32>,
|
|
846
|
-
@location(1) mulColor: vec4<f32>,
|
|
847
|
-
@location(2) addColor: vec4<f32>,
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
@vertex
|
|
851
|
-
fn main(
|
|
852
|
-
input: VertexInput,
|
|
853
|
-
instance: InstanceInput,
|
|
854
|
-
@builtin(instance_index) instanceIdx: u32
|
|
855
|
-
) -> VertexOutput {
|
|
856
|
-
var output: VertexOutput;
|
|
857
|
-
let texX = instance.textureRect.x + input.texCoord.x * instance.textureRect.z;
|
|
858
|
-
let texY = instance.textureRect.y + input.texCoord.y * instance.textureRect.w;
|
|
859
|
-
output.texCoord = vec2<f32>(texX, texY);
|
|
860
|
-
var pos = vec2<f32>(input.position.x, 1.0 - input.position.y);
|
|
861
|
-
pos = pos * vec2<f32>(instance.textureDim.x, instance.textureDim.y);
|
|
862
|
-
let scale0 = instance.matrixScale.x;
|
|
863
|
-
let rotate0 = instance.matrixScale.y;
|
|
864
|
-
let scale1 = instance.matrixScale.z;
|
|
865
|
-
let rotate1 = instance.matrixScale.w;
|
|
866
|
-
let transformedX = pos.x * scale0 + pos.y * scale1 + instance.matrixTx.x;
|
|
867
|
-
let transformedY = pos.x * rotate0 + pos.y * rotate1 + instance.matrixTx.y;
|
|
868
|
-
var position = vec2<f32>(transformedX, transformedY) / vec2<f32>(instance.textureDim.z, instance.textureDim.w);
|
|
869
|
-
position = position * 2.0 - 1.0;
|
|
870
|
-
output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);
|
|
871
|
-
output.mulColor = instance.mulColor;
|
|
872
|
-
output.addColor = instance.addColor;
|
|
873
|
-
return output;
|
|
874
|
-
}
|
|
875
|
-
\`,ka=\`
|
|
876
|
-
override yFlipSign: f32 = 1.0;
|
|
877
|
-
|
|
878
|
-
struct VertexInput {
|
|
879
|
-
@location(0) position: vec2<f32>,
|
|
880
|
-
@location(1) bezier: vec2<f32>,
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
struct VertexOutput {
|
|
884
|
-
@builtin(position) position: vec4<f32>,
|
|
885
|
-
@location(0) v_uv: vec2<f32>,
|
|
886
|
-
@location(1) bezier: vec2<f32>,
|
|
887
|
-
@location(2) color: vec4<f32>,
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
struct GradientUniforms {
|
|
891
|
-
inverseMatrix: mat3x3<f32>,
|
|
892
|
-
gradientType: f32,
|
|
893
|
-
focal: f32,
|
|
894
|
-
spread: f32,
|
|
895
|
-
radius: f32,
|
|
896
|
-
linearPoints: vec4<f32>,
|
|
897
|
-
color: vec4<f32>,
|
|
898
|
-
contextMatrix0: vec4<f32>,
|
|
899
|
-
contextMatrix1: vec4<f32>,
|
|
900
|
-
contextMatrix2: vec4<f32>,
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
@group(0) @binding(0) var<uniform> gradient: GradientUniforms;
|
|
904
|
-
|
|
905
|
-
@vertex
|
|
906
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
907
|
-
var output: VertexOutput;
|
|
908
|
-
let contextMatrix = mat3x3<f32>(gradient.contextMatrix0.xyz, gradient.contextMatrix1.xyz, gradient.contextMatrix2.xyz);
|
|
909
|
-
let pos = contextMatrix * vec3<f32>(input.position, 1.0);
|
|
910
|
-
let ndc = vec2<f32>(pos.x * 2.0 - 1.0, pos.y * 2.0 - 1.0);
|
|
911
|
-
output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);
|
|
912
|
-
let uvPos = gradient.inverseMatrix * vec3<f32>(input.position, 1.0);
|
|
913
|
-
output.v_uv = uvPos.xy;
|
|
914
|
-
output.bezier = input.bezier;
|
|
915
|
-
output.color = gradient.color;
|
|
916
|
-
return output;
|
|
917
|
-
}
|
|
918
|
-
\`,Ia=\`
|
|
919
|
-
override yFlipSign: f32 = 1.0;
|
|
920
|
-
|
|
921
|
-
struct VertexInput {
|
|
922
|
-
@location(0) position: vec2<f32>,
|
|
923
|
-
@location(1) bezier: vec2<f32>,
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
struct VertexOutput {
|
|
927
|
-
@builtin(position) position: vec4<f32>,
|
|
928
|
-
@location(0) bezier: vec2<f32>,
|
|
929
|
-
@location(1) color: vec4<f32>,
|
|
930
|
-
@location(2) worldPos: vec2<f32>,
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
struct BitmapUniforms {
|
|
934
|
-
bitmapMatrix: mat3x3<f32>,
|
|
935
|
-
width: f32,
|
|
936
|
-
height: f32,
|
|
937
|
-
repeat: f32,
|
|
938
|
-
_pad: f32,
|
|
939
|
-
color: vec4<f32>,
|
|
940
|
-
contextMatrix0: vec4<f32>,
|
|
941
|
-
contextMatrix1: vec4<f32>,
|
|
942
|
-
contextMatrix2: vec4<f32>,
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
@group(0) @binding(0) var<uniform> bitmap: BitmapUniforms;
|
|
946
|
-
|
|
947
|
-
@vertex
|
|
948
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
949
|
-
var output: VertexOutput;
|
|
950
|
-
let matrix = mat3x3<f32>(bitmap.contextMatrix0.xyz, bitmap.contextMatrix1.xyz, bitmap.contextMatrix2.xyz);
|
|
951
|
-
let transformedPos = matrix * vec3<f32>(input.position, 1.0);
|
|
952
|
-
let clipX = transformedPos.x * 2.0 - 1.0;
|
|
953
|
-
let clipY = (transformedPos.y * 2.0 - 1.0) * yFlipSign;
|
|
954
|
-
output.position = vec4<f32>(clipX, clipY, 0.0, 1.0);
|
|
955
|
-
output.bezier = input.bezier;
|
|
956
|
-
output.color = bitmap.color;
|
|
957
|
-
output.worldPos = input.position;
|
|
958
|
-
return output;
|
|
959
|
-
}
|
|
960
|
-
\`,Nt=\`
|
|
961
|
-
fn isInside(uv: vec2<f32>) -> f32 {
|
|
962
|
-
let s = step(vec2<f32>(0.0), uv) * step(uv, vec2<f32>(1.0));
|
|
963
|
-
return s.x * s.y;
|
|
964
|
-
}\`,lp=\`
|
|
965
|
-
const positions = array<vec2<f32>, 6>(
|
|
966
|
-
vec2<f32>(-1.0, -1.0),
|
|
967
|
-
vec2<f32>( 1.0, -1.0),
|
|
968
|
-
vec2<f32>(-1.0, 1.0),
|
|
969
|
-
vec2<f32>(-1.0, 1.0),
|
|
970
|
-
vec2<f32>( 1.0, -1.0),
|
|
971
|
-
vec2<f32>( 1.0, 1.0)
|
|
972
|
-
);\`,es=\`
|
|
973
|
-
const vertices = array<vec2<f32>, 6>(
|
|
974
|
-
vec2<f32>(0.0, 0.0),
|
|
975
|
-
vec2<f32>(1.0, 0.0),
|
|
976
|
-
vec2<f32>(0.0, 1.0),
|
|
977
|
-
vec2<f32>(0.0, 1.0),
|
|
978
|
-
vec2<f32>(1.0, 0.0),
|
|
979
|
-
vec2<f32>(1.0, 1.0)
|
|
980
|
-
);\`,Be=\`
|
|
981
|
-
struct VertexOutput {
|
|
982
|
-
@builtin(position) position: vec4<f32>,
|
|
983
|
-
@location(0) texCoord: vec2<f32>,
|
|
984
|
-
}\`,fo=t=>\`
|
|
985
|
-
\${Be}
|
|
986
|
-
|
|
987
|
-
@vertex
|
|
988
|
-
fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
989
|
-
var output: VertexOutput;
|
|
990
|
-
\${lp}
|
|
991
|
-
var texCoords = array<vec2<f32>, 6>(
|
|
992
|
-
vec2<f32>(0.0, \${t?"1.0":"0.0"}),
|
|
993
|
-
vec2<f32>(1.0, \${t?"1.0":"0.0"}),
|
|
994
|
-
vec2<f32>(0.0, \${t?"0.0":"1.0"}),
|
|
995
|
-
vec2<f32>(0.0, \${t?"0.0":"1.0"}),
|
|
996
|
-
vec2<f32>(1.0, \${t?"1.0":"0.0"}),
|
|
997
|
-
vec2<f32>(1.0, \${t?"0.0":"1.0"})
|
|
998
|
-
);
|
|
999
|
-
output.position = vec4<f32>(positions[vertexIndex], 0.0, 1.0);
|
|
1000
|
-
output.texCoord = texCoords[vertexIndex];
|
|
1001
|
-
return output;
|
|
1002
|
-
}
|
|
1003
|
-
\`,up=fo(!0),fp=fo(!1),hp=fo(!1),dp=\`
|
|
1004
|
-
struct VertexInput {
|
|
1005
|
-
@location(0) position: vec2<f32>,
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
struct VertexOutput {
|
|
1009
|
-
@builtin(position) position: vec4<f32>,
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
@vertex
|
|
1013
|
-
fn main(input: VertexInput) -> VertexOutput {
|
|
1014
|
-
var output: VertexOutput;
|
|
1015
|
-
let ndc = input.position * 2.0 - 1.0;
|
|
1016
|
-
output.position = vec4<f32>(ndc.x, ndc.y, 0.0, 1.0);
|
|
1017
|
-
return output;
|
|
1018
|
-
}
|
|
1019
|
-
\`,pp=\`
|
|
1020
|
-
struct PositionUniforms {
|
|
1021
|
-
offset: vec2<f32>,
|
|
1022
|
-
size: vec2<f32>,
|
|
1023
|
-
viewport: vec2<f32>,
|
|
1024
|
-
padding: vec2<f32>,
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
struct VertexOutput {
|
|
1028
|
-
@builtin(position) position: vec4<f32>,
|
|
1029
|
-
@location(0) texCoord: vec2<f32>,
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
@group(0) @binding(0) var<uniform> uniforms: PositionUniforms;
|
|
1033
|
-
|
|
1034
|
-
@vertex
|
|
1035
|
-
fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
1036
|
-
var output: VertexOutput;
|
|
1037
|
-
\${es}
|
|
1038
|
-
let vertex = vertices[vertexIndex];
|
|
1039
|
-
output.texCoord = vec2<f32>(vertex.x, 1.0 - vertex.y);
|
|
1040
|
-
var position = vertex * uniforms.size + uniforms.offset;
|
|
1041
|
-
position = position / uniforms.viewport;
|
|
1042
|
-
position = position * 2.0 - 1.0;
|
|
1043
|
-
output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);
|
|
1044
|
-
return output;
|
|
1045
|
-
}
|
|
1046
|
-
\`,mp=\`
|
|
1047
|
-
struct BitmapSyncUniforms {
|
|
1048
|
-
nodeRect: vec4<f32>,
|
|
1049
|
-
textureSize: vec2<f32>,
|
|
1050
|
-
padding: vec2<f32>,
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
struct VertexOutput {
|
|
1054
|
-
@builtin(position) position: vec4<f32>,
|
|
1055
|
-
@location(0) texCoord: vec2<f32>,
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
@group(0) @binding(0) var<uniform> uniforms: BitmapSyncUniforms;
|
|
1059
|
-
|
|
1060
|
-
@vertex
|
|
1061
|
-
fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
1062
|
-
var output: VertexOutput;
|
|
1063
|
-
\${es}
|
|
1064
|
-
let vertex = vertices[vertexIndex];
|
|
1065
|
-
let pixelPos = vec2<f32>(
|
|
1066
|
-
uniforms.nodeRect.x + vertex.x * uniforms.nodeRect.z,
|
|
1067
|
-
uniforms.nodeRect.y + vertex.y * uniforms.nodeRect.w
|
|
1068
|
-
);
|
|
1069
|
-
let ndc = pixelPos / uniforms.textureSize * 2.0 - 1.0;
|
|
1070
|
-
output.position = vec4<f32>(ndc.x, -ndc.y, 0.0, 1.0);
|
|
1071
|
-
output.texCoord = pixelPos / uniforms.textureSize;
|
|
1072
|
-
return output;
|
|
1073
|
-
}
|
|
1074
|
-
\`,gp=\`
|
|
1075
|
-
struct ScaleUniforms {
|
|
1076
|
-
matrix: vec4<f32>,
|
|
1077
|
-
translate: vec2<f32>,
|
|
1078
|
-
srcSize: vec2<f32>,
|
|
1079
|
-
dstSize: vec2<f32>,
|
|
1080
|
-
padding: vec2<f32>,
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
struct VertexOutput {
|
|
1084
|
-
@builtin(position) position: vec4<f32>,
|
|
1085
|
-
@location(0) texCoord: vec2<f32>,
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
@group(0) @binding(0) var<uniform> uniforms: ScaleUniforms;
|
|
1089
|
-
\`,bp=\`
|
|
1090
|
-
var pos = vertex * uniforms.srcSize;
|
|
1091
|
-
let a = uniforms.matrix.x;
|
|
1092
|
-
let b = uniforms.matrix.y;
|
|
1093
|
-
let c = uniforms.matrix.z;
|
|
1094
|
-
let d = uniforms.matrix.w;
|
|
1095
|
-
let tx = uniforms.translate.x;
|
|
1096
|
-
let ty = uniforms.translate.y;
|
|
1097
|
-
let transformedX = pos.x * a + pos.y * c + tx;
|
|
1098
|
-
let transformedY = pos.x * b + pos.y * d + ty;
|
|
1099
|
-
var position = vec2<f32>(transformedX, transformedY) / uniforms.dstSize;
|
|
1100
|
-
position = position * 2.0 - 1.0;
|
|
1101
|
-
output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);
|
|
1102
|
-
\`,ho=t=>\`
|
|
1103
|
-
\${gp}
|
|
1104
|
-
|
|
1105
|
-
@vertex
|
|
1106
|
-
fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
1107
|
-
var output: VertexOutput;
|
|
1108
|
-
\${es}
|
|
1109
|
-
let vertex = vertices[vertexIndex];
|
|
1110
|
-
output.texCoord = \${t?"vec2<f32>(vertex.x, 1.0 - vertex.y)":"vertex"};
|
|
1111
|
-
\${bp}
|
|
1112
|
-
return output;
|
|
1113
|
-
}
|
|
1114
|
-
\`,xp=ho(!1),yp=ho(!0),vp=ho(!1),_a=t=>\`
|
|
1115
|
-
struct PositionUniforms {
|
|
1116
|
-
offset: vec2<f32>,
|
|
1117
|
-
size: vec2<f32>,
|
|
1118
|
-
viewport: vec2<f32>,
|
|
1119
|
-
padding: vec2<f32>,
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
struct VertexOutput {
|
|
1123
|
-
@builtin(position) position: vec4<f32>,
|
|
1124
|
-
@location(0) texCoord: vec2<f32>,
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
@group(0) @binding(0) var<uniform> uniforms: PositionUniforms;
|
|
1128
|
-
|
|
1129
|
-
@vertex
|
|
1130
|
-
fn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
1131
|
-
var output: VertexOutput;
|
|
1132
|
-
\${es}
|
|
1133
|
-
let vertex = vertices[vertexIndex];
|
|
1134
|
-
output.texCoord = \${t?"vec2<f32>(vertex.x, 1.0 - vertex.y)":"vertex"};
|
|
1135
|
-
var position = vertex * uniforms.size + uniforms.offset;
|
|
1136
|
-
position = position / uniforms.viewport;
|
|
1137
|
-
position = position * 2.0 - 1.0;
|
|
1138
|
-
output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);
|
|
1139
|
-
return output;
|
|
1140
|
-
}
|
|
1141
|
-
\`,Mp=_a(!1),Sp=_a(!0),$p=\`
|
|
1142
|
-
struct FragmentInput {
|
|
1143
|
-
@builtin(position) position: vec4<f32>,
|
|
1144
|
-
@location(0) bezier: vec2<f32>,
|
|
1145
|
-
@location(1) color: vec4<f32>,
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
@fragment
|
|
1149
|
-
fn main(input: FragmentInput) -> @location(0) vec4<f32> {
|
|
1150
|
-
let f_val = input.bezier.x * input.bezier.x - input.bezier.y;
|
|
1151
|
-
let dx = dpdx(f_val);
|
|
1152
|
-
let dy = dpdy(f_val);
|
|
1153
|
-
|
|
1154
|
-
if (input.bezier.x == 0.5 && input.bezier.y == 0.5) {
|
|
1155
|
-
return vec4<f32>(input.color.rgb * input.color.a, input.color.a);
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
let dist = f_val * inverseSqrt(dx * dx + dy * dy);
|
|
1159
|
-
let coverage = smoothstep(0.5, -0.5, dist);
|
|
1160
|
-
|
|
1161
|
-
if (coverage <= 0.001) {
|
|
1162
|
-
discard;
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
let finalAlpha = input.color.a * min(coverage, 1.0);
|
|
1166
|
-
return vec4<f32>(input.color.rgb * finalAlpha, finalAlpha);
|
|
1167
|
-
}
|
|
1168
|
-
\`,Tp=\`
|
|
1169
|
-
struct FragmentInput {
|
|
1170
|
-
@builtin(position) position: vec4<f32>,
|
|
1171
|
-
@location(0) bezier: vec2<f32>,
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
@fragment
|
|
1175
|
-
fn main(input: FragmentInput) -> @location(0) vec4<f32> {
|
|
1176
|
-
let f_val = input.bezier.x * input.bezier.x - input.bezier.y;
|
|
1177
|
-
let dx = dpdx(f_val);
|
|
1178
|
-
let dy = dpdy(f_val);
|
|
1179
|
-
let dist = f_val * inverseSqrt(dx * dx + dy * dy);
|
|
1180
|
-
let alpha = smoothstep(0.5, -0.5, dist);
|
|
1181
|
-
|
|
1182
|
-
if (alpha <= 0.001) {
|
|
1183
|
-
discard;
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
return vec4<f32>(0.0, 0.0, 0.0, min(alpha, 1.0));
|
|
1187
|
-
}
|
|
1188
|
-
\`,Bp=\`
|
|
1189
|
-
struct FragmentInput {
|
|
1190
|
-
@builtin(position) position: vec4<f32>,
|
|
1191
|
-
@location(0) color: vec4<f32>,
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
@fragment
|
|
1195
|
-
fn main(input: FragmentInput) -> @location(0) vec4<f32> {
|
|
1196
|
-
let a = input.color.a;
|
|
1197
|
-
return vec4<f32>(input.color.r * a, input.color.g * a, input.color.b * a, a);
|
|
1198
|
-
}
|
|
1199
|
-
\`,Pp=\`
|
|
1200
|
-
struct FragmentInput {
|
|
1201
|
-
@location(0) bezier: vec2<f32>,
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
@fragment
|
|
1205
|
-
fn main(input: FragmentInput) -> @location(0) vec4<f32> {
|
|
1206
|
-
let px = dpdx(input.bezier);
|
|
1207
|
-
let py = dpdy(input.bezier);
|
|
1208
|
-
let f = (2.0 * input.bezier.x) * vec2<f32>(px.x, py.x) - vec2<f32>(px.y, py.y);
|
|
1209
|
-
let alpha = 0.5 - (input.bezier.x * input.bezier.x - input.bezier.y) / length(f);
|
|
1210
|
-
if (alpha <= 0.0) {
|
|
1211
|
-
discard;
|
|
1212
|
-
}
|
|
1213
|
-
return vec4<f32>(min(alpha, 1.0));
|
|
1214
|
-
}
|
|
1215
|
-
\`,Ap=\`
|
|
1216
|
-
struct VertexOutput {
|
|
1217
|
-
@builtin(position) position: vec4<f32>,
|
|
1218
|
-
@location(0) texCoord: vec2<f32>,
|
|
1219
|
-
@location(1) color: vec4<f32>,
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
@fragment
|
|
1223
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1224
|
-
return input.color;
|
|
1225
|
-
}
|
|
1226
|
-
\`,Fp=\`
|
|
1227
|
-
struct VertexOutput {
|
|
1228
|
-
@builtin(position) position: vec4<f32>,
|
|
1229
|
-
@location(0) texCoord: vec2<f32>,
|
|
1230
|
-
@location(1) color: vec4<f32>,
|
|
1231
|
-
}
|
|
1232
|
-
|
|
1233
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1234
|
-
@group(0) @binding(2) var textureData: texture_2d<f32>;
|
|
1235
|
-
|
|
1236
|
-
@fragment
|
|
1237
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1238
|
-
let textureColor = textureSampleLevel(textureData, textureSampler, input.texCoord, 0);
|
|
1239
|
-
return textureColor * input.color;
|
|
1240
|
-
}
|
|
1241
|
-
\`,wp=\`
|
|
1242
|
-
struct VertexOutput {
|
|
1243
|
-
@builtin(position) position: vec4<f32>,
|
|
1244
|
-
@location(0) texCoord: vec2<f32>,
|
|
1245
|
-
@location(1) mulColor: vec4<f32>,
|
|
1246
|
-
@location(2) addColor: vec4<f32>,
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
@group(0) @binding(0) var textureSampler: sampler;
|
|
1250
|
-
@group(0) @binding(1) var textureData: texture_2d<f32>;
|
|
1251
|
-
|
|
1252
|
-
@fragment
|
|
1253
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1254
|
-
var src = textureSample(textureData, textureSampler, input.texCoord);
|
|
1255
|
-
src = vec4<f32>(src.rgb / max(0.0001, src.a), src.a);
|
|
1256
|
-
src = clamp(src * input.mulColor + input.addColor, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
1257
|
-
src = vec4<f32>(src.rgb * src.a, src.a);
|
|
1258
|
-
return src;
|
|
1259
|
-
}
|
|
1260
|
-
\`,po=\`
|
|
1261
|
-
struct GradientUniforms {
|
|
1262
|
-
inverseMatrix: mat3x3<f32>,
|
|
1263
|
-
gradientType: f32,
|
|
1264
|
-
focal: f32,
|
|
1265
|
-
spread: f32,
|
|
1266
|
-
radius: f32,
|
|
1267
|
-
linearPoints: vec4<f32>,
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
@group(0) @binding(0) var<uniform> gradient: GradientUniforms;
|
|
1271
|
-
@group(0) @binding(1) var gradientSampler: sampler;
|
|
1272
|
-
@group(0) @binding(2) var gradientTexture: texture_2d<f32>;
|
|
1273
|
-
|
|
1274
|
-
override GRADIENT_TYPE: u32 = 0u;
|
|
1275
|
-
override SPREAD_MODE: u32 = 2u;
|
|
1276
|
-
|
|
1277
|
-
fn applySpread(t: f32) -> f32 {
|
|
1278
|
-
if (SPREAD_MODE == 0u) {
|
|
1279
|
-
return 1.0 - abs(fract(t * 0.5) * 2.0 - 1.0);
|
|
1280
|
-
} else if (SPREAD_MODE == 1u) {
|
|
1281
|
-
return fract(t);
|
|
1282
|
-
} else {
|
|
1283
|
-
return clamp(t, 0.0, 1.0);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
\`,mo=\`
|
|
1287
|
-
var t: f32;
|
|
1288
|
-
if (GRADIENT_TYPE == 0u) {
|
|
1289
|
-
let a = gradient.linearPoints.xy;
|
|
1290
|
-
let b = gradient.linearPoints.zw;
|
|
1291
|
-
let ab = b - a;
|
|
1292
|
-
let ap = p - a;
|
|
1293
|
-
let dotAB = dot(ab, ab);
|
|
1294
|
-
if (dotAB < 0.0001) {
|
|
1295
|
-
t = 0.0;
|
|
1296
|
-
} else {
|
|
1297
|
-
t = dot(ab, ap) / dotAB;
|
|
1298
|
-
}
|
|
1299
|
-
} else {
|
|
1300
|
-
let r = gradient.radius;
|
|
1301
|
-
let coord = p / r;
|
|
1302
|
-
let focalRatio = gradient.focal;
|
|
1303
|
-
|
|
1304
|
-
if (abs(focalRatio) < 0.001) {
|
|
1305
|
-
t = length(coord);
|
|
1306
|
-
} else {
|
|
1307
|
-
let focal = vec2<f32>(focalRatio, 0.0);
|
|
1308
|
-
let diff = coord - focal;
|
|
1309
|
-
let lenDiff = length(diff);
|
|
1310
|
-
|
|
1311
|
-
if (lenDiff < 0.0001) {
|
|
1312
|
-
t = 0.0;
|
|
1313
|
-
} else {
|
|
1314
|
-
let dir = diff / lenDiff;
|
|
1315
|
-
|
|
1316
|
-
// Solve quadratic equation for unit circle intersection (a=1 since dir is normalized)
|
|
1317
|
-
let b_coef = 2.0 * dot(dir, focal);
|
|
1318
|
-
let c_coef = dot(focal, focal) - 1.0;
|
|
1319
|
-
let discriminant = b_coef * b_coef - 4.0 * c_coef;
|
|
1320
|
-
let x = (-b_coef + sqrt(max(discriminant, 0.0))) * 0.5;
|
|
1321
|
-
t = lenDiff / abs(x);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
t = applySpread(t);
|
|
1326
|
-
let gradientColor = textureSampleLevel(gradientTexture, gradientSampler, vec2<f32>(t, 0.5), 0);
|
|
1327
|
-
\`,Op=\`
|
|
1328
|
-
struct VertexOutput {
|
|
1329
|
-
@builtin(position) position: vec4<f32>,
|
|
1330
|
-
@location(0) v_uv: vec2<f32>,
|
|
1331
|
-
@location(1) bezier: vec2<f32>,
|
|
1332
|
-
@location(2) color: vec4<f32>,
|
|
1333
|
-
}
|
|
1334
|
-
\${po}
|
|
1335
|
-
|
|
1336
|
-
@fragment
|
|
1337
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1338
|
-
let p = input.v_uv;
|
|
1339
|
-
\${mo}
|
|
1340
|
-
let result = gradientColor * input.color;
|
|
1341
|
-
return vec4<f32>(result.rgb * result.a, result.a);
|
|
1342
|
-
}
|
|
1343
|
-
\`,Ep=\`
|
|
1344
|
-
struct VertexOutput {
|
|
1345
|
-
@builtin(position) position: vec4<f32>,
|
|
1346
|
-
@location(0) v_uv: vec2<f32>,
|
|
1347
|
-
@location(1) bezier: vec2<f32>,
|
|
1348
|
-
@location(2) color: vec4<f32>,
|
|
1349
|
-
}
|
|
1350
|
-
\${po}
|
|
1351
|
-
|
|
1352
|
-
@fragment
|
|
1353
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1354
|
-
let p = input.v_uv;
|
|
1355
|
-
\${mo}
|
|
1356
|
-
return vec4<f32>(gradientColor.rgb * gradientColor.a, gradientColor.a);
|
|
1357
|
-
}
|
|
1358
|
-
\`,Rp=\`
|
|
1359
|
-
struct VertexOutput {
|
|
1360
|
-
@builtin(position) position: vec4<f32>,
|
|
1361
|
-
@location(0) texCoord: vec2<f32>,
|
|
1362
|
-
@location(1) color: vec4<f32>,
|
|
1363
|
-
}
|
|
1364
|
-
\${po}
|
|
1365
|
-
|
|
1366
|
-
@fragment
|
|
1367
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1368
|
-
let p = input.texCoord;
|
|
1369
|
-
\${mo}
|
|
1370
|
-
let result = gradientColor * input.color;
|
|
1371
|
-
return vec4<f32>(result.rgb * result.a, result.a);
|
|
1372
|
-
}
|
|
1373
|
-
\`,Cp=\`
|
|
1374
|
-
struct VertexOutput {
|
|
1375
|
-
@builtin(position) position: vec4<f32>,
|
|
1376
|
-
@location(0) bezier: vec2<f32>,
|
|
1377
|
-
@location(1) color: vec4<f32>,
|
|
1378
|
-
@location(2) worldPos: vec2<f32>,
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
struct BitmapUniforms {
|
|
1382
|
-
bitmapMatrix: mat3x3<f32>,
|
|
1383
|
-
textureWidth: f32,
|
|
1384
|
-
textureHeight: f32,
|
|
1385
|
-
repeat: f32,
|
|
1386
|
-
_pad: f32,
|
|
1387
|
-
}
|
|
1388
|
-
|
|
1389
|
-
@group(0) @binding(0) var<uniform> uniforms: BitmapUniforms;
|
|
1390
|
-
@group(0) @binding(1) var bitmapSampler: sampler;
|
|
1391
|
-
@group(0) @binding(2) var bitmapTexture: texture_2d<f32>;
|
|
1392
|
-
|
|
1393
|
-
@fragment
|
|
1394
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1395
|
-
let u = input.bezier.x;
|
|
1396
|
-
let v = input.bezier.y;
|
|
1397
|
-
if (abs(u - 0.5) > 0.001 || abs(v - 0.5) > 0.001) {
|
|
1398
|
-
let d = u * u - v;
|
|
1399
|
-
if (d > 0.0) {
|
|
1400
|
-
discard;
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
let transformedPos = uniforms.bitmapMatrix * vec3<f32>(input.worldPos, 1.0);
|
|
1404
|
-
var uv = vec2<f32>(
|
|
1405
|
-
transformedPos.x / uniforms.textureWidth,
|
|
1406
|
-
transformedPos.y / uniforms.textureHeight
|
|
1407
|
-
);
|
|
1408
|
-
if (uniforms.repeat > 0.5) {
|
|
1409
|
-
uv = fract(uv);
|
|
1410
|
-
}
|
|
1411
|
-
let bitmapColor = textureSampleLevel(bitmapTexture, bitmapSampler, uv, 0);
|
|
1412
|
-
let alpha = bitmapColor.a * input.color.a;
|
|
1413
|
-
return vec4<f32>(bitmapColor.rgb * input.color.a, alpha);
|
|
1414
|
-
}
|
|
1415
|
-
\`,Up=\`
|
|
1416
|
-
\${Be}
|
|
1417
|
-
|
|
1418
|
-
struct CopyUniforms {
|
|
1419
|
-
scale: vec2<f32>,
|
|
1420
|
-
offset: vec2<f32>,
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;
|
|
1424
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1425
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1426
|
-
|
|
1427
|
-
@fragment
|
|
1428
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1429
|
-
let uv = input.texCoord * uniforms.scale + uniforms.offset;
|
|
1430
|
-
return textureSampleLevel(inputTexture, textureSampler, uv, 0);
|
|
1431
|
-
}
|
|
1432
|
-
\`,Gp=\`
|
|
1433
|
-
\${Be}
|
|
1434
|
-
|
|
1435
|
-
struct CopyUniforms {
|
|
1436
|
-
scale: vec2<f32>,
|
|
1437
|
-
offset: vec2<f32>,
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;
|
|
1441
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1442
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1443
|
-
|
|
1444
|
-
@fragment
|
|
1445
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1446
|
-
let uv = (input.texCoord - uniforms.offset) * uniforms.scale;
|
|
1447
|
-
let clampedUv = clamp(uv, vec2<f32>(0.0), vec2<f32>(1.0));
|
|
1448
|
-
let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0);
|
|
1449
|
-
let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0;
|
|
1450
|
-
return select(vec4<f32>(0.0, 0.0, 0.0, 0.0), color, inBounds);
|
|
1451
|
-
}
|
|
1452
|
-
\`,Lp=\`
|
|
1453
|
-
\${Be}
|
|
1454
|
-
|
|
1455
|
-
struct CopyUniforms {
|
|
1456
|
-
scale: vec2<f32>,
|
|
1457
|
-
offset: vec2<f32>,
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;
|
|
1461
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1462
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1463
|
-
|
|
1464
|
-
@fragment
|
|
1465
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1466
|
-
let uv = input.texCoord * uniforms.scale + uniforms.offset;
|
|
1467
|
-
let clampedUv = clamp(uv, vec2<f32>(0.0), vec2<f32>(1.0));
|
|
1468
|
-
let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0);
|
|
1469
|
-
let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0;
|
|
1470
|
-
return select(vec4<f32>(0.0, 0.0, 0.0, 0.0), color, inBounds);
|
|
1471
|
-
}
|
|
1472
|
-
\`,kp=\`
|
|
1473
|
-
\${Be}
|
|
1474
|
-
|
|
1475
|
-
struct ColorTransformUniforms {
|
|
1476
|
-
mul: vec4<f32>,
|
|
1477
|
-
add: vec4<f32>,
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
@group(0) @binding(0) var<uniform> ct: ColorTransformUniforms;
|
|
1481
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1482
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1483
|
-
|
|
1484
|
-
@fragment
|
|
1485
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1486
|
-
var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);
|
|
1487
|
-
|
|
1488
|
-
color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);
|
|
1489
|
-
color = clamp(color * ct.mul + ct.add, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
1490
|
-
color = vec4<f32>(color.rgb * color.a, color.a);
|
|
1491
|
-
|
|
1492
|
-
return color;
|
|
1493
|
-
}
|
|
1494
|
-
\`,Ip=\`
|
|
1495
|
-
\${Be}
|
|
1496
|
-
|
|
1497
|
-
struct YFlipCTUniforms {
|
|
1498
|
-
scale: vec2<f32>,
|
|
1499
|
-
offset: vec2<f32>,
|
|
1500
|
-
mul: vec4<f32>,
|
|
1501
|
-
add: vec4<f32>,
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
@group(0) @binding(0) var<uniform> uniforms: YFlipCTUniforms;
|
|
1505
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1506
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1507
|
-
|
|
1508
|
-
@fragment
|
|
1509
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1510
|
-
let uv = input.texCoord * uniforms.scale + uniforms.offset;
|
|
1511
|
-
var color = textureSampleLevel(inputTexture, textureSampler, uv, 0);
|
|
1512
|
-
|
|
1513
|
-
color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);
|
|
1514
|
-
color = clamp(color * uniforms.mul + uniforms.add, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
1515
|
-
color = vec4<f32>(color.rgb * color.a, color.a);
|
|
1516
|
-
|
|
1517
|
-
return color;
|
|
1518
|
-
}
|
|
1519
|
-
\`,_p=\`
|
|
1520
|
-
\${Be}
|
|
1521
|
-
|
|
1522
|
-
struct ColorMatrixUniforms {
|
|
1523
|
-
matrix: mat4x4<f32>,
|
|
1524
|
-
offset: vec4<f32>,
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
@group(0) @binding(0) var<uniform> uniforms: ColorMatrixUniforms;
|
|
1528
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1529
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1530
|
-
|
|
1531
|
-
@fragment
|
|
1532
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1533
|
-
var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);
|
|
1534
|
-
|
|
1535
|
-
color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);
|
|
1536
|
-
var result = uniforms.matrix * color + uniforms.offset;
|
|
1537
|
-
result = clamp(result, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
1538
|
-
result = vec4<f32>(result.rgb * result.a, result.a);
|
|
1539
|
-
|
|
1540
|
-
return result;
|
|
1541
|
-
}
|
|
1542
|
-
\`,Vp=\`
|
|
1543
|
-
@fragment
|
|
1544
|
-
fn main() -> @location(0) vec4<f32> {
|
|
1545
|
-
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
|
1546
|
-
}
|
|
1547
|
-
\`,Dp=\`
|
|
1548
|
-
\${Be}
|
|
1549
|
-
|
|
1550
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1551
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1552
|
-
|
|
1553
|
-
@fragment
|
|
1554
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1555
|
-
return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);
|
|
1556
|
-
}
|
|
1557
|
-
\`,Np=\`
|
|
1558
|
-
\${Be}
|
|
1559
|
-
|
|
1560
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1561
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1562
|
-
|
|
1563
|
-
@fragment
|
|
1564
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1565
|
-
return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);
|
|
1566
|
-
}
|
|
1567
|
-
\`,zp=\`
|
|
1568
|
-
struct VertexOutput {
|
|
1569
|
-
@builtin(position) position: vec4<f32>,
|
|
1570
|
-
@location(0) texCoord: vec2<f32>,
|
|
1571
|
-
@location(1) color: vec4<f32>,
|
|
1572
|
-
}
|
|
1573
|
-
|
|
1574
|
-
struct BlendUniforms {
|
|
1575
|
-
blendMode: f32,
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1578
|
-
@group(0) @binding(1) var<uniform> blend: BlendUniforms;
|
|
1579
|
-
@group(0) @binding(2) var srcSampler: sampler;
|
|
1580
|
-
@group(0) @binding(3) var srcTexture: texture_2d<f32>;
|
|
1581
|
-
@group(0) @binding(4) var dstSampler: sampler;
|
|
1582
|
-
@group(0) @binding(5) var dstTexture: texture_2d<f32>;
|
|
1583
|
-
|
|
1584
|
-
fn blendNormal(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {
|
|
1585
|
-
return src;
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
fn blendMultiply(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {
|
|
1589
|
-
return src * dst;
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
fn blendScreen(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {
|
|
1593
|
-
return src + dst - src * dst;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
fn blendAdd(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {
|
|
1597
|
-
return min(src + dst, vec4<f32>(1.0));
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
|
-
@fragment
|
|
1601
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1602
|
-
let src = textureSampleLevel(srcTexture, srcSampler, input.texCoord, 0);
|
|
1603
|
-
let dst = textureSampleLevel(dstTexture, dstSampler, input.texCoord, 0);
|
|
1604
|
-
var result: vec4<f32>;
|
|
1605
|
-
if (blend.blendMode < 0.5) {
|
|
1606
|
-
result = blendNormal(src, dst);
|
|
1607
|
-
} else if (blend.blendMode < 1.5) {
|
|
1608
|
-
result = blendMultiply(src, dst);
|
|
1609
|
-
} else if (blend.blendMode < 2.5) {
|
|
1610
|
-
result = blendScreen(src, dst);
|
|
1611
|
-
} else {
|
|
1612
|
-
result = blendAdd(src, dst);
|
|
1613
|
-
}
|
|
1614
|
-
return result * input.color;
|
|
1615
|
-
}
|
|
1616
|
-
\`,Xp=\`
|
|
1617
|
-
\${Be}
|
|
1618
|
-
|
|
1619
|
-
override IS_INNER: u32 = 0u;
|
|
1620
|
-
override IS_KNOCKOUT: u32 = 0u;
|
|
1621
|
-
|
|
1622
|
-
struct GlowUniforms {
|
|
1623
|
-
color: vec4<f32>,
|
|
1624
|
-
baseScale: vec2<f32>,
|
|
1625
|
-
baseOffset: vec2<f32>,
|
|
1626
|
-
blurScale: vec2<f32>,
|
|
1627
|
-
blurOffset: vec2<f32>,
|
|
1628
|
-
strength: f32,
|
|
1629
|
-
_padding1: f32,
|
|
1630
|
-
_padding2: f32,
|
|
1631
|
-
_padding3: f32,
|
|
1632
|
-
}
|
|
1633
|
-
|
|
1634
|
-
@group(0) @binding(0) var<uniform> uniforms: GlowUniforms;
|
|
1635
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1636
|
-
@group(0) @binding(2) var blurTexture: texture_2d<f32>;
|
|
1637
|
-
@group(0) @binding(3) var baseTexture: texture_2d<f32>;
|
|
1638
|
-
\${Nt}
|
|
1639
|
-
|
|
1640
|
-
@fragment
|
|
1641
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1642
|
-
let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;
|
|
1643
|
-
let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);
|
|
1644
|
-
|
|
1645
|
-
let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;
|
|
1646
|
-
let blurColor = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);
|
|
1647
|
-
|
|
1648
|
-
var rawAlpha = blurColor.a;
|
|
1649
|
-
if (IS_INNER == 1u) {
|
|
1650
|
-
rawAlpha = 1.0 - rawAlpha;
|
|
1651
|
-
}
|
|
1652
|
-
let glowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0);
|
|
1653
|
-
let glowColor = vec4<f32>(uniforms.color.rgb * glowAlpha, uniforms.color.a * glowAlpha);
|
|
1654
|
-
if (IS_INNER == 1u) {
|
|
1655
|
-
let innerGlow = glowColor * baseColor.a;
|
|
1656
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1657
|
-
return innerGlow;
|
|
1658
|
-
} else {
|
|
1659
|
-
return innerGlow + baseColor * (1.0 - glowColor.a);
|
|
1660
|
-
}
|
|
1661
|
-
} else {
|
|
1662
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1663
|
-
return glowColor * (1.0 - baseColor.a);
|
|
1664
|
-
} else {
|
|
1665
|
-
return baseColor + glowColor * (1.0 - baseColor.a);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
\`,Yp=\`
|
|
1670
|
-
\${Be}
|
|
1671
|
-
|
|
1672
|
-
override IS_INNER: u32 = 0u;
|
|
1673
|
-
override IS_KNOCKOUT: u32 = 0u;
|
|
1674
|
-
override IS_HIDE_OBJECT: u32 = 0u;
|
|
1675
|
-
|
|
1676
|
-
struct DropShadowUniforms {
|
|
1677
|
-
color: vec4<f32>,
|
|
1678
|
-
baseScale: vec2<f32>,
|
|
1679
|
-
baseOffset: vec2<f32>,
|
|
1680
|
-
blurScale: vec2<f32>,
|
|
1681
|
-
blurOffset: vec2<f32>,
|
|
1682
|
-
strength: f32,
|
|
1683
|
-
_padding1: f32,
|
|
1684
|
-
_padding2: f32,
|
|
1685
|
-
_padding3: f32,
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
@group(0) @binding(0) var<uniform> uniforms: DropShadowUniforms;
|
|
1689
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1690
|
-
@group(0) @binding(2) var blurTexture: texture_2d<f32>;
|
|
1691
|
-
@group(0) @binding(3) var baseTexture: texture_2d<f32>;
|
|
1692
|
-
\${Nt}
|
|
1693
|
-
|
|
1694
|
-
@fragment
|
|
1695
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1696
|
-
let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;
|
|
1697
|
-
let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);
|
|
1698
|
-
|
|
1699
|
-
let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;
|
|
1700
|
-
let blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);
|
|
1701
|
-
|
|
1702
|
-
var rawAlpha = blur.a;
|
|
1703
|
-
if (IS_INNER == 1u) {
|
|
1704
|
-
rawAlpha = 1.0 - rawAlpha;
|
|
1705
|
-
}
|
|
1706
|
-
let shadowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0);
|
|
1707
|
-
let shadowColor = vec4<f32>(uniforms.color.rgb * shadowAlpha, uniforms.color.a * shadowAlpha);
|
|
1708
|
-
|
|
1709
|
-
if (IS_INNER == 1u) {
|
|
1710
|
-
let innerShadow = shadowColor * baseColor.a;
|
|
1711
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1712
|
-
return innerShadow;
|
|
1713
|
-
} else {
|
|
1714
|
-
return innerShadow + baseColor * (1.0 - shadowColor.a);
|
|
1715
|
-
}
|
|
1716
|
-
} else {
|
|
1717
|
-
if (IS_HIDE_OBJECT == 1u) {
|
|
1718
|
-
return shadowColor;
|
|
1719
|
-
} else if (IS_KNOCKOUT == 1u) {
|
|
1720
|
-
return shadowColor * (1.0 - baseColor.a);
|
|
1721
|
-
} else {
|
|
1722
|
-
return shadowColor * (1.0 - baseColor.a) + baseColor;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
\`,Wp=\`
|
|
1727
|
-
\${Be}
|
|
1728
|
-
|
|
1729
|
-
override GLOW_TYPE: u32 = 0u;
|
|
1730
|
-
override IS_KNOCKOUT: u32 = 0u;
|
|
1731
|
-
|
|
1732
|
-
struct GradientGlowUniforms {
|
|
1733
|
-
strength: f32,
|
|
1734
|
-
_padding1: f32,
|
|
1735
|
-
_padding2: f32,
|
|
1736
|
-
_padding3: f32,
|
|
1737
|
-
baseScale: vec2<f32>,
|
|
1738
|
-
baseOffset: vec2<f32>,
|
|
1739
|
-
blurScale: vec2<f32>,
|
|
1740
|
-
blurOffset: vec2<f32>,
|
|
1741
|
-
}
|
|
1742
|
-
|
|
1743
|
-
@group(0) @binding(0) var<uniform> uniforms: GradientGlowUniforms;
|
|
1744
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1745
|
-
@group(0) @binding(2) var blurTexture: texture_2d<f32>;
|
|
1746
|
-
@group(0) @binding(3) var baseTexture: texture_2d<f32>;
|
|
1747
|
-
@group(0) @binding(4) var gradientLUT: texture_2d<f32>;
|
|
1748
|
-
\${Nt}
|
|
1749
|
-
|
|
1750
|
-
@fragment
|
|
1751
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1752
|
-
let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;
|
|
1753
|
-
let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);
|
|
1754
|
-
|
|
1755
|
-
let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;
|
|
1756
|
-
var blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);
|
|
1757
|
-
|
|
1758
|
-
blur.a = clamp(blur.a * uniforms.strength, 0.0, 1.0);
|
|
1759
|
-
let glowColor = textureSampleLevel(gradientLUT, textureSampler, vec2<f32>(blur.a, 0.5), 0);
|
|
1760
|
-
var result: vec4<f32>;
|
|
1761
|
-
if (GLOW_TYPE == 0u) {
|
|
1762
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1763
|
-
result = glowColor;
|
|
1764
|
-
} else {
|
|
1765
|
-
result = base - base * glowColor.a + glowColor;
|
|
1766
|
-
}
|
|
1767
|
-
} else if (GLOW_TYPE == 1u) {
|
|
1768
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1769
|
-
result = glowColor * base.a;
|
|
1770
|
-
} else {
|
|
1771
|
-
result = glowColor * base.a + base * (1.0 - glowColor.a);
|
|
1772
|
-
}
|
|
1773
|
-
} else {
|
|
1774
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1775
|
-
result = glowColor - glowColor * base.a;
|
|
1776
|
-
} else {
|
|
1777
|
-
result = base + glowColor - glowColor * base.a;
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
return result;
|
|
1781
|
-
}
|
|
1782
|
-
\`,jp=\`
|
|
1783
|
-
\${Be}
|
|
1784
|
-
|
|
1785
|
-
override BEVEL_TYPE: u32 = 0u;
|
|
1786
|
-
override IS_KNOCKOUT: u32 = 0u;
|
|
1787
|
-
|
|
1788
|
-
struct GradientBevelUniforms {
|
|
1789
|
-
strength: f32,
|
|
1790
|
-
_padding1: f32,
|
|
1791
|
-
_padding2: f32,
|
|
1792
|
-
_padding3: f32,
|
|
1793
|
-
baseScale: vec2<f32>,
|
|
1794
|
-
baseOffset: vec2<f32>,
|
|
1795
|
-
blurScale: vec2<f32>,
|
|
1796
|
-
blurOffset: vec2<f32>,
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
@group(0) @binding(0) var<uniform> uniforms: GradientBevelUniforms;
|
|
1800
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1801
|
-
@group(0) @binding(2) var blurTexture: texture_2d<f32>;
|
|
1802
|
-
@group(0) @binding(3) var baseTexture: texture_2d<f32>;
|
|
1803
|
-
@group(0) @binding(4) var gradientLUT: texture_2d<f32>;
|
|
1804
|
-
\${Nt}
|
|
1805
|
-
|
|
1806
|
-
@fragment
|
|
1807
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1808
|
-
let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;
|
|
1809
|
-
let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);
|
|
1810
|
-
|
|
1811
|
-
let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;
|
|
1812
|
-
let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);
|
|
1813
|
-
|
|
1814
|
-
let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset;
|
|
1815
|
-
let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV);
|
|
1816
|
-
|
|
1817
|
-
var highlightAlpha = blur1.a - blur2.a;
|
|
1818
|
-
var shadowAlpha = blur2.a - blur1.a;
|
|
1819
|
-
highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0);
|
|
1820
|
-
shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0);
|
|
1821
|
-
|
|
1822
|
-
let lutCoord = 0.5019607843137255 - 0.5019607843137255 * shadowAlpha + 0.4980392156862745 * highlightAlpha;
|
|
1823
|
-
let bevelColor = textureSampleLevel(gradientLUT, textureSampler, vec2<f32>(lutCoord, 0.5), 0);
|
|
1824
|
-
|
|
1825
|
-
var result: vec4<f32>;
|
|
1826
|
-
if (BEVEL_TYPE == 0u) {
|
|
1827
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1828
|
-
result = bevelColor;
|
|
1829
|
-
} else {
|
|
1830
|
-
result = base - base * bevelColor.a + bevelColor;
|
|
1831
|
-
}
|
|
1832
|
-
} else if (BEVEL_TYPE == 1u) {
|
|
1833
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1834
|
-
result = bevelColor * base.a;
|
|
1835
|
-
} else {
|
|
1836
|
-
result = bevelColor * base.a + base * (1.0 - bevelColor.a);
|
|
1837
|
-
}
|
|
1838
|
-
} else {
|
|
1839
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1840
|
-
result = bevelColor - bevelColor * base.a;
|
|
1841
|
-
} else {
|
|
1842
|
-
result = base + bevelColor - bevelColor * base.a;
|
|
1843
|
-
}
|
|
1844
|
-
}
|
|
1845
|
-
|
|
1846
|
-
return result;
|
|
1847
|
-
}
|
|
1848
|
-
\`,Hp=\`
|
|
1849
|
-
\${Be}
|
|
1850
|
-
|
|
1851
|
-
override BEVEL_TYPE: u32 = 0u;
|
|
1852
|
-
override IS_KNOCKOUT: u32 = 0u;
|
|
1853
|
-
|
|
1854
|
-
struct BevelUniforms {
|
|
1855
|
-
highlightColor: vec4<f32>,
|
|
1856
|
-
shadowColor: vec4<f32>,
|
|
1857
|
-
strength: f32,
|
|
1858
|
-
_padding1: f32,
|
|
1859
|
-
_padding2: f32,
|
|
1860
|
-
_padding3: f32,
|
|
1861
|
-
baseScale: vec2<f32>,
|
|
1862
|
-
baseOffset: vec2<f32>,
|
|
1863
|
-
blurScale: vec2<f32>,
|
|
1864
|
-
blurOffset: vec2<f32>,
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1867
|
-
@group(0) @binding(0) var<uniform> uniforms: BevelUniforms;
|
|
1868
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1869
|
-
@group(0) @binding(2) var blurTexture: texture_2d<f32>;
|
|
1870
|
-
@group(0) @binding(3) var baseTexture: texture_2d<f32>;
|
|
1871
|
-
\${Nt}
|
|
1872
|
-
|
|
1873
|
-
@fragment
|
|
1874
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1875
|
-
let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;
|
|
1876
|
-
let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);
|
|
1877
|
-
|
|
1878
|
-
let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;
|
|
1879
|
-
let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);
|
|
1880
|
-
|
|
1881
|
-
let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset;
|
|
1882
|
-
let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV);
|
|
1883
|
-
|
|
1884
|
-
var highlightAlpha = blur1.a - blur2.a;
|
|
1885
|
-
var shadowAlpha = blur2.a - blur1.a;
|
|
1886
|
-
highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0);
|
|
1887
|
-
shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0);
|
|
1888
|
-
|
|
1889
|
-
let bevelColor = uniforms.highlightColor * highlightAlpha + uniforms.shadowColor * shadowAlpha;
|
|
1890
|
-
var result: vec4<f32>;
|
|
1891
|
-
if (BEVEL_TYPE == 0u) {
|
|
1892
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1893
|
-
result = bevelColor;
|
|
1894
|
-
} else {
|
|
1895
|
-
result = base - base * bevelColor.a + bevelColor;
|
|
1896
|
-
}
|
|
1897
|
-
} else if (BEVEL_TYPE == 1u) {
|
|
1898
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1899
|
-
result = bevelColor * base.a;
|
|
1900
|
-
} else {
|
|
1901
|
-
result = bevelColor * base.a + base * (1.0 - bevelColor.a);
|
|
1902
|
-
}
|
|
1903
|
-
} else {
|
|
1904
|
-
if (IS_KNOCKOUT == 1u) {
|
|
1905
|
-
result = bevelColor - bevelColor * base.a;
|
|
1906
|
-
} else {
|
|
1907
|
-
result = base + bevelColor - bevelColor * base.a;
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
return result;
|
|
1912
|
-
}
|
|
1913
|
-
\`,Kp=\`
|
|
1914
|
-
\${Be}
|
|
1915
|
-
|
|
1916
|
-
struct BevelBaseUniforms {
|
|
1917
|
-
offset: vec2<f32>,
|
|
1918
|
-
_padding: vec2<f32>,
|
|
1919
|
-
}
|
|
1920
|
-
|
|
1921
|
-
@group(0) @binding(0) var<uniform> uniforms: BevelBaseUniforms;
|
|
1922
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1923
|
-
@group(0) @binding(2) var sourceTexture: texture_2d<f32>;
|
|
1924
|
-
\${Nt}
|
|
1925
|
-
|
|
1926
|
-
@fragment
|
|
1927
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1928
|
-
let original = textureSampleLevel(sourceTexture, textureSampler, input.texCoord, 0);
|
|
1929
|
-
let shiftedUV = input.texCoord - uniforms.offset;
|
|
1930
|
-
let shifted = textureSampleLevel(sourceTexture, textureSampler, shiftedUV, 0) * isInside(shiftedUV);
|
|
1931
|
-
return original * (1.0 - shifted.a);
|
|
1932
|
-
}
|
|
1933
|
-
\`;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\`
|
|
1934
|
-
\${Be}
|
|
1935
|
-
|
|
1936
|
-
struct BlurUniforms {
|
|
1937
|
-
offset: vec2<f32>,
|
|
1938
|
-
fraction: f32,
|
|
1939
|
-
samples: f32,
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
@group(0) @binding(0) var<uniform> uniforms: BlurUniforms;
|
|
1943
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
1944
|
-
@group(0) @binding(2) var inputTexture: texture_2d<f32>;
|
|
1945
|
-
|
|
1946
|
-
@fragment
|
|
1947
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
1948
|
-
let offset = uniforms.offset;
|
|
1949
|
-
let fraction = uniforms.fraction;
|
|
1950
|
-
let samples = uniforms.samples;
|
|
1951
|
-
var color = textureSample(inputTexture, textureSampler, input.texCoord);
|
|
1952
|
-
for (var i: f32 = 1.0; i < \${r}; i += 1.0) {
|
|
1953
|
-
color += textureSample(inputTexture, textureSampler, input.texCoord + offset * i);
|
|
1954
|
-
color += textureSample(inputTexture, textureSampler, input.texCoord - offset * i);
|
|
1955
|
-
}
|
|
1956
|
-
color += textureSample(inputTexture, textureSampler, input.texCoord + offset * \${r}) * fraction;
|
|
1957
|
-
color += textureSample(inputTexture, textureSampler, input.texCoord - offset * \${r}) * fraction;
|
|
1958
|
-
color /= samples;
|
|
1959
|
-
return color;
|
|
1960
|
-
}
|
|
1961
|
-
\`}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<l;h++)c+=\`
|
|
1962
|
-
result = result + getWeightedColor(\${h}, getMatrixWeight(\${h}));\`;const u=n?"result.a = textureSample(sourceTexture, sourceSampler, input.texCoord).a;":"",a=s?"":\`
|
|
1963
|
-
let substituteColor = uniforms.substituteColor;
|
|
1964
|
-
color = mix(substituteColor, color, isInside(uv));\`;return\`
|
|
1965
|
-
struct ConvolutionUniforms {
|
|
1966
|
-
rcpSize: vec2<f32>,
|
|
1967
|
-
rcpDivisor: f32,
|
|
1968
|
-
bias: f32,
|
|
1969
|
-
substituteColor: vec4<f32>,
|
|
1970
|
-
matrix: array<vec4<f32>, \${Math.ceil(l/4)}>,
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
@group(0) @binding(0) var<uniform> uniforms: ConvolutionUniforms;
|
|
1974
|
-
@group(0) @binding(1) var sourceSampler: sampler;
|
|
1975
|
-
@group(0) @binding(2) var sourceTexture: texture_2d<f32>;
|
|
1976
|
-
|
|
1977
|
-
\${Be}
|
|
1978
|
-
|
|
1979
|
-
\${Nt}
|
|
1980
|
-
|
|
1981
|
-
fn getMatrixWeight(index: i32) -> f32 {
|
|
1982
|
-
let vecIndex = index / 4;
|
|
1983
|
-
let component = index % 4;
|
|
1984
|
-
let vec = uniforms.matrix[vecIndex];
|
|
1985
|
-
if (component == 0) { return vec.x; }
|
|
1986
|
-
else if (component == 1) { return vec.y; }
|
|
1987
|
-
else if (component == 2) { return vec.z; }
|
|
1988
|
-
else { return vec.w; }
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
fn getWeightedColor(i: i32, weight: f32) -> vec4<f32> {
|
|
1992
|
-
let rcpSize = uniforms.rcpSize;
|
|
1993
|
-
let iDivX = i / \${e};
|
|
1994
|
-
let iModX = i - \${e} * iDivX;
|
|
1995
|
-
let offset = vec2<f32>(f32(iModX - \${o}), f32(\${i} - iDivX));
|
|
1996
|
-
var uv = input.texCoord + offset * rcpSize;
|
|
1997
|
-
var color = textureSample(sourceTexture, sourceSampler, uv);
|
|
1998
|
-
color = vec4<f32>(color.rgb / max(0.0001, color.a), color.a);
|
|
1999
|
-
\${a}
|
|
2000
|
-
return color * weight;
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
var<private> input: VertexOutput;
|
|
2004
|
-
|
|
2005
|
-
@vertex
|
|
2006
|
-
fn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
|
|
2007
|
-
var positions = array<vec2<f32>, 6>(
|
|
2008
|
-
vec2<f32>(-1.0, -1.0),
|
|
2009
|
-
vec2<f32>(1.0, -1.0),
|
|
2010
|
-
vec2<f32>(-1.0, 1.0),
|
|
2011
|
-
vec2<f32>(-1.0, 1.0),
|
|
2012
|
-
vec2<f32>(1.0, -1.0),
|
|
2013
|
-
vec2<f32>(1.0, 1.0)
|
|
2014
|
-
);
|
|
2015
|
-
var texCoords = array<vec2<f32>, 6>(
|
|
2016
|
-
vec2<f32>(0.0, 1.0),
|
|
2017
|
-
vec2<f32>(1.0, 1.0),
|
|
2018
|
-
vec2<f32>(0.0, 0.0),
|
|
2019
|
-
vec2<f32>(0.0, 0.0),
|
|
2020
|
-
vec2<f32>(1.0, 1.0),
|
|
2021
|
-
vec2<f32>(1.0, 0.0)
|
|
2022
|
-
);
|
|
2023
|
-
var output: VertexOutput;
|
|
2024
|
-
output.position = vec4<f32>(positions[vertexIndex], 0.0, 1.0);
|
|
2025
|
-
output.texCoord = texCoords[vertexIndex];
|
|
2026
|
-
return output;
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
@fragment
|
|
2030
|
-
fn fs_main(fragInput: VertexOutput) -> @location(0) vec4<f32> {
|
|
2031
|
-
input = fragInput;
|
|
2032
|
-
let rcpDivisor = uniforms.rcpDivisor;
|
|
2033
|
-
let bias = uniforms.bias;
|
|
2034
|
-
var result = vec4<f32>(0.0);
|
|
2035
|
-
\${c}
|
|
2036
|
-
result = clamp(result * rcpDivisor + bias, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
2037
|
-
\${u}
|
|
2038
|
-
result = vec4<f32>(result.rgb * result.a, result.a);
|
|
2039
|
-
return result;
|
|
2040
|
-
}
|
|
2041
|
-
\`}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\`
|
|
2042
|
-
\${Be}
|
|
2043
|
-
|
|
2044
|
-
struct BlendUniforms {
|
|
2045
|
-
mulColor: vec4<f32>,
|
|
2046
|
-
addColor: vec4<f32>,
|
|
2047
|
-
blendMode: f32,
|
|
2048
|
-
_pad0: f32,
|
|
2049
|
-
_pad1: f32,
|
|
2050
|
-
_pad2: f32,
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
@group(0) @binding(0) var<uniform> uniforms: BlendUniforms;
|
|
2054
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
2055
|
-
@group(0) @binding(2) var dstTexture: texture_2d<f32>;
|
|
2056
|
-
@group(0) @binding(3) var srcTexture: texture_2d<f32>;
|
|
2057
|
-
|
|
2058
|
-
fn blend(src: vec4<f32>, dst: vec4<f32>, mode: i32) -> vec4<f32> {
|
|
2059
|
-
if (src.a == 0.0) { return dst; }
|
|
2060
|
-
if (dst.a == 0.0) { return src; }
|
|
2061
|
-
|
|
2062
|
-
let a = src - src * dst.a;
|
|
2063
|
-
let b = dst - dst * src.a;
|
|
2064
|
-
|
|
2065
|
-
if (mode == 1) {
|
|
2066
|
-
let c = src * dst;
|
|
2067
|
-
return a + b + c;
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
|
-
let srcRgb = src.rgb / src.a;
|
|
2071
|
-
let dstRgb = dst.rgb / dst.a;
|
|
2072
|
-
|
|
2073
|
-
var blended: vec3<f32>;
|
|
2074
|
-
|
|
2075
|
-
switch (mode) {
|
|
2076
|
-
case 0: {
|
|
2077
|
-
blended = dstRgb - srcRgb;
|
|
2078
|
-
}
|
|
2079
|
-
case 2: {
|
|
2080
|
-
blended = mix(srcRgb, dstRgb, step(srcRgb, dstRgb));
|
|
2081
|
-
}
|
|
2082
|
-
case 3: {
|
|
2083
|
-
blended = mix(srcRgb, dstRgb, step(dstRgb, srcRgb));
|
|
2084
|
-
}
|
|
2085
|
-
case 4: {
|
|
2086
|
-
let mul = srcRgb * dstRgb;
|
|
2087
|
-
let c1 = 2.0 * mul;
|
|
2088
|
-
let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0;
|
|
2089
|
-
blended = mix(c1, c2, step(vec3<f32>(0.5), dstRgb));
|
|
2090
|
-
}
|
|
2091
|
-
case 5: {
|
|
2092
|
-
let mul = srcRgb * dstRgb;
|
|
2093
|
-
let c1 = 2.0 * mul;
|
|
2094
|
-
let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0;
|
|
2095
|
-
blended = mix(c1, c2, step(vec3<f32>(0.5), srcRgb));
|
|
2096
|
-
}
|
|
2097
|
-
case 6: {
|
|
2098
|
-
blended = abs(srcRgb - dstRgb);
|
|
2099
|
-
}
|
|
2100
|
-
case 7: {
|
|
2101
|
-
let ib = dst - dst * src.a;
|
|
2102
|
-
let ic = vec4<f32>(src.a - dst.rgb * src.a, src.a);
|
|
2103
|
-
return ib + ic;
|
|
2104
|
-
}
|
|
2105
|
-
default: {
|
|
2106
|
-
blended = srcRgb;
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
|
|
2110
|
-
var c = vec4<f32>(blended, src.a * dst.a);
|
|
2111
|
-
c = vec4<f32>(c.rgb * c.a, c.a);
|
|
2112
|
-
return a + b + c;
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
@fragment
|
|
2116
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
2117
|
-
var dst = textureSample(dstTexture, textureSampler, input.texCoord);
|
|
2118
|
-
var src = textureSample(srcTexture, textureSampler, input.texCoord);
|
|
2119
|
-
let mul = uniforms.mulColor;
|
|
2120
|
-
let add = uniforms.addColor;
|
|
2121
|
-
if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0
|
|
2122
|
-
|| add.x != 0.0 || add.y != 0.0 || add.z != 0.0) {
|
|
2123
|
-
src = vec4<f32>(src.rgb / max(vec3<f32>(0.0001), vec3<f32>(src.a)), src.a);
|
|
2124
|
-
src = clamp(src * mul + add, vec4<f32>(0.0), vec4<f32>(1.0));
|
|
2125
|
-
src = vec4<f32>(src.rgb * src.a, src.a);
|
|
2126
|
-
}
|
|
2127
|
-
return blend(src, dst, i32(uniforms.blendMode));
|
|
2128
|
-
}
|
|
2129
|
-
\`}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=\`
|
|
2130
|
-
sourceColor = textureSample(srcTexture, textureSampler, uv);
|
|
2131
|
-
\`;break;case 1:l=!0,i=\`
|
|
2132
|
-
sourceColor = mix(uniforms.substituteColor, textureSample(srcTexture, textureSampler, uv), isInside(uv));
|
|
2133
|
-
\`;break;case 2:i=\`
|
|
2134
|
-
sourceColor = textureSample(srcTexture, textureSampler, fract(uv));
|
|
2135
|
-
\`;break;case 3:i=\`
|
|
2136
|
-
let insideUV = step(abs(uv - vec2<f32>(0.5)), vec2<f32>(0.5));
|
|
2137
|
-
sourceColor = textureSample(srcTexture, textureSampler, mix(input.texCoord, uv, insideUV));
|
|
2138
|
-
\`;break;default:i=\`
|
|
2139
|
-
sourceColor = textureSample(srcTexture, textureSampler, fract(uv));
|
|
2140
|
-
\`;break}return\`
|
|
2141
|
-
\${Be}
|
|
2142
|
-
|
|
2143
|
-
\${l?\`struct DisplacementUniforms {
|
|
2144
|
-
uvToStScale: vec2<f32>,
|
|
2145
|
-
uvToStOffset: vec2<f32>,
|
|
2146
|
-
scale: vec2<f32>,
|
|
2147
|
-
padding: vec2<f32>,
|
|
2148
|
-
substituteColor: vec4<f32>,
|
|
2149
|
-
}\`:\`struct DisplacementUniforms {
|
|
2150
|
-
uvToStScale: vec2<f32>,
|
|
2151
|
-
uvToStOffset: vec2<f32>,
|
|
2152
|
-
scale: vec2<f32>,
|
|
2153
|
-
padding: vec2<f32>,
|
|
2154
|
-
}\`}
|
|
2155
|
-
|
|
2156
|
-
@group(0) @binding(0) var<uniform> uniforms: DisplacementUniforms;
|
|
2157
|
-
@group(0) @binding(1) var textureSampler: sampler;
|
|
2158
|
-
@group(0) @binding(2) var srcTexture: texture_2d<f32>;
|
|
2159
|
-
@group(0) @binding(3) var mapTexture: texture_2d<f32>;
|
|
2160
|
-
|
|
2161
|
-
\${Nt}
|
|
2162
|
-
|
|
2163
|
-
@fragment
|
|
2164
|
-
fn main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
2165
|
-
let stCoord = vec2<f32>(input.texCoord.x, 1.0 - input.texCoord.y);
|
|
2166
|
-
let st = stCoord * uniforms.uvToStScale - uniforms.uvToStOffset;
|
|
2167
|
-
let mapColor = textureSample(mapTexture, textureSampler, vec2<f32>(st.x, 1.0 - st.y));
|
|
2168
|
-
let offset = vec2<f32>(\${s}, \${o}) - 0.5;
|
|
2169
|
-
let uv = input.texCoord + offset * uniforms.scale;
|
|
2170
|
-
var sourceColor: vec4<f32>;
|
|
2171
|
-
\${i}
|
|
2172
|
-
return mix(textureSample(srcTexture, textureSampler, input.texCoord), sourceColor, isInside(st));
|
|
2173
|
-
}
|
|
2174
|
-
\`}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<<l-1,u=this.device.createRenderPipeline({layout:n,vertex:{module:o,entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:i,entryPoint:"main",targets:[{format:this.format,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:c},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set(\`clip_write_main_\${l}\`,u)}this.pipelines.set("clip_write_main",this.pipelines.get("clip_write_main_1"));for(let l=1;l<=8;l++){const c=1<<l-1,u=this.device.createRenderPipeline({layout:n,vertex:{module:o,entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:i,entryPoint:"main",targets:[{format:this.format,writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"replace",depthFailOp:"replace",passOp:"replace"},stencilBack:{compare:"always",failOp:"replace",depthFailOp:"replace",passOp:"replace"},stencilReadMask:255,stencilWriteMask:c},multisample:{count:this.sampleCount}});this.pipelines.set(\`clip_clear_main_\${l}\`,u)}}createMaskUnionPipelines(){const e=rr,r=this.bindGroupLayouts.get("fill_dynamic"),n=this.device.createPipelineLayout({bindGroupLayouts:[r]}),s=this.getOrCreateShaderModule("stencilWriteVertex",N.getStencilWriteVertexShader()),o=this.getOrCreateShaderModule("stencilWriteFragment",N.getStencilWriteFragmentShader());for(let i=1;i<=8;i++){const c=~(1<<i-1)&255,u=this.device.createRenderPipeline({layout:n,vertex:{module:s,entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:o,entryPoint:"main",targets:[{format:this.format,writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"less-equal",failOp:"zero",depthFailOp:"replace",passOp:"replace"},stencilBack:{compare:"less-equal",failOp:"zero",depthFailOp:"replace",passOp:"replace"},stencilReadMask:255,stencilWriteMask:c}});this.pipelines.set(\`mask_union_merge_\${i}\`,u);const a=this.device.createRenderPipeline({layout:n,vertex:{module:s,entryPoint:"main",buffers:[e],constants:{yFlipSign:-1}},fragment:{module:o,entryPoint:"main",targets:[{format:this.format,writeMask:0}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:{format:"stencil8",stencilFront:{compare:"always",failOp:"replace",depthFailOp:"replace",passOp:"replace"},stencilBack:{compare:"always",failOp:"replace",depthFailOp:"replace",passOp:"replace"},stencilReadMask:255,stencilWriteMask:1<<i}});this.pipelines.set(\`mask_union_clear_\${i}\`,a)}}createMaskPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}}]});this.bindGroupLayouts.set("mask",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("maskVertex",N.getMaskVertexShader()),s=this.getOrCreateShaderModule("maskFragment",N.getMaskFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]}]},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("mask",o)}createBasicPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]});this.bindGroupLayouts.set("basic",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("basicVertex",N.getBasicVertexShader()),s=this.getOrCreateShaderModule("basicFragment",N.getBasicFragmentShader()),o={arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},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"},multisample:{count:this.sampleCount}}),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"}});this.pipelines.set("basic",l),this.pipelines.set("basic_bgra",c)}createTexturePipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("texture",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("basicVertex",N.getBasicVertexShader()),s=this.getOrCreateShaderModule("textureFragment",N.getTextureFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]}]},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("texture",o)}createInstancedPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("instanced",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("instancedVertex",N.getInstancedVertexShader()),s=this.getOrCreateShaderModule("instancedFragment",N.getInstancedFragmentShader()),o={arrayStride:96,stepMode:"instance",attributes:[{shaderLocation:2,offset:0,format:"float32x4"},{shaderLocation:3,offset:16,format:"float32x4"},{shaderLocation:4,offset:32,format:"float32x4"},{shaderLocation:5,offset:48,format:"float32x4"},{shaderLocation:6,offset:64,format:"float32x4"},{shaderLocation:7,offset:80,format:"float32x4"}]},i=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:16,stepMode:"vertex",attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},o]},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"},multisample:{count:this.sampleCount}});this.pipelines.set("instanced",i);const l=[{arrayStride:16,stepMode:"vertex",attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},o],c=[["instanced_add",{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}],["instanced_screen",{color:{srcFactor:"one-minus-dst",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}],["instanced_alpha",{color:{srcFactor:"zero",dstFactor:"src-alpha",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"src-alpha",operation:"add"}}],["instanced_erase",{color:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"}}],["instanced_copy",{color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}}]];for(const[a,h]of c){const d=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:l},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:h}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:this.sampleCount}});this.pipelines.set(a,d)}const u=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:16,stepMode:"vertex",attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]},o]},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"},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}});this.pipelines.set("instanced_masked",u)}createGradientPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("gradient_fill",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]});this.gradientPipelineLayout=r;const n=this.getOrCreateShaderModule("gradientFillVertex",N.getGradientFillVertexShader());this.gradientVertexShaderModule=n;const s=this.getOrCreateShaderModule("gradientFillFragment",N.getGradientFillFragmentShader());this.gradientFragmentShaderModule=s;const o=this.getOrCreateShaderModule("gradientFillStencilFragment",N.getGradientFillStencilFragmentShader());this.gradientStencilFragmentShaderModule=o;const i=rr,l=un,c=this.device.createRenderPipeline({label:"gradient_fill_no_stencil_pipeline",layout:r,vertex:{module:n,entryPoint:"main",buffers:[i]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:l}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:this.sampleCount}}),u=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:l}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:this.sampleCount}});this.pipelines.set("gradient_fill",c),this.pipelines.set("gradient_fill_no_stencil",c),this.pipelines.set("gradient_fill_bgra",u);const a={format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0},h=this.device.createRenderPipeline({label:"gradient_stroke_atlas_pipeline",layout:r,vertex:{module:n,entryPoint:"main",buffers:[i]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:l}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:a,multisample:{count:this.sampleCount}});this.pipelines.set("gradient_stroke_atlas",h);const d=this.device.createRenderPipeline({label:"gradient_stroke_bgra_pipeline",layout:r,vertex:{module:n,entryPoint:"main",buffers:[i],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:l}]},primitive:{topology:"triangle-list",cullMode:"none"},depthStencil:a,multisample:{count:this.sampleCount}});this.pipelines.set("gradient_stroke_bgra",d);const m=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:l}]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:1}});this.pipelines.set("gradient_fill_bgra_no_msaa",m);const g=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i]},fragment:{module:s,entryPoint:"main",targets:[{format:"rgba8unorm",blend:l}]},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("gradient_fill_stencil",g);const f=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i]},fragment:{module:o,entryPoint:"main",targets:[{format:"rgba8unorm",blend:l}]},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("gradient_fill_stencil_atlas",f);const b=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i],constants:{yFlipSign:-1}},fragment:{module:o,entryPoint:"main",targets:[{format:this.format,blend:l}]},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:1}});this.pipelines.set("gradient_fill_stencil_main",b);const x=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[i],constants:{yFlipSign:-1}},fragment:{module:s,entryPoint:"main",targets:[{format:this.format,blend:l}]},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}});this.pipelines.set("gradient_fill_bgra_stencil",x)}createBitmapFillPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("bitmap_fill",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("bitmapFillVertex",N.getBitmapFillVertexShader()),s=this.getOrCreateShaderModule("bitmapFillFragment",N.getBitmapFillFragmentShader()),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"},multisample:{count:this.sampleCount}}),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"}});this.pipelines.set("bitmap_fill",l),this.pipelines.set("bitmap_fill_bgra",c);const u={format:"stencil8",stencilFront:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilBack:{compare:"always",failOp:"keep",depthFailOp:"keep",passOp:"keep"},stencilReadMask:0,stencilWriteMask:0},a=this.device.createRenderPipeline({label:"bitmap_stroke_atlas_pipeline",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:u,multisample:{count:this.sampleCount}});this.pipelines.set("bitmap_stroke_atlas",a);const h=this.device.createRenderPipeline({label:"bitmap_stroke_bgra_pipeline",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:u,multisample:{count:this.sampleCount}});this.pipelines.set("bitmap_stroke_bgra",h);const d=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:"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("bitmap_fill_stencil",d);const m=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}});this.pipelines.set("bitmap_fill_bgra_stencil",m)}createBlendPipeline(){const e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:4,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:5,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set("blend",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("basicVertex",N.getBasicVertexShader()),s=this.getOrCreateShaderModule("blendFragment",N.getBlendFragmentShader()),o=this.device.createRenderPipeline({layout:r,vertex:{module:n,entryPoint:"main",buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:"float32x2"},{shaderLocation:1,offset:8,format:"float32x2"}]}]},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("blend",o)}createBlurFilterPipeline(){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:{}}]});this.bindGroupLayouts.set("blur_filter",e);const r=this.getOrCreateShaderModule("blurFilterVertex",N.getBlurFilterVertexShader()),n=this.device.createPipelineLayout({bindGroupLayouts:[e]});for(let s=1;s<=16;s++){const o=this.getOrCreateShaderModule(\`blurFilterFragment_\${s}\`,N.getBlurFilterFragmentShader(s)),i=this.device.createRenderPipeline({layout:n,vertex:{module:r,entryPoint:"main",buffers:[]},fragment:{module:o,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(\`blur_filter_\${s}\`,i)}}createTextureCopyPipeline(){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:{}}]});this.bindGroupLayouts.set("texture_copy",e);const r=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule("blurFilterVertex",N.getBlurFilterVertexShader()),s=this.getOrCreateShaderModule("textureCopyFragment",N.getTextureCopyFragmentShader()),o={color:{srcFactor:"one",dstFactor:"zero",operation:"add"},alpha:{srcFactor:"one",dstFactor:"zero",operation:"add"}},i={color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},l={color:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"}};this.pipelines.set("texture_copy",this.createFullscreenQuadPipeline(r,n,s,this.format,o)),this.pipelines.set("texture_copy_rgba8",this.createFullscreenQuadPipeline(r,n,s,"rgba8unorm",o));const c=this.getOrCreateShaderModule("colorTransformFragment",N.getColorTransformFragmentShader());this.pipelines.set("color_transform",this.createFullscreenQuadPipeline(r,n,c,"rgba8unorm",o));const u=this.getOrCreateShaderModule("yFlipColorTransformFragment",N.getYFlipColorTransformFragmentShader());this.pipelines.set("y_flip_color_transform",this.createFullscreenQuadPipeline(r,n,u,"rgba8unorm",o));const a=this.getOrCreateShaderModule("blurTextureCopyFragment",N.getBlurTextureCopyFragmentShader());this.pipelines.set("texture_erase",this.createFullscreenQuadPipeline(r,n,a,"rgba8unorm",l)),this.pipelines.set("blur_texture_copy",this.createFullscreenQuadPipeline(r,n,a,"rgba8unorm",o)),this.pipelines.set("filter_blend",this.createFullscreenQuadPipeline(r,n,s,this.format,i)),this.pipelines.set("texture_copy_bgra",this.createFullscreenQuadPipeline(r,n,s,this.format,o));const h=this.getOrCreateShaderModule("filterOutputFragment",N.getFilterOutputFragmentShader());this.pipelines.set("filter_output",this.createFullscreenQuadPipeline(r,n,h,this.format,i));const d=[["filter_output_add",{color:{srcFactor:"one",dstFactor:"one",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one",operation:"add"}}],["filter_output_screen",{color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"},alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}}],["filter_output_alpha",{color:{srcFactor:"zero",dstFactor:"src-alpha",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"src-alpha",operation:"add"}}],["filter_output_erase",{color:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"}}]];for(const[m,g]of d)this.pipelines.set(m,this.createFullscreenQuadPipeline(r,n,h,this.format,g));if(this.sampleCount>1){const m={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,m,this.sampleCount));const g={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,g,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;a<n;a++)u.push({binding:2+a,visibility:GPUShaderStage.FRAGMENT,texture:{}});o=this.device.createBindGroupLayout({entries:u}),this.filterBindGroupLayouts.set(n,o)}this.bindGroupLayouts.set(e,o);const i=this.device.createPipelineLayout({bindGroupLayouts:[o]}),l=this.getOrCreateShaderModule("blurFilterVertex",N.getBlurFilterVertexShader()),c=this.getOrCreateShaderModule(\`filter_\${e}\`,r);this.pipelines.set(e,this.createFullscreenQuadPipeline(i,l,c,"rgba8unorm",s))}createFullscreenQuadPipeline(e,r,n,s,o,i,l){const c={layout:e,vertex:{module:r,entryPoint:"main",buffers:[]},fragment:{module:n,entryPoint:"main",targets:[{format:s,blend:o}]},primitive:{topology:"triangle-list",cullMode:"none"}};return i&&i>1&&(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 m,g=this.sampleCount;e.includes("stroke")?m={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"?m={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"?(m={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},g=1):e==="gradient_fill_bgra_stencil"?m={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"&&(g=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:g}};return m&&(f.depthStencil=m),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\`
|
|
2175
|
-
struct BlurParams {
|
|
2176
|
-
direction: vec2<f32>, // (1,0) or (0,1)
|
|
2177
|
-
radius: f32, // ブラー半径
|
|
2178
|
-
fraction: f32, // 端ピクセルのブレンド割合
|
|
2179
|
-
texSize: vec2<f32>, // テクスチャサイズ
|
|
2180
|
-
samples: f32, // サンプル数
|
|
2181
|
-
padding: f32, // パディング(16バイトアライメント)
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
2185
|
-
@group(0) @binding(1) var outputTexture: texture_storage_2d<rgba8unorm, write>;
|
|
2186
|
-
@group(0) @binding(2) var<uniform> params: BlurParams;
|
|
2187
|
-
|
|
2188
|
-
const WORKGROUP_SIZE: u32 = 16u;
|
|
2189
|
-
|
|
2190
|
-
@compute @workgroup_size(16, 16, 1)
|
|
2191
|
-
fn main(
|
|
2192
|
-
@builtin(global_invocation_id) globalId: vec3<u32>
|
|
2193
|
-
) {
|
|
2194
|
-
let texSize = vec2<u32>(u32(params.texSize.x), u32(params.texSize.y));
|
|
2195
|
-
let radius = i32(params.radius);
|
|
2196
|
-
|
|
2197
|
-
let outCoord = globalId.xy;
|
|
2198
|
-
|
|
2199
|
-
if (outCoord.x >= texSize.x || outCoord.y >= texSize.y) {
|
|
2200
|
-
return;
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
let direction = vec2<i32>(i32(params.direction.x), i32(params.direction.y));
|
|
2204
|
-
let samples = params.samples;
|
|
2205
|
-
let fraction = params.fraction;
|
|
2206
|
-
|
|
2207
|
-
var color = vec4<f32>(0.0);
|
|
2208
|
-
|
|
2209
|
-
for (var i = -radius; i <= radius; i = i + 1) {
|
|
2210
|
-
var sampleCoord = vec2<i32>(outCoord) + direction * i;
|
|
2211
|
-
|
|
2212
|
-
sampleCoord.x = clamp(sampleCoord.x, 0, i32(texSize.x) - 1);
|
|
2213
|
-
sampleCoord.y = clamp(sampleCoord.y, 0, i32(texSize.y) - 1);
|
|
2214
|
-
|
|
2215
|
-
let sample = textureLoad(inputTexture, vec2<u32>(sampleCoord), 0);
|
|
2216
|
-
|
|
2217
|
-
// 端ピクセルにfraction重みを適用(Fragment Shaderと同じロジック)
|
|
2218
|
-
if (i == -radius || i == radius) {
|
|
2219
|
-
color = color + sample * fraction;
|
|
2220
|
-
} else {
|
|
2221
|
-
color = color + sample;
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
|
|
2225
|
-
color = color / samples;
|
|
2226
|
-
|
|
2227
|
-
textureStore(outputTexture, outCoord, color);
|
|
2228
|
-
}
|
|
2229
|
-
\`}getSharedBlurComputeShaderCode(){return\`
|
|
2230
|
-
struct BlurParams {
|
|
2231
|
-
direction: vec2<f32>,
|
|
2232
|
-
radius: f32,
|
|
2233
|
-
fraction: f32,
|
|
2234
|
-
texSize: vec2<f32>,
|
|
2235
|
-
samples: f32,
|
|
2236
|
-
padding: f32,
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
|
|
2240
|
-
@group(0) @binding(1) var outputTexture: texture_storage_2d<rgba8unorm, write>;
|
|
2241
|
-
@group(0) @binding(2) var<uniform> params: BlurParams;
|
|
2242
|
-
|
|
2243
|
-
const TILE: u32 = 16u;
|
|
2244
|
-
const MAX_APRON: u32 = 24u;
|
|
2245
|
-
const SHARED_W: u32 = TILE + 2u * MAX_APRON;
|
|
2246
|
-
|
|
2247
|
-
var<workgroup> tile: array<vec4<f32>, 1024>;
|
|
2248
|
-
|
|
2249
|
-
@compute @workgroup_size(16, 16, 1)
|
|
2250
|
-
fn main(
|
|
2251
|
-
@builtin(global_invocation_id) globalId: vec3<u32>,
|
|
2252
|
-
@builtin(local_invocation_id) localId: vec3<u32>,
|
|
2253
|
-
@builtin(workgroup_id) workgroupId: vec3<u32>
|
|
2254
|
-
) {
|
|
2255
|
-
let texSize = vec2<u32>(u32(params.texSize.x), u32(params.texSize.y));
|
|
2256
|
-
let radius = u32(params.radius);
|
|
2257
|
-
let apron = min(radius, MAX_APRON);
|
|
2258
|
-
let isHorizontal = params.direction.x > 0.5;
|
|
2259
|
-
let fraction = params.fraction;
|
|
2260
|
-
let samples = params.samples;
|
|
2261
|
-
|
|
2262
|
-
let threadIdx = localId.x + localId.y * TILE;
|
|
2263
|
-
let totalThreads = TILE * TILE;
|
|
2264
|
-
|
|
2265
|
-
if (isHorizontal) {
|
|
2266
|
-
let sharedWidth = TILE + 2u * apron;
|
|
2267
|
-
let baseX = workgroupId.x * TILE;
|
|
2268
|
-
let y = globalId.y;
|
|
2269
|
-
let clampedY = clamp(y, 0u, max(texSize.y, 1u) - 1u);
|
|
2270
|
-
|
|
2271
|
-
// 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード)
|
|
2272
|
-
var idx = threadIdx;
|
|
2273
|
-
loop {
|
|
2274
|
-
if (idx >= sharedWidth) { break; }
|
|
2275
|
-
let gx = i32(baseX) + i32(idx) - i32(apron);
|
|
2276
|
-
let cx = u32(clamp(gx, 0, i32(max(texSize.x, 1u)) - 1));
|
|
2277
|
-
tile[localId.y * SHARED_W + idx] = textureLoad(inputTexture, vec2<u32>(cx, clampedY), 0);
|
|
2278
|
-
idx += totalThreads;
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
// 全スレッドがバリアに到達(早期returnなし)
|
|
2282
|
-
workgroupBarrier();
|
|
2283
|
-
|
|
2284
|
-
// 範囲内のスレッドのみ出力
|
|
2285
|
-
let outX = globalId.x;
|
|
2286
|
-
if (outX < texSize.x && y < texSize.y) {
|
|
2287
|
-
let iRadius = i32(radius);
|
|
2288
|
-
var color = vec4<f32>(0.0);
|
|
2289
|
-
for (var i = -iRadius; i <= iRadius; i = i + 1) {
|
|
2290
|
-
let tileIdx = i32(localId.x) + i32(apron) + i;
|
|
2291
|
-
let s = tile[localId.y * SHARED_W + u32(clamp(tileIdx, 0, i32(sharedWidth) - 1))];
|
|
2292
|
-
if (i == -iRadius || i == iRadius) {
|
|
2293
|
-
color += s * fraction;
|
|
2294
|
-
} else {
|
|
2295
|
-
color += s;
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
textureStore(outputTexture, vec2<u32>(outX, y), color / samples);
|
|
2299
|
-
}
|
|
2300
|
-
} else {
|
|
2301
|
-
let sharedHeight = TILE + 2u * apron;
|
|
2302
|
-
let baseY = workgroupId.y * TILE;
|
|
2303
|
-
let x = globalId.x;
|
|
2304
|
-
let clampedX = clamp(x, 0u, max(texSize.x, 1u) - 1u);
|
|
2305
|
-
|
|
2306
|
-
// 全スレッドが協調ロード(範囲外スレッドもclampされた座標でロード)
|
|
2307
|
-
var idx = threadIdx;
|
|
2308
|
-
loop {
|
|
2309
|
-
if (idx >= sharedHeight) { break; }
|
|
2310
|
-
let gy = i32(baseY) + i32(idx) - i32(apron);
|
|
2311
|
-
let cy = u32(clamp(gy, 0, i32(max(texSize.y, 1u)) - 1));
|
|
2312
|
-
tile[idx * TILE + localId.x] = textureLoad(inputTexture, vec2<u32>(clampedX, cy), 0);
|
|
2313
|
-
idx += totalThreads;
|
|
2314
|
-
}
|
|
2315
|
-
|
|
2316
|
-
// 全スレッドがバリアに到達(早期returnなし)
|
|
2317
|
-
workgroupBarrier();
|
|
2318
|
-
|
|
2319
|
-
// 範囲内のスレッドのみ出力
|
|
2320
|
-
let outY = globalId.y;
|
|
2321
|
-
if (x < texSize.x && outY < texSize.y) {
|
|
2322
|
-
let iRadius = i32(radius);
|
|
2323
|
-
var color = vec4<f32>(0.0);
|
|
2324
|
-
for (var i = -iRadius; i <= iRadius; i = i + 1) {
|
|
2325
|
-
let tileIdx = i32(localId.y) + i32(apron) + i;
|
|
2326
|
-
let s = tile[u32(clamp(tileIdx, 0, i32(sharedHeight) - 1)) * TILE + localId.x];
|
|
2327
|
-
if (i == -iRadius || i == iRadius) {
|
|
2328
|
-
color += s * fraction;
|
|
2329
|
-
} else {
|
|
2330
|
-
color += s;
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
textureStore(outputTexture, vec2<u32>(x, outY), color / samples);
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
\`}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},We=()=>{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<Na.length;++t){const e=Na[t];e&&(e[0]=e[1]=Va,e[2]=e[3]=Da)}for(let t=0;t<za.length;++t){const e=za[t];e&&(e[0]=e[1]=Va,e[2]=e[3]=Da)}};let Xa=0;const xo=t=>{Xa=t},yo=()=>Xa,rm=()=>{fn.length=0,wr(0);for(let t=0;t<zt.length;t++){const e=zt[t];e&&(e.texture&&e.texture.resource.destroy(),e.stencil&&e.stencil.resource.destroy(),e.msaaTexture&&e.msaaTexture.resource.destroy(),e.msaaStencil&&e.msaaStencil.resource.destroy())}zt.length=0,tm(),xo(0)};class nm{count;constructor(){this.count=0}clear(){this.count=Ve.offset=0}}let ts="normal";const Ya=t=>{ts=t},sm=new Set(["normal","layer","add","screen","alpha","erase","copy"]),hn=[],vo=[],Mo=[],om=()=>hn,So=()=>{for(let t=0;t<hn.length;t++){const e=hn[t];vo.push(e.color_transform),Mo.push(e.matrix)}hn.length=0},$o=new Map,rs=()=>{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],m=o[1],g=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,m,g,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<<t.clipLevel)-1;Wa(!0),ja(r&255),Bo(!1)},um=()=>{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<n;s+=3){let o=r*4;t[s+2]?(e[o++]=t[s-3],e[o++]=t[s-2],e[o++]=0,e[o++]=0,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=0,e[o++]=t[s+3],e[o++]=t[s+4],e[o++]=1,e[o++]=1):t[s+5]?(e[o++]=t[0],e[o++]=t[1],e[o++]=.5,e[o++]=.5,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=.5,e[o++]=t[s+6],e[o++]=t[s+7],e[o++]=.5,e[o++]=.5):(e[o++]=t[0],e[o++]=t[1],e[o++]=.5,e[o++]=.5,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=.5,e[o++]=t[s+3],e[o++]=t[s+4],e[o++]=.5,e[o++]=.5),r+=3}return r};let Fo=new Float32Array(32);const hm=t=>(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<i;l+=3)e+=3}const r=e*4;Fo.length<r&&(Fo=new Float32Array(hm(r)));const n=Fo;let s=0;for(const o of t)s=fm(o,n,s);return{buffer:n.subarray(0,s*4),indexCount:s}},Cr=new OffscreenCanvas(1,1).getContext("2d"),dm={x:0,y:0},pm={x:0,y:0},mm={x:0,y:0},gm={x:0,y:0},bm=(t,e,r)=>{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<n;o++){const i=[];for(const l of s){const c=Mm(l[0],l[1],l[2],.5);i.push(c[0],c[1])}s=i}return s},Ka=(t,e,r,n)=>{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<o.length-1;++h)o[h+1][0]=o[h][2];for(let h=0;h<i.length-1;++h)i[h+1][0]=i[h][2];const l=o[0][0],c=[l.x,l.y,!1];for(let h=0;h<o.length;++h){const d=o[h];c.push(d[1].x,d[1].y,!0,d[2].x,d[2].y,!1)}const u=[...i].reverse();for(let h=0;h<u.length;++h){const[d,m,g]=u[h];u[h]=[g,m,d]}const a=u[0][0];c.push(a.x,a.y,!1);for(let h=0;h<u.length;++h){const d=u[h];c.push(d[1].x,d[1].y,!0,d[2].x,d[2].y,!1)}return c},Tm=(t,e,r)=>{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;i<n.length;i+=3){if(n[i+2])continue;const l=n[i],c=n[i+1],u=Math.sqrt(Math.pow(l-t,2)+Math.pow(c-e,2));Math.abs(u-r)>1e-4||s.push(l,c)}return s},Gr=(t,e)=>{Cr.beginPath(),Cr.moveTo(e[0],e[1]);for(let r=3;r<e.length;r+=3)e[r+2]?(Cr.quadraticCurveTo(e[r],e[r+1],e[r+3],e[r+4]),r+=3):Cr.lineTo(e[r],e[r+1]);Cr.closePath();for(let r=0;r<t.length;r+=2){const n=t[r],s=t[r+1];if(!Cr.isPointInPath(n,s))return[n,s]}return null},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]);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 m=Math.atan2(a[1]-e,a[0]-t)-h;m>Math.PI?m-=2*Math.PI:m<-Math.PI&&(m+=2*Math.PI);const g=8,f=m/g,b=[t,e,!1];for(let x=0;x<=g;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,m=e.y-t.y,g=Math.hypot(d,m),f={x:d/g,y:m/g},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],m=t[t.length-5],g=Math.atan2(h-m,a-d),f=[a,h,!1];for(let b=0;b<=u;b++){const x=g-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],m=t[t.length-5],g=a-d,f=h-m,b=Math.hypot(g,f);if(b>0){const x=g/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 m=3;m<t.length;m+=3){const g=t[m],f=t[m+1];if(t[m+2]){n.x=g,n.y=f;continue}if(s.x=g,s.y=f,t[m-1]?i.push($m(r,n,s,e)):i.push(Tm(r,s,e)),i.length>1)switch(st.joints){case 0:qa(r.x,r.y,e,i);break;case 1:o.x=t[m-6],o.y=t[m-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)<h&&Math.abs(c-a)<h&&i.length>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<s;i++){const l=i/(s-1),c=Vm(t,l,r),u=i*4;o[u+0]=Math.round(Math.max(0,Math.min(255,c.r))),o[u+1]=Math.round(Math.max(0,Math.min(255,c.g))),o[u+2]=Math.round(Math.max(0,Math.min(255,c.b))),o[u+3]=Math.round(Math.max(0,Math.min(255,c.a)))}return o},Vm=(t,e,r)=>{const n=t.length/5;let s=0,o=0;for(let x=0;x<n;x++){const y=t[x*5];if(y<=e&&(s=x),y>=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],m=t[o*5+1],g=t[o*5+2],f=t[o*5+3],b=t[o*5+4];return r===0?{r:Go(ot(kr(u/255),kr(m/255),c))*255,g:Go(ot(kr(a/255),kr(g/255),c))*255,b:Go(ot(kr(h/255),kr(f/255),c))*255,a:ot(d,b,c)}:{r:ot(u,m,c),g:ot(a,g,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<o;l++){const c=e[l];i.push({offset:t[l]/255,r:(c>>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<o-1;P++)if(i[P].offset<=c&&i[P+1].offset>=c){u=P,a=P+1;break}const h=i[u],d=i[a];let m=0;d.offset!==h.offset&&(m=(c-h.offset)/(d.offset-h.offset));const g=ot(h.r,d.r,m),f=ot(h.g,d.g,m),b=ot(h.b,d.b,m),x=ot(h.a,d.a,m),y=l*4;s[y+0]=Math.round(g*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,m=-o*a,g=n*a,f=(o*c-i*l)*a,b=(s*l-n*c)*a;return{inverseMatrix:new Float32Array([h,d,0,m,g,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,m,g,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/m,j[25]=F/g,j[26]=0,j[27]=0,j[28]=A/m,j[29]=R/g,j[30]=0,j[31]=0,j[32]=v/m,j[33]=U/g,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/m,Ue[5]=F/g,Ue[6]=0,Ue[7]=0,Ue[8]=A/m,Ue[9]=R/g,Ue[10]=0,Ue[11]=0,Ue[12]=v/m,Ue[13]=U/g,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],m=e[7],g=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+m,S=g*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=g*M,F=(f*P-x*y)*M,A=(b*y-g*P)*M,R=$*c+T*u,v=$*a+T*h,U=w*c+E*u,L=w*a+E*h,D=$*d+T*m+F,G=w*d+E*m+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,m,g,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/m,Z[21]=A/g,Z[22]=0,Z[23]=0,Z[24]=R/m,Z[25]=v/g,Z[26]=0,Z[27]=0,Z[28]=U/m,Z[29]=L/g,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/m,Ge[5]=A/g,Ge[6]=0,Ge[7]=0,Ge[8]=R/m,Ge[9]=v/g,Ge[10]=0,Ge[11]=0,Ge[12]=U/m,Ge[13]=L/g,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<n;s+=3){let o=r*4;t[s+2]?(e[o++]=t[s-3],e[o++]=t[s-2],e[o++]=.5,e[o++]=.5,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=.5,e[o++]=t[s+3],e[o++]=t[s+4],e[o++]=.5,e[o++]=.5):t[s+5]?(e[o++]=t[0],e[o++]=t[1],e[o++]=.5,e[o++]=.5,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=.5,e[o++]=t[s+6],e[o++]=t[s+7],e[o++]=.5,e[o++]=.5):(e[o++]=t[0],e[o++]=t[1],e[o++]=.5,e[o++]=.5,e[o++]=t[s],e[o++]=t[s+1],e[o++]=.5,e[o++]=.5,e[o++]=t[s+3],e[o++]=t[s+4],e[o++]=.5,e[o++]=.5),r+=3}return r};let _o=new Float32Array(32);const zm=t=>(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<u;a+=3)s+=3}if(s===0)return{buffer:new Float32Array(0),indexCount:0};const o=s*4;_o.length<o&&(_o=new Float32Array(zm(o)));const i=_o;let l=0;for(const c of n)l=dc(c,i,l);return{buffer:i.subarray(0,l*4),indexCount:l}};let Vo=null;const H=new Float32Array(36),is=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Ym=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x)=>{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,m)),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/g,H[25]=F/f,H[26]=0,H[27]=0,H[28]=A/g,H[29]=R/f,H[30]=0,H[31]=0,H[32]=v/g,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<u;a+=3)s+=3}if(s===0)return{buffer:new Float32Array(0),indexCount:0};const o=s*4;Do.length<o&&(Do=new Float32Array(Wm(o)));const i=Do;let l=0;for(const c of n)l=dc(c,i,l);return{buffer:i.subarray(0,l*4),indexCount:l}},pc=new Map,J=new Float32Array(32),as=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Hm=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g,f,b,x)=>{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/g,J[21]=A/f,J[22]=0,J[23]=0,J[24]=R/g,J[25]=v/f,J[26]=0,J[27]=0,J[28]=U/g,J[29]=L/f,J[30]=1,J[31]=0;const D=r.acquireAndWriteUniformBuffer(J),G=\`bitmap_\${m?"s":"n"}_\${d?"r":"c"}\`;let B=pc.get(G);B||(B=t.createSampler({magFilter:m?"linear":"nearest",minFilter:m?"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<<o-1,l=r.acquireVertexBuffer(mc.byteLength,mc),c=r.dynamicUniform.allocate(Km),u=n.getBindGroupLayout("fill_dynamic");if(!u)return;const a=t.createBindGroup({layout:u,entries:[{binding:0,resource:{buffer:r.dynamicUniform.getBuffer(),size:256}}]}),h=n.getPipeline(\`mask_union_merge_\${o}\`);h&&(e.setPipeline(h),e.setStencilReference(i),e.setVertexBuffer(0,l),e.setBindGroup(0,a,[c]),e.draw(6,1,0,0));const d=n.getPipeline(\`mask_union_clear_\${o}\`);d&&(e.setPipeline(d),e.setStencilReference(0),e.setVertexBuffer(0,l),e.setBindGroup(0,a,[c]),e.draw(6,1,0,0))},Le=new Float32Array(16),Qm=(t,e,r,n,s,o,i,l,c,u=!1)=>{const a=s.clipLevel,h=s.width,d=s.height,m=l[0],g=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]=m,Le[1]=g,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(),m=(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),g=l.getPipeline(m),f=l.getPipeline("instanced_masked"),b=u&&f&&(n.msaaStencil?.view||n.stencil?.view),x=b?f:g;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(),$=We()||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=We()||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),m=c.getPipeline("complex_blend"),g=c.getBindGroupLayout("complex_blend");if(!m||!g)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:g,entries:bn}),P=l.createRenderPassDescriptor(d.texture.view,0,0,0,0,"clear"),S=i.beginRenderPass(P);return S.setPipeline(m),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,m)=>{const g=d.getPipeline("complex_blend_copy"),f=d.getBindGroupLayout("texture_copy");if(!g||!f)return;xn[0]=c/i,xn[1]=u/l,xn[2]=s/i,xn[3]=o/l;const b=m.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(g),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),m=c.getBindGroupLayout("positioned_texture");if(!d||!m)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 g=u.acquireAndWriteUniformBuffer(Oe),f=l.createSampler("complex_blend_output_sampler",!1);at[0].resource.buffer=g,at[1].resource=f,at[2].resource=r.texture.view;const b=t.createBindGroup({layout:m,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=We()||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:m,y_max:g,color_transform:f,matrix:b,blend_mode:x,global_alpha:y}=u,P=Math.ceil(Math.abs(m-h)),S=Math.ceil(Math.abs(g-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,m=1;return l>128?d=.0625:l>64?d=.125:l>32?d=.25:l>16&&(d=.5),c>128?m=.0625:c>64?m=.125:c>32?m=.25:c>16&&(m=.5),{baseBlurX:l,baseBlurY:c,offsetX:a,offsetY:h,bufferScaleX:d,bufferScaleY:m}},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 m=1-(c-i*.5),g=1+i;ht[0]=o?1:0,ht[1]=o?0:1,ht[2]=c,ht[3]=m,ht[4]=n.width,ht[5]=n.height,ht[6]=g,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:m,baseBlurY:g,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=m*x,A=g*y,R=i.computePipelineManager&&a0(m,g,M,$),v=[T,w];let U=0;for(let D=0;D<s;++D){if(r>0){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"),m=n.getBindGroupLayout("texture_copy");if(!d||!m){console.error("[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found");return}const g=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:m,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,g,f,0,1),T.setScissorRect(Math.floor(u),Math.floor(a),Math.ceil(g),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:m,samples:g,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]=m,ye[3]=g;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 m=t.createBindGroup({layout:h,entries:ct}),g=r.createRenderPassDescriptor(o.texture.view,0,0,0,0,"clear"),f=e.beginRenderPass(g);f.setPipeline(a),f.setBindGroup(0,m),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 m=n.createBindGroup({layout:a,entries:ls}),g=o.createRenderPassDescriptor(c.texture.view,0,0,0,0,"clear"),f=s.beginRenderPass(g);return f.setPipeline(u),f.setBindGroup(0,m),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:m,frameBufferManager:g,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=g.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"),g.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=g.createRenderPassDescriptor(W.texture.view,0,0,0,0,"clear"),Je=m.beginRenderPass(Ct);return Je.setPipeline(K),Je.setBindGroup(0,Q),Je.draw(6,1,0,0),Je.end(),g.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,m,g)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=g,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,i,l,u,m,g),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/m),z=Math.sin(G)*r*(D/m),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=g.bufferManager?g.bufferManager.acquireAndWriteUniformBuffer(Ae):f.createBuffer({size:Ae.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});g.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,m,g,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/g),v=Math.sin(A)*r*(F/g),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,g,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:m?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]=m?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:m,textureManager:g}=a,f=t.width,b=t.height,x=m.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=g.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<M;B++)A[B]=n[B];const R=32+$*16,v=new Float32Array(R/4);v[0]=1/f,v[1]=1/b,v[2]=s!==0?1/s:1,v[3]=o/255,v[4]=T,v[5]=w,v[6]=E,v[7]=F;for(let B=0;B<A.length;B++)v[8+B]=A[B];const U=a.bufferManager?a.bufferManager.acquireAndWriteUniformBuffer(v):h.createBuffer({size:v.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});a.bufferManager||h.queue.writeBuffer(U,0,v),fs[0].resource.buffer=U,fs[1].resource=S,fs[2].resource=t.texture.view;const L=h.createBindGroup({layout:P.bindGroupLayout,entries:fs}),D=m.createRenderPassDescriptor(x.texture.view,0,0,0,0,"clear"),G=d.beginRenderPass(D);return G.setPipeline(P.pipeline),G.setBindGroup(0,L),G.draw(6,1,0,0),G.end(),x},m0=Math.PI/180,or=new Float32Array(4),Ne=new Float32Array(12),hs=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Ir=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null},{binding:4,resource:null}],Fc=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=g,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/m),R=Math.sin(F)*r*(E/m),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=g.bufferManager?g.bufferManager.acquireAndWriteUniformBuffer(or):f.createBuffer({size:or.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});g.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,m,g);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);Ne[0]=u,Ne[1]=X?1:0,Ne[2]=d?1:0,Ne[3]=h,Ne[4]=ur,Ne[5]=Yt,Ne[6]=Gt,Ne[7]=Lt,Ne[8]=Wt,Ne[9]=fr,Ne[10]=jt,Ne[11]=hr;const kt=g.bufferManager?g.bufferManager.acquireAndWriteUniformBuffer(Ne):f.createBuffer({size:Ne.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});g.bufferManager||f.queue.writeBuffer(kt,0,Ne),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(),g.frameTextures.push(Ut),x.releaseTemporaryAttachment(_),ne.x=S+Fe,ne.y=M+ge,Ht},g0=Math.PI/180,ze=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,m,g)=>{const{device:f,commandEncoder:b,frameBufferManager:x,pipelineManager:y,textureManager:P}=g,S=ne.x,M=ne.y,$=t.width,T=t.height,w=sr(t,e,l,c,a,m,g),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/m),z=Math.sin(G)*r*(D/m),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);ze[0]=u,ze[1]=k?1:0,ze[2]=d?1:0,ze[3]=h,ze[4]=ge,ze[5]=Q,ze[6]=Ct,ze[7]=Je,ze[8]=Ut,ze[9]=lr,ze[10]=ur,ze[11]=Yt;const jt=g.bufferManager?g.bufferManager.acquireAndWriteUniformBuffer(ze):f.createBuffer({size:ze.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});g.bufferManager||f.queue.writeBuffer(jt,0,ze),_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(),g.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,m,g,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,m);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=We()||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 m=t.bufferManager.acquireAndWriteUniformBuffer(bt),g=t.textureManager.createSampler("filter_copy_sampler",!1);fe[0].resource.buffer=m,fe[1].resource=g,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,m=o?r.texture.view:null,g=t.frameBufferManager.createRenderPassDescriptor(d,0,0,0,0,"load",m),f=t.commandEncoder.beginRenderPass(g);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,m=0,g=0;if(u<0&&(m=-u/e.width,h+=u,u=0),a<0&&(g=-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]=m,bt[3]=g;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 m=le.getDevicePixelRatio(),g=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?g*Math.cos(b):Math.cos(b),P=n?g*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,m,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,m,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;se<I;se++)V[se]=c[B++];const X=c[B++],Y=c[B++],W=!!c[B++],K=!!c[B++],q=c[B++],ce=c[B++],te=Ac(d,k,_,V,X,Y,W,K,q,ce,u);d!==te&&u.frameBufferManager.releaseTemporaryAttachment(d),d=te}break;case 4:{const k=c[B++],_=new Uint8Array(k);for(let ge=0;ge<k;ge++)_[ge]=c[B++];const 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=c[B++],Fe=Ec(d,s,_,I,V,X,Y,W,K,q,ce,te,se,ue,m,u);d!==Fe&&u.frameBufferManager.releaseTemporaryAttachment(d),d=Fe}break;case 5:{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(d,s,k,_,I,V,X,Y,W,K,q,ce,te,m,u);d!==se&&u.frameBufferManager.releaseTemporaryAttachment(d),d=se}break;case 6:{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=Sc(d,s,k,_,I,V,X,Y,W,K,m,u);d!==q&&u.frameBufferManager.releaseTemporaryAttachment(d),d=q}break;case 7:{const k=c[B++],_=c[B++],I=c[B++],V=new Float32Array(I);for(let Q=0;Q<I;Q++)V[Q]=c[B++];const X=c[B++],Y=new Float32Array(X);for(let Q=0;Q<X;Q++)Y[Q]=c[B++];const W=c[B++],K=new Float32Array(W);for(let Q=0;Q<W;Q++)K[Q]=c[B++];const q=c[B++],ce=c[B++],te=c[B++],se=c[B++],ue=c[B++],Fe=!!c[B++],ge=Fc(d,s,k,_,V,Y,K,q,ce,te,se,ue,Fe,m,u);d!==ge&&u.frameBufferManager.releaseTemporaryAttachment(d),d=ge}break;case 8:{const k=c[B++],_=c[B++],I=c[B++],V=new Float32Array(I);for(let Q=0;Q<I;Q++)V[Q]=c[B++];const X=c[B++],Y=new Float32Array(X);for(let Q=0;Q<X;Q++)Y[Q]=c[B++];const W=c[B++],K=new Float32Array(W);for(let Q=0;Q<W;Q++)K[Q]=c[B++];const q=c[B++],ce=c[B++],te=c[B++],se=c[B++],ue=c[B++],Fe=!!c[B++],ge=wc(d,s,k,_,V,Y,K,q,ce,te,se,ue,Fe,m,u);d!==ge&&u.frameBufferManager.releaseTemporaryAttachment(d),d=ge}break}if(!v0(o)){const B=M0(u,d,o);u.frameBufferManager.releaseTemporaryAttachment(d),d=B}const U=l[0]*(g/m),L=l[1]*(f/m),D=-R+U+s[4],G=-v+L+s[5];P0(u,d,o,i,D,G),u.frameBufferManager.releaseTemporaryAttachment(d)},xt=new Float32Array(4),ie=new Float32Array(8),Me=new Float32Array(20),Ie=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],F0=new Set(["normal","layer","add","screen","alpha","erase","copy"]),ir=new Float32Array([1,1,1,1,0,0,0,0]),Rc=t=>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:!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 m=t.bufferManager.acquireAndWriteUniformBuffer(xt),g=t.textureManager.createSampler("container_copy_sampler",!1);Ie[0].resource.buffer=m,Ie[1].resource=g,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 m=r.width,g=r.height;if(l+u>m&&(u=m-l),c+a>g&&(a=g-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,m-L)),B=Math.max(1,Math.min(Math.ceil(R+U)-D,g-D));if(G<=0||B<=0||L>=m||D>=g)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<u;d++)a[d]=r[o++];const h=Ac(t,l,c,a,r[o++],r[o++],!!r[o++],!!r[o++],r[o++],r[o++],s);t!==h&&s.frameBufferManager.releaseTemporaryAttachment(t),t=h}break;case 4:{const l=r[o++],c=new Uint8Array(l);for(let a=0;a<l;a++)c[a]=r[o++];const u=Ec(t,e,c,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!==u&&s.frameBufferManager.releaseTemporaryAttachment(t),t=u}break;case 5:{const l=$c(t,e,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 6:{const l=Sc(t,e,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 7:{const l=r[o++],c=r[o++],u=r[o++],a=new Float32Array(u);for(let b=0;b<u;b++)a[b]=r[o++];const h=r[o++],d=new Float32Array(h);for(let b=0;b<h;b++)d[b]=r[o++];const m=r[o++],g=new Float32Array(m);for(let b=0;b<m;b++)g[b]=r[o++];const f=Fc(t,e,l,c,a,d,g,r[o++],r[o++],r[o++],r[o++],r[o++],!!r[o++],n,s);t!==f&&s.frameBufferManager.releaseTemporaryAttachment(t),t=f}break;case 8:{const l=r[o++],c=r[o++],u=r[o++],a=new Float32Array(u);for(let b=0;b<u;b++)a[b]=r[o++];const h=r[o++],d=new Float32Array(h);for(let b=0;b<h;b++)d[b]=r[o++];const m=r[o++],g=new Float32Array(m);for(let b=0;b<m;b++)g[b]=r[o++];const f=wc(t,e,l,c,a,d,g,r[o++],r[o++],r[o++],r[o++],r[o++],!!r[o++],n,s);t!==f&&s.frameBufferManager.releaseTemporaryAttachment(t),t=f}break}return t},O0=(t,e,r,n,s,o,i,l,c,u,a,h,d,m,g)=>{if(i&&s&&l&&c){let f=Yo(m,t,0,0,t.width,t.height);m.frameBufferManager.releaseTemporaryAttachment(t);const b=le.getDevicePixelRatio();if(f=w0(f,s,c,b,m),u&&(ee.set(u,"fKey",a),ee.set(u,"fTexture",f)),f){let x=f,y=null;Rc(o)||(y=Cc(m,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(m,x,e,n,T,w,g),y&&m.frameBufferManager.releaseTemporaryAttachment(y),u||m.frameBufferManager.releaseTemporaryAttachment(f)}}else{let f=Yo(m,t,0,0,t.width,t.height);if(m.frameBufferManager.releaseTemporaryAttachment(t),!Rc(o)){const b=Cc(m,f,o);m.frameBufferManager.releaseTemporaryAttachment(f),f=b}Uc(m,f,e,n,s[4],s[5],g),m.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;$needsReconfigure=!1;$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 s of this.frameTextures)s.destroy();this.frameTextures.length=0;for(const s of this.pooledTextures)Ot(s);this.pooledTextures.length=0;for(const s of this.pooledRenderTextures)Xt(s);if(this.pooledRenderTextures.length=0,Em(),this.frameStarted=!1,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,am(),this.$stackAttachmentObject.length){for(let s=0;s<this.$stackAttachmentObject.length;++s){const o=this.$stackAttachmentObject[s];o&&(o.texture&&o.texture.resource.destroy(),o.stencil&&o.stencil.resource.destroy(),o.msaaTexture&&o.msaaTexture.resource.destroy(),o.msaaStencil&&o.msaaStencil.resource.destroy())}this.$stackAttachmentObject.length=0}this.$mainAttachmentObject&&this.frameBufferManager.destroyAttachment("main"),n&&(Rm(),Gm(),Lm(),rm(),this.frameBufferManager.destroyAttachment("atlas"),this.frameBufferManager.createAttachment("atlas",4096,4096,!1,!0)),this.frameBufferManager.setCurrentAttachment(null),this.$needsReconfigure=!0,this.mainTexture=null,this.mainTextureView=null,this.$mainAttachmentObject=this.frameBufferManager.createAttachment("main",e,r,!0,!0),this.bind(this.$mainAttachmentObject)}clearRect(e,r,n,s){}save(){const e=Wo.length>0?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],m=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+m}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=We(),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=We();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=We();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,m=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);m&&this.addFrameTexture(m),this.beginPath()}bitmapFill(e,r,n,s,o,i){const l=this.pathCommand.$getVertices;if(l.length===0)return;this.ensureFillRenderPass();const c=We(),u=!!(this.currentRenderTarget&&c?.stencil?.view),a=!!((this.inMaskMode||gt())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),h=u||a,d=this.$mainAttachmentObject?.clipLevel??1,m=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);m&&this.addFrameTexture(m),this.beginPath()}gradientStroke(e,r,n,s,o,i){const l=this.pathCommand.getVerticesForStroke();if(l.length===0)return;this.ensureFillRenderPass();const c=We(),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=We(),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 We()}useGrid(e){Ja.set(ec,e)}beginNodeRendering(e){this.nodeAreaCleared=!1,this.frameStarted||this.beginFrame();const r=bo(e.index)||We();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)||We();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),m=Eo(i);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=m;const g=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,g),b.draw(6),b.end(),this.pooledRenderTextures.push(i)}drawElement(e,r,n=!1){const s=bo(e.index)||We();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),m=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=m;const g=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,g),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),m=Eo(l);he[0].resource.buffer=h,he[1].resource=d,he[2].resource=m;const g=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,g),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 m=le.getDevicePixelRatio(),g=Math.sqrt(r[0]*r[0]+r[1]*r[1]),f=Math.sqrt(r[2]*r[2]+r[3]*r[3]),b=s[0]*(g/m),x=s[1]*(f/m),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.$needsReconfigure&&(this.canvasContext.configure({device:this.device,format:this.preferredFormat,alphaMode:"premultiplied"}),this.$needsReconfigure=!1),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=this.$mainAttachmentObject;if(!n||!n.texture)throw new Error("[WebGPU] Main 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});this.ensureCommandEncoder(),this.commandEncoder.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.endFrame(),await l.mapAsync(GPUMapMode.READ);const c=l.getMappedRange(),u=new Uint8Array(c),a=this.preferredFormat==="bgra8unorm",h=new Uint8Array(e*r*4),d=e*4;for(let f=0;f<r;f++){const b=f*o,x=f*d;if(a)for(let y=0;y<d;y+=4)h[x+y]=u[b+y+2],h[x+y+1]=u[b+y+1],h[x+y+2]=u[b+y],h[x+y+3]=u[b+y+3];else h.set(u.subarray(b,b+d),x)}l.unmap(),l.destroy();const m=new Float32Array(256);for(let f=1;f<256;f++)m[f]=255/f;for(let f=0;f<h.length;f+=4){const b=h[f+3];if(b===0||b===255)continue;const x=m[b];h[f]=Math.min(255,Math.round(h[f]*x)),h[f+1]=Math.min(255,Math.round(h[f+1]*x)),h[f+2]=Math.min(255,Math.round(h[f+2]*x))}const g=new ImageData(new Uint8ClampedArray(h),e,r);if(typeof createImageBitmap<"u")return await createImageBitmap(g,{premultiplyAlpha:"none",colorSpaceConversion:"none"});throw new Error("[WebGPU] createImageBitmap not available in this environment")}beginMask(){if(this.$mainAttachmentObject&&this.bind(this.$mainAttachmentObject),this.currentRenderTarget=null,this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.frameStarted||this.beginFrame(),this.ensureCommandEncoder(),this.$mainAttachmentObject?.texture&&this.$mainAttachmentObject?.stencil?.view){const r=this.$mainAttachmentObject.clipLevel===0?"clear":"load",n=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,s=n?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,o=n&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,i=this.frameBufferManager.createStencilRenderPassDescriptor(s,o,"load",r);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i),this.viewportWidth=this.$mainAttachmentObject.width,this.viewportHeight=this.$mainAttachmentObject.height}cm(),this.inMaskMode=!0}setMaskBounds(e,r,n,s){lm(e,r,n,s)}endMask(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),Ha(),this.inMaskMode=!1}leaveMask(){this.drawArraysInstanced();const r=this.frameBufferManager.getCurrentAttachment()?.clipLevel??0,n=r===1;um(),this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null),this.ensureCommandEncoder();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;if(n&&i){const l={colorAttachments:[{view:o,loadOp:"load",storeOp:"store"}],depthStencilAttachment:{view:i,stencilLoadOp:"clear",stencilStoreOp:"store",stencilClearValue:0}};this.commandEncoder.beginRenderPass(l).end()}else if(r>1&&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),m=this.bufferManager.acquireVertexBuffer(Gc.byteLength,Gc);d.setPipeline(a),d.setStencilReference(0),d.setVertexBuffer(0,m),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<o;++a)s.push(t[r++],t[r++],t[r++],t[r++],t[r++]);const i=t.subarray(r,r+6);r+=6;const l=t[r++],c=t[r++],u=t[r++];C.gradientFill(n,s,i,l,c,u)}break;case rg:{if(e){r+=2;const c=t[r++];r+=c,r+=8,C.fill();break}const n=t[r++],s=t[r++],o=t[r++],i=new Uint8Array(t.subarray(r,r+o));r+=o;const l=t.subarray(r,r+6);r+=6,C.bitmapFill(i,l,n,s,!!t[r++],!!t[r++])}break;case eg:{if(e){r+=20,C.fill();break}C.thickness=t[r++],C.caps=t[r++],C.joints=t[r++],C.miterLimit=t[r++];const n=t[r++],s=Dc(),o=t[r++];for(let a=0;a<o;++a)s.push(t[r++],t[r++],t[r++],t[r++],t[r++]);const i=t.subarray(r,r+6);r+=6;const l=t[r++],c=t[r++],u=t[r++];C.gradientStroke(n,s,i,l,c,u)}break;case ng:{if(e){r+=6;const c=t[r++];r+=c,r+=8,C.fill();break}C.thickness=t[r++],C.caps=t[r++],C.joints=t[r++],C.miterLimit=t[r++];const n=t[r++],s=t[r++],o=t[r++],i=new Uint8Array(t.subarray(r,r+o));r+=o;const l=t.subarray(r,r+6);r+=6,C.bitmapStroke(i,l,n,s,!!t[r++],!!t[r++])}break}},cr=t=>{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++]}\`,m=t[e++],g=t[e++],f=t[e++],b=\`\${t[e++]}\`;let x;if(t[e++]){if(x=ee.get(d,\`\${m}\`),!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,\`\${m}\`,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)*g),E=Math.ceil(Math.abs(c-i)*f);x=C.createNode(w,E),ee.set(d,\`\${m}\`,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(g,0,0,f,-o*g+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*g,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;G<D;++G)L+=t.heightTable[G];o.beginPath(),o.rect(A,L,R+F,t.heightTable[D]),o.fill(),A=0,R=0}}const u=e.rawWidth;let a=0;if(e.scrollX>0){const M=(e.textWidth-u)/u;a=e.scrollX*M}const h=u+a,d=e.rawHeight;let m=0;if(e.scrollY>0){const M=(e.textHeight-d)/d;m=e.scrollY*M}const g=d+m;let f=0,b=0,x=0,y=0,P=!1,S=-1;for(let M=0;M<t.textTable.length;++M){const $=t.textTable[M];if(!$)continue;if(($.mode==="text"||$.mode==="break")&&(S++,e.stopIndex>-1&&S>e.stopIndex))break;if(P&&$.mode==="text")continue;const T=$.textFormat;if(e.autoSize==="none"){if(b>g)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;U<A;++U)v+=t.heightTable[U];o.strokeStyle=\`rgba(\${w.R},\${w.G},\${w.B},\${w.A})\`,o.beginPath(),o.moveTo(F,v),o.lineTo(F,v-R),o.stroke()}if(e.thickness){const F=Dr(e.thicknessColor);o.lineWidth=e.thickness,o.strokeStyle=\`rgba(\${F.R},\${F.G},\${F.B},\${F.A})\`}const E=$.line|0;switch($.mode){case"break":case"wrap":if(f=0,E&&(b+=t.heightTable[E-1]),m>b+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++],m=t[e++],g=\`\${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)*m),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,m),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,g,!!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*m,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++],m=\`\${t[e++]}\`;let g;if(t[e++]){if(g=ee.get(a,\`\${h}\`),!g)return e}else{const y=Math.abs(c-i),P=Math.abs(u-l),S=!!t[e++];if(g=S?ee.get(a,\`\${h}\`):C.createNode(y,P),S||ee.set(a,\`\${h}\`,g),r&&r.length){const M=C.currentAttachmentObject,$=C.atlasAttachmentObject;$&&C.bind($),C.reset(),C.beginNodeRendering(g);const T=$?$.height-g.y-P:0;C.setTransform(1,0,0,1,g.x,T);const w=r.shift();C.drawElement(g,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(g,m,!!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(g,o[0],o[1],o[2],o[3],s),e},oi=(t,e)=>{const r=t[e++];for(let n=0;n<r;++n)switch(t[e++]){case 0:e=oi(t,e);break;case 1:e=ri(t,e);break}return e},ii=(t,e,r)=>{let n=0,s=!0;const o=cr(t[e++]),i=!!t[e++];let l=0,c=0,u=!1,a="",h="",d=null,m=null,g=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,g=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8,C.containerDrawCachedFilter(o,g,f,d,a,h),e;d=t.subarray(e,e+4),e+=4,g=t.subarray(e,e+6),e+=6,f=t.subarray(e,e+8),e+=8;const P=t[e++];m=t.subarray(e,e+P),e+=P}else g=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,g,f,u,d,m,a,h),e};let Nr=-1;const ag=(t,e)=>{I0()&&_0(),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(),C.transferMainCanvas()},cg=t=>{for(let e=0;e<t.length;++e){const r=\`\${t[e]}\`;if(!ee.has(r))continue;const n=ee.getById(r);for(const s of n.values())C.removeNode(s);ee.removeById(r)}},lg=async(t,e,r,n=0,s=0,o)=>{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()})})();
|
|
2338
|
-
`,Fn=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",ds],{type:"text/javascript;charset=utf-8"});function Ni(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(ds),{name:e?.name})}}const Ce=new Ni,Yi=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 As=null;const We=e=>{As=e},jt=()=>As;class V extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,s)=>{if(s in n)return n[s];const i=jt();if(i)switch(i.type){case V.KEY_DOWN:case V.KEY_UP:return s in i?$event[s]:void 0;default:return}}})}static get KEY_DOWN(){return"keydown"}static get KEY_UP(){return"keyup"}}const Wi=(e,t,r,n=!1,s=0)=>{let i;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:(!q.size||!q.has(t))&&q.set(t,Qt()),i=q.get(t);break;default:e._$events||(e._$events=new Map),(!e._$events.size||!e._$events.has(t))&&e._$events.set(t,Qt()),i=e._$events.get(t);break}const a=i.length;let o=0;for(;o<a;++o){const c=i[o];if(n===c.useCapture&&c.target===e&&c.listener===r)break}if(a===o)i.push({listener:r,priority:s,useCapture:n,target:e});else{const c=i[o];c.listener=r,c.priority=s,c.useCapture=n,c.target=e}i.length>1&&i.sort((c,u)=>{switch(!0){case c.priority>u.priority:return-1;case c.priority<u.priority:return 1;default:return 0}})},Vi=(e,t)=>{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))}},Ki=(e,t,r,n=!1)=>{let s;switch(t){case x.ENTER_FRAME:case V.KEY_DOWN:case V.KEY_UP:if(!q.size||!q.has(t))return;s=q.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;s=e._$events.get(t);break}if(s){for(let i=0;i<s.length;++i){const a=s[i];if(n===a.useCapture&&a.listener===r){s.splice(i,1);break}}if(!s.length){q.has(t)&&q.delete(t),e._$events&&e._$events.has(t)&&(e._$events.delete(t),e._$events.size||(e._$events=null)),Pe(s);return}s.length>1&&s.sort((i,a)=>{switch(!0){case i.priority>a.priority:return-1;case i.priority<a.priority:return 1;default:return 0}})}},Qi=(e,t,r=!1)=>{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 s=Qt();for(let i=0;i<n.length;++i){const a=n[i];r!==a.useCapture&&s.push(a)}if(!s.length){q.has(t)&&q.delete(t),e._$events&&e._$events.has(t)&&(e._$events.delete(t),e._$events.size||(e._$events=null)),Pe(s),Pe(n);return}s.length>1&&s.sort((i,a)=>{switch(!0){case i.priority>a.priority:return-1;case i.priority<a.priority:return 1;default:return 0}}),q.has(t)?q.set(t,s):e._$events?.set(t,s),Pe(n)},Xi=(e,t)=>{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},zi=(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<r.length;++n){const s=r[n];t.eventPhase=ze.AT_TARGET,t.target=t.currentTarget=s.target;try{t.listener=s.listener,s.listener(t)}catch(i){return console.error(i),!1}}}return!0;default:{t.target=e;let r=null;if(e._$events&&e._$events.size&&e._$events.has(t.type)){const s=e._$events.get(t.type);s&&(r=s.slice(0))}const n=Qt();if("parent"in e){let s=e.parent;for(;s;){if(s.hasEventListener(t.type)){const i=s._$events&&s._$events.has(t.type)?s._$events.get(t.type):null;i&&n.push(i)}if(!("parent"in s))break;s=s.parent}}if(!r&&!n.length)return r&&Pe(r),Pe(n),!1;if(n.length)switch(t.eventPhase=ze.CAPTURING_PHASE,!0){case t._$stopImmediatePropagation:case t._$stopPropagation:break;default:for(let s=n.length-1;s>-1;--s){const i=n[s];for(let a=0;a<i.length;++a){const o=i[a];if(o.useCapture){t.currentTarget=o.target;try{t.listener=o.listener,o.listener.call(null,t)}catch(c){return console.error(c),!1}if(t._$stopImmediatePropagation)break}}if(t._$stopImmediatePropagation)break}break}if(r&&!t._$stopImmediatePropagation&&!t._$stopPropagation){t.eventPhase=ze.AT_TARGET;for(let s=0;s<r.length;++s){const i=r[s];if(!i.useCapture){t.currentTarget=i.target;try{t.listener=i.listener,i.listener.call(null,t)}catch(a){return console.error(a),!1}if(t._$stopImmediatePropagation)break}}Pe(r)}if(n.length){switch(t.eventPhase=ze.BUBBLING_PHASE,!0){case t._$stopImmediatePropagation:case t._$stopPropagation:case!t.bubbles:break;default:for(let s=0;s<n.length;++s){const i=n[s];for(let a=0;a<i.length;++a){const o=i[a];if(!o.useCapture){t.currentTarget=o.target;try{t.listener=o.listener,o.listener.call(null,t)}catch(c){return console.error(c),!1}if(t._$stopImmediatePropagation)break}}if(t._$stopImmediatePropagation)break}break}Pe(n)}}return!0}};class nt{_$events;constructor(){this._$events=null}addEventListener(t,r,n=!1,s=0){this._$events||(this._$events=new Map),Wi(this,t,r,n,s)}dispatchEvent(t){return zi(this,t)}hasEventListener(t){return Vi(this,t)}removeEventListener(t,r,n=!1){Ki(this,t,r,n)}removeAllEventListener(t,r=!1){Qi(this,t,r)}willTrigger(t){return Xi(this,t)}}class Ne extends x{constructor(t,r=!0){return super(t,r),new Proxy(this,{get:(n,s)=>{if(s in n)return n[s];const i=jt();if(i)switch(i.type){case Ne.FOCUS_IN:case Ne.FOCUS_OUT:return s in i?$event[s]: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,s="",i=[]){super(t,r),this.status=n|0,this.responseHeaders=i,this.responseURL=s}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,s)=>{if(s in n)return n[s];const i=jt();if(i)switch(i.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 s in i?$event[s]: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,s=0){super(t,r),this.bytesLoaded=n|0,this.bytesTotal=s|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,s)=>{if(s in n)return n[s];const i=jt();if(i&&i.type===qe.WHEEL)return s in i?$event[s]:void 0}})}static get WHEEL(){return"wheel"}}const ps=[],er=e=>{e.size&&e.clear(),ps.push(e)},Hi=()=>ps.pop()||new Map,Ji=(e,t,r)=>{r.clear(),e.$timerId!==null&&clearTimeout(e.$timerId);for(const n of t.values()){for(const s of n.values())s&&e.destroy(s);er(n)}t.clear()},Zi=(e,t)=>{if(!(!t||typeof t!="object")&&"canvas"in t){const r=t.canvas,n=r.width,s=r.height;t.clearRect(0,0,n+1,s+1),r.width=r.height=1,e.push(r)}},qi=(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)))},ji=(e,t,r)=>{if(!t.has(r))return;const n=t.get(r);for(const s of n.values())e.destroy(s);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,s=null)=>{t.has(r)||t.set(r,Hi());const i=t.get(r);if(s===null){if(!i.has(n))return;e.destroy(i.get(n)),i.delete(n),i.size||(t.delete(r),er(i));return}i.set(n,s)},ra=(e,t,r="")=>r?e.has(t)?e.get(t).has(r):!1:e.has(t),na=(e,t,r)=>{let n=2166136261,s=e*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=t*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},sa=(e,t,r,n)=>{let s=2166136261,i=e*100|0;return s^=i&255,s=Math.imul(s,16777619),s^=i>>>8&255,s=Math.imul(s,16777619),s^=i>>>16&255,s=Math.imul(s,16777619),s^=i>>>24,s=Math.imul(s,16777619),i=t*100|0,s^=i&255,s=Math.imul(s,16777619),s^=i>>>8&255,s=Math.imul(s,16777619),s^=i>>>16&255,s=Math.imul(s,16777619),s^=i>>>24,s=Math.imul(s,16777619),i=r*100|0,s^=i&255,s=Math.imul(s,16777619),s^=i>>>8&255,s=Math.imul(s,16777619),s^=i>>>16&255,s=Math.imul(s,16777619),s^=i>>>24,s=Math.imul(s,16777619),i=n*100|0,s^=i&255,s=Math.imul(s,16777619),s^=i>>>8&255,s=Math.imul(s,16777619),s^=i>>>16&255,s=Math.imul(s,16777619),s^=i>>>24,s=Math.imul(s,16777619),(s>>>0)%16777216},ia=(e,t,r,n)=>{if(r.has(n))return;const s=t.get(n);s&&(s.set("trash",!0),r.set(n,s),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(){Ji(this,this._$store,this._$trash)}destroy(t=null){Zi(this._$pool,t)}getCanvas(){return this._$pool.pop()||document.createElement("canvas")}remove(t,r){qi(this._$store,t,r)}removeTimer(t){ia(this,this._$store,this._$trash,t)}removeTimerScheduledCache(){aa(this,this._$trash)}removeById(t){ji(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,s){return sa(t,r,n,s)}}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),s=new Uint8Array(n.data.buffer);return O.destroy(r),s},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),s=new Uint8Array(n.data.buffer);return O.destroy(r),s};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)},ms=[],En=(e=1,t=0,r=0,n=1,s=0,i=0)=>{const a=ms.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=s,a[5]=i,a},fa=e=>{ms.push(e)},gs=[],Pn=(e=1,t=1,r=1,n=1,s=0,i=0,a=0,o=0)=>{const c=gs.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=s,c[5]=i,c[6]=a,c[7]=o,c},da=e=>{gs.push(e)},Ee=(e,t,r,n=null)=>{const s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),r)};class U{_$colorTransform;constructor(t=1,r=1,n=1,s=1,i=0,a=0,o=0,c=0){this._$colorTransform=Pn(t,r,n,s,i,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 s=r[0]*n[0],i=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])&&(s+=r[1]*n[2],o+=r[2]*n[1],i+=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]=s,r[1]=i,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,s=0,i=0)=>{e.identity(),e.rotate(n),e.scale(t,r),e.translate(s,i)},ba=(e,t,r,n=0,s=0,i=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]=s+t/2,a[5]=i+r/2},xa=(e,t)=>new ie(e.x+t.x,e.y+t.y),ya=e=>new ie(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 ie(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 ie(e*Math.cos(t),e*Math.sin(t)),Ia=(e,t,r)=>{e.x=t,e.y=r},Ca=(e,t)=>new ie(e.x-t.x,e.y-t.y);class ie{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 ie(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],s=e._$matrix[3],i=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/s,e._$matrix[4]=-e._$matrix[0]*i,e._$matrix[5]=-e._$matrix[3]*a;else{const o=t*s-r*n;if(o){const c=1/o;e._$matrix[0]=s*c,e._$matrix[1]=-r*c,e._$matrix[2]=-n*c,e._$matrix[3]=t*c,e._$matrix[4]=-(e._$matrix[0]*i+e._$matrix[2]*a),e._$matrix[5]=-(e._$matrix[1]*i+e._$matrix[3]*a)}}},Ra=(e,t)=>{const r=e._$matrix,n=r[0],s=r[1],i=r[2],a=r[3],o=r[4],c=r[5];r[0]=n*Math.cos(t)-s*Math.sin(t),r[1]=n*Math.sin(t)+s*Math.cos(t),r[2]=i*Math.cos(t)-a*Math.sin(t),r[3]=i*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,s,i,a)=>{const o=e._$matrix;o[0]=t,o[1]=r,o[2]=n,o[3]=s,o[4]=i,o[5]=a},Ua=(e,t)=>{const r=t.x,n=t.y,s=e._$matrix;return new ie(r*s[0]+n*s[2]+s[4],r*s[1]+n*s[3]+s[5])},Ga=(e,t,r)=>{e.tx+=t,e.ty+=r};class T{_$matrix;constructor(t=1,r=0,n=0,s=1,i=0,a=0){this._$matrix=En(t,r,n,s,i,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,s=0,i=0){ga(this,t,r,n,s,i)}createGradientBox(t,r,n=0,s=0,i=0){ba(this,t,r,n,s,i)}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,s,i,a){ka(this,t,r,n,s,i,a)}transformPoint(t){return Ua(this,t)}translate(t,r){Ga(this,t,r)}static multiply(t,r){const n=t[0],s=t[1],i=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+i*h,s*u+a*h,n*l+i*f,s*l+a*f,n*A+i*d+o,s*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),s=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom),a=s-r,o=i-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),s=Math.min(e.right,t.right),i=Math.min(e.bottom,t.bottom);return s-r>0&&i-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,s)=>{e.x=t,e.y=r,e.width=n,e.height=s},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,s=0){this.x=t,this.y=r,this.width=n,this.height=s}get bottom(){return this.y+this.height}set bottom(t){this.height=t-this.y}get bottomRight(){return new ie(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 ie(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 ie(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,s){qa(this,t,r,n,s)}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 s=n.data.characters[r.characterId],i=r.isTimelineEnabled?r.currentFrame:1,a=s.placeMap[i];if(!a||!(t in a))return null;const o=a[t],c=s.placeObjects[o];return c?(e.placeObject=c,c):null},bt=new ie,bs=0,xs=1,eo=2,to=3,xt=new Float32Array([1,0,0,1,0,0]);let ro=0;const ys=()=>ro++,$s=[],Pr=[],vs=[],no=[],je=(e=0,t=0,r=0,n=0,s=0,i=0)=>{const a=vs.pop()||new Float32Array(6);return a[0]=e,a[1]=t,a[2]=r,a[3]=n,a[4]=s,a[5]=i,a},Ft=e=>{vs.push(e)},_t=(e=1,t=1,r=1,n=1,s=0,i=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]=s,c[5]=i,c[6]=a,c[7]=o,c},ws=[],so=()=>ws.pop()||new Map,io=e=>{e.clear(),ws.push(e)},z=(...e)=>{const t=$s.pop()||[];return e.length&&t.push(...e),t},oe=e=>{e.length&&(e.length=0),$s.push(e)},re=(e,t,r,n)=>{const s=Pr.length?Pr.pop():new Float32Array(4);return s[0]=e,s[1]=t,s[2]=r,s[3]=n,s},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 s=0;s<n.length;++s){const i=n[s];r.addEventListener(i,e.event[i])}}for(let n=0;n<e.headers.length;++n){const s=e.headers[n];s&&r.setRequestHeader(s.name,s.value)}r.send(t)},oo=e=>{const t=z();if(e){const r=e.trim().split(`
|
|
2339
|
-
`);for(let n=0;n<r.length;++n){const s=r[n].split(":");t.push({name:s[0].trim(),value:s[1].trim()})}}return t},Dt=new WeakMap,we=new WeakMap,ge=new Set,co=new WeakMap,Rr=document.createElement("canvas");Rr.width=Rr.height=1;const Ie=Rr.getContext("2d"),Or=e=>Ie?(Ie.fillStyle=e,+`0x${Ie.fillStyle.slice(1)}`):0,me=(e,t,r,n=null)=>{const s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),r)},kr=[],Ur=[],Ue=new Map;let Ms=null;const Bs=e=>{Ms=e},lo=()=>Ms,_=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 s=_(n);s&&(r=T.multiply(s,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 s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),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}},Ts=e=>e.strength>0&&e.distance!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Ss=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],st=(e,t)=>{if(!Ss(e))return t;const r=Ao[e.quality-1],n=Math.round(e.blurX*r),s=Math.round(e.blurY*r);return t[0]-=n,t[2]+=n,t[1]-=s,t[3]+=s,t},po=(e,t)=>{if(!Ts(e)||e.type==="inner")return t;st(e,t);const r=e.angle*cn,n=e.distance,s=Math.abs(Math.cos(r)*n),i=Math.abs(Math.sin(r)*n);return t[0]-=s,t[2]+=s,t[1]-=i,t[3]+=i,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,s=1,i=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=s,this.shadowColor=i,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 Ts(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 Ss(this)}getBounds(t){return st(this,t)}}const yo=e=>[e.$filterType,e.matrix],$o=e=>new Float32Array([e.$filterType,...e.matrix]);class sr 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 sr(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 ir extends Fe{$filterType=3;_$matrixX;_$matrixY;_$matrix;_$divisor;_$bias;_$preserveAlpha;_$clamp;_$color;_$alpha;constructor(t=0,r=0,n=null,s=1,i=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=s,this.bias=i,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 ir(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 s=0;s<r.length;s+=4096)n.push(...r.subarray(s,s+4096));return n.push(e.bitmapWidth,e.bitmapHeight,e.mapPointX,e.mapPointY,e.componentX,e.componentY,e.scaleX,e.scaleY,t,e.color,e.alpha),new Float32Array(n)};class ar extends Fe{$filterType=4;_$bitmapBuffer;_$bitmapWidth;_$bitmapHeight;_$mapPointX;_$mapPointY;_$componentX;_$componentY;_$scaleX;_$scaleY;_$mode;_$color;_$alpha;constructor(t=null,r=0,n=0,s=0,i=0,a=0,o=0,c=0,u=0,h="wrap",l=0,f=0){super(),this._$bitmapBuffer=null,this._$bitmapWidth=0,this._$bitmapHeight=0,this._$mapPointX=0,this._$mapPointY=0,this._$componentX=0,this._$componentY=0,this._$scaleX=0,this._$scaleY=0,this._$mode="wrap",this._$color=0,this._$alpha=0,this.bitmapBuffer=t,this.bitmapWidth=r,this.bitmapHeight=n,this.mapPointX=s,this.mapPointY=i,this.componentX=a,this.componentY=o,this.scaleX=c,this.scaleY=u,this.mode=h,this.color=l,this.alpha=f}get alpha(){return this._$alpha}set alpha(t){t=F(+t,0,1,0),t!==this._$alpha&&(this._$alpha=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 componentX(){return this._$componentX}set componentX(t){t!==this._$componentX&&(this._$componentX=t,this.$updated=!0)}get componentY(){return this._$componentY}set componentY(t){t!==this._$componentY&&(this._$componentY=t,this.$updated=!0)}get bitmapBuffer(){return this._$bitmapBuffer}set bitmapBuffer(t){t!==this._$bitmapBuffer&&(this._$bitmapBuffer=t,this.$updated=!0)}get bitmapWidth(){return this._$bitmapWidth}set bitmapWidth(t){t!==this._$bitmapWidth&&(this._$bitmapWidth=t,this.$updated=!0)}get bitmapHeight(){return this._$bitmapHeight}set bitmapHeight(t){t!==this._$bitmapHeight&&(this._$bitmapHeight=t,this.$updated=!0)}get mapPointX(){return this._$mapPointX}set mapPointX(t){t!==this._$mapPointX&&(this._$mapPointX=t,this.$updated=!0)}get mapPointY(){return this._$mapPointY}set mapPointY(t){t!==this._$mapPointY&&(this._$mapPointY=t,this.$updated=!0)}get mode(){return this._$mode}set mode(t){t!==this._$mode&&(this._$mode=t,this.$updated=!0)}get scaleX(){return this._$scaleX}set scaleX(t){t=F(+t,-65535,65535,0),t!==this._$scaleX&&(this._$scaleX=t,this.$updated=!0)}get scaleY(){return this._$scaleY}set scaleY(t){t=F(+t,-65535,65535,0),t!==this._$scaleY&&(this._$scaleY=t,this.$updated=!0)}clone(){return new ar(this._$bitmapBuffer?this._$bitmapBuffer.slice():null,this._$bitmapWidth,this._$bitmapHeight,this._$mapPointX,this._$mapPointX,this._$componentX,this._$componentY,this._$scaleX,this._$scaleY,this._$mode,this._$color,this._$alpha)}toArray(){return To(this)}toNumberArray(){return So(this)}canApplyFilter(){return Bo(this)}}const Io=e=>[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]),Is=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Fo=(e,t)=>{if(!Is(e)||e.inner)return t;st(e,t);const r=e.angle*cn,n=e.distance,s=Math.cos(r)*n,i=Math.sin(r)*n;return t[0]=Math.min(t[0],s),s>0&&(t[2]+=s),t[1]=Math.min(t[1],i),i>0&&(t[3]+=i),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,s=1,i=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=i,this.blurY=a,this.quality=c,this.distance=t,this.angle=r,this.color=n,this.alpha=s,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 Is(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]),Cs=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Ro=(e,t)=>!Cs(e)||e.inner?t:st(e,t);class cr extends Fe{$filterType=6;_$blurX;_$blurY;_$quality;_$color;_$alpha;_$strength;_$inner;_$knockout;constructor(t=0,r=1,n=4,s=4,i=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=s,this.quality=a,this.color=t,this.alpha=r,this.strength=i,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 Cs(this)}getBounds(t){return Ro(this,t)}}const Fs=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(!Fs(e)||e.type==="inner")return t;st(e,t);const r=e.angle*cn,n=e.distance,s=Math.abs(Math.cos(r)*n),i=Math.abs(Math.sin(r)*n);return t[0]-=s,t[2]+=s,t[1]-=i,t[3]+=i,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,s=null,i=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=s,this.ratios=i,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<t.length;++r){const n=t[r];t[r]=F(+n,0,1,0)}this._$alphas=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 colors(){return this._$colors}set colors(t){if(this._$colors!==t){if(Array.isArray(t))for(let r=0;r<t.length;++r){const n=t[r];t[r]=F(typeof n=="string"?Oe(n):n,0,16777215,0)}this._$colors=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 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 ratios(){return this._$ratios}set ratios(t){if(this._$ratios!==t){if(Array.isArray(t))for(let r=0;r<t.length;++r){const n=t[r];t[r]=F(+n,0,255,0)}this._$ratios=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){t!==this._$type&&(this._$type=t,this.$updated=!0)}clone(){return new lr(this._$distance,this._$angle,this._$colors?this._$colors.slice():null,this._$alphas?this._$alphas.slice():null,this._$ratios?this._$ratios.slice():null,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return Oo(this)}toNumberArray(){return ko(this)}canApplyFilter(){return Fs(this)}getBounds(t){return Uo(this,t)}}const Go=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],Es=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)=>!Es(e)||e.type==="inner"?t:st(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,s=null,i=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=s,this.ratios=i,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<t.length;++r){const n=t[r];t[r]=F(+n,0,1,0)}this._$alphas=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 colors(){return this._$colors}set colors(t){if(this._$colors!==t){if(Array.isArray(t))for(let r=0;r<t.length;++r){const n=t[r];t[r]=F(typeof n=="string"?Oe(n):n,0,16777215,0)}this._$colors=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 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 ratios(){return this._$ratios}set ratios(t){if(this._$ratios!==t){if(Array.isArray(t))for(let r=0;r<t.length;++r)t[r]=F(+t[r],0,255,0);this._$ratios=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){t!==this._$type&&(this._$type=t,this.$updated=!0)}clone(){return new ur(this._$distance,this._$angle,this._$colors,this._$alphas,this._$ratios,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return Go(this)}toNumberArray(){return _o(this)}canApplyFilter(){return Es(this)}getBounds(t){return Do(this,t)}}const Lo=e=>{const t=z();for(let r=0;r<e.length;++r){const n=e[r];if(n)switch(n.params[0]===null&&n.params.shift(),n.class){case"BevelFilter":t.push(new rr(...n.params));break;case"BlurFilter":t.push(new nr(...n.params));break;case"ColorMatrixFilter":t.push(new sr(...n.params));break;case"ConvolutionFilter":t.push(new ir(...n.params));break;case"DisplacementMapFilter":t.push(new ar(...n.params));break;case"DropShadowFilter":t.push(new or(...n.params));break;case"GlowFilter":t.push(new cr(...n.params));break;case"GradientBevelFilter":t.push(new lr(...n.params));break;case"GradientGlowFilter":t.push(new ur(...n.params));break}}return t},No=e=>{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 i=_(e);e.$matrix=r=i?new T(...i):new T}const n=Math.sqrt(r.a*r.a+r.b*r.b),s=Math.sqrt(r.c*r.c+r.d*r.d);if(t===0)r.a=n,r.b=0,r.c=0,r.d=s;else{let i=Math.atan2(r.b,r.a),a=Math.atan2(-r.c,r.d);const o=t*Xo;a=a+o-i,i=o,r.b=n*Math.sin(i),r.b===1||r.b===-1?r.a=0:r.a=n*Math.cos(i),r.c=-s*Math.sin(a),r.c===1||r.c===-1?r.d=0:r.d=s*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,s=Math.hypot(t[0],t[1]);return Math.round(s*n*1e4)/1e4},Ps=(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 s=_(e);e.$matrix=n=s?new T(...s):new T}if(n.b===0||isNaN(n.b))n.a=r;else{const i=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?i:i-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]),s=(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*s)*1e4)/1e4},Rs=(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 s=_(e);e.$matrix=n=s?new T(...s):new T}if(n.c===0||isNaN(n.c))n.d=r;else{const s=Math.max(0,Math.abs(r)),i=1e-12;let a=Math.atan2(n.b,n.a);(n.a<0||Math.abs(n.a)<i&&n.b<0)&&(a-=Math.PI),a<=-Math.PI&&(a+=2*Math.PI),a>Math.PI&&(a-=2*Math.PI);const o=a+(r<0?Math.PI:0);n.c=-s*Math.sin(o),n.d=s*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,s)=>{const i=s[0],a=s[1],o=s[2],c=s[3],u=s[4],h=s[5],l=r*i+n*o+u,f=r*i+t*o+u,A=e*i+n*o+u,d=e*i+t*o+u,y=r*a+n*c+h,m=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,m,p,$),Math.max(l,f,A,d),Math.max(y,m,p,$))},Os=e=>{const t=e.graphics;return re(t.xMin,t.yMin,t.xMax,t.yMax)},wt=(e,t=null)=>{const r=Os(e),n=_(e);if(!n){if(t){const i=he(r[0],r[1],r[2],r[3],t);return k(r),i}return r}const s=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),s},ks=e=>re(0,0,e.videoWidth,e.videoHeight),Mt=(e,t=null)=>{const r=ks(e),n=_(e);if(!n){if(t){const i=he(r[0],r[1],r[2],r[3],t);return k(r),i}return r}const s=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),s},Us=e=>re(e.xMin,e.yMin,e.xMax,e.yMax),Bt=(e,t=null)=>{const r=Us(e),n=_(e);if(!n){if(t){const i=he(r[0],r[1],r[2],r[3],t);return k(r),i}return r}const s=he(r[0],r[1],r[2],r[3],t?T.multiply(t,n):n);return k(r),s},yt=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),s=n?t?T.multiply(t,n):n:t,i=Number.MAX_VALUE;let a=i,o=-i,c=i,u=-i;for(let h=0;h<r.length;h++){const l=r[h];if(!l.visible)continue;let f=null;switch(!0){case l.isContainerEnabled:f=yt(l,s);break;case l.isShape:f=wt(l,s);break;case l.isText:f=Bt(l,s);break;case l.isVideo:f=Mt(l,s);break}f&&(a=Math.min(a,f[0]),c=Math.min(c,f[1]),o=Math.max(o,f[2]),u=Math.max(u,f[3]),k(f))}return re(a,c,o,u)},Gs=e=>{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=Gs(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}},_s=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e);let s=t;n&&(s=t?T.multiply(t,n):n);const i=Number.MAX_VALUE;let a=i,o=-i,c=i,u=-i;for(let h=0;h<r.length;h++){const l=r[h];if(!l.visible)continue;let f=null;switch(!0){case l.isContainerEnabled:f=_s(l,s);break;case l.isShape:f=wt(l,s);break;case l.isText:f=Bt(l,s);break;case l.isVideo:f=Mt(l,s);break}f&&(a=Math.min(a,f[0]),c=Math.min(c,f[1]),o=Math.max(o,f[2]),u=Math.max(u,f[3]),k(f))}return re(a,c,o,u)},tt=e=>{switch(!0){case e.isContainerEnabled:return _s(e);case e.isShape:return Os(e);case e.isText:return Us(e);case e.isVideo:return ks(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}Ps(e,t/n)},nc=(e,t)=>{const r=e.concatenatedMatrix,n=new ie(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,t)=>{const r=e.concatenatedMatrix;r.invert();const n=new ie(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=>{const t=Gs(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}Rs(e,t/n)},oc=e=>{const t=e.parent;t&&t.removeChild(e)},cc=(e,t=null)=>{const r=e.concatenatedMatrix,n=tt(e),s=he(n[0],n[1],n[2],n[3],r.rawData);if(k(n),T.release(r.rawData),!t){const c=new be(s[0],s[1],Math.abs(s[2]-s[0]),Math.abs(s[3]-s[1]));return k(s),c}const i=t.concatenatedMatrix;i.invert();const a=he(s[0],s[1],s[2],s[3],i.rawData);k(s),T.release(i.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,s=he(r[0],r[1],r[2],r[3],n.rawData);k(r),T.release(n.rawData);const i=tt(t),a=t.concatenatedMatrix,o=he(i[0],i[1],i[2],i[3],a.rawData);k(i),T.release(a.rawData);const c=Math.max(s[0],o[0]),u=Math.max(s[1],o[1]),h=Math.min(s[2],o[2]),l=Math.min(s[3],o[3]);return k(s),k(o),h-c>=0&&l-u>=0};class Xt{_$bitmapData;_$matrix;_$repeat;_$smooth;constructor(t,r=null,n=!0,s=!1){this._$bitmapData=t,this._$matrix=r,this._$repeat=n,this._$smooth=s}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,s,i=null,a="pad",o="rgb",c=0){this._$type=t,this._$colors=r,this._$alphas=n,this._$ratios=s,this._$matrix=i,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<t;++r){const n=this._$colors[r],s=typeof n=="string"?Or(n):n;this._$colorStops[r]={ratio:this._$ratios[r]/255,R:s>>>16&255,G:s>>>8&255,B:s&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,s=0,i=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,s)),e.yMax=Math.max(e.yMax,Math.max(r,s));const o=n-t,c=s-r,u=Math.sqrt(o*o+c*c);if(!u)return;const h=o/u,l=c/u,f=-l,A=h,d=i/2,y=Math.min(t+f*d,t-f*d,n+f*d,n-f*d),m=Math.max(t+f*d,t-f*d,n+f*d,n-f*d),p=Math.min(r+A*d,r-A*d,s+A*d,s-A*d),$=Math.max(r+A*d,r-A*d,s+A*d,s-A*d);if(e.xMin=Math.min(e.xMin,y),e.xMax=Math.max(e.xMax,m),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,s=0,i="none",...a)=>{for(let o=0;o<a.length;){const c=a[o++],u=a[o++];uc(e,c,u),t&&(Rn(e,c,u,r,n,s,i),Rn(e,r,n,c,u,s,i))}},ct=(e,t,r,n,s,...i)=>{e.isConfirmed=!1,t&&n&&n.push(...i),r&&s&&s.push(...i)},hc=(e,t,r,n,s)=>{t=+t||0,r=+r||0,n=+n||0,s=+s||0,n=Math.round(n),s=Math.round(s);const i=n/2,a=s/2,o=t+i,c=r+a,u=t+n,h=r+s,l=4/3*(Math.SQRT2-1),f=l*i,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,s)=>{t=+t||0,r=+r||0,n=+n||0,s=+s||0;const i=Math.round(t+n),a=Math.round(r+s);return e.moveTo(t,r).lineTo(t,a).lineTo(i,a).lineTo(i,r).lineTo(t,r)},dc=(e,t,r,n,s,i,a=NaN)=>{t=+t||0,r=+r||0,n=+n||0,s=+s||0,i=+i||0,a=+a||i,n=Math.round(n),s=Math.round(s),i=Math.round(i),a=Math.round(a);const o=i/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,m=r+s,p=m-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,m,d,m).lineTo(f,m).cubicCurveTo(f-h,m,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;r<e.length;){const n=e[r++];switch(t.push(n),n){case M.BEGIN_PATH:case M.END_FILL:case M.END_STROKE:case M.CLOSE_PATH:break;case M.MOVE_TO:case M.LINE_TO:t.push(e[r++],e[r++]);break;case M.CURVE_TO:case M.FILL_STYLE:t.push(e[r++],e[r++],e[r++],e[r++]);break;case M.CUBIC:t.push(e[r++],e[r++],e[r++],e[r++],e[r++],e[r++]);break;case M.STROKE_STYLE:{switch(t.push(e[r++]),e[r++]){case"none":t.push(0);break;case"round":t.push(1);break;case"square":t.push(2);break;default:t.push(0);break}switch(e[r++]){case"bevel":t.push(0);break;case"miter":t.push(1);break;case"round":t.push(2);break;default:t.push(2);break}t.push(e[r++],e[r++],e[r++],e[r++],e[r++])}break;case M.ARC:t.push(e[r++],e[r++],e[r++]);break;case M.GRADIENT_FILL:{const s=e[r++],i=e[r++],a=e[r++],o=e[r++],c=e[r++],u=e[r++];t.push(s==="linear"?0:1),t.push(i.length);const h=i.sort((l,f)=>l.ratio-f.ratio);for(let l=0;l<h.length;++l){const f=h[l];t.push(f.ratio,f.R,f.G,f.B,f.A)}switch(t.push(...a),o){case"reflect":t.push(0);break;case"repeat":t.push(1);break;default:t.push(2);break}t.push(c==="linearRGB"?0:1),t.push(u)}break;case M.GRADIENT_STROKE:{switch(t.push(e[r++]),e[r++]){case"none":t.push(0);break;case"round":t.push(1);break;case"square":t.push(2);break;default:t.push(0);break}switch(e[r++]){case"bevel":t.push(0);break;case"miter":t.push(1);break;case"round":t.push(2);break;default:t.push(2);break}t.push(e[r++]);const a=e[r++],o=e[r++],c=e[r++],u=e[r++],h=e[r++],l=e[r++];t.push(a==="linear"?0:1),t.push(o.length);for(let f=0;f<o.length;++f){const A=o[f];t.push(A.ratio,A.R,A.G,A.B,A.A)}switch(t.push(...c),u){case"reflect":t.push(0);break;case"repeat":t.push(1);break;default:t.push(2);break}t.push(h==="linearRGB"?0:1),t.push(l)}break;case M.BITMAP_FILL:{const s=e[r++],i=s.buffer;if(!i){r+=3;break}t.push(s.width,s.height,i.length);for(let u=0;u<i.length;u+=4096)t.push(...i.subarray(u,u+4096));const a=e[r++];a?t.push(...a.rawData):t.push(1,0,0,1,0,0);const o=e[r++];t.push(o?1:0);const c=e[r++];t.push(c?1:0)}break;case M.BITMAP_STROKE:{switch(t.push(e[r++]),e[r++]){case"none":t.push(0);break;case"round":t.push(1);break;case"square":t.push(2);break;default:t.push(0);break}switch(e[r++]){case"bevel":t.push(0);break;case"miter":t.push(1);break;case"round":t.push(2);break;default:t.push(2);break}t.push(e[r++]);const a=e[r++],o=a.buffer;if(!o){r+=3;break}t.push(a.width,a.height,o.length);for(let l=0;l<o.length;l+=4096)t.push(...o.subarray(l,l+4096));const c=e[r++];c?t.push(...c.rawData):t.push(1,0,0,1,0,0);const u=e[r++];t.push(u?1:0);const h=e[r++];t.push(h?1:0)}break}}return t};class M{isConfirmed;xMin;yMin;xMax;yMax;$recodes;_$buffer;_$maxAlpha;_$isBeginning;_$positionX;_$positionY;_$hasFillEnabled;_$fillType;_$fillColor;_$fillGradient;_$fillBitmap;_$fills;_$hasLineEnabled;_$lineType;_$lineColor;_$lineGradient;_$joints;_$miterLimit;_$caps;_$lineWidth;_$lines;constructor(){this.isConfirmed=!1,this.xMin=Number.MAX_VALUE,this.yMin=Number.MAX_VALUE,this.xMax=-Number.MAX_VALUE,this.yMax=-Number.MAX_VALUE,this.$recodes=null,this._$buffer=null,this._$positionX=0,this._$positionY=0,this._$maxAlpha=0,this._$isBeginning=!1,this._$fills=null,this._$hasFillEnabled=!1,this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillColor=0,this._$caps="none",this._$lineWidth=1,this._$lines=null,this._$hasLineEnabled=!1,this._$lineType=0,this._$lineGradient=null,this._$joints="round",this._$miterLimit=0,this._$lineColor=0}static get MOVE_TO(){return 0}static get CURVE_TO(){return 1}static get LINE_TO(){return 2}static get CUBIC(){return 3}static get ARC(){return 4}static get FILL_STYLE(){return 5}static get STROKE_STYLE(){return 6}static get END_FILL(){return 7}static get END_STROKE(){return 8}static get BEGIN_PATH(){return 9}static get GRADIENT_FILL(){return 10}static get GRADIENT_STROKE(){return 11}static get CLOSE_PATH(){return 12}static get BITMAP_FILL(){return 13}static get BITMAP_STROKE(){return 14}get isDrawable(){if(!this._$isBeginning||!this._$maxAlpha)return!1;const t=Math.abs(this.xMax-this.xMin),r=Math.abs(this.yMax-this.yMin);return t>0&&r>0}beginBitmapFill(t,r=null,n=!0,s=!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,s),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,s=t>>>8&255,i=t&255;return this._$fillColor=n<<24|s<<16|i<<8|r*255,this}beginGradientFill(t,r,n,s,i=null,a="pad",o="rgb",c=0){this._$hasFillEnabled&&this.endFill(),this._$fills||(this._$fills=z());for(let u=0;u<n.length;++u)this._$maxAlpha=Math.max(this._$maxAlpha,n[u]);return this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(M.BEGIN_PATH),this._$fillType=M.GRADIENT_FILL,this._$fillGradient=new zt(t,r,n,s,i,a,o,c),this}clear(){return this._$maxAlpha=0,this._$isBeginning=!1,this._$positionX=0,this._$positionY=0,this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillColor=0,this._$hasFillEnabled=!1,this._$caps="none",this._$lineWidth=1,this._$lineType=0,this._$lineGradient=null,this._$joints="round",this._$miterLimit=0,this._$lineColor=0,this._$hasLineEnabled=!1,this.xMin=Number.MAX_VALUE,this.xMax=-Number.MAX_VALUE,this.yMin=Number.MAX_VALUE,this.yMax=-Number.MAX_VALUE,this.$recodes&&oe(this.$recodes),this._$fills&&oe(this._$fills),this._$lines&&oe(this._$lines),this._$buffer=null,this.$recodes=null,this._$fills=null,this._$lines=null,this}clone(){const t=new M;return t.copyFrom(this),t}copyFrom(t){t._$fillGradient&&(this._$fillGradient=t._$fillGradient.clone()),t._$fillBitmap&&(this._$fillBitmap=t._$fillBitmap.clone()),this._$hasFillEnabled=t._$hasFillEnabled,this._$fillType=t._$fillType,this._$fillColor=t._$fillColor,t._$lineGradient&&(this._$lineGradient=t._$lineGradient.clone()),this._$hasLineEnabled=t._$hasLineEnabled,this._$lineType=t._$lineType,this._$caps=t._$caps,this._$joints=t._$joints,this._$miterLimit=t._$miterLimit,this._$lineWidth=t._$lineWidth,this._$lineColor=t._$lineColor,this.xMin=t.xMin,this.xMax=t.xMax,this.yMin=t.yMin,this.yMax=t.yMax,this._$maxAlpha=t._$maxAlpha,this._$positionX=t._$positionX,this._$positionY=t._$positionY,this._$isBeginning=t._$isBeginning,t._$fills&&(this._$fills=t._$fills.slice(0)),t._$lines&&(this._$lines=t._$lines.slice(0)),t.$recodes&&(this.$recodes=t.$recodes.slice(0)),this._$buffer=null}cubicCurveTo(t,r,n,s,i,a){return i=+i||0,a=+a||0,this._$positionX===i&&this._$positionY===a?this:(t=+t||0,r=+r||0,n=+n||0,s=+s||0,ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r,n,s,i,a),ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.CUBIC,t,r,n,s,i,a),this._$positionX=i,this._$positionY=a,this)}curveTo(t,r,n,s){return n=+n||0,s=+s||0,this._$positionX===n&&this._$positionY===s?this:(t=+t||0,r=+r||0,ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,r,n,s),ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.CURVE_TO,t,r,n,s),this._$positionX=n,this._$positionY=s,this)}drawCircle(t,r,n){return t=+t||0,r=+r||0,n=+n||0,n=Math.round(n),ot(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t-n,r-n,t+n,r+n),ct(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,M.MOVE_TO,t+n,r,M.ARC,t,r,n),this._$positionX=t,this._$positionY=r,this}drawEllipse(t,r,n,s){return hc(this,t,r,n,s)}drawRect(t,r,n,s){return fc(this,t,r,n,s)}drawRoundRect(t,r,n,s,i,a=NaN){return dc(this,t,r,n,s,i,a)}endFill(){if(!this._$hasFillEnabled||!this._$fills||8>this._$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,s=!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,s),this):this}lineGradientStyle(t,r,n,s,i=null,a="pad",o="rgb",c=0){if(!this._$hasLineEnabled)return this;this._$lines||(this._$lines=z());for(let u=0;u<n.length;++u)this._$maxAlpha=Math.max(this._$maxAlpha,n[u]);return this._$lines.push(M.BEGIN_PATH),this._$lineType=M.GRADIENT_STROKE,this._$lineGradient=new zt(t,r,n,s,i,a,o,c),this}lineStyle(t=1,r=0,n=1,s="round",i="round",a=3){this._$hasLineEnabled&&this.endLine(),this._$lines||(this._$lines=z()),this._$maxAlpha=Math.max(this._$maxAlpha,n),this._$hasLineEnabled=!0,this._$isBeginning=!0,this._$positionX||this._$positionY?this._$lines.push(M.BEGIN_PATH,M.MOVE_TO,this._$positionX,this._$positionY):this._$lines.push(M.BEGIN_PATH),this._$lineType=M.STROKE_STYLE,typeof r=="string"&&(r=Or(r)),r=me(r,0,16777215,0),n=me(n,0,1,1);const o=r>>>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=`${s}`,this._$joints=`${i}`,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<t.length;)switch(t[n++]){case M.BEGIN_PATH:e.beginPath();break;case M.MOVE_TO:e.moveTo(t[n++],t[n++]);break;case M.LINE_TO:e.lineTo(t[n++],t[n++]);break;case M.CURVE_TO:e.quadraticCurveTo(t[n++],t[n++],t[n++],t[n++]);break;case M.FILL_STYLE:n+=4;continue;case M.END_FILL:if(e.isPointInPath(r.x,r.y))return!0;break;case M.STROKE_STYLE:n+=8;continue;case M.END_STROKE:break;case M.CLOSE_PATH:e.closePath();break;case M.CUBIC:e.bezierCurveTo(t[n++],t[n++],t[n++],t[n++],t[n++],t[n++]);break;case M.ARC:e.arc(t[n++],t[n++],t[n++],0,2*Math.PI);break;case M.GRADIENT_FILL:if(e.isPointInPath(r.x,r.y))return!0;n+=6;continue;case M.GRADIENT_STROKE:n+=12;continue;case M.BITMAP_FILL:if(e.isPointInPath(r.x,r.y))return!0;n+=6;continue;case M.BITMAP_STROKE:n+=9;continue}return!1},Nt=(e,t,r,n)=>{const s=e.graphics,i=s.xMax-s.xMin,a=s.yMax-s.yMin;if(i<=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 s.buffer.length?u=Ac(t,s.buffer,n):(t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,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 s=Math.ceil(Math.abs(e.xMax-e.xMin)),i=Math.ceil(Math.abs(e.yMax-e.yMin));if(s<=0||i<=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(s,0),t.lineTo(s,i),t.lineTo(0,i),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},Wt=(e,t,r,n)=>{const s=e.videoWidth,i=e.videoHeight;if(s<=0||i<=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(s,0),t.lineTo(s,i),t.lineTo(0,i),t.lineTo(0,0),o!==r&&T.release(o),t.isPointInPath(n.x,n.y)},He=(e,t,r,n,s=!0)=>{const i=e.children;if(!i.length)return!1;const a=_(e),o=a?T.multiply(r,a):r,c=z(),u=z(),h=so();let l=0,f=0;for(let m=0;m<i.length;++m){const p=i[m];if(p&&!p.isMask){if(p.clipDepth){f=c.length,l=p.clipDepth,c.push(p);continue}p.visible&&(l&&p.placeId>l&&(f=0,l=0),f&&h.set(p.instanceId,f),u.push(p))}}const A=e.mouseChildren&&s;if(e.isSprite&&e.hitArea&&e.hitArea.isSprite){const m=He(e.hitArea,t,o,n,A);return m&&A&&e.mouseEnabled&&((e.isTimelineEnabled||e.buttonMode&&e.useHandCursor)&&(n.pointer="pointer"),n.hit||(n.hit=e)),m}let d=!1;const y=e.mask;if(y){let m=!1;switch(!0){case y.isContainerEnabled:m=He(y,t,o,n,A);break;case y.isShape:m=Nt(y,t,o,n);break;case y.isText:m=Yt(y,t,o,n);break;case y.isVideo:m=Wt(y,t,o,n);break}if(!m)return!1}for(;u.length;){const m=u.pop();if(!m||m.isMask)continue;if(h.has(m.instanceId)){const $=h.get(m.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 m.isContainerEnabled:p=He(m,t,o,n,A);break;case m.isShape:p=Nt(m,t,o,n);break;case m.isText:p=Yt(m,t,o,n);break;case m.isVideo:p=Wt(m,t,o,n);break}if(p){if(d=!0,!A)break;if(m.isInteractive&&m.mouseEnabled){if(n.pointer==="auto")switch(!0){case m.isText:m.type==="input"&&(n.pointer="text");break;case m.isSprite:(m.isTimelineEnabled||m.buttonMode&&m.useHandCursor)&&(n.pointer="pointer");break;default:n.pointer="pointer";break}n.hit||(n.hit=m);break}}}return oe(c),oe(u),io(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 s=tt(e),i=_(e),a=he(s[0],s[1],s[2],s[3],i||xt);k(s);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 ie(t,r)):new ie(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=ys(),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 ic(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){Ps(this,t)}get scaleY(){return this.$scaleY===null?Jo(this):this.$scaleY}set scaleY(t){Rs(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 sc(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 Ds=e=>{const t=e.children;for(let r=0;r<t.length;++r){const n=t[r];n&&(we.set(n,e.root),ge.add(n.instanceId),n.isContainerEnabled&&Ds(n))}},Ls=e=>{e.$addedToStage||!ge.has(e.instanceId)||(e.$addedToStage=!0,e.willTrigger(x.ADDED_TO_STAGE)&&e.dispatchEvent(new x(x.ADDED_TO_STAGE)))},Ns=e=>{const t=e.children;for(let r=0;r<t.length;++r){const n=t[r];n&&(Ls(n),n.isContainerEnabled&&Ns(n))}},bc=e=>{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 s=e.children;return 0>r?s.push(t):s.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&&Ds(t)),bc(t),ge.has(e.instanceId)&&(Ls(t),t.isContainerEnabled&&Ns(t)),j(t),t},Ys=e=>{const t=e.children;for(let r=0;r<t.length;++r){const n=t[r];n&&(we.delete(n),ge.delete(n.instanceId),n.isVideo&&n.pause(),n.isContainerEnabled&&Ys(n))}},xc=e=>{e.$added&&(e.$added=!1,e.willTrigger(x.REMOVED)&&e.dispatchEvent(new x(x.REMOVED,!0)))},Ws=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<t.length;++r){const n=t[r];n&&(Ws(n),n.isContainerEnabled&&un(n))}},hn=(e,t)=>{const r=t.parent;if(r&&r.instanceId!==e.instanceId)return;const n=e.children,s=n.indexOf(t);s>-1&&n.splice(s,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)&&(Ws(t),t.isContainerEnabled&&un(t)),ge.has(e.instanceId)&&(we.delete(t),ge.delete(t.instanceId),t.isVideo&&t.pause(),t.isContainerEnabled&&Ys(t)),t.parent=null,j(e)},Vs=(e,t)=>{const r=e.children;return t in r?r[t]:null},yc=(e,t)=>{const r=Vs(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<r.length;++n){const s=r[n];if(s){if(s.instanceId===t.instanceId)return!0;if(s.isContainerEnabled&&s.contains(t))return!0}}return!1},vc=(e,t)=>{if(!t)return null;const r=e.children;for(let n=0;n<r.length;++n){const s=r[n];if(!(!s.name||s.name!==t))return s}return null},wc=(e,t)=>{const r=e.children.slice();if(r.length)for(let n=0;n<t.length;n++){const s=t[n],i=r[s];i&&hn(e,i)}},Mc=(e,t,r)=>{const n=e.getChildIndex(t);if(n===-1||n===r)return;const s=e.children;s.splice(n,1),s.splice(r,0,t),j(e)},Bc=(e,t,r)=>{const n=e.getChildIndex(t),s=e.getChildIndex(r);if(n===-1||s===-1)return;const i=e.children;i[n]=r,i[s]=t,j(e)},Tc=(e,t,r)=>{const n=e.children,s=n[t],i=n[r];!s||!i||(n[t]=i,n[r]=s,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 Vs(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 Ks 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=ys(),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,Bs(e)},Cc=e=>{e.$lockCenter=!1,e.$offsetX=0,e.$offsetY=0,e.$boundedRect=null,Bs(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 Qs=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)},Xs=(e,t,r,n)=>{Qs(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,s=r.height,i=O.getCanvas();i.width=n,i.height=s;const a=i.getContext("2d",{willReadFrequently:!0});a.drawImage(r,0,0,n,s),Xs(e,n,s,new Uint8Array(a.getImageData(0,0,n,s).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)),s=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&&s===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,s)}}break;case t.inBitmap:{e.isBitmap=!0;const i=t.recodes,a=i[i.length-4];if(n===a.width&&s===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,s)}}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(){Qs(this)}setBitmapBuffer(t,r,n){Xs(this,t,r,n)}$sync(t,r=null){r&&super.$syncLoaderInfo(r),Ec(this,t)}}let zs=null;const kn=e=>{zs=e},ke=()=>zs,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 Hs=0;const Et=()=>Hs,dt=e=>{Hs=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 s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),r)};let Js;const Ht=()=>Js,Zs=e=>{Js=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,s=null,i=null,a=null,o=null,c=null,u=null,h=null,l=null){this.font=t,this.size=r,this.color=n,this.bold=s,this.italic=i,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"),s=r.G.toString(16).padStart(2,"0"),i=r.B.toString(16).padStart(2,"0");t+=`color: #${n}${s}${i};`}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<this.widthTable.length;++t)this._$textWidth=Math.max(this._$textWidth,this.widthTable[t]);return this._$textWidth}get textHeight(){if(this._$textHeight!==-1)return this._$textHeight;this._$textHeight=0;for(let t=0;t<this.heightTable.length;++t)this._$textHeight+=this.heightTable[t];return this._$textHeight}getLineWidth(t){return t in this.widthTable?this.widthTable[t]:0}getLineHeight(t){return t in this.heightTable?this.heightTable[t]:0}clear(){this._$textWidth=-1,this._$textHeight=-1,this.widthTable.length=0,this.heightTable.length=0,this.ascentTable.length=0,this.textTable.length=0,this.lineTable.length=0}}var Ir;const _c=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),Un=(Ir=String.fromCodePoint)!==null&&Ir!==void 0?Ir:(e=>{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 qs(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 s=0,i=0;s<r;s+=2){const a=t.charCodeAt(s),o=t.charCodeAt(s+1);n[i++]=a|o<<8}return n}const Lc=qs("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZABlADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcwCgLCFhAJJjcgAA4DXYBd1wAGYAAOA12Dnd5SF2ZdhiYwDyAOoAbSJwZXEAAKBOIgAHSE9hY2RlZmhpbG9yc3UXARoBHwE6AVIBVQFiAWQBZgGCAakB6QHtAfIBYwB5ACdkUABZADuAqQCpQIABY3B5ACUBKAE1AfUhdGUGYWmg0iJ0KGFsRGlmZmVyZW50aWFsRAAAoEUhbCJleXMAAKAtIQACYWVpb0EBRAFKAU0B8iFvbgxhZABpAGwAO4DHAMdAcgBjAAhhbiJpbnQAAKAwIm8AdAAKYQABZG5ZAV0BaSJsbGEAuGB0I2VyRG90ALdg8gA5AWkAp2NyImNsZQAAAkRNUFRwAXQBeQF9AW8AdAAAoJkiaSJudXMAAKCWIuwhdXMAoJUiaSJtZXMAAKCXIm8AAAFjc4cBlAFrKndpc2VDb250b3VySW50ZWdyYWwAAKAyImUjQ3VybHkAAAFEUZwBpAFvJXVibGVRdW90ZQAAoB0gdSJvdGUAAKAZIAACbG5wdbABtgHNAdgBbwBuAGWgNyIAoHQqgAFnaXQAvAHBAcUB8iJ1ZW50AKBhIm4AdAAAoC8i7yV1ckludGVncmFsAKAuIgABZnLRAdMBAKACIe8iZHVjdACgECJuLnRlckNsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbAAAoDMi7yFzcwCgLypjAHIAAOA12J7ccABDoNMiYQBwAACgTSKABURKU1phY2VmaW9zAAsCEgIVAhgCGwIsAjQCOQI9AnMCfwNvoEUh9CJyYWhkAKARKWMAeQACZGMAeQAFZGMAeQAPZIABZ3JzACECJQIoAuchZXIAoCEgcgAAoKEhaAB2AACg5CoAAWF5MAIzAvIhb24OYRRkbAB0oAciYQCUY3IAAOA12AfdAAFhZkECawIAAWNtRQJnAvIjaXRpY2FsAAJBREdUUAJUAl8CYwJjInV0ZQC0YG8AdAFZAloC2WJiJGxlQWN1dGUA3WJyImF2ZQBgYGkibGRlANxi7yFuZACgxCJmJWVyZW50aWFsRAAAoEYhcAR9AgAAAAAAAIECjgIAABoDZgAA4DXYO91EoagAhQKJAm8AdAAAoNwgcSJ1YWwAAKBQIuIhbGUAA0NETFJVVpkCqAK1Au8C/wIRA28AbgB0AG8AdQByAEkAbgB0AGUAZwByAGEA7ADEAW8AdAKvAgAAAACwAqhgbiNBcnJvdwAAoNMhAAFlb7kC0AJmAHQAgAFBUlQAwQLGAs0CciJyb3cAAKDQIekkZ2h0QXJyb3cAoNQhZQDlACsCbgBnAAABTFLWAugC5SFmdAABQVLcAuECciJyb3cAAKD4J+kkZ2h0QXJyb3cAoPon6SRnaHRBcnJvdwCg+SdpImdodAAAAUFU9gL7AnIicm93AACg0iFlAGUAAKCoInAAQQIGAwAAAAALA3Iicm93AACg0SFvJHduQXJyb3cAAKDVIWUlcnRpY2FsQmFyAACgJSJuAAADQUJMUlRhJAM2AzoDWgNxA3oDciJyb3cAAKGTIUJVLAMwA2EAcgAAoBMpcCNBcnJvdwAAoPUhciJldmUAEWPlIWZ00gJDAwAASwMAAFIDaSVnaHRWZWN0b3IAAKBQKWUkZVZlY3RvcgAAoF4p5SJjdG9yQqC9IWEAcgAAoFYpaSJnaHQA1AFiAwAAaQNlJGVWZWN0b3IAAKBfKeUiY3RvckKgwSFhAHIAAKBXKWUAZQBBoKQiciJyb3cAAKCnIXIAcgBvAPcAtAIAAWN0gwOHA3IAAOA12J/c8iFvaxBhAAhOVGFjZGZnbG1vcHFzdHV4owOlA6kDsAO/A8IDxgPNA9ID8gP9AwEEFAQeBCAEJQRHAEphSAA7gNAA0EBjAHUAdABlADuAyQDJQIABYWl5ALYDuQO+A/Ihb24aYXIAYwA7gMoAykAtZG8AdAAWYXIAAOA12AjdcgBhAHYAZQA7gMgAyEDlIm1lbnQAoAgiAAFhcNYD2QNjAHIAEmF0AHkAUwLhAwAAAADpA20lYWxsU3F1YXJlAACg+yVlJ3J5U21hbGxTcXVhcmUAAKCrJQABZ3D2A/kDbwBuABhhZgAA4DXYPN3zImlsb26VY3UAAAFhaQYEDgRsAFSgdSppImxkZQAAoEIi7CNpYnJpdW0AoMwhAAFjaRgEGwRyAACgMCFtAACgcyphAJdjbQBsADuAywDLQAABaXApBC0E8yF0cwCgAyLvJG5lbnRpYWxFAKBHIYACY2Zpb3MAPQQ/BEMEXQRyBHkAJGRyAADgNdgJ3WwibGVkAFMCTAQAAAAAVARtJWFsbFNxdWFyZQAAoPwlZSdyeVNtYWxsU3F1YXJlAACgqiVwA2UEAABpBAAAAABtBGYAAOA12D3dwSFsbACgACLyI2llcnRyZgCgMSFjAPIAcQQABkpUYWJjZGZnb3JzdIgEiwSOBJMElwSkBKcEqwStBLIE5QTqBGMAeQADZDuAPgA+QO0hbWFkoJMD3GNyImV2ZQAeYYABZWl5AJ0EoASjBOQhaWwiYXIAYwAcYRNkbwB0ACBhcgAA4DXYCt0AoNkicABmAADgNdg+3eUiYXRlcgADRUZHTFNUvwTIBM8E1QTZBOAEcSJ1YWwATKBlIuUhc3MAoNsidSRsbEVxdWFsAACgZyJyI2VhdGVyAACgoirlIXNzAKB3IuwkYW50RXF1YWwAoH4qaSJsZGUAAKBzImMAcgAA4DXYotwAoGsiAARBYWNmaW9zdfkE/QQFBQgFCwUTBSIFKwVSIkRjeQAqZAABY3QBBQQFZQBrAMdiXmDpIXJjJGFyAACgDCFsJWJlcnRTcGFjZQAAoAsh8AEYBQAAGwVmAACgDSHpJXpvbnRhbExpbmUAoAAlAAFjdCYFKAXyABIF8iFvayZhbQBwAEQBMQU5BW8AdwBuAEgAdQBtAPAAAAFxInVhbAAAoE8iAAdFSk9hY2RmZ21ub3N0dVMFVgVZBVwFYwVtBXAFcwV6BZAFtgXFBckFzQVjAHkAFWTsIWlnMmFjAHkAAWRjAHUAdABlADuAzQDNQAABaXlnBWwFcgBjADuAzgDOQBhkbwB0ADBhcgAAoBEhcgBhAHYAZQA7gMwAzEAAoREhYXB/BYsFAAFjZ4MFhQVyACphaSNuYXJ5SQAAoEghbABpAGUA8wD6AvQBlQUAAKUFZaAsIgABZ3KaBZ4F8iFhbACgKyLzI2VjdGlvbgCgwiJpI3NpYmxlAAABQ1SsBbEFbyJtbWEAAKBjIGkibWVzAACgYiCAAWdwdAC8Bb8FwwVvAG4ALmFmAADgNdhA3WEAmWNjAHIAAKAQIWkibGRlAChh6wHSBQAA1QVjAHkABmRsADuAzwDPQIACY2Zvc3UA4QXpBe0F8gX9BQABaXnlBegFcgBjADRhGWRyAADgNdgN3XAAZgAA4DXYQd3jAfcFAAD7BXIAAOA12KXc8iFjeQhk6yFjeQRkgANISmFjZm9zAAwGDwYSBhUGHQYhBiYGYwB5ACVkYwB5AAxk8CFwYZpjAAFleRkGHAbkIWlsNmEaZHIAAOA12A7dcABmAADgNdhC3WMAcgAA4DXYptyABUpUYWNlZmxtb3N0AD0GQAZDBl4GawZkB2gHcAd0B80H2gdjAHkACWQ7gDwAPECAAmNtbnByAEwGTwZSBlUGWwb1IXRlOWHiIWRhm2NnAACg6ifsI2FjZXRyZgCgEiFyAACgniGAAWFleQBkBmcGagbyIW9uPWHkIWlsO2EbZAABZnNvBjQHdAAABUFDREZSVFVWYXKABp4GpAbGBssG3AYDByEHwQIqBwABbnKEBowGZyVsZUJyYWNrZXQAAKDoJ/Ihb3cAoZAhQlKTBpcGYQByAACg5CHpJGdodEFycm93AKDGIWUjaWxpbmcAAKAII28A9QGqBgAAsgZiJWxlQnJhY2tldAAAoOYnbgDUAbcGAAC+BmUkZVZlY3RvcgAAoGEp5SJjdG9yQqDDIWEAcgAAoFkpbCJvb3IAAKAKI2kiZ2h0AAABQVbSBtcGciJyb3cAAKCUIeUiY3RvcgCgTikAAWVy4AbwBmUAAKGjIkFW5gbrBnIicm93AACgpCHlImN0b3IAoFopaSNhbmdsZQBCorIi+wYAAAAA/wZhAHIAAKDPKXEidWFsAACgtCJwAIABRFRWAAoHEQcYB+8kd25WZWN0b3IAoFEpZSRlVmVjdG9yAACgYCnlImN0b3JCoL8hYQByAACgWCnlImN0b3JCoLwhYQByAACgUilpAGcAaAB0AGEAcgByAG8A9wDMAnMAAANFRkdMU1Q/B0cHTgdUB1gHXwfxJXVhbEdyZWF0ZXIAoNoidSRsbEVxdWFsAACgZiJyI2VhdGVyAACgdiLlIXNzAKChKuwkYW50RXF1YWwAoH0qaSJsZGUAAKByInIAAOA12A/dZaDYIuYjdGFycm93AKDaIWkiZG90AD9hgAFucHcAege1B7kHZwAAAkxSbHKCB5QHmwerB+UhZnQAAUFSiAeNB3Iicm93AACg9SfpJGdodEFycm93AKD3J+kkZ2h0QXJyb3cAoPYn5SFmdAABYXLcAqEHaQBnAGgAdABhAHIAcgBvAPcA5wJpAGcAaAB0AGEAcgByAG8A9wDuAmYAAOA12EPdZQByAAABTFK/B8YHZSRmdEFycm93AACgmSHpJGdodEFycm93AKCYIYABY2h0ANMH1QfXB/IAWgYAoLAh8iFva0FhAKBqIgAEYWNlZmlvc3XpB+wH7gf/BwMICQgOCBEIcAAAoAUpeQAcZAABZGzyB/kHaSR1bVNwYWNlAACgXyBsI2ludHJmAACgMyFyAADgNdgQ3e4jdXNQbHVzAKATInAAZgAA4DXYRN1jAPIA/gecY4AESmFjZWZvc3R1ACEIJAgoCDUIgQiFCDsKQApHCmMAeQAKZGMidXRlAENhgAFhZXkALggxCDQI8iFvbkdh5CFpbEVhHWSAAWdzdwA7CGEIfQjhInRpdmWAAU1UVgBECEwIWQhlJWRpdW1TcGFjZQAAoAsgaABpAAABY25SCFMIawBTAHAAYQBjAOUASwhlAHIAeQBUAGgAaQDuAFQI9CFlZAABR0xnCHUIcgBlAGEAdABlAHIARwByAGUAYQB0AGUA8gDrBGUAcwBzAEwAZQBzAPMA2wdMImluZQAKYHIAAOA12BHdAAJCbnB0jAiRCJkInAhyImVhawAAoGAgwiZyZWFraW5nU3BhY2WgYGYAAKAVIUOq7CqzCMIIzQgAAOcIGwkAAAAAAAAtCQAAbwkAAIcJAACdCcAJGQoAADQKAAFvdbYIvAjuI2dydWVudACgYiJwIkNhcAAAoG0ibyh1YmxlVmVydGljYWxCYXIAAKAmIoABbHF4ANII1wjhCOUibWVudACgCSL1IWFsVKBgImkibGRlAADgQiI4A2kic3RzAACgBCJyI2VhdGVyAACjbyJFRkdMU1T1CPoIAgkJCQ0JFQlxInVhbAAAoHEidSRsbEVxdWFsAADgZyI4A3IjZWF0ZXIAAOBrIjgD5SFzcwCgeSLsJGFudEVxdWFsAOB+KjgDaSJsZGUAAKB1IvUhbXBEASAJJwnvI3duSHVtcADgTiI4A3EidWFsAADgTyI4A2UAAAFmczEJRgn0JFRyaWFuZ2xlQqLqIj0JAAAAAEIJYQByAADgzyk4A3EidWFsAACg7CJzAICibiJFR0xTVABRCVYJXAlhCWkJcSJ1YWwAAKBwInIjZWF0ZXIAAKB4IuUhc3MA4GoiOAPsJGFudEVxdWFsAOB9KjgDaSJsZGUAAKB0IuUic3RlZAABR0x1CX8J8iZlYXRlckdyZWF0ZXIA4KIqOAPlI3NzTGVzcwDgoSo4A/IjZWNlZGVzAKGAIkVTjwmVCXEidWFsAADgryo4A+wkYW50RXF1YWwAoOAiAAFlaaAJqQl2JmVyc2VFbGVtZW50AACgDCLnJWh0VHJpYW5nbGVCousitgkAAAAAuwlhAHIAAODQKTgDcSJ1YWwAAKDtIgABcXXDCeAJdSNhcmVTdQAAAWJwywnVCfMhZXRF4I8iOANxInVhbAAAoOIi5SJyc2V0ReCQIjgDcSJ1YWwAAKDjIoABYmNwAOYJ8AkNCvMhZXRF4IIi0iBxInVhbAAAoIgi4yJlZWRzgKGBIkVTVAD6CQAKBwpxInVhbAAA4LAqOAPsJGFudEVxdWFsAKDhImkibGRlAADgfyI4A+UicnNldEXggyLSIHEidWFsAACgiSJpImxkZQCAoUEiRUZUACIKJwouCnEidWFsAACgRCJ1JGxsRXF1YWwAAKBHImkibGRlAACgSSJlJXJ0aWNhbEJhcgAAoCQiYwByAADgNdip3GkAbABkAGUAO4DRANFAnWMAB0VhY2RmZ21vcHJzdHV2XgphCmgKcgp2CnoKgQqRCpYKqwqtCrsKyArNCuwhaWdSYWMAdQB0AGUAO4DTANNAAAFpeWwKcQpyAGMAO4DUANRAHmRiImxhYwBQYXIAAOA12BLdcgBhAHYAZQA7gNIA0kCAAWFlaQCHCooKjQpjAHIATGFnAGEAqWNjInJvbgCfY3AAZgAA4DXYRt3lI25DdXJseQABRFGeCqYKbyV1YmxlUXVvdGUAAKAcIHUib3RlAACgGCAAoFQqAAFjbLEKtQpyAADgNdiq3GEAcwBoADuA2ADYQGkAbAHACsUKZABlADuA1QDVQGUAcwAAoDcqbQBsADuA1gDWQGUAcgAAAUJQ0wrmCgABYXLXCtoKcgAAoD4gYQBjAAABZWvgCuIKAKDeI2UAdAAAoLQjYSVyZW50aGVzaXMAAKDcI4AEYWNmaGlsb3JzAP0KAwsFCwkLCwsMCxELIwtaC3IjdGlhbEQAAKACInkAH2RyAADgNdgT3WkApmOgY/Ujc01pbnVzsWAAAWlwFQsgC24AYwBhAHIAZQBwAGwAYQBuAOUACgVmAACgGSGAobsqZWlvACoLRQtJC+MiZWRlc4CheiJFU1QANAs5C0ALcSJ1YWwAAKCvKuwkYW50RXF1YWwAoHwiaSJsZGUAAKB+Im0AZQAAoDMgAAFkcE0LUQv1IWN0AKAPIm8jcnRpb24AYaA3ImwAAKAdIgABY2leC2ILcgAA4DXYq9yoYwACVWZvc2oLbwtzC3cLTwBUADuAIgAiQHIAAOA12BTdcABmAACgGiFjAHIAAOA12KzcAAZCRWFjZWZoaW9yc3WPC5MLlwupC7YL2AvbC90LhQyTDJoMowzhIXJyAKAQKUcAO4CuAK5AgAFjbnIAnQugC6ML9SF0ZVRhZwAAoOsncgB0oKAhbAAAoBYpgAFhZXkArwuyC7UL8iFvblhh5CFpbFZhIGR2oBwhZSJyc2UAAAFFVb8LzwsAAWxxwwvIC+UibWVudACgCyL1JGlsaWJyaXVtAKDLIXAmRXF1aWxpYnJpdW0AAKBvKXIAAKAcIW8AoWPnIWh0AARBQ0RGVFVWYewLCgwQDDIMNwxeDHwM9gIAAW5y8Av4C2clbGVCcmFja2V0AACg6SfyIW93AKGSIUJM/wsDDGEAcgAAoOUhZSRmdEFycm93AACgxCFlI2lsaW5nAACgCSNvAPUBFgwAAB4MYiVsZUJyYWNrZXQAAKDnJ24A1AEjDAAAKgxlJGVWZWN0b3IAAKBdKeUiY3RvckKgwiFhAHIAAKBVKWwib29yAACgCyMAAWVyOwxLDGUAAKGiIkFWQQxGDHIicm93AACgpiHlImN0b3IAoFspaSNhbmdsZQBCorMiVgwAAAAAWgxhAHIAAKDQKXEidWFsAACgtSJwAIABRFRWAGUMbAxzDO8kd25WZWN0b3IAoE8pZSRlVmVjdG9yAACgXCnlImN0b3JCoL4hYQByAACgVCnlImN0b3JCoMAhYQByAACgUykAAXB1iQyMDGYAAKAdIe4kZEltcGxpZXMAoHAp6SRnaHRhcnJvdwCg2yEAAWNongyhDHIAAKAbIQCgsSHsJGVEZWxheWVkAKD0KYAGSE9hY2ZoaW1vcXN0dQC/DMgMzAzQDOIM5gwKDQ0NFA0ZDU8NVA1YDQABQ2PDDMYMyCFjeSlkeQAoZEYiVGN5ACxkYyJ1dGUAWmEAorwqYWVpedgM2wzeDOEM8iFvbmBh5CFpbF5hcgBjAFxhIWRyAADgNdgW3e8hcnQAAkRMUlXvDPYM/QwEDW8kd25BcnJvdwAAoJMhZSRmdEFycm93AACgkCHpJGdodEFycm93AKCSIXAjQXJyb3cAAKCRIechbWGjY+EkbGxDaXJjbGUAoBgicABmAADgNdhK3XICHw0AAAAAIg10AACgGiLhIXJlgKGhJUlTVQAqDTINSg3uJXRlcnNlY3Rpb24AoJMidQAAAWJwNw1ADfMhZXRFoI8icSJ1YWwAAKCRIuUicnNldEWgkCJxInVhbAAAoJIibiJpb24AAKCUImMAcgAA4DXYrtxhAHIAAKDGIgACYmNtcF8Nag2ODZANc6DQImUAdABFoNAicSJ1YWwAAKCGIgABY2huDYkNZSJlZHMAgKF7IkVTVAB4DX0NhA1xInVhbAAAoLAq7CRhbnRFcXVhbACgfSJpImxkZQAAoH8iVABoAGEA9ADHCwCgESIAodEiZXOVDZ8NciJzZXQARaCDInEidWFsAACghyJlAHQAAKDRIoAFSFJTYWNmaGlvcnMAtQ27Db8NyA3ODdsN3w3+DRgOHQ4jDk8AUgBOADuA3gDeQMEhREUAoCIhAAFIY8MNxg1jAHkAC2R5ACZkAAFidcwNzQ0JYKRjgAFhZXkA1A3XDdoN8iFvbmRh5CFpbGJhImRyAADgNdgX3QABZWnjDe4N8gHoDQAA7Q3lImZvcmUAoDQiYQCYYwABY27yDfkNayNTcGFjZQAA4F8gCiDTInBhY2UAoAkg7CFkZYChPCJFRlQABw4MDhMOcSJ1YWwAAKBDInUkbGxFcXVhbAAAoEUiaSJsZGUAAKBIInAAZgAA4DXYS93pI3BsZURvdACg2yAAAWN0Jw4rDnIAAOA12K/c8iFva2Zh4QpFDlYOYA5qDgAAbg5yDgAAAAAAAAAAAAB5DnwOqA6zDgAADg8RDxYPGg8AAWNySA5ODnUAdABlADuA2gDaQHIAb6CfIeMhaXIAoEkpcgDjAVsOAABdDnkADmR2AGUAbGEAAWl5Yw5oDnIAYwA7gNsA20AjZGIibGFjAHBhcgAA4DXYGN1yAGEAdgBlADuA2QDZQOEhY3JqYQABZGl/Dp8OZQByAAABQlCFDpcOAAFhcokOiw5yAF9gYQBjAAABZWuRDpMOAKDfI2UAdAAAoLUjYSVyZW50aGVzaXMAAKDdI28AbgBQoMMi7CF1cwCgjiIAAWdwqw6uDm8AbgByYWYAAOA12EzdAARBREVUYWRwc78O0g7ZDuEOBQPqDvMOBw9yInJvdwDCoZEhyA4AAMwOYQByAACgEilvJHduQXJyb3cAAKDFIW8kd25BcnJvdwAAoJUhcSV1aWxpYnJpdW0AAKBuKWUAZQBBoKUiciJyb3cAAKClIW8AdwBuAGEAcgByAG8A9wAQA2UAcgAAAUxS+Q4AD2UkZnRBcnJvdwAAoJYh6SRnaHRBcnJvdwCglyFpAGyg0gNvAG4ApWPpIW5nbmFjAHIAAOA12LDcaSJsZGUAaGFtAGwAO4DcANxAgAREYmNkZWZvc3YALQ8xDzUPNw89D3IPdg97D4AP4SFzaACgqyJhAHIAAKDrKnkAEmThIXNobKCpIgCg5ioAAWVyQQ9DDwCgwSKAAWJ0eQBJD00Paw9hAHIAAKAWIGmgFiDjIWFsAAJCTFNUWA9cD18PZg9hAHIAAKAjIukhbmV8YGUkcGFyYXRvcgAAoFgnaSJsZGUAAKBAItQkaGluU3BhY2UAoAogcgAA4DXYGd1wAGYAAOA12E3dYwByAADgNdix3GQiYXNoAACgqiKAAmNlZm9zAI4PkQ+VD5kPng/pIXJjdGHkIWdlAKDAInIAAOA12BrdcABmAADgNdhO3WMAcgAA4DXYstwAAmZpb3OqD64Prw+0D3IAAOA12BvdnmNwAGYAAOA12E/dYwByAADgNdiz3IAEQUlVYWNmb3N1AMgPyw/OD9EP2A/gD+QP6Q/uD2MAeQAvZGMAeQAHZGMAeQAuZGMAdQB0AGUAO4DdAN1AAAFpedwP3w9yAGMAdmErZHIAAOA12BzdcABmAADgNdhQ3WMAcgAA4DXYtNxtAGwAeGEABEhhY2RlZm9z/g8BEAUQDRAQEB0QIBAkEGMAeQAWZGMidXRlAHlhAAFheQkQDBDyIW9ufWEXZG8AdAB7YfIBFRAAABwQbwBXAGkAZAB0AOgAVAhhAJZjcgAAoCghcABmAACgJCFjAHIAAOA12LXc4QtCEEkQTRAAAGcQbRByEAAAAAAAAAAAeRCKEJcQ8hD9EAAAGxEhETIROREAAD4RYwB1AHQAZQA7gOEA4UByImV2ZQADYYCiPiJFZGl1eQBWEFkQWxBgEGUQAOA+IjMDAKA/InIAYwA7gOIA4kB0AGUAO4C0ALRAMGRsAGkAZwA7gOYA5kByoGEgAOA12B7dcgBhAHYAZQA7gOAA4EAAAWVwfBCGEAABZnCAEIQQ8yF5bQCgNSHoAIMQaABhALFjAAFhcI0QWwAAAWNskRCTEHIAAWFnAACgPypkApwQAAAAALEQAKInImFkc3ajEKcQqRCuEG4AZAAAoFUqAKBcKmwib3BlAACgWCoAoFoqAKMgImVsbXJzersQvRDAEN0Q5RDtEACgpCllAACgICJzAGQAYaAhImEEzhDQENIQ1BDWENgQ2hDcEACgqCkAoKkpAKCqKQCgqykAoKwpAKCtKQCgrikAoK8pdAB2oB8iYgBkoL4iAKCdKQABcHTpEOwQaAAAoCIixWDhIXJyAKB8IwABZ3D1EPgQbwBuAAVhZgAA4DXYUt0Ao0giRWFlaW9wBxEJEQ0RDxESERQRAKBwKuMhaXIAoG8qAKBKImQAAKBLInMAJ2DyIW94ZaBIIvEADhFpAG4AZwA7gOUA5UCAAWN0eQAmESoRKxFyAADgNdi23CpgbQBwAGWgSCLxAPgBaQBsAGQAZQA7gOMA40BtAGwAO4DkAORAAAFjaUERRxFvAG4AaQBuAPQA6AFuAHQAAKARKgAITmFiY2RlZmlrbG5vcHJzdWQRaBGXEZ8RpxGrEdIR1hErEjASexKKEn0RThNbE3oTbwB0AACg7SoAAWNybBGJEWsAAAJjZXBzdBF4EX0RghHvIW5nAKBMInAjc2lsb24A9mNyImltZQAAoDUgaQBtAGWgPSJxAACgzSJ2AY0RkRFlAGUAAKC9ImUAZABnoAUjZQAAoAUjcgBrAHSgtSPiIXJrAKC2IwABb3mjEaYRbgDnAHcRMWTxIXVvAKAeIIACY21wcnQAtBG5Eb4RwRHFEeEhdXPloDUi5ABwInR5dgAAoLApcwDpAH0RbgBvAPUA6gCAAWFodwDLEcwRzhGyYwCgNiHlIWVuAKBsInIAAOA12B/dZwCAA2Nvc3R1dncA4xHyEQUSEhIhEiYSKRKAAWFpdQDpEesR7xHwAKMFcgBjAACg7yVwAACgwyKAAWRwdAD4EfwRABJvAHQAAKAAKuwhdXMAoAEqaSJtZXMAAKACKnECCxIAAAAADxLjIXVwAKAGKmEAcgAAoAUm8iNpYW5nbGUAAWR1GhIeEu8hd24AoL0lcAAAoLMlcCJsdXMAAKAEKmUA5QBCD+UAkg9hInJvdwAAoA0pgAFha28ANhJoEncSAAFjbjoSZRJrAIABbHN0AEESRxJNEm8jemVuZ2UAAKDrKXEAdQBhAHIA5QBcBPIjaWFuZ2xlgKG0JWRscgBYElwSYBLvIXduAKC+JeUhZnQAoMIlaSJnaHQAAKC4JWsAAKAjJLEBbRIAAHUSsgFxEgAAcxIAoJIlAKCRJTQAAKCTJWMAawAAoIglAAFlb38ShxJx4D0A5SD1IWl2AOBhIuUgdAAAoBAjAAJwdHd4kRKVEpsSnxJmAADgNdhT3XSgpSJvAG0AAKClIvQhaWUAoMgiAAZESFVWYmRobXB0dXayEsES0RLgEvcS+xIKExoTHxMjEygTNxMAAkxSbHK5ErsSvRK/EgCgVyUAoFQlAKBWJQCgUyUAolAlRFVkdckSyxLNEs8SAKBmJQCgaSUAoGQlAKBnJQACTFJsctgS2hLcEt4SAKBdJQCgWiUAoFwlAKBZJQCjUSVITFJobHLrEu0S7xLxEvMS9RIAoGwlAKBjJQCgYCUAoGslAKBiJQCgXyVvAHgAAKDJKQACTFJscgITBBMGEwgTAKBVJQCgUiUAoBAlAKAMJQCiACVEVWR1EhMUExYTGBMAoGUlAKBoJQCgLCUAoDQlaSJudXMAAKCfIuwhdXMAoJ4iaSJtZXMAAKCgIgACTFJsci8TMRMzEzUTAKBbJQCgWCUAoBglAKAUJQCjAiVITFJobHJCE0QTRhNIE0oTTBMAoGolAKBhJQCgXiUAoDwlAKAkJQCgHCUAAWV2UhNVE3YA5QD5AGIAYQByADuApgCmQAACY2Vpb2ITZhNqE24TcgAA4DXYt9xtAGkAAKBPIG0A5aA9IogRbAAAoVwAYmh0E3YTAKDFKfMhdWIAoMgnbAF+E4QTbABloCIgdAAAoCIgcAAAoU4iRWWJE4sTAKCuKvGgTyI8BeEMqRMAAN8TABQDFB8UAAAjFDQUAAAAAIUUAAAAAI0UAAAAANcU4xT3FPsUAACIFQAAlhWAAWNwcgCuE7ET1RP1IXRlB2GAoikiYWJjZHMAuxO/E8QTzhPSE24AZAAAoEQqciJjdXAAAKBJKgABYXXIE8sTcAAAoEsqcAAAoEcqbwB0AACgQCoA4CkiAP4AAWVv2RPcE3QAAKBBIO4ABAUAAmFlaXXlE+8T9RP4E/AB6hMAAO0TcwAAoE0qbwBuAA1hZABpAGwAO4DnAOdAcgBjAAlhcABzAHOgTCptAACgUCpvAHQAC2GAAWRtbgAIFA0UEhRpAGwAO4C4ALhAcCJ0eXYAAKCyKXQAAIGiADtlGBQZFKJAcgBkAG8A9ABiAXIAAOA12CDdgAFjZWkAKBQqFDIUeQBHZGMAawBtoBMn4SFyawCgEyfHY3IAAKPLJUVjZWZtcz8UQRRHFHcUfBSAFACgwykAocYCZWxGFEkUcQAAoFciZQBhAlAUAAAAAGAUciJyb3cAAAFsclYUWhTlIWZ0AKC6IWkiZ2h0AACguyGAAlJTYWNkAGgUaRRrFG8UcxSuYACgyCRzAHQAAKCbIukhcmMAoJoi4SFzaACgnSJuImludAAAoBAqaQBkAACg7yrjIWlyAKDCKfUhYnN1oGMmaQB0AACgYybsApMUmhS2FAAAwxRvAG4AZaA6APGgVCKrAG0CnxQAAAAAoxRhAHSgLABAYAChASJmbKcUqRTuABMNZQAAAW14rhSyFOUhbnQAoAEiZQDzANIB5wG6FAAAwBRkoEUibwB0AACgbSpuAPQAzAGAAWZyeQDIFMsUzhQA4DXYVN1vAOQA1wEAgakAO3MeAdMUcgAAoBchAAFhb9oU3hRyAHIAAKC1IXMAcwAAoBcnAAFjdeYU6hRyAADgNdi43AABYnDuFPIUZaDPKgCg0SploNAqAKDSKuQhb3QAoO8igANkZWxwcnZ3AAYVEBUbFSEVRBVlFYQV4SFycgABbHIMFQ4VAKA4KQCgNSlwAhYVAAAAABkVcgAAoN4iYwAAoN8i4SFycnCgtiEAoD0pgKIqImJjZG9zACsVMBU6FT4VQRVyImNhcAAAoEgqAAFhdTQVNxVwAACgRipwAACgSipvAHQAAKCNInIAAKBFKgDgKiIA/gACYWxydksVURVuFXMVcgByAG2gtyEAoDwpeQCAAWV2dwBYFWUVaRVxAHACXxUAAAAAYxVyAGUA4wAXFXUA4wAZFWUAZQAAoM4iZSJkZ2UAAKDPImUAbgA7gKQApEBlI2Fycm93AAABbHJ7FX8V5SFmdACgtiFpImdodAAAoLchZQDkAG0VAAFjaYsVkRVvAG4AaQBuAPQAkwFuAHQAAKAxImwiY3R5AACgLSOACUFIYWJjZGVmaGlqbG9yc3R1d3oAuBW7Fb8V1RXgFegV+RUKFhUWHxZUFlcWZRbFFtsW7xb7FgUXChdyAPIAtAJhAHIAAKBlKQACZ2xyc8YVyhXOFdAV5yFlcgCgICDlIXRoAKA4IfIA9QxoAHagECAAoKMiawHZFd4VYSJyb3cAAKAPKWEA4wBfAgABYXnkFecV8iFvbg9hNGQAoUYhYW/tFfQVAAFnciEC8RVyAACgyiF0InNlcQAAoHcqgAFnbG0A/xUCFgUWO4CwALBAdABhALRjcCJ0eXYAAKCxKQABaXIOFhIW8yFodACgfykA4DXYId1hAHIAAAFschsWHRYAoMMhAKDCIYACYWVnc3YAKBauAjYWOhY+Fm0AAKHEIm9zLhY0Fm4AZABzoMQi9SFpdACgZiZhIm1tYQDdY2kAbgAAoPIiAKH3AGlvQxZRFmQAZQAAgfcAO29KFksW90BuI3RpbWVzAACgxyJuAPgAUBZjAHkAUmRjAG8CXhYAAAAAYhZyAG4AAKAeI28AcAAAoA0jgAJscHR1dwBuFnEWdRaSFp4W7CFhciRgZgAA4DXYVd0AotkCZW1wc30WhBaJFo0WcQBkoFAibwB0AACgUSJpIm51cwAAoDgi7CF1cwCgFCLxInVhcmUAoKEiYgBsAGUAYgBhAHIAdwBlAGQAZwDlANcAbgCAAWFkaAClFqoWtBZyAHIAbwD3APUMbwB3AG4AYQByAHIAbwB3APMA8xVhI3Jwb29uAAABbHK8FsAWZQBmAPQAHBZpAGcAaAD0AB4WYgHJFs8WawBhAHIAbwD3AJILbwLUFgAAAADYFnIAbgAAoB8jbwBwAACgDCOAAWNvdADhFukW7BYAAXJ55RboFgDgNdi53FVkbAAAoPYp8iFvaxFhAAFkcvMW9xZvAHQAAKDxImkA5qC/JVsSAAFhaP8WAhdyAPIANQNhAPIA1wvhIm5nbGUAoKYpAAFjaQ4XEBd5AF9k5yJyYXJyAKD/JwAJRGFjZGVmZ2xtbm9wcXJzdHV4MRc4F0YXWxcyBF4XaRd5F40XrBe0F78X2RcVGCEYLRg1GEAYAAFEbzUXgRZvAPQA+BUAAWNzPBdCF3UAdABlADuA6QDpQPQhZXIAoG4qAAJhaW95TRdQF1YXWhfyIW9uG2FyAGOgViI7gOoA6kDsIW9uAKBVIk1kbwB0ABdhAAFEcmIXZhdvAHQAAKBSIgDgNdgi3XKhmipuF3QXYQB2AGUAO4DoAOhAZKCWKm8AdAAAoJgqgKGZKmlscwCAF4UXhxfuInRlcnMAoOcjAKATIWSglSpvAHQAAKCXKoABYXBzAJMXlheiF2MAcgATYXQAeQBzogUinxcAAAAAoRdlAHQAAKAFInAAMaADIDMBqRerFwCgBCAAoAUgAAFnc7AXsRdLYXAAAKACIAABZ3C4F7sXbwBuABlhZgAA4DXYVt2AAWFscwDFF8sXzxdyAHOg1SJsAACg4yl1AHMAAKBxKmkAAKG1A2x21RfYF28AbgC1Y/VjAAJjc3V24BfoF/0XEBgAAWlv5BdWF3IAYwAAoFYiaQLuFwAAAADwF+0ADQThIW50AAFnbPUX+Rd0AHIAAKCWKuUhc3MAoJUqgAFhZWkAAxgGGAoYbABzAD1gcwB0AACgXyJ2AESgYSJEAACgeCrwImFyc2wAoOUpAAFEYRkYHRhvAHQAAKBTInIAcgAAoHEpgAFjZGkAJxgqGO0XcgAAoC8hbwD0AIwCAAFhaDEYMhi3YzuA8ADwQAABbXI5GD0YbAA7gOsA60BvAACgrCCAAWNpcABGGEgYSxhsACFgcwD0ACwEAAFlb08YVxhjAHQAYQB0AGkAbwDuABoEbgBlAG4AdABpAGEAbADlADME4Ql1GAAAgRgAAIMYiBgAAAAAoRilGAAAqhgAALsYvhjRGAAA1xgnGWwAbABpAG4AZwBkAG8AdABzAGUA8QBlF3kARGRtImFsZQAAoEAmgAFpbHIAjRiRGJ0Y7CFpZwCgA/tpApcYAAAAAJoYZwAAoAD7aQBnAACgBPsA4DXYI93sIWlnAKAB++whaWcA4GYAagCAAWFsdACvGLIYthh0AACgbSZpAGcAAKAC+24AcwAAoLElbwBmAJJh8AHCGAAAxhhmAADgNdhX3QABYWvJGMwYbADsAGsEdqDUIgCg2SphI3J0aW50AACgDSoAAWFv2hgiGQABY3PeGB8ZsQPnGP0YBRkSGRUZAAAdGbID7xjyGPQY9xj5GAAA+xg7gL0AvUAAoFMhO4C8ALxAAKBVIQCgWSEAoFshswEBGQAAAxkAoFQhAKBWIbQCCxkOGQAAAAAQGTuAvgC+QACgVyEAoFwhNQAAoFghtgEZGQAAGxkAoFohAKBdITgAAKBeIWwAAKBEIHcAbgAAoCIjYwByAADgNdi73IAIRWFiY2RlZmdpamxub3JzdHYARhlKGVoZXhlmGWkZkhmWGZkZnRmgGa0ZxhnLGc8Z4BkjGmygZyIAoIwqgAFjbXAAUBlTGVgZ9SF0ZfVhbQBhAOSgswM6FgCghipyImV2ZQAfYQABaXliGWUZcgBjAB1hM2RvAHQAIWGAoWUibHFzAMYEcBl6GfGhZSLOBAAAdhlsAGEAbgD0AN8EgKF+KmNkbACBGYQZjBljAACgqSpvAHQAb6CAKmyggioAoIQqZeDbIgD+cwAAoJQqcgAA4DXYJN3noGsirATtIWVsAKA3IWMAeQBTZIChdyJFYWoApxmpGasZAKCSKgCgpSoAoKQqAAJFYWVztBm2Gb0ZwhkAoGkicABwoIoq8iFveACgiipxoIgq8aCIKrUZaQBtAACg5yJwAGYAAOA12FjdYQB2AOUAYwIAAWNp0xnWGXIAAKAKIW0AAKFzImVs3BneGQCgjioAoJAqAIM+ADtjZGxxco0E6xn0GfgZ/BkBGgABY2nvGfEZAKCnKnIAAKB6Km8AdAAAoNci0CFhcgCglSl1ImVzdAAAoHwqgAJhZGVscwAKGvQZFhrVBCAa8AEPGgAAFBpwAHIAbwD4AFkZcgAAoHgpcQAAAWxxxAQbGmwAZQBzAPMASRlpAO0A5AQAAWVuJxouGnIjdG5lcXEAAOBpIgD+xQAsGgAFQWFiY2Vma29zeUAaQxpmGmoabRqDGocalhrCGtMacgDyAMwCAAJpbG1yShpOGlAaVBpyAHMA8ABxD2YAvWBpAGwA9AASBQABZHJYGlsaYwB5AEpkAKGUIWN3YBpkGmkAcgAAoEgpAKCtIWEAcgAAoA8h6SFyYyVhgAFhbHIAcxp7Gn8a8iF0c3WgZSZpAHQAAKBlJuwhaXAAoCYg4yFvbgCguSJyAADgNdgl3XMAAAFld4wakRphInJvdwAAoCUpYSJyb3cAAKAmKYACYW1vcHIAnxqjGqcauhq+GnIAcgAAoP8h9CFodACgOyJrAAABbHKsGrMaZSRmdGFycm93AACgqSHpJGdodGFycm93AKCqIWYAAOA12Fnd4iFhcgCgFSCAAWNsdADIGswa0BpyAADgNdi93GEAcwDoAGka8iFvaydhAAFicNca2xr1IWxsAKBDIOghZW4AoBAg4Qr2GgAA/RoAAAgbExsaGwAAIRs7GwAAAAA+G2IbmRuVG6sbAACyG80b0htjAHUAdABlADuA7QDtQAChYyBpeQEbBhtyAGMAO4DuAO5AOGQAAWN4CxsNG3kANWRjAGwAO4ChAKFAAAFmcssCFhsA4DXYJt1yAGEAdgBlADuA7ADsQIChSCFpbm8AJxsyGzYbAAFpbisbLxtuAHQAAKAMKnQAAKAtIuYhaW4AoNwpdABhAACgKSHsIWlnM2GAAWFvcABDG1sbXhuAAWNndABJG0sbWRtyACthgAFlbHAAcQVRG1UbaQBuAOUAyAVhAHIA9AByBWgAMWFmAACgtyJlAGQAtWEAoggiY2ZvdGkbbRt1G3kb4SFyZQCgBSFpAG4AdKAeImkAZQAAoN0pZABvAPQAWxsAoisiY2VscIEbhRuPG5QbYQBsAACguiIAAWdyiRuNG2UAcgDzACMQ4wCCG2EicmhrAACgFyryIW9kAKA8KgACY2dwdJ8boRukG6gbeQBRZG8AbgAvYWYAAOA12FrdYQC5Y3UAZQBzAHQAO4C/AL9AAAFjabUbuRtyAADgNdi+3G4AAKIIIkVkc3bCG8QbyBvQAwCg+SJvAHQAAKD1Inag9CIAoPMiaaBiIOwhZGUpYesB1hsAANkbYwB5AFZkbAA7gO8A70AAA2NmbW9zdeYb7hvyG/Ub+hsFHAABaXnqG+0bcgBjADVhOWRyAADgNdgn3eEhdGg3YnAAZgAA4DXYW93jAf8bAAADHHIAAOA12L/c8iFjeVhk6yFjeVRkAARhY2ZnaGpvcxUcGhwiHCYcKhwtHDAcNRzwIXBhdqC6A/BjAAFleR4cIRzkIWlsN2E6ZHIAAOA12CjdciJlZW4AOGFjAHkARWRjAHkAXGRwAGYAAOA12FzdYwByAADgNdjA3IALQUJFSGFiY2RlZmdoamxtbm9wcnN0dXYAXhxtHHEcdRx5HN8cBx0dHTwd3B3tHfEdAR4EHh0eLB5FHrwewx7hHgkfPR9LH4ABYXJ0AGQcZxxpHHIA8gBvB/IAxQLhIWlsAKAbKeEhcnIAoA4pZ6BmIgCgiyphAHIAAKBiKWMJjRwAAJAcAACVHAAAAAAAAAAAAACZHJwcAACmHKgcrRwAANIc9SF0ZTph7SJwdHl2AKC0KXIAYQDuAFoG4iFkYbtjZwAAoegnZGyhHKMcAKCRKeUAiwYAoIUqdQBvADuAqwCrQHIAgKOQIWJmaGxwc3QAuhy/HMIcxBzHHMoczhxmoOQhcwAAoB8pcwAAoB0p6wCyGnAAAKCrIWwAAKA5KWkAbQAAoHMpbAAAoKIhAKGrKmFl1hzaHGkAbAAAoBkpc6CtKgDgrSoA/oABYWJyAOUc6RztHHIAcgAAoAwpcgBrAACgcicAAWFr8Rz4HGMAAAFla/Yc9xx7YFtgAAFlc/wc/hwAoIspbAAAAWR1Ax0FHQCgjykAoI0pAAJhZXV5Dh0RHRodHB3yIW9uPmEAAWRpFR0YHWkAbAA8YewAowbiAPccO2QAAmNxcnMkHScdLB05HWEAAKA2KXUAbwDyoBwgqhEAAWR1MB00HeghYXIAoGcpcyJoYXIAAKBLKWgAAKCyIQCiZCJmZ3FzRB1FB5Qdnh10AIACYWhscnQATh1WHWUdbB2NHXIicm93AHSgkCFhAOkAzxxhI3Jwb29uAAABZHVeHWId7yF3bgCgvSFwAACgvCHlJGZ0YXJyb3dzAKDHIWkiZ2h0AIABYWhzAHUdex2DHXIicm93APOglCGdBmEAcgBwAG8AbwBuAPMAzgtxAHUAaQBnAGEAcgByAG8A9wBlGugkcmVldGltZXMAoMsi8aFkIk0HAACaHWwAYQBuAPQAXgcAon0qY2Rnc6YdqR2xHbcdYwAAoKgqbwB0AG+gfypyoIEqAKCDKmXg2iIA/nMAAKCTKoACYWRlZ3MAwB3GHcod1h3ZHXAAcAByAG8A+ACmHG8AdAAAoNYicQAAAWdxzx3SHXQA8gBGB2cAdADyAHQcdADyAFMHaQDtAGMHgAFpbHIA4h3mHeod8yFodACgfClvAG8A8gDKBgDgNdgp3UWgdiIAoJEqYQH1Hf4dcgAAAWR1YB35HWygvCEAoGopbABrAACghCVjAHkAWWQAomoiYWNodAweDx4VHhkecgDyAGsdbwByAG4AZQDyAGAW4SFyZACgaylyAGkAAKD6JQABaW8hHiQe5CFvdEBh9SFzdGGgsCPjIWhlAKCwIwACRWFlczMeNR48HkEeAKBoInAAcKCJKvIhb3gAoIkqcaCHKvGghyo0HmkAbQAAoOYiAARhYm5vcHR3elIeXB5fHoUelh6mHqsetB4AAW5yVh5ZHmcAAKDsJ3IAAKD9IXIA6wCwBmcAgAFsbXIAZh52Hnse5SFmdAABYXKIB2weaQBnAGgAdABhAHIAcgBvAPcAkwfhInBzdG8AoPwnaQBnAGgAdABhAHIAcgBvAPcAmgdwI2Fycm93AAABbHKNHpEeZQBmAPQAxhxpImdodAAAoKwhgAFhZmwAnB6fHqIecgAAoIUpAOA12F3ddQBzAACgLSppIm1lcwAAoDQqYQGvHrMecwB0AACgFyLhAIoOZaHKJbkeRhLuIWdlAKDKJWEAcgBsoCgAdAAAoJMpgAJhY2htdADMHs8e1R7bHt0ecgDyAJ0GbwByAG4AZQDyANYWYQByAGSgyyEAoG0pAKAOIHIAaQAAoL8iAANhY2hpcXTrHu8e1QfzHv0eBh/xIXVvAKA5IHIAAOA12MHcbQDloXIi+h4AAPweAKCNKgCgjyoAAWJ19xwBH28AcqAYIACgGiDyIW9rQmEAhDwAO2NkaGlscXJCBhcfxh0gHyQfKB8sHzEfAAFjaRsfHR8AoKYqcgAAoHkqcgBlAOUAkx3tIWVzAKDJIuEhcnIAoHYpdSJlc3QAAKB7KgABUGk1HzkfYQByAACglillocMlAgdfEnIAAAFkdUIfRx9zImhhcgAAoEop6CFhcgCgZikAAWVuTx9WH3IjdG5lcXEAAOBoIgD+xQBUHwAHRGFjZGVmaGlsbm9wc3VuH3Ifoh+rH68ftx+7H74f5h/uH/MfBwj/HwsgxCFvdACgOiIAAmNscHJ5H30fiR+eH3IAO4CvAK9AAAFldIEfgx8AoEImZaAgJ3MAZQAAoCAnc6CmIXQAbwCAoaYhZGx1AJQfmB+cH28AdwDuAHkDZQBmAPQA6gbwAOkO6yFlcgCgriUAAW95ph+qH+0hbWEAoCkqPGThIXNoAKAUIOElc3VyZWRhbmdsZQCgISJyAADgNdgq3W8AAKAnIYABY2RuAMQfyR/bH3IAbwA7gLUAtUBhoiMi0B8AANMf1x9zAPQAKxFpAHIAAKDwKm8AdAA7gLcAt0B1AHMA4qESIh4TAADjH3WgOCIAoCoqYwHqH+0fcAAAoNsq8gB+GnAAbAB1APMACAgAAWRw9x/7H+UhbHMAoKciZgAA4DXYXt0AAWN0AyAHIHIAAOA12MLc8CFvcwCgPiJsobwDECAVIPQiaW1hcACguCJhAPAAEyAADEdMUlZhYmNkZWZnaGlqbG1vcHJzdHV2dzwgRyBmIG0geSCqILgg2iDeIBEhFSEyIUMhTSFQIZwhnyHSIQAiIyKLIrEivyIUIwABZ3RAIEMgAODZIjgD9uBrItIgBwmAAWVsdABNIF8gYiBmAHQAAAFhclMgWCByInJvdwAAoM0h6SRnaHRhcnJvdwCgziEA4NgiOAP24Goi0iBfCekkZ2h0YXJyb3cAoM8hAAFEZHEgdSDhIXNoAKCvIuEhc2gAoK4igAJiY25wdACCIIYgiSCNIKIgbABhAACgByL1IXRlRGFnAADgICLSIACiSSJFaW9wlSCYIJwgniAA4HAqOANkAADgSyI4A3MASWFyAG8A+AAyCnUAcgBhoG4mbADzoG4mmwjzAa8gAACzIHAAO4CgAKBAbQBwAOXgTiI4AyoJgAJhZW91eQDBIMogzSDWINkg8AHGIAAAyCAAoEMqbwBuAEhh5CFpbEZhbgBnAGSgRyJvAHQAAOBtKjgDcAAAoEIqPWThIXNoAKATIACjYCJBYWRxc3jpIO0g+SD+IAIhDCFyAHIAAKDXIXIAAAFocvIg9SBrAACgJClvoJch9wAGD28AdAAA4FAiOAN1AGkA9gC7CAABZWkGIQohYQByAACgKCntAN8I6SFzdPOgBCLlCHIAAOA12CvdAAJFZXN0/wgcISshLiHxoXEiIiEAABMJ8aFxIgAJAAAnIWwAYQBuAPQAEwlpAO0AGQlyoG8iAKBvIoABQWFwADghOyE/IXIA8gBeIHIAcgAAoK4hYQByAACg8ipzogsiSiEAAAAAxwtkoPwiAKD6ImMAeQBaZIADQUVhZGVzdABcIV8hYiFmIWkhkyGWIXIA8gBXIADgZiI4A3IAcgAAoJohcgAAoCUggKFwImZxcwBwIYQhjiF0AAABYXJ1IXohcgByAG8A9wBlIWkAZwBoAHQAYQByAHIAbwD3AD4h8aFwImAhAACKIWwAYQBuAPQAZwlz4H0qOAMAoG4iaQDtAG0JcqBuImkA5aDqIkUJaQDkADoKAAFwdKMhpyFmAADgNdhf3YCBrAA7aW4AriGvIcchrEBuAIChCSJFZHYAtyG6Ib8hAOD5IjgDbwB0AADg9SI4A+EB1gjEIcYhAKD3IgCg9iJpAHagDCLhAagJzyHRIQCg/iIAoP0igAFhb3IA2CHsIfEhcgCAoSYiYXN0AOAh5SHpIWwAbABlAOwAywhsAADg/SrlIADgAiI4A2wiaW50AACgFCrjoYAi9yEAAPohdQDlAJsJY+CvKjgDZaCAIvEAkwkAAkFhaXQHIgoiFyIeInIA8gBsIHIAcgAAoZshY3cRIhQiAOAzKTgDAOCdITgDZyRodGFycm93AACgmyFyAGkA5aDrIr4JgANjaGltcHF1AC8iPCJHIpwhTSJQIloigKGBImNlcgA2Iv0JOSJ1AOUABgoA4DXYw9zvIXJ0bQKdIQAAAABEImEAcgDhAOEhbQBloEEi8aBEIiYKYQDyAMsIcwB1AAABYnBWIlgi5QDUCeUA3wmAAWJjcABgInMieCKAoYQiRWVzAGci7glqIgDgxSo4A2UAdABl4IIi0iBxAPGgiCJoImMAZaCBIvEA/gmAoYUiRWVzAH8iFgqCIgDgxio4A2UAdABl4IMi0iBxAPGgiSKAIgACZ2lscpIilCKaIpwi7AAMCWwAZABlADuA8QDxQOcAWwlpI2FuZ2xlAAABbHKkIqoi5SFmdGWg6iLxAEUJaSJnaHQAZaDrIvEAvgltoL0DAKEjAGVzuCK8InIAbwAAoBYhcAAAoAcggARESGFkZ2lscnMAziLSItYi2iLeIugi7SICIw8j4SFzaACgrSLhIXJyAKAEKXAAAOBNItIg4SFzaACgrCIAAWV04iLlIgDgZSLSIADgPgDSIG4iZmluAACg3imAAUFldADzIvci+iJyAHIAAKACKQDgZCLSIHLgPADSIGkAZQAA4LQi0iAAAUF0BiMKI3IAcgAAoAMp8iFpZQDgtSLSIGkAbQAA4Dwi0iCAAUFhbgAaIx4jKiNyAHIAAKDWIXIAAAFociMjJiNrAACgIylvoJYh9wD/DuUhYXIAoCcpUxJqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVCMAAF4jaSN/I4IjjSOeI8AUAAAAAKYjwCMAANoj3yMAAO8jHiQvJD8kRCQAAWNzVyNsFHUAdABlADuA8wDzQAABaXlhI2cjcgBjoJoiO4D0APRAPmSAAmFiaW9zAHEjdCN3I3EBeiNzAOgAdhTsIWFjUWF2AACgOCrvIWxkAKC8KewhaWdTYQABY3KFI4kjaQByAACgvykA4DXYLN1vA5QjAAAAAJYjAACcI24A22JhAHYAZQA7gPIA8kAAoMEpAAFibaEjjAphAHIAAKC1KQACYWNpdKwjryO6I70jcgDyAFkUAAFpcrMjtiNyAACgvinvIXNzAKC7KW4A5QDZCgCgwCmAAWFlaQDFI8gjyyNjAHIATWFnAGEAyWOAAWNkbgDRI9Qj1iPyIW9uv2MAoLYpdQDzAHgBcABmAADgNdhg3YABYWVsAOQj5yPrI3IAAKC3KXIAcAAAoLkpdQDzAHwBAKMoImFkaW9zdvkj/CMPJBMkFiQbJHIA8gBeFIChXSplZm0AAyQJJAwkcgBvoDQhZgAAoDQhO4CqAKpAO4C6ALpA5yFvZgCgtiJyAACgVipsIm9wZQAAoFcqAKBbKoABY2xvACMkJSQrJPIACCRhAHMAaAA7gPgA+EBsAACgmCJpAGwBMyQ4JGQAZQA7gPUA9UBlAHMAYaCXInMAAKA2Km0AbAA7gPYA9kDiIWFyAKA9I+EKXiQAAHokAAB8JJQkAACYJKkkAAAAALUkEQsAAPAkAAAAAAQleiUAAIMlcgCAoSUiYXN0AGUkbyQBCwCBtgA7bGokayS2QGwAZQDsABgDaQJ1JAAAAAB4JG0AAKDzKgCg/Sp5AD9kcgCAAmNpbXB0AIUkiCSLJJkSjyRuAHQAJWBvAGQALmBpAGwAAKAwIOUhbmsAoDEgcgAA4DXYLd2AAWltbwCdJKAkpCR2oMYD1WNtAGEA9AD+B24AZQAAoA4m9KHAA64kAAC0JGMjaGZvcmsAAKDUItZjAAFhdbgkxCRuAAABY2u9JMIkawBooA8hAKAOIfYAaRpzAACkKwBhYmNkZW1zdNMkIRPXJNsk4STjJOck6yTjIWlyAKAjKmkAcgAAoCIqAAFvdYsW3yQAoCUqAKByKm4AO4CxALFAaQBtAACgJip3AG8AAKAnKoABaXB1APUk+iT+JO4idGludACgFSpmAADgNdhh3W4AZAA7gKMAo0CApHoiRWFjZWlub3N1ABMlFSUYJRslTCVRJVklSSV1JQCgsypwAACgtyp1AOUAPwtjoK8qgKJ6ImFjZW5zACclLSU0JTYlSSVwAHAAcgBvAPgAFyV1AHIAbAB5AGUA8QA/C/EAOAuAAWFlcwA8JUElRSXwInByb3gAoLkqcQBxAACgtSppAG0AAKDoImkA7QBEC20AZQDzoDIgIguAAUVhcwBDJVclRSXwAEAlgAFkZnAATwtfJXElgAFhbHMAZSVpJW0l7CFhcgCgLiPpIW5lAKASI/UhcmYAoBMjdKAdIu8AWQvyIWVsAKCwIgABY2l9JYElcgAA4DXYxdzIY24iY3NwAACgCCAAA2Zpb3BzdZElKxuVJZolnyWkJXIAAOA12C7dcABmAADgNdhi3XIiaW1lAACgVyBjAHIAAOA12MbcgAFhZW8AqiW6JcAldAAAAWVpryW2JXIAbgBpAG8AbgDzABkFbgB0AACgFipzAHQAZaA/APEACRj0AG0LgApBQkhhYmNkZWZoaWxtbm9wcnN0dXgA4yXyJfYl+iVpJpAmpia9JtUm5ib4JlonaCdxJ3UnnietJ7EnyCfiJ+cngAFhcnQA6SXsJe4lcgDyAJkM8gD6AuEhaWwAoBwpYQByAPIA3BVhAHIAAKBkKYADY2RlbnFydAAGJhAmEyYYJiYmKyZaJgABZXUKJg0mAOA9IjEDdABlAFVhaQDjACAN7SJwdHl2AKCzKWcAgKHpJ2RlbAAgJiImJCYAoJIpAKClKeUA9wt1AG8AO4C7ALtAcgAApZIhYWJjZmhscHN0dz0mQCZFJkcmSiZMJk4mUSZVJlgmcAAAoHUpZqDlIXMAAKAgKQCgMylzAACgHinrALka8ACVHmwAAKBFKWkAbQAAoHQpbAAAoKMhAKCdIQABYWleJmImaQBsAACgGilvAG6gNiJhAGwA8wB2C4ABYWJyAG8mciZ2JnIA8gAvEnIAawAAoHMnAAFha3omgSZjAAABZWt/JoAmfWBdYAABZXOFJocmAKCMKWwAAAFkdYwmjiYAoI4pAKCQKQACYWV1eZcmmiajJqUm8iFvbllhAAFkaZ4moSZpAGwAV2HsAA8M4gCAJkBkAAJjbHFzrSawJrUmuiZhAACgNylkImhhcgAAoGkpdQBvAPKgHSCjAWgAAKCzIYABYWNnAMMm0iaUC2wAgKEcIWlwcwDLJs4migxuAOUAoAxhAHIA9ADaC3QAAKCtJYABaWxyANsm3ybjJvMhaHQAoH0pbwBvAPIANgwA4DXYL90AAWFv6ib1JnIAAAFkde8m8SYAoMEhbKDAIQCgbCl2oMED8WOAAWducwD+Jk4nUCdoAHQAAANhaGxyc3QKJxInISc1Jz0nRydyInJvdwB0oJIhYQDpAFYmYSNycG9vbgAAAWR1GiceJ28AdwDuAPAmcAAAoMAh5SFmdAABYWgnJy0ncgByAG8AdwDzAAkMYQByAHAAbwBvAG4A8wATBGklZ2h0YXJyb3dzAACgySFxAHUAaQBnAGEAcgByAG8A9wBZJugkcmVldGltZXMAoMwiZwDaYmkAbgBnAGQAbwB0AHMAZQDxABwYgAFhaG0AYCdjJ2YncgDyAAkMYQDyABMEAKAPIG8idXN0AGGgsSPjIWhlAKCxI+0haWQAoO4qAAJhYnB0fCeGJ4knmScAAW5ygCeDJ2cAAKDtJ3IAAKD+IXIA6wAcDIABYWZsAI8nkieVJ3IAAKCGKQDgNdhj3XUAcwAAoC4qaSJtZXMAAKA1KgABYXCiJ6gncgBnoCkAdAAAoJQp7yJsaW50AKASKmEAcgDyADwnAAJhY2hxuCe8J6EMwCfxIXVvAKA6IHIAAOA12MfcAAFidYAmxCdvAPKgGSCoAYABaGlyAM4n0ifWJ3IAZQDlAE0n7SFlcwCgyiJpAIChuSVlZmwAXAxjEt4n9CFyaQCgzinsInVoYXIAoGgpAKAeIWENBSgJKA0oSyhVKIYoAACLKLAoAAAAAOMo5ygAABApJCkxKW0pcSmHKaYpAACYKgAAAACxKmMidXRlAFthcQB1AO8ABR+ApHsiRWFjZWlucHN5ABwoHignKCooLygyKEEoRihJKACgtCrwASMoAAAlKACguCpvAG4AYWF1AOUAgw1koLAqaQBsAF9hcgBjAF1hgAFFYXMAOCg6KD0oAKC2KnAAAKC6KmkAbQAAoOki7yJsaW50AKATKmkA7QCIDUFkbwB0AGKixSKRFgAAAABTKACgZiqAA0FhY21zdHgAYChkKG8ocyh1KHkogihyAHIAAKDYIXIAAAFocmkoayjrAJAab6CYIfcAzAd0ADuApwCnQGkAO2D3IWFyAKApKW0AAAFpbn4ozQBuAHUA8wDOAHQAAKA2J3IA7+A12DDdIxkAAmFjb3mRKJUonSisKHIAcAAAoG8mAAFoeZkonChjAHkASWRIZHIAdABtAqUoAAAAAKgoaQDkAFsPYQByAGEA7ABsJDuArQCtQAABZ22zKLsobQBhAAChwwNmdroouijCY4CjPCJkZWdsbnByAMgozCjPKNMo1yjaKN4obwB0AACgairxoEMiCw5FoJ4qAKCgKkWgnSoAoJ8qZQAAoEYi7CF1cwCgJCrhIXJyAKByKWEAcgDyAPwMAAJhZWl07Sj8KAEpCCkAAWxz8Sj4KGwAcwBlAHQAbQDpAH8oaABwAACgMyrwImFyc2wAoOQpAAFkbFoPBSllAACgIyNloKoqc6CsKgDgrCoA/oABZmxwABUpGCkfKfQhY3lMZGKgLwBhoMQpcgAAoD8jZgAA4DXYZN1hAAABZHIoKRcDZQBzAHWgYCZpAHQAAKBgJoABY3N1ADYpRilhKQABYXU6KUApcABzoJMiAOCTIgD+cABzoJQiAOCUIgD+dQAAAWJwSylWKQChjyJlcz4NUCllAHQAZaCPIvEAPw0AoZAiZXNIDVspZQB0AGWgkCLxAEkNAKGhJWFmZilbBHIAZQFrKVwEAKChJWEAcgDyAAMNAAJjZW10dyl7KX8pgilyAADgNdjI3HQAbQDuAM4AaQDsAAYpYQByAOYAVw0AAWFyiimOKXIA5qAGJhESAAFhbpIpoylpImdodAAAAWVwmSmgKXAAcwBpAGwAbwDuANkXaADpAKAkcwCvYIACYmNtbnAArin8KY4NJSooKgCkgiJFZGVtbnByc7wpvinCKcgpzCnUKdgp3CkAoMUqbwB0AACgvSpkoIYibwB0AACgwyr1IWx0AKDBKgABRWXQKdIpAKDLKgCgiiLsIXVzAKC/KuEhcnIAoHkpgAFlaXUA4inxKfQpdAAAoYIiZW7oKewpcQDxoIYivSllAHEA8aCKItEpbQAAoMcqAAFicPgp+ikAoNUqAKDTKmMAgKJ7ImFjZW5zAAcqDSoUKhYqRihwAHAAcgBvAPgAIyh1AHIAbAB5AGUA8QCDDfEAfA2AAWFlcwAcKiIqPShwAHAAcgBvAPgAPChxAPEAOShnAACgaiYApoMiMTIzRWRlaGxtbnBzPCo/KkIqRSpHKlIqWCpjKmcqaypzKncqO4C5ALlAO4CyALJAO4CzALNAAKDGKgABb3NLKk4qdAAAoL4qdQBiAACg2CpkoIcibwB0AACgxCpzAAABb3VdKmAqbAAAoMknYgAAoNcq4SFycgCgeyn1IWx0AKDCKgABRWVvKnEqAKDMKgCgiyLsIXVzAKDAKoABZWl1AH0qjCqPKnQAAKGDImVugyqHKnEA8aCHIkYqZQBxAPGgiyJwKm0AAKDIKgABYnCTKpUqAKDUKgCg1iqAAUFhbgCdKqEqrCpyAHIAAKDZIXIAAAFocqYqqCrrAJUab6CZIfcAxQf3IWFyAKAqKWwAaQBnADuA3wDfQOELzyrZKtwq6SrsKvEqAAD1KjQrAAAAAAAAAAAAAEwrbCsAAHErvSsAAAAAAADRK3IC1CoAAAAA2CrnIWV0AKAWI8RjcgDrAOUKgAFhZXkA4SrkKucq8iFvbmVh5CFpbGNhQmRvAPQAIg5sInJlYwAAoBUjcgAA4DXYMd0AAmVpa2/7KhIrKCsuK/IBACsAAAkrZQAAATRm6g0EK28AcgDlAOsNYQBzorgDECsAAAAAEit5AG0A0WMAAWNuFislK2sAAAFhcxsrIStwAHAAcgBvAPgAFw5pAG0AAKA8InMA8AD9DQABYXMsKyEr8AAXDnIAbgA7gP4A/kDsATgrOyswG2QA5QBnAmUAcwCAgdcAO2JkAEMrRCtJK9dAYaCgInIAAKAxKgCgMCqAAWVwcwBRK1MraSvhAAkh4qKkIlsrXysAAAAAYytvAHQAAKA2I2kAcgAAoPEqb+A12GXdcgBrAACg2irhAHgociJpbWUAAKA0IIABYWlwAHYreSu3K2QA5QC+DYADYWRlbXBzdACFK6MrmiunK6wrsCuzK24iZ2xlAACitSVkbHFykCuUK5ornCvvIXduAKC/JeUhZnRloMMl8QACBwCgXCJpImdodABloLkl8QBdDG8AdAAAoOwlaSJudXMAAKA6KuwhdXMAoDkqYgAAoM0p6SFtZQCgOyrlInppdW0AoOIjgAFjaHQAwivKK80rAAFyecYrySsA4DXYydxGZGMAeQBbZPIhb2tnYQABaW/UK9creAD0ANERaCJlYWQAAAFsct4r5ytlAGYAdABhAHIAcgBvAPcAXQbpJGdodGFycm93AKCgIQAJQUhhYmNkZmdobG1vcHJzdHV3CiwNLBEsHSwnLDEsQCxLLFIsYix6LIQsjyzLLOgs7Sz/LAotcgDyAAkDYQByAACgYykAAWNyFSwbLHUAdABlADuA+gD6QPIACQ1yAOMBIywAACUseQBeZHYAZQBtYQABaXkrLDAscgBjADuA+wD7QENkgAFhYmgANyw6LD0scgDyANEO7CFhY3FhYQDyAOAOAAFpckQsSCzzIWh0AKB+KQDgNdgy3XIAYQB2AGUAO4D5APlAYQFWLF8scgAAAWxyWixcLACgvyEAoL4hbABrAACggCUAAWN0Zix2LG8CbCwAAAAAcyxyAG4AZaAcI3IAAKAcI28AcAAAoA8jcgBpAACg+CUAAWFsfiyBLGMAcgBrYTuAqACoQAABZ3CILIssbwBuAHNhZgAA4DXYZt0AA2FkaGxzdZksniynLLgsuyzFLHIAcgBvAPcACQ1vAHcAbgBhAHIAcgBvAPcA2A5hI3Jwb29uAAABbHKvLLMsZQBmAPQAWyxpAGcAaAD0AF0sdQDzAKYOaQAAocUDaGzBLMIs0mNvAG4AxWPwI2Fycm93cwCgyCGAAWNpdADRLOEs5CxvAtcsAAAAAN4scgBuAGWgHSNyAACgHSNvAHAAAKAOI24AZwBvYXIAaQAAoPklYwByAADgNdjK3IABZGlyAPMs9yz6LG8AdAAAoPAi7CFkZWlhaQBmoLUlAKC0JQABYW0DLQYtcgDyAMosbAA7gPwA/EDhIm5nbGUAoKcpgAdBQkRhY2RlZmxub3Byc3oAJy0qLTAtNC2bLZ0toS2/LcMtxy3TLdgt3C3gLfwtcgDyABADYQByAHag6CoAoOkqYQBzAOgA/gIAAW5yOC08LechcnQAoJwpgANla25wcnN0AJkpSC1NLVQtXi1iLYItYQBwAHAA4QAaHG8AdABoAGkAbgDnAKEXgAFoaXIAoSmzJFotbwBwAPQAdCVooJUh7wD4JgABaXVmLWotZwBtAOEAuygAAWJwbi14LXMjZXRuZXEAceCKIgD+AODLKgD+cyNldG5lcQBx4IsiAP4A4MwqAP4AAWhyhi2KLWUAdADhABIraSNhbmdsZQAAAWxyki2WLeUhZnQAoLIiaSJnaHQAAKCzInkAMmThIXNoAKCiIoABZWxyAKcttC24LWKiKCKuLQAAAACyLWEAcgAAoLsicQAAoFoi7CFpcACg7iIAAWJ0vC1eD2EA8gBfD3IAAOA12DPddAByAOkAlS1zAHUAAAFicM0t0C0A4IIi0iAA4IMi0iBwAGYAAOA12GfdcgBvAPAAWQt0AHIA6QCaLQABY3XkLegtcgAA4DXYy9wAAWJw7C30LW4AAAFFZXUt8S0A4IoiAP5uAAABRWV/LfktAOCLIgD+6SJnemFnAKCaKYADY2Vmb3BycwANLhAuJS4pLiMuLi40LukhcmN1YQABZGkULiEuAAFiZxguHC5hAHIAAKBfKmUAcaAnIgCgWSLlIXJwAKAYIXIAAOA12DTdcABmAADgNdho3WWgQCJhAHQA6ABqD2MAcgAA4DXYzNzjCuQRUC4AAFQuAABYLmIuAAAAAGMubS5wLnQuAAAAAIguki4AAJouJxIqEnQAcgDpAB0ScgAA4DXYNd0AAUFhWy5eLnIA8gDnAnIA8gCTB75jAAFBYWYuaS5yAPIA4AJyAPIAjAdhAPAAeh5pAHMAAKD7IoABZHB0APgReS6DLgABZmx9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg"),Nc=qs("AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg");var le;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.FLAG13=8192]="FLAG13",e[e.BRANCH_LENGTH=8064]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(le||(le={}));var X;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(X||(X={}));const Gn=32;function Dr(e){return e>=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<t.length;){const n=t.charCodeAt(r);if(Dr(n)||Yc(n)){const s=n<=X.NINE?n-X.ZERO:(n|Gn)-X.LOWER_A+10;this.result=this.result*16+s,this.consumed++,r++}else return this.emitNumericEntity(n,3)}return-1}stateNumericDecimal(t,r){for(;r<t.length;){const n=t.charCodeAt(r);if(Dr(n))this.result=this.result*10+(n-X.ZERO),this.consumed++,r++;else return this.emitNumericEntity(n,2)}return-1}emitNumericEntity(t,r){var n;if(this.consumed<=r)return(n=this.errors)===null||n===void 0||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===X.SEMI)this.consumed+=1;else if(this.decodeMode===$e.Strict)return 0;return this.emitCodePoint(Dc(this.result),this.consumed),this.errors&&(t!==X.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,r){const{decodeTree:n}=this;let s=n[this.treeIndex],i=(s&le.VALUE_LENGTH)>>14;for(;r<t.length;){if(i===0&&(s&le.FLAG13)!==0){const o=(s&le.BRANCH_LENGTH)>>7;if(this.runConsumed===0){const c=s&le.JUMP_TABLE;if(t.charCodeAt(r)!==c)return this.result===0?0:this.emitNotTerminatedNamedEntity();r++,this.excess++,this.runConsumed++}for(;this.runConsumed<o;){if(r>=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),s=n[this.treeIndex],i=(s&le.VALUE_LENGTH)>>14}if(r>=t.length)break;const a=t.charCodeAt(r);if(a===X.SEMI&&i!==0&&(s&le.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);if(this.treeIndex=Qc(n,s,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===$e.Attribute&&(i===0||Vc(a))?0:this.emitNotTerminatedNamedEntity();if(s=n[this.treeIndex],i=(s&le.VALUE_LENGTH)>>14,i!==0){if(a===X.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==$e.Strict&&(s&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,s=(n[r]&le.VALUE_LENGTH)>>14;return this.emitNamedEntityData(r,s,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,r,n){const{decodeTree:s}=this;return this.emitCodePoint(r===1?s[t]&~(le.VALUE_LENGTH|le.FLAG13):s[t+1],n),r===3&&this.emitCodePoint(s[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 s=(t&le.BRANCH_LENGTH)>>7,i=t&le.JUMP_TABLE;if(s===0)return i!==0&&n===i?r:-1;if(i){const u=n-i;return u<0||u>=s?-1:e[r+u]-1}const a=s+1>>1;let o=0,c=s-1;for(;o<=c;){const u=o+c>>>1,h=u>>1,f=e[r+h]>>(u&1)*8&255;if(f<n)o=u+1;else if(f>n)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 g;(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"})(g||(g={}));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=g.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=g.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,(s,i)=>this.emitCodePoint(s,i))}reset(){this.state=g.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=g.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.index<this.buffer.length+this.offset&&this.parse()}stateText(t){t===E.Lt||!this.decodeEntities&&this.fastForwardTo(E.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=g.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=g.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<r){const n=this.index;this.index=r,this.cbs.ontext(this.sectionStart,r),this.index=n}this.isSpecial=!1,this.sectionStart=r+2,this.stateInClosingTagName(t);return}this.sequenceIndex=0}(t|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===te.TitleEnd?this.decodeEntities&&t===E.Amp&&this.startEntity():this.fastForwardTo(E.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(t===E.Lt)}stateCDATASequence(t){t===te.Cdata[this.sequenceIndex]?++this.sequenceIndex===te.Cdata.length&&(this.state=g.InCommentLike,this.currentSequence=te.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=g.InDeclaration,this.stateInDeclaration(t))}fastForwardTo(t){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===t)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(t){t===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===te.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=g.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):t!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(t){return this.xmlMode?!Pt(t):Xc(t)}startSpecial(t,r){this.isSpecial=!0,this.currentSequence=t,this.sequenceIndex=r,this.state=g.SpecialStartSequence}stateBeforeTagName(t){if(t===E.ExclamationMark)this.state=g.BeforeDeclaration,this.sectionStart=this.index+1;else if(t===E.Questionmark)this.state=g.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(t)){const r=t|32;this.sectionStart=this.index,this.xmlMode?this.state=g.InTagName:r===te.ScriptEnd[2]?this.state=g.BeforeSpecialS:r===te.TitleEnd[2]||r===te.XmpEnd[2]?this.state=g.BeforeSpecialT:this.state=g.InTagName}else t===E.Slash?this.state=g.BeforeClosingTagName:(this.state=g.Text,this.stateText(t))}stateInTagName(t){Pt(t)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=g.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateBeforeClosingTagName(t){Se(t)||(t===E.Gt?this.state=g.Text:(this.state=this.isTagStartChar(t)?g.InClosingTagName:g.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(t){(t===E.Gt||Se(t))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=g.AfterClosingTagName,this.stateAfterClosingTagName(t))}stateAfterClosingTagName(t){(t===E.Gt||this.fastForwardTo(E.Gt))&&(this.state=g.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(t){t===E.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=g.InSpecialTag,this.sequenceIndex=0):this.state=g.Text,this.sectionStart=this.index+1):t===E.Slash?this.state=g.InSelfClosingTag:Se(t)||(this.state=g.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(t){t===E.Gt?(this.cbs.onselfclosingtag(this.index),this.state=g.Text,this.sectionStart=this.index+1,this.isSpecial=!1):Se(t)||(this.state=g.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateInAttributeName(t){(t===E.Eq||Pt(t))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=g.AfterAttributeName,this.stateAfterAttributeName(t))}stateAfterAttributeName(t){t===E.Eq?this.state=g.BeforeAttributeValue:t===E.Slash||t===E.Gt?(this.cbs.onattribend(ve.NoValue,this.sectionStart),this.sectionStart=-1,this.state=g.BeforeAttributeName,this.stateBeforeAttributeName(t)):Se(t)||(this.cbs.onattribend(ve.NoValue,this.sectionStart),this.state=g.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(t){t===E.DoubleQuote?(this.state=g.InAttributeValueDq,this.sectionStart=this.index+1):t===E.SingleQuote?(this.state=g.InAttributeValueSq,this.sectionStart=this.index+1):Se(t)||(this.sectionStart=this.index,this.state=g.InAttributeValueNq,this.stateInAttributeValueNoQuotes(t))}handleInAttributeValue(t,r){t===r||!this.decodeEntities&&this.fastForwardTo(r)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(r===E.DoubleQuote?ve.Double:ve.Single,this.index+1),this.state=g.BeforeAttributeName):this.decodeEntities&&t===E.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(t){this.handleInAttributeValue(t,E.DoubleQuote)}stateInAttributeValueSingleQuotes(t){this.handleInAttributeValue(t,E.SingleQuote)}stateInAttributeValueNoQuotes(t){Se(t)||t===E.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(ve.Unquoted,this.index),this.state=g.BeforeAttributeName,this.stateBeforeAttributeName(t)):this.decodeEntities&&t===E.Amp&&this.startEntity()}stateBeforeDeclaration(t){t===E.OpeningSquareBracket?(this.state=g.CDATASequence,this.sequenceIndex=0):this.state=t===E.Dash?g.BeforeComment:g.InDeclaration}stateInDeclaration(t){(t===E.Gt||this.fastForwardTo(E.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=g.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(t){(t===E.Gt||this.fastForwardTo(E.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=g.Text,this.sectionStart=this.index+1)}stateBeforeComment(t){t===E.Dash?(this.state=g.InCommentLike,this.currentSequence=te.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=g.InDeclaration}stateInSpecialComment(t){(t===E.Gt||this.fastForwardTo(E.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=g.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(t){const r=t|32;r===te.ScriptEnd[3]?this.startSpecial(te.ScriptEnd,4):r===te.StyleEnd[3]?this.startSpecial(te.StyleEnd,4):(this.state=g.InTagName,this.stateInTagName(t))}stateBeforeSpecialT(t){switch(t|32){case te.TitleEnd[3]:{this.startSpecial(te.TitleEnd,4);break}case te.TextareaEnd[3]:{this.startSpecial(te.TextareaEnd,4);break}case te.XmpEnd[3]:{this.startSpecial(te.XmpEnd,4);break}default:this.state=g.InTagName,this.stateInTagName(t)}}startEntity(){this.baseState=this.state,this.state=g.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?$e.Strict:this.baseState===g.Text||this.baseState===g.InSpecialTag?$e.Legacy:$e.Attribute)}stateInEntity(){const t=this.index-this.offset,r=this.entityDecoder.write(this.buffer,t);if(r>=0)this.state=this.baseState,r===0&&(this.index-=1);else{if(t<this.buffer.length&&this.buffer.charCodeAt(t)===E.Amp){this.state=this.baseState,this.index-=1;return}this.index=this.offset+this.buffer.length-1}}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===g.Text||this.state===g.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===g.InAttributeValueDq||this.state===g.InAttributeValueSq||this.state===g.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const t=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case g.Text:{this.stateText(t);break}case g.SpecialStartSequence:{this.stateSpecialStartSequence(t);break}case g.InSpecialTag:{this.stateInSpecialTag(t);break}case g.CDATASequence:{this.stateCDATASequence(t);break}case g.InAttributeValueDq:{this.stateInAttributeValueDoubleQuotes(t);break}case g.InAttributeName:{this.stateInAttributeName(t);break}case g.InCommentLike:{this.stateInCommentLike(t);break}case g.InSpecialComment:{this.stateInSpecialComment(t);break}case g.BeforeAttributeName:{this.stateBeforeAttributeName(t);break}case g.InTagName:{this.stateInTagName(t);break}case g.InClosingTagName:{this.stateInClosingTagName(t);break}case g.BeforeTagName:{this.stateBeforeTagName(t);break}case g.AfterAttributeName:{this.stateAfterAttributeName(t);break}case g.InAttributeValueSq:{this.stateInAttributeValueSingleQuotes(t);break}case g.BeforeAttributeValue:{this.stateBeforeAttributeValue(t);break}case g.BeforeClosingTagName:{this.stateBeforeClosingTagName(t);break}case g.AfterClosingTagName:{this.stateAfterClosingTagName(t);break}case g.BeforeSpecialS:{this.stateBeforeSpecialS(t);break}case g.BeforeSpecialT:{this.stateBeforeSpecialT(t);break}case g.InAttributeValueNq:{this.stateInAttributeValueNoQuotes(t);break}case g.InSelfClosingTag:{this.stateInSelfClosingTag(t);break}case g.InDeclaration:{this.stateInDeclaration(t);break}case g.BeforeDeclaration:{this.stateBeforeDeclaration(t);break}case g.BeforeComment:{this.stateBeforeComment(t);break}case g.InProcessingInstruction:{this.stateInProcessingInstruction(t);break}case g.InEntity:{this.stateInEntity();break}}this.index++}this.cleanup()}finish(){this.state===g.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){const t=this.buffer.length+this.offset;this.sectionStart>=t||(this.state===g.InCommentLike?this.currentSequence===te.CdataEnd?this.cbs.oncdata(this.sectionStart,t,0):this.cbs.oncomment(this.sectionStart,t,0):this.state===g.InTagName||this.state===g.BeforeAttributeName||this.state===g.BeforeAttributeValue||this.state===g.AfterAttributeName||this.state===g.InAttributeName||this.state===g.InAttributeValueSq||this.state===g.InAttributeValueDq||this.state===g.InAttributeValueNq||this.state===g.InClosingTagName||this.cbs.ontext(this.sectionStart,t))}emitCodePoint(t,r){this.baseState!==g.Text&&this.baseState!==g.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+r,this.index=this.sectionStart-1,this.cbs.onattribentity(t)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+r,this.index=this.sectionStart-1,this.cbs.ontextentity(t,this.sectionStart))}}const Xe=new Set(["input","option","optgroup","select","button","datalist","textarea"]),D=new Set(["p"]),_n=new Set(["thead","tbody"]),Dn=new Set(["dd","dt"]),Ln=new Set(["rt","rp"]),Hc=new Map([["tr",new Set(["tr","th","td"])],["th",new Set(["th"])],["td",new Set(["thead","th","td"])],["body",new Set(["head","link","script"])],["li",new Set(["li"])],["p",D],["h1",D],["h2",D],["h3",D],["h4",D],["h5",D],["h6",D],["select",Xe],["input",Xe],["output",Xe],["button",Xe],["datalist",Xe],["textarea",Xe],["option",new Set(["option"])],["optgroup",new Set(["optgroup","option"])],["dd",Dn],["dt",Dn],["address",D],["article",D],["aside",D],["blockquote",D],["details",D],["div",D],["dl",D],["fieldset",D],["figcaption",D],["figure",D],["footer",D],["form",D],["header",D],["hr",D],["main",D],["nav",D],["ol",D],["pre",D],["section",D],["table",D],["ul",D],["rt",Ln],["rp",Ln],["tbody",_n],["tfoot",_n]]),Jc=new Set(["area","base","basefont","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr"]),Nn=new Set(["math","svg"]),Yn=new Set(["mi","mo","mn","ms","mtext","annotation-xml","foreignobject","desc","title"]),Zc=/\s|\//;class qc{constructor(t,r={}){var n,s,i,a,o,c;this.options=r,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname="",this.attribname="",this.attribvalue="",this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=t??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=(n=r.lowerCaseTags)!==null&&n!==void 0?n:this.htmlMode,this.lowerCaseAttributeNames=(s=r.lowerCaseAttributeNames)!==null&&s!==void 0?s:this.htmlMode,this.recognizeSelfClosing=(i=r.recognizeSelfClosing)!==null&&i!==void 0?i:!this.htmlMode,this.tokenizer=new((a=r.Tokenizer)!==null&&a!==void 0?a:zc)(this.options,this),this.foreignContext=[!this.htmlMode],(c=(o=this.cbs).onparserinit)===null||c===void 0||c.call(o,this)}ontext(t,r){var n,s;const i=this.getSlice(t,r);this.endIndex=r-1,(s=(n=this.cbs).ontext)===null||s===void 0||s.call(n,i),this.startIndex=r}ontextentity(t,r){var n,s;this.endIndex=r-1,(s=(n=this.cbs).ontext)===null||s===void 0||s.call(n,Un(t)),this.startIndex=r}isVoidElement(t){return this.htmlMode&&Jc.has(t)}onopentagname(t,r){this.endIndex=r;let n=this.getSlice(t,r);this.lowerCaseTagNames&&(n=n.toLowerCase()),this.emitOpenTag(n)}emitOpenTag(t){var r,n,s,i;this.openTagStart=this.startIndex,this.tagname=t;const a=this.htmlMode&&Hc.get(t);if(a)for(;this.stack.length>0&&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))),(i=(s=this.cbs).onopentagname)===null||i===void 0||i.call(s,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,s,i,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=(i=this.cbs).onopentagname)===null||a===void 0||a.call(i,"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();(s=(n=this.cbs).onclosetag)===null||s===void 0||s.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 s=this.tagname;this.endOpenTag(t),this.stack[0]===s&&((n=(r=this.cbs).onclosetag)===null||n===void 0||n.call(r,s,!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,s;this.endIndex=r,(s=(n=this.cbs).onattribute)===null||s===void 0||s.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 s=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${s}`,`!${n}`)}this.startIndex=r+1}onprocessinginstruction(t,r){this.endIndex=r;const n=this.getSlice(t,r);if(this.cbs.onprocessinginstruction){const s=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${s}`,`?${n}`)}this.startIndex=r+1}oncomment(t,r,n){var s,i,a,o;this.endIndex=r,(i=(s=this.cbs).oncomment)===null||i===void 0||i.call(s,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 s,i,a,o,c,u,h,l,f,A;this.endIndex=r;const d=this.getSlice(t,r-n);!this.htmlMode||this.options.recognizeCDATA?((i=(s=this.cbs).oncdatastart)===null||i===void 0||i.call(s),(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.stack.length;n++)this.cbs.onclosetag(this.stack[n],!0)}(r=(t=this.cbs).onend)===null||r===void 0||r.call(t)}reset(){var t,r,n,s;(r=(t=this.cbs).onreset)===null||r===void 0||r.call(t),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(s=(n=this.cbs).onparserinit)===null||s===void 0||s.call(n,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(t){this.reset(),this.end(t)}getSlice(t,r){for(;t-this.bufferOffset>=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.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(t){this.write(t)}done(t){this.end(t)}}var G;(function(e){e.Root="root",e.Text="text",e.Directive="directive",e.Comment="comment",e.Script="script",e.Style="style",e.Tag="tag",e.CDATA="cdata",e.Doctype="doctype"})(G||(G={}));function jc(e){return e.type===G.Tag||e.type===G.Script||e.type===G.Style}G.Root;G.Text;G.Directive;G.Comment;G.Script;G.Style;G.Tag;G.CDATA;G.Doctype;class js{constructor(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}get parentNode(){return this.parent}set parentNode(t){this.parent=t}get previousSibling(){return this.prev}set previousSibling(t){this.prev=t}get nextSibling(){return this.next}set nextSibling(t){this.next=t}cloneNode(t=!1){return si(this,t)}}class pn extends js{constructor(t){super(),this.data=t}get nodeValue(){return this.data}set nodeValue(t){this.data=t}}class Lr extends pn{constructor(){super(...arguments),this.type=G.Text}get nodeType(){return 3}}class ei extends pn{constructor(){super(...arguments),this.type=G.Comment}get nodeType(){return 8}}class ti extends pn{constructor(t,r){super(r),this.name=t,this.type=G.Directive}get nodeType(){return 1}}class mn extends js{constructor(t){super(),this.children=t}get firstChild(){var t;return(t=this.children[0])!==null&&t!==void 0?t:null}get lastChild(){return this.children.length>0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(t){this.children=t}}class ri 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 ni extends mn{constructor(t,r,n=[],s=t==="script"?G.Script:t==="style"?G.Style:G.Tag){super(n),this.name=t,this.attribs=r,this.type=s}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 sl(e){return e.type===G.Directive}function il(e){return e.type===G.Root}function si(e,t=!1){let r;if(rl(e))r=new Lr(e.data);else if(nl(e))r=new ei(e.data);else if(el(e)){const n=t?Cr(e.children):[],s=new ni(e.name,{...e.attribs},n);n.forEach(i=>i.parent=s),e.namespace!=null&&(s.namespace=e.namespace),e["x-attribsNamespace"]&&(s["x-attribsNamespace"]={...e["x-attribsNamespace"]}),e["x-attribsPrefix"]&&(s["x-attribsPrefix"]={...e["x-attribsPrefix"]}),r=s}else if(tl(e)){const n=t?Cr(e.children):[],s=new ri(n);n.forEach(i=>i.parent=s),r=s}else if(il(e)){const n=t?Cr(e.children):[],s=new Nr(n);n.forEach(i=>i.parent=s),e["x-mode"]&&(s["x-mode"]=e["x-mode"]),r=s}else if(sl(e)){const n=new ti(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=>si(r,!0));for(let r=1;r<t.length;r++)t[r].prev=t[r-1],t[r-1].next=t[r];return t}const Wn={withStartIndices:!1,withEndIndices:!1,xmlMode:!1};class al{constructor(t,r,n){this.dom=[],this.root=new Nr(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof r=="function"&&(n=r,r=Wn),typeof t=="object"&&(r=t,t=void 0),this.callback=t??null,this.options=r??Wn,this.elementCB=n??null}onparserinit(t){this.parser=t}onreset(){this.dom=[],this.root=new Nr(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null}onend(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))}onerror(t){this.handleCallback(t)}onclosetag(){this.lastNode=null;const t=this.tagStack.pop();this.options.withEndIndices&&(t.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(t)}onopentag(t,r){const n=this.options.xmlMode?G.Tag:void 0,s=new ni(t,r,void 0,n);this.addNode(s),this.tagStack.push(s)}ontext(t){const{lastNode:r}=this;if(r&&r.type===G.Text)r.data+=t,this.options.withEndIndices&&(r.endIndex=this.parser.endIndex);else{const n=new Lr(t);this.addNode(n),this.lastNode=n}}oncomment(t){if(this.lastNode&&this.lastNode.type===G.Comment){this.lastNode.data+=t;return}const r=new ei(t);this.addNode(r),this.lastNode=r}oncommentend(){this.lastNode=null}oncdatastart(){const t=new Lr(""),r=new ri([t]);this.addNode(r),t.parent=r,this.lastNode=t}oncdataend(){this.lastNode=null}onprocessinginstruction(t,r){const n=new ti(t,r);this.addNode(n)}handleCallback(t){if(typeof this.callback=="function")this.callback(t,this.dom);else if(t)throw t}addNode(t){const r=this.tagStack[this.tagStack.length-1],n=r.children[r.children.length-1];this.options.withStartIndices&&(t.startIndex=this.parser.startIndex),this.options.withEndIndices&&(t.endIndex=this.parser.endIndex),r.children.push(t),n&&(t.prev=n,n.next=t),t.parent=r,this.lastNode=null}}function ol(e,t){const r=new al(void 0,t);return new qc(r,t).end(e),r.root}const ii=e=>{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=ii(t);const n=De.measureText(""),s={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(s),e.textTable.push(s)},cl=e=>{const t=e.heightTable.length-1;for(let r=1;r<t;++r){if(e.heightTable[r]>0)continue;const s=e.lineTable[r];s&&(e.heightTable[r]=s.h=e.heightTable[r-1])}},ai=e=>{let t=0;return e.leftMargin&&(t+=e.leftMargin),e.rightMargin&&(t+=e.rightMargin),t},ll=(e,t,r,n)=>{let s=r.lineTable.length-1;const i=n.width-ai(t)-4;for(let a=0;a<e.length;++a){const o=n.textFormats?n.textFormats.shift():t,c=e[a],u={mode:"text",text:c,x:0,y:0,w:0,h:0,line:s,textFormat:o.toObject()};De.font=ii(o);const h=De.measureText(c||""),l=o.letterSpacing?h.width+o.letterSpacing:h.width,f=o.leading?h.fontBoundingBoxAscent+h.fontBoundingBoxDescent+o.leading:h.fontBoundingBoxAscent+h.fontBoundingBoxDescent;if(u.x=0,u.y=h.fontBoundingBoxAscent,u.w=l,u.h=f,dt(Et()+l),n.wordWrap&&Et()>i){dt(l),s++,u.line=s;const A={mode:"wrap",text:"",x:0,y:0,w:0,h:0,line:s,textFormat:o.toObject()};let d=1,y=!0;const m=/[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(m)){d--;break}d++}if(r.widthTable[s]=0,r.heightTable[s]=0,r.ascentTable[s]=0,d>0&&y){const p=r.textTable.length-d;r.textTable.splice(p,0,A),r.lineTable.push(A);const $=s-1;r.widthTable[$]=0,r.heightTable[$]=0,r.ascentTable[$]=0;for(let w=0;w<p;++w){const I=r.textTable[w];I&&I.line===$&&I.mode==="text"&&(r.widthTable[$]+=I.w,r.heightTable[$]=Math.max(r.heightTable[$],I.h),r.ascentTable[$]=Math.max(r.ascentTable[$],I.y))}dt(0);for(let w=p+1;w<r.textTable.length;++w){const I=r.textTable[w];I.line=s,dt(Et()+I.w)}}else r.textTable.push(A),r.lineTable.push(A)}r.widthTable[s]=Et(),r.heightTable[s]=Math.max(r.heightTable[s],f),r.ascentTable[s]=Math.max(r.ascentTable[s],u.y),r.textTable.push(u)}},ul=e=>{const t=e.trim().split(";"),r=[];for(let n=0;n<t.length;++n){const s=t[n];if(!s)continue;const i=s.split(":"),a=i[0].trim(),o=i[1].trim();switch(a){case"font-size":r.push({name:"size",value:parseInt(o)});break;case"font-family":r.push({name:"face",value:o.replace(/'|"/g,"")});break;case"letter-spacing":r.push({name:"letterSpacing",value:parseInt(o)});break;case"margin-bottom":r.push({name:"leading",value:parseInt(o)});break;case"margin-left":r.push({name:"leftMargin",value:parseInt(o)});break;case"margin-right":r.push({name:"rightMargin",value:parseInt(o)});break;case"color":case"align":r.push({name:a,value:o});break;case"text-decoration":case"font-weight":case"font-style":r.push({name:o,value:!0});break}}return r},Wr=(e,t,r)=>{for(let n=0;n<e.length;++n){const s=e[n];switch(s.name){case"style":Wr(ul(s.value),t,r);break;case"align":t.align=s.value;break;case"face":t.font=s.value;break;case"size":t.size=+s.value,r.subFontSize&&(t.size-=r.subFontSize,1>t.size&&(t.size=1));break;case"color":t.color=et(s.value);break;case"letterSpacing":t.letterSpacing=parseInt(s.value);break;case"leading":t.leading=parseInt(s.value);break;case"leftMargin":t.leftMargin=parseInt(s.value);break;case"rightMargin":t.rightMargin=parseInt(s.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 s=0;s<e.children.length;++s){const i=e.children[s];if(i.nodeType===3){ll(i.nodeValue||"",t,r,n);continue}const a=t.clone();switch(i.name.toUpperCase()){case"DIV":case"P":Wr(i.attributes,a,n),n.multiline&&Yr(r,a),Vr(i,a,r,n);continue;case"U":a.underline=!0;break;case"B":a.bold=!0;break;case"I":a.italic=!0;break;case"FONT":case"SPAN":Wr(i.attributes,a,n);break;case"BR":if(!n.multiline)continue;Yr(r,a);break}Vr(i,a,r,n)}},hl=(e,t,r)=>{const n=new Gc;if(!e)return n;const s=e.trim().replace(/\r?\n/g,"").replace(/\t/g,""),i=t.clone();return r.subFontSize&&r.subFontSize>0&&i.size&&(i.size-=r.subFontSize,1>i.size&&(i.size=1)),Yr(n,i),Vr(ol(s),i,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+ai(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 s=0;s<r.textTable.length;++s){const i=r.textTable[s];t=Math.max(t,i.textFormat.size||0)}let n=1;if(e.width&&e.textWidth)for(;t>n&&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,s=0;for(let f=1;f<r.textTable.length;++f){const A=r.textTable[f];if(!A)continue;let d=!1;if(A.mode==="text"&&(d=!0,n+=A.w),s>=t){s=f;break}A.mode==="break"&&(d=!0,n=2),d&&s++}const i=r.textTable[s];if(!i)return;e.$scrollX=e.$scrollY=0;const a=i.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(c<u+A)break;u+=A}if(o>c){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=s;f>0;--f){const A=r.textTable[f];if(A.mode==="text"){if(h<l+A.w)break;l+=A.w}}if(n>h){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),Zs(void 0)},pl=window.devicePixelRatio,ml=e=>{const t=e.localToGlobal(new ie),r=e.$textData;if(r){const s=r.textTable[e.focusIndex];if(s){for(let a=e.focusIndex-1;a>-1;--a){const o=r.textTable[a];if(!o||o.line!==s.line)break;t.x+=o.w}const i=s.mode==="break"?s.line-1:s.line;for(let a=0;a<i;++a)t.y+=r.heightTable[a]}}const n=v.rendererScale/pl;de.style.left=`${Je.x+t.x*n}px`,de.style.top=`${Je.y+t.y*n}px`},pe=e=>{e.focusVisible=!e.focusVisible,K(e),Zs(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 s=1.70158;return(e/=n/2)<1?e*e*(((s*=1.525)+1)*e-s)*r/2+t:((e-=2)*e*(((s*=1.525)+1)*e+s)+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<n/2?Ye.inBounce(e*2,t,r/2,n):Ye.outBounce(e*2-n,t+r/2,r/2,n);class Ye{static linear(t,r,n,s){return bl(t,r,n,s)}static inQuad(t,r,n,s){return xl(t,r,n,s)}static outQuad(t,r,n,s){return yl(t,r,n,s)}static inOutQuad(t,r,n,s){return $l(t,r,n,s)}static inCubic(t,r,n,s){return vl(t,r,n,s)}static outCubic(t,r,n,s){return wl(t,r,n,s)}static inOutCubic(t,r,n,s){return Ml(t,r,n,s)}static inQuart(t,r,n,s){return Bl(t,r,n,s)}static outQuart(t,r,n,s){return Tl(t,r,n,s)}static inOutQuart(t,r,n,s){return Sl(t,r,n,s)}static inQuint(t,r,n,s){return Il(t,r,n,s)}static outQuint(t,r,n,s){return Cl(t,r,n,s)}static inOutQuint(t,r,n,s){return Fl(t,r,n,s)}static inSine(t,r,n,s){return El(t,r,n,s)}static outSine(t,r,n,s){return Pl(t,r,n,s)}static inOutSine(t,r,n,s){return Rl(t,r,n,s)}static inExpo(t,r,n,s){return Ol(t,r,n,s)}static outExpo(t,r,n,s){return kl(t,r,n,s)}static inOutExpo(t,r,n,s){return Ul(t,r,n,s)}static inCirc(t,r,n,s){return Gl(t,r,n,s)}static outCirc(t,r,n,s){return _l(t,r,n,s)}static inOutCirc(t,r,n,s){return Dl(t,r,n,s)}static inBack(t,r,n,s){return Ll(t,r,n,s)}static outBack(t,r,n,s){return Nl(t,r,n,s)}static inOutBack(t,r,n,s){return Yl(t,r,n,s)}static inElastic(t,r,n,s){return Wl(t,r,n,s)}static outElastic(t,r,n,s){return Vl(t,r,n,s)}static inOutElastic(t,r,n,s){return Kl(t,r,n,s)}static outBounce(t,r,n,s){return Ql(t,r,n,s)}static inBounce(t,r,n,s){return Xl(t,r,n,s)}static inOutBounce(t,r,n,s){return zl(t,r,n,s)}}const Hl=e=>{cancelAnimationFrame(e.$timerId),e.hasEventListener(ye.STOP)&&e.dispatchEvent(new ye(ye.STOP)),e.entries=null,e.stopFlag=!0},oi=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({name:r,value:typeof n=="number"?n:oi(n)});return t},ci=(e,t,r,n,s)=>{for(let i=0;i<s.length;++i){const a=s[i];if(!a)continue;const o=a.name;if(!(o in t)||!(o in n))continue;if(typeof a.value!="number"){ci(e,t[o],r[o],n[o],a.value);continue}const c=r[o];e.duration>e.currentTime?t[o]=e.ease(e.currentTime,c,n[o]-c,e.duration):t[o]=n[o]}},li=(e,t)=>e.stopFlag||!e.entries?-1:(e.currentTime=(t-e.startTime)/1e3,ci(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=>{li(e,r)})),Vn=e=>{e.stopFlag||(e.entries=oi(e.from),e.entries&&(e.startTime=performance.now(),e.$timerId=li(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,s=0,i=1,a=null){super(),this.target=t,this.from=r,this.to=n,this.delay=s,this.duration=i,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,s=0,i=1,a=null){return new Zl(t,r,n,s,i,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 s=e.parent;if(s){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,s.addChildAt(n,s.getChildIndex(e)+1);const i=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);i.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),i.start(),n.setLocalVariable("job",i)}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 s=e.parent;if(s){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),s.addChildAt(n,s.getChildIndex(e)+1);const i=gn.add(n,{alpha:.9},{alpha:0},.5,.2,Ye.outQuad);i.addEventListener(x.COMPLETE,a=>{const o=a.target.target;o.deleteLocalVariable("job"),o.parent&&o.parent.removeChild(o)}),i.start(),n.setLocalVariable("job",i),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<r.textTable.length;++n){const s=r.textTable[n];if(s)switch(s.mode){case"text":t+=s.text;break;case"break":t+="\r";break;default:continue}}return t},tu=(e,t)=>{let r="";const n=H(e);for(let s=1;s<n.textTable.length;s++){const i=n.textTable[s];if(i){if(i.line>t)break;i.line===t&&i.mode==="text"&&(r+=i.text)}}return r},ru=(e,t,r,n)=>{if(0>r||r>n)return;const s=e.text,i=r?s.slice(0,r):"";e.text=i+t+s.slice(n,s.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,s=H(e);for(let i=r;i<n;++i){const a=s.textTable[i];if(a)switch(a.mode){case"text":t+=a.text;break;case"break":t+=`
|
|
2340
|
-
`;break}}await navigator.clipboard.writeText(t)},su=async e=>{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),s=n.textTable[e.focusIndex];s&&s.mode==="wrap"&&e.focusIndex--;const i=[];let a="";for(let o=1;o<n.textTable.length;++o){const c=n.textTable[o];if(c&&!(e.focusIndex===o||t<=o&&r>o))switch(c.mode){case"break":i.push(new ue(...Object.values(c.textFormat))),a+=`
|
|
2341
|
-
`;break;case"text":i.push(new ue(...Object.values(c.textFormat))),a+=c.text;break;default:continue}}if(n.textTable.length===e.focusIndex&&(i.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=i,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}},ui=(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 s="";for(let i=1;i<r.textTable.length;++i){const a=r.textTable[i];if(a){if(e.focusIndex===i)for(let o=0;o<t.length;++o)n.push(new ue(...Object.values(a.textFormat))),s+=t[o];switch(a.mode){case"break":n.push(new ue(...Object.values(a.textFormat))),s+=`
|
|
2342
|
-
`;break;case"text":n.push(new ue(...Object.values(a.textFormat))),s+=a.text;break;default:continue}}}if(r.textTable.length===e.focusIndex){let i;if(r.textTable.length){const a=r.textTable[r.textTable.length-1];i=new ue(...Object.values(a.textFormat))}else i=e.defaultTextFormat,e.focusIndex++;for(let a=0;a<t.length;++a)n.push(new ue(...Object.values(i.toObject()))),s+=t[a]}e.$textFormats=n,e.text=s,e.$textFormats=null,e.focusIndex+=t.length,e.selectIndex=-1,de.value=""},Kn=e=>{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,s=e.height,i=(e.textHeight-s)/s;let a=-e.scrollY*i-2,o=0;for(let d=0;d<t.heightTable.length&&(a+=t.heightTable[d],!(a>s));++d)o++;a=-e.scrollY*i-2;let c=0;for(let d=0;d<t.heightTable.length&&(a+=t.heightTable[d],!(a>0));++d)c++;c>=r.line&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY-=t.heightTable[r.line]/i),r.line>=o&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=t.heightTable[r.line]/i);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))},iu=(e,t,r,n=!1)=>{if(e.type!=="input")return;const s=H(e);if(2>s.textTable.length){e.focusIndex=1,e.selectIndex=-1,Ht()===void 0&&pe(e);return}const i=e.width,a=e.height;let o=0;e.scrollX>0&&(o+=e.scrollX*(e.textWidth-i)/i);let c=0;e.scrollY>0&&(c+=e.scrollY*(e.textHeight-a)/a);const u=e.globalToLocal(new ie(t,r)),h=u.x+o,l=u.y+c;let f=2,A=2,d=A+s.heightTable[0];for(let y=1;y<s.textTable.length;++y){const m=s.textTable[y];if(m){switch(m.mode){case"break":case"wrap":if(h>f&&l>A&&d>l&&i>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+=s.heightTable[m.line-1],d=A+s.heightTable[m.line];break;case"text":if(h>f&&l>A&&d>l&&f+m.w>h){let p=y;if(n)e.focusIndex>p?e.focusIndex===p+1?f+m.w/2<h&&(p=-1):f+m.w/2<h&&(p+=1):e.focusIndex===p?f+m.w/2>h&&(p=-1):f+m.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+m.w/2<h){const $=s.textTable[p+1];(!$||$.mode==="text")&&(p+=1)}(e.focusIndex!==p||e.selectIndex>-1)&&(e.focusIndex=p,e.selectIndex=-1,K(e))}return}if(y===s.textTable.length-1&&h>f&&l>A&&d>l&&i>h){const p=s.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+=m.w;break}if(!n)e.focusIndex=s.textTable.length,e.selectIndex=-1,Ht()===void 0?pe(e):K(e);else{let p=0;for(let $=0;s.heightTable.length>$;++$)p+=s.heightTable[$];(l>p||2>l)&&(e.selectIndex=2>l?1:s.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 s=n.mode==="text"?n.line:n.line-1;if(s===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 m=r.textTable[y];if(!m||m.line>s)break;m.line===s&&(d+=m.w)}e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=(d-f)/A,fe(),pe(e);return}const i=e.height,a=(e.textHeight-i)/i;let o=-e.scrollY*a-2,c=0;for(let f=0;f<r.heightTable.length&&(o+=r.heightTable[f],!(o>i));++f)c++;let u=2;for(let f=1;f<r.textTable.length;++f){const A=r.textTable[f];if(A){if(e.focusIndex===f){A.mode==="text"&&(u+=A.w/2);break}if(A.line>s)break;A.line!==s||A.mode!=="text"||(u+=A.w)}}let h=2;const l=s+1;for(let f=1;f<r.textTable.length;++f){const A=r.textTable[f];if(A){if(A.line>l){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&&h<u&&(e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width*((h-2)/e.textWidth)),fe(),pe(e);return}if(!(A.line!==l||A.mode!=="text")&&(h+=A.w,h>u)){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,s=r.textTable[n];if(!s||!s.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 i=s.mode==="text"?s.line:s.line-1,a=e.height,o=(e.textHeight-a)/a;let c=0,u=-e.scrollY*o-2;for(let A=0;A<r.heightTable.length&&(u+=r.heightTable[A],!(u>0));++A)c++;let h=2;for(let A=1;A<r.textTable.length;++A){const d=r.textTable[A];if(d){if(e.focusIndex===A){d.mode==="text"&&(h+=d.w/2);break}if(d.line>i)break;d.line!==i||d.mode!=="text"||(h+=d.w)}}let l=2;const f=i-1;for(let A=1;A<r.textTable.length;++A){const d=r.textTable[A];if(d){if(d.line>f){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 s=n.mode==="text"?n.line:n.line-1,i=e.height,a=(e.textHeight-i)/i;let o=-e.scrollY*a-2,c=0;for(let h=0;h<r.heightTable.length&&(o+=r.heightTable[h],!(o>0));++h)c++;c>s&&(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 m=r.textTable[y];if(!m||m.line>s)break;m.line===s&&(l+=m.w)}const f=e.width,A=(e.textWidth-f)/f,d=e.scrollX*A-2;if(l>f&&u&&s<h){e.yScrollShape.hasLocalVariable("job")&&e.yScrollShape.deleteLocalVariable("job"),e.scrollX=e.width;return}if(d>l){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 s=n.mode==="text"?n.line:n.line-1,i=e.height,a=(e.textHeight-i)/i;let o=-e.scrollY*a-2,c=0;for(let d=0;d<r.heightTable.length&&(o+=r.heightTable[d],!(o>i));++d)c++;s>=c&&(e.xScrollShape.hasLocalVariable("job")&&e.xScrollShape.deleteLocalVariable("job"),e.scrollY+=r.heightTable[s]/a);const u=r.textTable[e.focusIndex-1],h=u.mode==="text"?u.line:u.line-1;if(u&&s>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>s)break;if(y.line===s&&(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(`
|
|
2343
|
-
`);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=`<span style="${t}">${this._$text.replace(/\n/g,"<br>")}</span>`,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){ui(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(){su(this)}setFocusIndex(t,r,n=!1){iu(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=[],s=t.length;let i="";if(2>r.textTable.length)i=t,e.focusIndex=1,e.compositionStartIndex=1;else{for(let o=1;o<r.textTable.length;++o){const c=r.textTable[o];if(c){if(e.compositionStartIndex===o)for(let u=0;u<s;++u)n.push(new ue(...Object.values(c.textFormat))),i+=t[u];switch(c.mode){case"break":n.push(new ue(...Object.values(c.textFormat))),i+=`
|
|
2344
|
-
`;break;case"text":n.push(new ue(...Object.values(c.textFormat))),i+=c.text;break;default:continue}}}if(e.compositionStartIndex===r.textTable.length){const o=r.textTable[e.compositionStartIndex-1];if(!o)return;for(let c=0;c<s;++c)n.push(new ue(...Object.values(o.textFormat))),i+=t[c]}}n.length&&(e.$textFormats=n),e.text=i,e.$textFormats=null,r=H(e);let a=e.compositionStartIndex+s;for(let o=e.compositionStartIndex;o<a;++o){const c=r.textTable[o];if(!c)break;if(c.textFormat.underline=!0,c.mode==="wrap"){if(o===e.compositionStartIndex){let u=1;for(;;){const h=r.textTable[o-u];if(!h)break;if(h.mode==="text"){h.textFormat.underline=!0;break}u++}}o>e.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<e.compositionEndIndex;++r){const n=t.textTable[r];n&&(n.textFormat.underline=!1)}e.focusIndex=e.compositionEndIndex}de.blur(),de.value="",e.focus&&de.focus(),e.selectIndex=-1,e.compositionStartIndex=-1,e.compositionEndIndex=-1},bu=()=>{const e=ke();e&&gu(e)},xu=e=>{if(!e.data)return;const t=ke();t&&(ui(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 hi=[],$u=()=>hi,vu=e=>{hi.push(e)};let Le=null;const wu=()=>!!Le,Mu=()=>{Le||(Le=new AudioContext),Le.resume()},fi=()=>(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 s=0;s<n.length;++s){const i=n[s];r.addEventListener(i,e.event[i])}}for(let n=0;n<e.headers.length;++n){const s=e.headers[n];s&&r.setRequestHeader(s.name,s.value)}r.send(t)},xn=(e,t,r,n=null)=>{const s=+e;return isNaN(s)&&n!==null?n:Math.min(Math.max(t,isNaN(s)?0:s),r)};let di=1;const Tu=()=>di,Su=e=>{di=xn(e,0,1,1)},Iu=[],Jt=()=>Iu,Cu=[],fr=()=>Cu,Fu=e=>{Su(e);const t=Jt();for(let n=0;n<t.length;++n){const s=t[n];s&&(s.volume=e)}const r=fr();for(let n=0;n<r.length;++n){const s=r[n];s&&(s.volume=e)}},Eu=()=>{const e=Jt();for(let r=0;r<e.length;++r){const n=e[r];n&&n.stop()}const t=fr();for(let r=0;r<t.length;++r){const n=t[r];n&&n.pause()}e.length=0,t.length=0};class rt{static get volume(){return Tu()}static set volume(t){Fu(t)}static stopAll(){Eu()}}const Pu=e=>{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 fi().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)),199<r.status&&400>r.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=fi();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)})},Ai=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(()=>{Ai(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=Ai(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,s=-1)=>{const i=n.loaderInfo;if(!i)throw new Error("the loaderInfo or data is null.");e.parent=n,we.set(e,n.root),Dt.set(e,i),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=s},Qn=(e,t,r,n,s=-1)=>{switch(r.extends){case qt.namespace:{const i=new qt;return At(i,e,t,n,s),i.$sync(r),i}case $t.namespace:{const i=new $t;return At(i,e,t,n,s),i.$sync(r),i}case Qr.namespace:{const i=new Qr;return At(i,e,t,n,s),i.$sync(r),i}case Xr.namespace:{const i=new Xr;return At(i,e,t,n,s),i.$sync(r),i}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 s=e.currentFrame,i=n.controller[s];if(!i)return t;const a=[],o=n.dictionary;if(!t.length){for(let c=0;c<i.length;++c){if(!(c in i))continue;const u=i[c];if(typeof u!="number")continue;const h=o[u];if(!h)continue;const l=r.data.characters[h.characterId];if(!l)continue;const f=Qn(u,h,l,e,c);f&&(t.push(f),f.isContainerEnabled&&a.push(f))}return e.$container=a,t}for(let c=0;c<t.length;++c){const u=t[c];if(!u)continue;const h=u.startFrame,l=u.endFrame;if(h===1&&l===0||h<=s&&l>s){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<i.length;++c){if(!(c in i))continue;const u=i[c];if(typeof u!="number")continue;if(Rt.has(u)){const A=Rt.get(u);A.placeId=c,A.placeObject=null,t.push(A);continue}const h=o[u];if(!h)continue;const l=r.data.characters[h.characterId];if(!l)continue;const f=Qn(u,h,l,e,c);f&&(t.push(f),f.isContainerEnabled&&a.push(f))}return e.$container=a,Rt.clear(),t},Xu=(e,t)=>{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<t.length;++r){const n=t[r];if(!n)continue;n.script||(n.script=Function(n.action));const s=n.frame;e.has(s)||e.set(s,z()),e.get(s)?.push(n.script)}},sh=(e,t)=>{for(let r=0;r<t.length;++r){const n=t[r];n&&e.set(n.frame,new Ks(n.name,n.frame))}},ih=async(e,t,r)=>{const n=e.loaderInfo;if(!n)return;const s=n.data;if(!s)return;const i=s.characters;for(let a=0;a<r.length;++a){const o=r[a];if(!o)continue;const c=z();for(let u=0;u<o.sound.length;++u){const h=o.sound[u];if(!h)continue;const l=i[h.characterId];if(!l)continue;const f=new dr;f.loopCount=h.loopCount|0,f.volume=Math.min(rt.volume,h.volume),await f.$build(l),c.push(f)}t.set(o.frame,c)}},ah=(e,t)=>{t.actions&&(e.$actions||(e.$actions=new Map),nh(e.$actions,t.actions)),t.sounds&&(e.$sounds||(e.$sounds=new Map),ih(e,e.$sounds,t.sounds)),t.labels&&(e.$labels||(e.$labels=new Map),sh(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<t.symbols.length;++a){const o=t.symbols[a];r.set(o[0],o[1])}const n=e.contentLoaderInfo;n.data={stage:t.stage,characters:t.characters,symbols:r};const s=new qt,i=t.characters[0];At(s,-1,{characterId:0,name:"main",clipDepth:0,endFrame:i.controller.length,startFrame:1},e),s.$sync(i,n),s.parent=null,n.content=s,n.willTrigger(x.COMPLETE)&&n.dispatchEvent(new x(x.COMPLETE))},pi=`(function(){"use strict";var l=Uint8Array,k=Uint16Array,tr=Int32Array,W=new l([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),X=new l([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ur=new l([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Y=function(r,e){for(var n=new k(31),i=0;i<31;++i)n[i]=e+=1<<r[i-1];for(var f=new tr(n[30]),i=1;i<30;++i)for(var g=n[i];g<n[i+1];++g)f[g]=g-n[i]<<5|i;return{b:n,r:f}},Z=Y(W,2),$=Z.b,cr=Z.r;$[28]=258,cr[258]=28;for(var wr=Y(X,0),gr=wr.b,O=new k(32768),v=0;v<32768;++v){var b=(v&43690)>>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<i;++f)r[f]&&++g[r[f]-1];var s=new k(e);for(f=1;f<e;++f)s[f]=s[f-1]+g[f-1]<<1;var h;if(n){h=new k(1<<e);var p=15-e;for(f=0;f<i;++f)if(r[f])for(var C=f<<4|r[f],y=e-r[f],a=s[r[f]-1]++<<y,o=a|(1<<y)-1;a<=o;++a)h[O[a]>>p]=C}else for(h=new k(i),f=0;f<i;++f)r[f]&&(h[f]=O[s[r[f]-1]++]>>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;n<r.length;++n)r[n]>e&&(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<L;++u)K[ur[u]]=c(r,a+u*3,7);a+=L*3;for(var rr=B(K),Mr=(1<<rr)-1,Ur=m(K,rr,1),u=0;u<d;){var er=Ur[c(r,a,Mr)];a+=er&15;var w=er>>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<<E)-1,Ir=(1<<T)-1,P=a;;P=a){var x=F[J(r,a)&Dr],S=x>>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<<U)-1)+$[u],a+=U}var Q=D[J(r,a)&Ir],V=Q>>4;Q||t(3),a+=Q&15;var z=gr[V];if(V>3){var U=X[V];z+=J(r,a)&(1<<U)-1,a+=U}if(a>R){p&&t(0);break}h&&C(o+131072);var ir=o+ar;if(o<z){var fr=g-z,Or=Math.min(z,ir);for(fr+o<0&&t(3);o<Or;++o)n[o]=i[fr+o]}for(;o<ir;++o)n[o]=n[o-z]}}e.l=F,e.p=P,e.b=o,e.f=y,F&&(y=1,e.m=E,e.d=D,e.n=T)}while(!y);return o!=n.length&&s?yr(n,0,o):n.subarray(0,o)},Fr=new l(0),kr=function(r){(r[0]!=31||r[1]!=139||r[2]!=8)&&t(6,"invalid gzip data");var e=r[3],n=10;e&4&&(n+=(r[10]|r[11]<<8)+2);for(var i=(e>>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<e.length;i+=4096)n+=String.fromCharCode(...e.subarray(i,i+4096));self.postMessage(JSON.parse(decodeURIComponent(n)))})})();
|
|
2345
|
-
`,zn=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",pi],{type:"text/javascript;charset=utf-8"});function oh(e){let t;try{if(t=zn&&(self.URL||self.webkitURL).createObjectURL(zn),!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(pi),{name:e?.name})}}const Hn=new oh,mi=async(e,t)=>{t.type==="zlib"?await new Promise(r=>{Hn.onmessage=s=>{Xn(e,s.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 s=oo(r.getAllResponseHeaders());n.dispatchEvent(new Gt(Gt.HTTP_STATUS,!1,r.status,r.responseURL,s))}199<r.status&&400>r.status?(await mi(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 gi{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 mi(this,t)}}const bi=()=>{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 s=0;s<n.length;s++)try{n[s].apply(e)}catch(i){console.error(i)}}},xi=()=>{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),s=e.soundTransform;for(let i=0;i<n.length;i++){const a=n[i];a&&(s&&(a.volume=s.volume,a.loopCount=s.loopCount),a.play())}}},fh=(e,t=null)=>{if(!t||!t.size)return;const r=e.currentFrame;t.has(r)&&Ur.push(e)},yi=e=>{e.$canSound&&(e.$canSound=!1,fh(e,e.$sounds))},$i=e=>{const t=e.children;for(let r=t.length-1;r>-1;--r){const n=t[r];n&&n.isContainerEnabled&&($i(n),n.isTimelineEnabled&&(yi(n),Zt(n)))}},dh=e=>{$i(e),xi(),bi()},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<this.offset+t.length&&this.resize(t.length);for(let r=0;r<t.length;r++)this.buffer[this.offset++]=t[r]}pushDisplayObjectBuffer(t,r,n,s,i,a,o,c,u,h,l,f,A,d,y,m,p,$,w,I,P,W){this.buffer.length<this.offset+22&&this.resize(22),this.buffer[this.offset++]=t,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=h,this.buffer[this.offset++]=l,this.buffer[this.offset++]=f,this.buffer[this.offset++]=A,this.buffer[this.offset++]=d,this.buffer[this.offset++]=y,this.buffer[this.offset++]=m,this.buffer[this.offset++]=p,this.buffer[this.offset++]=$,this.buffer[this.offset++]=w,this.buffer[this.offset++]=I,this.buffer[this.offset++]=P,this.buffer[this.offset++]=W}pushInstanceBuffer(t,r,n,s,i,a,o,c,u,h,l,f,A,d,y,m,p,$,w,I,P,W,C,R){this.buffer.length<this.offset+24&&this.resize(24),this.buffer[this.offset++]=t,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=h,this.buffer[this.offset++]=l,this.buffer[this.offset++]=f,this.buffer[this.offset++]=A,this.buffer[this.offset++]=d,this.buffer[this.offset++]=y,this.buffer[this.offset++]=m,this.buffer[this.offset++]=p,this.buffer[this.offset++]=$,this.buffer[this.offset++]=w,this.buffer[this.offset++]=I,this.buffer[this.offset++]=P,this.buffer[this.offset++]=W,this.buffer[this.offset++]=C,this.buffer[this.offset++]=R}pushShapeBuffer(t,r,n,s,i,a,o,c,u,h,l,f,A,d,y,m,p,$,w,I,P,W,C,R,L,N,J,Y,ee,Q,ce,ae){this.buffer.length<this.offset+32&&this.resize(32),this.buffer[this.offset++]=t,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=h,this.buffer[this.offset++]=l,this.buffer[this.offset++]=f,this.buffer[this.offset++]=A,this.buffer[this.offset++]=d,this.buffer[this.offset++]=y,this.buffer[this.offset++]=m,this.buffer[this.offset++]=p,this.buffer[this.offset++]=$,this.buffer[this.offset++]=w,this.buffer[this.offset++]=I,this.buffer[this.offset++]=P,this.buffer[this.offset++]=W,this.buffer[this.offset++]=C,this.buffer[this.offset++]=R,this.buffer[this.offset++]=L,this.buffer[this.offset++]=N,this.buffer[this.offset++]=J,this.buffer[this.offset++]=Y,this.buffer[this.offset++]=ee,this.buffer[this.offset++]=Q,this.buffer[this.offset++]=ce,this.buffer[this.offset++]=ae}pushTextFieldBuffer(t,r,n,s,i,a,o,c,u,h,l,f,A,d,y,m,p,$,w,I,P,W,C,R,L,N,J,Y,ee,Q){this.buffer.length<this.offset+30&&this.resize(30),this.buffer[this.offset++]=t,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=h,this.buffer[this.offset++]=l,this.buffer[this.offset++]=f,this.buffer[this.offset++]=A,this.buffer[this.offset++]=d,this.buffer[this.offset++]=y,this.buffer[this.offset++]=m,this.buffer[this.offset++]=p,this.buffer[this.offset++]=$,this.buffer[this.offset++]=w,this.buffer[this.offset++]=I,this.buffer[this.offset++]=P,this.buffer[this.offset++]=W,this.buffer[this.offset++]=C,this.buffer[this.offset++]=R,this.buffer[this.offset++]=L,this.buffer[this.offset++]=N,this.buffer[this.offset++]=J,this.buffer[this.offset++]=Y,this.buffer[this.offset++]=ee,this.buffer[this.offset++]=Q}pushVideoBuffer(t,r,n,s,i,a,o,c,u,h,l,f,A,d,y,m,p,$,w,I,P,W,C,R,L,N,J){this.buffer.length<this.offset+27&&this.resize(27),this.buffer[this.offset++]=t,this.buffer[this.offset++]=r,this.buffer[this.offset++]=n,this.buffer[this.offset++]=s,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=c,this.buffer[this.offset++]=u,this.buffer[this.offset++]=h,this.buffer[this.offset++]=l,this.buffer[this.offset++]=f,this.buffer[this.offset++]=A,this.buffer[this.offset++]=d,this.buffer[this.offset++]=y,this.buffer[this.offset++]=m,this.buffer[this.offset++]=p,this.buffer[this.offset++]=$,this.buffer[this.offset++]=w,this.buffer[this.offset++]=I,this.buffer[this.offset++]=P,this.buffer[this.offset++]=W,this.buffer[this.offset++]=C,this.buffer[this.offset++]=R,this.buffer[this.offset++]=L,this.buffer[this.offset++]=N,this.buffer[this.offset++]=J}set(t){this.buffer.length<this.offset+t.length&&this.resize(t.length),this.buffer.set(t,this.offset),this.offset+=t.length}resize(t){const r=new Float32Array(Ah(this.offset+t));this.buffer.length&&r.set(this.buffer),this.buffer=r}}const b=new ph,mt=e=>{const t=new Uint32Array(e.buffer,e.byteOffset,e.length),r=t.length;let n=2166136261,s=0;const i=r&-8;for(;s<i;){let a=t[s++];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[s++],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[s++],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[s++],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[s++],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[s++],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[s++],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[s++],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(;s<r;){const a=t[s++];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)}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}},vi=(e,t,r,n,s)=>{if(!e.visible){b.push(0);return}const i=e.graphics,a=i.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(i.xMin,i.yMin,i.xMax,i.yMax,l),A=f[0],d=f[1],y=f[2],m=f[3];k(f);const p=Math.ceil(Math.abs(y-A)),$=Math.ceil(Math.abs(m-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>s){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(i.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,xs,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,m,i.xMin,i.yMin,i.xMax,i.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),ki=Ke[5]-(l[5]-d);Ft(Ke);const it=he(i.xMin,i.yMin,i.xMax,i.yMax,Q),Bn=it[0],Tn=it[1],Ui=it[2],Gi=it[3];k(it);const Tt=Math.ceil(Math.abs(Ui-Bn)),St=Math.ceil(Math.abs(Gi-Tn)),xe=e.scale9Grid,br=Math.abs(i.xMax-i.xMin),xr=Math.abs(i.yMax-i.yMin),It=xe.width>0?(xe.x-i.xMin)/br:1e-5,Ct=xe.height>0?(xe.y-i.yMin)/xr:1e-5,yr=xe.width>0?(xe.x+xe.width-i.xMin)/br:.99999,$r=xe.height>0?(xe.y+xe.height-i.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]-ki,Bn,Tn,Tt,St,It,Ct,vr,wr,yr,$r,Mr,Br),Ft(ae),Ft(Q)}const J=a||w?i.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;ce<N.length;ce++){const ae=N[ce];if(!ae||!ae.canApplyFilter())continue;ae.$updated&&(J=!0),ae.$updated=!1,ae.getBounds(ee);const Ke=ae.toNumberArray();for(let Qe=0;Qe<Ke.length;Qe+=4096)Y.push(...Ke.subarray(Qe,Qe+4096))}const Q=Y.length>0;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 s=r&&e.scale9Grid?Math.abs(r[1])<.001&&Math.abs(r[2])<1e-4:!1,i=e.graphics.buffer;b.push(xs,n[0],n[1],n[2],n[3],n[4],n[5],+s,i.length),b.set(i)},mh=new TextEncoder,wi=(e,t,r,n,s)=>{if(!e.visible){b.push(0);return}const i=Ve(e),a=i&&(i[0]!==1||i[1]!==1||i[2]!==1||i[3]!==1||i[4]!==0||i[5]!==0||i[6]!==0||i[7]!==0)?U.multiply(r,i):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)),m=Math.ceil(Math.abs(d-f));switch(!0){case y===0:case m===0:case y===-1/0:case m===-1/0:case y===1/0:case m===1/0:a!==r&&U.release(a),u!==t&&T.release(u),b.push(0);return}if(0>l+y||0>f+m||l>n||f>s){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;J<e.filters.length;J++){const Y=e.filters[J];if(!Y||!Y.canApplyFilter())continue;Y.$updated&&(C=!0),Y.$updated=!1,Y.getBounds(L);const ee=Y.toNumberArray();for(let Q=0;Q<ee.length;Q+=4096)R.push(...ee.subarray(Q,Q+4096))}const N=R.length>0;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)},Mi=(e,t,r,n,s,i)=>{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 m=Math.ceil(Math.abs(d-f)),p=Math.ceil(Math.abs(y-A));switch(!0){case m===0:case p===0:case m===-1/0:case p===-1/0:case m===1/0:case p===1/0:o!==n&&U.release(o),h!==r&&T.release(h),b.push(0);return}if(0>f+m||0>A+p||f>s||A>i){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;C<e.filters.length;C++){const R=e.filters[C];if(!R||!R.canApplyFilter())continue;R.$updated&&(w=!0),R.$updated=!1,R.getBounds(P);const L=R.toNumberArray();for(let N=0;N<L.length;N+=4096)I.push(...L.subarray(N,N+4096))}const W=I.length>0;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 s=null;switch(!0){case e.isContainerEnabled:s=yt(e,t);break;case e.isShape:s=wt(e,t);break;case e.isText:s=Bt(e,t);break;case e.isVideo:s=Mt(e,t);break}if(!s)return null;const i=s[0],a=s[2],o=Math.abs(a-i);if(!o)return null;const c=s[1],u=s[3],h=Math.abs(u-c);return!h||0>i+o||0>c+h||i>r||c>n?null:s},Hr=(e,t)=>{const r=_(e),n=r?T.multiply(t,r):t,s=e.children;b.push(bs,s.length);for(let i=0;i<s.length;i++){const a=s[i];if(a&&!a.isMask)switch(!0){case a.isContainerEnabled:Hr(a,n);break;case a.isShape:zr(a,n);break}}n!==t&&T.release(n)},gh=(e,t=null)=>{const r=wt(e,t),n=e.filters;if(n){const s=re(0,0,0,0);for(let i=0;i<n.length;i++){const a=n[i];!a||!a.canApplyFilter()||a.getBounds(s)}r[0]+=s[0],r[1]+=s[1],r[2]+=s[2],r[3]+=s[3],k(s)}return r},bh=(e,t=null)=>{const r=Mt(e,t),n=e.filters;if(n){const s=re(0,0,0,0);for(let i=0;i<n.length;i++){const a=n[i];!a||!a.canApplyFilter()||a.getBounds(s)}r[0]+=s[0],r[1]+=s[1],r[2]+=s[2],r[3]+=s[3],k(s)}return r},xh=(e,t=null)=>{const r=Bt(e,t),n=e.filters;if(n){const s=re(0,0,0,0);for(let i=0;i<n.length;i++){const a=n[i];!a||!a.canApplyFilter()||a.getBounds(s)}r[0]+=s[0],r[1]+=s[1],r[2]+=s[2],r[3]+=s[3],k(s)}return r},Bi=(e,t=null)=>{const r=e.children;if(!r.length)return re(0,0,0,0);const n=_(e),s=n?t?T.multiply(t,n):n:t,i=Number.MAX_VALUE;let a=i,o=-i,c=i,u=-i;for(let h=0;h<r.length;h++){const l=r[h];if(!l||!l.visible)continue;let f=null;switch(!0){case l.isContainerEnabled:f=Bi(l,s);break;case l.isShape:f=gh(l,s);break;case l.isText:f=xh(l,s);break;case l.isVideo:f=bh(l,s);break}f&&(a=Math.min(a,f[0]),c=Math.min(c,f[1]),o=Math.max(o,f[2]),u=Math.max(u,f[3]),k(f))}return re(a,c,o,u)},Ti=(e,t,r,n,s,i)=>{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,bs);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;C<A.length;C++){const R=A[C];if(!R||!R.canApplyFilter())continue;R.$updated&&(w=!0),R.$updated=!1,R.getBounds(P);const L=R.toNumberArray();for(let N=0;N<L.length;N+=4096)I.push(...L.subarray(N,N+4096))}if(I.length>0){w||(w=e.changed);const C=Bi(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,s,i);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,m=!0;for(let p=0;p<u.length;++p){const $=u[p];if(b.push($.placeId,$.clipDepth),$.isMask){b.push(0),$.changed=!1;continue}if(y&&$.placeId>y&&(y=0,m=!0),!m){b.push(0),$.changed=!1;continue}if($.clipDepth){y=$.clipDepth;const w=Jn($,l,s,i);if(m=!!w,b.push(+m),!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:Ti($,t,l,o,s,i);break;case $.isShape:vi($,l,o,s,i);break;case $.isText:wi($,l,o,s,i);break;case $.isVideo:Mi($,t,l,o,s,i);break}$.changed=!1}o!==n&&U.release(o),l!==r&&T.release(l)},yh=(e,t,r,n,s,i)=>{switch(b.push(v.backgroundColor),!0){case e.isContainerEnabled:Ti(e,t,r,n,s,i);break;case e.isShape:vi(e,r,n,s,i);break;case e.isText:wi(e,r,n,s,i);break;case e.isVideo:Mi(e,t,r,n,s,i);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,yi(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 s=0;n.length>s;++s){const i=n[s];i.isContainerEnabled&&(i.isTimelineEnabled&&Zn(i),Jr(i),r.push(i))}e.$container=r}},$h=()=>{Jr(v),xi(),bi()};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,s){yh(t,r,n,s,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,s=e.style;if(s.width=`${r}px`,s.height=`${n}px`,!v.stageWidth||!v.stageHeight)return;const i=Math.min(r/v.stageWidth,n/v.stageHeight)*Ze,a=B.fullScreen?window.innerWidth*Ze:v.stageWidth*i|0,o=B.fullScreen?window.innerHeight*Ze:v.stageHeight*i|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=i,v.rendererWidth=B.rendererWidth=a,v.rendererHeight=B.rendererHeight=o,ft[0]=ft[3]=i,ft[4]=(B.rendererWidth-v.stageWidth*i)/2,ft[5]=(B.rendererHeight-v.stageHeight*i)/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 Si=()=>{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))},es={command:"removeCache",buffer:null},ts=[],rs=()=>{const e=new Float32Array(O.$removeIds);O.$removeIds.length=0,es.buffer=e,ts[0]=e.buffer,Ce.postMessage(es,ts)},Mh=new x(x.ENTER_FRAME),Ii=e=>{if(B.stopFlag)return;O.$removeIds.length&&rs();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&&Si(),O.$removeCache&&(O.removeTimerScheduledCache(),O.$removeIds.length&&rs())),B.timerId=requestAnimationFrame(r=>{Ii(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=>{Ii(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 ns="auto";const wn=()=>{B.stopFlag||(se.x=v.pointer.x,se.y=v.pointer.y,se.pointer="auto",se.hit=null,Tr.beginPath(),Tr.setTransform(1,0,0,1,0,0),v.$mouseHit(Tr,gt,se),B.mouseState==="up"&&ns!==se.pointer&&(us().style.cursor=ns=se.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 s=e.target;if(s){const c=s.getBoundingClientRect();t+=c.left,r+=c.top}const i=(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-i/B.rendererScale,v.pointer.y=(e.pageY-r)/o-a/B.rendererScale},Eh=()=>{const e=se.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(se.x-gt[4],se.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=se.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 ss,kt=!1;const Rh=e=>{const t=e.target;t&&(B.mouseState="down",t.setPointerCapture(e.pointerId),We(e),Mn(e),wn(),se.hit&&e.preventDefault(),clearTimeout(ss),kt?(kt=!1,Ph()):(kt=!0,ss=setTimeout(()=>{kt=!1},300),Eh()))},Oh=()=>{const e=v.dropTarget,t=se.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))},is=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 s=e.parent?e.parent.globalToLocal(v.pointer):e.globalToLocal(v.pointer);let i=0,a=0;e.$lockCenter?(i=s.x-e.width/2,a=s.y-e.height/2):(i=s.x+e.$offsetX,a=s.y+e.$offsetY);const o=e.$boundedRect;o&&(i=Vt(i,o.left,o.right),a=Vt(a,o.top,o.bottom)),e.x=i,e.y=a}const t=ke();if(t&&B.mouseState==="down"){t.setFocusIndex(se.x-gt[4],se.y-gt[5],!0);return}const r=fs(),n=se.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(),se.hit&&e.preventDefault(),kh())},Gh=e=>{We(e);const t=fs();t&&t.willTrigger(S.POINTER_LEAVE)&&(e.preventDefault(),t.dispatchEvent(new S(S.POINTER_LEAVE)))},_h=e=>{We(e);const t=se.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<r.length;++n){const s=r[n];s&&(s.muted=!1)}r.length=0,e.removeEventListener(S.POINTER_UP,t)};e.addEventListener(S.POINTER_UP,t),e.addEventListener(S.POINTER_DOWN,Rh,{passive:!1}),e.addEventListener(S.POINTER_UP,is),e.addEventListener(S.POINTER_CANCEL,is),e.addEventListener(S.POINTER_MOVE,Uh,{passive:!1}),e.addEventListener(S.POINTER_LEAVE,Gh),e.addEventListener(qe.WHEEL,_h)},gr=document.createElement("canvas");Di(gr);Li(gr,Ze);Dh(gr);Yi(gr);const qr={Event:x,EventDispatcher:nt,EventPhase:ze,FocusEvent:Ne,HTTPStatusEvent:Gt,IOErrorEvent:Re,PointerEvent:S,JobEvent:ye,ProgressEvent:Z,VideoEvent:Ae};Object.entries(qr).forEach(([e,t])=>{Object.defineProperty(qr,e,{get(){return t}})});const jr={Sprite:An,MovieClip:qt,BitmapData:_e,BlendMode:ua,DisplayObject:hr,DisplayObjectContainer:dn,FrameLabel:Ks,Graphics:M,InteractiveObject:fn,Loader:gi,Shape:$t,stage:v};Object.entries(jr).forEach(([e,t])=>{Object.defineProperty(jr,e,{get(){return t}})});const en={BevelFilter:rr,BlurFilter:nr,ColorMatrixFilter:sr,ConvolutionFilter:ir,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:ie,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 Ci{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:Ci};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 Fi=()=>{const e=vt();if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},Ei=()=>{const e=vt();if(!e)return;const t=us();t&&(e.appendChild(t),e.appendChild(de))},Pi=()=>{v.ready=!0,Si(),B.play(),v.changed=!1},Lh=()=>{const e=document.createElement("div");if(_i(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 s=e.parentElement;if(!s)throw new Error("parent element is null.");s.tagName==="BODY"?(n+=`width:${window.innerWidth}px;`,n+=`height:${window.innerHeight}px;`):(n+=`width:${s.clientWidth}px;`,n+=`height:${s.clientHeight}px;`)}e.setAttribute("style",n)},Yh=e=>{const t=`${on}_loading`;e.innerHTML=`<style>
|
|
2346
|
-
#${t} {
|
|
1
|
+
var e=`__next2d__`,t=Math.min(2,window.devicePixelRatio),n=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},r=document.createElement(`canvas`);r.width=r.height=1;var i=r.getContext(`2d`),a=null,o=e=>{a=e},s=null,c=e=>{s=e},l=()=>s,u=()=>a,d=new Float32Array([1,0,0,1,0,0]),f=new Float32Array([1,0,0,1,0,0]),p={x:0,y:0,pointer:``,hit:null},m=null,h=e=>{m=e},g=()=>m,_=(e,t=1)=>{let n=``;n+=`-webkit-tap-highlight-color: rgba(0,0,0,0);`,n+=`backface-visibility: hidden;`,n+=`touch-action: none;`,n+=`user-select: none;`,n+=`-webkit-user-select: none;`,n+=`-webkit-touch-callout: none;`,t>1&&(n+=`transform: scale(${1/t});`),e.width=1,e.height=1,e.setAttribute(`style`,n)},v="\"use strict\";(function(){let e=2048,t=t=>{e=Math.max(2048,t/2)},n=4,r=e=>{n=e},i,a=e=>{i=e},o,s=e=>{o=e},c=!1,l=()=>{c||(c=!0,i.enable(i.SCISSOR_TEST))},u=()=>{c&&(c=!1,i.disable(i.SCISSOR_TEST))},d=!1,f=()=>{d||(d=!0,i.enable(i.STENCIL_TEST))},p=()=>{d&&(d=!1,i.disable(i.STENCIL_TEST))},m=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},h=[],g=(...e)=>{let t=h.pop()||[];return e.length&&t.push(...e),t},_=(e=null)=>{e&&(e.length&&=0,h.push(e))},v=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),y=[],b=(e=0,t=0,n=0,r=0)=>{let i=y.pop()||new Float32Array(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},x=e=>{y.push(e)},S=[],C=(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0)=>{let l=S.pop()||new Float32Array(9);return l[0]=e,l[1]=t,l[2]=n,l[3]=r,l[4]=i,l[5]=a,l[6]=o,l[7]=s,l[8]=c,l},w=e=>{S.push(e)},T=[],E=(e=0,t=0,n=0,r=0,i=0,a=0)=>{let o=T.pop()||new Float32Array(6);return o[0]=e,o[1]=t,o[2]=n,o[3]=r,o[4]=i,o[5]=a,o},D=e=>{T.push(e)},O=e=>{let t=1/(e[0]*e[4]-e[3]*e[1]),n=e[3]*e[7]-e[4]*e[6],r=e[1]*e[6]-e[0]*e[7];return C(e[4]*t,0-e[1]*t,0,0-e[3]*t,e[0]*t,0,n*t,r*t,1)},k=0,A=0,j=(e,t)=>{k=e,A=t},M=e=>{let t=-819.2*e[0]-819.2*e[2]+e[4],n=819.2*e[0]-819.2*e[2]+e[4],r=-819.2*e[0]+819.2*e[2]+e[4],i=-819.2*e[1]-819.2*e[3]+e[5],a=819.2*e[1]-819.2*e[3]+e[5],o=-819.2*e[1]+819.2*e[3]+e[5],s=r-t,c=o-i,l=Math.sqrt(s*s+c*c);l?(s/=l,c/=l):(s=0,c=0);let u=(n-t)*s+(a-i)*c;return b(t+u*s,i+u*c,n,a)},N=1,P=e=>{N=e},F=(e,t)=>{let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=t[0],l=t[1],u=t[2],d=t[3],f=t[4],p=t[5];return E(n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s)},I=()=>typeof crypto?.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)}),L=g(),R=g(),z=(e=!1)=>{let t=e?6:9;L.length>=t&&R.push(L.slice(0)),L.length=0;let n=[];for(let e=0;e<R.length;e++){let r=R[e];r.length>=t&&n.push(r)}return R.length=0,n},ee=()=>{for(L.length=0;R.length;)_(R.pop())},te=(e,t,n)=>{L.push(e,t,n)},ne=(e,t)=>{let n=L.length,r=+L[n-3],i=+L[n-2];return e===r&&t===i},re=()=>{if(L.length<3){L.length=0;return}R.push(L.slice(0)),L.length=0},ie=(e,t)=>{if(!L.length){te(e,t,!1);return}ne(e,t)||(re(),te(e,t,!1))},ae=(e,t)=>{L.length||ie(e,t),!ne(e,t)&&te(e,t,!1)},oe=(e,t,n,r)=>{L.length||ie(0,0),!ne(n,r)&&(te(e,t,!0),te(n,r,!1))},se=()=>{if(L.length<7)return;let e=+L[0],t=+L[1];ne(e,t)||te(e,t,!1)},B=new Float32Array(64),ce=0,le=.5,ue=(e,t,n,r,i,a,o,s)=>{let c=3*n-2*e-o,l=3*r-2*t-s,u=3*i-2*o-e,d=3*a-2*s-t;return Math.max(c*c+l*l,u*u+d*d)},de=(e,t,n,r,i,a,o,s)=>{let c=ue(e,t,n,r,i,a,o,s);if(c<le*le)return 2;let l=Math.ceil(Math.log2(Math.sqrt(c)/le)/2);return Math.min(Math.max(l+2,2),8)},fe=e=>{B.length<e&&(B=new Float32Array(e*2))},pe=e=>{ce=e},me=[],he=0,ge=()=>{he=0},V=()=>(he>=me.length&&me.push(new Float32Array(8)),me[he++]),_e=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=1-c,f=d*e+c*n,p=d*t+c*r,m=d*n+c*i,h=d*r+c*a,g=d*i+c*o,_=d*a+c*s,v=d*f+c*m,y=d*p+c*h,b=d*m+c*g,x=d*h+c*_,S=d*v+c*b,C=d*y+c*x;l[0]=e,l[1]=t,l[2]=f,l[3]=p,l[4]=v,l[5]=y,l[6]=S,l[7]=C,u[0]=S,u[1]=C,u[2]=b,u[3]=x,u[4]=g,u[5]=_,u[6]=o,u[7]=s},ve=(e,t,n,r,i,a,o,s,c,l)=>{let u=(3*n+3*i-e-o)*.25,d=(3*r+3*a-t-s)*.25;c[l]=u,c[l+1]=d,c[l+2]=o,c[l+3]=s},ye=new Float32Array(8),be=new Float32Array(8),xe=(e,t,n,r,i,a,o,s)=>{let c=de(e,t,n,r,i,a,o,s);fe(c*4);let l=0;if(c<=2)_e(e,t,n,r,i,a,o,s,.5,ye,be),ve(ye[0],ye[1],ye[2],ye[3],ye[4],ye[5],ye[6],ye[7],B,l),l+=4,ve(be[0],be[1],be[2],be[3],be[4],be[5],be[6],be[7],B,l),l+=4;else if(c<=4){ge();let c=V(),u=V();_e(e,t,n,r,i,a,o,s,.5,c,u);let d=V(),f=V(),p=V(),m=V();_e(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],.5,d,f),_e(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],.5,p,m),ve(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],B,l),l+=4,ve(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],B,l),l+=4,ve(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],B,l),l+=4,ve(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],B,l),l+=4}else{ge();let c=V(),u=V();_e(e,t,n,r,i,a,o,s,.5,c,u);let d=V(),f=V(),p=V(),m=V();_e(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],.5,d,f),_e(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],.5,p,m);let h=V(),g=V(),_=V(),v=V(),y=V(),b=V(),x=V(),S=V();_e(d[0],d[1],d[2],d[3],d[4],d[5],d[6],d[7],.5,h,g),_e(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],.5,_,v),_e(p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],.5,y,b),_e(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],.5,x,S),ve(h[0],h[1],h[2],h[3],h[4],h[5],h[6],h[7],B,l),l+=4,ve(g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],B,l),l+=4,ve(_[0],_[1],_[2],_[3],_[4],_[5],_[6],_[7],B,l),l+=4,ve(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],B,l),l+=4,ve(y[0],y[1],y[2],y[3],y[4],y[5],y[6],y[7],B,l),l+=4,ve(b[0],b[1],b[2],b[3],b[4],b[5],b[6],b[7],B,l),l+=4,ve(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],B,l),l+=4,ve(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],B,l),l+=4}return pe(l/4),{buffer:B,count:ce}},Se=(e,t,n,r,i,a)=>{if(L.length||ie(0,0),ne(i,a))return;let o=L.length,s=xe(+L[o-3],+L[o-2],e,t,n,r,i,a),c=s.buffer,l=s.count;for(let e=0;e<l*4;)oe(c[e++],c[e++],c[e++],c[e++])},Ce=(e,t,n)=>{let r=n,i=n*.5522847498307936;Se(e+r,t+i,e+i,t+r,e,t+r),Se(e-i,t+r,e-r,t+i,e-r,t),Se(e-r,t-i,e-i,t-r,e,t-r),Se(e+i,t-r,e+r,t-i,e+r,t)},we=(e,t,n,r,i)=>{e.$clearColorR=m(t,0,1,0),e.$clearColorG=m(n,0,1,0),e.$clearColorB=m(r,0,1,0),e.$clearColorA=m(i,0,1,0)},Te=(e,t,n,r)=>{i.clearColor(e,t,n,r),i.clear(i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),i.clearColor(0,0,0,0)},Ee=[],De=e=>{let t=-1,n=Ee.length;for(;Math.abs(n-t)>1;){let r=Math.floor((n+t)/2);e<=Ee[r].area?n=r:t=r}return n},Oe=e=>{if(Ee.indexOf(e)>-1)return;let t=De(e.area);e.dirty=!0,Ee.splice(t,0,e)},H=e=>{i.deleteTexture(e.resource)},ke=[],Ae=e=>{if(!(ke.indexOf(e)>-1)){if(ke.length>10){i.deleteRenderbuffer(e.resource);return}e.dirty=!0,ke.push(e)}},je=[],Me,Ne=e=>{Me=e.createFramebuffer()},Pe=null,Fe=e=>{Pe=e.createFramebuffer()},Ie=null,Le=(e,t)=>{Ie=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,Ie),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.resource,0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,Ie)},Re=null,ze=e=>{Re=e},Be=!1,Ve=e=>{Be=e},He=null,Ue=null,We=null,Ge=null,Ke=e=>{Ue=e.createFramebuffer(),He=e.createFramebuffer(),We=e.createFramebuffer(),Ge=e.createBuffer(),e.bindBuffer(e.PIXEL_PACK_BUFFER,Ge)},qe=(e,t=!0)=>{e.msaa?(Oe(e.color),e.color=null,e.stencil=null):(t&&H(e.texture),e.texture=null,Ae(e.stencil),e.stencil=null),je.push(e)},Je=0,Ye=()=>({id:Je++,width:0,height:0,clipLevel:0,msaa:!1,mask:!1,color:null,texture:null,stencil:null}),Xe=()=>{let e={id:0,resource:i.createRenderbuffer(),width:0,height:0,area:0,dirty:!1};return{resource:i.createRenderbuffer(),stencil:e,width:0,height:0,area:0,dirty:!1}},Ze=e=>{if(!Ee.length)return Xe();let t=De(e);if(t<Ee.length){let e=Ee[t];return Ee.splice(t,1),e}let n=Ee.shift();if(!n)throw Error(`the color buffer is void.`);return n},Qe=(e,t)=>{e=Math.max(256,v(e)),t=Math.max(256,v(t));let r=Ze(e*t);return(r.width<e||r.height<t)&&(e=Math.max(e,r.width),t=Math.max(t,r.height),r.width=e,r.height=t,r.area=e*t,i.bindRenderbuffer(i.RENDERBUFFER,r.resource),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.RGBA8,e,t),i.bindRenderbuffer(i.RENDERBUFFER,r.stencil.resource),i.renderbufferStorageMultisample(i.RENDERBUFFER,n,i.STENCIL_INDEX8,e,t)),r.dirty=!0,r},$e=0,et=()=>({id:$e++,resource:i.createRenderbuffer(),width:0,height:0,area:0,dirty:!1}),tt=(e,t)=>{if(!ke.length)return et();let n=-1,r=1/0;for(let i=0;i<ke.length;++i){let a=ke[i];a.width>=e&&a.height>=t&&a.area<r&&(r=a.area,n=i)}if(n!==-1){let e=ke[n];return ke[n]=ke[ke.length-1],ke.pop(),e}return ke.pop()},nt=(e,t)=>{let n=tt(e,t);return(n.width!==e||n.height!==t)&&(n.width=e,n.height=t,n.area=e*t,n.dirty=!1,i.bindRenderbuffer(i.RENDERBUFFER,n.resource),i.renderbufferStorage(i.RENDERBUFFER,i.STENCIL_INDEX8,e,t)),n},rt=0,it=(e,t)=>({id:rt++,resource:i.createTexture(),width:e,height:t,area:e*t,smooth:!1}),at=-1,ot=e=>{at=e},st=[null,null,null],ct=(e,t=!1)=>{at!==i.TEXTURE0&&(ot(i.TEXTURE0),i.activeTexture(i.TEXTURE0)),st[0]=e,i.bindTexture(i.TEXTURE_2D,e.resource),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,t?i.LINEAR:i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t?i.LINEAR:i.NEAREST),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA8,e.width,e.height)},lt=(e,t,n=!1)=>{let r=it(e,t);return ct(r,n),r},ut=(e,t,n=!1)=>{let r=je.length?je.pop():Ye();return r.width=e,r.height=t,n?(r.msaa=!0,r.texture=null,r.color=Qe(e,t),r.stencil=r.color.stencil):(r.msaa=!1,r.texture=lt(e,t),r.color=null,r.stencil=nt(e,t)),r.mask=!1,r.clipLevel=0,r},dt=()=>{ze(null),Be&&(Ve(!1),i.bindFramebuffer(i.FRAMEBUFFER,null))},ft=()=>{let t=it(e,e);return i.activeTexture(i.TEXTURE3),i.bindTexture(i.TEXTURE_2D,t.resource),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.NEAREST),i.texStorage2D(i.TEXTURE_2D,1,i.RGBA8,t.width,t.height),i.activeTexture(at===-1?i.TEXTURE0:at),t},pt=Number.MAX_VALUE,mt=-Number.MAX_VALUE,ht=0,gt=e=>{ht=e},_t=[],vt=()=>_t,yt=e=>{_t[ht]=e},bt=()=>(ht in _t||yt(ut(e,e,!0)),_t[ht]),xt=[],St=null,Ct=()=>(St||=ft(),St),wt=[],Tt=e=>(e in wt||(wt[e]=new Float32Array([pt,pt,mt,mt])),wt[e]),Et=()=>{for(let e=0;e<wt.length;++e){let t=wt[e];t&&(t[0]=t[1]=pt,t[2]=t[3]=mt)}},Dt=0,Ot=e=>{Dt=e},kt=()=>{xt.length=0,gt(0);let e=vt();for(let t=0;t<e.length;t++)qe(e[t]);e.length=0},At=(e,t,n,r=!0)=>{if(e.clearArraysInstanced(),e.$stackAttachmentObject.length)for(let t=0;t<e.$stackAttachmentObject.length;++t){let n=e.$stackAttachmentObject[t];n&&qe(n)}else e.$mainAttachmentObject&&qe(e.$mainAttachmentObject);r&&kt(),dt(),e.$mainAttachmentObject=ut(t,n,!0),e.bind(e.$mainAttachmentObject)},jt=(e,t,n,r)=>{l(),i.scissor(e,t,n,r),i.clear(i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),u()},Mt=(e,t,n=null,r=!1)=>{(at===-1||t!==at)&&(ot(t),i.activeTexture(t));let a=st[e];a!==null&&n!==null&&a.id===n.id||n===a||(st[e]=n,i.bindTexture(i.TEXTURE_2D,n?n.resource:null),n&&n.smooth!==r&&(n.smooth=r,i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,r?i.LINEAR:i.NEAREST),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,r?i.LINEAR:i.NEAREST)))},Nt=(e,t=!1)=>{Mt(2,i.TEXTURE2,null),Mt(1,i.TEXTURE1,null),Mt(0,i.TEXTURE0,e,t)},Pt=e=>{ze(e),Be||(Ve(!0),i.bindFramebuffer(i.FRAMEBUFFER,Me)),e.msaa?(i.bindRenderbuffer(i.RENDERBUFFER,e.color.resource),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,e.color.resource)):(Nt(e.texture),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e.texture.resource,0),Mt(0,i.TEXTURE0,null)),i.bindRenderbuffer(i.RENDERBUFFER,e.stencil.resource),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.STENCIL_ATTACHMENT,i.RENDERBUFFER,e.stencil.resource)},Ft=()=>{let e=o.currentAttachmentObject;if(!e)return;let t=e.clipLevel,n=0;for(let e=0;e<t;++e)n|=(1<<t-e)-1;i.stencilMask(255),i.stencilFunc(i.EQUAL,n&255,n),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.colorMask(!0,!0,!0,!0),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),u()},It=!1,Lt=e=>{It=e},Rt=()=>It,zt=new Map,Bt=new Map,Vt=e=>{!e&&Rt()?(Lt(!1),p(),u()):e&&!Rt()&&(Lt(!0),f(),Ft())},Ht=(e,t)=>{let n=Re;if(n&&t.id===n.id)return;Pt(t),(!n||n.width!==t.width||n.height!==t.height)&&(j(t.width,t.height),i.viewport(0,0,t.width,t.height));let r=t.msaa?t.color:t.stencil;r.dirty&&(r.dirty=!1,e.clearRect(0,0,t.width,t.height)),Vt(t.mask)},Ut=e=>{e.$stack.push(C(...e.$matrix))},Wt=e=>{if(!e.$stack.length)return;let t=e.$stack.pop();e.$matrix[0]=t[0],e.$matrix[1]=t[1],e.$matrix[3]=t[3],e.$matrix[4]=t[4],e.$matrix[6]=t[6],e.$matrix[7]=t[7],w(t)},Gt=(e,t,n,r,i,a,o)=>{e[0]=t,e[1]=n,e[3]=r,e[4]=i,e[6]=a,e[7]=o},Kt=(e,t,n,r,i,a,o)=>{let s=e.$matrix[0],c=e.$matrix[1],l=e.$matrix[3],u=e.$matrix[4],d=e.$matrix[6],f=e.$matrix[7];e.$matrix[0]=t*s+n*l,e.$matrix[1]=t*c+n*u,e.$matrix[3]=r*s+i*l,e.$matrix[4]=r*c+i*u,e.$matrix[6]=a*s+o*l+d,e.$matrix[7]=a*c+o*u+f},qt=e=>{e.globalAlpha=1,e.globalCompositeOperation=`normal`,e.imageSmoothingEnabled=!1},Jt=e=>{e.$fillStyle.fill(1),e.$strokeStyle.fill(1)},Yt=(e,t,n,r)=>{l(),i.scissor(e,t,n+1,r+1),i.clear(i.COLOR_BUFFER_BIT|i.STENCIL_BUFFER_BIT),i.scissor(e,t,n,r)},Xt=()=>{u()},Zt=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=e.length-5;for(let m=3;m<p;m+=3){let p=n*17;e[m+2]?(t[p++]=e[m-3],t[p++]=e[m-2],t[p++]=0,t[p++]=0,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m],t[p++]=e[m+1],t[p++]=.5,t[p++]=0,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m+3],t[p++]=e[m+4],t[p++]=1,t[p++]=1,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0):e[m+5]?(t[p++]=e[0],t[p++]=e[1],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m],t[p++]=e[m+1],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m+6],t[p++]=e[m+7],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0):(t[p++]=e[0],t[p++]=e[1],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m],t[p++]=e[m+1],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0,t[p++]=e[m+3],t[p++]=e[m+4],t[p++]=.5,t[p++]=.5,t[p++]=l,t[p++]=u,t[p++]=d,t[p++]=f,t[p++]=r,t[p++]=i,t[p++]=0,t[p++]=a,t[p++]=o,t[p++]=0,t[p++]=s,t[p++]=c,t[p++]=0),n+=3}return n},Qt=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),$t=new Float32Array(128),en=0,tn=()=>$t,nn=()=>en,rn=e=>{let t=e.length+en;if(t>$t.length){let n=new Float32Array(Qt(t));n.set($t),n.set(e,en),$t=n}else $t.set(e,en);en+=e.length},an=[],on=[],sn=()=>{on.length=0,en=0,an.length=0},cn=new Float32Array(32),ln=e=>(cn.length<e&&(cn=new Float32Array(Qt(e))),cn),un=(e,t=`fill`)=>{let n=t===`fill`?o.$fillStyle:o.$strokeStyle,r=n[0],i=n[1],a=n[2],s=n[3],c=o.$matrix,l=k,u=A,d=c[0]/l,f=c[3]/l,p=c[6]/l,m=c[1]/u,h=c[4]/u,g=c[7]/u,_=0;for(let t=0;t<e.length;++t)_+=(e[t].length/3-2)*51;let v=ln(_),y=0;for(let t=0;t<e.length;++t)y=Zt(e[t],v,y,d,m,f,h,p,g,r,i,a,s);return{buffer:v.subarray(0,_),indexCount:y}},dn=e=>{let t=z();if(!t.length)return;on.push(e);let n=un(t);rn(n.buffer),an.push(n.indexCount)},fn=[],pn=(e,t,n,r,i,a)=>{let o=z();if(!o.length)return;on.push(e===0?`linear`:`radial`);let s=un(o);rn(s.buffer),an.push(s.indexCount),fn.push(t,n,r,i),e===1&&fn.push(a)},mn=(e,t,n)=>{let r=Math.sqrt(e*e+t*t);return{x:-(t/r)*n,y:e/r*n}},hn=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i=mn(r.x,r.y,n),a={x:e.x+i.x,y:e.y+i.y},o={x:t.x+i.x,y:t.y+i.y},s={x:e.x-i.x,y:e.y-i.y},c={x:t.x-i.x,y:t.y-i.y};return[a.x,a.y,!1,o.x,o.y,!1,c.x,c.y,!1,s.x,s.y,!1,a.x,a.y,!1]},gn=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),_n=(e,t,n,r=.5)=>{let i=gn(e,t,r),a=gn(t,n,r),o=gn(i,a,r);return[[e,i,o],[o,a,n]]},vn=(e,t,n,r=4)=>{let i=[[e,t,n]];for(let e=0;e<r;++e){let e=[];for(let t=0;t<i.length;++t){let n=i[t];if(!n)continue;let r=_n(n[0],n[1],n[2],.5);e.push(r[0],r[1])}i=e}return i},yn=(e,t,n,r)=>({x:(1-e)**2*t.x+2*(1-e)*e*n.x+e**2*r.x,y:(1-e)**2*t.y+2*(1-e)*e*n.y+e**2*r.y}),bn=(e,t,n,r)=>({x:2*(1-e)*(n.x-t.x)+2*e*(r.x-n.x),y:2*(1-e)*(n.y-t.y)+2*e*(r.y-n.y)}),xn=e=>{let t=Math.sqrt(e.x*e.x+e.y*e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},Sn=(e,t,n,r)=>{let i=[0,.5,1],a=[];for(let o=0;o<i.length;++o){let s=i[o],c=yn(s,e,t,n),l=bn(s,e,t,n),u=xn({x:-l.y,y:l.x});a.push({x:c.x+u.x*r,y:c.y+u.y*r})}return a},Cn=(e,t,n,r)=>{let i=vn(e,t,n,5),a=[],o=[];for(let e=0;e<i.length;++e){let[t,n,s]=i[e];a.push(Sn(t,n,s,+r)),o.push(Sn(t,n,s,-r))}let s=a[0][0],c=[s.x,s.y,!1];for(let e=0;e<a.length;++e){let t=a[e];c.push(t[1].x,t[1].y,!0,t[2].x,t[2].y,!1)}let l=[...o].reverse();for(let e=0;e<l.length;++e){let[t,n,r]=l[e];l[e]=[r,n,t]}let u=l[0][0];c.push(u.x,u.y,!1);for(let e=0;e<l.length;++e){let t=l[e];c.push(t[1].x,t[1].y,!0,t[2].x,t[2].y,!1)}return c},wn=(e,t,n,r)=>{let i=[];for(let a=0;a<r.length;a+=3){if(r[a+2])continue;let o=r[a],s=r[a+1],c=Math.sqrt((o-e)**2+(s-t)**2);Math.abs(c-n)>1e-4||i.push(o,s)}return i},Tn=new OffscreenCanvas(1,1).getContext(`2d`),En=(e,t)=>{Tn.beginPath(),Tn.moveTo(t[0],t[1]);for(let e=3;e<t.length;e+=3)t[e+2]?(Tn.quadraticCurveTo(t[e],t[e+1],t[e+3],t[e+4]),e+=3):Tn.lineTo(t[e],t[e+1]);Tn.closePath();for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];if(!Tn.isPointInPath(n,r))return[n,r]}return null},Dn=(e,t,n,r,i=!1)=>{let a=i?0:r.length-1,o=i?r.length-1:r.length-2,s=r[a].length>15,c=r[o].length>15;if(s&&c)return;let l=wn(e,t,n,r[a]),u=wn(e,t,n,r[o]),d=En(l,r[o]);if(!d)return;let f=En(u,r[a]);if(!f)return;let p=Math.atan2(d[1]-t,d[0]-e),m=Math.atan2(f[1]-t,f[0]-e)-p;m>Math.PI?m-=2*Math.PI:m<-Math.PI&&(m+=2*Math.PI);let h=Math.abs(m);if(h<.1||h>Math.PI-.1)return;let g=m/8,_=[e,t,!1];for(let r=0;r<=8;r++){let i=p+r*g,a=e+n*Math.cos(i),o=t+n*Math.sin(i);_.push(a,o,!1)}r.splice(-1,0,_)},On=(e,t,n,r,i=!1)=>{let a=i?0:r.length-1,o=i?r.length-1:r.length-2,s=r[a].length>15,c=r[o].length>15;if(s&&c)return;let l=wn(e,t,n,r[a]),u=wn(e,t,n,r[o]);if(l[0]===u[0]&&l[1]===u[1]||l[0]===u[2]&&l[1]===u[3])return;let d=En(l,r[o]);if(!d)return;let f=En(u,r[a]);f&&r.splice(-1,0,[e,t,!1,d[0],d[1],!1,f[0],f[1],!1,e,t,!1])},kn=(e,t,n)=>{for(let r=0;r<2;++r){let i=0,a=0,o=0,s=0;r===0?(i=e[0],a=e[1],o=e[3],s=e[4]):(i=e[e.length-3],a=e[e.length-2],o=e[e.length-6],s=e[e.length-5]);let c=o-i,l=s-a,u=Math.atan2(l,c),d=u+Math.PI/2,f=u-Math.PI/2,p=(f-d)/16,m=[];for(let e=0;e<=16;e++){let n=f+p*e,r=i+t*Math.cos(n),o=a+t*Math.sin(n);m.push(r,o,!1)}r===0?n.unshift(m):n.push(m)}},An=(e,t,n)=>{for(let r=0;r<2;++r){let i=0,a=0,o=0,s=0;r===0?(i=e[0],a=e[1],o=e[3],s=e[4]):(i=e[e.length-3],a=e[e.length-2],o=e[e.length-6],s=e[e.length-5]);let c=-(o-i),l=-(s-a),u=Math.sqrt(c*c+l*l);if(u===0)continue;let d=c/u,f=l/u,p=i+t*d,m=a+t*f,h=-f,g=d,_=[p+t*d+t*h,m+t*f+t*g,!1,p+t*d-t*h,m+t*f-t*g,!1,p-t*d-t*h,m-t*f-t*g,!1,p+t*d+t*h,m+t*f+t*g,!1,p-t*d-t*h,m-t*f-t*g,!1,p-t*d+t*h,m-t*f+t*g,!1];r===0?n.unshift(_):n.push(_)}},jn=(e,t,n,r,i,a=!1)=>{let o=a?0:i.length-1,s=a?i.length-1:i.length-2,c=i[o].length>15,l=i[s].length>15;if(c&&l)return;let u=wn(e.x,e.y,r,i[o]),d=wn(e.x,e.y,r,i[s]);if(u[0]===d[0]&&u[1]===d[1]||u[0]===d[2]&&u[1]===d[3])return;let f=En(u,i[s]);if(!f)return;let p=En(d,i[o]);if(!p)return;let m=t.x-e.x,h=t.y-e.y,g=Math.hypot(m,h),_={x:m/g,y:h/g},v=n.x-e.x,y=n.y-e.y,b=Math.hypot(v,y),x={x:v/b,y:y/b},S=_.x,C=_.y,w=x.x,T=x.y,E=S*T-C*w;if(E===0){i.splice(-1,0,[e.x,e.y,!1,f[0],f[1],!1,p[0],p[1],!1]);return}let D=((p[0]-f[0])*T-(p[1]-f[1])*w)/E,O=f[0]+D*S,k=f[1]+D*C;i.splice(-1,0,[e.x,e.y,!1,f[0],f[1],!1,O,k,!1,e.x,e.y,!1,p[0],p[1],!1,O,k,!1])},Mn={x:0,y:0},Nn={x:0,y:0},Pn={x:0,y:0},Fn={x:0,y:0},In=(e,t)=>{let n=Mn;n.x=e[0],n.y=e[1];let r=Nn;r.x=0,r.y=0;let i=Pn;i.x=0,i.y=0;let a=Fn;a.x=0,a.y=0;let s=[];for(let c=3;c<e.length;c+=3){let l=e[c],u=e[c+1];if(e[c+2]){r.x=l,r.y=u;continue}if(i.x=l,i.y=u,e[c-1]?s.push(Cn(n,r,i,t)):s.push(hn(n,i,t)),s.length>1)switch(o.joints){case 0:On(n.x,n.y,t,s);break;case 1:a.x=e[c-6],a.y=e[c-5],jn(n,i,a,t,s);break;case 2:Dn(n.x,n.y,t,s);break}n.x=i.x,n.y=i.y}let c=e[0],l=e[1],u=e[e.length-3],d=e[e.length-2],f=1e-4;if(Math.abs(c-u)<f&&Math.abs(l-d)<f&&s.length>1)switch(o.joints){case 0:On(c,l,t,s,!0);break;case 1:n.x=c,n.y=l,i.x=e[3],i.y=e[4],a.x=e[e.length-6],a.y=e[e.length-5],jn(n,i,a,t,s,!0);break;case 2:Dn(c,l,t,s,!0);break;default:break}else switch(o.caps){case 1:kn(e,t,s);break;case 2:An(e,t,s);break;default:break}return s},Ln=e=>{let t=o.thickness/2,n=g();for(let r=0;r<e.length;++r){let i=In(e[r],t);for(let e=0;e<i.length;++e)n.push(i[e])}let r=un(n,`stroke`);return n.length=0,_(n),r},Rn=(e,t,n,r,i,a)=>{let o=z(!0);if(!o.length)return;on.push(e===0?`linear`:`radial`);let s=Ln(o);rn(s.buffer),an.push(s.indexCount),fn.push(t,n,r,i),e===1&&fn.push(a)},zn=new Map,Bn=()=>{zn.clear()},Vn=e=>{zn.set(an.length,e)},Hn=()=>({id:I(),resource:i.createVertexArray(),vertexBuffer:i.createBuffer(),vertexLength:0}),Un,Wn=e=>{Un&&Un.id===e.id||(Un=e,i.bindVertexArray(e.resource))},Gn=()=>{let e=Hn();Wn(e),i.bindBuffer(i.ARRAY_BUFFER,e.vertexBuffer);let t=new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]);return i.bufferData(i.ARRAY_BUFFER,t,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,0,0),e},Kn=[],qn=new Float32Array([0,0,0,1,1,0,1,1]),Jn,Yn=e=>{Jn=e.createBuffer()},Xn,Zn=e=>{Xn=e},Qn,$n=()=>(Qn||=Gn(),Qn),er=()=>{if(Kn.length)return Kn.pop();let e=Hn();return Wn(e),i.bindBuffer(i.ARRAY_BUFFER,e.vertexBuffer),i.enableVertexAttribArray(0),i.enableVertexAttribArray(1),i.enableVertexAttribArray(2),i.enableVertexAttribArray(3),i.enableVertexAttribArray(4),i.enableVertexAttribArray(5),i.vertexAttribPointer(0,2,i.FLOAT,!1,68,0),i.vertexAttribPointer(1,2,i.FLOAT,!1,68,8),i.vertexAttribPointer(2,4,i.FLOAT,!1,68,16),i.vertexAttribPointer(3,3,i.FLOAT,!1,68,32),i.vertexAttribPointer(4,3,i.FLOAT,!1,68,44),i.vertexAttribPointer(5,3,i.FLOAT,!1,68,56),e},tr=()=>{let e=er();Wn(e);let t=tn(),n=nn();return i.bindBuffer(i.ARRAY_BUFFER,e.vertexBuffer),e.vertexLength<t.length&&(e.vertexLength=v(t.length),i.bufferData(i.ARRAY_BUFFER,e.vertexLength*4,i.STREAM_DRAW)),i.bufferSubData(i.ARRAY_BUFFER,0,t.subarray(0,n)),e},nr=e=>{Kn.indexOf(e)>-1||Kn.push(e)},rr=0,ir=(e,t)=>{let n=i.createProgram(),r=i.createShader(i.VERTEX_SHADER);i.shaderSource(r,e),i.compileShader(r);let a=i.createShader(i.FRAGMENT_SHADER);return i.shaderSource(a,t),i.compileShader(a),i.attachShader(n,r),i.attachShader(n,a),i.linkProgram(n),i.detachShader(n,r),i.detachShader(n,a),i.deleteShader(r),i.deleteShader(a),{id:rr++,resource:n}},ar=(e,t,n=!1)=>{let r=i.getProgramParameter(e,i.ACTIVE_UNIFORMS);for(let a=0;a<r;++a){let r=i.getActiveUniform(e,a),o=r.name.endsWith(`[0]`)?r.name.slice(0,-3):r.name,s=i.getUniformLocation(e,o);if(r.type===i.SAMPLER_2D&&r.size===1&&!n)continue;let c={};switch(r.type){case i.FLOAT_VEC4:c.method=i.uniform4fv.bind(i,s),c.array=new Float32Array(4*r.size),c.assign=-1;break;case i.INT_VEC4:c.method=i.uniform4iv.bind(i,s),c.array=new Int32Array(4*r.size),c.assign=-1;break;case i.SAMPLER_2D:c.method=n?i.uniform1i.bind(i,s,3):i.uniform1iv.bind(i,s),c.array=new Int32Array(r.size),c.assign=1;break;case i.FLOAT:case i.FLOAT_VEC2:case i.FLOAT_VEC3:case i.FLOAT_MAT2:case i.FLOAT_MAT3:case i.FLOAT_MAT4:case i.INT:case i.INT_VEC2:case i.INT_VEC3:default:throw Error(`Use gl.FLOAT_VEC4 or gl.INT_VEC4 instead`)}t.set(o,c)}},or=-1,sr=e=>{or!==e.id&&(or=e.id,i.useProgram(e.resource))},cr=e=>{for(let t of e.values())t.method===void 0||t.assign===void 0||(t.assign<0?t.method(t.array):t.assign>0&&(t.assign--,t.method(t.array)))};var lr=class{_$programObject;_$uniformMap;highp;mediump;textures;constructor(e,t,n=!1){this._$programObject=ir(e,t),this._$uniformMap=new Map,ar(this._$programObject.resource,this._$uniformMap,n);let r=new Float32Array;this.highp=this._$uniformMap.get(`u_highp`)?.array??r,this.mediump=this._$uniformMap.get(`u_mediump`)?.array??r,this.textures=this._$uniformMap.get(`u_textures`)?.array??r}useProgram(){sr(this._$programObject)}bindUniform(){cr(this._$uniformMap)}};let ur=new Map,dr=()=>`\nvec2 applyMatrix(in vec2 vertex) {\n mat3 matrix = mat3(a_matrix0, a_matrix1, a_matrix2);\n return (matrix * vec3(vertex, 1.0)).xy;\n}`,fr=e=>`\nvec2 applyMatrix(in vec2 vertex) {\n mat3 parent_matrix = mat3(\n u_highp[${e}].xyz,\n u_highp[${e+1}].xyz,\n u_highp[${e+2}].xyz\n );\n mat3 ancestor_matrix = mat3(\n u_highp[${e+3}].xyz,\n u_highp[${e+4}].xyz,\n u_highp[${e+5}].xyz\n );\n\n vec2 parent_offset = vec2(u_highp[${e+2}].w, u_highp[${e+3}].w);\n vec2 parent_size = vec2(u_highp[${e+4}].w, u_highp[${e+5}].w);\n vec4 grid_min = u_highp[${e+6}];\n vec4 grid_max = u_highp[${e+7}];\n\n vec2 position = (parent_matrix * vec3(vertex, 1.0)).xy;\n position = (position - parent_offset) / parent_size;\n\n vec4 ga = grid_min;\n vec4 gb = grid_max - grid_min;\n vec4 gc = vec4(1.0) - grid_max;\n\n vec2 pa = position;\n vec2 pb = position - grid_min.st;\n vec2 pc = position - grid_max.st;\n\n position = (ga.pq / ga.st) * min(pa, ga.st)\n + (gb.pq / gb.st) * clamp(pb, vec2(0.0), gb.st)\n + (gc.pq / gc.st) * max(vec2(0.0), pc);\n\n position = position * parent_size + parent_offset;\n position = (ancestor_matrix * vec3(position, 1.0)).xy;\n\n position = position + vec2(u_highp[${e+8}].x, u_highp[${e+8}].y);\n return position / vec2(u_highp[0].w, u_highp[1].w);\n}`,pr=()=>`layout (location = 1) in vec2 a_bezier;`,mr=()=>`layout (location = 3) in vec3 a_matrix0;\nlayout (location = 4) in vec3 a_matrix1;\nlayout (location = 5) in vec3 a_matrix2;`,hr=()=>`out vec2 v_uv;`,gr=()=>`out vec2 v_bezier;`,_r=()=>`\n mat3 uv_matrix = mat3(\n u_highp[0].xyz,\n u_highp[1].xyz,\n u_highp[2].xyz\n );\n mat3 inverse_matrix = mat3(\n u_highp[3].xyz,\n u_highp[4].xyz,\n vec3(u_highp[2].w, u_highp[3].w, u_highp[4].w)\n );\n v_uv = (inverse_matrix * uv_matrix * vec3(a_vertex, 1.0)).xy;`,vr=()=>`v_bezier = a_bezier;`,yr=()=>`layout (location = 2) in vec4 a_color;`,br=()=>`out vec4 v_color;`,xr=()=>`v_color = a_color;`,Sr=(e,t,n,r)=>{let i=n?pr():``,a=n?gr():t?hr():``,o=n?vr():t?_r():``,s=r?fr(t?5:0):dr(),c=n?``:yr(),l=n?``:br(),u=n?``:xr();return`#version 300 es\n\nlayout (location = 0) in vec2 a_vertex;\n${i}\n${c}\n${r?``:mr()}\n\n${e>1?`uniform vec4 u_highp[${e}];`:``}\n${a}\n${l}\n${s}\n\nvoid main() {\n ${u}\n ${o}\n vec2 pos = applyMatrix(a_vertex);\n pos = pos * 2.0 - 1.0;\n gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);\n}`},Cr=()=>`#version 300 es\nlayout (location = 0) in vec2 a_vertex;\nvoid main() {\n vec2 pos = a_vertex * 2.0 - 1.0;\n gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);\n}`,wr=()=>`#version 300 es\nprecision mediump float;\n\nin vec4 v_color;\nout vec4 o_color;\n\nvoid main() {\n o_color = vec4(v_color.rgb * v_color.a, v_color.a);\n}`,Tr=()=>`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[1];\n\nin vec2 v_uv;\nout vec4 o_color;\n\nvoid main() {\n vec2 uv = vec2(v_uv.x, u_mediump[0].y - v_uv.y) / u_mediump[0].xy;\n\n vec4 src = texture(u_texture, uv);\n o_color = src;\n}`,Er=()=>`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[1];\n\nin vec2 v_uv;\nout vec4 o_color;\n\nvoid main() {\n vec2 uv = fract(vec2(v_uv.x, -v_uv.y) / u_mediump[0].xy);\n\n vec4 src = texture(u_texture, uv);\n o_color = src;\n}`,Dr=()=>`#version 300 es\nprecision mediump float;\n\nin vec2 v_bezier;\nout vec4 o_color;\n\nvoid main() {\n float f_val = v_bezier.x * v_bezier.x - v_bezier.y;\n\n float dx = dFdx(f_val);\n float dy = dFdy(f_val);\n\n float dist = f_val / length(vec2(dx, dy));\n float alpha = smoothstep(0.5, -0.5, dist);\n\n if (alpha > 0.001) {\n o_color = vec4(min(alpha, 1.0));\n } else {\n discard;\n }\n}`,Or=()=>`#version 300 es\nprecision mediump float;\nout vec4 o_color;\nvoid main() {\n o_color = vec4(1.0);\n}`,kr=e=>{let t=`m${e?`y`:`n`}`;if(ur.has(t))return ur.get(t);let n=new lr(Sr(e?9:0,!1,!0,e),Dr());return ur.set(t,n),n},Ar=(e,t)=>{let n=e.highp;n[0]=t[0],n[1]=t[1],n[2]=0,n[4]=t[2],n[5]=t[3],n[6]=0,n[8]=t[4],n[9]=t[5],n[10]=1,n[12]=t[6],n[13]=t[7],n[14]=0,n[16]=t[8],n[17]=t[9],n[18]=0,n[20]=t[10],n[21]=t[11],n[22]=1,n[3]=k,n[7]=A,n[11]=t[12],n[15]=t[13],n[19]=t[14],n[23]=t[15],n[24]=t[16],n[25]=t[17],n[26]=t[18],n[27]=t[19],n[28]=t[20],n[29]=t[21],n[30]=t[22],n[31]=t[23],n[32]=t[24],n[33]=t[25]},jr=`normal`,Mr=e=>{jr=e},Nr=600,Pr=e=>{Nr=e},Fr=()=>{Nr!==613&&(Pr(613),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA))},Ir=(e,t,n,r)=>{e.useProgram(),e.bindUniform(),Fr(),Wn(t),i.drawArrays(i.TRIANGLES,n,r)},Lr=()=>{let e=`rmnn`;if(ur.has(e))return ur.get(e);let t=new lr(Cr(),Or());return ur.set(e,t),t},Rr=()=>{let e=o.currentAttachmentObject;if(!e)return;let t=1<<e.clipLevel-1;i.stencilMask(~t-1),i.stencilFunc(i.LEQUAL,t,255),i.stencilOp(i.ZERO,i.REPLACE,i.REPLACE),Ir(Lr(),$n(),0,6),i.stencilMask(1<<e.clipLevel),i.stencilFunc(i.ALWAYS,0,255),i.stencilOp(i.REPLACE,i.REPLACE,i.REPLACE),Ir(Lr(),$n(),0,6),i.stencilMask(255),i.stencilOp(i.ZERO,i.INVERT,i.INVERT)},zr=()=>{let e=o.currentAttachmentObject;if(!e)return;let t=zt.get(e.clipLevel),n=t[0],r=t[1],a=t[2],s=t[3],c=Math.ceil(Math.abs(a-n)),d=Math.ceil(Math.abs(s-r));l(),i.scissor(n,e.height-r-d,c,d);let f=tr(),p=Bt.get(e.clipLevel),m=0,h=null,g=an.length;for(let t=0;t<g;t++){i.stencilMask(1<<p-1);let n=an[t];zn.has(t)&&(h=zn.get(t));let r=kr(!!h);h&&Ar(r,h),Ir(r,f,m,n),m+=n,++p,p>7&&(Rr(),p=e.clipLevel+1)}Bt.set(e.clipLevel,p),nr(f),sn(),Bn(),u()},Br=(e,t,n)=>{if(e.used)return e.left?.insert(t,n)||e.right?.insert(t,n)||null;if(t>e.w||n>e.h)return null;if(t===e.w&&n===e.h)return e.used=!0,e;let r=t+1,i=n+1,a=e.w-r,o=e.h-i;return a>o?(e.left=e.create(e.index,e.x,e.y,t,e.h),e.right=e.create(e.index,e.x+r,e.y,a,e.h)):(e.left=e.create(e.index,e.x,e.y,e.w,n),e.right=e.create(e.index,e.x,e.y+i,e.w,o)),e.used=!0,e.left.insert(t,n)},Vr=(e,t,n,r,i)=>e.left?.dispose(t,n,r,i)?(!e.left.used&&!e.right?.used&&(e.left&&e.left.release(),e.right&&e.right.release(),e.left=e.right=null,e.used=!1),!0):e.right?.dispose(t,n,r,i)?(!e.right.used&&!e.left?.used&&(e.left&&e.left.release(),e.right&&e.right.release(),e.left=e.right=null,e.used=!1),!0):t===e.x&&n===e.y&&r===e.w&&i===e.h?(e.used=!1,!0):!1,Hr=[];var Ur=class e{index;x;y;w;h;left;right;used;constructor(e,t,n,r,i){this.index=e,this.x=t,this.y=n,this.w=r,this.h=i,this.left=null,this.right=null,this.used=!1}insert(e,t){return Br(this,e,t)}dispose(e,t,n,r){return Vr(this,e,t,n,r)}create(t,n,r,i,a){let o=Hr.length?Hr.pop():new e(t,0,0,0,0);return o.index=t,o.x=n,o.y=r,o.w=i,o.h=a,o.left=null,o.right=null,o.used=!1,o}release(){this.left&&=(this.left.release(),null),this.right&&=(this.right.release(),null),this.used=!1,Hr.push(this)}},Wr=class{_$root;constructor(e,t,n){this._$root=new Ur(e,0,0,t,n)}insert(e,t){return this._$root.insert(e,t)}dispose(e,t,n,r){return this._$root.dispose(e,t,n,r)}};let Gr=(t,n)=>{let r=ht;xt[r]||(xt[r]=new Wr(r,e,e));let i=xt[r].insert(t,n);if(i)return i;for(let e=0;e<10;e++){if(r===e)continue;gt(e);let i=xt[e];if(!i)return Gr(t,n);let a=i.insert(t,n);if(a)return a}return Gr(t,n)},Kr=e=>{let t=xt[e.index];t&&t.dispose(e.x,e.y,e.w,e.h)},qr=()=>`\nfloat isInside(in vec2 uv) {\n 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)));\n}`,Jr=e=>`\n vec4 mul = u_mediump[${e}];\n vec4 add = u_mediump[${e+1}];\n\n if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0\n || add.x != 0.0 || add.y != 0.0 || add.z != 0.0\n ) {\n src.rgb /= max(0.0001, src.a);\n src = clamp(src * mul + add, 0.0, 1.0);\n src.rgb *= src.a;\n }\n`,Yr=e=>`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\n${e?`uniform vec4 u_mediump[2];`:``}\n\nin vec2 v_coord;\nout vec4 o_color;\n\nvoid main() {\n vec4 src = texture(u_texture, v_coord);\n ${e?Jr(0):``}\n o_color = src;\n}`,Xr=()=>`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\n\nin vec4 v_mul;\nin vec4 v_add;\nin vec2 v_coord;\nout vec4 o_color;\n\nvoid main() {\n vec4 src = texture(u_texture, v_coord);\n\n if (v_mul.x != 1.0 || v_mul.y != 1.0 || v_mul.z != 1.0 || v_mul.w != 1.0\n || v_add.x != 0.0 || v_add.y != 0.0 || v_add.z != 0.0\n ) {\n src.rgb /= max(0.0001, src.a);\n src = clamp(src * v_mul + v_add, 0.0, 1.0);\n src.rgb *= src.a;\n }\n\n o_color = src;\n}`,Zr=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),Qr=new class{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...e){this.buffer.length<this.offset+e.length&&this.resize(e.length);for(let t=0;t<e.length;t++)this.buffer[this.offset++]=e[t]}pushDisplayObjectBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){this.buffer.length<this.offset+22&&this.resize(22),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x}pushInstanceBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C){this.buffer.length<this.offset+24&&this.resize(24),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C}pushShapeBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,j){this.buffer.length<this.offset+32&&this.resize(32),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E,this.buffer[this.offset++]=D,this.buffer[this.offset++]=O,this.buffer[this.offset++]=k,this.buffer[this.offset++]=A,this.buffer[this.offset++]=j}pushTextFieldBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k){this.buffer.length<this.offset+30&&this.resize(30),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E,this.buffer[this.offset++]=D,this.buffer[this.offset++]=O,this.buffer[this.offset++]=k}pushVideoBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E){this.buffer.length<this.offset+27&&this.resize(27),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E}set(e){this.buffer.length<this.offset+e.length&&this.resize(e.length),this.buffer.set(e,this.offset),this.offset+=e.length}resize(e){let t=new Float32Array(Zr(this.offset+e));this.buffer.length&&t.set(this.buffer),this.buffer=t}};var $r=class extends lr{count;constructor(e,t,n=!0){super(e,t,n),this.count=0}clear(){this.count=Qr.offset=0}};let ei=()=>`#version 300 es\n\nlayout (location = 0) in vec2 a_vertex;\n\nout vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n vec2 position = a_vertex * 2.0 - 1.0;\n gl_Position = vec4(position, 0.0, 1.0);\n}`,ti=()=>`#version 300 es\n\nlayout (location = 0) in vec2 a_vertex;\nuniform vec4 u_highp[3];\n\nout vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n mat3 matrix = mat3(\n u_highp[0].x, u_highp[0].y, 0.0,\n u_highp[0].z, u_highp[0].w, 0.0,\n u_highp[1].x, u_highp[1].y, 1.0\n );\n\n vec2 size = u_highp[1].zw;\n vec2 viewport = vec2(u_highp[2].x, u_highp[2].y);\n\n vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);\n position = position * size;\n position = (matrix * vec3(position, 1.0)).xy;\n position /= viewport;\n\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}`,ni=()=>`#version 300 es\n\nlayout (location = 0) in vec2 a_vertex;\nuniform vec4 u_highp[2];\n\nout vec2 v_coord;\n\nvoid main() {\n v_coord = a_vertex;\n\n vec2 offset = u_highp[0].xy;\n vec2 size = u_highp[0].zw;\n vec2 viewport = vec2(u_highp[1].x, u_highp[1].y);\n\n vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);\n position = position * size + offset;\n position /= viewport;\n\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}`,ri=()=>`#version 300 es\n\nlayout (location = 0) in vec2 a_vertex;\nlayout (location = 1) in vec4 a_rect;\nlayout (location = 2) in vec4 a_size;\nlayout (location = 3) in vec2 a_offset;\nlayout (location = 4) in vec4 a_matrix;\nlayout (location = 5) in vec4 a_mul;\nlayout (location = 6) in vec4 a_add;\n\nout vec2 v_coord;\nout vec4 v_mul;\nout vec4 v_add;\n\nvoid main() {\n v_coord = a_vertex * a_rect.zw + a_rect.xy;\n v_mul = a_mul;\n v_add = a_add;\n\n vec2 position = vec2(a_vertex.x, 1.0 - a_vertex.y);\n position = position * a_size.xy;\n\n mat3 matrix = mat3(\n a_matrix.x, a_matrix.y, 0.0,\n a_matrix.z, a_matrix.w, 0.0,\n a_offset.x, a_offset.y, 1.0\n );\n\n position = (matrix * vec3(position, 1.0)).xy;\n position /= a_size.zw;\n\n position = position * 2.0 - 1.0;\n gl_Position = vec4(position.x, -position.y, 0.0, 1.0);\n}`,ii=new Map,ai=()=>{if(ii.has(`i`))return ii.get(`i`);let e=new $r(ri(),Xr());return ii.set(`i`,e),e},oi=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n return src + dst - dst * src.a;\n}`,si=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(dst.rgb - src.rgb, src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,ci=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n vec4 c = src * dst;\n\n return a + b + c;\n}`,li=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(src.rgb, dst.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,ui=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(mix(src.rgb, dst.rgb, step(dst.rgb, src.rgb)), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,di=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), dst.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,fi=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 mul = src * dst;\n vec3 c1 = 2.0 * mul.rgb;\n vec3 c2 = 2.0 * (src.rgb + dst.rgb - mul.rgb) - 1.0;\n vec4 c = vec4(mix(c1, c2, step(vec3(0.5), src.rgb)), mul.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,pi=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 a = src - src * dst.a;\n vec4 b = dst - dst * src.a;\n\n src.rgb /= src.a;\n dst.rgb /= dst.a;\n\n vec4 c = vec4(abs(src.rgb - dst.rgb), src.a * dst.a);\n c.rgb *= c.a;\n\n return a + b + c;\n}`,mi=()=>`\nvec4 blend (in vec4 src, in vec4 dst) {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n vec4 b = dst - dst * src.a;\n vec4 c = vec4(src.a - dst.rgb * src.a, src.a);\n\n return b + c;\n}`,hi=(e,t)=>{let n;switch(e){case`subtract`:n=si();break;case`multiply`:n=ci();break;case`lighten`:n=li();break;case`darken`:n=ui();break;case`overlay`:n=di();break;case`hardlight`:n=fi();break;case`difference`:n=pi();break;case`invert`:n=mi();break;default:n=oi();break}let r=t?`uniform vec4 u_mediump[2];`:``,i=t?Jr(0):``;return`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\n${r}\n\nin vec2 v_coord;\nout vec4 o_color;\n\n${n}\n\nvoid main() {\n vec4 dst = texture(u_textures[0], v_coord);\n vec4 src = texture(u_textures[1], v_coord);\n ${i}\n o_color = blend(src, dst);\n}`},gi=(e,t)=>{let n=`i${e}${t?`y`:`n`}`;if(ii.has(n))return ii.get(n);let r=new lr(ei(),hi(e,t));return ii.set(n,r),r},_i=()=>{if(!o.newDrawState)return;let e=o.currentAttachmentObject,t=o.atlasAttachmentObject;o.bind(t),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ie),Ve(!1);let n=Tt(ht);l(),i.scissor(n[0],n[1],n[2]-n[0],n[3]-n[1]),i.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,i.COLOR_BUFFER_BIT,i.NEAREST),u(),e&&o.bind(e),o.newDrawState=!1},vi=e=>{let t=ht;gt(e.index),_i(),i.bindFramebuffer(i.FRAMEBUFFER,He);let n=Ct();i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n.resource,0),i.bindFramebuffer(i.FRAMEBUFFER,Ue);let r=lt(e.w,e.h);return i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,r.resource,0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,He),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue),i.blitFramebuffer(e.x,e.y,e.x+e.w,e.y+e.h,0,0,e.w,e.h,i.COLOR_BUFFER_BIT,i.NEAREST),gt(t),i.bindFramebuffer(i.READ_FRAMEBUFFER,Me),i.bindFramebuffer(i.FRAMEBUFFER,Me),r},yi=(e,t,n=!1)=>{Mt(2,i.TEXTURE2,null,n),Mt(1,i.TEXTURE1,t,n),Mt(0,i.TEXTURE0,e,n)},bi=()=>{if(ii.has(`p`))return ii.get(`p`);let e=new lr(ni(),Yr(!1));return ii.set(`p`,e),e},xi=(e,t,n)=>{let r=e.highp,i=o.$matrix;r[0]=i[6],r[1]=i[7],r[2]=t,r[3]=n,r[4]=k,r[5]=A},Si=e=>{e.useProgram(),e.bindUniform(),Wn($n()),i.drawArrays(i.TRIANGLES,0,6)},Ci=null,wi=(e,t,n,r)=>{let a=o.currentAttachmentObject,s=o.$mainAttachmentObject;return o.bind(s),i.bindFramebuffer(i.FRAMEBUFFER,Ue),(!Ci||Ci.width!==s.width||Ci.height!==s.height)&&(Ci=lt(s.width,s.height)),Nt(Ci),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Ci.resource,0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,Me),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,Ue),l(),i.scissor(e,s.height-t-r,n+1,r+1),i.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,i.COLOR_BUFFER_BIT,i.NEAREST),u(),i.bindFramebuffer(i.FRAMEBUFFER,Me),a&&o.bind(a),Ci},Ti=(e,t,n,r)=>{let i=o.currentAttachmentObject,a=wi(e,t,n,r),s=ut(n,r,!1);o.bind(s),o.save(),o.setTransform(1,0,0,1,-e,-t);let c=bi();xi(c,a.width,a.height),Fr(),Nt(a),Si(c);let l=s.texture;return o.restore(),qe(s,!1),i&&o.bind(i),l},Ei=()=>{Nr!==610&&(Pr(610),i.blendFunc(i.ONE,i.ZERO))},Di=e=>{Nt(e),Ei();let t=bi();xi(t,e.width,e.height),Si(t),Fr()},Oi=(e,t,n,r,i,a,o,s,c)=>{let l=e.textures;l[0]=0,l[1]=1;let u=e.mediump;u[0]=t,u[1]=n,u[2]=r,u[3]=i,u[4]=a,u[5]=o,u[6]=s,u[7]=c},ki=(e=!1)=>{let t=`m${e?`y`:`n`}`;if(ii.has(t))return ii.get(t);let n=new lr(ti(),Yr(e));return ii.set(t,n),n},Ai=(e,t,n)=>{let r=e.highp,i=o.$matrix;r[0]=i[0],r[1]=i[1],r[2]=i[3],r[3]=i[4],r[4]=i[6],r[5]=i[7],r[6]=t,r[7]=n,r[8]=k,r[9]=A},ji=(t,n,r,i,a,s)=>{let c=s[0],l=s[1],u=s[2],d=o.globalAlpha,f=s[4]/255,p=s[5]/255,m=s[6]/255,h=o.$matrix;switch(o.globalCompositeOperation){case`normal`:case`layer`:case`add`:case`screen`:case`alpha`:case`erase`:case`copy`:{if(jr!==o.globalCompositeOperation||Dt!==t.index){gt(Dt);let e=o.globalCompositeOperation;o.globalCompositeOperation=jr,o.newDrawState=!0,o.drawArraysInstanced(),o.newDrawState=!0,o.globalCompositeOperation=e,Mr(o.globalCompositeOperation),Ot(t.index),gt(t.index)}let n=ai();Qr.pushDisplayObjectBuffer((t.x+.5)/e,(t.y+.5)/e,(t.w-1)/e,(t.h-1)/e,t.w,t.h,k,A,h[6],h[7],h[0],h[1],h[3],h[4],c,l,u,d,f,p,m,0),n.count++}break;default:{let e=o.currentAttachmentObject;o.drawArraysInstanced();let s=Math.ceil(Math.abs(i-n)),g=Math.ceil(Math.abs(a-r)),_=0,v=0,y=vi(t);if(h[0]!==1||h[1]!==0||h[3]!==0||h[4]!==1){let n=ut(s,g,!1),r=E(h[0],h[1],h[3],h[4],s/2,g/2),i=E(1,0,0,1,-t.w/2,-t.h/2),a=E(r[0]*i[0]+r[2]*i[1],r[1]*i[0]+r[3]*i[1],r[0]*i[2]+r[2]*i[3],r[1]*i[2]+r[3]*i[3],r[0]*i[4]+r[2]*i[5]+r[4],r[1]*i[4]+r[3]*i[5]+r[5]);o.save(),o.bind(n),o.setTransform(a[0],a[1],a[2],a[3],a[4],a[5]),_=a[4],v=a[5];let c=ki();Ai(c,y.width,y.height),Nt(y,!0),Si(c),H(y),y=n.texture,qe(n,!1),e&&o.bind(e),o.restore()}(_||v)&&(h[6]-=_,h[7]-=v);let b=Ti(h[6],h[7],s,g),x=ut(s,g,!1);o.bind(x),yi(b,y);let S=gi(o.globalCompositeOperation,!0);Oi(S,c,l,u,d,f,p,m,0),Si(S),e&&o.bind(e),Di(x.texture),(_||v)&&(h[6]+=_,h[7]+=v),H(y),H(b),qe(x),Mr(o.globalCompositeOperation),Ot(t.index),gt(t.index)}break}},Mi=()=>{ai().clear()},Ni=0,Pi=()=>{Wn(Xn),i.bindBuffer(i.ARRAY_BUFFER,Jn),Qr.buffer.length>Ni&&(Ni=Qr.buffer.length,i.bufferData(i.ARRAY_BUFFER,Ni*4,i.STREAM_DRAW)),i.bufferSubData(i.ARRAY_BUFFER,0,Qr.buffer,0,Qr.offset)},Fi=e=>{e.useProgram(),e.bindUniform(),Pi(),i.drawArraysInstanced(i.TRIANGLES,0,6,e.count)},Ii=()=>{Nr!==611&&(Pr(611),i.blendFunc(i.ONE,i.ONE))},Li=()=>{Nr!==641&&(Pr(641),i.blendFunc(i.ONE_MINUS_DST_COLOR,i.ONE))},Ri=()=>{Nr!==606&&(Pr(606),i.blendFunc(i.ZERO,i.SRC_ALPHA))},zi=()=>{Nr!==603&&(Pr(603),i.blendFunc(i.ZERO,i.ONE_MINUS_SRC_ALPHA))},Bi=e=>{switch(e){case`add`:Ii();break;case`screen`:Li();break;case`alpha`:Ri();break;case`erase`:zi();break;case`copy`:Ei();break;default:Fr();break}},Vi=()=>{let e=ai();e.count&&(_i(),Bi(jr),Fi(e),e.clear())},Hi=()=>{let e=Hn();return Wn(e),i.bindBuffer(i.ARRAY_BUFFER,e.vertexBuffer),i.bufferData(i.ARRAY_BUFFER,new Float32Array([0,0,1,0,1,1,0,0,1,1,0,1]),i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,Jn),i.bufferData(i.ARRAY_BUFFER,Qr.buffer.length,i.STREAM_DRAW),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,4,i.FLOAT,!1,88,0),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,88,16),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,88,32),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,4,i.FLOAT,!1,88,40),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,4,i.FLOAT,!1,88,56),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,4,i.FLOAT,!1,88,72),i.vertexAttribDivisor(6,1),e},Ui=e=>{Yn(e),Zn(Hi())},Wi=()=>{let e=o.$mainAttachmentObject;o.bind(e),i.bindFramebuffer(i.READ_FRAMEBUFFER,Me),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null);let t=e.width,n=e.height;i.blitFramebuffer(0,0,t,n,0,0,t,n,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,Pe),i.bindFramebuffer(i.FRAMEBUFFER,Me)},Gi=()=>{i.enable(i.BLEND),Fr()},Ki=()=>{let e=o.currentAttachmentObject;e&&(e.mask=!0,e.clipLevel++,Bt.set(e.clipLevel,e.clipLevel),Rt()||(Lt(!0),f(),i.enable(i.SAMPLE_ALPHA_TO_COVERAGE),i.stencilFunc(i.ALWAYS,0,255),i.stencilOp(i.ZERO,i.INVERT,i.INVERT),i.colorMask(!1,!1,!1,!1)))},qi=(e,t,n,r)=>{let a=o.currentAttachmentObject;if(!a)return;zt.set(a.clipLevel,b(e,t,n,r));let s=Math.ceil(Math.abs(n-e)),c=Math.ceil(Math.abs(r-t));l(),i.scissor(e,a.height-t-c,s,c)},Ji=()=>{let e=o.currentAttachmentObject;if(!e)return;let t=e.clipLevel,n=zt.get(t),r=n[0],a=n[1],s=n[2],c=n[3];zt.delete(t),Bt.delete(t),x(n);let d=Math.ceil(Math.abs(s-r)),f=Math.ceil(Math.abs(c-a));if(l(),i.scissor(r,e.height-a-f,d,f),--e.clipLevel,!e.clipLevel){e.mask=!1,Lt(!1),i.clear(i.STENCIL_BUFFER_BIT),p(),u(),Bt.clear(),zt.clear();return}i.stencilMask(1<<e.clipLevel),i.stencilFunc(i.ALWAYS,0,255),i.stencilOp(i.REPLACE,i.REPLACE,i.REPLACE),i.colorMask(!1,!1,!1,!1),Ir(Lr(),$n(),0,6),Ft()},Yi=(e,t,n,r=!1)=>{let a=lt(e,t,r);return i.texSubImage2D(i.TEXTURE_2D,0,0,0,e,t,i.RGBA,i.UNSIGNED_BYTE,n),a},Xi=(e,t)=>{let n=Yi(e.w,e.h,t),r=bi();xi(r,e.w,e.h),Fr(),Si(r),H(n)},Zi=(e,t,n,r=!1)=>{let a=lt(e,t,r);return i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,n),a},Qi=(e,t)=>{let n=Zi(e.w,e.h,t),r=bi();xi(r,e.w,e.h),Fr(),Si(r),H(n)},$i=[],ea=(e,t,n,r,i,a)=>{let o=z();if(!o.length)return;on.push(`bitmap`);let s=un(o);rn(s.buffer),an.push(s.indexCount),$i.push(e,t,n,r,i,a)},ta=(e,t,n,r,i,a)=>{let o=z(!0);if(!o.length)return;on.push(`bitmap`);let s=Ln(o);rn(s.buffer),an.push(s.indexCount),$i.push(e,t,n,r,i,a)},na=()=>{let e=z(!0);if(!e.length)return;on.push(`fill`);let t=Ln(e);rn(t.buffer),an.push(t.indexCount)},ra=e=>{let t=e.toFixed(1);return`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump;\n\nin vec2 v_coord;\nout vec4 o_color;\n\nvoid main() {\n vec2 offset = u_mediump.xy;\n float fraction = u_mediump.z;\n float samples = u_mediump.w;\n \n vec4 color = texture(u_texture, v_coord);\n\n for (float i = 1.0; i < ${t}; i += 1.0) {\n color += texture(u_texture, v_coord + offset * i);\n color += texture(u_texture, v_coord - offset * i);\n }\n color += texture(u_texture, v_coord + offset * ${t}) * fraction;\n color += texture(u_texture, v_coord - offset * ${t}) * fraction;\n color /= samples;\n\n o_color = color;\n}`},ia=new Map,aa=e=>{let t=`b${e}`;if(ia.has(t))return ia.get(t);let n=new lr(ei(),ra(e));return ia.set(t,n),n},oa=(e,t,n,r,i,a)=>{let o=e.mediump;r?(o[0]=1/t,o[1]=0):(o[0]=0,o[1]=1/n),o[2]=i,o[3]=a},sa=(e,t,n)=>{Nt(e,!0);let r=Math.ceil(n*.5),i=1-(r-n*.5),a=1+n,o=aa(r);oa(o,e.width,e.height,t,i,a),Si(o)},U={x:0,y:0},ca=(e,t,n)=>(e>>16)*(n?t:1)/255,la=(e,t,n)=>(e>>8&255)*(n?t:1)/255,ua=(e,t,n)=>(e&255)*(n?t:1)/255,da=[.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],fa=(e,t,n=4,r=4,i=1,a=!0)=>{let s=o.currentAttachmentObject,c=Math.sqrt(t[0]*t[0]+t[1]*t[1]),l=Math.sqrt(t[2]*t[2]+t[3]*t[3]),u=N,d=c/u*n,f=l/u*r,p=da[i-1],m=Math.round(d*p),h=Math.round(f*p);U.x+=m,U.y+=h;let g=e.width+m*2,_=e.height+h*2,v=1,y=1;d>128?v=.0625:d>64?v=.125:d>32?v=.25:d>16&&(v=.5),f>128?y=.0625:f>64?y=.125:f>32?y=.25:f>16&&(y=.5);let b=Math.ceil(g*v),x=Math.ceil(_*y),S=ut(b,x,!1),C=[S,ut(b,x,!1)];o.bind(S),o.reset(),o.setTransform(v,0,0,y,m*v,h*y),Nt(e);let w=ki();Ai(w,e.width,e.height),Si(w),a&&H(e);let T=d*v,E=f*y,D=0,O=S.texture;Nt(O,!0),Ei();for(let e=0;e<i;++e){if(n>0){D=(D+1)%2;let e=C[D];o.bind(e),sa(O,!0,T),O=e.texture}if(r>0){D=(D+1)%2;let e=C[D];o.bind(e),sa(O,!1,E),O=e.texture}}if(Fr(),v!==1||y!==1){let e=ut(g,_,!1);o.bind(e),o.setTransform(1/v,0,0,1/y,0,0),Nt(O,!0),Ai(w,O.width,O.height),Si(w),O=e.texture,qe(C[0]),qe(C[1]),qe(e,!1)}else D=(D+1)%2,qe(C[D]),D=(D+1)%2,qe(C[D],!1);return s&&o.bind(s),O},pa=()=>`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[5];\n\nin vec2 v_coord;\nout vec4 o_color;\n\nvoid main() {\n mat4 mul = mat4(u_mediump[0], u_mediump[1], u_mediump[2], u_mediump[3]);\n vec4 add = u_mediump[4];\n \n vec4 color = texture(u_texture, v_coord);\n\n color.rgb /= max(0.0001, color.a);\n color = clamp(color * mul + add, 0.0, 1.0);\n color.rgb *= color.a;\n\n o_color = color;\n}`,ma=()=>{if(ia.has(`m`))return ia.get(`m`);let e=new lr(ei(),pa());return ia.set(`m`,e),e},ha=(e,t)=>{let n=e.mediump;n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[5],n[5]=t[6],n[6]=t[7],n[7]=t[8],n[8]=t[10],n[9]=t[11],n[10]=t[12],n[11]=t[13],n[12]=t[15],n[13]=t[16],n[14]=t[17],n[15]=t[18],n[16]=t[4]/255,n[17]=t[9]/255,n[18]=t[14]/255,n[19]=t[19]/255},ga=(e,t)=>{let n=o.currentAttachmentObject,r=ut(e.width,e.height,!1);o.bind(r),o.reset(),o.setTransform(1,0,0,1,0,0),Nt(e),Fr();let i=ma();ha(i,t),Si(i);let a=r.texture;return H(e),qe(r,!1),n&&o.bind(n),a},_a=(e,t,n=!1)=>{Mt(2,i.TEXTURE2,t,n),Mt(1,i.TEXTURE1,null),Mt(0,i.TEXTURE0,e,n)},va=(e,t,n,r=!1)=>{Mt(2,i.TEXTURE2,n,r),Mt(1,i.TEXTURE1,t,r),Mt(0,i.TEXTURE0,e,r)},ya=()=>{Nr!==670&&(Pr(670),i.blendFunc(i.DST_ALPHA,i.ZERO))},ba=()=>{Nr!==673&&(Pr(673),i.blendFunc(i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA))},xa=e=>`\n vec2 base_scale = u_mediump[${e}].xy;\n vec2 base_offset = u_mediump[${e}].zw;\n\n vec2 uv = v_coord * base_scale - base_offset;\n vec4 base = mix(vec4(0.0), texture(u_textures[1], uv), isInside(uv));\n`,Sa=()=>`\n vec4 blur = texture(u_textures[0], v_coord);\n`,Ca=e=>`\n vec2 blur_scale = u_mediump[${e}].xy;\n vec2 blur_offset = u_mediump[${e}].zw;\n\n vec2 st = v_coord * blur_scale - blur_offset;\n vec4 blur = mix(vec4(0.0), texture(u_textures[0], st), isInside(st));\n`,wa=e=>`\n float strength = u_mediump[${Math.floor(e/4)}][${e%4}];\n blur.a = clamp(blur.a * strength, 0.0, 1.0);\n`,Ta=e=>`\n vec4 color = u_mediump[${e}];\n blur = color * blur.a;\n`,Ea=e=>`\n blur = texture(u_textures[${e?2:1}], vec2(blur.a, 0.5));\n`,Da=(e,t,n,r,i,a)=>`\n ${e?`blur.a = 1.0 - blur.a;`:``}\n ${n?wa(a):``}\n ${r?Ea(t):Ta(i)}\n`,Oa=()=>`\n vec4 blur2 = texture(u_textures[0], 1.0 - v_coord);\n`,ka=()=>`\n vec2 pq = (1.0 - v_coord) * blur_scale - blur_offset;\n vec4 blur2 = mix(vec4(0.0), texture(u_textures[0], pq), isInside(pq));\n`,Aa=e=>`\n float strength = u_mediump[${Math.floor(e/4)}][${e%4}];\n highlight_alpha *= strength;\n shadow_alpha *= strength;\n`,ja=e=>`\n vec4 highlight_color = u_mediump[${e}];\n vec4 shadow_color = u_mediump[${e+1}];\n blur = highlight_color * highlight_alpha + shadow_color * shadow_alpha;\n`,Ma=e=>`\n blur = texture(u_textures[${e?2:1}], vec2(\n 0.5019607843137255 - 0.5019607843137255 * shadow_alpha + 0.4980392156862745 * highlight_alpha,\n 0.5\n ));\n`,Na=(e,t,n,r,i,a,o,s,c)=>{let l=0,u=n?xa(l++):``,d=r?Ca(l++):Sa(),f=a===`inner`,p=l,m=l*4,h;c?h=i?Da(!1,n,s,c,p,m):Pa(n,r,s,c,p,m):i?(m+=4,h=Da(f,n,s,c,p,m)):(m+=8,h=Pa(n,r,s,c,p,m));let g;switch(a){case`outer`:g=o?`blur - blur * base.a`:`base + blur - blur * base.a`;break;case`full`:g=o?`blur`:`base - base * blur.a + blur`;break;default:g=`blur`;break}return`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_textures[${e}];\nuniform vec4 u_mediump[${t}];\n\nin vec2 v_coord;\nout vec4 o_color;\n\n${qr()}\n\nvoid main() {\n ${u}\n ${d}\n ${h}\n o_color = ${g};\n}`},Pa=(e,t,n,r,i,a)=>`\n ${t?ka():Oa()}\n float highlight_alpha = blur.a - blur2.a;\n float shadow_alpha = blur2.a - blur.a;\n ${n?Aa(a):``}\n highlight_alpha = clamp(highlight_alpha, 0.0, 1.0);\n shadow_alpha = clamp(shadow_alpha, 0.0, 1.0);\n ${r?Ma(e):ja(i)}\n`,Fa=(e,t,n,r,i,a,o)=>{let s=`f${e?`y`:`n`}${t?`y`:`n`}${n?`y`:`n`}${r}${i?`y`:`n`}${a?`y`:`n`}${o?`y`:`n`}`;if(ia.has(s))return ia.get(s);let c=1;e&&c++,o&&c++;let l=(e?4:0)+(t?4:0)+(a?1:0);o||(l+=n?4:8),l=Math.ceil(l/4);let u=new lr(ei(),Na(c,l,e,t,n,r,i,a,o));return ia.set(s,u),u},Ia=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w)=>{let T;x?(T=e.textures,T[0]=0,T[1]=1,w&&(T[2]=2)):w&&(T=e.textures,T[0]=0,T[1]=2);let E=e.mediump,D=0;x&&(E[D++]=t/r,E[D++]=n/i,E[D++]=a/r,E[D++]=(n-i-o)/i),S&&(E[D++]=t/s,E[D++]=n/c,E[D++]=l/s,E[D++]=(n-c-u)/c),w||(d?(E[D++]=p,E[D++]=m,E[D++]=h,E[D++]=g):(E[D++]=p,E[D++]=m,E[D++]=h,E[D++]=g,E[D++]=_,E[D++]=v,E[D++]=y,E[D++]=b)),C&&(E[D]=f)},La=new Map,Ra=[],za=(e,t)=>{let n=Ra.indexOf(e);for(n!==-1&&Ra.splice(n,1);La.size>=16&&Ra.length>0;){let e=Ra.shift();e&&La.delete(e)}La.set(e,t),Ra.push(e)},Ba=e=>{let t=La.get(e);if(t){let t=Ra.indexOf(e);t!==-1&&(Ra.splice(t,1),Ra.push(e))}return t},Va=(e,t,n)=>{let r=``;for(let e=1;e<t;++e){let n=e-1,i=e,a=`u_mediump[${t+Math.floor(n/4)}][${n%4}]`,o=`u_mediump[${t+Math.floor(i/4)}][${i%4}]`,s=`u_mediump[${n}]`,c=`u_mediump[${i}]`;r+=`\n if (t <= ${o}) {\n return mix(${s}, ${c}, (t - ${a}) / (${o} - ${a}));\n }\n`}let i=n?`color = pow(color, vec4(0.45454545));`:``;return`#version 300 es\nprecision mediump float;\n\nuniform vec4 u_mediump[${e}];\n\nin vec2 v_coord;\nout vec4 o_color;\n\nvec4 getGradientColor(in float t) {\n if (t <= u_mediump[${t}][0]) {\n return u_mediump[0];\n }\n ${r}\n return u_mediump[${t-1}];\n}\n\nvoid main() {\n vec4 color = getGradientColor(v_coord.x);\n ${i}\n color.rgb *= color.a;\n\n o_color = color;\n}`},Ha=(e,t)=>{let n=`l${(`00`+e).slice(-3)}${t?`y`:`n`}`,r=Ba(n);if(r)return r;let i=Math.ceil(e*5/4),a=new lr(ei(),Va(i,e,t));return za(n,a),a},Ua=(e,t,n,r,i,a)=>{let o=e.mediump,s=0;for(let e=i;e<a;e++){let t=n[e];o[s++]=(t>>16)/255,o[s++]=(t>>8&255)/255,o[s++]=(t&255)/255,o[s++]=r[e]}for(let e=i;e<a;e++)o[s++]=t[e]/255},Wa=(e,t)=>{let n=Hn();return Wn(n),i.bindBuffer(i.ARRAY_BUFFER,n.vertexBuffer),qn[0]=e,qn[2]=e,qn[4]=t,qn[6]=t,i.bufferData(i.ARRAY_BUFFER,qn,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,0,0),n},Ga,Ka=(e,t)=>(Ga?(qn[0]!==e||qn[4]!==t)&&(qn[0]=e,qn[2]=e,qn[4]=t,qn[6]=t,i.bufferSubData(i.ARRAY_BUFFER,0,qn)):Ga=Wa(e,t),Ga),qa=(e,t,n)=>{e.useProgram(),e.bindUniform(),Wn(Ka(t,n)),i.drawArrays(i.TRIANGLE_STRIP,0,4)},Ja=new Map,Ya=e=>e<=4?256:e<=8?512:1024,Xa=e=>{if(!Ja.has(e)){let t=ut(e,1,!1);Ja.set(e,t)}return Ja.get(e)},Za=()=>Xa(512),Qa=0,$a=()=>Qa,eo=e=>{Qa=Math.floor(e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)*.75)},to=new Float32Array(256),no=new Float32Array(256);for(let e=0;e<256;++e){let t=e/255;to[e]=t**2.23333333,no[e]=t}let ro=(e,t,n)=>{let r=o.currentAttachmentObject,i=Za();o.bind(i);let a=e.length;Ei();let s=$a();for(let r=0;r<a;r+=s-1){let i=Math.min(r+s,a),o=Ha(i-r,!1);Ua(o,e,t,n,r,i),qa(o,e[r]/255,e[i-1]/255)}return Fr(),r&&o.bind(r),i.texture},io=(e,t,n,r,i,a,s,c,l,u,d,f,p,m,h,g,_=null,v=null,y=null,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=0)=>{let O=o.currentAttachmentObject,k=ut(n,r,!1);o.bind(k);let A=m===`inner`,j=_!==null&&v!==null&&y!==null,M=null;if(j&&(M=ro(_,v,y)),A){o.reset(),o.setTransform(1,0,0,1,0,0),Nt(e,!0);let n=bi();xi(n,e.width,e.height),Si(n),j&&M?_a(t,M,!0):Nt(t,!0)}else j&&M?va(t,e,M,!0):yi(t,e,!0);let N=!(A||m===`full`&&h),P=!(n===l&&r===u&&d===0&&f===0),F=g!==1;A?h?ya():ba():Ei();let I=Fa(N,P,p,m,h,F,j);Ia(I,n,r,i,a,s,c,l,u,d,f,p,g,b,x,S,C,w,T,E,D,N,P,F,j),Si(I);let L=k.texture;return qe(k,!1),Fr(),O&&o.bind(O),L},ao=(e,t,n=0,r=1,i=4,a=4,s=1,c=1,l=!1,u=!1)=>{let d=o.currentAttachmentObject,f=e.width,p=e.height,m=U.x,h=U.y,g=fa(e,t,i,a,c,!1),_=g.width,v=g.height,y=U.x,b=U.y,x=l?f:_,S=l?p:v,C=y-m,w=b-h,T=io(e,g,x,S,f,p,l?0:C,l?0:w,_,v,l?-C:0,l?-w:0,!0,l?`inner`:`outer`,u,s,null,null,null,ca(n,r,!0),la(n,r,!0),ua(n,r,!0),r,0,0,0,0);return H(e),H(g),d&&o.bind(d),T},oo=Math.PI/180,so=(e,t,n=4,r=45,i=0,a=1,s=4,c=4,l=1,u=1,d=!1,f=!1,p=!1)=>{let m=o.currentAttachmentObject,h=e.width,g=e.height,_=U.x,v=U.y,y=fa(e,t,s,c,u,!1),b=y.width,x=y.height,S=U.x,C=U.y,w=S-_,T=C-v,E=Math.sqrt(t[0]*t[0]+t[1]*t[1]),D=Math.sqrt(t[2]*t[2]+t[3]*t[3]),O=N,k=r*oo,A=Math.cos(k)*n*(E/O),j=Math.sin(k)*n*(D/O),M=d?h:b+Math.max(0,Math.abs(A)-w),P=d?g:x+Math.max(0,Math.abs(j)-T),F=Math.ceil(M),I=Math.ceil(P),L=(F-M)/2,R=(I-P)/2,z=d?0:Math.max(0,w-A)+L,ee=d?0:Math.max(0,T-j)+R,te=d?A-S:(A>0?Math.max(0,A-w):0)+L,ne=d?j-C:(j>0?Math.max(0,j-T):0)+R,re=``,ie;d?(re=`inner`,ie=f||p):!f&&p?(re=`full`,ie=!0):(re=`outer`,ie=f);let ae=io(e,y,F,I,h,g,z,ee,b,x,te,ne,!0,re,ie,l,null,null,null,ca(i,a,!0),la(i,a,!0),ua(i,a,!0),a,0,0,0,0);return H(e),H(y),m&&o.bind(m),ae},co=Math.PI/180,lo=(e,t,n=4,r=45,i=16777215,a=1,s=0,c=1,l=4,u=4,d=1,f=1,p=0,m=!1)=>{let h=e.width,g=e.height,_=U.x,v=U.y,y=Math.sqrt(t[0]*t[0]+t[1]*t[1]),b=Math.sqrt(t[2]*t[2]+t[3]*t[3]),x=N,S=r*co,C=Math.cos(S)*n*(y/x),w=Math.sin(S)*n*(b/x),T=o.currentAttachmentObject,E=ut(h,g,!1);o.bind(E),o.reset(),o.setTransform(1,0,0,1,0,0),Nt(e);let D=bi();xi(D,e.width,e.height),Si(D),o.setTransform(1,0,0,1,C*2,w*2),zi(),xi(D,e.width,e.height),Si(D),Fr();let O=E.texture;T&&o.bind(T);let k=fa(O,t,l,u,f,!1);qe(E);let A=k.width,j=k.height,M=Math.ceil(A+Math.abs(C)*2),P=Math.ceil(j+Math.abs(w)*2),F=``;switch(p){case 0:F=`full`;break;case 1:F=`inner`;break;case 2:F=`outer`;break}let I=F===`inner`,L=I?h:M,R=I?g:P,z=Math.abs(C),ee=Math.abs(w),te=(A-h)/2,ne=(j-g)/2,re=I?0:z+te,ie=I?0:ee+ne,ae=io(e,k,L,R,h,g,re,ie,A,j,I?-te-C:z-C,I?-ne-w:ee-w,!1,F,m,d,null,null,null,ca(i,a,!0),la(i,a,!0),ua(i,a,!0),a,ca(s,c,!0),la(s,c,!0),ua(s,c,!0),c);return U.x=_+re,U.y=v+ie,H(e),H(k),ae},uo=Math.PI/180,fo=(e,t,n=4,r=45,i,a,s,c=4,l=4,u=1,d=1,f=0,p=!1)=>{let m=e.width,h=e.height,g=U.x,_=U.y,v=Math.sqrt(t[0]*t[0]+t[1]*t[1]),y=Math.sqrt(t[2]*t[2]+t[3]*t[3]),b=N,x=r*uo,S=Math.cos(x)*n*(v/b),C=Math.sin(x)*n*(y/b),w=o.currentAttachmentObject,T=ut(m,h,!1);o.bind(T),o.reset(),o.setTransform(1,0,0,1,0,0),Nt(e);let E=bi();xi(E,e.width,e.height),Si(E),o.setTransform(1,0,0,1,S*2,C*2),zi(),xi(E,e.width,e.height),Si(E),Fr();let D=T.texture;w&&o.bind(w);let O=fa(D,t,c,l,d,!1);qe(T);let k=O.width,A=O.height,j=Math.ceil(k+Math.abs(S)*2),M=Math.ceil(A+Math.abs(C)*2),P=``;switch(f){case 0:P=`full`;break;case 1:P=`inner`;break;case 2:P=`outer`;break}let F=P===`inner`,I=F?m:j,L=F?h:M,R=Math.abs(S),z=Math.abs(C),ee=(k-m)/2,te=(A-h)/2,ne=F?0:R+ee,re=F?0:z+te,ie=io(e,O,I,L,m,h,ne,re,k,A,F?-ee-S:R-S,F?-te-C:z-C,!1,P,p,u,s,i,a,0,0,0,0,0,0,0,0);return U.x=g+ne,U.y=_+re,H(e),H(O),ie},po=Math.PI/180,mo=(e,t,n=4,r=45,i,a,o,s=4,c=4,l=1,u=1,d=0,f=!1)=>{let p=e.width,m=e.height,h=U.x,g=U.y,_=fa(e,t,s,c,u,!1),v=_.width,y=_.height,b=U.x,x=U.y,S=b-h,C=x-g,w=Math.sqrt(t[0]*t[0]+t[1]*t[1]),T=Math.sqrt(t[2]*t[2]+t[3]*t[3]),E=N,D=r*po,O=Math.cos(D)*n*(w/E),k=Math.sin(D)*n*(T/E),A=d===1,j=A?p:v+Math.max(0,Math.abs(O)-S),M=A?m:y+Math.max(0,Math.abs(k)-C),P=Math.ceil(j),F=Math.ceil(M),I=(P-j)/2,L=(F-M)/2,R=A?0:Math.max(0,S-O)+I,z=A?0:Math.max(0,C-k)+L,ee=A?O-b:(O>0?Math.max(0,O-S):0)+I,te=A?k-x:(k>0?Math.max(0,k-C):0)+L,ne=``;switch(d){case 0:ne=`full`;break;case 1:ne=`inner`;break;case 2:ne=`outer`;break}let re=io(e,_,P,F,p,m,R,z,v,y,ee,te,!0,ne,f,l,o,i,a,0,0,0,0,0,0,0,0);return U.x=h+R,U.y=g+z,H(e),H(_),re},ho=(e,t,n,r,i)=>{let a=Math.floor(t*.5),o=Math.floor(n*.5),s=t*n,c=``,l=i?1:2;for(let e=0;e<s;++e){let t=l+Math.floor(e/4),n=e%4;c+=`\n result += getWeightedColor(${e}, u_mediump[${t}][${n}]);\n`}let u=r?`result.a = texture(u_texture, v_coord).a;`:``,d=i?``:`\n vec4 substitute_color = u_mediump[1];\n color = mix(substitute_color, color, isInside(uv));\n`;return`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_mediump[${e}];\n\nin vec2 v_coord;\nout vec4 o_color;\n\n${qr()}\n\nvec4 getWeightedColor (in int i, in float weight) {\n vec2 rcp_size = u_mediump[0].xy;\n\n int i_div_x = i / ${t};\n int i_mod_x = i - ${t} * i_div_x;\n vec2 offset = vec2(i_mod_x - ${a}, ${o} - i_div_x);\n vec2 uv = v_coord + offset * rcp_size;\n\n vec4 color = texture(u_texture, uv);\n color.rgb /= max(0.0001, color.a);\n ${d}\n\n return color * weight;\n}\n\nvoid main() {\n float rcp_divisor = u_mediump[0].z;\n float bias = u_mediump[0].w;\n\n vec4 result = vec4(0.0);\n ${c}\n result = clamp(result * rcp_divisor + bias, 0.0, 1.0);\n ${u}\n\n result.rgb *= result.a;\n o_color = result;\n}`},go=(e,t,n,r)=>{let i=`c${(`0`+e).slice(-2)}${(`0`+t).slice(-2)}${n?`y`:`n`}${r?`y`:`n`}`;if(ia.has(i))return ia.get(i);let a=(r?1:2)+Math.ceil(e*t/4),o=new lr(ei(),ho(a,e,t,n,r));return ia.set(i,o),o},_o=(e,t,n,r,i,a,o,s,c,l,u)=>{let d=e.mediump;d[0]=1/t,d[1]=1/n,d[2]=1/i,d[3]=a/255;let f=4;o||(d[f++]=s,d[f++]=c,d[f++]=l,d[f++]=u);let p=r.length;for(let e=0;e<p;e++)d[f++]=r[e]},vo=(e,t=0,n=0,r,i=1,a=0,s=!0,c=!0,l=0,u=0)=>{let d=o.currentAttachmentObject,f=e.width,p=e.height,m=ut(f,p,!1);o.bind(m),o.reset(),o.setTransform(1,0,0,1,0,0),Nt(e,!0),Fr();let h=go(t,n,s,c);_o(h,f,p,r,i,a,c,ca(l,u,!1),la(l,u,!1),ua(l,u,!1),u),Si(h);let g=m.texture;return H(e),qe(m,!1),d&&o.bind(d),g},yo=(e,t,n,r)=>{let i,a,o;switch(t){case 1:i=`map_color.r`;break;case 2:i=`map_color.g`;break;case 4:i=`map_color.b`;break;case 8:i=`map_color.a`;break;default:i=`0.5`;break}switch(n){case 1:a=`map_color.r`;break;case 2:a=`map_color.g`;break;case 4:a=`map_color.b`;break;case 8:a=`map_color.a`;break;default:a=`0.5`;break}switch(r){case 0:o=`\n vec4 source_color = texture(u_textures[0], uv);\n`;break;case 3:o=`\n vec4 source_color =texture(u_textures[0], mix(v_coord, uv, step(abs(uv - vec2(0.5)), vec2(0.5))));\n`;break;case 1:o=`\n vec4 substitute_color = u_mediump[2];\n vec4 source_color = mix(substitute_color, texture(u_textures[0], uv), isInside(uv));\n`;break;default:o=`\n vec4 source_color = texture(u_textures[0], fract(uv));\n`;break}return`#version 300 es\nprecision mediump float;\n\nuniform sampler2D u_textures[2];\nuniform vec4 u_mediump[${e}];\n\nin vec2 v_coord;\nout vec4 o_color;\n\n${qr()}\n\nvoid main() {\n vec2 uv_to_st_scale = u_mediump[0].xy;\n vec2 uv_to_st_offset = u_mediump[0].zw;\n vec2 scale = u_mediump[1].xy;\n\n vec2 st = v_coord * uv_to_st_scale - uv_to_st_offset;\n vec4 map_color = texture(u_textures[1], st);\n\n vec2 offset = vec2(${i}, ${a}) - 0.5;\n vec2 uv = v_coord + offset * scale;\n ${o}\n\n o_color = mix(texture(u_textures[0], v_coord), source_color, isInside(st));\n}`},bo=(e,t,n)=>{let r=`d${e}${t}${n}`;if(ia.has(r))return ia.get(r);let i=n===1?3:2,a=new lr(ei(),yo(i,e,t,n));return ia.set(r,a),a},xo=(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>{let m=e.textures;m[0]=0,m[1]=1;let h=e.mediump;h[0]=r/t,h[1]=i/n,h[2]=a/t,h[3]=(i-n-o)/n,h[4]=s/r,h[5]=-c/i,l===1&&(h[8]=u,h[9]=d,h[10]=f,h[11]=p)},So=(e,t,n=0,r=0,i=0,a=0,s=0,c=0,l=0,u=0,d=2,f=0,p=0)=>{let m=o.currentAttachmentObject,h=e.width,g=e.height,_=ut(h,g,!1);o.bind(_);let v=Yi(n,r,t);yi(e,v);let y=bo(s,c,d);xo(y,n,r,n,r,i,a,l,u,d,ca(f,p,!0),la(f,p,!0),ua(f,p,!0),p),Fr(),Si(y);let b=_.texture;return m&&o.bind(m),H(e),H(v),qe(_,!1),b},Co=(e,t,n,r)=>{let i=e.highp,a=o.$matrix;i[0]=a[0],i[1]=a[1],i[2]=a[3],i[3]=a[4],i[4]=a[6],i[5]=a[7],i[6]=n,i[7]=r,i[8]=k,i[9]=A;let s=e.mediump;s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=t[4],s[5]=t[5],s[6]=t[6],s[7]=t[7]},wo=(e,t,n,r)=>{let i=o.currentAttachmentObject,a=e.width,s=e.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,n,r);let i=ki(!0);Co(i,t,a,s),Nt(e),Bi(o.globalCompositeOperation),Si(i)}break;default:{let i=Ti(n,r,a,s),c=ut(a,s,!1);o.bind(c),yi(i,e);let l=gi(o.globalCompositeOperation,!0);Oi(l,t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]),Si(l),o.bind(o.$mainAttachmentObject),o.reset(),o.setTransform(1,0,0,1,n,r),Di(c.texture),H(i),qe(c)}break}i&&o.bind(i),Fr()},To=[],Eo=e=>{e.size&&e.clear(),To.push(e)},Do=()=>To.pop()||new Map,Oo=(e,t,n)=>{n.clear(),e.$timerId!==null&&clearTimeout(e.$timerId);for(let n of t.values()){for(let t of n.values())t&&e.destroy(t);Eo(n)}t.clear()},ko=(e,t)=>{if(!(!t||typeof t!=`object`)&&`canvas`in t){let n=t.canvas,r=n.width,i=n.height;t.clearRect(0,0,r+1,i+1),n.width=n.height=1,e.push(n)}},Ao=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.has(n)&&(r.delete(n),r.size||(Eo(r),e.delete(t)))},jo=(e,t,n)=>{if(!t.has(n))return;let r=t.get(n);for(let t of r.values())e.destroy(t);t.delete(n),Eo(r)},Mo=(e,t,n)=>{let r=e.get(t)||null;return r?(r.delete(`trash`),r.get(n)||null):null},No=(e,t,n,r,i=null)=>{t.has(n)||t.set(n,Do());let a=t.get(n);if(i===null){if(!a.has(r))return;e.destroy(a.get(r)),a.delete(r),a.size||(t.delete(n),Eo(a));return}a.set(r,i)},Po=(e,t,n=``)=>n?e.has(t)?e.get(t).has(n):!1:e.has(t),Fo=(e,t,n)=>{let r=2166136261,i=e*100|0;return r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619),i=t*100|0,r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619),n&&(i=n*100|0,r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619)),(r>>>0)%16777216},Io=(e,t,n,r)=>{let i=2166136261,a=e*100|0;return i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=t*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=n*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=r*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),(i>>>0)%16777216},Lo=(e,t,n,r)=>{if(n.has(r))return;let i=t.get(r);i&&(i.set(`trash`,!0),n.set(r,i),e.$timerId!==null&&clearTimeout(e.$timerId),e.$removeCache=!1,e.$timerId=setTimeout(()=>{e.$removeCache=!0,e.$timerId=null},1e3))},Ro=(e,t)=>{if(t.size){for(let[n,r]of t)r.has(`trash`)&&(e.removeById(n),e.$removeIds.push(+n));t.clear(),e.$removeCache=!1}},W=new class{_$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(){Oo(this,this._$store,this._$trash)}destroy(e=null){ko(this._$pool,e)}getCanvas(){return this._$pool.pop()||document.createElement(`canvas`)}remove(e,t){Ao(this._$store,e,t)}removeTimer(e){Lo(this,this._$store,this._$trash,e)}removeTimerScheduledCache(){Ro(this,this._$trash)}removeById(e){jo(this,this._$store,e)}getById(e){return this._$store.get(e)}get(e,t){return Mo(this._$store,e,t)}set(e,t,n=null){No(this,this._$store,e,t,n)}has(e,t=``){return Po(this._$store,e,t)}generateKeys(e,t,n){return Fo(e,t,n)}generateFilterKeys(e,t,n,r){return Io(e,t,n,r)}},zo=new Float32Array(20),Bo=(e,t,n,r,i,a,s,c,l,u,d)=>{let f=o.currentAttachmentObject,p=null,m=Math.sqrt(s[0]*s[0]+s[1]*s[1]),h=Math.sqrt(s[2]*s[2]+s[3]*s[3]),g=W.generateFilterKeys(s[0],s[1],s[2],s[3]),_=!1;if(W.get(t,`fKey`)===g){let e=W.get(t,`fTexture`);n?H(e):(_=!0,p=e)}let v=0,y=0;if(_)v=W.get(t,`offsetX`),y=W.get(t,`offsetY`);else{p=vi(e);let t=Math.atan2(s[1],s[0]),n=Math.atan2(-s[2],s[3]),c=E(a?m*Math.cos(t):Math.cos(t),a?m*Math.sin(t):Math.sin(t),a?-h*Math.sin(n):-Math.sin(n),a?h*Math.cos(n):Math.cos(n),r/2,i/2),l=E(1,0,0,1,-e.w/2,-e.h/2),u=F(c,l);if(D(c),D(l),u[0]!==1||u[1]!==0||u[2]!==0||u[3]!==1){let e=ut(r,i,!1);o.bind(e),o.reset(),o.setTransform(u[0],u[1],u[2],u[3],u[4],u[5]),v=u[4],y=u[5],Nt(p);let t=ki();Ai(t,p.width,p.height),Si(t),H(p),p=e.texture,qe(e,!1),f&&o.bind(f)}D(u),U.x=0,U.y=0;for(let e=0;d.length>e;)switch(d[e++]){case 0:p=lo(p,s,d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],!!d[e++]);break;case 1:p=fa(p,s,d[e++],d[e++],d[e++]);break;case 2:for(let t=0;t<20;++t)zo[t]=d[e++];p=ga(p,zo);break;case 3:{let t=d[e++],n=d[e++],r=t*n,i=d.subarray(e,e+r);e+=r,p=vo(p,t,n,i,d[e++],d[e++],!!d[e++],!!d[e++],d[e++],d[e++])}break;case 4:{let t=d[e++],n=new Uint8Array(t);n.set(d.subarray(e,e+t)),e+=t,p=So(p,n,d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++])}break;case 5:p=so(p,s,d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],!!d[e++],!!d[e++],!!d[e++]);break;case 6:p=ao(p,s,d[e++],d[e++],d[e++],d[e++],d[e++],d[e++],!!d[e++],!!d[e++]);break;case 7:{let t=d[e++],n=d[e++],r=d[e++],i=d.subarray(e,e+r);e+=r,r=d[e++];let a=d.subarray(e,e+r);e+=r,r=d[e++];let o=d.subarray(e,e+r);e+=r,p=fo(p,s,t,n,i,a,o,d[e++],d[e++],d[e++],d[e++],d[e++],!!d[e++])}break;case 8:{let t=d[e++],n=d[e++],r=d[e++],i=d.subarray(e,e+r);e+=r,r=d[e++];let a=d.subarray(e,e+r);e+=r,r=d[e++];let o=d.subarray(e,e+r);e+=r,p=mo(p,s,t,n,i,a,o,d[e++],d[e++],d[e++],d[e++],d[e++],!!d[e++])}break}}if(p){let e=N,t=u[0]*(m/e),n=u[1]*(h/e);o.reset(),o.setTransform(1,0,0,1,0,0),o.globalCompositeOperation=l,wo(p,c,-v+t+s[4],-y+n+s[5])}_||(W.set(t,`fKey`,g),W.set(t,`fTexture`,p),W.set(t,`offsetX`,v),W.set(t,`offsetY`,y)),f&&o.bind(f)},Vo=[],Ho=(e,t)=>{o.drawArraysInstanced();let n=o.$mainAttachmentObject;Vo.push(n);let r=ut(e,t,!1);o.$mainAttachmentObject=r,o.bind(r)},Uo=new Float32Array(20),Wo=(e,t,n,r,i,a,s,c)=>{o.drawArraysInstanced();let l=o.$mainAttachmentObject,u=null;if(r&&i&&a){u=Ti(0,0,l.width,l.height),o.$mainAttachmentObject=Vo.pop(),qe(l),o.bind(o.$mainAttachmentObject),U.x=0,U.y=0;for(let e=0;a.length>e;)switch(a[e++]){case 0:u=lo(u,t,a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],!!a[e++]);break;case 1:u=fa(u,t,a[e++],a[e++],a[e++]);break;case 2:for(let t=0;t<20;++t)Uo[t]=a[e++];u=ga(u,Uo);break;case 3:{let t=a[e++],n=a[e++],r=t*n,i=a.subarray(e,e+r);e+=r,u=vo(u,t,n,i,a[e++],a[e++],!!a[e++],!!a[e++],a[e++],a[e++])}break;case 4:{let t=a[e++],n=new Uint8Array(t);n.set(a.subarray(e,e+t)),e+=t,u=So(u,n,a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++])}break;case 5:u=so(u,t,a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],!!a[e++],!!a[e++],!!a[e++]);break;case 6:u=ao(u,t,a[e++],a[e++],a[e++],a[e++],a[e++],a[e++],!!a[e++],!!a[e++]);break;case 7:{let n=a[e++],r=a[e++],i=a[e++],o=a.subarray(e,e+i);e+=i,i=a[e++];let s=a.subarray(e,e+i);e+=i,i=a[e++];let c=a.subarray(e,e+i);e+=i,u=fo(u,t,n,r,o,s,c,a[e++],a[e++],a[e++],a[e++],a[e++],!!a[e++])}break;case 8:{let n=a[e++],r=a[e++],i=a[e++],o=a.subarray(e,e+i);e+=i,i=a[e++];let s=a.subarray(e,e+i);e+=i,i=a[e++];let c=a.subarray(e,e+i);e+=i,u=mo(u,t,n,r,o,s,c,a[e++],a[e++],a[e++],a[e++],a[e++],!!a[e++])}break}if(s&&(W.set(s,`fKey`,c),W.set(s,`fTexture`,u)),u){let r=Math.sqrt(t[0]*t[0]+t[1]*t[1]),a=Math.sqrt(t[2]*t[2]+t[3]*t[3]),s=N,c=i[0]*(r/s),l=i[1]*(a/s);o.reset(),o.globalCompositeOperation=e,wo(u,n,c+t[4],l+t[5])}}else u=Ti(0,0,l.width,l.height),o.$mainAttachmentObject=Vo.pop(),qe(l),o.bind(o.$mainAttachmentObject),u&&(o.reset(),o.globalCompositeOperation=e,wo(u,n,t[4],t[5]),H(u));o.bind(o.$mainAttachmentObject)},Go=new Float32Array([1,1,1,1,0,0,0,0]),Ko=e=>{o.drawArraysInstanced();let t=o.$mainAttachmentObject,n=t.texture;if(o.$mainAttachmentObject=Vo.pop(),qe(t,!1),n){let t=bt();o.bind(t),o.beginNodeRendering(e),Bi(`normal`);let r=t.height-e.y-e.h;o.setTransform(1,0,0,1,e.x,r);let i=ki(!1);Co(i,Go,e.w,e.h),Nt(n),Si(i),o.endNodeRendering(),H(n)}o.bind(o.$mainAttachmentObject)},qo=(e,t,n,r,i,a)=>{if(W.get(i,`fKey`)!==a)return;let s=W.get(i,`fTexture`);if(!s)return;let c=Math.sqrt(t[0]*t[0]+t[1]*t[1]),l=Math.sqrt(t[2]*t[2]+t[3]*t[3]),u=N,d=r[0]*(c/u),f=r[1]*(l/u);o.drawArraysInstanced(),o.reset(),o.globalCompositeOperation=e,wo(s,n,d+t[4],f+t[5])},Jo=e=>{let t=Tt(e.index),n=t[0],r=t[1],i=t[2],a=t[3];t[0]=Math.min(e.x,n),t[1]=Math.min(e.y,r),t[2]=Math.max(e.x+e.w+1,i),t[3]=Math.max(e.y+e.h+1,a)},Yo=e=>{let t=`s${e?`y`:`n`}`;if(ur.has(t))return ur.get(t);let n=new lr(Sr(e?9:0,!1,!1,e),wr());return ur.set(t,n),n},Xo=(e,t)=>{let n=e.highp;n[0]=t[0],n[1]=t[1],n[2]=0,n[4]=t[2],n[5]=t[3],n[6]=0,n[8]=t[4],n[9]=t[5],n[10]=1,n[12]=t[6],n[13]=t[7],n[14]=0,n[16]=t[8],n[17]=t[9],n[18]=0,n[20]=t[10],n[21]=t[11],n[22]=1,n[3]=k,n[7]=A,n[11]=t[12],n[15]=t[13],n[19]=t[14],n[23]=t[15],n[24]=t[16],n[25]=t[17],n[26]=t[18],n[27]=t[19],n[28]=t[20],n[29]=t[21],n[30]=t[22],n[31]=t[23],n[32]=t[24],n[33]=t[25]},Zo=0,Qo=e=>{Zo=e},$o=()=>{Zo=0},es=!0,ts=e=>{es=e},ns=!1,rs=e=>{ns=e},is=()=>{Zo!==1&&(Qo(1),i.stencilFunc(i.ALWAYS,0,255),i.stencilOpSeparate(i.FRONT,i.KEEP,i.KEEP,i.INCR_WRAP),i.stencilOpSeparate(i.BACK,i.KEEP,i.KEEP,i.DECR_WRAP)),es&&(ts(!1),i.colorMask(!1,!1,!1,!1))},as=()=>{Zo!==2&&(Qo(2),i.stencilFunc(i.NOTEQUAL,0,255),i.stencilOp(i.KEEP,i.ZERO,i.ZERO)),es||(ts(!0),i.colorMask(!0,!0,!0,!0))},os=()=>{ns||(rs(!0),i.enable(i.SAMPLE_ALPHA_TO_COVERAGE))},ss=()=>{ns&&(rs(!1),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE))},cs=(e,t,n,r)=>{is();let i=!!r,a=kr(i);r&&Ar(a,r),os(),Ir(a,e,t,n),ss(),as();let o=Yo(i);r&&Xo(o,r),Ir(o,e,t,n)},ls=(e,t,n,r,i)=>{let a=e.mediump,o=0;for(let e=n;e<r;++e){let n=e*5;a[o++]=i[t[n+1]],a[o++]=i[t[n+2]],a[o++]=i[t[n+3]],a[o++]=i[t[n+4]]}for(let e=n;e<r;++e)a[o++]=t[e*5]},us=(e,t)=>{let n=o.currentAttachmentObject,r=i.getParameter(i.SCISSOR_BOX);u();let a=t===0,s=e.length/5,c=Xa(Ya(s));o.bind(c);let d=a?to:no;Ei();let f=$a();for(let t=0;t<s;t+=f-1){let n=Math.min(t+f,s),r=Ha(n-t,a);ls(r,e,t,n,d),qa(r,e[0],e[e.length-5])}return Fr(),n&&o.bind(n),l(),i.scissor(r[0],r[1],r[2],r[3]),c.texture},ds=new Map,fs=(e,t,n,r)=>`${e?`y`:`n`}${t?`y`:`n`}${t&&n?`y`:`n`}${`${r}`}`,ps=e=>`\n vec2 focal = vec2(u_highp[${e}][1], 0.0);\n\n vec2 diff = coord - focal;\n float lenDiff = length(diff);\n vec2 dir = diff / lenDiff;\n float b = 2.0 * dot(dir, focal);\n float c = dot(focal, focal) - 1.0;\n float x = (-b + sqrt(max(b * b - 4.0 * c, 0.0))) * 0.5;\n\n float t = lenDiff / abs(x);`,ms=()=>`float t = length(coord);`,hs=(e,t)=>`\n float radius = u_highp[${e}][0];\n vec2 coord = p / radius;\n ${t?ps(e):ms()}\n`,gs=e=>`\n vec2 a = u_highp[${e}].xy;\n vec2 b = u_highp[${e}].zw;\n\n vec2 ab = b - a;\n vec2 ap = p - a;\n\n float t = dot(ab, ap) / dot(ab, ab);`,_s=(e,t,n,r,i)=>{let a=n?hs(t,r):gs(t),o;switch(i){case 0:o=`1.0 - abs(fract(t * 0.5) * 2.0 - 1.0)`;break;case 1:o=`fract(t)`;break;default:o=`clamp(t, 0.0, 1.0)`;break}return`#version 300 es\nprecision highp float;\n\nuniform sampler2D u_texture;\nuniform vec4 u_highp[${e}];\n\nin vec2 v_uv;\nout vec4 o_color;\n\nvoid main() {\n vec2 p = v_uv;\n ${a}\n t = ${o};\n o_color = texture(u_texture, vec2(t, 0.5));\n}`},vs=(e,t,n,r)=>{let i=fs(r,e,t,n);if(ds.has(i))return ds.get(i);let a=(r?14:5)+1,o=a-1,s=new lr(Sr(a,!0,!1,r),_s(a,o,e,t,n));return ds.set(i,s),s},ys=(e,t,n,r,i=0,a=null,o=null)=>{let s=e.highp;s[0]=n[0],s[1]=n[1],s[2]=n[2],s[4]=n[3],s[5]=n[4],s[6]=n[5],s[8]=n[6],s[9]=n[7],s[10]=n[8],s[12]=r[0],s[13]=r[1],s[14]=r[2],s[16]=r[3],s[17]=r[4],s[18]=r[5],s[11]=r[6],s[15]=r[7],s[19]=r[8],s[3]=k,s[7]=A;let c=20;o&&(s[20]=o[0],s[21]=o[1],s[22]=0,s[24]=o[2],s[25]=o[3],s[26]=0,s[28]=o[4],s[29]=o[5],s[30]=1,s[32]=o[6],s[33]=o[7],s[34]=0,s[36]=o[8],s[37]=o[9],s[38]=0,s[40]=o[10],s[41]=o[11],s[42]=1,s[31]=o[12],s[35]=o[13],s[39]=o[14],s[43]=o[15],s[44]=o[16],s[45]=o[17],s[46]=o[18],s[47]=o[19],s[48]=o[20],s[49]=o[21],s[50]=o[22],s[51]=o[23],s[52]=o[24],s[53]=o[25],c=56),t===0?(s[c++]=a[0],s[c++]=a[1],s[c++]=a[2],s[c]=a[3]):(s[c++]=819.2,s[c]=m(i,-.975,.975,0))},bs=()=>{$o(),ts(!0),rs(!1)},xs=(e,t,n,r)=>{let a=fn.shift(),s=fn.shift(),c=fn.shift(),l=fn.shift();bs(),p(),Nt(us(a,l)),f(),i.stencilMask(255),is();let u=!!r,d=kr(u);r&&Ar(d,r),os(),Ir(d,e,t,n),ss(),as();let m=vs(!1,!1,c,u),h=M(s),g=O(o.$matrix);ys(m,0,o.$matrix,g,0,h,r),x(h),D(g),Ir(m,e,t,n)},Ss=(e,t,n,r)=>{let a=fn.shift(),s=fn.shift(),c=fn.shift(),l=fn.shift(),u=fn.shift();bs(),p(),Nt(us(a,l)),f(),i.stencilMask(255),is();let d=!!r,m=kr(d);r&&Ar(m,r),os(),Ir(m,e,t,n),ss(),as(),o.save(),o.transform(s[0],s[1],s[2],s[3],s[4],s[5]);let h=o.$stack[o.$stack.length-1],g=O(o.$matrix),_=vs(!0,!!u,c,d);ys(_,1,h,g,u,r),o.restore(),D(g),Ir(_,e,t,n)},Cs=new Map,ws=(e,t)=>{let n=`b${e?`y`:`n`}${t?`y`:`n`}`;if(Cs.has(n))return Cs.get(n);let r=e?Er():Tr(),i=new lr(Sr(t?14:5,!0,!1,t),r);return Cs.set(n,i),i},Ts=(e,t,n,r)=>{let i=e.highp,a=o.$stack[o.$stack.length-1];i[0]=a[0],i[1]=a[1],i[2]=a[2],i[4]=a[3],i[5]=a[4],i[6]=a[5],i[8]=a[6],i[9]=a[7],i[10]=a[8];let s=O(o.$matrix);i[12]=s[0],i[13]=s[1],i[14]=s[2],i[16]=s[3],i[17]=s[4],i[18]=s[5],i[11]=s[6],i[15]=s[7],i[19]=s[8],i[3]=k,i[7]=A,r&&(i[20]=r[0],i[21]=r[1],i[22]=0,i[24]=r[2],i[25]=r[3],i[26]=0,i[28]=r[4],i[29]=r[5],i[30]=1,i[32]=r[6],i[33]=r[7],i[34]=0,i[36]=r[8],i[37]=r[9],i[38]=0,i[40]=r[10],i[41]=r[11],i[42]=1,i[31]=r[12],i[35]=r[13],i[39]=r[14],i[43]=r[15],i[44]=r[16],i[45]=r[17],i[46]=r[18],i[47]=r[19],i[48]=r[20],i[49]=r[21],i[50]=r[22],i[51]=r[23],i[52]=r[24],i[53]=r[25]);let c=e.mediump;c[0]=t,c[1]=n},Es=(e,t,n,r)=>{is();let i=!!r,a=kr(i);r&&Ar(a,r),os(),Ir(a,e,t,n),ss();let s=$i.shift(),c=$i.shift(),l=$i.shift(),u=$i.shift(),d=$i.shift(),f=Yi(l,u,s,$i.shift());o.save(),o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),as();let p=ws(d,i);Ts(p,l,u,r),Ir(p,e,t,n),o.restore(),H(f)},Ds=()=>{let e=tr();f(),i.stencilMask(255),bs();let t=0,n=null;for(let r=0;r<on.length;r++)switch(zn.has(r)&&(n=zn.get(r)),on[r]){case`fill`:{let r=an.shift();cs(e,t,r,n),t+=r}break;case`linear`:{let r=an.shift();xs(e,t,r,n),t+=r}break;case`radial`:{let r=an.shift();Ss(e,t,r,n),t+=r}break;case`bitmap`:{let r=an.shift();Es(e,t,r,n),t+=r}break}p(),bs(),nr(e),sn(),Bn()},Os=0,ks=new Float32Array(256);for(let e=1;e<256;e++)ks[e]=255/e;let As=async(e,t)=>{let n=wi(0,0,e,t);Nt(n),i.bindFramebuffer(i.FRAMEBUFFER,We),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,n.resource,0);let r=new Uint8Array(e*t*4),a=o.$mainAttachmentObject;r.byteLength>Os&&(Os=v(r.byteLength),i.bufferData(i.PIXEL_PACK_BUFFER,Os,i.STREAM_READ)),i.readPixels(0,a.height-t,e,t,i.RGBA,i.UNSIGNED_BYTE,0);let s=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);await new Promise(e=>{let t=()=>{if(i.clientWaitSync(s,i.SYNC_FLUSH_COMMANDS_BIT,0)===i.TIMEOUT_EXPIRED){requestAnimationFrame(t);return}return i.deleteSync(s),i.getBufferSubData(i.PIXEL_PACK_BUFFER,0,r),e()};t()}),i.bindFramebuffer(i.FRAMEBUFFER,Me);for(let e=0;e<r.length;e+=4){let t=r[e+3];if(t===0||t===255)continue;let n=ks[t];r[e]=Math.min(255,Math.round(r[e]*n)),r[e+1]=Math.min(255,Math.round(r[e+1]*n)),r[e+2]=Math.min(255,Math.round(r[e+2]*n))}return await createImageBitmap(new ImageData(new Uint8ClampedArray(r),e,t),{imageOrientation:`flipY`,premultiplyAlpha:`none`,colorSpaceConversion:`none`})};var js=class{$stack;$matrix;$clearColorR;$clearColorG;$clearColorB;$clearColorA;$mainAttachmentObject;$stackAttachmentObject;globalAlpha;globalCompositeOperation;imageSmoothingEnabled;$fillStyle;$strokeStyle;maskBounds;thickness;caps;joints;miterLimit;newDrawState=!1;_pendingAtlasNodes=[];constructor(e,n,i=1){a(e),t(e.getParameter(e.MAX_TEXTURE_SIZE)),r(n),P(i),this.$stack=g(),this.$stackAttachmentObject=g(),this.$matrix=C(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},e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!0),e.clearColor(0,0,0,0),e.frontFace(e.CCW),Ne(e),Fe(e),Le(e,Ct()),Ke(e),Ui(e),Gi(),eo(e),s(this)}clearTransferBounds(){Et()}updateBackgroundColor(e,t,n,r){we(this,e,t,n,r)}fillBackgroundColor(){Te(this.$clearColorR,this.$clearColorG,this.$clearColorB,this.$clearColorA)}resize(e,t,n=!0){At(this,e,t,n)}clearRect(e,t,n,r){jt(e,t,n,r)}bind(e){Ht(this,e)}save(){Ut(this)}restore(){Wt(this)}setTransform(e,t,n,r,i,a){Gt(this.$matrix,e,t,n,r,i,a)}transform(e,t,n,r,i,a){Kt(this,e,t,n,r,i,a)}reset(){qt(this)}beginPath(){Jt(this),ee()}moveTo(e,t){ie(e,t)}lineTo(e,t){ae(e,t)}quadraticCurveTo(e,t,n,r){oe(e,t,n,r)}fillStyle(e,t,n,r){this.$fillStyle[0]=e,this.$fillStyle[1]=t,this.$fillStyle[2]=n,this.$fillStyle[3]=r}strokeStyle(e,t,n,r){this.$strokeStyle[0]=e,this.$strokeStyle[1]=t,this.$strokeStyle[2]=n,this.$strokeStyle[3]=r}closePath(){se()}arc(e,t,n){Ce(e,t,n)}bezierCurveTo(e,t,n,r,i,a){Se(e,t,n,r,i,a)}fill(){dn(`fill`)}gradientFill(e,t,n,r,i,a){pn(e,t,n,r,i,a)}bitmapFill(e,t,n,r,i,a){ea(e,t,n,r,i,a)}stroke(){na()}gradientStroke(e,t,n,r,i,a){Rn(e,t,n,r,i,a)}bitmapStroke(e,t,n,r,i,a){ta(e,t,n,r,i,a)}clip(){zr()}get currentAttachmentObject(){return Re}get atlasAttachmentObject(){return bt()}createNode(e,t){return Gr(e,t)}removeNode(e){Kr(e)}beginNodeRendering(e){this.newDrawState=!0,Jo(e),Yt(e.x,e.y,e.w,e.h)}endNodeRendering(){Xt()}drawFill(){Ds()}drawDisplayObject(e,t,n,r,i,a){Jo(e),ji(e,t,n,r,i,a)}drawArraysInstanced(){Vi()}clearArraysInstanced(){Mi()}transferMainCanvas(){Wi()}drawPixels(e,t){Xi(e,t)}drawElement(e,t,n=!1){Qi(e,t)}beginMask(){Ki()}setMaskBounds(e,t,n,r){qi(e,t,n,r)}endMask(){Ft()}leaveMask(){this.drawArraysInstanced(),Ji()}useGrid(e){Vn(e)}applyFilter(e,t,n,r,i,a,o,s,c,l,u){this.drawArraysInstanced(),Bo(e,t,n,r,i,a,o,s,c,l,u)}containerBeginLayer(e,t){this.drawArraysInstanced(),Ho(e,t)}containerEndLayer(e,t,n,r,i,a,o,s){Wo(e,t,n,r,i,a,o,s)}containerBeginAtlasNode(e,t){this.drawArraysInstanced();let n=Gr(e,t);return this._pendingAtlasNodes.push(n),Ho(e,t),n}containerEndAtlasNode(){Ko(this._pendingAtlasNodes.pop())}containerDrawCachedFilter(e,t,n,r,i,a){qo(e,t,n,r,i,a)}async createImageBitmap(e,t){return await As(e,t)}},Ms=class e{static device=null;static devicePixelRatio=1;static renderMaxSize=8192;static float32Array4Pool=[];static setDevice(t){e.device=t}static getDevice(){if(!e.device)throw Error(`GPUDevice is not initialized`);return e.device}static setDevicePixelRatio(t){e.devicePixelRatio=t}static getDevicePixelRatio(){return e.devicePixelRatio}static setRenderMaxSize(t){e.renderMaxSize=t}static getRenderMaxSize(){return e.renderMaxSize}static createFloat32Array(e){return new Float32Array(e)}static createArray(){return[]}static getFloat32Array4(){return e.float32Array4Pool.length>0?e.float32Array4Pool.pop():new Float32Array(4)}static poolFloat32Array4(t){t.length===4&&e.float32Array4Pool.push(t)}};let Ns=null,Ps=e=>{Ns=e},Fs=()=>Ms.getFloat32Array4(),Is=e=>{Ms.poolFloat32Array4(e)},Ls=(e,t,n,r)=>{let i=r.x-e.x,a=r.y-e.y,o=i*i+a*a;if(o<1e-10){let r=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y),i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y);return Math.max(r,i)}let s=(t.x-e.x)*a-(t.y-e.y)*i,c=s*s/o,l=(n.x-e.x)*a-(n.y-e.y)*i,u=l*l/o;return Math.max(c,u)},Rs=(e,t,n,r)=>{let i={x:(e.x+t.x)*.5,y:(e.y+t.y)*.5},a={x:(t.x+n.x)*.5,y:(t.y+n.y)*.5},o={x:(n.x+r.x)*.5,y:(n.y+r.y)*.5},s={x:(i.x+a.x)*.5,y:(i.y+a.y)*.5},c={x:(a.x+o.x)*.5,y:(a.y+o.y)*.5},l={x:(s.x+c.x)*.5,y:(s.y+c.y)*.5};return{first:[e,i,s,l],second:[l,c,o,r]}},zs=(e,t,n,r,i=.25)=>{let a=[],o=(e,t,n,r,s)=>{if(Ls(e,t,n,r)<=i||s>=8){let e={x:(t.x+n.x)*.5,y:(t.y+n.y)*.5};a.push({ctrl:e,end:r});return}let c=Rs(e,t,n,r);o(c.first[0],c.first[1],c.first[2],c.first[3],s+1),o(c.second[0],c.second[1],c.second[2],c.second[3],s+1)};return o(e,t,n,r,0),a};var Bs=class{$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,t){this.$currentPath.length>=6&&this.$vertices.push(this.$currentPath),this.$currentPath=[e,t,!1],this.$currentX=e,this.$currentY=t,this.$startX=e,this.$startY=t}lineTo(e,t){e===this.$currentX&&t===this.$currentY||(this.$currentPath.push(e,t,!1),this.$currentX=e,this.$currentY=t)}quadraticCurveTo(e,t,n,r){this.$currentPath.push(e,t,!0),this.$currentPath.push(n,r,!1),this.$currentX=n,this.$currentY=r}$flatnessThreshold=.25;bezierCurveTo(e,t,n,r,i,a){let o=zs({x:this.$currentX,y:this.$currentY},{x:e,y:t},{x:n,y:r},{x:i,y:a},this.$flatnessThreshold);for(let e of o)this.$currentPath.push(e.ctrl.x,e.ctrl.y,!0),this.$currentPath.push(e.end.x,e.end.y,!1);this.$currentX=i,this.$currentY=a}arc(e,t,n){let r=n,i=n*.5522847498307936;this.bezierCurveTo(e+r,t+i,e+i,t+r,e,t+r),this.bezierCurveTo(e-i,t+r,e-r,t+i,e-r,t),this.bezierCurveTo(e-r,t-i,e-i,t-r,e,t-r),this.bezierCurveTo(e+i,t-r,e+r,t-i,e+r,t);let a=this.$currentPath.length;a>=3&&(this.$currentPath[a-3]=this.$startX,this.$currentPath[a-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(){let e=[...this.$vertices];return this.$currentPath.length>=9&&e.push(this.$currentPath),e}getVerticesForStroke(){let 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}};let Vs=(e,t,n,r)=>new Float32Array([e,t,0,0,e+n,t,1,0,e,t+r,0,1,e+n,t,1,0,e+n,t+r,1,1,e,t+r,0,1]),Hs=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1),Us=(e,t,n,r)=>{let i=Hs(n),a=t.get(i),o;return a&&a.length>0?(o=a.pop(),r&&e.queue.writeBuffer(o,0,r.buffer,r.byteOffset,r.byteLength)):r?(o=e.createBuffer({size:i,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0}),new Float32Array(o.getMappedRange()).set(r),o.unmap()):o=e.createBuffer({size:i,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),o},Ws=(e,t,n)=>{let r=Math.ceil(n/16)*16,i=t.get(r);return i&&i.length>0?i.pop():e.createBuffer({size:r,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})},Gs=(e,t)=>{let n=t.size,r=e.get(n);if(r||(r=[],e.set(n,r)),r.length>=32){t.destroy();return}r.push(t)},Ks=(e,t)=>{let n=t.size,r=e.get(n);if(r||(r=[],e.set(n,r)),r.length>=32){t.destroy();return}r.push(t)},qs=(e,t)=>e.createBuffer({size:t.size,usage:t.usage|GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,label:t.label||`storage_buffer`}),Js=(e,t,n,r)=>{let i=Math.ceil(n/256)*256,a=null,o=1/0;for(let e of t)if(!e.inUse&&e.size>=i){let t=e.size-i;t<o&&(a=e,o=t)}if(a)return a.inUse=!0,a.lastUsedFrame=r,a.buffer;let s=Math.max(i,16384),c=qs(e,{size:s,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST|GPUBufferUsage.VERTEX,label:`storage_buffer_${t.length}`});return t.push({buffer:c,size:s,inUse:!0,lastUsedFrame:r}),c},Ys=(e,t,n=60)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];!i.inUse&&t-i.lastUsedFrame>n&&(i.buffer.destroy(),e.splice(r,1))}},Xs=(e,t,n,r=0,i=0)=>{let a=new Uint32Array([t,n,r,i]),o=e.createBuffer({size:a.byteLength,usage:GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_DST,mappedAtCreation:!0,label:`indirect_buffer`});return new Uint32Array(o.getMappedRange()).set(a),o.unmap(),o},Zs=(e,t,n,r,i=0,a=0)=>{let o=new Uint32Array([n,r,i,a]);e.queue.writeBuffer(t,0,o)};var Qs=class{device;buffer=null;offset=0;capacity;alignment=256;pendingDestroyBuffers=[];stagingBuffer;stagingFloat32;dirtyEnd=0;constructor(e,t=65536){this.device=e,this.capacity=t,this.stagingBuffer=new ArrayBuffer(t),this.stagingFloat32=new Float32Array(this.stagingBuffer)}resetFrame(){this.offset=0,this.dirtyEnd=0;for(let e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}getBuffer(){return this.buffer||=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.buffer}allocate(e){this.buffer||this.getBuffer();let t=this.offset,n=e.byteLength;if(t+n>this.capacity){this.flush(),this.capacity*=2;let e=this.buffer;this.buffer=this.device.createBuffer({size:this.capacity,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),e&&this.pendingDestroyBuffers.push(e),this.stagingBuffer=new ArrayBuffer(this.capacity),this.stagingFloat32=new Float32Array(this.stagingBuffer)}this.stagingFloat32.set(e,t/4);let r=t+n;return r>this.dirtyEnd&&(this.dirtyEnd=r),this.offset=t+Math.ceil(n/this.alignment)*this.alignment,t}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(),null);for(let e of this.pendingDestroyBuffers)e.destroy();this.pendingDestroyBuffers.length=0}},$s=class{device;vertexBufferBuckets;uniformBufferBuckets;storageBufferPool;indirectBufferPool;frameIndirectBuffers;frameNumber;unitRectBuffer;frameVertexPoolBuffers;frameUniformPoolBuffers;dynamicUniform;constructor(e){this.device=e,this.vertexBufferBuckets=new Map,this.uniformBufferBuckets=new Map,this.storageBufferPool=[],this.indirectBufferPool=[],this.frameIndirectBuffers=[],this.frameNumber=0,this.unitRectBuffer=null,this.frameVertexPoolBuffers=[],this.frameUniformPoolBuffers=[],this.dynamicUniform=new Qs(e)}createRectVertices(e,t,n,r){return Vs(e,t,n,r)}acquireVertexBuffer(e,t){let n=Us(this.device,this.vertexBufferBuckets,e,t);return this.frameVertexPoolBuffers.push(n),n}acquireUniformBuffer(e){let t=Ws(this.device,this.uniformBufferBuckets,e);return this.frameUniformPoolBuffers.push(t),t}acquireAndWriteUniformBuffer(e,t){let n=t??e.byteLength,r=this.acquireUniformBuffer(n);return this.device.queue.writeBuffer(r,0,e.buffer,e.byteOffset,n),r}dispose(){for(let e of this.vertexBufferBuckets.values())for(let t of e)t.destroy();this.vertexBufferBuckets.clear();for(let e of this.uniformBufferBuckets.values())for(let t of e)t.destroy();this.uniformBufferBuckets.clear();for(let e of this.storageBufferPool)e.buffer.destroy();this.storageBufferPool=[];for(let e of this.indirectBufferPool)e.destroy();this.indirectBufferPool=[];for(let e of this.frameIndirectBuffers)e.destroy();this.frameIndirectBuffers=[],this.unitRectBuffer&&=(this.unitRectBuffer.destroy(),null),this.frameVertexPoolBuffers.length=0,this.frameUniformPoolBuffers.length=0,this.dynamicUniform.dispose()}clearFrameBuffers(){for(let e of this.frameVertexPoolBuffers)Gs(this.vertexBufferBuckets,e);this.frameVertexPoolBuffers.length=0;for(let e of this.frameUniformPoolBuffers)Ks(this.uniformBufferBuckets,e);this.frameUniformPoolBuffers.length=0;for(let e of this.frameIndirectBuffers)this.indirectBufferPool.push(e);this.frameIndirectBuffers.length=0,this.releaseAllStorageBuffers(),this.dynamicUniform.resetFrame(),this.frameNumber++,this.frameNumber%60==0&&Ys(this.storageBufferPool,this.frameNumber)}releaseAllStorageBuffers(){for(let e of this.storageBufferPool)e.inUse=!1}acquireStorageBuffer(e){return Js(this.device,this.storageBufferPool,e,this.frameNumber)}writeStorageBuffer(e,t){this.device.queue.writeBuffer(e,0,t.buffer,t.byteOffset,t.byteLength)}createIndirectBuffer(e,t,n=0,r=0){let i=this.indirectBufferPool.pop();return i?Zs(this.device,i,e,t,n,r):i=Xs(this.device,e,t,n,r),this.frameIndirectBuffers.push(i),i}getUnitRectBuffer(){if(!this.unitRectBuffer){let 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}};let ec=(e,t)=>{let n=e.createSampler({magFilter:`linear`,minFilter:`linear`,mipmapFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});t.set(`linear`,n);let r=e.createSampler({magFilter:`nearest`,minFilter:`nearest`,mipmapFilter:`nearest`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});t.set(`nearest`,r);let i=e.createSampler({magFilter:`nearest`,minFilter:`linear`,mipmapFilter:`nearest`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});t.set(`atlas_instanced_sampler`,i);let a=e.createSampler({magFilter:`linear`,minFilter:`linear`,mipmapFilter:`linear`,addressModeU:`repeat`,addressModeV:`repeat`});t.set(`repeat`,a)};var tc=class{device;textures;samplers;constructor(e){this.device=e,this.textures=new Map,this.samplers=new Map,ec(e,this.samplers)}createTexture(e,t,n,r=`rgba8unorm`){let i=this.device.createTexture({size:{width:t,height:n},format:r,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return this.textures.set(e,i),i}getTexture(e){return this.textures.get(e)}createSampler(e,t=!0){let n=this.samplers.get(e);if(n)return n;let r=this.device.createSampler({magFilter:t?`linear`:`nearest`,minFilter:t?`linear`:`nearest`,mipmapFilter:t?`linear`:`nearest`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});return this.samplers.set(e,r),r}dispose(){for(let e of this.textures.values())e.destroy();this.textures.clear(),this.samplers.clear()}};let nc=(e,t,n,r,i,a,o,s,c)=>{let l=r===`atlas`||r.startsWith(`atlas_`),u=l||r.startsWith(`temp_`)?`rgba8unorm`:t,d=o||l&&!0,f=d?4:1,p=e.createTexture({size:{width:i,height:a},format:u,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST}),m=p.createView(),h={id:c.textureId++,resource:p,view:m,width:i,height:a,area:i*a,smooth:!0},g=null;if(d){let t=e.createTexture({size:{width:i,height:a},format:u,sampleCount:f,usage:GPUTextureUsage.RENDER_ATTACHMENT}),n=t.createView();g={id:c.textureId++,resource:t,view:n,width:i,height:a,area:i*a,smooth:!0}}let _=null,v=null;if(l||r===`main`||s){let t=e.createTexture({size:{width:i,height:a},format:`stencil8`,usage:GPUTextureUsage.RENDER_ATTACHMENT}),n=t.createView();if(_={id:c.stencilId++,resource:t,view:n,width:i,height:a,area:i*a,dirty:!1},d){let t=e.createTexture({size:{width:i,height:a},format:`stencil8`,sampleCount:f,usage:GPUTextureUsage.RENDER_ATTACHMENT}),n=t.createView();v={id:c.stencilId++,resource:t,view:n,width:i,height:a,area:i*a,dirty:!1}}}let y={id:c.nextId++,width:i,height:a,clipLevel:0,msaa:d,mask:s,color:null,texture:h,stencil:_,msaaTexture:g,msaaStencil:v};return n.set(r,y),y},rc=(e,t,n)=>{for(let[r,i]of e.entries())if(i.id===n.id){e.delete(r),t.push(i);break}},ic={r:0,g:0,b:0,a:0},ac={view:null,clearValue:ic,loadOp:`clear`,storeOp:`store`},oc={colorAttachments:[ac]},sc=(e,t=0,n=0,r=0,i=0,a=`clear`,o=null)=>(ac.view=e,ic.r=t,ic.g=n,ic.b=r,ic.a=i,ac.loadOp=a,ac.resolveTarget=o??void 0,oc),cc={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:`load`,storeOp:`store`},lc={view:null,stencilClearValue:0,stencilLoadOp:`clear`,stencilStoreOp:`store`},uc={colorAttachments:[cc],depthStencilAttachment:lc},dc=(e,t,n=`load`,r=`clear`,i=null)=>(cc.view=e,cc.loadOp=n,cc.resolveTarget=i??void 0,lc.view=t,lc.stencilLoadOp=r,uc),fc=(e,t,n)=>`${e}_${t}_${n}`,pc=(e,t,n,r,i,a,o,s,c)=>{let l=fc(n,r,i),u=t.get(l);if(u)for(let e=0;e<u.length;e++){let t=u[e];if(!t.inUse)return t.inUse=!0,t.lastUsedFrame=o,t.texture}if(c[0]>=s){let e=1/0,n=``,r=-1;for(let[i,a]of t)for(let t=0;t<a.length;t++){let o=a[t];!o.inUse&&o.lastUsedFrame<e&&(e=o.lastUsedFrame,n=i,r=t)}if(r>=0){let e=t.get(n);e[r].texture.destroy(),e.splice(r,1),e.length===0&&t.delete(n),c[0]--}}let d=e.createTexture({size:{width:n,height:r},format:i,usage:a}),f={texture:d,width:n,height:r,format:i,lastUsedFrame:o,inUse:!0};return u?u.push(f):t.set(l,[f]),c[0]++,d},mc=(e,t,n)=>{for(let r of e.values())for(let e=0;e<r.length;e++)if(r[e].texture===t){r[e].inUse=!1,r[e].lastUsedFrame=n;return}},hc=(e,t,n,r)=>{let i=t-n;for(let[t,n]of e){for(let e=n.length-1;e>=0;e--){let t=n[e];!t.inUse&&t.lastUsedFrame<i&&(t.texture.destroy(),n.splice(e,1),r[0]--)}n.length===0&&e.delete(t)}};var gc=class{device;buckets;currentFrame;totalCount;constructor(e){this.device=e,this.buckets=new Map,this.currentFrame=0,this.totalCount=[0]}beginFrame(){this.currentFrame++,this.currentFrame%60==0&&hc(this.buckets,this.currentFrame,180,this.totalCount)}acquire(e,t,n=`rgba8unorm`,r=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT){return pc(this.device,this.buckets,e,t,n,r,this.currentFrame,32,this.totalCount)}release(e){mc(this.buckets,e,this.currentFrame)}dispose(){for(let e of this.buckets.values())for(let t of e)t.texture.destroy();this.buckets.clear(),this.totalCount[0]=0}},_c=class{device;format;attachments;currentAttachment;idCounter;texturePool;pendingReleases=[];constructor(e,t){this.device=e,this.format=t,this.attachments=new Map,this.currentAttachment=null,this.idCounter={nextId:1,textureId:1,stencilId:1},this.texturePool=new gc(e)}beginFrame(){this.texturePool.beginFrame()}createAttachment(e,t,n,r=!1,i=!1){return nc(this.device,this.format,this.attachments,e,t,n,r,i,this.idCounter)}getAttachment(e){return this.attachments.get(e)}setCurrentAttachment(e){this.currentAttachment=e}getCurrentAttachment(){return this.currentAttachment}createRenderPassDescriptor(e,t=0,n=0,r=0,i=0,a=`clear`,o=null){return sc(e,t,n,r,i,a,o)}createStencilRenderPassDescriptor(e,t,n=`load`,r=`clear`,i=null){return dc(e,t,n,r,i)}destroyAttachment(e){let t=this.attachments.get(e);t&&(t.texture&&t.texture.resource.destroy(),t.stencil&&t.stencil.resource.destroy(),this.attachments.delete(e))}createTemporaryAttachment(e,t){let n=`temp_${this.idCounter.nextId}`,r=GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.COPY_DST|GPUTextureUsage.STORAGE_BINDING,i=this.texturePool.acquire(e,t,`rgba8unorm`,r),a=i.createView(),o={id:this.idCounter.textureId++,resource:i,view:a,width:e,height:t,area:e*t,smooth:!0},s={id:this.idCounter.nextId++,width:e,height:t,clipLevel:0,msaa:!1,mask:!1,color:null,texture:o,stencil:null,msaaTexture:null,msaaStencil:null};return this.attachments.set(n,s),s}releaseTemporaryAttachment(e){rc(this.attachments,this.pendingReleases,e)}flushPendingReleases(){for(let e of this.pendingReleases)e.texture&&this.texturePool.release(e.texture.resource),e.msaaTexture&&e.msaaTexture.resource.destroy(),e.stencil&&e.stencil.resource.destroy(),e.msaaStencil&&e.msaaStencil.resource.destroy();this.pendingReleases=[]}dispose(){for(let e of this.attachments.values())e.texture&&e.texture.resource.destroy(),e.stencil&&e.stencil.resource.destroy();this.attachments.clear(),this.currentAttachment=null,this.texturePool.dispose()}};let vc=`\nfn isInside(uv: vec2<f32>) -> f32 {\n let s = step(vec2<f32>(0.0), uv) * step(uv, vec2<f32>(1.0));\n return s.x * s.y;\n}`,yc=`\n const vertices = array<vec2<f32>, 6>(\n vec2<f32>(0.0, 0.0),\n vec2<f32>(1.0, 0.0),\n vec2<f32>(0.0, 1.0),\n vec2<f32>(0.0, 1.0),\n vec2<f32>(1.0, 0.0),\n vec2<f32>(1.0, 1.0)\n );`,bc=`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n}`,xc=e=>`\n${bc}\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n\n const positions = array<vec2<f32>, 6>(\n vec2<f32>(-1.0, -1.0),\n vec2<f32>( 1.0, -1.0),\n vec2<f32>(-1.0, 1.0),\n vec2<f32>(-1.0, 1.0),\n vec2<f32>( 1.0, -1.0),\n vec2<f32>( 1.0, 1.0)\n );\n var texCoords = array<vec2<f32>, 6>(\n vec2<f32>(0.0, ${e?`1.0`:`0.0`}),\n vec2<f32>(1.0, ${e?`1.0`:`0.0`}),\n vec2<f32>(0.0, ${e?`0.0`:`1.0`}),\n vec2<f32>(0.0, ${e?`0.0`:`1.0`}),\n vec2<f32>(1.0, ${e?`1.0`:`0.0`}),\n vec2<f32>(1.0, ${e?`0.0`:`1.0`})\n );\n output.position = vec4<f32>(positions[vertexIndex], 0.0, 1.0);\n output.texCoord = texCoords[vertexIndex];\n return output;\n}\n`,Sc=xc(!0),Cc=xc(!1),wc=xc(!1),Tc=`\nstruct PositionUniforms {\n offset: vec2<f32>,\n size: vec2<f32>,\n viewport: vec2<f32>,\n padding: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: PositionUniforms;\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n${yc}\n let vertex = vertices[vertexIndex];\n output.texCoord = vec2<f32>(vertex.x, 1.0 - vertex.y);\n var position = vertex * uniforms.size + uniforms.offset;\n position = position / uniforms.viewport;\n position = position * 2.0 - 1.0;\n output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);\n return output;\n}\n`,Ec=`\nstruct BitmapSyncUniforms {\n nodeRect: vec4<f32>,\n textureSize: vec2<f32>,\n padding: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BitmapSyncUniforms;\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n${yc}\n let vertex = vertices[vertexIndex];\n let pixelPos = vec2<f32>(\n uniforms.nodeRect.x + vertex.x * uniforms.nodeRect.z,\n uniforms.nodeRect.y + vertex.y * uniforms.nodeRect.w\n );\n let ndc = pixelPos / uniforms.textureSize * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, -ndc.y, 0.0, 1.0);\n output.texCoord = pixelPos / uniforms.textureSize;\n return output;\n}\n`,Dc=e=>`\n\nstruct ScaleUniforms {\n matrix: vec4<f32>,\n translate: vec2<f32>,\n srcSize: vec2<f32>,\n dstSize: vec2<f32>,\n padding: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ScaleUniforms;\n\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n${yc}\n let vertex = vertices[vertexIndex];\n output.texCoord = ${e?`vec2<f32>(vertex.x, 1.0 - vertex.y)`:`vertex`};\n\n var pos = vertex * uniforms.srcSize;\n let a = uniforms.matrix.x;\n let b = uniforms.matrix.y;\n let c = uniforms.matrix.z;\n let d = uniforms.matrix.w;\n let tx = uniforms.translate.x;\n let ty = uniforms.translate.y;\n let transformedX = pos.x * a + pos.y * c + tx;\n let transformedY = pos.x * b + pos.y * d + ty;\n var position = vec2<f32>(transformedX, transformedY) / uniforms.dstSize;\n position = position * 2.0 - 1.0;\n output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);\n\n return output;\n}\n`,Oc=Dc(!1),kc=Dc(!0),Ac=Dc(!1),jc=e=>`\nstruct PositionUniforms {\n offset: vec2<f32>,\n size: vec2<f32>,\n viewport: vec2<f32>,\n padding: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: PositionUniforms;\n\n@vertex\nfn main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var output: VertexOutput;\n${yc}\n let vertex = vertices[vertexIndex];\n output.texCoord = ${e?`vec2<f32>(vertex.x, 1.0 - vertex.y)`:`vertex`};\n var position = vertex * uniforms.size + uniforms.offset;\n position = position / uniforms.viewport;\n position = position * 2.0 - 1.0;\n output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);\n return output;\n}\n`,Mc=jc(!1),Nc=jc(!0),Pc=`\nstruct GradientUniforms {\n inverseMatrix: mat3x3<f32>,\n gradientType: f32,\n focal: f32,\n spread: f32,\n radius: f32,\n linearPoints: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> gradient: GradientUniforms;\n@group(0) @binding(1) var gradientSampler: sampler;\n@group(0) @binding(2) var gradientTexture: texture_2d<f32>;\n\noverride GRADIENT_TYPE: u32 = 0u;\noverride SPREAD_MODE: u32 = 2u;\n\nfn applySpread(t: f32) -> f32 {\n if (SPREAD_MODE == 0u) {\n return 1.0 - abs(fract(t * 0.5) * 2.0 - 1.0);\n } else if (SPREAD_MODE == 1u) {\n return fract(t);\n } else {\n return clamp(t, 0.0, 1.0);\n }\n}\n`,Fc=`\n var t: f32;\n if (GRADIENT_TYPE == 0u) {\n let a = gradient.linearPoints.xy;\n let b = gradient.linearPoints.zw;\n let ab = b - a;\n let ap = p - a;\n let dotAB = dot(ab, ab);\n if (dotAB < 0.0001) {\n t = 0.0;\n } else {\n t = dot(ab, ap) / dotAB;\n }\n } else {\n let r = gradient.radius;\n let coord = p / r;\n let focalRatio = gradient.focal;\n\n if (abs(focalRatio) < 0.001) {\n t = length(coord);\n } else {\n let focal = vec2<f32>(focalRatio, 0.0);\n let diff = coord - focal;\n let lenDiff = length(diff);\n\n if (lenDiff < 0.0001) {\n t = 0.0;\n } else {\n let dir = diff / lenDiff;\n\n // Solve quadratic equation for unit circle intersection (a=1 since dir is normalized)\n let b_coef = 2.0 * dot(dir, focal);\n let c_coef = dot(focal, focal) - 1.0;\n let discriminant = b_coef * b_coef - 4.0 * c_coef;\n let x = (-b_coef + sqrt(max(discriminant, 0.0))) * 0.5;\n t = lenDiff / abs(x);\n }\n }\n }\n t = applySpread(t);\n let gradientColor = textureSampleLevel(gradientTexture, gradientSampler, vec2<f32>(t, 0.5), 0);\n`,Ic=`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) v_uv: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n @location(2) color: vec4<f32>,\n}\n${Pc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let p = input.v_uv;\n${Fc}\n let result = gradientColor * input.color;\n return vec4<f32>(result.rgb * result.a, result.a);\n}\n`,Lc=`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) v_uv: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n @location(2) color: vec4<f32>,\n}\n${Pc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let p = input.v_uv;\n${Fc}\n return vec4<f32>(gradientColor.rgb * gradientColor.a, gradientColor.a);\n}\n`;`${Pc}${Fc}`;let Rc=`\n${bc}\n\nstruct CopyUniforms {\n scale: vec2<f32>,\n offset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let uv = input.texCoord * uniforms.scale + uniforms.offset;\n return textureSampleLevel(inputTexture, textureSampler, uv, 0);\n}\n`,zc=`\n${bc}\n\nstruct CopyUniforms {\n scale: vec2<f32>,\n offset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let uv = (input.texCoord - uniforms.offset) * uniforms.scale;\n let clampedUv = clamp(uv, vec2<f32>(0.0), vec2<f32>(1.0));\n let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0);\n let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0;\n return select(vec4<f32>(0.0, 0.0, 0.0, 0.0), color, inBounds);\n}\n`,Bc=`\n${bc}\n\nstruct CopyUniforms {\n scale: vec2<f32>,\n offset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: CopyUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let uv = input.texCoord * uniforms.scale + uniforms.offset;\n let clampedUv = clamp(uv, vec2<f32>(0.0), vec2<f32>(1.0));\n let color = textureSampleLevel(inputTexture, textureSampler, clampedUv, 0);\n let inBounds = uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0;\n return select(vec4<f32>(0.0, 0.0, 0.0, 0.0), color, inBounds);\n}\n`,Vc=`\n${bc}\n\nstruct ColorTransformUniforms {\n mul: vec4<f32>,\n add: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> ct: ColorTransformUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);\n\n color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);\n color = clamp(color * ct.mul + ct.add, vec4<f32>(0.0), vec4<f32>(1.0));\n color = vec4<f32>(color.rgb * color.a, color.a);\n\n return color;\n}\n`,Hc=`\n${bc}\n\nstruct YFlipCTUniforms {\n scale: vec2<f32>,\n offset: vec2<f32>,\n mul: vec4<f32>,\n add: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: YFlipCTUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let uv = input.texCoord * uniforms.scale + uniforms.offset;\n var color = textureSampleLevel(inputTexture, textureSampler, uv, 0);\n\n color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);\n color = clamp(color * uniforms.mul + uniforms.add, vec4<f32>(0.0), vec4<f32>(1.0));\n color = vec4<f32>(color.rgb * color.a, color.a);\n\n return color;\n}\n`,Uc=`\n${bc}\n\nstruct ColorMatrixUniforms {\n matrix: mat4x4<f32>,\n offset: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ColorMatrixUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n var color = textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);\n\n color = vec4<f32>(color.rgb / max(vec3<f32>(0.0001), vec3<f32>(color.a)), color.a);\n var result = uniforms.matrix * color + uniforms.offset;\n result = clamp(result, vec4<f32>(0.0), vec4<f32>(1.0));\n result = vec4<f32>(result.rgb * result.a, result.a);\n\n return result;\n}\n`,Wc=`\n${bc}\n\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);\n}\n`,Gc=`\n${bc}\n\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n return textureSampleLevel(inputTexture, textureSampler, input.texCoord, 0);\n}\n`,Kc=`\n${bc}\n\noverride IS_INNER: u32 = 0u;\noverride IS_KNOCKOUT: u32 = 0u;\n\nstruct GlowUniforms {\n color: vec4<f32>,\n baseScale: vec2<f32>,\n baseOffset: vec2<f32>,\n blurScale: vec2<f32>,\n blurOffset: vec2<f32>,\n strength: f32,\n _padding1: f32,\n _padding2: f32,\n _padding3: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: GlowUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var blurTexture: texture_2d<f32>;\n@group(0) @binding(3) var baseTexture: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;\n let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);\n\n let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;\n let blurColor = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);\n\n var rawAlpha = blurColor.a;\n if (IS_INNER == 1u) {\n rawAlpha = 1.0 - rawAlpha;\n }\n let glowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0);\n let glowColor = vec4<f32>(uniforms.color.rgb * glowAlpha, uniforms.color.a * glowAlpha);\n if (IS_INNER == 1u) {\n let innerGlow = glowColor * baseColor.a;\n if (IS_KNOCKOUT == 1u) {\n return innerGlow;\n } else {\n return innerGlow + baseColor * (1.0 - glowColor.a);\n }\n } else {\n if (IS_KNOCKOUT == 1u) {\n return glowColor * (1.0 - baseColor.a);\n } else {\n return baseColor + glowColor * (1.0 - baseColor.a);\n }\n }\n}\n`,qc=`\n${bc}\n\noverride IS_INNER: u32 = 0u;\noverride IS_KNOCKOUT: u32 = 0u;\noverride IS_HIDE_OBJECT: u32 = 0u;\n\nstruct DropShadowUniforms {\n color: vec4<f32>,\n baseScale: vec2<f32>,\n baseOffset: vec2<f32>,\n blurScale: vec2<f32>,\n blurOffset: vec2<f32>,\n strength: f32,\n _padding1: f32,\n _padding2: f32,\n _padding3: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: DropShadowUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var blurTexture: texture_2d<f32>;\n@group(0) @binding(3) var baseTexture: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;\n let baseColor = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);\n\n let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;\n let blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);\n\n var rawAlpha = blur.a;\n if (IS_INNER == 1u) {\n rawAlpha = 1.0 - rawAlpha;\n }\n let shadowAlpha = clamp(rawAlpha * uniforms.strength, 0.0, 1.0);\n let shadowColor = vec4<f32>(uniforms.color.rgb * shadowAlpha, uniforms.color.a * shadowAlpha);\n\n if (IS_INNER == 1u) {\n let innerShadow = shadowColor * baseColor.a;\n if (IS_KNOCKOUT == 1u) {\n return innerShadow;\n } else {\n return innerShadow + baseColor * (1.0 - shadowColor.a);\n }\n } else {\n if (IS_HIDE_OBJECT == 1u) {\n return shadowColor;\n } else if (IS_KNOCKOUT == 1u) {\n return shadowColor * (1.0 - baseColor.a);\n } else {\n return shadowColor * (1.0 - baseColor.a) + baseColor;\n }\n }\n}\n`,Jc=`\n${bc}\n\noverride GLOW_TYPE: u32 = 0u;\noverride IS_KNOCKOUT: u32 = 0u;\n\nstruct GradientGlowUniforms {\n strength: f32,\n _padding1: f32,\n _padding2: f32,\n _padding3: f32,\n baseScale: vec2<f32>,\n baseOffset: vec2<f32>,\n blurScale: vec2<f32>,\n blurOffset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: GradientGlowUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var blurTexture: texture_2d<f32>;\n@group(0) @binding(3) var baseTexture: texture_2d<f32>;\n@group(0) @binding(4) var gradientLUT: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;\n let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);\n\n let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;\n var blur = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);\n\n blur.a = clamp(blur.a * uniforms.strength, 0.0, 1.0);\n let glowColor = textureSampleLevel(gradientLUT, textureSampler, vec2<f32>(blur.a, 0.5), 0);\n var result: vec4<f32>;\n if (GLOW_TYPE == 0u) {\n if (IS_KNOCKOUT == 1u) {\n result = glowColor;\n } else {\n result = base - base * glowColor.a + glowColor;\n }\n } else if (GLOW_TYPE == 1u) {\n if (IS_KNOCKOUT == 1u) {\n result = glowColor * base.a;\n } else {\n result = glowColor * base.a + base * (1.0 - glowColor.a);\n }\n } else {\n if (IS_KNOCKOUT == 1u) {\n result = glowColor - glowColor * base.a;\n } else {\n result = base + glowColor - glowColor * base.a;\n }\n }\n return result;\n}\n`,Yc=`\n${bc}\n\noverride BEVEL_TYPE: u32 = 0u;\noverride IS_KNOCKOUT: u32 = 0u;\n\nstruct GradientBevelUniforms {\n strength: f32,\n _padding1: f32,\n _padding2: f32,\n _padding3: f32,\n baseScale: vec2<f32>,\n baseOffset: vec2<f32>,\n blurScale: vec2<f32>,\n blurOffset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: GradientBevelUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var blurTexture: texture_2d<f32>;\n@group(0) @binding(3) var baseTexture: texture_2d<f32>;\n@group(0) @binding(4) var gradientLUT: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;\n let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);\n\n let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;\n let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);\n\n let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset;\n let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV);\n\n var highlightAlpha = blur1.a - blur2.a;\n var shadowAlpha = blur2.a - blur1.a;\n highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0);\n shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0);\n\n let lutCoord = 0.5019607843137255 - 0.5019607843137255 * shadowAlpha + 0.4980392156862745 * highlightAlpha;\n let bevelColor = textureSampleLevel(gradientLUT, textureSampler, vec2<f32>(lutCoord, 0.5), 0);\n\n var result: vec4<f32>;\n if (BEVEL_TYPE == 0u) {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor;\n } else {\n result = base - base * bevelColor.a + bevelColor;\n }\n } else if (BEVEL_TYPE == 1u) {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor * base.a;\n } else {\n result = bevelColor * base.a + base * (1.0 - bevelColor.a);\n }\n } else {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor - bevelColor * base.a;\n } else {\n result = base + bevelColor - bevelColor * base.a;\n }\n }\n\n return result;\n}\n`,Xc=`\n${bc}\n\noverride BEVEL_TYPE: u32 = 0u;\noverride IS_KNOCKOUT: u32 = 0u;\n\nstruct BevelUniforms {\n highlightColor: vec4<f32>,\n shadowColor: vec4<f32>,\n strength: f32,\n _padding1: f32,\n _padding2: f32,\n _padding3: f32,\n baseScale: vec2<f32>,\n baseOffset: vec2<f32>,\n blurScale: vec2<f32>,\n blurOffset: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BevelUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var blurTexture: texture_2d<f32>;\n@group(0) @binding(3) var baseTexture: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let baseUV = input.texCoord * uniforms.baseScale - uniforms.baseOffset;\n let base = textureSampleLevel(baseTexture, textureSampler, baseUV, 0) * isInside(baseUV);\n\n let blurUV = input.texCoord * uniforms.blurScale - uniforms.blurOffset;\n let blur1 = textureSampleLevel(blurTexture, textureSampler, blurUV, 0) * isInside(blurUV);\n\n let mirrorUV = (1.0 - input.texCoord) * uniforms.blurScale - uniforms.blurOffset;\n let blur2 = textureSampleLevel(blurTexture, textureSampler, mirrorUV, 0) * isInside(mirrorUV);\n\n var highlightAlpha = blur1.a - blur2.a;\n var shadowAlpha = blur2.a - blur1.a;\n highlightAlpha = clamp(highlightAlpha * uniforms.strength, 0.0, 1.0);\n shadowAlpha = clamp(shadowAlpha * uniforms.strength, 0.0, 1.0);\n\n let bevelColor = uniforms.highlightColor * highlightAlpha + uniforms.shadowColor * shadowAlpha;\n var result: vec4<f32>;\n if (BEVEL_TYPE == 0u) {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor;\n } else {\n result = base - base * bevelColor.a + bevelColor;\n }\n } else if (BEVEL_TYPE == 1u) {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor * base.a;\n } else {\n result = bevelColor * base.a + base * (1.0 - bevelColor.a);\n }\n } else {\n if (IS_KNOCKOUT == 1u) {\n result = bevelColor - bevelColor * base.a;\n } else {\n result = base + bevelColor - bevelColor * base.a;\n }\n }\n\n return result;\n}\n`,Zc=`\n${bc}\n\nstruct BevelBaseUniforms {\n offset: vec2<f32>,\n _padding: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BevelBaseUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var sourceTexture: texture_2d<f32>;\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let original = textureSampleLevel(sourceTexture, textureSampler, input.texCoord, 0);\n let shiftedUV = input.texCoord - uniforms.offset;\n let shifted = textureSampleLevel(sourceTexture, textureSampler, shiftedUV, 0) * isInside(shiftedUV);\n return original * (1.0 - shifted.a);\n}\n`;var G=class{static getFillVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\nstruct FillUniforms {\n color: vec4<f32>,\n matrix0: vec4<f32>,\n matrix1: vec4<f32>,\n matrix2: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: FillUniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);\n let transformed = matrix * vec3<f32>(input.position, 1.0);\n let ndc = transformed.xy * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);\n output.bezier = input.bezier;\n output.color = uniforms.color;\n return output;\n}\n`}static getFillFragmentShader(){return`\nstruct FragmentInput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\n@fragment\nfn main(input: FragmentInput) -> @location(0) vec4<f32> {\n let f_val = input.bezier.x * input.bezier.x - input.bezier.y;\n let dx = dpdx(f_val);\n let dy = dpdy(f_val);\n\n if (input.bezier.x == 0.5 && input.bezier.y == 0.5) {\n return vec4<f32>(input.color.rgb * input.color.a, input.color.a);\n }\n\n let dist = f_val * inverseSqrt(dx * dx + dy * dy);\n let coverage = smoothstep(0.5, -0.5, dist);\n\n if (coverage <= 0.001) {\n discard;\n }\n\n let finalAlpha = input.color.a * min(coverage, 1.0);\n return vec4<f32>(input.color.rgb * finalAlpha, finalAlpha);\n}\n`}static getStencilWriteVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n}\n\nstruct FillUniforms {\n color: vec4<f32>,\n matrix0: vec4<f32>,\n matrix1: vec4<f32>,\n matrix2: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: FillUniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);\n let transformed = matrix * vec3<f32>(input.position, 1.0);\n let ndc = transformed.xy * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);\n output.bezier = input.bezier;\n return output;\n}\n`}static getStencilWriteFragmentShader(){return`\nstruct FragmentInput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n}\n\n@fragment\nfn main(input: FragmentInput) -> @location(0) vec4<f32> {\n let f_val = input.bezier.x * input.bezier.x - input.bezier.y;\n let dx = dpdx(f_val);\n let dy = dpdy(f_val);\n let dist = f_val * inverseSqrt(dx * dx + dy * dy);\n let alpha = smoothstep(0.5, -0.5, dist);\n\n if (alpha <= 0.001) {\n discard;\n }\n\n return vec4<f32>(0.0, 0.0, 0.0, min(alpha, 1.0));\n}\n`}static getStencilFillVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n}\n\nstruct FillUniforms {\n color: vec4<f32>,\n matrix0: vec4<f32>,\n matrix1: vec4<f32>,\n matrix2: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: FillUniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let matrix = mat3x3<f32>(uniforms.matrix0.xyz, uniforms.matrix1.xyz, uniforms.matrix2.xyz);\n let transformed = matrix * vec3<f32>(input.position, 1.0);\n let ndc = transformed.xy * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);\n output.color = uniforms.color;\n return output;\n}\n`}static getStencilFillFragmentShader(){return`\nstruct FragmentInput {\n @builtin(position) position: vec4<f32>,\n @location(0) color: vec4<f32>,\n}\n\n@fragment\nfn main(input: FragmentInput) -> @location(0) vec4<f32> {\n let a = input.color.a;\n return vec4<f32>(input.color.r * a, input.color.g * a, input.color.b * a, a);\n}\n`}static getMaskVertexShader(){return`\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n}\n\nstruct Uniforms {\n viewportSize: vec2<f32>,\n _padding0: vec2<f32>,\n matrixCol0: vec3<f32>,\n _padding1: f32,\n matrixCol1: vec3<f32>,\n _padding2: f32,\n matrixCol2: vec3<f32>,\n _padding3: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let matrix = mat3x3<f32>(uniforms.matrixCol0, uniforms.matrixCol1, uniforms.matrixCol2);\n let transformed = matrix * vec3<f32>(input.position, 1.0);\n let pos = transformed.xy;\n let ndc = pos * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, -ndc.y, 0.0, 1.0);\n output.bezier = input.bezier;\n return output;\n}\n`}static getMaskFragmentShader(){return`\nstruct FragmentInput {\n @location(0) bezier: vec2<f32>,\n}\n\n@fragment\nfn main(input: FragmentInput) -> @location(0) vec4<f32> {\n let px = dpdx(input.bezier);\n let py = dpdy(input.bezier);\n let f = (2.0 * input.bezier.x) * vec2<f32>(px.x, py.x) - vec2<f32>(px.y, py.y);\n let alpha = 0.5 - (input.bezier.x * input.bezier.x - input.bezier.y) / length(f);\n if (alpha <= 0.0) {\n discard;\n }\n return vec4<f32>(min(alpha, 1.0));\n}\n`}static getBasicVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) texCoord: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\nstruct Uniforms {\n matrix: mat3x3<f32>,\n color: vec4<f32>,\n alpha: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let pos = uniforms.matrix * vec3<f32>(input.position, 1.0);\n let ndc = pos.xy * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);\n output.texCoord = input.texCoord;\n let premultipliedColor = vec4<f32>(\n uniforms.color.rgb * uniforms.color.a * uniforms.alpha,\n uniforms.color.a * uniforms.alpha\n );\n output.color = premultipliedColor;\n return output;\n}\n`}static getBasicFragmentShader(){return`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n return input.color;\n}\n`}static getTextureFragmentShader(){return`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var textureData: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let textureColor = textureSampleLevel(textureData, textureSampler, input.texCoord, 0);\n return textureColor * input.color;\n}\n`}static getInstancedVertexShader(){return`\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) texCoord: vec2<f32>,\n}\n\nstruct InstanceInput {\n @location(2) textureRect: vec4<f32>,\n @location(3) textureDim: vec4<f32>,\n @location(4) matrixTx: vec4<f32>,\n @location(5) matrixScale: vec4<f32>,\n @location(6) mulColor: vec4<f32>,\n @location(7) addColor: vec4<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) mulColor: vec4<f32>,\n @location(2) addColor: vec4<f32>,\n}\n\n@vertex\nfn main(\n input: VertexInput,\n instance: InstanceInput,\n @builtin(instance_index) instanceIdx: u32\n) -> VertexOutput {\n var output: VertexOutput;\n let texX = instance.textureRect.x + input.texCoord.x * instance.textureRect.z;\n let texY = instance.textureRect.y + input.texCoord.y * instance.textureRect.w;\n output.texCoord = vec2<f32>(texX, texY);\n var pos = vec2<f32>(input.position.x, 1.0 - input.position.y);\n pos = pos * vec2<f32>(instance.textureDim.x, instance.textureDim.y);\n let scale0 = instance.matrixScale.x;\n let rotate0 = instance.matrixScale.y;\n let scale1 = instance.matrixScale.z;\n let rotate1 = instance.matrixScale.w;\n let transformedX = pos.x * scale0 + pos.y * scale1 + instance.matrixTx.x;\n let transformedY = pos.x * rotate0 + pos.y * rotate1 + instance.matrixTx.y;\n var position = vec2<f32>(transformedX, transformedY) / vec2<f32>(instance.textureDim.z, instance.textureDim.w);\n position = position * 2.0 - 1.0;\n output.position = vec4<f32>(position.x, -position.y, 0.0, 1.0);\n output.mulColor = instance.mulColor;\n output.addColor = instance.addColor;\n return output;\n}\n`}static getInstancedFragmentShader(){return`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) mulColor: vec4<f32>,\n @location(2) addColor: vec4<f32>,\n}\n\n@group(0) @binding(0) var textureSampler: sampler;\n@group(0) @binding(1) var textureData: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n var src = textureSample(textureData, textureSampler, input.texCoord);\n src = vec4<f32>(src.rgb / max(0.0001, src.a), src.a);\n src = clamp(src * input.mulColor + input.addColor, vec4<f32>(0.0), vec4<f32>(1.0));\n src = vec4<f32>(src.rgb * src.a, src.a);\n return src;\n}\n`}static getGradientFillVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) v_uv: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n @location(2) color: vec4<f32>,\n}\n\nstruct GradientUniforms {\n inverseMatrix: mat3x3<f32>,\n gradientType: f32,\n focal: f32,\n spread: f32,\n radius: f32,\n linearPoints: vec4<f32>,\n color: vec4<f32>,\n contextMatrix0: vec4<f32>,\n contextMatrix1: vec4<f32>,\n contextMatrix2: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> gradient: GradientUniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let contextMatrix = mat3x3<f32>(gradient.contextMatrix0.xyz, gradient.contextMatrix1.xyz, gradient.contextMatrix2.xyz);\n let pos = contextMatrix * vec3<f32>(input.position, 1.0);\n let ndc = vec2<f32>(pos.x * 2.0 - 1.0, pos.y * 2.0 - 1.0);\n output.position = vec4<f32>(ndc.x, ndc.y * yFlipSign, 0.0, 1.0);\n let uvPos = gradient.inverseMatrix * vec3<f32>(input.position, 1.0);\n output.v_uv = uvPos.xy;\n output.bezier = input.bezier;\n output.color = gradient.color;\n return output;\n}\n`}static getGradientFillFragmentShader(){return Ic}static getGradientFillStencilFragmentShader(){return Lc}static getBitmapFillVertexShader(){return`\noverride yFlipSign: f32 = 1.0;\n\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n @location(1) bezier: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n @location(1) color: vec4<f32>,\n @location(2) worldPos: vec2<f32>,\n}\n\nstruct BitmapUniforms {\n bitmapMatrix: mat3x3<f32>,\n width: f32,\n height: f32,\n repeat: f32,\n _pad: f32,\n color: vec4<f32>,\n contextMatrix0: vec4<f32>,\n contextMatrix1: vec4<f32>,\n contextMatrix2: vec4<f32>,\n}\n\n@group(0) @binding(0) var<uniform> bitmap: BitmapUniforms;\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let matrix = mat3x3<f32>(bitmap.contextMatrix0.xyz, bitmap.contextMatrix1.xyz, bitmap.contextMatrix2.xyz);\n let transformedPos = matrix * vec3<f32>(input.position, 1.0);\n let clipX = transformedPos.x * 2.0 - 1.0;\n let clipY = (transformedPos.y * 2.0 - 1.0) * yFlipSign;\n output.position = vec4<f32>(clipX, clipY, 0.0, 1.0);\n output.bezier = input.bezier;\n output.color = bitmap.color;\n output.worldPos = input.position;\n return output;\n}\n`}static getBitmapFillFragmentShader(){return`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) bezier: vec2<f32>,\n @location(1) color: vec4<f32>,\n @location(2) worldPos: vec2<f32>,\n}\n\nstruct BitmapUniforms {\n bitmapMatrix: mat3x3<f32>,\n textureWidth: f32,\n textureHeight: f32,\n repeat: f32,\n _pad: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BitmapUniforms;\n@group(0) @binding(1) var bitmapSampler: sampler;\n@group(0) @binding(2) var bitmapTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let u = input.bezier.x;\n let v = input.bezier.y;\n if (abs(u - 0.5) > 0.001 || abs(v - 0.5) > 0.001) {\n let d = u * u - v;\n if (d > 0.0) {\n discard;\n }\n }\n let transformedPos = uniforms.bitmapMatrix * vec3<f32>(input.worldPos, 1.0);\n var uv = vec2<f32>(\n transformedPos.x / uniforms.textureWidth,\n transformedPos.y / uniforms.textureHeight\n );\n if (uniforms.repeat > 0.5) {\n uv = fract(uv);\n }\n let bitmapColor = textureSampleLevel(bitmapTexture, bitmapSampler, uv, 0);\n let alpha = bitmapColor.a * input.color.a;\n return vec4<f32>(bitmapColor.rgb * input.color.a, alpha);\n}\n`}static getBlendFragmentShader(){return`\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) color: vec4<f32>,\n}\n\nstruct BlendUniforms {\n blendMode: f32,\n}\n\n@group(0) @binding(1) var<uniform> blend: BlendUniforms;\n@group(0) @binding(2) var srcSampler: sampler;\n@group(0) @binding(3) var srcTexture: texture_2d<f32>;\n@group(0) @binding(4) var dstSampler: sampler;\n@group(0) @binding(5) var dstTexture: texture_2d<f32>;\n\nfn blendNormal(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {\n return src;\n}\n\nfn blendMultiply(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {\n return src * dst;\n}\n\nfn blendScreen(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {\n return src + dst - src * dst;\n}\n\nfn blendAdd(src: vec4<f32>, dst: vec4<f32>) -> vec4<f32> {\n return min(src + dst, vec4<f32>(1.0));\n}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let src = textureSampleLevel(srcTexture, srcSampler, input.texCoord, 0);\n let dst = textureSampleLevel(dstTexture, dstSampler, input.texCoord, 0);\n var result: vec4<f32>;\n if (blend.blendMode < 0.5) {\n result = blendNormal(src, dst);\n } else if (blend.blendMode < 1.5) {\n result = blendMultiply(src, dst);\n } else if (blend.blendMode < 2.5) {\n result = blendScreen(src, dst);\n } else {\n result = blendAdd(src, dst);\n }\n return result * input.color;\n}\n`}static getBlurFilterVertexShader(){return Sc}static getBitmapSyncVertexShader(){return Ec}static getBitmapSyncFragmentShader(){return Gc}static getBlurFilterFragmentShader(e){let t=e.toFixed(1);return`\n${bc}\n\nstruct BlurUniforms {\n offset: vec2<f32>,\n fraction: f32,\n samples: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BlurUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var inputTexture: texture_2d<f32>;\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let offset = uniforms.offset;\n let fraction = uniforms.fraction;\n let samples = uniforms.samples;\n var color = textureSample(inputTexture, textureSampler, input.texCoord);\n for (var i: f32 = 1.0; i < ${t}; i += 1.0) {\n color += textureSample(inputTexture, textureSampler, input.texCoord + offset * i);\n color += textureSample(inputTexture, textureSampler, input.texCoord - offset * i);\n }\n color += textureSample(inputTexture, textureSampler, input.texCoord + offset * ${t}) * fraction;\n color += textureSample(inputTexture, textureSampler, input.texCoord - offset * ${t}) * fraction;\n color /= samples;\n return color;\n}\n`}static getTextureCopyFragmentShader(){return Rc}static getBlurTextureCopyFragmentShader(){return zc}static getFilterOutputFragmentShader(){return Bc}static getColorTransformFragmentShader(){return Vc}static getYFlipColorTransformFragmentShader(){return Hc}static getColorMatrixFilterFragmentShader(){return Uc}static getGlowFilterFragmentShader(){return Kc}static getDropShadowFilterFragmentShader(){return qc}static getGradientGlowFilterFragmentShader(){return Jc}static getGradientBevelFilterFragmentShader(){return Yc}static getBevelFilterFragmentShader(){return Xc}static getBevelBaseFragmentShader(){return Zc}static getConvolutionFilterFragmentShader(e,t,n=!0,r=!0){let i=Math.floor(e*.5),a=Math.floor(t*.5),o=e*t,s=``;for(let e=0;e<o;e++)s+=`\n result = result + getWeightedColor(${e}, getMatrixWeight(${e}));`;let c=n?`result.a = textureSample(sourceTexture, sourceSampler, input.texCoord).a;`:``,l=r?``:`\n let substituteColor = uniforms.substituteColor;\n color = mix(substituteColor, color, isInside(uv));`;return`\nstruct ConvolutionUniforms {\n rcpSize: vec2<f32>,\n rcpDivisor: f32,\n bias: f32,\n substituteColor: vec4<f32>,\n matrix: array<vec4<f32>, ${Math.ceil(o/4)}>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ConvolutionUniforms;\n@group(0) @binding(1) var sourceSampler: sampler;\n@group(0) @binding(2) var sourceTexture: texture_2d<f32>;\n\n${bc}\n\n${vc}\n\nfn getMatrixWeight(index: i32) -> f32 {\n let vecIndex = index / 4;\n let component = index % 4;\n let vec = uniforms.matrix[vecIndex];\n if (component == 0) { return vec.x; }\n else if (component == 1) { return vec.y; }\n else if (component == 2) { return vec.z; }\n else { return vec.w; }\n}\n\nfn getWeightedColor(i: i32, weight: f32) -> vec4<f32> {\n let rcpSize = uniforms.rcpSize;\n let iDivX = i / ${e};\n let iModX = i - ${e} * iDivX;\n let offset = vec2<f32>(f32(iModX - ${i}), f32(${a} - iDivX));\n var uv = input.texCoord + offset * rcpSize;\n var color = textureSample(sourceTexture, sourceSampler, uv);\n color = vec4<f32>(color.rgb / max(0.0001, color.a), color.a);\n ${l}\n return color * weight;\n}\n\nvar<private> input: VertexOutput;\n\n@vertex\nfn vs_main(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {\n var positions = array<vec2<f32>, 6>(\n vec2<f32>(-1.0, -1.0),\n vec2<f32>(1.0, -1.0),\n vec2<f32>(-1.0, 1.0),\n vec2<f32>(-1.0, 1.0),\n vec2<f32>(1.0, -1.0),\n vec2<f32>(1.0, 1.0)\n );\n var texCoords = array<vec2<f32>, 6>(\n vec2<f32>(0.0, 1.0),\n vec2<f32>(1.0, 1.0),\n vec2<f32>(0.0, 0.0),\n vec2<f32>(0.0, 0.0),\n vec2<f32>(1.0, 1.0),\n vec2<f32>(1.0, 0.0)\n );\n var output: VertexOutput;\n output.position = vec4<f32>(positions[vertexIndex], 0.0, 1.0);\n output.texCoord = texCoords[vertexIndex];\n return output;\n}\n\n@fragment\nfn fs_main(fragInput: VertexOutput) -> @location(0) vec4<f32> {\n input = fragInput;\n let rcpDivisor = uniforms.rcpDivisor;\n let bias = uniforms.bias;\n var result = vec4<f32>(0.0);\n ${s}\n result = clamp(result * rcpDivisor + bias, vec4<f32>(0.0), vec4<f32>(1.0));\n ${c}\n result = vec4<f32>(result.rgb * result.a, result.a);\n return result;\n}\n`}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`\n${bc}\n\nstruct BlendUniforms {\n mulColor: vec4<f32>,\n addColor: vec4<f32>,\n blendMode: f32,\n _pad0: f32,\n _pad1: f32,\n _pad2: f32,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: BlendUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var dstTexture: texture_2d<f32>;\n@group(0) @binding(3) var srcTexture: texture_2d<f32>;\n\nfn blend(src: vec4<f32>, dst: vec4<f32>, mode: i32) -> vec4<f32> {\n if (src.a == 0.0) { return dst; }\n if (dst.a == 0.0) { return src; }\n\n let a = src - src * dst.a;\n let b = dst - dst * src.a;\n\n if (mode == 1) {\n let c = src * dst;\n return a + b + c;\n }\n\n let srcRgb = src.rgb / src.a;\n let dstRgb = dst.rgb / dst.a;\n\n var blended: vec3<f32>;\n\n switch (mode) {\n case 0: {\n blended = dstRgb - srcRgb;\n }\n case 2: {\n blended = mix(srcRgb, dstRgb, step(srcRgb, dstRgb));\n }\n case 3: {\n blended = mix(srcRgb, dstRgb, step(dstRgb, srcRgb));\n }\n case 4: {\n let mul = srcRgb * dstRgb;\n let c1 = 2.0 * mul;\n let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0;\n blended = mix(c1, c2, step(vec3<f32>(0.5), dstRgb));\n }\n case 5: {\n let mul = srcRgb * dstRgb;\n let c1 = 2.0 * mul;\n let c2 = 2.0 * (srcRgb + dstRgb - mul) - 1.0;\n blended = mix(c1, c2, step(vec3<f32>(0.5), srcRgb));\n }\n case 6: {\n blended = abs(srcRgb - dstRgb);\n }\n case 7: {\n let ib = dst - dst * src.a;\n let ic = vec4<f32>(src.a - dst.rgb * src.a, src.a);\n return ib + ic;\n }\n default: {\n blended = srcRgb;\n }\n }\n\n var c = vec4<f32>(blended, src.a * dst.a);\n c = vec4<f32>(c.rgb * c.a, c.a);\n return a + b + c;\n}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n var dst = textureSample(dstTexture, textureSampler, input.texCoord);\n var src = textureSample(srcTexture, textureSampler, input.texCoord);\n let mul = uniforms.mulColor;\n let add = uniforms.addColor;\n if (mul.x != 1.0 || mul.y != 1.0 || mul.z != 1.0 || mul.w != 1.0\n || add.x != 0.0 || add.y != 0.0 || add.z != 0.0) {\n src = vec4<f32>(src.rgb / max(vec3<f32>(0.0001), vec3<f32>(src.a)), src.a);\n src = clamp(src * mul + add, vec4<f32>(0.0), vec4<f32>(1.0));\n src = vec4<f32>(src.rgb * src.a, src.a);\n }\n return blend(src, dst, i32(uniforms.blendMode));\n}\n`}static getDisplacementMapFilterFragmentShader(e,t,n){let r,i;switch(e){case 1:r=`mapColor.r`;break;case 2:r=`mapColor.g`;break;case 4:r=`mapColor.b`;break;case 8:r=`mapColor.a`;break;default:r=`0.5`;break}switch(t){case 1:i=`mapColor.r`;break;case 2:i=`mapColor.g`;break;case 4:i=`mapColor.b`;break;case 8:i=`mapColor.a`;break;default:i=`0.5`;break}let a,o=!1;switch(n){case 0:a=`\nsourceColor = textureSample(srcTexture, textureSampler, uv);\n`;break;case 1:o=!0,a=`\nsourceColor = mix(uniforms.substituteColor, textureSample(srcTexture, textureSampler, uv), isInside(uv));\n`;break;case 2:a=`\nsourceColor = textureSample(srcTexture, textureSampler, fract(uv));\n`;break;case 3:a=`\nlet insideUV = step(abs(uv - vec2<f32>(0.5)), vec2<f32>(0.5));\nsourceColor = textureSample(srcTexture, textureSampler, mix(input.texCoord, uv, insideUV));\n`;break;default:a=`\nsourceColor = textureSample(srcTexture, textureSampler, fract(uv));\n`;break}return`\n${bc}\n\n${o?`struct DisplacementUniforms {\n uvToStScale: vec2<f32>,\n uvToStOffset: vec2<f32>,\n scale: vec2<f32>,\n padding: vec2<f32>,\n substituteColor: vec4<f32>,\n}`:`struct DisplacementUniforms {\n uvToStScale: vec2<f32>,\n uvToStOffset: vec2<f32>,\n scale: vec2<f32>,\n padding: vec2<f32>,\n}`}\n\n@group(0) @binding(0) var<uniform> uniforms: DisplacementUniforms;\n@group(0) @binding(1) var textureSampler: sampler;\n@group(0) @binding(2) var srcTexture: texture_2d<f32>;\n@group(0) @binding(3) var mapTexture: texture_2d<f32>;\n\n${vc}\n\n@fragment\nfn main(input: VertexOutput) -> @location(0) vec4<f32> {\n let stCoord = vec2<f32>(input.texCoord.x, 1.0 - input.texCoord.y);\n let st = stCoord * uniforms.uvToStScale - uniforms.uvToStOffset;\n let mapColor = textureSample(mapTexture, textureSampler, vec2<f32>(st.x, 1.0 - st.y));\n let offset = vec2<f32>(${r}, ${i}) - 0.5;\n let uv = input.texCoord + offset * uniforms.scale;\n var sourceColor: vec4<f32>;\n ${a}\n return mix(textureSample(srcTexture, textureSampler, input.texCoord), sourceColor, isInside(st));\n}\n`}static getNodeClearVertexShader(){return`\nstruct VertexInput {\n @location(0) position: vec2<f32>,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n}\n\n@vertex\nfn main(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n let ndc = input.position * 2.0 - 1.0;\n output.position = vec4<f32>(ndc.x, ndc.y, 0.0, 1.0);\n return output;\n}\n`}static getNodeClearFragmentShader(){return`\n@fragment\nfn main() -> @location(0) vec4<f32> {\n return vec4<f32>(0.0, 0.0, 0.0, 0.0);\n}\n`}static getPositionedTextureVertexShader(){return Tc}static getTextureScaleVertexShader(){return Oc}static getTextureScaleBlendVertexShader(){return kc}static getComplexBlendScaleVertexShader(){return Ac}static getComplexBlendVertexShader(){return Cc}static getComplexBlendCopyVertexShader(){return wc}static getComplexBlendOutputVertexShader(){return Mc}static getFilterComplexBlendOutputVertexShader(){return Nc}static getPositionedTextureFragmentShader(){return Wc}};let Qc={arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]},$c={color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}};var el=class{device;format;pipelines;bindGroupLayouts;sampleCount;shaderModuleCache=new Map;filterBindGroupLayouts=new Map;constructor(e,t){this.device=e,this.format=t,this.pipelines=new Map,this.bindGroupLayouts=new Map,this.sampleCount=4,this.initialize()}getOrCreateShaderModule(e,t){let n=this.shaderModuleCache.get(e);return n||(n=this.device.createShaderModule({code:t}),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,t)=>[`blur_filter_${t+1}`,`blur_filter`]),[`blur_filter`,`blur_filter`],[`texture_copy`,`texture_copy`],[`texture_copy_rgba8`,`texture_copy`],[`texture_copy_rgba8_msaa`,`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`],[`filter_output_masked`,`texture_copy`],[`filter_output_masked_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){let t=this.lazyGroupMap.get(e);if(!(!t||this.lazyInitGroups.has(t)))switch(this.lazyInitGroups.add(t),t){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(){for(let e of[`blur_filter`,`texture_copy`,`bitmap_sync`,`filter`,`complex_blend`])this.ensureLazyGroup(e)}createFillPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`,hasDynamicOffset:!0}}]});this.bindGroupLayouts.set(`fill_dynamic`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`fillVertex`,G.getFillVertexShader()),r=this.getOrCreateShaderModule(`fillFragment`,G.getFillFragmentShader()),i=Qc,a=$c,o=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:a}]},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}}),s=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set(`fill`,o),this.pipelines.set(`fill_bgra`,s);let c=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},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`,c)}createStencilFillPipelines(){let e=Qc,t=this.bindGroupLayouts.get(`fill_dynamic`),n=this.device.createPipelineLayout({bindGroupLayouts:[t]}),r=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilWriteFragment`,G.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`,r);let i=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilFillVertex`,G.getStencilFillVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilFillFragment`,G.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`,i);let a=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilWriteFragment`,G.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`,a);let o=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule(`stencilWriteFragment`,G.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`,o);let s=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilFillVertex`,G.getStencilFillVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilFillFragment`,G.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`,s);let c=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilFillVertex`,G.getStencilFillVertexShader()),entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:this.getOrCreateShaderModule(`stencilFillFragment`,G.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`,c);let l=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilFillVertex`,G.getStencilFillVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilFillFragment`,G.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`,l)}createClipPipeline(){let e=Qc,t=this.bindGroupLayouts.get(`fill_dynamic`),n=this.device.createPipelineLayout({bindGroupLayouts:[t]}),r=this.device.createRenderPipeline({layout:n,vertex:{module:this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),entryPoint:`main`,buffers:[e]},fragment:{module:this.getOrCreateShaderModule(`stencilWriteFragment`,G.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`,r);let i=this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),a=this.getOrCreateShaderModule(`stencilWriteFragment`,G.getStencilWriteFragmentShader());for(let t=1;t<=8;t++){let r=1<<t-1,o=this.device.createRenderPipeline({layout:n,vertex:{module:i,entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:a,entryPoint:`main`,targets:[{format:this.format,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:r},multisample:{count:this.sampleCount,alphaToCoverageEnabled:!0}});this.pipelines.set(`clip_write_main_${t}`,o)}this.pipelines.set(`clip_write_main`,this.pipelines.get(`clip_write_main_1`));for(let t=1;t<=8;t++){let r=1<<t-1,o=this.device.createRenderPipeline({layout:n,vertex:{module:i,entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:a,entryPoint:`main`,targets:[{format:this.format,writeMask:0}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:{format:`stencil8`,stencilFront:{compare:`always`,failOp:`replace`,depthFailOp:`replace`,passOp:`replace`},stencilBack:{compare:`always`,failOp:`replace`,depthFailOp:`replace`,passOp:`replace`},stencilReadMask:255,stencilWriteMask:r},multisample:{count:this.sampleCount}});this.pipelines.set(`clip_clear_main_${t}`,o)}}createMaskUnionPipelines(){let e=Qc,t=this.bindGroupLayouts.get(`fill_dynamic`),n=this.device.createPipelineLayout({bindGroupLayouts:[t]}),r=this.getOrCreateShaderModule(`stencilWriteVertex`,G.getStencilWriteVertexShader()),i=this.getOrCreateShaderModule(`stencilWriteFragment`,G.getStencilWriteFragmentShader());for(let t=1;t<=8;t++){let a=~(1<<t-1)&255,o=this.device.createRenderPipeline({layout:n,vertex:{module:r,entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:i,entryPoint:`main`,targets:[{format:this.format,writeMask:0}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:{format:`stencil8`,stencilFront:{compare:`less-equal`,failOp:`zero`,depthFailOp:`replace`,passOp:`replace`},stencilBack:{compare:`less-equal`,failOp:`zero`,depthFailOp:`replace`,passOp:`replace`},stencilReadMask:255,stencilWriteMask:a}});this.pipelines.set(`mask_union_merge_${t}`,o);let s=this.device.createRenderPipeline({layout:n,vertex:{module:r,entryPoint:`main`,buffers:[e],constants:{yFlipSign:-1}},fragment:{module:i,entryPoint:`main`,targets:[{format:this.format,writeMask:0}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:{format:`stencil8`,stencilFront:{compare:`always`,failOp:`replace`,depthFailOp:`replace`,passOp:`replace`},stencilBack:{compare:`always`,failOp:`replace`,depthFailOp:`replace`,passOp:`replace`},stencilReadMask:255,stencilWriteMask:1<<t}});this.pipelines.set(`mask_union_clear_${t}`,s)}}createMaskPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:`uniform`}}]});this.bindGroupLayouts.set(`mask`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`maskVertex`,G.getMaskVertexShader()),r=this.getOrCreateShaderModule(`maskFragment`,G.getMaskFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]}]},fragment:{module:r,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(`mask`,i)}createBasicPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}}]});this.bindGroupLayouts.set(`basic`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`basicVertex`,G.getBasicVertexShader()),r=this.getOrCreateShaderModule(`basicFragment`,G.getBasicFragmentShader()),i={arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]},a=$c,o=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount}}),s=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`}});this.pipelines.set(`basic`,o),this.pipelines.set(`basic_bgra`,s)}createTexturePipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set(`texture`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`basicVertex`,G.getBasicVertexShader()),r=this.getOrCreateShaderModule(`textureFragment`,G.getTextureFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]}]},fragment:{module:r,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(`texture`,i)}createInstancedPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set(`instanced`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`instancedVertex`,G.getInstancedVertexShader()),r=this.getOrCreateShaderModule(`instancedFragment`,G.getInstancedFragmentShader()),i={arrayStride:96,stepMode:`instance`,attributes:[{shaderLocation:2,offset:0,format:`float32x4`},{shaderLocation:3,offset:16,format:`float32x4`},{shaderLocation:4,offset:32,format:`float32x4`},{shaderLocation:5,offset:48,format:`float32x4`},{shaderLocation:6,offset:64,format:`float32x4`},{shaderLocation:7,offset:80,format:`float32x4`}]},a=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[{arrayStride:16,stepMode:`vertex`,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]},i]},fragment:{module:r,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`},multisample:{count:this.sampleCount}});this.pipelines.set(`instanced`,a);let o=[{arrayStride:16,stepMode:`vertex`,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]},i];for(let[e,i]of[[`instanced_add`,{color:{srcFactor:`one`,dstFactor:`one`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}}],[`instanced_screen`,{color:{srcFactor:`one-minus-dst`,dstFactor:`one`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}}],[`instanced_alpha`,{color:{srcFactor:`zero`,dstFactor:`src-alpha`,operation:`add`},alpha:{srcFactor:`zero`,dstFactor:`src-alpha`,operation:`add`}}],[`instanced_erase`,{color:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`}}],[`instanced_copy`,{color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}}]]){let a=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:o},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:i}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount}});this.pipelines.set(e,a)}let s=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[{arrayStride:16,stepMode:`vertex`,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]},i]},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:$c}]},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}});this.pipelines.set(`instanced_masked`,s)}createGradientPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set(`gradient_fill`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]});this.gradientPipelineLayout=t;let n=this.getOrCreateShaderModule(`gradientFillVertex`,G.getGradientFillVertexShader());this.gradientVertexShaderModule=n;let r=this.getOrCreateShaderModule(`gradientFillFragment`,G.getGradientFillFragmentShader());this.gradientFragmentShaderModule=r;let i=this.getOrCreateShaderModule(`gradientFillStencilFragment`,G.getGradientFillStencilFragmentShader());this.gradientStencilFragmentShaderModule=i;let a=Qc,o=$c,s=this.device.createRenderPipeline({label:`gradient_fill_no_stencil_pipeline`,layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:o}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount}}),c=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:o}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount}});this.pipelines.set(`gradient_fill`,s),this.pipelines.set(`gradient_fill_no_stencil`,s),this.pipelines.set(`gradient_fill_bgra`,c);let l={format:`stencil8`,stencilFront:{compare:`always`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilBack:{compare:`always`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilReadMask:0,stencilWriteMask:0},u=this.device.createRenderPipeline({label:`gradient_stroke_atlas_pipeline`,layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:o}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:l,multisample:{count:this.sampleCount}});this.pipelines.set(`gradient_stroke_atlas`,u);let d=this.device.createRenderPipeline({label:`gradient_stroke_bgra_pipeline`,layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:o}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:l,multisample:{count:this.sampleCount}});this.pipelines.set(`gradient_stroke_bgra`,d);let f=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:o}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:1}});this.pipelines.set(`gradient_fill_bgra_no_msaa`,f);let p=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:o}]},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(`gradient_fill_stencil`,p);let m=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a]},fragment:{module:i,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:o}]},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(`gradient_fill_stencil_atlas`,m);let h=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a],constants:{yFlipSign:-1}},fragment:{module:i,entryPoint:`main`,targets:[{format:this.format,blend:o}]},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:1}});this.pipelines.set(`gradient_fill_stencil_main`,h);let g=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[a],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:o}]},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}});this.pipelines.set(`gradient_fill_bgra_stencil`,g)}createBitmapFillPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set(`bitmap_fill`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`bitmapFillVertex`,G.getBitmapFillVertexShader()),r=this.getOrCreateShaderModule(`bitmapFillFragment`,G.getBitmapFillFragmentShader()),i=Qc,a=$c,o=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:this.sampleCount}}),s=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`}});this.pipelines.set(`bitmap_fill`,o),this.pipelines.set(`bitmap_fill_bgra`,s);let c={format:`stencil8`,stencilFront:{compare:`always`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilBack:{compare:`always`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilReadMask:0,stencilWriteMask:0},l=this.device.createRenderPipeline({label:`bitmap_stroke_atlas_pipeline`,layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:c,multisample:{count:this.sampleCount}});this.pipelines.set(`bitmap_stroke_atlas`,l);let u=this.device.createRenderPipeline({label:`bitmap_stroke_bgra_pipeline`,layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},primitive:{topology:`triangle-list`,cullMode:`none`},depthStencil:c,multisample:{count:this.sampleCount}});this.pipelines.set(`bitmap_stroke_bgra`,u);let d=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i]},fragment:{module:r,entryPoint:`main`,targets:[{format:`rgba8unorm`,blend:a}]},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(`bitmap_fill_stencil`,d);let f=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[i],constants:{yFlipSign:-1}},fragment:{module:r,entryPoint:`main`,targets:[{format:this.format,blend:a}]},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}});this.pipelines.set(`bitmap_fill_bgra_stencil`,f)}createBlendPipeline(){let e=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{}},{binding:4,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:5,visibility:GPUShaderStage.FRAGMENT,texture:{}}]});this.bindGroupLayouts.set(`blend`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`basicVertex`,G.getBasicVertexShader()),r=this.getOrCreateShaderModule(`blendFragment`,G.getBlendFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[{arrayStride:16,attributes:[{shaderLocation:0,offset:0,format:`float32x2`},{shaderLocation:1,offset:8,format:`float32x2`}]}]},fragment:{module:r,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(`blend`,i)}createBlurFilterPipeline(){let 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:{}}]});this.bindGroupLayouts.set(`blur_filter`,e);let t=this.getOrCreateShaderModule(`blurFilterVertex`,G.getBlurFilterVertexShader()),n=this.device.createPipelineLayout({bindGroupLayouts:[e]});for(let e=1;e<=16;e++){let r=this.getOrCreateShaderModule(`blurFilterFragment_${e}`,G.getBlurFilterFragmentShader(e)),i=this.device.createRenderPipeline({layout:n,vertex:{module:t,entryPoint:`main`,buffers:[]},fragment:{module:r,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(`blur_filter_${e}`,i)}}createTextureCopyPipeline(){let 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:{}}]});this.bindGroupLayouts.set(`texture_copy`,e);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`blurFilterVertex`,G.getBlurFilterVertexShader()),r=this.getOrCreateShaderModule(`textureCopyFragment`,G.getTextureCopyFragmentShader()),i={color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}},a={color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},o={color:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`}};this.pipelines.set(`texture_copy`,this.createFullscreenQuadPipeline(t,n,r,this.format,i)),this.pipelines.set(`texture_copy_rgba8`,this.createFullscreenQuadPipeline(t,n,r,`rgba8unorm`,i)),this.sampleCount>1&&this.pipelines.set(`texture_copy_rgba8_msaa`,this.createFullscreenQuadPipeline(t,n,r,`rgba8unorm`,{color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}},this.sampleCount));let s=this.getOrCreateShaderModule(`colorTransformFragment`,G.getColorTransformFragmentShader());this.pipelines.set(`color_transform`,this.createFullscreenQuadPipeline(t,n,s,`rgba8unorm`,i));let c=this.getOrCreateShaderModule(`yFlipColorTransformFragment`,G.getYFlipColorTransformFragmentShader());this.pipelines.set(`y_flip_color_transform`,this.createFullscreenQuadPipeline(t,n,c,`rgba8unorm`,i));let l=this.getOrCreateShaderModule(`blurTextureCopyFragment`,G.getBlurTextureCopyFragmentShader());this.pipelines.set(`texture_erase`,this.createFullscreenQuadPipeline(t,n,l,`rgba8unorm`,o)),this.pipelines.set(`blur_texture_copy`,this.createFullscreenQuadPipeline(t,n,l,`rgba8unorm`,i)),this.pipelines.set(`filter_blend`,this.createFullscreenQuadPipeline(t,n,r,this.format,a)),this.pipelines.set(`texture_copy_bgra`,this.createFullscreenQuadPipeline(t,n,r,this.format,i));let u=this.getOrCreateShaderModule(`filterOutputFragment`,G.getFilterOutputFragmentShader());this.pipelines.set(`filter_output`,this.createFullscreenQuadPipeline(t,n,u,this.format,a));let d=[[`filter_output_add`,{color:{srcFactor:`one`,dstFactor:`one`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one`,operation:`add`}}],[`filter_output_screen`,{color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}}],[`filter_output_alpha`,{color:{srcFactor:`zero`,dstFactor:`src-alpha`,operation:`add`},alpha:{srcFactor:`zero`,dstFactor:`src-alpha`,operation:`add`}}],[`filter_output_erase`,{color:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`}}]];for(let[e,r]of d)this.pipelines.set(e,this.createFullscreenQuadPipeline(t,n,u,this.format,r));let f={format:`stencil8`,stencilFront:{compare:`equal`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilBack:{compare:`equal`,failOp:`keep`,depthFailOp:`keep`,passOp:`keep`},stencilReadMask:255,stencilWriteMask:0};if(this.pipelines.set(`filter_output_masked`,this.createFullscreenQuadPipeline(t,n,u,this.format,a,void 0,f)),this.sampleCount>1&&this.pipelines.set(`filter_output_masked_msaa`,this.createFullscreenQuadPipeline(t,n,u,this.format,{color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},this.sampleCount,f)),this.sampleCount>1){this.pipelines.set(`texture_copy_bgra_msaa`,this.createFullscreenQuadPipeline(t,n,r,this.format,{color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}},this.sampleCount)),this.pipelines.set(`filter_output_msaa`,this.createFullscreenQuadPipeline(t,n,u,this.format,{color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},this.sampleCount));for(let[e,r]of d)this.pipelines.set(`${e}_msaa`,this.createFullscreenQuadPipeline(t,n,u,this.format,r,this.sampleCount))}this.createPositionedTexturePipeline(),this.createTextureScalePipeline()}createPositionedTexturePipeline(){let 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);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`positionedTextureVertex`,G.getPositionedTextureVertexShader()),r=this.getOrCreateShaderModule(`positionedTextureFragment`,G.getPositionedTextureFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,i);let a=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,a);let o=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,o);let s=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,s)}createTextureScalePipeline(){let 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);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`textureScaleVertex`,G.getTextureScaleVertexShader()),r=this.getOrCreateShaderModule(`positionedTextureFragment`,G.getPositionedTextureFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,i);let a=this.getOrCreateShaderModule(`textureScaleBlendVertex`,G.getTextureScaleBlendVertexShader()),o=this.device.createRenderPipeline({layout:t,vertex:{module:a,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,o)}createBitmapSyncPipeline(){let 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);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`bitmapSyncVertex`,G.getBitmapSyncVertexShader()),r=this.getOrCreateShaderModule(`bitmapSyncFragment`,G.getBitmapSyncFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,i)}createColorMatrixFilterPipeline(){let e={color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}},t={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`,G.getColorMatrixFilterFragmentShader(),1,e),this.createFilterPipelineWithLayout(`bevel_base`,G.getBevelBaseFragmentShader(),1,e),this.createFilterPipelineWithLayout(`glow_filter`,G.getGlowFilterFragmentShader(),2,t),this.createFilterPipelineWithLayout(`drop_shadow_filter`,G.getDropShadowFilterFragmentShader(),2,t),this.createFilterPipelineWithLayout(`bevel_filter`,G.getBevelFilterFragmentShader(),2,t),this.createFilterPipelineWithLayout(`gradient_glow_filter`,G.getGradientGlowFilterFragmentShader(),3,t),this.createFilterPipelineWithLayout(`gradient_bevel_filter`,G.getGradientBevelFilterFragmentShader(),3,t)}createComplexBlendPipelines(){let 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);let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`complexBlendVertex`,G.getComplexBlendVertexShader()),r=this.getOrCreateShaderModule(`unifiedComplexBlendFragment`,G.getUnifiedComplexBlendFragmentShader()),i=this.device.createRenderPipeline({layout:t,vertex:{module:n,entryPoint:`main`,buffers:[]},fragment:{module:r,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`,i),this.createComplexBlendCopyPipeline(),this.createComplexBlendOutputPipeline()}createComplexBlendCopyPipeline(){let e={color:{srcFactor:`one`,dstFactor:`zero`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`zero`,operation:`add`}},t=this.bindGroupLayouts.get(`texture_copy`);if(t){let n=this.device.createPipelineLayout({bindGroupLayouts:[t]}),r=this.getOrCreateShaderModule(`complexBlendCopyVertex`,G.getComplexBlendCopyVertexShader()),i=this.getOrCreateShaderModule(`textureCopyFragment`,G.getTextureCopyFragmentShader());this.pipelines.set(`complex_blend_copy`,this.createFullscreenQuadPipeline(n,r,i,`rgba8unorm`,e))}let n=this.bindGroupLayouts.get(`texture_scale`);if(n){let t=this.device.createPipelineLayout({bindGroupLayouts:[n]}),r=this.getOrCreateShaderModule(`complexBlendScaleVertex`,G.getComplexBlendScaleVertexShader()),i=this.getOrCreateShaderModule(`positionedTextureFragment`,G.getPositionedTextureFragmentShader());this.pipelines.set(`complex_blend_scale`,this.createFullscreenQuadPipeline(t,r,i,`rgba8unorm`,e))}}createComplexBlendOutputPipeline(){let e=this.bindGroupLayouts.get(`positioned_texture`);if(!e)return;let t=this.device.createPipelineLayout({bindGroupLayouts:[e]}),n=this.getOrCreateShaderModule(`positionedTextureFragment`,G.getPositionedTextureFragmentShader()),r={color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},i=this.getOrCreateShaderModule(`complexBlendOutputVertex`,G.getComplexBlendOutputVertexShader());this.pipelines.set(`complex_blend_output`,this.createFullscreenQuadPipeline(t,i,n,this.format,r)),this.sampleCount>1&&this.pipelines.set(`complex_blend_output_msaa`,this.createFullscreenQuadPipeline(t,i,n,this.format,r,this.sampleCount));let a=this.getOrCreateShaderModule(`filterComplexBlendOutputVertex`,G.getFilterComplexBlendOutputVertexShader());this.pipelines.set(`filter_complex_blend_output`,this.createFullscreenQuadPipeline(t,a,n,this.format,r)),this.sampleCount>1&&this.pipelines.set(`filter_complex_blend_output_msaa`,this.createFullscreenQuadPipeline(t,a,n,this.format,r,this.sampleCount))}createFilterPipelineWithLayout(e,t,n,r){let i=this.filterBindGroupLayouts.get(n);if(!i){let e=[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}}];for(let t=0;t<n;t++)e.push({binding:2+t,visibility:GPUShaderStage.FRAGMENT,texture:{}});i=this.device.createBindGroupLayout({entries:e}),this.filterBindGroupLayouts.set(n,i)}this.bindGroupLayouts.set(e,i);let a=this.device.createPipelineLayout({bindGroupLayouts:[i]}),o=this.getOrCreateShaderModule(`blurFilterVertex`,G.getBlurFilterVertexShader()),s=this.getOrCreateShaderModule(`filter_${e}`,t);this.pipelines.set(e,this.createFullscreenQuadPipeline(a,o,s,`rgba8unorm`,r))}createFullscreenQuadPipeline(e,t,n,r,i,a,o){let s={layout:e,vertex:{module:t,entryPoint:`main`,buffers:[]},fragment:{module:n,entryPoint:`main`,targets:[{format:r,blend:i}]},primitive:{topology:`triangle-list`,cullMode:`none`}};return a&&a>1&&(s.multisample={count:a}),o&&(s.depthStencil=o),this.device.createRenderPipeline(s)}getPipeline(e){let t=this.pipelines.get(e);return t||=(this.ensureLazyGroup(e),this.pipelines.get(e)),t}getFilterPipeline(e,t){let n=`${e}_${Object.keys(t).sort().map(e=>`${e}${t[e]}`).join(`_`)}`,r=this.pipelines.get(n);if(r)return r;this.ensureLazyGroup(e);let i=this.shaderModuleCache.get(`filter_${e}`),a=this.shaderModuleCache.get(`blurFilterVertex`),o=this.bindGroupLayouts.get(e);if(!i||!a||!o)return this.pipelines.get(e);let s=this.device.createPipelineLayout({bindGroupLayouts:[o]});return r=this.device.createRenderPipeline({layout:s,vertex:{module:a,entryPoint:`main`,buffers:[]},fragment:{module:i,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:t},primitive:{topology:`triangle-list`,cullMode:`none`}}),this.pipelines.set(n,r),r}getGradientPipeline(e,t,n){let r=`${e}_t${t}s${n}`,i=this.pipelines.get(r);return i||(this.gradientPipelineLayout?(i=this.createGradientVariant(e,t,n),i?(this.pipelines.set(r,i),i):this.getPipeline(e)):this.getPipeline(e))}gradientPipelineLayout=null;gradientVertexShaderModule=null;gradientFragmentShaderModule=null;gradientStencilFragmentShaderModule=null;createGradientVariant(e,t,n){if(!this.gradientPipelineLayout)return;let r={GRADIENT_TYPE:t,SPREAD_MODE:n},i=Qc,a=$c,o=e.includes(`stencil_atlas`)||e===`gradient_fill_stencil_main`?this.gradientStencilFragmentShaderModule:this.gradientFragmentShaderModule,s=e.includes(`bgra`)||e===`gradient_fill_stencil_main`?this.format:`rgba8unorm`,c=e.includes(`bgra`)||e===`gradient_fill_stencil_main`,l={};c&&(l.yFlipSign=-1);let u,d=this.sampleCount;e.includes(`stroke`)?u={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`?u={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`?(u={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},d=1):e===`gradient_fill_bgra_stencil`?u={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`&&(d=1);let f={layout:this.gradientPipelineLayout,vertex:{module:this.gradientVertexShaderModule,entryPoint:`main`,buffers:[i],constants:Object.keys(l).length>0?l:void 0},fragment:{module:o,entryPoint:`main`,targets:[{format:s,blend:a}],constants:r},primitive:{topology:`triangle-list`,cullMode:`none`},multisample:{count:d}};return u&&(f.depthStencil=u),this.device.createRenderPipeline(f)}getBindGroupLayout(e){let t=this.bindGroupLayouts.get(e);return t||=(this.ensureLazyGroup(e),this.bindGroupLayouts.get(e)),t}createNodeClearPipeline(){let e=this.device.createRenderPipeline({layout:`auto`,vertex:{module:this.getOrCreateShaderModule(`nodeClearVertex`,G.getNodeClearVertexShader()),entryPoint:`main`,buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:`float32x2`}]}]},fragment:{module:this.getOrCreateShaderModule(`nodeClearFragment`,G.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`,e)}dispose(){this.pipelines.clear(),this.bindGroupLayouts.clear(),this.shaderModuleCache.clear(),this.filterBindGroupLayouts.clear()}};let tl=Number.MAX_VALUE,nl=-Number.MAX_VALUE,rl=0,il=e=>{rl=e},al=()=>rl,ol=[],sl=e=>{ol[rl]=e},cl=null,ll=e=>{cl=e},ul=()=>{if(!(rl in ol))if(cl)sl(cl(rl));else return null;return ol[rl]},dl=e=>e in ol?ol[e]:null,fl=[],pl=[],ml=()=>{for(let e=0;e<pl.length;++e){let t=pl[e];t&&(t[0]=t[1]=tl,t[2]=t[3]=nl)}},hl=0,gl=e=>{hl=e},_l=()=>hl,vl=()=>{fl.length=0,il(0);for(let e=0;e<ol.length;e++){let t=ol[e];t&&(t.texture&&t.texture.resource.destroy(),t.stencil&&t.stencil.resource.destroy(),t.msaaTexture&&t.msaaTexture.resource.destroy(),t.msaaStencil&&t.msaaStencil.resource.destroy())}ol.length=0,ml(),gl(0)};var yl=class{count;constructor(){this.count=0}clear(){this.count=Qr.offset=0}};let bl=`normal`,xl=e=>{bl=e},Sl=new Set([`normal`,`layer`,`add`,`screen`,`alpha`,`erase`,`copy`]),Cl=[],wl=[],Tl=[],El=()=>Cl,Dl=()=>{for(let e=0;e<Cl.length;e++){let t=Cl[e];wl.push(t.color_transform),Tl.push(t.matrix)}Cl.length=0},Ol=new Map,kl=()=>{let e=`blend_instanced`;return Ol.has(e)||Ol.set(e,new yl),Ol.get(e)},Al=(e,t,n,r,i,a,o,s,c,l,u,d)=>{let f=a[0],p=a[1],m=a[2],h=d,g=a[4]/255,_=a[5]/255,v=a[6]/255;if(Sl.has(s)){(bl!==s||_l()!==e.index)&&(Ns&&(il(_l()),Ns.drawArraysInstanced()),xl(s),gl(e.index),il(e.index));let t=kl();Qr.pushInstanceBuffer((e.x+.5)/u,(e.y+.5)/u,(e.w-1)/u,(e.h-1)/u,e.w,e.h,c,l,o[6],o[7],0,0,o[0],o[1],o[3],o[4],f,p,m,h,g,_,v,0),t.count++}else{Ns&&(il(_l()),Ns.drawArraysInstanced());let f=wl.length>0?wl.pop():new Float32Array(8);f.set(a);let p=Tl.length>0?Tl.pop():new Float32Array(9);p.set(o),Cl.push({node:e,x_min:t,y_min:n,x_max:r,y_max:i,color_transform:f,matrix:p,blend_mode:s,viewport_width:c,viewport_height:l,render_max_size:u,global_alpha:d}),xl(s),gl(e.index),il(e.index)}},jl=!1,Ml=e=>{jl=e},Nl=()=>jl,Pl=!1,Fl=0,Il=e=>{Pl=e},Ll=()=>Pl,Rl=e=>{Fl=e},zl=()=>Fl,Bl=new Map,Vl=new Map,Hl=()=>{jl=!1,Pl=!1,Fl=0,Bl.clear(),Vl.clear()},Ul=()=>{let e=Ns.currentAttachmentObject;e&&(e.mask=!0,e.clipLevel++,Vl.set(e.clipLevel,e.clipLevel),Nl()||Ml(!0))},Wl=(e,t,n,r)=>{let i=Ns.currentAttachmentObject;if(!i)return;let a=i.clipLevel,o=Bl.get(a);o?(o[0]=Math.min(o[0],e),o[1]=Math.min(o[1],t),o[2]=Math.max(o[2],n),o[3]=Math.max(o[3],r)):(o=Fs(),o[0]=e,o[1]=t,o[2]=n,o[3]=r,Bl.set(a,o))},Gl=()=>{let e=Ns.currentAttachmentObject;if(!e)return;let t=(1<<e.clipLevel)-1;Il(!0),Rl(t&255),Ml(!1)},Kl=()=>{let e=Ns.currentAttachmentObject;if(!e)return;let t=e.clipLevel,n=Bl.get(t);if(n&&(Bl.delete(t),Is(n)),Vl.delete(t),--e.clipLevel,!e.clipLevel){e.mask=!1,Ml(!1),Il(!1),Rl(0),e.needsStencilClear=!0,Vl.clear(),Bl.clear();return}e.pendingStencilClearLevel=e.clipLevel,Gl()},ql=(e,t,n)=>{let r=e.length-5;for(let i=3;i<r;i+=3){let r=n*4;e[i+2]?(t[r++]=e[i-3],t[r++]=e[i-2],t[r++]=0,t[r++]=0,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=0,t[r++]=e[i+3],t[r++]=e[i+4],t[r++]=1,t[r++]=1):e[i+5]?(t[r++]=e[0],t[r++]=e[1],t[r++]=.5,t[r++]=.5,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=.5,t[r++]=e[i+6],t[r++]=e[i+7],t[r++]=.5,t[r++]=.5):(t[r++]=e[0],t[r++]=e[1],t[r++]=.5,t[r++]=.5,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=.5,t[r++]=e[i+3],t[r++]=e[i+4],t[r++]=.5,t[r++]=.5),n+=3}return n},Jl=new Float32Array(32),Yl=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),Xl=e=>{let t=0;for(let n of e){let e=n.length-5;for(let n=3;n<e;n+=3)t+=3}let n=t*4;Jl.length<n&&(Jl=new Float32Array(Yl(n)));let r=Jl,i=0;for(let t of e)i=ql(t,r,i);return{buffer:r.subarray(0,i*4),indexCount:i}},Zl=new OffscreenCanvas(1,1).getContext(`2d`),Ql={x:0,y:0},$l={x:0,y:0},eu={x:0,y:0},tu={x:0,y:0},nu=(e,t,n)=>{let r=Math.sqrt(e*e+t*t);return r===0?{x:0,y:0}:{x:-(t/r)*n,y:e/r*n}},ru=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),iu=e=>{let t=Math.sqrt(e.x*e.x+e.y*e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},au=(e,t,n,r)=>({x:(1-e)**2*t.x+2*(1-e)*e*n.x+e**2*r.x,y:(1-e)**2*t.y+2*(1-e)*e*n.y+e**2*r.y}),ou=(e,t,n,r)=>({x:2*(1-e)*(n.x-t.x)+2*e*(r.x-n.x),y:2*(1-e)*(n.y-t.y)+2*e*(r.y-n.y)}),su=(e,t,n,r=.5)=>{let i=ru(e,t,r),a=ru(t,n,r),o=ru(i,a,r);return[[e,i,o],[o,a,n]]},cu=(e,t,n,r=4)=>{let i=[[e,t,n]];for(let e=0;e<r;e++){let e=[];for(let t of i){let n=su(t[0],t[1],t[2],.5);e.push(n[0],n[1])}i=e}return i},lu=(e,t,n,r)=>{let i=[0,.5,1],a=[];for(let o of i){let i=au(o,e,t,n),s=ou(o,e,t,n),c=iu({x:-s.y,y:s.x});a.push({x:i.x+c.x*r,y:i.y+c.y*r})}return a},uu=(e,t,n,r)=>{let i=cu(e,t,n,5),a=[],o=[];for(let e of i)a.push(lu(e[0],e[1],e[2],+r)),o.push(lu(e[0],e[1],e[2],-r));for(let e=0;e<a.length-1;++e)a[e+1][0]=a[e][2];for(let e=0;e<o.length-1;++e)o[e+1][0]=o[e][2];let s=a[0][0],c=[s.x,s.y,!1];for(let e=0;e<a.length;++e){let t=a[e];c.push(t[1].x,t[1].y,!0,t[2].x,t[2].y,!1)}let l=[...o].reverse();for(let e=0;e<l.length;++e){let[t,n,r]=l[e];l[e]=[r,n,t]}let u=l[0][0];c.push(u.x,u.y,!1);for(let e=0;e<l.length;++e){let t=l[e];c.push(t[1].x,t[1].y,!0,t[2].x,t[2].y,!1)}return c},du=(e,t,n)=>{let r={x:t.x-e.x,y:t.y-e.y},i=nu(r.x,r.y,n),a={x:e.x+i.x,y:e.y+i.y},o={x:t.x+i.x,y:t.y+i.y},s={x:t.x-i.x,y:t.y-i.y},c={x:e.x-i.x,y:e.y-i.y};return[a.x,a.y,!1,o.x,o.y,!1,s.x,s.y,!1,c.x,c.y,!1,a.x,a.y,!1]},fu=(e,t,n,r)=>{let i=[];for(let a=0;a<r.length;a+=3){if(r[a+2])continue;let o=r[a],s=r[a+1],c=Math.sqrt((o-e)**2+(s-t)**2);Math.abs(c-n)>1e-4||i.push(o,s)}return i},pu=(e,t)=>{Zl.beginPath(),Zl.moveTo(t[0],t[1]);for(let e=3;e<t.length;e+=3)t[e+2]?(Zl.quadraticCurveTo(t[e],t[e+1],t[e+3],t[e+4]),e+=3):Zl.lineTo(t[e],t[e+1]);Zl.closePath();for(let t=0;t<e.length;t+=2){let n=e[t],r=e[t+1];if(!Zl.isPointInPath(n,r))return[n,r]}return null},mu=(e,t,n,r,i=!1)=>{let a=i?0:r.length-1,o=i?r.length-1:r.length-2,s=fu(e,t,n,r[a]),c=fu(e,t,n,r[o]);if(s[0]===c[0]&&s[1]===c[1]||s[0]===c[2]&&s[1]===c[3])return;let l=pu(s,r[o]);if(!l)return;let u=pu(c,r[a]);u&&r.splice(-1,0,[e,t,!1,l[0],l[1],!1,u[0],u[1],!1,e,t,!1])},hu=(e,t,n,r,i=!1)=>{let a=i?0:r.length-1,o=i?r.length-1:r.length-2,s=fu(e,t,n,r[a]),c=fu(e,t,n,r[o]),l=pu(s,r[o]);if(!l)return;let u=pu(c,r[a]);if(!u)return;let d=Math.atan2(l[1]-t,l[0]-e),f=Math.atan2(u[1]-t,u[0]-e)-d;f>Math.PI?f-=2*Math.PI:f<-Math.PI&&(f+=2*Math.PI);let p=f/8,m=[e,t,!1];for(let r=0;r<=8;r++){let i=d+r*p,a=e+n*Math.cos(i),o=t+n*Math.sin(i);m.push(a,o,!1)}r.splice(-1,0,m)},gu=(e,t,n,r,i,a=!1)=>{let o=a?0:i.length-1,s=a?i.length-1:i.length-2,c=fu(e.x,e.y,r,i[o]),l=fu(e.x,e.y,r,i[s]);if(c[0]===l[0]&&c[1]===l[1]||c[0]===l[2]&&c[1]===l[3])return;let u=pu(c,i[s]);if(!u)return;let d=pu(l,i[o]);if(!d)return;let f=t.x-e.x,p=t.y-e.y,m=Math.hypot(f,p),h={x:f/m,y:p/m},g=n.x-e.x,_=n.y-e.y,v=Math.hypot(g,_),y={x:g/v,y:_/v},b=h.x,x=h.y,S=y.x,C=y.y,w=b*C-x*S;if(w===0){i.splice(-1,0,[e.x,e.y,!1,u[0],u[1],!1,d[0],d[1],!1]);return}let T=((d[0]-u[0])*C-(d[1]-u[1])*S)/w,E=u[0]+T*b,D=u[1]+T*x;i.splice(-1,0,[e.x,e.y,!1,u[0],u[1],!1,E,D,!1,e.x,e.y,!1,d[0],d[1],!1,E,D,!1])},_u=(e,t,n)=>{let r=e[0],i=e[1],a=e[3],o=e[4],s=Math.atan2(i-o,r-a),c=[r,i,!1];for(let e=0;e<=8;e++){let n=s-Math.PI/2+e*Math.PI/8;c.push(r+t*Math.cos(n),i+t*Math.sin(n),!1)}n.unshift(c);let l=e[e.length-3],u=e[e.length-2],d=e[e.length-6],f=e[e.length-5],p=Math.atan2(u-f,l-d),m=[l,u,!1];for(let e=0;e<=8;e++){let n=p-Math.PI/2+e*Math.PI/8;m.push(l+t*Math.cos(n),u+t*Math.sin(n),!1)}n.push(m)},vu=(e,t,n)=>{let r=e[0],i=e[1],a=e[3],o=e[4],s=r-a,c=i-o,l=Math.hypot(s,c);if(l>0){let e=s/l,a=c/l,o=r+e*t,u=i+a*t,d=[r-a*t,i+e*t,!1,o-a*t,u+e*t,!1,o+a*t,u-e*t,!1,r+a*t,i-e*t,!1,r-a*t,i+e*t,!1];n.unshift(d)}let u=e[e.length-3],d=e[e.length-2],f=e[e.length-6],p=e[e.length-5],m=u-f,h=d-p,g=Math.hypot(m,h);if(g>0){let e=m/g,r=h/g,i=u+e*t,a=d+r*t,o=[u-r*t,d+e*t,!1,i-r*t,a+e*t,!1,i+r*t,a-e*t,!1,u+r*t,d-e*t,!1,u-r*t,d+e*t,!1];n.push(o)}},yu=(e,t)=>{let n=Ql;n.x=e[0],n.y=e[1];let r=$l;r.x=0,r.y=0;let i=eu;i.x=0,i.y=0;let a=tu;a.x=0,a.y=0;let o=[];for(let s=3;s<e.length;s+=3){let c=e[s],l=e[s+1];if(e[s+2]){r.x=c,r.y=l;continue}if(i.x=c,i.y=l,e[s-1]?o.push(uu(n,r,i,t)):o.push(du(n,i,t)),o.length>1)switch(Ns.joints){case 0:mu(n.x,n.y,t,o);break;case 1:a.x=e[s-6],a.y=e[s-5],gu(n,i,a,t,o);break;case 2:hu(n.x,n.y,t,o);break}n.x=i.x,n.y=i.y}let s=e[0],c=e[1],l=e[e.length-3],u=e[e.length-2],d=1e-4;if(Math.abs(s-l)<d&&Math.abs(c-u)<d&&o.length>1)switch(Ns.joints){case 0:mu(s,c,t,o,!0);break;case 1:n.x=s,n.y=c,i.x=e[3],i.y=e[4],a.x=e[e.length-6],a.y=e[e.length-5],gu(n,i,a,t,o,!0);break;case 2:hu(s,c,t,o,!0);break;default:break}else if(o.length>0)switch(Ns.caps){case 1:_u(e,t,o);break;case 2:vu(e,t,o);break;default:break}return o},bu=(e,t)=>{let n=t/2,r=[];for(let t of e){if(t.length<6)continue;let e=yu(t,n);for(let t of e)r.push(t)}return r},xu=new Map,Su=0,Cu=()=>{xu.clear(),Su=0},wu=new WeakMap,Tu=e=>{let t=wu.get(e);return t||(t=e.createView(),wu.set(e,t)),t},Eu=new Map,Du=new Map,Ou=(e,t,n)=>{let r=`${t}_${n}`,i=Eu.get(r);return i&&i.length>0?i.pop():e.createTexture({size:{width:t,height:n},format:`rgba8unorm`,usage:6})},ku=e=>{let t=`${e.width}_${e.height}`,n=Eu.get(t);n||(n=[],Eu.set(t,n)),n.push(e)},Au=(e,t,n)=>{let r=`${t}_${n}`,i=Du.get(r);return i&&i.length>0?i.pop():e.createTexture({size:{width:t,height:n},format:`rgba8unorm`,usage:22})},ju=e=>{let t=`${e.width}_${e.height}`,n=Du.get(t);n||(n=[],Du.set(t,n)),n.push(e)},Mu=()=>{for(let[,e]of Eu)for(let t of e)t.destroy();Eu.clear();for(let[,e]of Du)for(let t of e)t.destroy();Du.clear()},Nu=new Map,Pu=()=>{for(let e of Nu.values())e.texture?.resource&&e.texture.resource.destroy();Nu.clear()},Fu=new Map,Iu=0,Lu=(e,t,n)=>`${t}_${n}_${e.join(`,`)}`,Ru=(e,t,n)=>{let r=Lu(e,t,n),i=Fu.get(r);return i?(i.lastUsedFrame=Iu,i):null},zu=(e,t,n,r,i)=>{let a=Lu(e,t,n);Fu.set(a,{texture:r,view:i,lastUsedFrame:Iu})},Bu=()=>{Iu++;for(let[e,t]of Fu)Iu-t.lastUsedFrame>60&&(ku(t.texture),Fu.delete(e))},Vu=()=>{for(let e of Fu.values())ku(e.texture);Fu.clear(),Iu=0},Hu=null,Uu=()=>{Hu?.texture?.resource&&Hu.texture.resource.destroy(),Hu=null},Wu=(e,t,n,r,i,a)=>{let o=t.getPipeline(`stencil_write_atlas`);o&&(e.setPipeline(o),e.setStencilReference(0),e.setVertexBuffer(0,n),e.setBindGroup(0,i,[a]),e.draw(r,1,0,0));let s=t.getPipeline(`stencil_fill_atlas`);s&&(e.setPipeline(s),e.setStencilReference(0),e.setBindGroup(0,i,[a]),e.draw(r,1,0,0))},Gu=(e,t,n,r,i,a)=>{let o=t.getPipeline(`stencil_write_main`);o&&(e.setPipeline(o),e.setStencilReference(0),e.setVertexBuffer(0,n),e.setBindGroup(0,i,[a]),e.draw(r,1,0,0));let s=t.getPipeline(`stencil_fill_main`);s&&(e.setPipeline(s),e.setStencilReference(0),e.setBindGroup(0,i,[a]),e.draw(r,1,0,0))},Ku=(e,t,n,r,i,a,o,s=!1,c=1)=>{let l;if(o)l=`fill`;else if(s){if(Nl())return;l=`fill_bgra_stencil`}else l=`fill_bgra`;let u=t.getPipeline(l);if(!u){console.error(`[WebGPU] ${l} pipeline not found`);return}e.setPipeline(u),e.setVertexBuffer(0,n),e.setBindGroup(0,i,[a]),s&&!o&&!Nl()&&e.setStencilReference(zl()),e.draw(r,1,0,0)},qu=e=>e<=4?256:e<=8?512:1024,Ju=(e,t,n)=>{let r=qu(e.length/5),i=new Uint8Array(r*4);for(let t=0;t<r;t++){let a=Yu(e,t/(r-1),n),o=t*4;i[o+0]=Math.round(Math.max(0,Math.min(255,a.r))),i[o+1]=Math.round(Math.max(0,Math.min(255,a.g))),i[o+2]=Math.round(Math.max(0,Math.min(255,a.b))),i[o+3]=Math.round(Math.max(0,Math.min(255,a.a)))}return i},Yu=(e,t,n)=>{let r=e.length/5,i=0,a=0;for(let n=0;n<r;n++){let r=e[n*5];if(r<=t&&(i=n),r>=t&&a===0){a=n;break}}if(a===0&&(a=r-1),i===a){let t=i*5;return{r:e[t+1],g:e[t+2],b:e[t+3],a:e[t+4]}}let o=e[i*5],s=e[a*5],c=(t-o)/(s-o),l=e[i*5+1],u=e[i*5+2],d=e[i*5+3],f=e[i*5+4],p=e[a*5+1],m=e[a*5+2],h=e[a*5+3],g=e[a*5+4];return n===0?{r:Qu(Xu(Zu(l/255),Zu(p/255),c))*255,g:Qu(Xu(Zu(u/255),Zu(m/255),c))*255,b:Qu(Xu(Zu(d/255),Zu(h/255),c))*255,a:Xu(f,g,c)}:{r:Xu(l,p,c),g:Xu(u,m,c),b:Xu(d,h,c),a:Xu(f,g,c)}},Xu=(e,t,n)=>e+(t-e)*n,Zu=e=>e**2.23333333,Qu=e=>e**.45454545,$u=(e,t,n)=>{let r=new Uint8Array(256*4),i=e.length,a=[];for(let r=0;r<i;r++){let i=t[r];a.push({offset:e[r]/255,r:(i>>16&255)/255,g:(i>>8&255)/255,b:(i&255)/255,a:n[r]})}for(let e=0;e<256;e++){let t=e/255,n=0,o=i-1;for(let e=0;e<i-1;e++)if(a[e].offset<=t&&a[e+1].offset>=t){n=e,o=e+1;break}let s=a[n],c=a[o],l=0;c.offset!==s.offset&&(l=(t-s.offset)/(c.offset-s.offset));let u=Xu(s.r,c.r,l),d=Xu(s.g,c.g,l),f=Xu(s.b,c.b,l),p=Xu(s.a,c.a,l),m=e*4;r[m+0]=Math.round(u*p*255),r[m+1]=Math.round(d*p*255),r[m+2]=Math.round(f*p*255),r[m+3]=Math.round(p*255)}return r},ed=(e,t,n)=>{let r=e[0],i=e[1],a=e[2],o=e[3],s=e[4],c=e[5];if(n===0){let e=-819.2*r-819.2*a+s,t=819.2*r-819.2*a+s,n=-819.2*r+819.2*a+s,l=-819.2*i-819.2*o+c,u=819.2*i-819.2*o+c,d=-819.2*i+819.2*o+c,f=n-e,p=d-l,m=Math.sqrt(f*f+p*p);m?(f/=m,p/=m):(f=0,p=0);let h=(t-e)*f+(u-l)*p,g=new Float32Array([e+h*f,l+h*p,t,u]);return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:g}}let l=r*o-i*a;if(Math.abs(l)<1e-10)return{inverseMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),linearPoints:null};let u=1/l,d=o*u,f=-i*u,p=-a*u,m=r*u,h=(a*c-o*s)*u,g=(i*s-r*c)*u;return{inverseMatrix:new Float32Array([d,f,0,p,m,0,h,g,1]),linearPoints:null}},td=null,K=new Float32Array(36),nd=new Float32Array(16),rd=null,id=null,ad=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],od=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=!1,_=1)=>{let v=Xl(i);if(v.indexCount===0)return null;let y=n.acquireVertexBuffer(v.buffer.byteLength,v.buffer),b,x,S=Ru(c,u,d);if(S)b=S.texture,x=S.view;else{let t=Ju(c,u,d),n=qu(c.length/5);b=Ou(e,n,1),e.queue.writeTexture({texture:b},t,{bytesPerRow:n*4,rowsPerImage:1},{width:n,height:1}),x=b.createView(),zu(c,u,d,b,x)}let C=ed(l,a,s),w=o[3]>0?o[3]:1,T=a[0],E=a[1],D=a[3],O=a[4],k=a[6],A=a[7];K[0]=C.inverseMatrix[0],K[1]=C.inverseMatrix[3],K[2]=0,K[3]=0,K[4]=C.inverseMatrix[1],K[5]=C.inverseMatrix[4],K[6]=0,K[7]=0,K[8]=C.inverseMatrix[6],K[9]=C.inverseMatrix[7],K[10]=1,K[11]=0,K[12]=s,K[13]=Math.max(-.975,Math.min(.975,f)),K[14]=u,K[15]=819.2,C.linearPoints?(K[16]=C.linearPoints[0],K[17]=C.linearPoints[1],K[18]=C.linearPoints[2],K[19]=C.linearPoints[3]):(K[16]=0,K[17]=0,K[18]=0,K[19]=0),K[20]=1,K[21]=1,K[22]=1,K[23]=w,K[24]=T/p,K[25]=E/m,K[26]=0,K[27]=0,K[28]=D/p,K[29]=O/m,K[30]=0,K[31]=0,K[32]=k/p,K[33]=A/m,K[34]=1,K[35]=0;let j=n.acquireAndWriteUniformBuffer(K);td||=e.createSampler({magFilter:`linear`,minFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});let M=td,N=r.getBindGroupLayout(`gradient_fill`);if(!N)return console.error(`[WebGPU] gradient_fill bind group layout not found`),null;ad[0].resource.buffer=j,ad[1].resource=M,ad[2].resource=x;let P=e.createBindGroup({layout:N,entries:ad}),F=()=>{let t=r.getBindGroupLayout(`fill_dynamic`);if(!t)return null;nd[0]=1,nd[1]=1,nd[2]=1,nd[3]=w,nd[4]=T/p,nd[5]=E/m,nd[6]=0,nd[7]=0,nd[8]=D/p,nd[9]=O/m,nd[10]=0,nd[11]=0,nd[12]=k/p,nd[13]=A/m,nd[14]=1,nd[15]=0;let i=n.dynamicUniform.allocate(nd),a=n.dynamicUniform.getBuffer();return(!rd||id!==a)&&(rd=e.createBindGroup({layout:t,entries:[{binding:0,resource:{buffer:a,size:256}}]}),id=a),{bindGroup:rd,offset:i}};if(h){let e=r.getPipeline(`stencil_write_atlas`);if(e){let n=F();t.setPipeline(e),t.setStencilReference(0),t.setVertexBuffer(0,y),n&&t.setBindGroup(0,n.bindGroup,[n.offset]),t.draw(v.indexCount,1,0,0)}let n=r.getGradientPipeline(`gradient_fill_stencil_atlas`,s,u);return n&&(t.setPipeline(n),t.setStencilReference(0),t.setBindGroup(0,P),t.draw(v.indexCount,1,0,0)),null}if(g&&Nl())return null;let I=r.getPipeline(`stencil_write_main`);if(I){let e=F();t.setPipeline(I),t.setStencilReference(0),t.setVertexBuffer(0,y),e&&t.setBindGroup(0,e.bindGroup,[e.offset]),t.draw(v.indexCount,1,0,0)}let L=g?`gradient_fill_bgra_stencil_masked`:`gradient_fill_stencil_main`,R=r.getGradientPipeline(L,s,u);return R&&(t.setPipeline(R),t.setStencilReference(g?zl():0),t.setBindGroup(0,P),t.draw(v.indexCount,1,0,0)),null},sd=(e,t)=>{let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=t[0],l=t[1],u=t[3],d=t[4],f=t[6],p=t[7],m=c*n+u*r,h=c*i+u*a,g=l*n+d*r,_=l*i+d*a,v=c*o+u*s+f,y=l*o+d*s+p,b=m*_-h*g;if(Math.abs(b)<1e-10)return new Float32Array([1,0,0,0,1,0,0,0,1]);let x=1/b,S=_*x,C=-h*x,w=-g*x,T=m*x,E=(h*y-_*v)*x,D=(g*v-m*y)*x,O=S*c+C*l,k=S*u+C*d,A=w*c+T*l,j=w*u+T*d,M=S*f+C*p+E,N=w*f+T*p+D;return new Float32Array([O,A,0,k,j,0,M,N,1])},cd=new Map,q=new Float32Array(32),ld=new Float32Array(16),ud=null,dd=null,fd=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],pd=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=!1,_=1)=>{let v=Xl(i);if(v.indexCount===0)return null;let y=n.acquireVertexBuffer(v.buffer.byteLength,v.buffer),b=Ou(e,l,u);e.queue.writeTexture({texture:b},s.buffer,{bytesPerRow:l*4,rowsPerImage:u,offset:s.byteOffset},{width:l,height:u});let x=sd(c,a),S=o[0],C=o[1],w=o[2],T=o[3],E=a[0],D=a[1],O=a[3],k=a[4],A=a[6],j=a[7];q[0]=x[0],q[1]=x[1],q[2]=x[2],q[3]=0,q[4]=x[3],q[5]=x[4],q[6]=x[5],q[7]=0,q[8]=x[6],q[9]=x[7],q[10]=x[8],q[11]=0,q[12]=l,q[13]=u,q[14]=d?1:0,q[15]=0,q[16]=S,q[17]=C,q[18]=w,q[19]=T,q[20]=E/p,q[21]=D/m,q[22]=0,q[23]=0,q[24]=O/p,q[25]=k/m,q[26]=0,q[27]=0,q[28]=A/p,q[29]=j/m,q[30]=1,q[31]=0;let M=n.acquireAndWriteUniformBuffer(q),N=`bitmap_${f?`s`:`n`}_${d?`r`:`c`}`,P=cd.get(N);P||(P=e.createSampler({magFilter:f?`linear`:`nearest`,minFilter:f?`linear`:`nearest`,addressModeU:d?`repeat`:`clamp-to-edge`,addressModeV:d?`repeat`:`clamp-to-edge`}),cd.set(N,P));let F=r.getBindGroupLayout(`bitmap_fill`);if(!F)return console.error(`[WebGPU] bitmap_fill bind group layout not found`),ku(b),null;fd[0].resource.buffer=M,fd[1].resource=P,fd[2].resource=b.createView();let I=e.createBindGroup({layout:F,entries:fd}),L=()=>{let t=r.getBindGroupLayout(`fill_dynamic`);if(!t)return null;ld[0]=S,ld[1]=C,ld[2]=w,ld[3]=T,ld[4]=E/p,ld[5]=D/m,ld[6]=0,ld[7]=0,ld[8]=O/p,ld[9]=k/m,ld[10]=0,ld[11]=0,ld[12]=A/p,ld[13]=j/m,ld[14]=1,ld[15]=0;let i=n.dynamicUniform.allocate(ld),a=n.dynamicUniform.getBuffer();return(!ud||dd!==a)&&(ud=e.createBindGroup({layout:t,entries:[{binding:0,resource:{buffer:a,size:256}}]}),dd=a),{bindGroup:ud,offset:i}};if(h&&g){let e=r.getPipeline(`stencil_write`);if(e){let n=L();n&&(t.setPipeline(e),t.setStencilReference(0),t.setVertexBuffer(0,y),t.setBindGroup(0,n.bindGroup,[n.offset]),t.draw(v.indexCount,1,0,0))}let n=r.getPipeline(`bitmap_fill_stencil`);n&&(t.setPipeline(n),t.setStencilReference(0),t.setBindGroup(0,I),t.draw(v.indexCount,1,0,0))}else{let e;if(h)e=`bitmap_fill`;else if(g){if(Nl())return ku(b),null;e=`bitmap_fill_bgra_stencil`}else e=`bitmap_fill_bgra`;let n=r.getPipeline(e);if(!n)return console.error(`[WebGPU] ${e} pipeline not found`),ku(b),null;t.setPipeline(n),t.setVertexBuffer(0,y),t.setBindGroup(0,I),g&&!h&&!Nl()&&t.setStencilReference(zl()),t.draw(v.indexCount,1,0,0)}return b},md=(e,t,n)=>{let r=e.length-5;for(let i=3;i<r;i+=3){let r=n*4;e[i+2]?(t[r++]=e[i-3],t[r++]=e[i-2],t[r++]=.5,t[r++]=.5,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=.5,t[r++]=e[i+3],t[r++]=e[i+4],t[r++]=.5,t[r++]=.5):e[i+5]?(t[r++]=e[0],t[r++]=e[1],t[r++]=.5,t[r++]=.5,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=.5,t[r++]=e[i+6],t[r++]=e[i+7],t[r++]=.5,t[r++]=.5):(t[r++]=e[0],t[r++]=e[1],t[r++]=.5,t[r++]=.5,t[r++]=e[i],t[r++]=e[i+1],t[r++]=.5,t[r++]=.5,t[r++]=e[i+3],t[r++]=e[i+4],t[r++]=.5,t[r++]=.5),n+=3}return n},hd=new Float32Array(32),gd=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),_d=(e,t)=>{let n=t/2,r=[];for(let t of e){let e=yu(t,n);for(let t of e)r.push(t)}let i=0;for(let e of r){let t=e.length-5;for(let e=3;e<t;e+=3)i+=3}if(i===0)return{buffer:new Float32Array,indexCount:0};let a=i*4;hd.length<a&&(hd=new Float32Array(gd(a)));let o=hd,s=0;for(let e of r)s=md(e,o,s);return{buffer:o.subarray(0,s*4),indexCount:s}},vd=null,J=new Float32Array(36),yd=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],bd=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{let v=_d(i,a);if(v.indexCount===0)return null;let y=n.acquireVertexBuffer(v.buffer.byteLength,v.buffer),b,x,S=Ru(l,d,f);if(S)b=S.texture,x=S.view;else{let t=Ju(l,d,f),n=qu(l.length/5);b=Ou(e,n,1),e.queue.writeTexture({texture:b},t,{bytesPerRow:n*4,rowsPerImage:1},{width:n,height:1}),x=b.createView(),zu(l,d,f,b,x)}let C=ed(u,o,c),w=s[3]>0?s[3]:1,T=o[0],E=o[1],D=o[3],O=o[4],k=o[6],A=o[7];J[0]=C.inverseMatrix[0],J[1]=C.inverseMatrix[3],J[2]=0,J[3]=0,J[4]=C.inverseMatrix[1],J[5]=C.inverseMatrix[4],J[6]=0,J[7]=0,J[8]=C.inverseMatrix[6],J[9]=C.inverseMatrix[7],J[10]=1,J[11]=0,J[12]=c,J[13]=Math.max(-.975,Math.min(.975,p)),J[14]=d,J[15]=819.2,C.linearPoints?(J[16]=C.linearPoints[0],J[17]=C.linearPoints[1],J[18]=C.linearPoints[2],J[19]=C.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]=T/m,J[25]=E/h,J[26]=0,J[27]=0,J[28]=D/m,J[29]=O/h,J[30]=0,J[31]=0,J[32]=k/m,J[33]=A/h,J[34]=1,J[35]=0;let j=n.acquireAndWriteUniformBuffer(J);vd||=e.createSampler({magFilter:`linear`,minFilter:`linear`,addressModeU:`clamp-to-edge`,addressModeV:`clamp-to-edge`});let M=vd,N=r.getBindGroupLayout(`gradient_fill`);if(!N)return console.error(`[WebGPU] gradient_fill bind group layout not found`),null;yd[0].resource.buffer=j,yd[1].resource=M,yd[2].resource=x;let P=e.createBindGroup({layout:N,entries:yd}),F=_?g?`gradient_stroke_atlas`:`gradient_stroke_bgra`:g?`gradient_fill`:`gradient_fill_bgra`,I=r.getGradientPipeline(F,c,d);return I?(t.setPipeline(I),t.setVertexBuffer(0,y),t.setBindGroup(0,P),t.draw(v.indexCount,1,0,0),null):(console.error(`[WebGPU] ${F} pipeline not found`),null)},xd=new Float32Array(32),Sd=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),Cd=(e,t)=>{let n=t/2,r=[];for(let t of e){let e=yu(t,n);for(let t of e)r.push(t)}let i=0;for(let e of r){let t=e.length-5;for(let e=3;e<t;e+=3)i+=3}if(i===0)return{buffer:new Float32Array,indexCount:0};let a=i*4;xd.length<a&&(xd=new Float32Array(Sd(a)));let o=xd,s=0;for(let e of r)s=md(e,o,s);return{buffer:o.subarray(0,s*4),indexCount:s}},wd=new Map,Y=new Float32Array(32),Td=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Ed=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)=>{let v=Cd(i,a);if(v.indexCount===0)return null;let y=n.acquireVertexBuffer(v.buffer.byteLength,v.buffer),b=Ou(e,u,d);e.queue.writeTexture({texture:b},c.buffer,{bytesPerRow:u*4,rowsPerImage:d,offset:c.byteOffset},{width:u,height:d});let x=sd(l,o),S=s[3]>0?s[3]:1,C=o[0],w=o[1],T=o[3],E=o[4],D=o[6],O=o[7];Y[0]=x[0],Y[1]=x[1],Y[2]=x[2],Y[3]=0,Y[4]=x[3],Y[5]=x[4],Y[6]=x[5],Y[7]=0,Y[8]=x[6],Y[9]=x[7],Y[10]=x[8],Y[11]=0,Y[12]=u,Y[13]=d,Y[14]=f?1:0,Y[15]=0,Y[16]=1,Y[17]=1,Y[18]=1,Y[19]=S,Y[20]=C/m,Y[21]=w/h,Y[22]=0,Y[23]=0,Y[24]=T/m,Y[25]=E/h,Y[26]=0,Y[27]=0,Y[28]=D/m,Y[29]=O/h,Y[30]=1,Y[31]=0;let k=n.acquireAndWriteUniformBuffer(Y),A=`bitmap_${p?`s`:`n`}_${f?`r`:`c`}`,j=wd.get(A);j||(j=e.createSampler({magFilter:p?`linear`:`nearest`,minFilter:p?`linear`:`nearest`,addressModeU:f?`repeat`:`clamp-to-edge`,addressModeV:f?`repeat`:`clamp-to-edge`}),wd.set(A,j));let M=r.getBindGroupLayout(`bitmap_fill`);if(!M)return console.error(`[WebGPU] bitmap_fill bind group layout not found`),ku(b),null;Td[0].resource.buffer=k,Td[1].resource=j,Td[2].resource=b.createView();let N=e.createBindGroup({layout:M,entries:Td}),P=_?g?`bitmap_stroke_atlas`:`bitmap_stroke_bgra`:g?`bitmap_fill`:`bitmap_fill_bgra`,F=r.getPipeline(P);return F?(t.setPipeline(F),t.setVertexBuffer(0,y),t.setBindGroup(0,N),t.draw(v.indexCount,1,0,0),b):(console.error(`[WebGPU] ${P} pipeline not found`),ku(b),null)},Dd=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]),Od=new Float32Array([1,1,1,1,.5,0,0,0,0,.5,0,0,.5,.5,1,0]),kd=(e,t,n,r,i)=>{if(!i)return;let a=i.clipLevel,o=1<<a-1,s=n.acquireVertexBuffer(Dd.byteLength,Dd),c=n.dynamicUniform.allocate(Od),l=r.getBindGroupLayout(`fill_dynamic`);if(!l)return;let u=e.createBindGroup({layout:l,entries:[{binding:0,resource:{buffer:n.dynamicUniform.getBuffer(),size:256}}]}),d=r.getPipeline(`mask_union_merge_${a}`);d&&(t.setPipeline(d),t.setStencilReference(o),t.setVertexBuffer(0,s),t.setBindGroup(0,u,[c]),t.draw(6,1,0,0));let f=r.getPipeline(`mask_union_clear_${a}`);f&&(t.setPipeline(f),t.setStencilReference(0),t.setVertexBuffer(0,s),t.setBindGroup(0,u,[c]),t.draw(6,1,0,0))},Ad=new Float32Array(16),jd=(e,t,n,r,i,a,o,s,c,l=!1)=>{let u=i.clipLevel,d=i.width,f=i.height,p=s[0],m=s[1],h=s[2],g=s[3]*c;if(a.length===0)return;let _=Xl(a);if(_.indexCount===0)return;let v=n.acquireVertexBuffer(_.buffer.byteLength,_.buffer),y=o[0],b=o[1],x=o[3],S=o[4],C=o[6],w=o[7];Ad[0]=p,Ad[1]=m,Ad[2]=h,Ad[3]=g,Ad[4]=y/d,Ad[5]=b/f,Ad[6]=0,Ad[7]=0,Ad[8]=x/d,Ad[9]=S/f,Ad[10]=0,Ad[11]=0,Ad[12]=C/d,Ad[13]=w/f,Ad[14]=1,Ad[15]=0;let T=n.dynamicUniform.allocate(Ad),E=Vl.get(u)??u,D;D=l?`clip_write_main_${Math.min(8,Math.max(1,E))}`:`clip_write`;let O=r.getPipeline(D);if(!O){console.error(`[WebGPU] ${D} pipeline not found`);return}let k=r.getBindGroupLayout(`fill_dynamic`);if(!k)return;let A=e.createBindGroup({layout:k,entries:[{binding:0,resource:{buffer:n.dynamicUniform.getBuffer(),size:256}}]});t.setPipeline(O),t.setStencilReference(0),t.setVertexBuffer(0,v),t.setBindGroup(0,A,[T]),t.draw(_.indexCount,1,0,0),E++,E>8&&(kd(e,t,n,r,i),E=u+1),Vl.set(u,E)},Md=null,Nd=null,Pd=e=>{switch(e){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`}},Fd=(e,t,n,r,i,a,o,s)=>{let c=kl();if(c.count===0)return n;n&&=(n.end(),null);let l=Ll(),u=zl(),d=Pd(bl),f=s.getPipeline(d),p=s.getPipeline(`instanced_masked`),m=l&&p&&(r.msaaStencil?.view||r.stencil?.view),h=m?p:f;if(!h)return console.error(`[WebGPU] Instanced pipeline not found`),null;let g;if(m){let e=r.msaa&&r.msaaTexture?.view,n=e?r.msaaTexture.view:r.texture.view,i=e&&r.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,o=e?r.texture.view:null,s=a.createStencilRenderPassDescriptor(n,i,`load`,`load`,o);g=t.beginRenderPass(s)}else{let e=r.msaa&&r.msaaTexture?.view,n=e?r.msaaTexture.view:r.texture.view,i=e?r.texture.view:null,o=a.createRenderPassDescriptor(n,0,0,0,0,`load`,i);g=t.beginRenderPass(o)}g.setPipeline(h),m&&g.setStencilReference(u);let _=new Float32Array(Qr.buffer.buffer,Qr.buffer.byteOffset,Qr.offset),v=i.acquireVertexBuffer(_.byteLength,_),y=i.getUnitRectBuffer(),b=ul()||a.getAttachment(`atlas`);if(!b)return console.error(`[WebGPU] Atlas attachment not found`),g.end(),null;let x=o.createSampler(`atlas_instanced_sampler`,!1),S=s.getBindGroupLayout(`instanced`);if(!S)return console.error(`[WebGPU] Instanced bind group layout not found`),g.end(),null;let C=b.texture.view;return(!Md||Nd!==C)&&(Md=e.createBindGroup({layout:S,entries:[{binding:0,resource:x},{binding:1,resource:C}]}),Nd=C),g.setVertexBuffer(0,y),g.setVertexBuffer(1,v),g.setBindGroup(0,Md),g.draw(6,c.count,0,0),g.end(),c.clear(),null},Id=null,Ld=null,Rd=(e,t,n,r,i,a,o,s,c=!0,l=!0)=>{let u=kl();if(u.count===0)return n;n&&=(n.end(),null);let d=Ll(),f=zl(),p=(e=>{switch(e){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`}})(bl),m=s.getPipeline(p),h=s.getPipeline(`instanced_masked`),g=d&&h&&(r.msaaStencil?.view||r.stencil?.view),_=g?h:m;if(!_)return console.error(`[WebGPU] Instanced pipeline not found`),null;let v;if(g){let e=r.msaa&&r.msaaTexture?.view,n=e?r.msaaTexture.view:r.texture.view,i=e&&r.msaaStencil?.view?r.msaaStencil.view:r.stencil.view,o=e?r.texture.view:null,s=a.createStencilRenderPassDescriptor(n,i,`load`,`load`,o);v=t.beginRenderPass(s)}else{let e=r.msaa&&r.msaaTexture?.view,n=e?r.msaaTexture.view:r.texture.view,i=e?r.texture.view:null,o=a.createRenderPassDescriptor(n,0,0,0,0,`load`,i);v=t.beginRenderPass(o)}v.setPipeline(_),g&&v.setStencilReference(f);let y=new Float32Array(Qr.buffer.buffer,Qr.buffer.byteOffset,Qr.offset),b;l?(b=i.acquireStorageBuffer(y.byteLength),i.writeStorageBuffer(b,y)):b=i.acquireVertexBuffer(y.byteLength,y);let x=i.getUnitRectBuffer(),S=ul()||a.getAttachment(`atlas`);if(!S)return console.error(`[WebGPU] Atlas attachment not found`),v.end(),null;let C=o.createSampler(`atlas_instanced_sampler`,!1),w=s.getBindGroupLayout(`instanced`);if(!w)return console.error(`[WebGPU] Instanced bind group layout not found`),v.end(),null;let T=S.texture.view;if((!Id||Ld!==T)&&(Id=e.createBindGroup({layout:w,entries:[{binding:0,resource:C},{binding:1,resource:T}]}),Ld=T),v.setVertexBuffer(0,x),v.setVertexBuffer(1,b),v.setBindGroup(0,Id),c){let e=i.createIndirectBuffer(6,u.count,0,0);v.drawIndirect(e,0)}else v.draw(6,u.count,0,0);return v.end(),u.clear(),null},zd=new Float32Array(12),Bd=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Vd=(e,t,n,r,i)=>{let{device:a,commandEncoder:o,frameBufferManager:s,pipelineManager:c,textureManager:l}=i,u=Math.max(e.width,t.width),d=Math.max(e.height,t.height),f=s.createTemporaryAttachment(u,d),p=c.getPipeline(`complex_blend`),m=c.getBindGroupLayout(`complex_blend`);if(!p||!m)return console.error(`[WebGPU ComplexBlend] Pipeline not found for blend mode: ${n}`),e;let h=l.createSampler(`complex_blend_sampler`,!0),g=G.getBlendModeIndex(n);zd[0]=r[0],zd[1]=r[1],zd[2]=r[2],zd[3]=r[3],zd[4]=r[4],zd[5]=r[5],zd[6]=r[6],zd[7]=r[7],zd[8]=g,zd[9]=0,zd[10]=0,zd[11]=0;let _=i.bufferManager?i.bufferManager.acquireAndWriteUniformBuffer(zd):a.createBuffer({size:48,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});i.bufferManager||a.queue.writeBuffer(_,0,zd),Bd[0].resource.buffer=_,Bd[1].resource=h,Bd[2].resource=t.texture.view,Bd[3].resource=e.texture.view;let v=a.createBindGroup({layout:m,entries:Bd}),y=s.createRenderPassDescriptor(f.texture.view,0,0,0,0,`clear`),b=o.beginRenderPass(y);return b.setPipeline(p),b.setBindGroup(0,v),b.draw(6,1,0,0),b.end(),f},Hd=new Float32Array(4),Ud=new Float32Array(6),Wd=new Float32Array(8),Gd=new Float32Array(12),Kd=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],qd=(e,t,n,r,i,a,o,s,c,l,u,d,f,p)=>{let m=f.getPipeline(`complex_blend_copy`),h=f.getBindGroupLayout(`texture_copy`);if(!m||!h)return;Hd[0]=c/o,Hd[1]=l/s,Hd[2]=i/o,Hd[3]=a/s;let g=p.acquireAndWriteUniformBuffer(Hd),_=d.createSampler(`complex_blend_copy_sampler`,!1);Kd[0].resource.buffer=g,Kd[1].resource=_,Kd[2].resource=n;let v=e.createBindGroup({layout:h,entries:Kd}),y=u.createRenderPassDescriptor(r.texture.view,0,0,0,0,`clear`),b=t.beginRenderPass(y);b.setPipeline(m),b.setBindGroup(0,v),b.draw(6,1,0,0),b.end()},Jd=(e,t,n,r,i,a,o,s,c,l)=>{let u=r.msaa&&r.msaaTexture?.view,d=u?`complex_blend_output_msaa`:`complex_blend_output`,f=c.getPipeline(d),p=c.getBindGroupLayout(`positioned_texture`);if(!f||!p)return;Wd[0]=i,Wd[1]=a,Wd[2]=n.width,Wd[3]=n.height,Wd[4]=r.width,Wd[5]=r.height,Wd[6]=0,Wd[7]=0;let m=l.acquireAndWriteUniformBuffer(Wd),h=s.createSampler(`complex_blend_output_sampler`,!1);Kd[0].resource.buffer=m,Kd[1].resource=h,Kd[2].resource=n.texture.view;let g=e.createBindGroup({layout:p,entries:Kd}),_=u?r.msaaTexture.view:r.texture.view,v=u?r.texture.view:null,y=o.createRenderPassDescriptor(_,0,0,0,0,`load`,v),b=t.beginRenderPass(y);b.setPipeline(f),b.setBindGroup(0,g),b.draw(6,1,0,0),b.end()},Yd=(e,t,n,r,i,a,o)=>{let s=El();if(s.length===0)return;if(!n||!n.texture){Dl();return}let c=ul()||r.getAttachment(`atlas`);if(!c||!c.texture){Dl();return}for(let l of s){let{node:s,x_min:u,y_min:d,x_max:f,y_max:p,color_transform:m,matrix:h,blend_mode:g,global_alpha:_}=l,v=Math.ceil(Math.abs(f-u)),y=Math.ceil(Math.abs(p-d));if(v<=0||y<=0)continue;let b=Math.max(0,Math.floor(h[6])),x=Math.max(0,Math.floor(h[7]));if(b>=n.width||x>=n.height)continue;let S=h[0]!==1||h[1]!==0||h[3]!==0||h[4]!==1,C=S?v:s.w,w=S?y:s.h,T=Math.min(C,n.width-b),E=Math.min(w,n.height-x);if(T<=0||E<=0)continue;let D;if(S){D=r.createTemporaryAttachment(C,w);let n=a.getPipeline(`complex_blend_scale`),l=a.getBindGroupLayout(`texture_scale`);if(n&&l){let a=C/2,u=w/2,d=s.w/2,f=s.h/2;Ud[0]=h[0],Ud[1]=h[1],Ud[2]=h[3],Ud[3]=h[4],Ud[4]=-d*h[0]-f*h[3]+a,Ud[5]=-d*h[1]-f*h[4]+u;let p=r.createTemporaryAttachment(s.w,s.h);t.copyTextureToTexture({texture:c.texture.resource,origin:{x:s.x,y:s.y,z:0}},{texture:p.texture.resource,origin:{x:0,y:0,z:0}},{width:s.w,height:s.h}),Gd[0]=Ud[0],Gd[1]=Ud[1],Gd[2]=Ud[2],Gd[3]=Ud[3],Gd[4]=Ud[4],Gd[5]=Ud[5],Gd[6]=s.w,Gd[7]=s.h,Gd[8]=C,Gd[9]=w,Gd[10]=0,Gd[11]=0;let m=o.acquireAndWriteUniformBuffer(Gd,48),g=i.createSampler(`scale_sampler`,!0);Kd[0].resource.buffer=m,Kd[1].resource=g,Kd[2].resource=p.texture.view;let _=e.createBindGroup({layout:l,entries:Kd}),v=r.createRenderPassDescriptor(D.texture.view,0,0,0,0,`clear`),y=t.beginRenderPass(v);y.setPipeline(n),y.setBindGroup(0,_),y.draw(6,1,0,0),y.end(),r.releaseTemporaryAttachment(p)}else t.copyTextureToTexture({texture:c.texture.resource,origin:{x:s.x,y:s.y,z:0}},{texture:D.texture.resource,origin:{x:0,y:0,z:0}},{width:Math.min(s.w,C),height:Math.min(s.h,w)})}else D=r.createTemporaryAttachment(C,w),t.copyTextureToTexture({texture:c.texture.resource,origin:{x:s.x,y:s.y,z:0}},{texture:D.texture.resource,origin:{x:0,y:0,z:0}},{width:C,height:w});let O=r.createTemporaryAttachment(C,w);qd(e,t,n.texture.view,O,b,x,n.width,n.height,C,w,r,i,a,o),Wd[0]=m[0],Wd[1]=m[1],Wd[2]=m[2],Wd[3]=_,Wd[4]=m[4],Wd[5]=m[5],Wd[6]=m[6],Wd[7]=0;let k=Vd(D,O,g,Wd,{device:e,commandEncoder:t,bufferManager:o,frameBufferManager:r,pipelineManager:a,textureManager:i,frameTextures:[]});Jd(e,t,k,n,b,x,r,i,a,o),r.releaseTemporaryAttachment(D),r.releaseTemporaryAttachment(O),r.releaseTemporaryAttachment(k)}Dl()},X={x:0,y:0},Xd=[.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],Zd=(e,t,n,r,i)=>{let a=Math.sqrt(e[0]*e[0]+e[1]*e[1]),o=Math.sqrt(e[2]*e[2]+e[3]*e[3]),s=a/i*t,c=o/i*n,l=Xd[Math.min(r-1,Xd.length-1)],u=Math.round(s*l),d=Math.round(c*l),f=1,p=1;return s>128?f=.0625:s>64?f=.125:s>32?f=.25:s>16&&(f=.5),c>128?p=.0625:c>64?p=.125:c>32?p=.25:c>16&&(p=.5),{baseBlurX:s,baseBlurY:c,offsetX:u,offsetY:d,bufferScaleX:f,bufferScaleY:p}},Qd=(e,t,n,r)=>{let i=Math.ceil(t*.5),a=1-(i-t*.5),o=1+t;return{offsetX:e?1/n:0,offsetY:e?0:1/r,fraction:a,samples:o,halfBlur:i}},$d=new Float32Array(4),ef=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],tf=(e,t,n,r,i,a,o)=>{let{device:s,commandEncoder:c,frameBufferManager:l,pipelineManager:u,textureManager:d}=o,{baseBlurX:f,baseBlurY:p,offsetX:m,offsetY:h,bufferScaleX:g,bufferScaleY:_}=Zd(t,n,r,i,a);X.x+=m,X.y+=h;let v=e.width+m*2,y=e.height+h*2,b=Math.ceil(v*g),x=Math.ceil(y*_),S=l.createTemporaryAttachment(b,x),C=l.createTemporaryAttachment(b,x),w=d.createSampler(`blur_sampler`,!0);nf(s,c,l,u,e,S,w,g,_,m*g,h*_,o.bufferManager);let T=f*g,E=p*_,D=[S,C],O=0;for(let e=0;e<i;++e){if(n>0){let e=O;O=(O+1)%2,rf(s,c,l,u,D[e],D[O],w,!0,T,o.bufferManager)}if(r>0){let e=O;O=(O+1)%2,rf(s,c,l,u,D[e],D[O],w,!1,E,o.bufferManager)}}let k=D[O];if(g!==1||_!==1){let e=l.createTemporaryAttachment(v,y);af(s,c,l,u,k,e,w,o.bufferManager),l.releaseTemporaryAttachment(S),l.releaseTemporaryAttachment(C),k=e}else{let e=(O+1)%2;l.releaseTemporaryAttachment(D[e])}return k},nf=(e,t,n,r,i,a,o,s,c,l,u,d)=>{let f=r.getPipeline(`texture_copy_rgba8`),p=r.getBindGroupLayout(`texture_copy`);if(!f||!p){console.error(`[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found`);return}let m=i.width*s,h=i.height*c;$d[0]=1,$d[1]=1,$d[2]=0,$d[3]=0;let g=d?d.acquireAndWriteUniformBuffer($d):e.createBuffer({size:$d.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});d||e.queue.writeBuffer(g,0,$d),ef[0].resource.buffer=g,ef[1].resource=o,ef[2].resource=i.texture.view;let _=e.createBindGroup({layout:p,entries:ef}),v=n.createRenderPassDescriptor(a.texture.view,0,0,0,0,`clear`),y=t.beginRenderPass(v);y.setPipeline(f),y.setBindGroup(0,_),y.setViewport(l,u,m,h,0,1),y.setScissorRect(Math.floor(l),Math.floor(u),Math.ceil(m),Math.ceil(h)),y.draw(6,1,0,0),y.end()},rf=(e,t,n,r,i,a,o,s,c,l)=>{let{offsetX:u,offsetY:d,fraction:f,samples:p,halfBlur:m}=Qd(s,c,i.width,i.height),h=Math.max(1,Math.min(16,m)),g=r.getPipeline(`blur_filter_${h}`),_=r.getBindGroupLayout(`blur_filter`);if(!g||!_){console.error(`[WebGPU BlurFilter] blur_filter_${h} pipeline not found`);return}$d[0]=u,$d[1]=d,$d[2]=f,$d[3]=p;let v=l?l.acquireAndWriteUniformBuffer($d):e.createBuffer({size:$d.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l||e.queue.writeBuffer(v,0,$d),ef[0].resource.buffer=v,ef[1].resource=o,ef[2].resource=i.texture.view;let y=e.createBindGroup({layout:_,entries:ef}),b=n.createRenderPassDescriptor(a.texture.view,0,0,0,0,`clear`),x=t.beginRenderPass(b);x.setPipeline(g),x.setBindGroup(0,y),x.draw(6,1,0,0),x.end()},af=(e,t,n,r,i,a,o,s)=>{let c=r.getPipeline(`texture_copy_rgba8`),l=r.getBindGroupLayout(`texture_copy`);if(!c||!l){console.error(`[WebGPU BlurFilter] texture_copy_rgba8 pipeline not found`);return}$d[0]=1,$d[1]=1,$d[2]=0,$d[3]=0;let u=s?s.acquireAndWriteUniformBuffer($d):e.createBuffer({size:$d.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});s||e.queue.writeBuffer(u,0,$d),ef[0].resource.buffer=u,ef[1].resource=o,ef[2].resource=i.texture.view;let d=e.createBindGroup({layout:l,entries:ef}),f=n.createRenderPassDescriptor(a.texture.view,0,0,0,0,`clear`),p=t.beginRenderPass(f);p.setPipeline(c),p.setBindGroup(0,d),p.draw(6,1,0,0),p.end()},of=new Float32Array(20),sf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],cf=(e,t,n)=>{let{device:r,commandEncoder:i,frameBufferManager:a,pipelineManager:o,textureManager:s}=n,c=a.createTemporaryAttachment(e.width,e.height),l=o.getPipeline(`color_matrix_filter`),u=o.getBindGroupLayout(`color_matrix_filter`);if(!l||!u)return console.error(`[WebGPU ColorMatrixFilter] Pipeline not found`),e;let d=s.createSampler(`color_matrix_sampler`,!0);of[0]=t[0],of[1]=t[5],of[2]=t[10],of[3]=t[15],of[4]=t[1],of[5]=t[6],of[6]=t[11],of[7]=t[16],of[8]=t[2],of[9]=t[7],of[10]=t[12],of[11]=t[17],of[12]=t[3],of[13]=t[8],of[14]=t[13],of[15]=t[18],of[16]=t[4]/255,of[17]=t[9]/255,of[18]=t[14]/255,of[19]=t[19]/255;let f=n.bufferManager?n.bufferManager.acquireAndWriteUniformBuffer(of):r.createBuffer({size:of.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});n.bufferManager||r.queue.writeBuffer(f,0,of),sf[0].resource.buffer=f,sf[1].resource=d,sf[2].resource=e.texture.view;let p=r.createBindGroup({layout:u,entries:sf}),m=a.createRenderPassDescriptor(c.texture.view,0,0,0,0,`clear`),h=i.beginRenderPass(m);return h.setPipeline(l),h.setBindGroup(0,p),h.draw(6,1,0,0),h.end(),c},lf=Math.PI/180,uf=(e,t)=>[(e>>16&255)/255*t,(e>>8&255)/255*t,(e&255)/255*t,t],df=(e,t)=>[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255,t],ff=new Float32Array(16),pf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],mf=(e,t,n,r,i,a,o,s,c,l,u,d)=>{let{device:f,commandEncoder:p,frameBufferManager:m,pipelineManager:h,textureManager:g}=d,_=X.x,v=X.y,y=e.width,b=e.height,x=tf(e,t,i,a,s,u,d),S=x.width,C=x.height,w=X.x,T=X.y,E=c?y:S,D=c?b:C,O=w-_,k=T-v,A=c?0:O,j=c?0:k,M=c?-O:0,N=c?-k:0,P=E/y,F=D/b,I=A/y,L=j/b,R=E/S,z=D/C,ee=M/S,te=N/C,ne=m.createTemporaryAttachment(E,D),re=h.getFilterPipeline(`glow_filter`,{IS_INNER:c?1:0,IS_KNOCKOUT:l?1:0}),ie=h.getBindGroupLayout(`glow_filter`);if(!re||!ie)return console.error(`[WebGPU GlowFilter] Pipeline not found`),m.releaseTemporaryAttachment(x),e;let ae=g.createSampler(`glow_sampler`,!0),[oe,se,B,ce]=uf(n,r);ff[0]=oe,ff[1]=se,ff[2]=B,ff[3]=ce,ff[4]=P,ff[5]=F,ff[6]=I,ff[7]=L,ff[8]=R,ff[9]=z,ff[10]=ee,ff[11]=te,ff[12]=o,ff[13]=c?1:0,ff[14]=l?1:0,ff[15]=0;let le=d.bufferManager?d.bufferManager.acquireAndWriteUniformBuffer(ff):f.createBuffer({size:ff.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});d.bufferManager||f.queue.writeBuffer(le,0,ff),pf[0].resource.buffer=le,pf[1].resource=ae,pf[2].resource=x.texture.view,pf[3].resource=e.texture.view;let ue=f.createBindGroup({layout:ie,entries:pf}),de=m.createRenderPassDescriptor(ne.texture.view,0,0,0,0,`clear`),fe=p.beginRenderPass(de);return fe.setPipeline(re),fe.setBindGroup(0,ue),fe.draw(6,1,0,0),fe.end(),m.releaseTemporaryAttachment(x),ne},hf=new Float32Array(16),gf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],_f=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let{device:h,commandEncoder:g,frameBufferManager:_,pipelineManager:v,textureManager:y}=m,b=X.x,x=X.y,S=e.width,C=e.height,w=tf(e,t,o,s,l,p,m),T=w.width,E=w.height,D=X.x,O=X.y,k=D-b,A=O-x,j=Math.sqrt(t[0]*t[0]+t[1]*t[1]),M=Math.sqrt(t[2]*t[2]+t[3]*t[3]),N=r*lf,P=Math.cos(N)*n*(j/p),F=Math.sin(N)*n*(M/p),I=u?S:T+Math.max(0,Math.abs(P)-k),L=u?C:E+Math.max(0,Math.abs(F)-A),R=Math.ceil(I),z=Math.ceil(L),ee=(R-I)/2,te=(z-L)/2,ne=u?0:Math.max(0,k-P)+ee,re=u?0:Math.max(0,A-F)+te,ie=u?P-D:(P>0?Math.max(0,P-k):0)+ee,ae=u?F-O:(F>0?Math.max(0,F-A):0)+te,oe=_.createTemporaryAttachment(R,z),se=u,B=d,ce=f;u?B=d||f:!d&&f&&(B=!0,ce=!0);let le=v.getFilterPipeline(`drop_shadow_filter`,{IS_INNER:se?1:0,IS_KNOCKOUT:B?1:0,IS_HIDE_OBJECT:ce?1:0}),ue=v.getBindGroupLayout(`drop_shadow_filter`);if(!le||!ue)return console.error(`[WebGPU DropShadowFilter] Pipeline not found`),_.releaseTemporaryAttachment(w),e;let de=y.createSampler(`drop_shadow_sampler`,!0),[fe,pe,me,he]=uf(i,a),ge=R/S,V=z/C,_e=ne/S,ve=re/C,ye=R/T,be=z/E,xe=ie/T,Se=ae/E;hf[0]=fe,hf[1]=pe,hf[2]=me,hf[3]=he,hf[4]=ge,hf[5]=V,hf[6]=_e,hf[7]=ve,hf[8]=ye,hf[9]=be,hf[10]=xe,hf[11]=Se,hf[12]=c,hf[13]=se?1:0,hf[14]=B?1:0,hf[15]=ce?1:0;let Ce=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(hf):h.createBuffer({size:hf.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||h.queue.writeBuffer(Ce,0,hf),gf[0].resource.buffer=Ce,gf[1].resource=de,gf[2].resource=w.texture.view,gf[3].resource=e.texture.view;let we=h.createBindGroup({layout:ue,entries:gf}),Te=_.createRenderPassDescriptor(oe.texture.view,0,0,0,0,`clear`),Ee=g.beginRenderPass(Te);return Ee.setPipeline(le),Ee.setBindGroup(0,we),Ee.draw(6,1,0,0),Ee.end(),_.releaseTemporaryAttachment(w),oe},vf=new Float32Array(8),yf=new Float32Array(20),bf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],xf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],Sf=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>{let{device:g,commandEncoder:_,frameBufferManager:v,pipelineManager:y,textureManager:b}=h,x=X.x,S=X.y,C=e.width,w=e.height,T=Math.sqrt(t[0]*t[0]+t[1]*t[1]),E=Math.sqrt(t[2]*t[2]+t[3]*t[3]),D=r*lf,O=Math.cos(D)*n*(T/m),k=Math.sin(D)*n*(E/m),A=v.createTemporaryAttachment(C,w);_.copyTextureToTexture({texture:e.texture.resource,origin:{x:0,y:0,z:0}},{texture:A.texture.resource,origin:{x:0,y:0,z:0}},{width:C,height:w});let j=y.getPipeline(`texture_erase`),M=y.getBindGroupLayout(`texture_copy`);if(j&&M){let t=b.createSampler(`erase_sampler`,!0),n=O*2/C,r=k*2/w;vf[0]=1,vf[1]=1,vf[2]=n,vf[3]=r,vf[4]=0,vf[5]=0,vf[6]=0,vf[7]=0;let i=h.bufferManager?h.bufferManager.acquireAndWriteUniformBuffer(vf):g.createBuffer({size:vf.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.bufferManager||g.queue.writeBuffer(i,0,vf),bf[0].resource.buffer=i,bf[1].resource=t,bf[2].resource=e.texture.view;let a=g.createBindGroup({layout:M,entries:bf}),o=v.createRenderPassDescriptor(A.texture.view,0,0,0,0,`load`),s=_.beginRenderPass(o);s.setPipeline(j),s.setBindGroup(0,a),s.draw(6,1,0,0),s.end()}let N=tf(A,t,c,l,d,m,h);v.releaseTemporaryAttachment(A);let P=N.width,F=N.height,I=Math.abs(O),L=Math.abs(k),R=f===1,z=Math.ceil(P+I*2),ee=Math.ceil(F+L*2),te=R?C:z,ne=R?w:ee,re=(P-C)/2,ie=(F-w)/2,ae=R?0:Math.floor(I+re),oe=R?0:Math.floor(L+ie),se=Math.floor(R?-re-O:I-O),B=Math.floor(R?-ie-k:L-k),ce=te/C,le=ne/w,ue=ae/C,de=oe/w,fe=te/P,pe=ne/F,me=se/P,he=B/F,ge=v.createTemporaryAttachment(te,ne),V=y.getFilterPipeline(`bevel_filter`,{BEVEL_TYPE:f,IS_KNOCKOUT:p?1:0}),_e=y.getBindGroupLayout(`bevel_filter`);if(!V||!_e)return console.error(`[WebGPU BevelFilter] Pipeline not found`),v.releaseTemporaryAttachment(N),e;let ve=b.createSampler(`bevel_sampler`,!0),[ye,be,xe,Se]=uf(i,a),[Ce,we,Te,Ee]=uf(o,s);yf[0]=ye,yf[1]=be,yf[2]=xe,yf[3]=Se,yf[4]=Ce,yf[5]=we,yf[6]=Te,yf[7]=Ee,yf[8]=u,yf[9]=R?1:0,yf[10]=p?1:0,yf[11]=f,yf[12]=ce,yf[13]=le,yf[14]=ue,yf[15]=de,yf[16]=fe,yf[17]=pe,yf[18]=me,yf[19]=he;let De=h.bufferManager?h.bufferManager.acquireAndWriteUniformBuffer(yf):g.createBuffer({size:yf.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.bufferManager||g.queue.writeBuffer(De,0,yf),xf[0].resource.buffer=De,xf[1].resource=ve,xf[2].resource=N.texture.view,xf[3].resource=e.texture.view;let Oe=g.createBindGroup({layout:_e,entries:xf}),H=v.createRenderPassDescriptor(ge.texture.view,0,0,0,0,`clear`),ke=_.beginRenderPass(H);return ke.setPipeline(V),ke.setBindGroup(0,Oe),ke.draw(6,1,0,0),ke.end(),v.releaseTemporaryAttachment(N),X.x=x+ae,X.y=S+oe,ge},Cf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],wf=new Map,Tf=(e,t,n,r,i,a,o,s,c,l,u)=>{let{device:d,commandEncoder:f,frameBufferManager:p,textureManager:m}=u,h=e.width,g=e.height,_=p.createTemporaryAttachment(h,g),v=`${t},${n},${o},${s}`,y=wf.get(v);if(!y){let e=G.getConvolutionFilterFragmentShader(t,n,o,s),r=d.createShaderModule({code:e}),i=d.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.FRAGMENT,buffer:{type:`uniform`}},{binding:1,visibility:GPUShaderStage.FRAGMENT,sampler:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{}}]}),a=d.createPipelineLayout({bindGroupLayouts:[i]});y={pipeline:d.createRenderPipeline({layout:a,vertex:{module:r,entryPoint:`vs_main`,buffers:[]},fragment:{module:r,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:i},wf.set(v,y)}let b=m.createSampler(`convolution_sampler`,!0),x=t*n,S=Math.ceil(x/4),[C,w,T,E]=df(c,l),D=new Float32Array(S*4);for(let e=0;e<x;e++)D[e]=r[e];let O=32+S*16,k=new Float32Array(O/4);k[0]=1/h,k[1]=1/g,k[2]=i===0?1:1/i,k[3]=a/255,k[4]=C,k[5]=w,k[6]=T,k[7]=E;for(let e=0;e<D.length;e++)k[8+e]=D[e];let A=u.bufferManager?u.bufferManager.acquireAndWriteUniformBuffer(k):d.createBuffer({size:k.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});u.bufferManager||d.queue.writeBuffer(A,0,k),Cf[0].resource.buffer=A,Cf[1].resource=b,Cf[2].resource=e.texture.view;let j=d.createBindGroup({layout:y.bindGroupLayout,entries:Cf}),M=p.createRenderPassDescriptor(_.texture.view,0,0,0,0,`clear`),N=f.beginRenderPass(M);return N.setPipeline(y.pipeline),N.setBindGroup(0,j),N.draw(6,1,0,0),N.end(),_},Ef=new Float32Array(4),Df=new Float32Array(12),Of=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],kf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null},{binding:4,resource:null}],Af=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let{device:h,commandEncoder:g,frameBufferManager:_,pipelineManager:v,textureManager:y}=m,b=X.x,x=X.y,S=e.width,C=e.height,w=Math.sqrt(t[0]*t[0]+t[1]*t[1]),T=Math.sqrt(t[2]*t[2]+t[3]*t[3]),E=r*lf,D=Math.cos(E)*n*(w/p),O=Math.sin(E)*n*(T/p),k=v.getPipeline(`bevel_base`),A=v.getBindGroupLayout(`bevel_base`);if(!k||!A)return console.error(`[WebGPU GradientBevelFilter] bevel_base pipeline not found`),e;let j=_.createTemporaryAttachment(S,C),M=y.createSampler(`bevel_base_sampler`,!0);Ef[0]=2*D/S,Ef[1]=2*O/C,Ef[2]=0,Ef[3]=0;let N=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Ef):h.createBuffer({size:Ef.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||h.queue.writeBuffer(N,0,Ef),Of[0].resource.buffer=N,Of[1].resource=M,Of[2].resource=e.texture.view;let P=h.createBindGroup({layout:A,entries:Of}),F=_.createRenderPassDescriptor(j.texture.view,0,0,0,0,`clear`),I=g.beginRenderPass(F);I.setPipeline(k),I.setBindGroup(0,P),I.draw(6,1,0,0),I.end();let L=tf(j,t,s,c,u,p,m);_.releaseTemporaryAttachment(j);let R=L.width,z=L.height,ee=d===1,te=Math.abs(D),ne=Math.abs(O),re=(R-S)/2,ie=(z-C)/2,ae=Math.ceil(R+te*2),oe=Math.ceil(z+ne*2),se=ee?S:ae,B=ee?C:oe,ce=ee?0:te+re,le=ee?0:ne+ie,ue=ee?-re-D:te-D,de=ee?-ie-O:ne-O,fe=$u(o,i,a),pe=h.createTexture({size:{width:256,height:1},format:`rgba8unorm`,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});h.queue.writeTexture({texture:pe},fe.buffer,{bytesPerRow:256*4,offset:fe.byteOffset},{width:256,height:1});let me=pe.createView(),he=se/S,ge=B/C,V=ce/S,_e=le/C,ve=se/R,ye=B/z,be=ue/R,xe=de/z,Se=_.createTemporaryAttachment(se,B),Ce=v.getFilterPipeline(`gradient_bevel_filter`,{BEVEL_TYPE:d,IS_KNOCKOUT:f?1:0}),we=v.getBindGroupLayout(`gradient_bevel_filter`);if(!Ce||!we)return console.error(`[WebGPU GradientBevelFilter] Pipeline not found`),_.releaseTemporaryAttachment(L),e;let Te=y.createSampler(`gradient_bevel_sampler`,!0);Df[0]=l,Df[1]=ee?1:0,Df[2]=f?1:0,Df[3]=d,Df[4]=he,Df[5]=ge,Df[6]=V,Df[7]=_e,Df[8]=ve,Df[9]=ye,Df[10]=be,Df[11]=xe;let Ee=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(Df):h.createBuffer({size:Df.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||h.queue.writeBuffer(Ee,0,Df),kf[0].resource.buffer=Ee,kf[1].resource=Te,kf[2].resource=L.texture.view,kf[3].resource=e.texture.view,kf[4].resource=me;let De=h.createBindGroup({layout:we,entries:kf}),Oe=_.createRenderPassDescriptor(Se.texture.view,0,0,0,0,`clear`),H=g.beginRenderPass(Oe);return H.setPipeline(Ce),H.setBindGroup(0,De),H.draw(6,1,0,0),H.end(),m.frameTextures.push(pe),_.releaseTemporaryAttachment(L),X.x=b+ce,X.y=x+le,Se},jf=new Float32Array(12),Mf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null},{binding:4,resource:null}],Nf=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let{device:h,commandEncoder:g,frameBufferManager:_,pipelineManager:v,textureManager:y}=m,b=X.x,x=X.y,S=e.width,C=e.height,w=tf(e,t,s,c,u,p,m),T=w.width,E=w.height,D=X.x,O=X.y,k=D-b,A=O-x,j=Math.sqrt(t[0]*t[0]+t[1]*t[1]),M=Math.sqrt(t[2]*t[2]+t[3]*t[3]),N=r*lf,P=Math.cos(N)*n*(j/p),F=Math.sin(N)*n*(M/p),I=d===1,L=I?S:T+Math.max(0,Math.abs(P)-k),R=I?C:E+Math.max(0,Math.abs(F)-A),z=Math.ceil(L),ee=Math.ceil(R),te=(z-L)/2,ne=(ee-R)/2,re=I?0:Math.max(0,k-P)+te,ie=I?0:Math.max(0,A-F)+ne,ae=I?P-D:(P>0?Math.max(0,P-k):0)+te,oe=I?F-O:(F>0?Math.max(0,F-A):0)+ne,se=$u(o,i,a),B=h.createTexture({size:{width:256,height:1},format:`rgba8unorm`,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});h.queue.writeTexture({texture:B},se.buffer,{bytesPerRow:256*4,offset:se.byteOffset},{width:256,height:1});let ce=B.createView(),le=z/S,ue=ee/C,de=re/S,fe=ie/C,pe=z/T,me=ee/E,he=ae/T,ge=oe/E,V=_.createTemporaryAttachment(z,ee),_e=v.getFilterPipeline(`gradient_glow_filter`,{GLOW_TYPE:d,IS_KNOCKOUT:f?1:0}),ve=v.getBindGroupLayout(`gradient_glow_filter`);if(!_e||!ve)return console.error(`[WebGPU GradientGlowFilter] Pipeline not found`),_.releaseTemporaryAttachment(w),e;let ye=y.createSampler(`gradient_glow_sampler`,!0);jf[0]=l,jf[1]=I?1:0,jf[2]=f?1:0,jf[3]=d,jf[4]=le,jf[5]=ue,jf[6]=de,jf[7]=fe,jf[8]=pe,jf[9]=me,jf[10]=he,jf[11]=ge;let be=m.bufferManager?m.bufferManager.acquireAndWriteUniformBuffer(jf):h.createBuffer({size:jf.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});m.bufferManager||h.queue.writeBuffer(be,0,jf),Mf[0].resource.buffer=be,Mf[1].resource=ye,Mf[2].resource=w.texture.view,Mf[3].resource=e.texture.view,Mf[4].resource=ce;let xe=h.createBindGroup({layout:ve,entries:Mf}),Se=_.createRenderPassDescriptor(V.texture.view,0,0,0,0,`clear`),Ce=g.beginRenderPass(Se);return Ce.setPipeline(_e),Ce.setBindGroup(0,xe),Ce.draw(6,1,0,0),Ce.end(),m.frameTextures.push(B),_.releaseTemporaryAttachment(w),X.x=b+re,X.y=x+ie,V},Pf=new Float32Array(12),Ff=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null},{binding:3,resource:null}],If=new Map,Lf=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)=>{let{device:g,commandEncoder:_,frameBufferManager:v,textureManager:y}=h,b=e.width,x=e.height,S=r,C=i,w=v.createTemporaryAttachment(b,x),T=g.createTexture({size:{width:r,height:i},format:`rgba8unorm`,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST});g.queue.writeTexture({texture:T},n.buffer,{bytesPerRow:r*4,offset:n.byteOffset},{width:r,height:i});let E=`${s},${c},${d}`,D=If.get(E);if(!D){let e=G.getDisplacementMapFilterFragmentShader(s,c,d),t=g.createShaderModule({code:G.getBlurFilterVertexShader()}),n=g.createShaderModule({code:e}),r=g.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:{}}]}),i=g.createPipelineLayout({bindGroupLayouts:[r]});D={pipeline:g.createRenderPipeline({layout:i,vertex:{module:t,entryPoint:`main`,buffers:[]},fragment:{module:n,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:r},If.set(E,D)}let O=y.createSampler(`displacement_sampler`,!0),k=d===1,A=k?48:32;if(Pf[0]=S/r,Pf[1]=C/i,Pf[2]=a/r,Pf[3]=(C-i-o)/i,Pf[4]=l/S,Pf[5]=u/C,Pf[6]=0,Pf[7]=0,k){let[e,t,n,r]=uf(f,p);Pf[8]=e,Pf[9]=t,Pf[10]=n,Pf[11]=r}let j=h.bufferManager?h.bufferManager.acquireAndWriteUniformBuffer(Pf,A):g.createBuffer({size:A,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.bufferManager||g.queue.writeBuffer(j,0,Pf,0,A/4),Ff[0].resource.buffer=j,Ff[1].resource=O,Ff[2].resource=e.texture.view,Ff[3].resource=T.createView();let M=g.createBindGroup({layout:D.bindGroupLayout,entries:Ff}),N=v.createRenderPassDescriptor(w.texture.view,0,0,0,0,`clear`),P=_.beginRenderPass(N);return P.setPipeline(D.pipeline),P.setBindGroup(0,M),P.draw(6,1,0,0),P.end(),h.frameTextures.push(T),w},Rf=new Float32Array(4),zf=new Float32Array(6),Bf=new Float32Array(6),Z=new Float32Array(8),Vf=new Float32Array(12),Hf=new Float32Array(20),Uf=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],Wf=new Set([`normal`,`layer`,`add`,`screen`,`alpha`,`erase`,`copy`]),Gf=new Float32Array([1,-1,0,1]),Kf=e=>e[0]===1&&e[1]===1&&e[2]===1&&e[3]===1&&e[4]===0&&e[5]===0&&e[6]===0&&e[7]===0,qf=(e,t,n)=>{let r=e.frameBufferManager.createTemporaryAttachment(t.width,t.height),i=e.pipelineManager.getPipeline(`color_transform`),a=e.pipelineManager.getBindGroupLayout(`texture_copy`);if(!i||!a||!t.texture||!r.texture)return t;Z[0]=n[0],Z[1]=n[1],Z[2]=n[2],Z[3]=n[3],Z[4]=n[4],Z[5]=n[5],Z[6]=n[6],Z[7]=0;let o=e.bufferManager.acquireAndWriteUniformBuffer(Z),s=e.textureManager.createSampler(`color_transform_sampler`,!1);Uf[0].resource.buffer=o,Uf[1].resource=s,Uf[2].resource=t.texture.view;let c=e.device.createBindGroup({layout:a,entries:Uf}),l=e.frameBufferManager.createRenderPassDescriptor(r.texture.view,0,0,0,0,`clear`),u=e.commandEncoder.beginRenderPass(l);return u.setPipeline(i),u.setBindGroup(0,c),u.draw(6,1,0,0),u.end(),r},Jf=(e,t,n)=>{let r=n.createTemporaryAttachment(e.w,e.h),i=ul()||n.getAttachment(`atlas`);return i&&i.texture&&r.texture?t.copyTextureToTexture({texture:i.texture.resource,origin:{x:e.x,y:e.y,z:0}},{texture:r.texture.resource,origin:{x:0,y:0,z:0}},{width:e.w,height:e.h}):console.error(`[WebGPU Filter] $getTextureFromNode: FAILED - missing atlas or textures`),r},Yf=e=>Wf.has(e),Xf=(e,t,n,r,i,a)=>{let o=e.frameBufferManager.createTemporaryAttachment(i,a),s=e.pipelineManager.getPipeline(`complex_blend_copy`),c=e.pipelineManager.getBindGroupLayout(`texture_copy`);if(!s||!c||!t.texture||!o.texture)return o;let l=i/t.width,u=a/t.height,d=n/t.width,f=r/t.height;Rf[0]=l,Rf[1]=u,Rf[2]=d,Rf[3]=f;let p=e.bufferManager.acquireAndWriteUniformBuffer(Rf),m=e.textureManager.createSampler(`filter_copy_sampler`,!1);Uf[0].resource.buffer=p,Uf[1].resource=m,Uf[2].resource=t.texture.view;let h=e.device.createBindGroup({layout:c,entries:Uf}),g=e.frameBufferManager.createRenderPassDescriptor(o.texture.view,0,0,0,0,`clear`),_=e.commandEncoder.beginRenderPass(g);return _.setPipeline(s),_.setBindGroup(0,h),_.draw(6,1,0,0),_.end(),o},Zf=(e,t,n,r,i)=>{let a=n.msaa&&n.msaaTexture?.view,o=a?`filter_complex_blend_output_msaa`:`filter_complex_blend_output`,s=e.pipelineManager.getPipeline(o),c=e.pipelineManager.getBindGroupLayout(`positioned_texture`);if(!s||!c||!t.texture||!n.texture)return;Z[0]=r,Z[1]=i,Z[2]=t.width,Z[3]=t.height,Z[4]=n.width,Z[5]=n.height,Z[6]=0,Z[7]=0;let l=e.bufferManager.acquireAndWriteUniformBuffer(Z),u=e.textureManager.createSampler(`filter_blend_output_sampler`,!1);Uf[0].resource.buffer=l,Uf[1].resource=u,Uf[2].resource=t.texture.view;let d=e.device.createBindGroup({layout:c,entries:Uf}),f=a?n.msaaTexture.view:n.texture.view,p=a?n.texture.view:null,m=e.frameBufferManager.createRenderPassDescriptor(f,0,0,0,0,`load`,p),h=e.commandEncoder.beginRenderPass(m);h.setPipeline(s),h.setBindGroup(0,d),h.draw(6,1,0,0),h.end()},Qf=(e,t,n,r,i,a,o,s)=>{let c=e.mainAttachment||e.frameBufferManager.getAttachment(`main`);if(!c||!c.texture||!t.texture)return;let l=i,u=a,d=t.width,f=t.height,p=0,m=0;if(l<0&&(p=-l/t.width,d+=l,l=0),u<0&&(m=-u/t.height,f+=u,u=0),d<=0||f<=0)return;let h=c.width,g=c.height;if(l+d>h&&(d=h-l),u+f>g&&(f=g-u),Yf(r)){let n=c.msaa&&c.msaaTexture?.view,i=Ll()&&(c.msaaStencil?.view||c.stencil?.view),a;if(i)a=n?`filter_output_masked_msaa`:`filter_output_masked`;else switch(r){case`add`:a=n?`filter_output_add_msaa`:`filter_output_add`;break;case`screen`:a=n?`filter_output_screen_msaa`:`filter_output_screen`;break;case`alpha`:a=n?`filter_output_alpha_msaa`:`filter_output_alpha`;break;case`erase`:a=n?`filter_output_erase_msaa`:`filter_output_erase`;break;case`copy`:a=n?`texture_copy_bgra_msaa`:`texture_copy_bgra`;break;default:a=n?`filter_output_msaa`:`filter_output`;break}let o=e.pipelineManager.getPipeline(a),s=e.pipelineManager.getBindGroupLayout(`texture_copy`);if((!o||!s)&&(a=n?`filter_output_msaa`:`filter_output`,o=e.pipelineManager.getPipeline(a),s=e.pipelineManager.getBindGroupLayout(`texture_copy`),!o||!s))return;let _=e.textureManager.createSampler(`filter_output_sampler`,!0),v=d/t.width,y=f/t.height;Rf[0]=v,Rf[1]=y,Rf[2]=p,Rf[3]=m;let b=e.bufferManager.acquireAndWriteUniformBuffer(Rf);Uf[0].resource.buffer=b,Uf[1].resource=_,Uf[2].resource=t.texture.view;let x=e.device.createBindGroup({layout:s,entries:Uf}),S=n?c.msaaTexture.view:c.texture.view,C=n?c.texture.view:null,w;if(i){let t=n&&c.msaaStencil?.view?c.msaaStencil.view:c.stencil.view;w=e.frameBufferManager.createStencilRenderPassDescriptor(S,t,`load`,`load`,C)}else w=e.frameBufferManager.createRenderPassDescriptor(S,0,0,0,0,`load`,C);let T=Math.max(0,l),E=Math.max(0,u),D=Math.max(1,d),O=Math.max(1,f),k=Math.max(0,Math.floor(T)),A=Math.max(0,Math.floor(E)),j=Math.max(1,Math.min(Math.ceil(T+D)-k,h-k)),M=Math.max(1,Math.min(Math.ceil(E+O)-A,g-A));if(j<=0||M<=0||k>=h||A>=g)return;let N=e.commandEncoder.beginRenderPass(w);N.setPipeline(o),N.setBindGroup(0,x),i&&N.setStencilReference(zl()),N.setViewport(T,E,D,O,0,1),N.setScissorRect(k,A,j,M),N.draw(6,1,0,0),N.end()}else{let i=Xf(e,c,l,u,d,f);Z[0]=n[0],Z[1]=n[1],Z[2]=n[2],Z[3]=n[3],Z[4]=n[4],Z[5]=n[5],Z[6]=n[6],Z[7]=0;let a=Vd(t,i,r,Z,{device:e.device,commandEncoder:e.commandEncoder,bufferManager:e.bufferManager,frameBufferManager:e.frameBufferManager,pipelineManager:e.pipelineManager,textureManager:e.textureManager,frameTextures:e.frameTextures});Zf(e,a,c,l,u),e.frameBufferManager.releaseTemporaryAttachment(i),e.frameBufferManager.releaseTemporaryAttachment(a)}},$f=(e,t,n,r,i,a,o,s,c,l,u,d)=>{X.x=0,X.y=0;let f=Jf(e,l.commandEncoder,l.frameBufferManager);if(f.texture){let t=l.frameBufferManager.createTemporaryAttachment(e.w,e.h),n=l.pipelineManager.getPipeline(`texture_copy_rgba8`),r=l.pipelineManager.getBindGroupLayout(`texture_copy`);if(n&&r&&t.texture){let e=l.textureManager.createSampler(`filter_flip_sampler`,!1),i=l.bufferManager.acquireAndWriteUniformBuffer(Gf);Uf[0].resource.buffer=i,Uf[1].resource=e,Uf[2].resource=f.texture.view;let a=l.device.createBindGroup({layout:r,entries:Uf}),o=l.frameBufferManager.createRenderPassDescriptor(t.texture.view,0,0,0,0,`clear`),s=l.commandEncoder.beginRenderPass(o);s.setPipeline(n),s.setBindGroup(0,a),s.draw(6,1,0,0),s.end(),l.frameBufferManager.releaseTemporaryAttachment(f),f=t}}let p=Ms.getDevicePixelRatio(),m=Math.sqrt(i[0]*i[0]+i[1]*i[1]),h=Math.sqrt(i[2]*i[2]+i[3]*i[3]),g=Math.atan2(i[1],i[0]),_=Math.atan2(-i[2],i[3]),v=r?m*Math.cos(g):Math.cos(g),y=r?m*Math.sin(g):Math.sin(g),b=r?-h*Math.sin(_):-Math.sin(_),x=r?h*Math.cos(_):Math.cos(_);zf[0]=v,zf[1]=y,zf[2]=b,zf[3]=x,zf[4]=t/2,zf[5]=n/2,Bf[0]=1,Bf[1]=0,Bf[2]=0,Bf[3]=1,Bf[4]=-e.w/2,Bf[5]=-e.h/2;let S=zf[0]*Bf[0]+zf[2]*Bf[1],C=zf[1]*Bf[0]+zf[3]*Bf[1],w=zf[0]*Bf[2]+zf[2]*Bf[3],T=zf[1]*Bf[2]+zf[3]*Bf[3],E=zf[0]*Bf[4]+zf[2]*Bf[5]+zf[4],D=zf[1]*Bf[4]+zf[3]*Bf[5]+zf[5],O=0,k=0;if(S!==1||C!==0||w!==0||T!==1){let r=l.frameBufferManager.createTemporaryAttachment(t,n),i=l.pipelineManager.getPipeline(`texture_scale`),a=l.pipelineManager.getBindGroupLayout(`texture_scale`);if(i&&a){Vf[0]=S,Vf[1]=C,Vf[2]=w,Vf[3]=T,Vf[4]=E,Vf[5]=D,Vf[6]=e.w,Vf[7]=e.h,Vf[8]=t,Vf[9]=n,Vf[10]=0,Vf[11]=0;let o=l.bufferManager.acquireAndWriteUniformBuffer(Vf,48),s=l.textureManager.createSampler(`filter_scale_sampler`,!0);Uf[0].resource.buffer=o,Uf[1].resource=s,Uf[2].resource=f.texture.view;let c=l.device.createBindGroup({layout:a,entries:Uf}),u=l.frameBufferManager.createRenderPassDescriptor(r.texture.view,0,0,0,0,`clear`),d=l.commandEncoder.beginRenderPass(u);d.setPipeline(i),d.setBindGroup(0,c),d.draw(6,1,0,0),d.end(),O=E,k=D,l.frameBufferManager.releaseTemporaryAttachment(f),f=r}}for(let e=0;c.length>e;)switch(c[e++]){case 0:{let t=c[e++],n=c[e++],r=c[e++],a=c[e++],o=c[e++],s=c[e++],u=c[e++],d=c[e++],m=c[e++],h=c[e++],g=c[e++],_=!!c[e++],v=Sf(f,i,t,n,r,a,o,s,u,d,m,h,g,_,p,l);f!==v&&l.frameBufferManager.releaseTemporaryAttachment(f),f=v}break;case 1:{let t=c[e++],n=c[e++],r=c[e++],a=tf(f,i,t,n,r,p,l);f!==a&&l.frameBufferManager.releaseTemporaryAttachment(f),f=a}break;case 2:{Hf[0]=c[e++],Hf[1]=c[e++],Hf[2]=c[e++],Hf[3]=c[e++],Hf[4]=c[e++],Hf[5]=c[e++],Hf[6]=c[e++],Hf[7]=c[e++],Hf[8]=c[e++],Hf[9]=c[e++],Hf[10]=c[e++],Hf[11]=c[e++],Hf[12]=c[e++],Hf[13]=c[e++],Hf[14]=c[e++],Hf[15]=c[e++],Hf[16]=c[e++],Hf[17]=c[e++],Hf[18]=c[e++],Hf[19]=c[e++];let t=cf(f,Hf,l);f!==t&&l.frameBufferManager.releaseTemporaryAttachment(f),f=t}break;case 3:{let t=c[e++],n=c[e++],r=t*n,i=new Float32Array(r);for(let t=0;t<r;t++)i[t]=c[e++];let a=c[e++],o=c[e++],s=!!c[e++],u=!!c[e++],d=c[e++],p=c[e++],m=Tf(f,t,n,i,a,o,s,u,d,p,l);f!==m&&l.frameBufferManager.releaseTemporaryAttachment(f),f=m}break;case 4:{let t=c[e++],n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=c[e++];let r=c[e++],a=c[e++],o=c[e++],s=c[e++],u=c[e++],d=c[e++],m=c[e++],h=c[e++],g=c[e++],_=c[e++],v=c[e++],y=Lf(f,i,n,r,a,o,s,u,d,m,h,g,_,v,p,l);f!==y&&l.frameBufferManager.releaseTemporaryAttachment(f),f=y}break;case 5:{let t=c[e++],n=c[e++],r=c[e++],a=c[e++],o=c[e++],s=c[e++],u=c[e++],d=c[e++],m=!!c[e++],h=!!c[e++],g=!!c[e++],_=_f(f,i,t,n,r,a,o,s,u,d,m,h,g,p,l);f!==_&&l.frameBufferManager.releaseTemporaryAttachment(f),f=_}break;case 6:{let t=c[e++],n=c[e++],r=c[e++],a=c[e++],o=c[e++],s=c[e++],u=!!c[e++],d=!!c[e++],m=mf(f,i,t,n,r,a,o,s,u,d,p,l);f!==m&&l.frameBufferManager.releaseTemporaryAttachment(f),f=m}break;case 7:{let t=c[e++],n=c[e++],r=c[e++],a=new Float32Array(r);for(let t=0;t<r;t++)a[t]=c[e++];let o=c[e++],s=new Float32Array(o);for(let t=0;t<o;t++)s[t]=c[e++];let u=c[e++],d=new Float32Array(u);for(let t=0;t<u;t++)d[t]=c[e++];let m=c[e++],h=c[e++],g=c[e++],_=c[e++],v=c[e++],y=!!c[e++],b=Af(f,i,t,n,a,s,d,m,h,g,_,v,y,p,l);f!==b&&l.frameBufferManager.releaseTemporaryAttachment(f),f=b}break;case 8:{let t=c[e++],n=c[e++],r=c[e++],a=new Float32Array(r);for(let t=0;t<r;t++)a[t]=c[e++];let o=c[e++],s=new Float32Array(o);for(let t=0;t<o;t++)s[t]=c[e++];let u=c[e++],d=new Float32Array(u);for(let t=0;t<u;t++)d[t]=c[e++];let m=c[e++],h=c[e++],g=c[e++],_=c[e++],v=c[e++],y=!!c[e++],b=Nf(f,i,t,n,a,s,d,m,h,g,_,v,y,p,l);f!==b&&l.frameBufferManager.releaseTemporaryAttachment(f),f=b}break}if(!Kf(a)){let e=qf(l,f,a);l.frameBufferManager.releaseTemporaryAttachment(f),f=e}let A=s[0]*(m/p),j=s[1]*(h/p),M=-O+A+i[4],N=-k+j+i[5];Qf(l,f,a,o,M,N,u,d),l.frameBufferManager.releaseTemporaryAttachment(f)},ep=new Float32Array(4),Q=new Float32Array(8),tp=new Float32Array(20),np=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],rp=new Set([`normal`,`layer`,`add`,`screen`,`alpha`,`erase`,`copy`]),ip=new Float32Array([1,1,1,1,0,0,0,0]),ap=e=>e?e[0]===1&&e[1]===1&&e[2]===1&&e[3]===1&&e[4]===0&&e[5]===0&&e[6]===0&&e[7]===0:!0,op=(e,t,n)=>{let r=e.frameBufferManager.createTemporaryAttachment(t.width,t.height),i=e.pipelineManager.getPipeline(`color_transform`),a=e.pipelineManager.getBindGroupLayout(`texture_copy`);if(!i||!a||!t.texture||!r.texture)return t;Q[0]=n[0],Q[1]=n[1],Q[2]=n[2],Q[3]=n[3],Q[4]=n[4],Q[5]=n[5],Q[6]=n[6],Q[7]=0;let o=e.bufferManager.acquireAndWriteUniformBuffer(Q),s=e.textureManager.createSampler(`container_ct_sampler`,!1);np[0].resource.buffer=o,np[1].resource=s,np[2].resource=t.texture.view;let c=e.device.createBindGroup({layout:a,entries:np}),l=e.frameBufferManager.createRenderPassDescriptor(r.texture.view,0,0,0,0,`clear`),u=e.commandEncoder.beginRenderPass(l);return u.setPipeline(i),u.setBindGroup(0,c),u.draw(6,1,0,0),u.end(),r},sp=(e,t,n,r,i,a)=>{let o=e.frameBufferManager.createTemporaryAttachment(i,a),s=e.pipelineManager.getPipeline(`texture_copy_rgba8`),c=e.pipelineManager.getBindGroupLayout(`texture_copy`);if(!s||!c||!t.texture||!o.texture)return o;let l=i/t.width,u=a/t.height,d=n/t.width,f=r/t.height;ep[0]=l,ep[1]=u,ep[2]=d,ep[3]=f;let p=e.bufferManager.acquireAndWriteUniformBuffer(ep),m=e.textureManager.createSampler(`container_copy_sampler`,!1);np[0].resource.buffer=p,np[1].resource=m,np[2].resource=t.texture.view;let h=e.device.createBindGroup({layout:c,entries:np}),g=e.frameBufferManager.createRenderPassDescriptor(o.texture.view,0,0,0,0,`clear`),_=e.commandEncoder.beginRenderPass(g);return _.setPipeline(s),_.setBindGroup(0,h),_.draw(6,1,0,0),_.end(),o},cp=(e,t,n,r,i,a,o)=>{if(!n.texture||!t.texture)return;let s=i,c=a,l=t.width,u=t.height,d=0,f=0;if(s<0&&(d=-s/t.width,l+=s,s=0),c<0&&(f=-c/t.height,u+=c,c=0),l<=0||u<=0)return;let p=n.width,m=n.height;if(s+l>p&&(l=p-s),c+u>m&&(u=m-c),rp.has(r)){let i=n.msaa&&n.msaaTexture?.view,a;switch(r){case`add`:a=i?`filter_output_add_msaa`:`filter_output_add`;break;case`screen`:a=i?`filter_output_screen_msaa`:`filter_output_screen`;break;case`alpha`:a=i?`filter_output_alpha_msaa`:`filter_output_alpha`;break;case`erase`:a=i?`filter_output_erase_msaa`:`filter_output_erase`;break;case`copy`:a=i?`texture_copy_bgra_msaa`:`texture_copy_bgra`;break;default:a=i?`filter_output_msaa`:`filter_output`;break}let h=e.pipelineManager.getPipeline(a),g=e.pipelineManager.getBindGroupLayout(`texture_copy`);if(!h||!g)return;let _=e.textureManager.createSampler(`container_output_sampler`,!0),v=l/t.width,y=u/t.height;ep[0]=v,ep[1]=y,ep[2]=d,ep[3]=f;let b=o.acquireAndWriteUniformBuffer(ep);np[0].resource.buffer=b,np[1].resource=_,np[2].resource=t.texture.view;let x=e.device.createBindGroup({layout:g,entries:np}),S=i?n.msaaTexture.view:n.texture.view,C=i?n.texture.view:null,w=e.frameBufferManager.createRenderPassDescriptor(S,0,0,0,0,`load`,C),T=Math.max(0,s),E=Math.max(0,c),D=Math.max(1,l),O=Math.max(1,u),k=Math.max(0,Math.floor(T)),A=Math.max(0,Math.floor(E)),j=Math.max(1,Math.min(Math.ceil(T+D)-k,p-k)),M=Math.max(1,Math.min(Math.ceil(E+O)-A,m-A));if(j<=0||M<=0||k>=p||A>=m)return;let N=e.commandEncoder.beginRenderPass(w);N.setPipeline(h),N.setBindGroup(0,x),N.setViewport(T,E,D,O,0,1),N.setScissorRect(k,A,j,M),N.draw(6,1,0,0),N.end()}else{let i=sp(e,n,s,c,l,u);Q[0]=ip[0],Q[1]=ip[1],Q[2]=ip[2],Q[3]=ip[3],Q[4]=ip[4]/255,Q[5]=ip[5]/255,Q[6]=ip[6]/255,Q[7]=0;let a=Vd(t,i,r,Q,{device:e.device,commandEncoder:e.commandEncoder,bufferManager:e.bufferManager,frameBufferManager:e.frameBufferManager,pipelineManager:e.pipelineManager,textureManager:e.textureManager,frameTextures:e.frameTextures}),d=n.msaa&&n.msaaTexture?.view,f=d?`filter_complex_blend_output_msaa`:`filter_complex_blend_output`,p=e.pipelineManager.getPipeline(f),m=e.pipelineManager.getBindGroupLayout(`positioned_texture`);if(p&&m&&a.texture&&n.texture){Q[0]=s,Q[1]=c,Q[2]=a.width,Q[3]=a.height,Q[4]=n.width,Q[5]=n.height,Q[6]=0,Q[7]=0;let t=o.acquireAndWriteUniformBuffer(Q),r=e.textureManager.createSampler(`container_blend_output_sampler`,!1);np[0].resource.buffer=t,np[1].resource=r,np[2].resource=a.texture.view;let i=e.device.createBindGroup({layout:m,entries:np}),l=d?n.msaaTexture.view:n.texture.view,u=d?n.texture.view:null,f=e.frameBufferManager.createRenderPassDescriptor(l,0,0,0,0,`load`,u),h=e.commandEncoder.beginRenderPass(f);h.setPipeline(p),h.setBindGroup(0,i),h.draw(6,1,0,0),h.end()}e.frameBufferManager.releaseTemporaryAttachment(i),e.frameBufferManager.releaseTemporaryAttachment(a)}},lp=(e,t,n,r,i)=>{X.x=0,X.y=0;for(let a=0;n.length>a;)switch(n[a++]){case 0:{let o=Sf(e,t,n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],!!n[a++],r,i);e!==o&&i.frameBufferManager.releaseTemporaryAttachment(e),e=o}break;case 1:{let o=tf(e,t,n[a++],n[a++],n[a++],r,i);e!==o&&i.frameBufferManager.releaseTemporaryAttachment(e),e=o}break;case 2:{tp[0]=n[a++],tp[1]=n[a++],tp[2]=n[a++],tp[3]=n[a++],tp[4]=n[a++],tp[5]=n[a++],tp[6]=n[a++],tp[7]=n[a++],tp[8]=n[a++],tp[9]=n[a++],tp[10]=n[a++],tp[11]=n[a++],tp[12]=n[a++],tp[13]=n[a++],tp[14]=n[a++],tp[15]=n[a++],tp[16]=n[a++],tp[17]=n[a++],tp[18]=n[a++],tp[19]=n[a++];let t=cf(e,tp,i);e!==t&&i.frameBufferManager.releaseTemporaryAttachment(e),e=t}break;case 3:{let t=n[a++],r=n[a++],o=t*r,s=new Float32Array(o);for(let e=0;e<o;e++)s[e]=n[a++];let c=Tf(e,t,r,s,n[a++],n[a++],!!n[a++],!!n[a++],n[a++],n[a++],i);e!==c&&i.frameBufferManager.releaseTemporaryAttachment(e),e=c}break;case 4:{let o=n[a++],s=new Uint8Array(o);for(let e=0;e<o;e++)s[e]=n[a++];let c=Lf(e,t,s,n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],r,i);e!==c&&i.frameBufferManager.releaseTemporaryAttachment(e),e=c}break;case 5:{let o=_f(e,t,n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],!!n[a++],!!n[a++],!!n[a++],r,i);e!==o&&i.frameBufferManager.releaseTemporaryAttachment(e),e=o}break;case 6:{let o=mf(e,t,n[a++],n[a++],n[a++],n[a++],n[a++],n[a++],!!n[a++],!!n[a++],r,i);e!==o&&i.frameBufferManager.releaseTemporaryAttachment(e),e=o}break;case 7:{let o=n[a++],s=n[a++],c=n[a++],l=new Float32Array(c);for(let e=0;e<c;e++)l[e]=n[a++];let u=n[a++],d=new Float32Array(u);for(let e=0;e<u;e++)d[e]=n[a++];let f=n[a++],p=new Float32Array(f);for(let e=0;e<f;e++)p[e]=n[a++];let m=Af(e,t,o,s,l,d,p,n[a++],n[a++],n[a++],n[a++],n[a++],!!n[a++],r,i);e!==m&&i.frameBufferManager.releaseTemporaryAttachment(e),e=m}break;case 8:{let o=n[a++],s=n[a++],c=n[a++],l=new Float32Array(c);for(let e=0;e<c;e++)l[e]=n[a++];let u=n[a++],d=new Float32Array(u);for(let e=0;e<u;e++)d[e]=n[a++];let f=n[a++],p=new Float32Array(f);for(let e=0;e<f;e++)p[e]=n[a++];let m=Nf(e,t,o,s,l,d,p,n[a++],n[a++],n[a++],n[a++],n[a++],!!n[a++],r,i);e!==m&&i.frameBufferManager.releaseTemporaryAttachment(e),e=m}break}return e},up=(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{if(o&&i&&s&&c){let n=sp(p,e,0,0,e.width,e.height);p.frameBufferManager.releaseTemporaryAttachment(e);let o=Ms.getDevicePixelRatio();if(n=lp(n,i,c,o,p),l&&(W.set(l,`fKey`,u),W.set(l,`fTexture`,n)),n){let e=n,c=null;ap(a)||(c=op(p,n,a),e=c);let u=Math.sqrt(i[0]*i[0]+i[1]*i[1]),d=Math.sqrt(i[2]*i[2]+i[3]*i[3]),f=s[0]*(u/o),h=s[1]*(d/o),g=f+i[4],_=h+i[5];cp(p,e,t,r,g,_,m),c&&p.frameBufferManager.releaseTemporaryAttachment(c),l||p.frameBufferManager.releaseTemporaryAttachment(n)}}else{let n=sp(p,e,0,0,e.width,e.height);if(p.frameBufferManager.releaseTemporaryAttachment(e),!ap(a)){let e=op(p,n,a);p.frameBufferManager.releaseTemporaryAttachment(n),n=e}cp(p,n,t,r,i[4],i[5],m),p.frameBufferManager.releaseTemporaryAttachment(n)}},dp=new Float32Array([1,1,0,0]),fp=[],pp=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]),mp=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]),hp=new Float32Array(8),gp=new Float32Array([1,-1,0,1]),_p=new Float32Array(16),vp=null,yp=null,bp=null,xp={view:null,clearValue:{r:0,g:0,b:0,a:0},loadOp:`clear`,storeOp:`store`},Sp={colorAttachments:[xp]},Cp=[{binding:0,resource:{buffer:null}},{binding:1,resource:null},{binding:2,resource:null}],wp={r:0,g:0,b:0,a:0},Tp={view:null,clearValue:wp,loadOp:`clear`,storeOp:`store`,resolveTarget:void 0},Ep={view:null,stencilClearValue:0,stencilLoadOp:`clear`,stencilStoreOp:`store`},Dp={colorAttachments:[Tp]},Op={view:null,resolveTarget:void 0,loadOp:`load`,storeOp:`store`},kp={view:null,stencilLoadOp:`load`,stencilStoreOp:`store`},Ap={colorAttachments:[Op]};var jp=class{$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;newDrawState=!1;_pendingAtlasNodes=[];$containerLayerStack=[];containerLayerContentSizes=[];inMaskMode=!1;nodeAreaCleared=!1;currentNodeScissor=null;nodeRenderPassAtlasIndex=-1;fillDynamicBindGroup=null;fillDynamicBindGroupBuffer=null;nodeClearQuadBuffer=null;useOptimizedInstancing=!0;$needsReconfigure=!1;$uniformData8=new Float32Array(8);$scissorRect={x:0,y:0,w:0,h:0};$filterConfig;constructor(e,t,n,r=1){this.device=e,this.canvasContext=t,this.preferredFormat=n,Ms.setDevice(e),Ms.setDevicePixelRatio(r);let i=e.limits.maxTextureDimension2D,a=Math.max(2048,i/2);Ms.setRenderMaxSize(a),this.$stack=Ms.createArray(),this.$stackAttachmentObject=Ms.createArray(),this.$matrix=Ms.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},t.configure({device:e,format:n,alphaMode:`premultiplied`}),this.viewportWidth=t.canvas.width,this.viewportHeight=t.canvas.height,this.pathCommand=new Bs,this.bufferManager=new $s(e),this.textureManager=new tc(e),this.frameBufferManager=new _c(e,n),this.pipelineManager=new el(e,n),this.pipelineManager.preloadLazyGroups(),ll(e=>{let t=Ms.getRenderMaxSize();return this.frameBufferManager.createAttachment(`atlas_${e}`,t,t,!1,!0)}),this.$filterConfig={device:this.device,commandEncoder:null,bufferManager:this.bufferManager,frameBufferManager:this.frameBufferManager,pipelineManager:this.pipelineManager,textureManager:this.textureManager,frameTextures:this.frameTextures},Ps(this)}clearTransferBounds(){this.beginFrame()}updateBackgroundColor(e,t,n,r){this.$clearColorR=e,this.$clearColorG=t,this.$clearColorB=n,this.$clearColorA=r}fillBackgroundColor(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture)return;this.frameStarted||this.beginFrame(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder();let e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view;Tp.view=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,Tp.resolveTarget=e?this.$mainAttachmentObject.texture.view:void 0,wp.r=this.$clearColorR,wp.g=this.$clearColorG,wp.b=this.$clearColorB,wp.a=this.$clearColorA;let t=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil?.view;t?(Ep.view=t,Dp.depthStencilAttachment=Ep):Dp.depthStencilAttachment=void 0,this.renderPassEncoder=this.commandEncoder.beginRenderPass(Dp),this.renderPassEncoder.end(),this.renderPassEncoder=null}resize(e,t,n=!0){this.clearArraysInstanced();for(let e of this.frameTextures)e.destroy();this.frameTextures.length=0;for(let e of this.pooledTextures)ku(e);this.pooledTextures.length=0;for(let e of this.pooledRenderTextures)ju(e);if(this.pooledRenderTextures.length=0,Mu(),this.frameStarted=!1,this.commandEncoder=null,this.renderPassEncoder=null,this.currentRenderTarget=null,Hl(),this.$stackAttachmentObject.length){for(let e=0;e<this.$stackAttachmentObject.length;++e){let t=this.$stackAttachmentObject[e];t&&(t.texture&&t.texture.resource.destroy(),t.stencil&&t.stencil.resource.destroy(),t.msaaTexture&&t.msaaTexture.resource.destroy(),t.msaaStencil&&t.msaaStencil.resource.destroy())}this.$stackAttachmentObject.length=0}this.$mainAttachmentObject&&this.frameBufferManager.destroyAttachment(`main`),n&&(Pu(),Vu(),Uu(),vl(),this.frameBufferManager.destroyAttachment(`atlas`),this.frameBufferManager.createAttachment(`atlas`,4096,4096,!1,!0)),this.frameBufferManager.setCurrentAttachment(null),this.$needsReconfigure=!0,this.mainTexture=null,this.mainTextureView=null,this.$mainAttachmentObject=this.frameBufferManager.createAttachment(`main`,e,t,!0,!0),this.bind(this.$mainAttachmentObject)}save(){let e=fp.length>0?fp.pop():new Float32Array(9);e.set(this.$matrix),this.$stack.push(e)}restore(){let e=this.$stack.pop();e&&(this.$matrix.set(e),fp.push(e))}setTransform(e,t,n,r,i,a){this.$matrix[0]=e,this.$matrix[1]=t,this.$matrix[3]=n,this.$matrix[4]=r,this.$matrix[6]=i,this.$matrix[7]=a}transform(e,t,n,r,i,a){let o=this.$matrix,s=o[0],c=o[1],l=o[3],u=o[4],d=o[6],f=o[7];o[0]=e*s+t*l,o[1]=e*c+t*u,o[3]=n*s+r*l,o[4]=n*c+r*u,o[6]=i*s+a*l+d,o[7]=i*c+a*u+f}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,t){this.pathCommand.moveTo(e,t)}lineTo(e,t){this.pathCommand.lineTo(e,t)}quadraticCurveTo(e,t,n,r){this.pathCommand.quadraticCurveTo(e,t,n,r)}fillStyle(e,t,n,r){this.$fillStyle[0]=e,this.$fillStyle[1]=t,this.$fillStyle[2]=n,this.$fillStyle[3]=r}strokeStyle(e,t,n,r){this.$strokeStyle[0]=e,this.$strokeStyle[1]=t,this.$strokeStyle[2]=n,this.$strokeStyle[3]=r}closePath(){this.pathCommand.closePath()}arc(e,t,n){this.pathCommand.arc(e,t,n)}bezierCurveTo(e,t,n,r,i,a){this.pathCommand.bezierCurveTo(e,t,n,r,i,a)}ensureFillRenderPass(){if(this.frameStarted||this.beginFrame(),this.ensureCommandEncoder(),this.renderPassEncoder){this.currentRenderTarget&&this.ensureNodeAreaCleared();return}{let e=this.getCurrentTextureView(),t=ul(),n=t?.msaa&&t?.msaaTexture?.view,r=n?t.msaaTexture.view:e,i=n?e:null;if(this.currentRenderTarget&&t?.stencil?.view){let e=n&&t?.msaaStencil?.view?t.msaaStencil.view:t.stencil.view,a=this.frameBufferManager.createStencilRenderPassDescriptor(r,e,`load`,`clear`,i);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}else if(!this.currentRenderTarget&&(Ll()||Nl())&&this.$mainAttachmentObject?.stencil?.view){let e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,t=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,n=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,r=e?this.$mainAttachmentObject.texture.view:null,i=this.frameBufferManager.createStencilRenderPassDescriptor(t,n,`load`,`load`,r);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i),Ll()&&this.renderPassEncoder.setStencilReference(zl())}else if(!this.currentRenderTarget&&this.$mainAttachmentObject){let e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,t=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,n=e?this.$mainAttachmentObject.texture.view:null;if(this.$mainAttachmentObject.stencil?.view){let r=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,i=this.frameBufferManager.createStencilRenderPassDescriptor(t,r,`load`,`clear`,n);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i)}else{let e=this.frameBufferManager.createRenderPassDescriptor(t,0,0,0,0,`load`,n);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e)}}else{let e=this.frameBufferManager.createRenderPassDescriptor(r,0,0,0,0,`load`,i);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e)}}this.currentRenderTarget&&this.ensureNodeAreaCleared()}fill(){let e=this.pathCommand.$getVertices;if(e.length===0)return;this.ensureFillRenderPass();let t=this.viewportWidth,n=this.viewportHeight,r=Xl(e);if(r.indexCount===0)return;let i=this.bufferManager.acquireVertexBuffer(r.buffer.byteLength,r.buffer),a=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],t,n),o=this.getOrCreateFillDynamicBindGroup(),s=ul();if(this.currentRenderTarget&&s?.stencil?.view)this.fillWithStencil(i,r.indexCount,o,a);else if(!this.currentRenderTarget&&!this.inMaskMode&&!Ll()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(i,r.indexCount,o,a);else{let e=(this.inMaskMode||Ll())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(i,r.indexCount,e,o,a)}}getOrCreateFillDynamicBindGroup(){let e=this.bufferManager.dynamicUniform.getBuffer();if(!this.fillDynamicBindGroup||this.fillDynamicBindGroupBuffer!==e){let t=this.pipelineManager.getBindGroupLayout(`fill_dynamic`);if(!t)throw Error(`[WebGPU] fill_dynamic bind group layout not found`);this.fillDynamicBindGroup=this.device.createBindGroup({layout:t,entries:[{binding:0,resource:{buffer:e,size:256}}]}),this.fillDynamicBindGroupBuffer=e}return this.fillDynamicBindGroup}writeFillUniform(e,t,n,r,i,a,o,s,c,l,u,d){return _p[0]=e,_p[1]=t,_p[2]=n,_p[3]=r,_p[4]=i/u,_p[5]=a/d,_p[6]=0,_p[7]=0,_p[8]=o/u,_p[9]=s/d,_p[10]=0,_p[11]=0,_p[12]=c/u,_p[13]=l/d,_p[14]=1,_p[15]=0,this.bufferManager.dynamicUniform.allocate(_p)}fillWithStencil(e,t,n,r){Wu(this.renderPassEncoder,this.pipelineManager,e,t,n,r)}fillWithStencilMain(e,t,n,r){Gu(this.renderPassEncoder,this.pipelineManager,e,t,n,r)}fillSimple(e,t,n,r,i){let a=this.$mainAttachmentObject?.clipLevel??1;Ku(this.renderPassEncoder,this.pipelineManager,e,t,r,i,this.currentRenderTarget!==null,n,a)}stroke(){let e=this.pathCommand.getVerticesForStroke();if(e.length===0)return;this.ensureFillRenderPass();let t=this.viewportWidth,n=this.viewportHeight,r=bu(e,this.thickness);if(r.length===0)return;let i=Xl(r);if(i.indexCount===0)return;let a=this.bufferManager.acquireVertexBuffer(i.buffer.byteLength,i.buffer),o=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],t,n),s=this.getOrCreateFillDynamicBindGroup(),c=ul();if(this.currentRenderTarget&&c?.stencil?.view)this.fillWithStencil(a,i.indexCount,s,o);else if(!this.currentRenderTarget&&!this.inMaskMode&&!Ll()&&this.$mainAttachmentObject?.stencil?.view)this.fillWithStencilMain(a,i.indexCount,s,o);else{let e=(this.inMaskMode||Ll())&&!!this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget;this.fillSimple(a,i.indexCount,e,s,o)}this.pathCommand.reset()}gradientFill(e,t,n,r,i,a){let o=this.pathCommand.$getVertices;if(o.length===0)return;this.ensureFillRenderPass();let s=this.viewportWidth,c=this.viewportHeight,l=!!((this.inMaskMode||Ll())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),u=this.currentRenderTarget!==null,d=od(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,o,this.$matrix,this.$fillStyle,e,t,n,r,i,a,s,c,u,l,this.$mainAttachmentObject?.clipLevel??1);d&&this.addFrameTexture(d),this.beginPath()}bitmapFill(e,t,n,r,i,a){let o=this.pathCommand.$getVertices;if(o.length===0)return;this.ensureFillRenderPass();let s=ul(),c=!!(this.currentRenderTarget&&s?.stencil?.view),l=!!((this.inMaskMode||Ll())&&this.$mainAttachmentObject?.stencil?.view&&!this.currentRenderTarget),u=c||l,d=this.$mainAttachmentObject?.clipLevel??1,f=pd(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,o,this.$matrix,this.$fillStyle,e,t,n,r,i,a,this.viewportWidth,this.viewportHeight,this.currentRenderTarget!==null,!!u,d);f&&this.addFrameTexture(f),this.beginPath()}gradientStroke(e,t,n,r,i,a){let o=this.pathCommand.getVerticesForStroke();if(o.length===0)return;this.ensureFillRenderPass();let s=ul(),c=!!(this.currentRenderTarget&&s?.stencil?.view),l=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),u=c||l,d=bd(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,o,this.thickness,this.$matrix,this.$strokeStyle,e,t,n,r,i,a,this.viewportWidth,this.viewportHeight,this.currentRenderTarget!==null,u);d&&this.addFrameTexture(d),this.pathCommand.reset()}bitmapStroke(e,t,n,r,i,a){let o=this.pathCommand.getVerticesForStroke();if(o.length===0)return;this.ensureFillRenderPass();let s=ul(),c=!!(this.currentRenderTarget&&s?.stencil?.view),l=!!(!this.currentRenderTarget&&this.$mainAttachmentObject?.stencil?.view),u=c||l,d=Ed(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,o,this.thickness,this.$matrix,this.$strokeStyle,e,t,n,r,i,a,this.viewportWidth,this.viewportHeight,this.currentRenderTarget!==null,u);d&&this.addFrameTexture(d),this.pathCommand.reset()}clip(){let e=this.frameBufferManager.getCurrentAttachment(),t=!e||e===this.$mainAttachmentObject;if(!e&&this.$mainAttachmentObject&&(e=this.$mainAttachmentObject),!e||!e.stencil)return;let n=this.pathCommand.$getVertices;if(n.length!==0){if(!this.renderPassEncoder)if(this.ensureCommandEncoder(),t&&this.$mainAttachmentObject?.stencil?.view){let e=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,t=e?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,n=e&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,r=this.frameBufferManager.createStencilRenderPassDescriptor(t,n,`load`,`load`);this.renderPassEncoder=this.commandEncoder.beginRenderPass(r)}else return;jd(this.device,this.renderPassEncoder,this.bufferManager,this.pipelineManager,e,n,this.$matrix,this.$fillStyle,this.globalAlpha,t)}}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 ul()}useGrid(e){xu.set(Su,e)}beginNodeRendering(e){this.nodeAreaCleared=!1,this.frameStarted||this.beginFrame();let t=dl(e.index)||ul();if(t&&t.texture){if(this.renderPassEncoder&&this.nodeRenderPassAtlasIndex===e.index)this.currentRenderTarget=t.texture.view,this.viewportWidth=t.width,this.viewportHeight=t.height;else{this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.currentRenderTarget=t.texture.view,this.viewportWidth=t.width,this.viewportHeight=t.height,this.ensureCommandEncoder();let n=t.msaa&&t.msaaTexture?.view,r=n?t.msaaTexture.view:t.texture.view,i=n?t.texture.view:null;if(t.stencil?.view){let e=n&&t.msaaStencil?.view?t.msaaStencil.view:t.stencil.view,a=this.frameBufferManager.createStencilRenderPassDescriptor(r,e,`load`,`load`,i);this.renderPassEncoder=this.commandEncoder.beginRenderPass(a)}else{let e=this.frameBufferManager.createRenderPassDescriptor(r,0,0,0,0,`load`,i);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e)}this.nodeRenderPassAtlasIndex=e.index}let n=Math.max(0,e.x),r=Math.max(0,e.y),i=Math.min(e.w,t.width-n),a=Math.min(e.h,t.height-r);if(n=Math.min(n,t.width),r=Math.min(r,t.height),i=Math.max(0,Math.min(i,t.width-n)),a=Math.max(0,Math.min(a,t.height-r)),this.$scissorRect.x=n,this.$scissorRect.y=r,this.$scissorRect.w=i,this.$scissorRect.h=a,this.currentNodeScissor=this.$scissorRect,i>0&&a>0){let e=Math.min(i+1,t.width-n),o=Math.min(a+1,t.height-r);this.renderPassEncoder.setScissorRect(n,r,e,o)}}}ensureNodeAreaCleared(){this.nodeAreaCleared||(this.nodeAreaCleared=!0,this.clearNodeArea())}clearNodeArea(){if(!this.renderPassEncoder)return;let e=this.pipelineManager.getPipeline(`node_clear_atlas`);if(!e)return;if(!this.nodeClearQuadBuffer){let e=this.device.createBuffer({size:mp.byteLength,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST,mappedAtCreation:!0});new Float32Array(e.getMappedRange()).set(mp),e.unmap(),this.nodeClearQuadBuffer=e}let t=this.nodeClearQuadBuffer;this.renderPassEncoder.setPipeline(e),this.renderPassEncoder.setVertexBuffer(0,t),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(){Cu()}drawDisplayObject(e,t,n,r,i,a){let o=Ms.getRenderMaxSize();Al(e,t,n,r,i,a,this.$matrix,this.globalCompositeOperation,this.viewportWidth,this.viewportHeight,o,this.globalAlpha)}drawArraysInstanced(){this.frameStarted||this.beginFrame(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$mainAttachmentObject&&(this.useOptimizedInstancing?this.renderPassEncoder=Rd(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager,!0,!0):this.renderPassEncoder=Fd(this.device,this.commandEncoder,this.renderPassEncoder,this.$mainAttachmentObject,this.bufferManager,this.frameBufferManager,this.textureManager,this.pipelineManager),this.processComplexBlendQueue())}processComplexBlendQueue(){this.ensureCommandEncoder(),Yd(this.device,this.commandEncoder,this.$mainAttachmentObject,this.frameBufferManager,this.textureManager,this.pipelineManager,this.bufferManager)}clearArraysInstanced(){kl().clear()}drawPixels(e,t){let n=dl(e.index)||ul();if(!n||!n.texture)return;let r=e.w,i=e.h;if(this.renderPassEncoder&&=(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),null),this.nodeRenderPassAtlasIndex=-1,n.msaa&&n.msaaTexture?.view)this.drawPixelsToMsaa(n,e,t,r,i);else{let a=r*4;this.device.queue.writeTexture({texture:n.texture.resource,origin:{x:e.x,y:e.y,z:0}},t,{bytesPerRow:a,rowsPerImage:i,offset:0},{width:r,height:i,depthOrArrayLayers:1})}}drawPixelsToMsaa(e,t,n,r,i){let a=Au(this.device,r,i),o=r*4;this.device.queue.writeTexture({texture:a},n,{bytesPerRow:o,rowsPerImage:i},{width:r,height:i});let s=this.pipelineManager.getPipeline(`bitmap_render_msaa`);if(!s){ju(a);return}let c=this.pipelineManager.getBindGroupLayout(`positioned_texture`);if(!c){ju(a);return}let l=this.$uniformData8;l[0]=t.x,l[1]=t.y,l[2]=r,l[3]=i,l[4]=e.width,l[5]=e.height,l[6]=0,l[7]=0;let u=this.bufferManager.acquireAndWriteUniformBuffer(l),d=this.textureManager.createSampler(`linear_sampler`,!0),f=Tu(a);Cp[0].resource.buffer=u,Cp[1].resource=d,Cp[2].resource=f;let p=this.device.createBindGroup({layout:c,entries:Cp});this.ensureCommandEncoder(),Op.view=e.msaaTexture.view,Op.resolveTarget=e.texture.view;let m=e.msaaStencil?.view;m?(kp.view=m,Ap.depthStencilAttachment=kp):Ap.depthStencilAttachment=void 0;let h=this.commandEncoder.beginRenderPass(Ap);h.setViewport(0,0,e.width,e.height,0,1),h.setScissorRect(t.x,t.y,r,i),h.setPipeline(s),h.setBindGroup(0,p),h.draw(6),h.end(),this.pooledRenderTextures.push(a)}drawElement(e,t,n=!1){let r=dl(e.index)||ul();if(!r||!r.texture)return;let i=e.w,a=e.h;this.renderPassEncoder&&=(this.ensureNodeAreaCleared(),this.renderPassEncoder.end(),null),this.nodeRenderPassAtlasIndex=-1,r.msaa&&r.msaaTexture?.view?this.drawElementToMsaa(r,e,t,i,a,n):this.drawElementToTexture(r,e,t,i,a,n)}drawElementToMsaa(e,t,n,r,i,a){let o=Au(this.device,r,i);this.device.queue.copyExternalImageToTexture({source:n,flipY:a},{texture:o,premultipliedAlpha:!0},{width:r,height:i});let s=this.pipelineManager.getPipeline(`bitmap_render_msaa`);if(!s){ju(o);return}let c=this.pipelineManager.getBindGroupLayout(`positioned_texture`);if(!c){ju(o);return}let l=this.$uniformData8;l[0]=t.x,l[1]=t.y,l[2]=r,l[3]=i,l[4]=e.width,l[5]=e.height,l[6]=0,l[7]=0;let u=this.bufferManager.acquireAndWriteUniformBuffer(l),d=this.textureManager.createSampler(`linear_sampler`,!0),f=Tu(o);Cp[0].resource.buffer=u,Cp[1].resource=d,Cp[2].resource=f;let p=this.device.createBindGroup({layout:c,entries:Cp});this.ensureCommandEncoder(),Op.view=e.msaaTexture.view,Op.resolveTarget=e.texture.view;let m=e.msaaStencil?.view;m?(kp.view=m,Ap.depthStencilAttachment=kp):Ap.depthStencilAttachment=void 0;let h=this.commandEncoder.beginRenderPass(Ap);h.setViewport(0,0,e.width,e.height,0,1),h.setScissorRect(t.x,t.y,r,i),h.setPipeline(s),h.setBindGroup(0,p),h.draw(6),h.end(),this.pooledRenderTextures.push(o)}drawElementToTexture(e,t,n,r,i,a){let o=Au(this.device,r,i);this.device.queue.copyExternalImageToTexture({source:n,flipY:a},{texture:o,premultipliedAlpha:!0},{width:r,height:i});let s=this.pipelineManager.getPipeline(`bitmap_render`);if(!s){ju(o);return}let c=this.pipelineManager.getBindGroupLayout(`positioned_texture`);if(!c){ju(o);return}let l=this.$uniformData8;l[0]=t.x,l[1]=t.y,l[2]=r,l[3]=i,l[4]=e.width,l[5]=e.height,l[6]=0,l[7]=0;let u=this.bufferManager.acquireAndWriteUniformBuffer(l),d=this.textureManager.createSampler(`linear_sampler`,!0),f=Tu(o);Cp[0].resource.buffer=u,Cp[1].resource=d,Cp[2].resource=f;let p=this.device.createBindGroup({layout:c,entries:Cp});this.ensureCommandEncoder(),Op.view=e.texture.view,Op.resolveTarget=void 0;let m=e.stencil?.view;m?(kp.view=m,Ap.depthStencilAttachment=kp):Ap.depthStencilAttachment=void 0;let h=this.commandEncoder.beginRenderPass(Ap);h.setViewport(0,0,e.width,e.height,0,1),h.setScissorRect(t.x,t.y,r,i),h.setPipeline(s),h.setBindGroup(0,p),h.draw(6),h.end(),this.pooledRenderTextures.push(o)}applyFilter(e,t,n,r,i,a,o,s,c,l,u){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.nodeRenderPassAtlasIndex=-1,this.ensureCommandEncoder(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=this.$mainAttachmentObject,$f(e,r,i,a,o,s,c,l,u,this.$filterConfig,this.mainTextureView,this.bufferManager)}containerBeginLayer(e,t){this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null);let n=this.$mainAttachmentObject;this.$containerLayerStack.push(n),this.containerLayerContentSizes.push({width:e,height:t});let r=this.frameBufferManager.createAttachment(`container_layer`,e,t,n.msaa,!0);this.$mainAttachmentObject=r,this.bind(r)}containerEndLayer(e,t,n,r,i,a,o,s){this.drawArraysInstanced(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder();let c=this.$mainAttachmentObject,l=this.containerLayerContentSizes.pop()||{width:c.width,height:c.height};this.$mainAttachmentObject=this.$containerLayerStack.pop(),this.$filterConfig.commandEncoder=this.commandEncoder,this.$filterConfig.mainAttachment=void 0,up(c,this.$mainAttachmentObject,`container_layer`,e,t,n,r,i,a,o,s,l.width,l.height,this.$filterConfig,this.bufferManager),this.bind(this.$mainAttachmentObject)}containerBeginAtlasNode(e,t){this.drawArraysInstanced();let n=this.createNode(e,t);this._pendingAtlasNodes.push(n);let r=this.$mainAttachmentObject;this.$containerLayerStack.push(r),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null);let i=this.frameBufferManager.createAttachment(`container_layer`,e,t,r.msaa,!0);return this.$mainAttachmentObject=i,this.bind(i),n}containerEndAtlasNode(){this.drawArraysInstanced(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder();let e=this.$mainAttachmentObject,t=this._pendingAtlasNodes.pop();this.$mainAttachmentObject=this.$containerLayerStack.pop(),this.copyTempToAtlasNode(e,t),this.frameBufferManager.releaseTemporaryAttachment(e),this.bind(this.$mainAttachmentObject)}copyTempToAtlasNode(e,t){let n=dl(t.index)||ul();if(!n||!n.texture||!e.texture)return;let r=n.msaa&&n.msaaTexture?.view,i=r?`texture_copy_rgba8_msaa`:`texture_copy_rgba8`,a=this.pipelineManager.getPipeline(i),o=this.pipelineManager.getBindGroupLayout(`texture_copy`);if(!a||!o)return;let s=this.bufferManager.acquireAndWriteUniformBuffer(gp),c=this.textureManager.createSampler(`container_atlas_copy`,!1),l=e.texture.view,u=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:{buffer:s}},{binding:1,resource:c},{binding:2,resource:l}]}),d=r?n.msaaTexture.view:n.texture.view,f=r?n.texture.view:null,p=this.frameBufferManager.createRenderPassDescriptor(d,0,0,0,0,`load`,f),m=this.commandEncoder.beginRenderPass(p);m.setViewport(t.x,t.y,t.w,t.h,0,1),m.setScissorRect(t.x,t.y,t.w,t.h),m.setPipeline(a),m.setBindGroup(0,u),m.draw(6,1,0,0),m.end(),this.nodeRenderPassAtlasIndex=-1}containerDrawCachedFilter(e,t,n,r,i,a){if(W.get(i,`fKey`)!==a)return;let o=W.get(i,`fTexture`);if(!o||!o.texture)return;this.drawArraysInstanced(),this.frameStarted||this.beginFrame(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder();let s=this.$mainAttachmentObject;if(!s||!s.texture)return;let c=o,l=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)){l=this.frameBufferManager.createTemporaryAttachment(o.width,o.height);let e=this.pipelineManager.getPipeline(`color_transform`),t=this.pipelineManager.getBindGroupLayout(`texture_copy`);if(e&&t&&l.texture){hp[0]=n[0],hp[1]=n[1],hp[2]=n[2],hp[3]=n[3],hp[4]=n[4],hp[5]=n[5],hp[6]=n[6],hp[7]=0;let r=hp,i=this.bufferManager.acquireAndWriteUniformBuffer(r),a=this.textureManager.createSampler(`cached_ct_sampler`,!1);Cp[0].resource.buffer=i,Cp[1].resource=a,Cp[2].resource=o.texture.view;let s=this.device.createBindGroup({layout:t,entries:Cp}),u=this.frameBufferManager.createRenderPassDescriptor(l.texture.view,0,0,0,0,`clear`),d=this.commandEncoder.beginRenderPass(u);d.setPipeline(e),d.setBindGroup(0,s),d.draw(6,1,0,0),d.end(),c=l}}let u=Ms.getDevicePixelRatio(),d=Math.sqrt(t[0]*t[0]+t[1]*t[1]),f=Math.sqrt(t[2]*t[2]+t[3]*t[3]),p=r[0]*(d/u),m=r[1]*(f/u),h=Math.floor(p+t[4]),g=Math.floor(m+t[5]),_=s.msaa&&s.msaaTexture?.view,v;switch(e){case`add`:v=_?`filter_output_add_msaa`:`filter_output_add`;break;case`screen`:v=_?`filter_output_screen_msaa`:`filter_output_screen`;break;case`alpha`:v=_?`filter_output_alpha_msaa`:`filter_output_alpha`;break;case`erase`:v=_?`filter_output_erase_msaa`:`filter_output_erase`;break;default:v=_?`filter_output_msaa`:`filter_output`;break}let y=this.pipelineManager.getPipeline(v),b=this.pipelineManager.getBindGroupLayout(`texture_copy`);if(!y||!b)return;let x=this.textureManager.createSampler(`cached_filter_sampler`,!0),S=this.bufferManager.acquireAndWriteUniformBuffer(dp);Cp[0].resource.buffer=S,Cp[1].resource=x,Cp[2].resource=c.texture.view;let C=this.device.createBindGroup({layout:b,entries:Cp}),w=_?s.msaaTexture.view:s.texture.view,T=_?s.texture.view:null,E=this.frameBufferManager.createRenderPassDescriptor(w,0,0,0,0,`load`,T),D=Math.max(0,h),O=Math.max(0,g),k=Math.max(1,c.width),A=Math.max(1,c.height),j=s.width,M=s.height,N=Math.max(1,Math.min(k,j-D)),P=Math.max(1,Math.min(A,M-O));if(N<=0||P<=0||D>=j||O>=M){l&&this.frameBufferManager.releaseTemporaryAttachment(l);return}let F=this.commandEncoder.beginRenderPass(E);F.setPipeline(y),F.setBindGroup(0,C),F.setViewport(D,O,k,A,0,1),F.setScissorRect(D,O,N,P),F.draw(6,1,0,0),F.end(),l&&this.frameBufferManager.releaseTemporaryAttachment(l),this.bind(s)}ensureMainTexture(){this.mainTexture||(this.$needsReconfigure&&=(this.canvasContext.configure({device:this.device,format:this.preferredFormat,alphaMode:`premultiplied`}),!1),this.mainTexture=this.canvasContext.getCurrentTexture(),this.mainTextureView=this.mainTexture.createView())}getCurrentTextureView(){return this.currentRenderTarget?this.currentRenderTarget:(this.ensureMainTexture(),this.mainTextureView)}ensureCommandEncoder(){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(),null),this.bufferManager.dynamicUniform.flush(),this.commandEncoder)try{let 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(let e of this.frameTextures)e.destroy();this.frameTextures.length=0;for(let e of this.pooledTextures)ku(e);this.pooledTextures.length=0;for(let e of this.pooledRenderTextures)ju(e);this.pooledRenderTextures.length=0,Bu(),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,t){let n=al();if(!fl[n]){let e=Ms.getRenderMaxSize();fl[n]=new Wr(n,e,e)}return fl[n].insert(e,t)||(il(n+1),this.createNode(e,t))}removeNode(e){let t=fl[e.index];t&&t.dispose(e.x,e.y,e.w,e.h)}transferMainCanvas(){if(!this.$mainAttachmentObject||!this.$mainAttachmentObject.texture){this.endFrame();return}this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder(),this.ensureMainTexture();let e=this.pipelineManager.getPipeline(`texture_copy_bgra`),t=this.pipelineManager.getBindGroupLayout(`texture_copy`);if(!e||!t){console.error(`[WebGPU] texture_copy_bgra pipeline not found`),this.endFrame();return}let n=this.$mainAttachmentObject.texture.view;if(!vp||yp!==n){bp||(bp=this.device.createBuffer({size:dp.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.device.queue.writeBuffer(bp,0,dp.buffer,dp.byteOffset,dp.byteLength));let e=this.textureManager.createSampler(`transfer_sampler`,!1);Cp[0].resource={buffer:bp},Cp[1].resource=e,Cp[2].resource=n,vp=this.device.createBindGroup({layout:t,entries:Cp}),yp=n}let r=vp;xp.view=this.mainTextureView;let i=this.commandEncoder.beginRenderPass(Sp);i.setPipeline(e),i.setBindGroup(0,r),i.draw(6,1,0,0),i.end(),this.endFrame()}async createImageBitmap(e,t){let n=this.$mainAttachmentObject;if(!n||!n.texture)throw Error(`[WebGPU] Main attachment not found`);this.renderPassEncoder&&=(this.renderPassEncoder.end(),null);let r=Math.ceil(e*4/256)*256,i=r*t,a=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});this.ensureCommandEncoder(),this.commandEncoder.copyTextureToBuffer({texture:n.texture.resource,mipLevel:0,origin:{x:0,y:0,z:0}},{buffer:a,bytesPerRow:r,rowsPerImage:t},{width:e,height:t,depthOrArrayLayers:1}),this.endFrame(),await a.mapAsync(GPUMapMode.READ);let o=a.getMappedRange(),s=new Uint8Array(o),c=this.preferredFormat===`bgra8unorm`,l=new Uint8Array(e*t*4),u=e*4;for(let e=0;e<t;e++){let t=e*r,n=e*u;if(c)for(let e=0;e<u;e+=4)l[n+e]=s[t+e+2],l[n+e+1]=s[t+e+1],l[n+e+2]=s[t+e],l[n+e+3]=s[t+e+3];else l.set(s.subarray(t,t+u),n)}a.unmap(),a.destroy();let d=new Float32Array(256);for(let e=1;e<256;e++)d[e]=255/e;for(let e=0;e<l.length;e+=4){let t=l[e+3];if(t===0||t===255)continue;let n=d[t];l[e]=Math.min(255,Math.round(l[e]*n)),l[e+1]=Math.min(255,Math.round(l[e+1]*n)),l[e+2]=Math.min(255,Math.round(l[e+2]*n))}let f=new ImageData(new Uint8ClampedArray(l),e,t);if(typeof createImageBitmap<`u`)return await createImageBitmap(f,{premultiplyAlpha:`none`,colorSpaceConversion:`none`});throw Error(`[WebGPU] createImageBitmap not available in this environment`)}beginMask(){if(this.$mainAttachmentObject&&this.bind(this.$mainAttachmentObject),this.currentRenderTarget=null,this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.frameStarted||this.beginFrame(),this.ensureCommandEncoder(),this.$mainAttachmentObject?.texture&&this.$mainAttachmentObject?.stencil?.view){let e=this.$mainAttachmentObject.clipLevel===0?`clear`:`load`,t=this.$mainAttachmentObject.msaa&&this.$mainAttachmentObject.msaaTexture?.view,n=t?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject.texture.view,r=t&&this.$mainAttachmentObject.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject.stencil.view,i=this.frameBufferManager.createStencilRenderPassDescriptor(n,r,`load`,e);this.renderPassEncoder=this.commandEncoder.beginRenderPass(i),this.viewportWidth=this.$mainAttachmentObject.width,this.viewportHeight=this.$mainAttachmentObject.height}Ul(),this.inMaskMode=!0}setMaskBounds(e,t,n,r){Wl(e,t,n,r)}endMask(){this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),Gl(),this.inMaskMode=!1}leaveMask(){this.drawArraysInstanced();let e=this.frameBufferManager.getCurrentAttachment()?.clipLevel??0,t=e===1;Kl(),this.renderPassEncoder&&=(this.renderPassEncoder.end(),null),this.ensureCommandEncoder();let n=this.$mainAttachmentObject?.msaa&&this.$mainAttachmentObject?.msaaTexture?.view,r=n?this.$mainAttachmentObject.msaaTexture.view:this.$mainAttachmentObject?.texture.view,i=n&&this.$mainAttachmentObject?.msaaStencil?.view?this.$mainAttachmentObject.msaaStencil.view:this.$mainAttachmentObject?.stencil?.view;if(t&&i){let e={colorAttachments:[{view:r,loadOp:`load`,storeOp:`store`}],depthStencilAttachment:{view:i,stencilLoadOp:`clear`,stencilStoreOp:`store`,stencilClearValue:0}};this.commandEncoder.beginRenderPass(e).end()}else if(e>1&&i){let t=`clip_clear_main_${Math.min(8,Math.max(1,e))}`,n=this.pipelineManager.getPipeline(t);if(n){let e=this.frameBufferManager.createStencilRenderPassDescriptor(r,i,`load`,`load`),t=this.commandEncoder.beginRenderPass(e),a=this.bufferManager.acquireVertexBuffer(pp.byteLength,pp);t.setPipeline(n),t.setStencilReference(0),t.setVertexBuffer(0,a),t.draw(6,1,0,0),t.end()}}}};let $,Mp=e=>{$=e},Np,Pp=e=>{Np=e},Fp=0,Ip=()=>Fp,Lp=0,Rp=()=>Lp,zp=!1,Bp=(e,t)=>{zp=!0,Fp=e,Lp=t},Vp=()=>zp,Hp=()=>{Np.width=Fp,Np.height=Lp,zp=!1},Up=[],Wp=(...e)=>{let t=Up.pop()||[];return e.length&&t.push(...e),t},Gp=(e,t=1)=>({R:(e&16711680)>>16,G:(e&65280)>>8,B:e&255,A:t*255}),Kp=async(e,t)=>{if(Pp(e),`gpu`in navigator){let n=navigator.gpu,r=await n.requestAdapter();if(!r)throw Error(`WebGPU adapter not available`);let i=await r.requestDevice();if(!i)throw Error(`WebGPU device not available`);let a=e.getContext(`webgpu`);if(!a)throw Error(`WebGPU context not available`);Mp(new jp(i,a,n.getPreferredCanvasFormat(),t))}else{let n=e.getContext(`webgl2`,{stencil:!0,premultipliedAlpha:!0,antialias:!1,depth:!1});if(!n)throw Error(`webgl2 is not supported.`);Mp(new js(n,4,t))}},qp=(e,t,n=!0)=>{Ip()===e&&Rp()===t||(Bp(e,t),$.resize(e,t,n),n&&W.reset())},Jp=(e,t=!1)=>{let n=0;for(;e.length>n;)switch(e[n++]){case 9:$.beginPath();break;case 0:$.moveTo(e[n++],e[n++]);break;case 2:$.lineTo(e[n++],e[n++]);break;case 1:$.quadraticCurveTo(e[n++],e[n++],e[n++],e[n++]);break;case 5:if(t){n+=4;break}$.fillStyle(e[n++]/255,e[n++]/255,e[n++]/255,e[n++]/255);break;case 7:$.fill();break;case 6:if(t){n+=8;break}$.thickness=e[n++],$.caps=e[n++],$.joints=e[n++],$.miterLimit=e[n++],$.strokeStyle(e[n++]/255,e[n++]/255,e[n++]/255,e[n++]/255);break;case 8:if(t)break;$.stroke();break;case 12:$.closePath();break;case 4:$.arc(e[n++],e[n++],e[n++]);break;case 3:$.bezierCurveTo(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case 10:{if(t){n+=1;let t=e[n++];n+=t*5,n+=9,$.fill();break}let r=e[n++],i=Wp(),a=e[n++];for(let t=0;t<a;++t)i.push(e[n++],e[n++],e[n++],e[n++],e[n++]);let o=e.subarray(n,n+6);n+=6;let s=e[n++],c=e[n++],l=e[n++];$.gradientFill(r,i,o,s,c,l)}break;case 13:{if(t){n+=2;let t=e[n++];n+=t,n+=8,$.fill();break}let r=e[n++],i=e[n++],a=e[n++],o=new Uint8Array(e.subarray(n,n+a));n+=a;let s=e.subarray(n,n+6);n+=6,$.bitmapFill(o,s,r,i,!!e[n++],!!e[n++])}break;case 11:{if(t){n+=20,$.fill();break}$.thickness=e[n++],$.caps=e[n++],$.joints=e[n++],$.miterLimit=e[n++];let r=e[n++],i=Wp(),a=e[n++];for(let t=0;t<a;++t)i.push(e[n++],e[n++],e[n++],e[n++],e[n++]);let o=e.subarray(n,n+6);n+=6;let s=e[n++],c=e[n++],l=e[n++];$.gradientStroke(r,i,o,s,c,l)}break;case 14:{if(t){n+=6;let t=e[n++];n+=t,n+=8,$.fill();break}$.thickness=e[n++],$.caps=e[n++],$.joints=e[n++],$.miterLimit=e[n++];let r=e[n++],i=e[n++],a=e[n++],o=new Uint8Array(e.subarray(n,n+a));n+=a;let s=e.subarray(n,n+6);n+=6,$.bitmapStroke(o,s,r,i,!!e[n++],!!e[n++])}break}},Yp=e=>{switch(e){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`}},Xp=(e,t)=>{let n=e.subarray(t,t+6);t+=6;let r=e.subarray(t,t+8);t+=8;let i=e.subarray(t,t+4);t+=4;let a=e[t++],o=e[t++],s=e[t++],c=e[t++],l=!!e[t++],u=!!e[t++],d=e[t++],f=d===1,p=d===2,m=`${e[t++]}`,h=e[t++],g=e[t++],_=e[t++],v=`${e[t++]}`,y;if(!e[t++]){let n=l?new Float32Array(28):null;n&&(n.set(e.subarray(t,t+24)),t+=24),$.useGrid(n);let r=e[t++],i=e.subarray(t,t+r);if(f&&!l){let e=Math.ceil(Math.abs(s-a)),t=Math.ceil(Math.abs(c-o));y=$.createNode(e,t),W.set(m,`${h}`,y);let n=$.currentAttachmentObject,r=$.atlasAttachmentObject;r&&$.bind(r),$.reset(),$.beginNodeRendering(y);let l=r?r.height-y.y-t:0;$.setTransform(1,0,0,1,y.x,l),u?(Jp(i),$.drawFill()):$.drawPixels(y,new Uint8Array(i)),$.endNodeRendering(),n&&$.bind(n)}else{let e=Math.ceil(Math.abs(s-a)*g),t=Math.ceil(Math.abs(c-o)*_);y=$.createNode(e,t),W.set(m,`${h}`,y);let r=$.currentAttachmentObject,l=$.atlasAttachmentObject;l&&$.bind(l),$.reset(),$.beginNodeRendering(y);let u=l?l.height-y.y-t:0;$.setTransform(g,0,0,_,-a*g+y.x,-o*_+u),n&&(n[24]=y.x,n[25]=u),Jp(i),$.drawFill(),$.endNodeRendering(),r&&$.bind(r)}t+=r}else if(y=W.get(m,`${h}`),!y)return t;let b=e[t++];if(e[t++]){let a=!!e[t++],o=e.subarray(t,t+4);t+=4;let s=e[t++],c=e.subarray(t,t+s),l=Math.ceil(Math.abs(i[2]-i[0])),u=Math.ceil(Math.abs(i[3]-i[1]));return $.applyFilter(y,v,a,l,u,f,n,r,Yp(b),o,c),t+=s,t}if($.globalAlpha=Math.min(Math.max(0,r[3]+r[7]/255),1),$.imageSmoothingEnabled=!0,$.globalCompositeOperation=Yp(b),f&&!l)$.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]),$.drawDisplayObject(y,i[0],i[1],i[2],i[3],r);else if(p){let e=n[0]*a+n[2]*o+n[4],t=n[1]*a+n[3]*o+n[5];$.setTransform(n[0]/g,n[1]/g,n[2]/_,n[3]/_,e,t),$.drawDisplayObject(y,i[0],i[1],i[2],i[3],r)}else{let e=Math.atan2(n[1],n[0]),t=Math.atan2(-n[2],n[3]);if(e||t){let r=a*g,i=o*_,s=Math.cos(e),c=Math.sin(e),l=Math.cos(t),u=Math.sin(t);$.setTransform(s,c,-u,l,r*s-i*u+n[4],r*c+i*l+n[5])}else $.setTransform(1,0,0,1,i[0],i[1]);$.drawDisplayObject(y,i[0],i[1],i[2],i[3],r)}return t},Zp=(e,t)=>{let n=e.subarray(t,t+6);t+=6,$.reset(),$.setTransform(n[0],n[1],n[2],n[3],n[4],n[5]);let r=e[t++]?new Float32Array(28):null;$.useGrid(r),r&&(r.set(e.subarray(t,t+24)),t+=24);let i=e[t++];return Jp(e.subarray(t,t+i),!0),t+=i,$.clip(),t},Qp=(e,t,n)=>{let r=e.widthTable[t.line]||0,i=t.textFormat,a=i.leftMargin||0;if(!n.wordWrap&&r>n.rawWidth)return Math.max(0,a);let o=i.rightMargin||0;return i.align===`center`||n.autoSize===`center`?Math.max(0,n.rawWidth/2-a-o-r/2-2):i.align===`right`||n.autoSize===`right`?Math.max(0,n.rawWidth-a-r-o-4):Math.max(0,a)},$p=e=>{let t=``;return e.italic&&(t+=`italic `),e.bold&&(t+=`bold `),`${t}${e.size}px '${e.font}','sans-serif'`},em=(e,t,n,r)=>{let i=new OffscreenCanvas(t.width,t.height),a=i.getContext(`2d`);if(!a)return i;let o=Math.min(1,Math.max(n,r));if(t.background||t.border){if(a.beginPath(),a.moveTo(0,0),a.lineTo(t.width,0),a.lineTo(t.width,t.height),a.lineTo(0,t.height),a.lineTo(0,0),t.background){let e=Gp(t.backgroundColor);a.fillStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`,a.fill()}if(t.border){let e=Gp(t.borderColor);a.lineWidth=o,a.strokeStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`,a.stroke()}}if(!e)return i;a.save(),a.beginPath(),a.moveTo(2,2),a.lineTo(t.width-2,2),a.lineTo(t.width-2,t.height-2),a.lineTo(2,t.height-2),a.lineTo(2,2),a.clip();let s=2;if(t.scrollX>0){let e=(t.textWidth+4-t.rawWidth)/t.rawWidth;s+=-t.scrollX*e}let c=2;if(t.scrollY>0){let e=(t.textHeight+2-t.rawHeight)/t.rawHeight;c+=-t.scrollY*e}if(a.setTransform(n,0,0,r,s*n,c*r),a.beginPath(),t.selectIndex>-1&&t.focusIndex>-1){let n=e.textTable.length-1,r=0,i=0;t.focusIndex<=t.selectIndex?(r=Math.min(t.focusIndex,n),i=Math.min(t.selectIndex,n)):(r=Math.min(t.selectIndex,n),i=Math.min(t.focusIndex-1,n));let o=e.textTable[r],s=e.lineTable[o.line],c=Qp(e,s,t),l=0;if(r&&o.mode===`text`){let t=r;for(;t;){let n=e.textTable[--t];if(n.mode!==`text`)break;l+=n.w}}a.fillStyle=`#b4d7ff`;let u=0;for(let t=r;t<=i;++t){let n=e.textTable[t];if(n.mode===`text`&&(u+=n.w,t!==i))continue;let r=0,o=n.mode===`text`?n.line:n.line-1;for(let t=0;t<o;++t)r+=e.heightTable[t];a.beginPath(),a.rect(l,r,u+c,e.heightTable[o]),a.fill(),l=0,u=0}}let l=t.rawWidth,u=0;if(t.scrollX>0){let e=(t.textWidth-l)/l;u=t.scrollX*e}let d=l+u,f=t.rawHeight,p=0;if(t.scrollY>0){let e=(t.textHeight-f)/f;p=t.scrollY*e}let m=f+p,h=0,g=0,_=0,v=0,y=!1,b=-1;for(let n=0;n<e.textTable.length;++n){let r=e.textTable[n];if(!r)continue;if((r.mode===`text`||r.mode===`break`)&&(b++,t.stopIndex>-1&&b>t.stopIndex))break;if(y&&r.mode===`text`)continue;let i=r.textFormat;if(t.autoSize===`none`){if(g>m)break;if(r.mode===`text`&&(u>h+r.w||h>d)){h+=r.w;continue}}let s=Gp(i.color||0);if(a.fillStyle=`rgba(${s.R},${s.G},${s.B},${s.A})`,t.focusVisible&&t.focusIndex===n){let t=h+_+.1,n=r.line,i=r.y,o=e.ascentTable[n];r.mode!==`text`&&(i=r.mode===`break`?r.h:e.ascentTable[n-1],n>0?(n=r.line-1,o=e.ascentTable[n]):o=r.h),n>0&&e.ascentTable[n]===0&&n++;for(let t=0;t<n;++t)o+=e.heightTable[t];a.strokeStyle=`rgba(${s.R},${s.G},${s.B},${s.A})`,a.beginPath(),a.moveTo(t,o),a.lineTo(t,o-i),a.stroke()}if(t.thickness){let e=Gp(t.thicknessColor);a.lineWidth=t.thickness,a.strokeStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`}let c=r.line|0;switch(r.mode){case`break`:case`wrap`:if(h=0,c&&(g+=e.heightTable[c-1]),p>g+e.heightTable[c]){y=!0;continue}v=e.ascentTable[c],_=Qp(e,r,t),y=!1;break;case`text`:{a.beginPath(),a.font=$p(i);let e=h+_,n=g+v;if(i.underline){let t=Gp(i.color||0);a.lineWidth=o,a.strokeStyle=`rgba(${t.R},${t.G},${t.B},${t.A})`,a.beginPath(),a.moveTo(e,n+2),a.lineTo(e+r.w,n+2),a.stroke()}t.thickness&&a.strokeText(r.text,e,n),a.fillText(r.text,e,n),h+=r.w}break;case`image`:break;default:break}}if(t.focusVisible&&t.focusIndex>=e.textTable.length){let n=e.textTable[t.focusIndex-1];if(n){let e=Gp(n.textFormat.color||0);a.strokeStyle=`rgba(${e.R},${e.G},${e.B},${e.A})`;let t=h+_+.1,r=g+v;a.beginPath(),n.mode===`text`?a.moveTo(t,r-n.y):a.moveTo(t,r+n.h),a.lineTo(t,r),a.stroke()}}return a.restore(),i},tm=new TextDecoder,nm=(e,t)=>{let n=e.subarray(t,t+6);t+=6;let r=e.subarray(t,t+8);t+=8;let i=e.subarray(t,t+4);t+=4;let a=e[t++],o=e[t++],s=e[t++],c=e[t++],l=`${e[t++]}`,u=e[t++],d=e[t++],f=!!(d&1),p=!!(d&2),m=e[t++],h=e[t++],g=`${e[t++]}`,_;if(!e[t++]){let n=Math.ceil(Math.abs(s-a)*m),r=Math.ceil(Math.abs(c-o)*h),i=!!e[t++];_=i?W.get(l,`${u}`):$.createNode(n,r),i||W.set(l,`${u}`,_);let d=e[t++],f=new Uint8Array(e.subarray(t,t+d));t+=d;let p=`none`;switch(e[t++]){case 0:p=`center`;break;case 1:p=`left`;break;case 2:p=`none`;break;case 3:p=`right`;break}let g={width:n,height:r,autoSize:p,stopIndex:e[t++],scrollX:e[t++],scrollY:e[t++],textWidth:e[t++],textHeight:e[t++],rawWidth:e[t++],rawHeight:e[t++],focusIndex:e[t++],selectIndex:e[t++],focusVisible:!!e[t++],thickness:e[t++],thicknessColor:e[t++],wordWrap:!!e[t++],border:!!e[t++],borderColor:e[t++],background:!!e[t++],backgroundColor:e[t++],defaultColor:e[t++],defaultSize:e[t++]},v=em(JSON.parse(tm.decode(f)),g,m,h),y=$.currentAttachmentObject,b=$.atlasAttachmentObject;b&&$.bind(b),$.reset(),$.beginNodeRendering(_);let x=b?b.height-_.y-r:0;$.setTransform(1,0,0,1,_.x,x),$.drawElement(_,v),$.endNodeRendering(),y&&$.bind(y)}else if(_=W.get(l,`${u}`),!_)return t;let v=e[t++];if(e[t++]){let a=!!e[t++],o=e.subarray(t,t+4);t+=4;let s=e[t++],c=e.subarray(t,t+s),l=Math.ceil(Math.abs(i[2]-i[0])),u=Math.ceil(Math.abs(i[3]-i[1]));return $.applyFilter(_,g,!!Math.max(+f,+a),l,u,!1,n,r,Yp(v),o,c),t+=s,t}if($.globalAlpha=Math.min(Math.max(0,r[3]+r[7]/255),1),$.imageSmoothingEnabled=!0,$.globalCompositeOperation=Yp(v),p){let e=n[0]*a+n[2]*o+n[4],t=n[1]*a+n[3]*o+n[5];$.setTransform(n[0]/m,n[1]/m,n[2]/h,n[3]/h,e,t)}else{let e=Math.atan2(n[1],n[0]),t=Math.atan2(-n[2],n[3]);if(e||t){let r=a*m,i=o*h,s=Math.cos(e),c=Math.sin(e),l=Math.cos(t),u=Math.sin(t);$.setTransform(s,c,-u,l,r*s-i*u+n[4],r*c+i*l+n[5])}else $.setTransform(1,0,0,1,i[0],i[1])}return $.drawDisplayObject(_,i[0],i[1],i[2],i[3],r),t},rm=(e,t,n)=>{let r=e.subarray(t,t+6);t+=6;let i=e.subarray(t,t+8);t+=8;let a=e.subarray(t,t+4);t+=4;let o=e[t++],s=e[t++],c=e[t++],l=e[t++],u=`${e[t++]}`,d=!!e[t++],f=`${e[t++]}`,p;if(!e[t++]){let r=Math.abs(c-o),i=Math.abs(l-s),a=!!e[t++];if(p=a?W.get(u,`0`):$.createNode(r,i),a||W.set(u,`0`,p),n&&n.length){let e=$.currentAttachmentObject,t=$.atlasAttachmentObject;t&&$.bind(t),$.reset(),$.beginNodeRendering(p);let r=t?t.height-p.y-i:0;$.setTransform(1,0,0,1,p.x,r);let a=n.shift();$.drawElement(p,a,!0),$.endNodeRendering(),e&&$.bind(e)}}else if(p=W.get(u,`0`),!p)return t;let m=e[t++];if(e[t++]){let n=!!e[t++],o=e.subarray(t,t+4);t+=4;let s=e[t++],c=e.subarray(t,t+s),l=Math.ceil(Math.abs(a[2]-a[0])),u=Math.ceil(Math.abs(a[3]-a[1]));return $.applyFilter(p,f,!!Math.max(+d,+n),l,u,!0,r,i,Yp(m),o,c),t+=s,t}return $.globalAlpha=Math.min(Math.max(0,i[3]+i[7]/255),1),$.imageSmoothingEnabled=!0,$.globalCompositeOperation=Yp(m),$.setTransform(r[0],r[1],r[2],r[3],r[4],r[5]),$.drawDisplayObject(p,a[0],a[1],a[2],a[3],i),t},im=(e,t)=>{let n=e[t++];for(let r=0;r<n;++r)switch(e[t++]){case 0:t=im(e,t);break;case 1:t=Zp(e,t);break;default:break}return t},am=(e,t,n)=>{let r=0,i=!0,a=Yp(e[t++]),o=!!e[t++],s=0,c=0,l=!1,u=!1,d=``,f=``,p=1,m=1,h=null,g=null,_=null,v=null;if(o){s=e[t++],c=e[t++];let n=e[t++];if(l=n===1,u=n===2,u){let n=!!e[t++];if(d=`${e[t++]}`,f=`${e[t++]}`,h=e.subarray(t,t+4),t+=4,p=e[t++],m=e[t++],_=e.subarray(t,t+6),t+=6,v=e.subarray(t,t+8),t+=8,n){let e=W.get(d,`bNode`);return e&&($.globalAlpha=Math.min(Math.max(0,v[3]+v[7]/255),1),$.globalCompositeOperation=a,$.setTransform(_[0]/p,_[1]/p,_[2]/m,_[3]/m,_[4],_[5]),$.drawDisplayObject(e,h[0],h[1],h[2],h[3],v)),t}t+=e[t]+1}else if(l){let n=!!e[t++];if(d=`${e[t++]}`,f=`${e[t++]}`,n)return h=e.subarray(t,t+4),t+=4,_=e.subarray(t,t+6),t+=6,v=e.subarray(t,t+8),t+=8,$.containerDrawCachedFilter(a,_,v,h,d,f),t;h=e.subarray(t,t+4),t+=4,_=e.subarray(t,t+6),t+=6,v=e.subarray(t,t+8),t+=8;let r=e[t++];g=e.subarray(t,t+r),t+=r}else _=e.subarray(t,t+6),t+=6,v=e.subarray(t,t+8),t+=8}let y=null;u?y=$.containerBeginAtlasNode(s,c):o&&$.containerBeginLayer(s,c);let b=!!e[t++];if(b){switch($.drawArraysInstanced(),$.save(),$.beginMask(),$.setMaskBounds(e[t++],e[t++],e[t++],e[t++]),e[t++]){case 0:t=im(e,t);break;case 1:t=Zp(e,t);break;default:break}$.endMask()}let x=e[t++];for(let a=0;x>a;a++){let a=e[t++],o=e[t++];if(r&&a>r&&(i&&($.restore(),$.leaveMask()),r=0,i=!0),i){if(o){if(r=o,i=!!e[t++],!i)continue;switch($.drawArraysInstanced(),$.save(),$.beginMask(),$.setMaskBounds(e[t++],e[t++],e[t++],e[t++]),e[t++]){case 0:t=im(e,t);break;case 1:t=Zp(e,t);break;default:break}$.endMask();continue}if(e[t++])switch(e[t++]){case 0:t=am(e,t,n);break;case 1:t=Xp(e,t);break;case 2:t=nm(e,t);break;case 3:t=rm(e,t,n);break;default:break}}}if((r||b)&&($.restore(),$.leaveMask()),y){$.containerEndAtlasNode();let e=W.get(d,`bNode`);e&&$.removeNode(e),W.set(d,`bNode`,y),W.set(d,`bKey`,f),$.globalAlpha=Math.min(Math.max(0,v[3]+v[7]/255),1),$.globalCompositeOperation=a,$.setTransform(_[0]/p,_[1]/p,_[2]/m,_[3]/m,_[4],_[5]),$.drawDisplayObject(y,h[0],h[1],h[2],h[3],v)}else o&&$.containerEndLayer(a,_,v,l,h,g,d,f);return t},om=-1,sm=(e,t)=>{Vp()&&Hp(),$.clearTransferBounds();let n=0,r=e[n++];for(om!==r&&(om=r,om===-1?$.updateBackgroundColor(0,0,0,0):$.updateBackgroundColor((om>>16&255)/255,(om>>8&255)/255,(om&255)/255,1)),$.reset(),$.setTransform(1,0,0,1,0,0),$.fillBackgroundColor();e.length>n;){if(!e[n++])continue;let r=e[n++];switch(r){case 0:n=am(e,n,t);break;case 1:n=Xp(e,n);break;case 2:n=nm(e,n);break;case 3:n=rm(e,n,t);break;default:console.error(`unknown type`,r);break}}$.drawArraysInstanced(),$.transferMainCanvas()},cm=e=>{for(let t=0;t<e.length;++t){let n=`${e[t]}`;if(!W.has(n))continue;let r=W.getById(n);for(let e of r.values())$.removeNode(e);W.removeById(n)}},lm=async(e,t,n,r=0,i=0,a)=>{$.clearTransferBounds();let o=1;$.reset(),$.setTransform(1,0,0,1,0,0);let s=$.$clearColorR,c=$.$clearColorG,l=$.$clearColorB,u=$.$clearColorA;for($.updateBackgroundColor((r>>16&255)/255,(r>>8&255)/255,(r&255)/255,i),$.fillBackgroundColor();e.length>o;){if(!e[o++])continue;let t=e[o++];switch(t){case 0:o=am(e,o,a);break;case 1:o=Xp(e,o);break;case 2:o=nm(e,o);break;case 3:o=rm(e,o,a);break;default:console.error(`unknown type`,t);break}}$.drawArraysInstanced();let d=await $.createImageBitmap(t,n);return $.updateBackgroundColor(s,c,l,u),d},um=new class{state;queue;constructor(){this.state=`deactivate`,this.queue=[]}async execute(){for(this.state=`active`;this.queue.length;){let e=this.queue.shift();if(e)switch(e.command){case`render`:sm(e.buffer.subarray(0,e.length),e.imageBitmaps),globalThis.postMessage({message:`render`,buffer:e.buffer},[e.buffer.buffer]);break;case`resize`:qp(e.buffer[0],e.buffer[1],!!e.buffer[2]);break;case`initialize`:await Kp(e.canvas,e.devicePixelRatio);break;case`removeCache`:cm(e.buffer);break;case`cacheClear`:W.reset();break;case`capture`:{let t=await lm(e.buffer.subarray(0,e.length),e.width,e.height,e.bgColor,e.bgAlpha,e.imageBitmaps);globalThis.postMessage({message:`capture`,buffer:e.buffer,imageBitmap:t},[e.buffer.buffer,t])}break;default:break}}this.state=`deactivate`}};self.addEventListener(`message`,async e=>{um.queue.push(e.data),um.state===`deactivate`&&await um.execute()})})();",y=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,v],{type:`text/javascript;charset=utf-8`});function b(e){let t;try{if(t=y&&(self.URL||self.webkitURL).createObjectURL(y),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(v),{name:e?.name})}}var x=new b,S=e=>{let t=e.transferControlToOffscreen();x.postMessage({command:`initialize`,canvas:t,devicePixelRatio:window.devicePixelRatio},[t])},C=class{static get AT_TARGET(){return 2}static get BUBBLING_PHASE(){return 3}static get CAPTURING_PHASE(){return 1}},w=class{type;bubbles;listener;target;currentTarget;eventPhase;_$stopImmediatePropagation;_$stopPropagation;constructor(e,t=!1){this.type=`${e}`,this.bubbles=t,this.target=null,this.currentTarget=null,this.eventPhase=C.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}},T=new Map,E=[],D=()=>E.length?E.pop():[],ee=e=>{10>E.length&&(e.length=0,E.push(e))},te=null,O=e=>{te=e},ne=()=>te,k=class e extends w{constructor(t,n=!0){return super(t,n),new Proxy(this,{get:(t,n)=>{if(n in t)return t[n];let r=ne();if(r)switch(r.type){case e.KEY_DOWN:case e.KEY_UP:return n in r?$event[n]:void 0;default:return}}})}static get KEY_DOWN(){return`keydown`}static get KEY_UP(){return`keyup`}},re=(e,t,n,r=!1,i=0)=>{let a;switch(t){case w.ENTER_FRAME:case k.KEY_DOWN:case k.KEY_UP:(!T.size||!T.has(t))&&T.set(t,D()),a=T.get(t);break;default:e._$events||=new Map,(!e._$events.size||!e._$events.has(t))&&e._$events.set(t,D()),a=e._$events.get(t);break}let o=a.length,s=0;for(;s<o;++s){let t=a[s];if(r===t.useCapture&&t.target===e&&t.listener===n)break}if(o===s)a.push({listener:n,priority:i,useCapture:r,target:e});else{let t=a[s];t.listener=n,t.priority=i,t.useCapture=r,t.target=e}a.length>1&&a.sort((e,t)=>{switch(!0){case e.priority>t.priority:return-1;case e.priority<t.priority:return 1;default:return 0}})},ie=(e,t)=>{switch(t){case w.ENTER_FRAME:case k.KEY_DOWN:case k.KEY_UP:return!!(T.size&&T.has(t));default:return!!(e._$events&&e._$events.size&&e._$events.has(t))}},ae=(e,t,n,r=!1)=>{let i;switch(t){case w.ENTER_FRAME:case k.KEY_DOWN:case k.KEY_UP:if(!T.size||!T.has(t))return;i=T.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 e=0;e<i.length;++e){let t=i[e];if(r===t.useCapture&&t.listener===n){i.splice(e,1);break}}if(!i.length){T.has(t)&&T.delete(t),e._$events&&e._$events.has(t)&&(e._$events.delete(t),e._$events.size||(e._$events=null)),ee(i);return}i.length>1&&i.sort((e,t)=>{switch(!0){case e.priority>t.priority:return-1;case e.priority<t.priority:return 1;default:return 0}})}},oe=(e,t,n=!1)=>{let r;switch(t){case w.ENTER_FRAME:case k.KEY_DOWN:case k.KEY_UP:if(!T.size||!T.has(t))return;r=T.get(t);break;default:if(!e._$events||!e._$events.size||!e._$events.has(t))return;r=e._$events.get(t);break}if(!r)return;let i=D();for(let e=0;e<r.length;++e){let t=r[e];n!==t.useCapture&&i.push(t)}if(!i.length){T.has(t)&&T.delete(t),e._$events&&e._$events.has(t)&&(e._$events.delete(t),e._$events.size||(e._$events=null)),ee(i),ee(r);return}i.length>1&&i.sort((e,t)=>{switch(!0){case e.priority>t.priority:return-1;case e.priority<t.priority:return 1;default:return 0}}),T.has(t)?T.set(t,i):e._$events?.set(t,i),ee(r)},se=(e,t)=>{if(e.hasEventListener(t))return!0;if(`parent`in e){let n=e.parent;for(;n;){if(n.hasEventListener(t))return!0;if(!(`parent`in n))break;n=n.parent}}return!1},ce=(e,t)=>{switch(t.type){case w.ENTER_FRAME:case k.KEY_DOWN:case k.KEY_UP:{if(!T.size||!T.has(t.type))return!1;let e=T.get(t.type);if(!e.length)return!1;for(let n=0;n<e.length;++n){let r=e[n];t.eventPhase=C.AT_TARGET,t.target=t.currentTarget=r.target;try{t.listener=r.listener,r.listener(t)}catch(e){return console.error(e),!1}}}return!0;default:{t.target=e;let n=null;if(e._$events&&e._$events.size&&e._$events.has(t.type)){let r=e._$events.get(t.type);r&&(n=r.slice(0))}let r=D();if(`parent`in e){let n=e.parent;for(;n;){if(n.hasEventListener(t.type)){let e=n._$events&&n._$events.has(t.type)?n._$events.get(t.type):null;e&&r.push(e)}if(!(`parent`in n))break;n=n.parent}}if(!n&&!r.length)return n&&ee(n),ee(r),!1;if(r.length)switch(t.eventPhase=C.CAPTURING_PHASE,!0){case t._$stopImmediatePropagation:case t._$stopPropagation:break;default:for(let e=r.length-1;e>-1;--e){let n=r[e];for(let e=0;e<n.length;++e){let r=n[e];if(r.useCapture){t.currentTarget=r.target;try{t.listener=r.listener,r.listener.call(null,t)}catch(e){return console.error(e),!1}if(t._$stopImmediatePropagation)break}}if(t._$stopImmediatePropagation)break}break}if(n&&!t._$stopImmediatePropagation&&!t._$stopPropagation){t.eventPhase=C.AT_TARGET;for(let e=0;e<n.length;++e){let r=n[e];if(!r.useCapture){t.currentTarget=r.target;try{t.listener=r.listener,r.listener.call(null,t)}catch(e){return console.error(e),!1}if(t._$stopImmediatePropagation)break}}ee(n)}if(r.length){switch(t.eventPhase=C.BUBBLING_PHASE,!0){case t._$stopImmediatePropagation:case t._$stopPropagation:case!t.bubbles:break;default:for(let e=0;e<r.length;++e){let n=r[e];for(let e=0;e<n.length;++e){let r=n[e];if(!r.useCapture){t.currentTarget=r.target;try{t.listener=r.listener,r.listener.call(null,t)}catch(e){return console.error(e),!1}if(t._$stopImmediatePropagation)break}}if(t._$stopImmediatePropagation)break}break}ee(r)}}return!0}},le=class{_$events;constructor(){this._$events=null}addEventListener(e,t,n=!1,r=0){this._$events||=new Map,re(this,e,t,n,r)}dispatchEvent(e){return ce(this,e)}hasEventListener(e){return ie(this,e)}removeEventListener(e,t,n=!1){ae(this,e,t,n)}removeAllEventListener(e,t=!1){oe(this,e,t)}willTrigger(e){return se(this,e)}},ue=class e extends w{constructor(t,n=!0){return super(t,n),new Proxy(this,{get:(t,n)=>{if(n in t)return t[n];let r=ne();if(r)switch(r.type){case e.FOCUS_IN:case e.FOCUS_OUT:return n in r?$event[n]:void 0;default:return}}})}static get FOCUS_IN(){return`focusin`}static get FOCUS_OUT(){return`focusout`}},de=class extends w{status;responseHeaders;responseURL;constructor(e,t=!1,n=0,r=``,i=[]){super(e,t),this.status=n|0,this.responseHeaders=i,this.responseURL=r}static get HTTP_STATUS(){return`httpStatus`}},fe=class extends w{text;constructor(e,t=!1,n=``){super(e,t),this.text=`${n}`}static get IO_ERROR(){return`ioError`}},A=class e extends w{constructor(t,n=!0){return super(t,n),new Proxy(this,{get:(t,n)=>{if(n in t)return t[n];let r=ne();if(r)switch(r.type){case e.POINTER_DOWN:case e.POINTER_MOVE:case e.POINTER_UP:case e.POINTER_LEAVE:case e.POINTER_OVER:case e.POINTER_OUT:return n in r?$event[n]: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`}},j=class extends w{bytesLoaded;bytesTotal;constructor(e,t=!1,n=0,r=0){super(e,t),this.bytesLoaded=n|0,this.bytesTotal=r|0}static get PROGRESS(){return`progress`}},pe=class extends w{static get PLAY(){return`play`}static get PLAYING(){return`playing`}static get PAUSE(){return`pause`}static get SEEK(){return`seek`}},me=class extends w{static get UPDATE(){return`jobupdate`}static get STOP(){return`jobstop`}},he=class e extends w{constructor(t,n=!0){return super(t,n),new Proxy(this,{get:(t,n)=>{if(n in t)return t[n];let r=ne();if(r&&r.type===e.WHEEL)return n in r?$event[n]:void 0}})}static get WHEEL(){return`wheel`}},ge=[],_e=e=>{e.size&&e.clear(),ge.push(e)},ve=()=>ge.pop()||new Map,ye=(e,t,n)=>{n.clear(),e.$timerId!==null&&clearTimeout(e.$timerId);for(let n of t.values()){for(let t of n.values())t&&e.destroy(t);_e(n)}t.clear()},be=(e,t)=>{if(!(!t||typeof t!=`object`)&&`canvas`in t){let n=t.canvas,r=n.width,i=n.height;t.clearRect(0,0,r+1,i+1),n.width=n.height=1,e.push(n)}},xe=(e,t,n)=>{if(!e.has(t))return;let r=e.get(t);r.has(n)&&(r.delete(n),r.size||(_e(r),e.delete(t)))},Se=(e,t,n)=>{if(!t.has(n))return;let r=t.get(n);for(let t of r.values())e.destroy(t);t.delete(n),_e(r)},Ce=(e,t,n)=>{let r=e.get(t)||null;return r?(r.delete(`trash`),r.get(n)||null):null},we=(e,t,n,r,i=null)=>{t.has(n)||t.set(n,ve());let a=t.get(n);if(i===null){if(!a.has(r))return;e.destroy(a.get(r)),a.delete(r),a.size||(t.delete(n),_e(a));return}a.set(r,i)},Te=(e,t,n=``)=>n?e.has(t)?e.get(t).has(n):!1:e.has(t),Ee=(e,t,n)=>{let r=2166136261,i=e*100|0;return r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619),i=t*100|0,r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619),n&&(i=n*100|0,r^=i&255,r=Math.imul(r,16777619),r^=i>>>8&255,r=Math.imul(r,16777619),r^=i>>>16&255,r=Math.imul(r,16777619),r^=i>>>24,r=Math.imul(r,16777619)),(r>>>0)%16777216},De=(e,t,n,r)=>{let i=2166136261,a=e*100|0;return i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=t*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=n*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),a=r*100|0,i^=a&255,i=Math.imul(i,16777619),i^=a>>>8&255,i=Math.imul(i,16777619),i^=a>>>16&255,i=Math.imul(i,16777619),i^=a>>>24,i=Math.imul(i,16777619),(i>>>0)%16777216},Oe=(e,t,n,r)=>{if(n.has(r))return;let i=t.get(r);i&&(i.set(`trash`,!0),n.set(r,i),e.$timerId!==null&&clearTimeout(e.$timerId),e.$removeCache=!1,e.$timerId=setTimeout(()=>{e.$removeCache=!0,e.$timerId=null},1e3))},ke=(e,t)=>{if(t.size){for(let[n,r]of t)r.has(`trash`)&&(e.removeById(n),e.$removeIds.push(+n));t.clear(),e.$removeCache=!1}},M=new class{_$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(){ye(this,this._$store,this._$trash)}destroy(e=null){be(this._$pool,e)}getCanvas(){return this._$pool.pop()||document.createElement(`canvas`)}remove(e,t){xe(this._$store,e,t)}removeTimer(e){Oe(this,this._$store,this._$trash,e)}removeTimerScheduledCache(){ke(this,this._$trash)}removeById(e){Se(this,this._$store,e)}getById(e){return this._$store.get(e)}get(e,t){return Ce(this._$store,e,t)}set(e,t,n=null){we(this,this._$store,e,t,n)}has(e,t=``){return Te(this._$store,e,t)}generateKeys(e,t,n){return Ee(e,t,n)}generateFilterKeys(e,t,n,r){return De(e,t,n,r)}},Ae=e=>{let t=M.getCanvas();t.width=e.width,t.height=e.height;let n=t.getContext(`2d`,{willReadFrequently:!0});n.drawImage(e,0,0);let r=n.getImageData(0,0,e.width,e.height),i=new Uint8Array(r.data.buffer);return M.destroy(n),i},je=e=>{let t=M.getCanvas();t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.setTransform(1,0,0,1,0,0),n.drawImage(e,0,0);let r=n.getImageData(0,0,e.width,e.height),i=new Uint8Array(r.data.buffer);return M.destroy(n),i},Me=class e{width;height;buffer;constructor(e=0,t=0){this.width=e|0,this.height=t|0,this.buffer=null}set image(e){if(!e){this.width=0,this.height=0,this.buffer=null;return}this.buffer=Ae(e),this.width=e.width,this.height=e.height}set canvas(e){if(!e){this.width=0,this.height=0,this.buffer=null;return}this.buffer=je(e),this.width=e.width,this.height=e.height}clone(){let t=new e(this.width,this.height);return this.buffer!==null&&(t.buffer=this.buffer.slice()),t}},Ne=class{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`}},Pe=(e,t)=>{let n=N.multiply(e._$colorTransform,t._$colorTransform);e._$colorTransform[0]=n[0],e._$colorTransform[1]=n[1],e._$colorTransform[2]=n[2],e._$colorTransform[3]=n[3],e._$colorTransform[4]=n[4],e._$colorTransform[5]=n[5],e._$colorTransform[6]=n[6],e._$colorTransform[7]=n[7],N.release(n)},Fe=[],Ie=(e=1,t=0,n=0,r=1,i=0,a=0)=>{let o=Fe.pop()||new Float32Array(6);return o[0]=e,o[1]=t,o[2]=n,o[3]=r,o[4]=i,o[5]=a,o},Le=e=>{Fe.push(e)},Re=[],ze=(e=1,t=1,n=1,r=1,i=0,a=0,o=0,s=0)=>{let c=Re.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c},Be=e=>{Re.push(e)},Ve=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},N=class e{_$colorTransform;constructor(e=1,t=1,n=1,r=1,i=0,a=0,o=0,s=0){this._$colorTransform=ze(e,t,n,r,i,a,o,s)}get rawData(){return this._$colorTransform}get alphaMultiplier(){return this._$colorTransform[3]}set alphaMultiplier(e){this._$colorTransform[3]=Ve(e,0,1,1)}get alphaOffset(){return this._$colorTransform[7]}set alphaOffset(e){this._$colorTransform[7]=Ve(e,-255,255,0)}get blueMultiplier(){return this._$colorTransform[2]}set blueMultiplier(e){this._$colorTransform[2]=Ve(e,0,1,1)}get blueOffset(){return this._$colorTransform[6]}set blueOffset(e){this._$colorTransform[6]=Ve(e,-255,255,0)}get greenMultiplier(){return this._$colorTransform[1]}set greenMultiplier(e){this._$colorTransform[1]=Ve(e,0,1,1)}get greenOffset(){return this._$colorTransform[5]}set greenOffset(e){this._$colorTransform[5]=Ve(e,-255,255,0)}get redMultiplier(){return this._$colorTransform[0]}set redMultiplier(e){this._$colorTransform[0]=Ve(e,0,1,1)}get redOffset(){return this._$colorTransform[4]}set redOffset(e){this._$colorTransform[4]=Ve(e,-255,255,0)}clone(){return new e(...this._$colorTransform)}concat(e){Pe(this,e)}static multiply(e,t){return ze(e[0]*t[0],e[1]*t[1],e[2]*t[2],e[3]*t[3],e[0]*t[4]+e[4],e[1]*t[5]+e[5],e[2]*t[6]+e[6],e[3]*t[7]+e[7])}static release(e){Be(e)}},He=e=>new F(e._$matrix[0],e._$matrix[1],e._$matrix[2],e._$matrix[3],e._$matrix[4],e._$matrix[5]),Ue=(e,t)=>{let n=e._$matrix,r=t._$matrix,i=n[0]*r[0],a=0,o=0,s=n[3]*r[3],c=n[4]*r[0]+r[4],l=n[5]*r[3]+r[5];(n[1]||n[2]||r[1]||r[2])&&(i+=n[1]*r[2],s+=n[2]*r[1],a+=n[0]*r[1]+n[1]*r[3],o+=n[2]*r[0]+n[3]*r[2],c+=n[5]*r[2],l+=n[4]*r[1]),n[0]=i,n[1]=a,n[2]=o,n[3]=s,n[4]=c,n[5]=l},We=(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]},Ge=(e,t,n,r=0,i=0,a=0)=>{e.identity(),e.rotate(r),e.scale(t,n),e.translate(i,a)},Ke=(e,t,n,r=0,i=0,a=0)=>{let o=e._$matrix;if(o[0]=t/1638.4,o[3]=n/1638.4,r){let e=Math.cos(r),t=Math.sin(r);o[1]=t*o[3],o[2]=-t*o[0],o[0]*=e,o[3]*=e}else o[1]=0,o[2]=0;o[4]=i+t/2,o[5]=a+n/2},qe=(e,t)=>new P(e.x+t.x,e.y+t.y),Je=e=>new P(e.x,e.y),Ye=(e,t)=>{e.x=t.x,e.y=t.y},Xe=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),Ze=(e,t)=>e.x===t.x&&e.y===t.y,Qe=(e,t,n)=>new P(e.x+(t.x-e.x)*(1-n),e.y+(t.y-e.y)*(1-n)),$e=(e,t)=>{let n=t/e.length;e.x*=n,e.y*=n},et=(e,t,n)=>{e.x+=t,e.y+=n},tt=(e,t)=>new P(e*Math.cos(t),e*Math.sin(t)),nt=(e,t,n)=>{e.x=t,e.y=n},rt=(e,t)=>new P(e.x-t.x,e.y-t.y),P=class{x;y;constructor(e=0,t=0){this.x=e,this.y=t}get length(){return Math.sqrt(this.x**2+this.y**2)}add(e){return qe(this,e)}clone(){return Je(this)}copyFrom(e){Ye(this,e)}static distance(e,t){return Xe(e,t)}equals(e){return Ze(this,e)}static interpolate(e,t,n){return Qe(e,t,n)}normalize(e){$e(this,e)}offset(e,t){et(this,e,t)}static polar(e,t){return tt(e,t)}setTo(e,t){nt(this,e,t)}subtract(e){return rt(this,e)}},it=(e,t)=>new P(t.x*e._$matrix[0]+t.y*e._$matrix[2],t.x*e._$matrix[1]+t.y*e._$matrix[3]),at=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},ot=e=>{let t=e._$matrix[0],n=e._$matrix[1],r=e._$matrix[2],i=e._$matrix[3],a=e._$matrix[4],o=e._$matrix[5];if(n===0&&r===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]*a,e._$matrix[5]=-e._$matrix[3]*o;else{let s=t*i-n*r;if(s){let c=1/s;e._$matrix[0]=i*c,e._$matrix[1]=-n*c,e._$matrix[2]=-r*c,e._$matrix[3]=t*c,e._$matrix[4]=-(e._$matrix[0]*a+e._$matrix[2]*o),e._$matrix[5]=-(e._$matrix[1]*a+e._$matrix[3]*o)}}},st=(e,t)=>{let n=e._$matrix,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5];n[0]=r*Math.cos(t)-i*Math.sin(t),n[1]=r*Math.sin(t)+i*Math.cos(t),n[2]=a*Math.cos(t)-o*Math.sin(t),n[3]=a*Math.sin(t)+o*Math.cos(t),n[4]=s*Math.cos(t)-c*Math.sin(t),n[5]=s*Math.sin(t)+c*Math.cos(t)},ct=(e,t,n)=>{let r=e._$matrix;r[0]*=t,r[2]*=t,r[4]*=t,r[1]*=n,r[3]*=n,r[5]*=n},lt=(e,t,n,r,i,a,o)=>{let s=e._$matrix;s[0]=t,s[1]=n,s[2]=r,s[3]=i,s[4]=a,s[5]=o},ut=(e,t)=>{let n=t.x,r=t.y,i=e._$matrix;return new P(n*i[0]+r*i[2]+i[4],n*i[1]+r*i[3]+i[5])},dt=(e,t,n)=>{e.tx+=t,e.ty+=n},F=class{_$matrix;constructor(e=1,t=0,n=0,r=1,i=0,a=0){this._$matrix=Ie(e,t,n,r,i,a)}get a(){return this._$matrix[0]}set a(e){this._$matrix[0]=e}get b(){return this._$matrix[1]}set b(e){this._$matrix[1]=e}get c(){return this._$matrix[2]}set c(e){this._$matrix[2]=e}get d(){return this._$matrix[3]}set d(e){this._$matrix[3]=e}get tx(){return this._$matrix[4]}set tx(e){this._$matrix[4]=e}get ty(){return this._$matrix[5]}set ty(e){this._$matrix[5]=e}get rawData(){return this._$matrix}clone(){return He(this)}concat(e){Ue(this,e)}copyFrom(e){We(this,e)}createBox(e,t,n=0,r=0,i=0){Ge(this,e,t,n,r,i)}createGradientBox(e,t,n=0,r=0,i=0){Ke(this,e,t,n,r,i)}deltaTransformPoint(e){return it(this,e)}identity(){at(this)}invert(){ot(this)}rotate(e){st(this,e)}scale(e,t){ct(this,e,t)}setTo(e,t,n,r,i,a){lt(this,e,t,n,r,i,a)}transformPoint(e){return ut(this,e)}translate(e,t){dt(this,e,t)}static multiply(e,t){let n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],s=e[5],c=t[0],l=t[1],u=t[2],d=t[3],f=t[4],p=t[5];return Ie(n*c+i*l,r*c+a*l,n*u+i*d,r*u+a*d,n*f+i*p+o,r*f+a*p+s)}static release(e){Le(e)}},ft=e=>new Ot(e.x,e.y,e.width,e.height),pt=(e,t,n)=>e.x<=t&&e.y<=n&&e.right>t&&e.bottom>n,mt=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>t.x&&e.bottom>t.y,ht=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.right>=t.right&&e.bottom>=t.bottom,gt=(e,t)=>{e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height},_t=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,vt=(e,t,n)=>{e.x-=t,e.width+=2*t,e.y-=n,e.height+=2*n},yt=(e,t)=>{e.x-=t.x,e.width+=2*t.x,e.y-=t.y,e.height+=2*t.y},bt=(e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.right,t.right),a=Math.min(e.bottom,t.bottom),o=i-n,s=a-r;return o>0&&s>0?new Ot(n,r,o,s):new Ot(0,0,0,0)},xt=(e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.right,t.right),a=Math.min(e.bottom,t.bottom);return i-n>0&&a-r>0},St=e=>e.width<=0||e.height<=0,Ct=(e,t,n)=>{e.x+=t,e.y+=n},wt=(e,t)=>{e.x+=t.x,e.y+=t.y},Tt=e=>{e.x=e.y=e.width=e.height=0},Et=(e,t,n,r,i)=>{e.x=t,e.y=n,e.width=r,e.height=i},Dt=(e,t)=>e.isEmpty()?t.clone():t.isEmpty()?e.clone():new Ot(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)),Ot=class{x;y;width;height;constructor(e=0,t=0,n=0,r=0){this.x=e,this.y=t,this.width=n,this.height=r}get bottom(){return this.y+this.height}set bottom(e){this.height=e-this.y}get bottomRight(){return new P(this.right,this.bottom)}set bottomRight(e){this.right=e.x,this.bottom=e.y}get left(){return this.x}set left(e){this.width=this.right-e,this.x=e}get right(){return this.x+this.width}set right(e){this.width=e-this.x}get size(){return new P(this.width,this.height)}set size(e){this.width=e.x,this.height=e.y}get top(){return this.y}set top(e){this.height=this.bottom-e,this.y=e}get topLeft(){return new P(this.x,this.y)}set topLeft(e){this.left=e.x,this.top=e.y}clone(){return ft(this)}contains(e,t){return pt(this,e,t)}containsPoint(e){return mt(this,e)}containsRect(e){return ht(this,e)}copyFrom(e){gt(this,e)}equals(e){return _t(this,e)}inflate(e,t){vt(this,e,t)}inflatePoint(e){yt(this,e)}intersection(e){return bt(this,e)}intersects(e){return xt(this,e)}isEmpty(){return St(this)}offset(e,t){Ct(this,e,t)}offsetPoint(e){wt(this,e)}setEmpty(){Tt(this)}setTo(e,t,n,r){Et(this,e,t,n,r)}union(e){return Dt(this,e)}},I=e=>{e.changed=!0;let t=e.parent;for(;t&&!t.changed;)t.changed=!0,t=t.parent},kt=e=>{if(e.placeObject)return e.placeObject;let t=e.placeId;if(t===-1)return null;let n=e.parent;if(!n)return null;let r=n.loaderInfo;if(!r||!r.data)return null;let i=r.data.characters[n.characterId],a=n.isTimelineEnabled?n.currentFrame:1,o=i.placeMap[a];if(!o||!(t in o))return null;let s=o[t],c=i.placeObjects[s];return c?(e.placeObject=c,c):null},At=new P,jt=new Float32Array([1,0,0,1,0,0]),Mt=0,Nt=()=>Mt++,Pt=[],Ft=[],It=[],Lt=[],L=(e=0,t=0,n=0,r=0,i=0,a=0)=>{let o=It.pop()||new Float32Array(6);return o[0]=e,o[1]=t,o[2]=n,o[3]=r,o[4]=i,o[5]=a,o},Rt=e=>{It.push(e)},zt=(e=1,t=1,n=1,r=1,i=0,a=0,o=0,s=0)=>{let c=Lt.pop()||new Float32Array(8);return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c},Bt=[],Vt=()=>Bt.pop()||new Map,Ht=e=>{e.clear(),Bt.push(e)},R=(...e)=>{let t=Pt.pop()||[];return e.length&&t.push(...e),t},z=e=>{e.length&&=0,Pt.push(e)},B=(e,t,n,r)=>{let i=Ft.length?Ft.pop():new Float32Array(4);return i[0]=e,i[1]=t,i[2]=n,i[3]=r,i},V=e=>{Ft.push(e)},Ut=e=>{let t=null;switch(e.method.toUpperCase()){case`GET`:if(e.data){let t=e.url.split(`?`);t[1]=t.length===1?e.data.toString():`${t[1]}&${e.data.toString()}`,e.url=t.join(`?`)}break;case`PUT`:case`POST`:e.data&&(t=e.data.toString());break;default:break}let n=new XMLHttpRequest;if(n.open(e.method,e.url,!0),n.responseType=e.format,n.withCredentials=e.withCredentials,e.event){let t=Object.keys(e.event);for(let r=0;r<t.length;++r){let i=t[r];n.addEventListener(i,e.event[i])}}for(let t=0;t<e.headers.length;++t){let r=e.headers[t];r&&n.setRequestHeader(r.name,r.value)}n.send(t)},Wt=e=>{let t=R();if(e){let n=e.trim().split(`
|
|
2
|
+
`);for(let e=0;e<n.length;++e){let r=n[e].split(`:`);t.push({name:r[0].trim(),value:r[1].trim()})}}return t},Gt=new WeakMap,Kt=new WeakMap,qt=new Set,Jt=new WeakMap,Yt=document.createElement(`canvas`);Yt.width=Yt.height=1;var Xt=Yt.getContext(`2d`),Zt=e=>Xt?(Xt.fillStyle=e,+`0x${Xt.fillStyle.slice(1)}`):0,Qt=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},$t=[],en=[],tn=new Map,nn=null,rn=e=>{nn=e},an=()=>nn,H=e=>{if(e.$matrix)return e.$matrix.rawData;let t=kt(e);if(!t||!t.matrix)return null;if(!t.typedMatrix){let e=t.matrix;t.typedMatrix=L(e[0],e[1],e[2],e[3],e[4],e[5])}return t.typedMatrix},on=e=>{let t=H(e)||jt,n=e.parent;for(;n;){let e=H(n);e&&(t=F.multiply(e,t)),n=n.parent}return new F(t[0],t[1],t[2],t[3],t[4],t[5])},sn=e=>{if(e.$colorTransform)return e.$colorTransform.rawData;let t=kt(e);if(!t||!t.colorTransform)return null;if(!t.typedColorTransform){let e=t.colorTransform;t.typedColorTransform=zt(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7])}return t.typedColorTransform},cn=e=>{if(e.$alpha!==null)return e.$alpha;if(e.$colorTransform){let t=e.$colorTransform.rawData;return t[3]+t[7]/255}let t=sn(e);return t?t[3]+t[7]/255:1},ln=(e,t)=>{if(t=Qt(t,0,1),e.$alpha===t)return;e.$alpha=t;let n=e.$colorTransform;if(!n){let t=sn(e);n=t?new N(...t):new N}n.alphaMultiplier=t,n.alphaOffset=0,e.$colorTransform=n,I(e)},un=class{$updated;constructor(){this.$updated=!0}canApplyFilter(){return!0}getBounds(e){return e}},U=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},dn=document.createElement(`canvas`);dn.width=dn.height=1;var fn=dn.getContext(`2d`),pn=e=>fn?(fn.fillStyle=e,+`0x${fn.fillStyle.slice(1)}`):0,mn=Math.PI/180,hn=e=>{switch(e){case`full`:return 0;case`inner`:return 1;case`outer`:return 2;default:return 0}},gn=e=>e.strength>0&&e.distance!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,_n=e=>e.blurX>0&&e.blurY>0&&e.quality>0,vn=[.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],yn=(e,t)=>{if(!_n(e))return t;let n=vn[e.quality-1],r=Math.round(e.blurX*n),i=Math.round(e.blurY*n);return t[0]-=r,t[2]+=r,t[1]-=i,t[3]+=i,t},bn=(e,t)=>{if(!gn(e)||e.type===`inner`)return t;yn(e,t);let n=e.angle*mn,r=e.distance,i=Math.abs(Math.cos(n)*r),a=Math.abs(Math.sin(n)*r);return t[0]-=i,t[2]+=i,t[1]-=a,t[3]+=a,t},xn=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],Sn=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,hn(e.type),+e.knockout]),Cn=class e extends un{$filterType=0;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$highlightColor;_$highlightAlpha;_$shadowColor;_$shadowAlpha;_$strength;_$type;_$knockout;constructor(e=4,t=45,n=16777215,r=1,i=0,a=1,o=4,s=4,c=1,l=1,u=`inner`,d=!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=s,this.quality=l,this.distance=e,this.angle=t,this.highlightColor=n,this.highlightAlpha=r,this.shadowColor=i,this.shadowAlpha=a,this.strength=c,this.type=u,this.knockout=d}get angle(){return this._$angle}set angle(e){e=U(e%360,-360,360,45),e!==this._$angle&&(this._$angle=e,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get distance(){return this._$distance}set distance(e){e=U(+e,-255,255,4),e!==this._$distance&&(this._$distance=e,this.$updated=!0)}get highlightAlpha(){return this._$highlightAlpha}set highlightAlpha(e){e=U(+e,0,1,0),e!==this._$highlightAlpha&&(this._$highlightAlpha=e,this.$updated=!0)}get highlightColor(){return this._$highlightColor}set highlightColor(e){e=U(typeof e==`string`?pn(e):e,0,16777215,16777215),e!==this._$highlightColor&&(this._$highlightColor=e,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(e){e=!!e,e!==this._$knockout&&(this._$knockout=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}get shadowAlpha(){return this._$shadowAlpha}set shadowAlpha(e){e=U(e,0,1,0),e!==this._$shadowAlpha&&(this._$shadowAlpha=e,this.$updated=!0)}get shadowColor(){return this._$shadowColor}set shadowColor(e){e=U(typeof e==`string`?pn(e):e,0,16777215,0),e!==this._$shadowColor&&(this._$shadowColor=e,this.$updated=!0)}get strength(){return this._$strength}set strength(e){e=U(e|0,0,255,0),e!==this._$strength&&(this._$strength=e,this.$updated=!0)}get type(){return this._$type}set type(e){if(e=`${e}`.toLowerCase(),e!==this._$type){switch(e){case`inner`:case`outer`:case`full`:break;default:return}this._$type=e,this.$updated=!0}}clone(){return new e(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 xn(this)}toNumberArray(){return Sn(this)}canApplyFilter(){return gn(this)}getBounds(e){return bn(this,e)}},wn=e=>[e.$filterType,e.blurX,e.blurY,e.quality],Tn=e=>new Float32Array([e.$filterType,e.blurX,e.blurY,e.quality]),En=class e extends un{$filterType=1;_$blurX;_$blurY;_$quality;constructor(e=4,t=4,n=1){super(),this._$blurX=4,this._$blurY=4,this._$quality=1,this.blurX=e,this.blurY=t,this.quality=n}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}clone(){return new e(this._$blurX,this._$blurY,this._$quality)}toArray(){return wn(this)}toNumberArray(){return Tn(this)}canApplyFilter(){return _n(this)}getBounds(e){return yn(this,e)}},Dn=e=>[e.$filterType,e.matrix],On=e=>new Float32Array([e.$filterType,...e.matrix]),kn=class e extends un{$filterType=2;_$matrix;constructor(e=null){super(),this._$matrix=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],e&&e.length===20&&(this.matrix=e)}get matrix(){return this._$matrix}set matrix(e){if(this._$matrix!==e&&!(!Array.isArray(e)||e.length!==20)){for(let t=0;t<20;t++)if(e[t]!==this._$matrix[t]){this.$updated=!0;break}this.$updated&&(this._$matrix=e)}}clone(){return new e(this._$matrix)}toArray(){return Dn(this)}toNumberArray(){return On(this)}},An=e=>e.matrix!==null&&e.matrixX*e.matrixY===e.matrix.length,jn=e=>[e.$filterType,e.matrixX,e.matrixY,e.matrix,e.divisor,e.bias,e.preserveAlpha,e.clamp,e.color,e.alpha],Mn=e=>{let 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])},Nn=class e extends un{$filterType=3;_$matrixX;_$matrixY;_$matrix;_$divisor;_$bias;_$preserveAlpha;_$clamp;_$color;_$alpha;constructor(e=0,t=0,n=null,r=1,i=0,a=!0,o=!0,s=0,c=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=e,this.matrixY=t,this.matrix=n,this.divisor=r,this.bias=i,this.preserveAlpha=a,this.clamp=o,this.color=s,this.alpha=c}get alpha(){return this._$alpha}set alpha(e){e=U(+e,0,1,0),e!==this._$alpha&&(this._$alpha=e,this.$updated=!0)}get bias(){return this._$bias}set bias(e){e|=0,e!==this._$bias&&(this._$bias=e,this.$updated=!0)}get clamp(){return this._$clamp}set clamp(e){e=!!e,e!==this._$clamp&&(this._$clamp=e,this.$updated=!0)}get color(){return this._$color}set color(e){e=U(typeof e==`string`?pn(e):e,0,16777215,0),e!==this._$color&&(this._$color=e,this.$updated=!0)}get divisor(){return this._$divisor}set divisor(e){e|=0,e!==this._$divisor&&(this._$divisor=e,this.$updated=!0)}get matrix(){return this._$matrix}set matrix(e){this._$matrix!==e&&(this._$matrix=e,this.$updated=!0)}get matrixX(){return this._$matrixX}set matrixX(e){e=U(e|0,0,15,0)|0,e!==this._$matrixX&&(this._$matrixX=e,this.$updated=!0)}get matrixY(){return this._$matrixY}set matrixY(e){e=U(e|0,0,15,0)|0,e!==this._$matrixY&&(this._$matrixY=e,this.$updated=!0)}get preserveAlpha(){return this._$preserveAlpha}set preserveAlpha(e){e=!!e,e!==this._$preserveAlpha&&(this._$preserveAlpha=e,this.$updated=!0)}clone(){return new e(this._$matrixX,this._$matrixY,this._$matrix?this._$matrix.slice():null,this._$divisor,this._$bias,this._$preserveAlpha,this._$clamp,this._$color,this._$alpha)}toArray(){return jn(this)}toNumberArray(){return Mn(this)}canApplyFilter(){return An(this)}},Pn=e=>e.bitmapBuffer!==null&&e.componentX>0&&e.componentY>0&&e.scaleX!==0&&e.scaleY!==0,Fn=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],In=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}let n=e.bitmapBuffer||new Uint8Array,r=[e.$filterType,n.length];for(let e=0;e<n.length;e+=4096)r.push(...n.subarray(e,e+4096));return r.push(e.bitmapWidth,e.bitmapHeight,e.mapPointX,e.mapPointY,e.componentX,e.componentY,e.scaleX,e.scaleY,t,e.color,e.alpha),new Float32Array(r)},Ln=class e extends un{$filterType=4;_$bitmapBuffer;_$bitmapWidth;_$bitmapHeight;_$mapPointX;_$mapPointY;_$componentX;_$componentY;_$scaleX;_$scaleY;_$mode;_$color;_$alpha;constructor(e=null,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=`wrap`,u=0,d=0){super(),this._$bitmapBuffer=null,this._$bitmapWidth=0,this._$bitmapHeight=0,this._$mapPointX=0,this._$mapPointY=0,this._$componentX=0,this._$componentY=0,this._$scaleX=0,this._$scaleY=0,this._$mode=`wrap`,this._$color=0,this._$alpha=0,this.bitmapBuffer=e,this.bitmapWidth=t,this.bitmapHeight=n,this.mapPointX=r,this.mapPointY=i,this.componentX=a,this.componentY=o,this.scaleX=s,this.scaleY=c,this.mode=l,this.color=u,this.alpha=d}get alpha(){return this._$alpha}set alpha(e){e=U(+e,0,1,0),e!==this._$alpha&&(this._$alpha=e,this.$updated=!0)}get color(){return this._$color}set color(e){e=U(typeof e==`string`?pn(e):e,0,16777215,0),e!==this._$color&&(this._$color=e,this.$updated=!0)}get componentX(){return this._$componentX}set componentX(e){e!==this._$componentX&&(this._$componentX=e,this.$updated=!0)}get componentY(){return this._$componentY}set componentY(e){e!==this._$componentY&&(this._$componentY=e,this.$updated=!0)}get bitmapBuffer(){return this._$bitmapBuffer}set bitmapBuffer(e){e!==this._$bitmapBuffer&&(this._$bitmapBuffer=e,this.$updated=!0)}get bitmapWidth(){return this._$bitmapWidth}set bitmapWidth(e){e!==this._$bitmapWidth&&(this._$bitmapWidth=e,this.$updated=!0)}get bitmapHeight(){return this._$bitmapHeight}set bitmapHeight(e){e!==this._$bitmapHeight&&(this._$bitmapHeight=e,this.$updated=!0)}get mapPointX(){return this._$mapPointX}set mapPointX(e){e!==this._$mapPointX&&(this._$mapPointX=e,this.$updated=!0)}get mapPointY(){return this._$mapPointY}set mapPointY(e){e!==this._$mapPointY&&(this._$mapPointY=e,this.$updated=!0)}get mode(){return this._$mode}set mode(e){e!==this._$mode&&(this._$mode=e,this.$updated=!0)}get scaleX(){return this._$scaleX}set scaleX(e){e=U(+e,-65535,65535,0),e!==this._$scaleX&&(this._$scaleX=e,this.$updated=!0)}get scaleY(){return this._$scaleY}set scaleY(e){e=U(+e,-65535,65535,0),e!==this._$scaleY&&(this._$scaleY=e,this.$updated=!0)}clone(){return new e(this._$bitmapBuffer?this._$bitmapBuffer.slice():null,this._$bitmapWidth,this._$bitmapHeight,this._$mapPointX,this._$mapPointX,this._$componentX,this._$componentY,this._$scaleX,this._$scaleY,this._$mode,this._$color,this._$alpha)}toArray(){return Fn(this)}toNumberArray(){return In(this)}canApplyFilter(){return Pn(this)}},Rn=e=>[e.$filterType,e.distance,e.angle,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout,e.hideObject],zn=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]),Bn=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Vn=(e,t)=>{if(!Bn(e)||e.inner)return t;yn(e,t);let n=e.angle*mn,r=e.distance,i=Math.cos(n)*r,a=Math.sin(n)*r;return t[0]=Math.min(t[0],i),i>0&&(t[2]+=i),t[1]=Math.min(t[1],a),a>0&&(t[3]+=a),t},Hn=class e extends un{$filterType=5;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$color;_$alpha;_$strength;_$inner;_$knockout;_$hideObject;constructor(e=4,t=45,n=0,r=1,i=4,a=4,o=1,s=1,c=!1,l=!1,u=!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=i,this.blurY=a,this.quality=s,this.distance=e,this.angle=t,this.color=n,this.alpha=r,this.strength=o,this.inner=c,this.knockout=l,this.hideObject=u}get alpha(){return this._$alpha}set alpha(e){e=U(+e,0,1,0),e!==this._$alpha&&(this._$alpha=e,this.$updated=!0)}get angle(){return this._$angle}set angle(e){e=U(e%360,-360,360,45),e!==this._$angle&&(this._$angle=e,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get color(){return this._$color}set color(e){e=U(typeof e==`string`?pn(e):e,0,16777215,0),e!==this._$color&&(this._$color=e,this.$updated=!0)}get distance(){return this._$distance}set distance(e){e=U(+e,-255,255,4),e!==this._$distance&&(this._$distance=e,this.$updated=!0)}get hideObject(){return this._$hideObject}set hideObject(e){e=!!e,e!==this._$hideObject&&(this._$hideObject=e,this.$updated=!0)}get inner(){return this._$inner}set inner(e){e=!!e,e!==this._$inner&&(this._$inner=e,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(e){e=!!e,e!==this._$knockout&&(this._$knockout=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}get strength(){return this._$strength}set strength(e){e=U(e|0,0,255,0),e!==this._$strength&&(this._$strength=e,this.$updated=!0)}clone(){return new e(this._$distance,this._$angle,this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout,this._$hideObject)}toArray(){return Rn(this)}toNumberArray(){return zn(this)}canApplyFilter(){return Bn(this)}getBounds(e){return Vn(this,e)}},Un=e=>[e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,e.inner,e.knockout],Wn=e=>new Float32Array([e.$filterType,e.color,e.alpha,e.blurX,e.blurY,e.strength,e.quality,+e.inner,+e.knockout]),Gn=e=>e.alpha>0&&e.strength!==0&&e.blurX>0&&e.blurY>0&&e.quality>0,Kn=(e,t)=>!Gn(e)||e.inner?t:yn(e,t),qn=class e extends un{$filterType=6;_$blurX;_$blurY;_$quality;_$color;_$alpha;_$strength;_$inner;_$knockout;constructor(e=0,t=1,n=4,r=4,i=1,a=1,o=!1,s=!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=r,this.quality=a,this.color=e,this.alpha=t,this.strength=i,this.inner=o,this.knockout=s}get alpha(){return this._$alpha}set alpha(e){e=U(+e,0,1,0),e!==this._$alpha&&(this._$alpha=e,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get color(){return this._$color}set color(e){e=U(typeof e==`string`?pn(e):e,0,16777215,4),e!==this._$color&&(this._$color=e,this.$updated=!0)}get inner(){return this._$inner}set inner(e){e=!!e,e!==this._$inner&&(this._$inner=e,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(e){e=!!e,e!==this._$knockout&&(this._$knockout=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}get strength(){return this._$strength}set strength(e){e=U(e|0,0,255,0),e!==this._$strength&&(this._$strength=e,this.$updated=!0)}clone(){return new e(this._$color,this._$alpha,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$inner,this._$knockout)}toArray(){return Un(this)}toNumberArray(){return Wn(this)}canApplyFilter(){return Gn(this)}getBounds(e){return Kn(this,e)}},Jn=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,Yn=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],Xn=e=>{let t=e.colors?e.colors:[],n=e.alphas?e.alphas:[],r=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,n.length,...n,r.length,...r,e.blurX,e.blurY,e.strength,e.quality,hn(e.type),+e.knockout])},Zn=(e,t)=>{if(!Jn(e)||e.type===`inner`)return t;yn(e,t);let n=e.angle*mn,r=e.distance,i=Math.abs(Math.cos(n)*r),a=Math.abs(Math.sin(n)*r);return t[0]-=i,t[2]+=i,t[1]-=a,t[3]+=a,t},Qn=class e extends un{$filterType=7;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(e=4,t=45,n=null,r=null,i=null,a=4,o=4,s=1,c=1,l=`inner`,u=!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=c,this.distance=e,this.angle=t,this.colors=n,this.alphas=r,this.ratios=i,this.strength=s,this.type=l,this.knockout=u}get alphas(){return this._$alphas}set alphas(e){if(e!==this._$alphas){if(Array.isArray(e))for(let t=0;t<e.length;++t){let n=e[t];e[t]=U(+n,0,1,0)}this._$alphas=e,this.$updated=!0}}get angle(){return this._$angle}set angle(e){e=U(e%360,-360,360,45),e!==this._$angle&&(this._$angle=e,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get colors(){return this._$colors}set colors(e){if(this._$colors!==e){if(Array.isArray(e))for(let t=0;t<e.length;++t){let n=e[t];e[t]=U(typeof n==`string`?pn(n):n,0,16777215,0)}this._$colors=e,this.$updated=!0}}get distance(){return this._$distance}set distance(e){e=U(+e,-255,255,4),e!==this._$distance&&(this._$distance=e,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(e){e=!!e,e!==this._$knockout&&(this._$knockout=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}get ratios(){return this._$ratios}set ratios(e){if(this._$ratios!==e){if(Array.isArray(e))for(let t=0;t<e.length;++t){let n=e[t];e[t]=U(+n,0,255,0)}this._$ratios=e,this.$updated=!0}}get strength(){return this._$strength}set strength(e){e=U(e|0,0,255,0),e!==this._$strength&&(this._$strength=e,this.$updated=!0)}get type(){return this._$type}set type(e){e!==this._$type&&(this._$type=e,this.$updated=!0)}clone(){return new e(this._$distance,this._$angle,this._$colors?this._$colors.slice():null,this._$alphas?this._$alphas.slice():null,this._$ratios?this._$ratios.slice():null,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return Yn(this)}toNumberArray(){return Xn(this)}canApplyFilter(){return Jn(this)}getBounds(e){return Zn(this,e)}},$n=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],er=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,tr=e=>{let t=e.colors?e.colors:[],n=e.alphas?e.alphas:[],r=e.ratios?e.ratios:[];return new Float32Array([e.$filterType,e.distance,e.angle,t.length,...t,n.length,...n,r.length,...r,e.blurX,e.blurY,e.strength,e.quality,hn(e.type),+e.knockout])},nr=(e,t)=>!er(e)||e.type===`inner`?t:yn(e,t),rr=class e extends un{$filterType=8;_$blurX;_$blurY;_$quality;_$distance;_$angle;_$colors;_$alphas;_$ratios;_$strength;_$type;_$knockout;constructor(e=4,t=45,n=null,r=null,i=null,a=4,o=4,s=1,c=1,l=`outer`,u=!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=c,this.distance=e,this.angle=t,this.colors=n,this.alphas=r,this.ratios=i,this.strength=s,this.type=l,this.knockout=u}get alphas(){return this._$alphas}set alphas(e){if(e!==this._$alphas){if(Array.isArray(e))for(let t=0;t<e.length;++t){let n=e[t];e[t]=U(+n,0,1,0)}this._$alphas=e,this.$updated=!0}}get angle(){return this._$angle}set angle(e){e=U(e%360,-360,360,45),e!==this._$angle&&(this._$angle=e,this.$updated=!0)}get blurX(){return this._$blurX}set blurX(e){e=U(+e,0,255,0),e!==this._$blurX&&(this._$blurX=e,this.$updated=!0)}get blurY(){return this._$blurY}set blurY(e){e=U(+e,0,255,0),e!==this._$blurY&&(this._$blurY=e,this.$updated=!0)}get colors(){return this._$colors}set colors(e){if(this._$colors!==e){if(Array.isArray(e))for(let t=0;t<e.length;++t){let n=e[t];e[t]=U(typeof n==`string`?pn(n):n,0,16777215,0)}this._$colors=e,this.$updated=!0}}get distance(){return this._$distance}set distance(e){e=U(+e,-255,255,4),e!==this._$distance&&(this._$distance=e,this.$updated=!0)}get knockout(){return this._$knockout}set knockout(e){e=!!e,e!==this._$knockout&&(this._$knockout=e,this.$updated=!0)}get quality(){return this._$quality}set quality(e){e=U(e|0,0,15,1),e!==this._$quality&&(this._$quality=e,this.$updated=!0)}get ratios(){return this._$ratios}set ratios(e){if(this._$ratios!==e){if(Array.isArray(e))for(let t=0;t<e.length;++t)e[t]=U(+e[t],0,255,0);this._$ratios=e,this.$updated=!0}}get strength(){return this._$strength}set strength(e){e=U(e|0,0,255,0),e!==this._$strength&&(this._$strength=e,this.$updated=!0)}get type(){return this._$type}set type(e){e!==this._$type&&(this._$type=e,this.$updated=!0)}clone(){return new e(this._$distance,this._$angle,this._$colors,this._$alphas,this._$ratios,this._$blurX,this._$blurY,this._$strength,this._$quality,this._$type,this._$knockout)}toArray(){return $n(this)}toNumberArray(){return tr(this)}canApplyFilter(){return er(this)}getBounds(e){return nr(this,e)}},ir=e=>{let t=R();for(let n=0;n<e.length;++n){let r=e[n];if(r)switch(r.params[0]===null&&r.params.shift(),r.class){case`BevelFilter`:t.push(new Cn(...r.params));break;case`BlurFilter`:t.push(new En(...r.params));break;case`ColorMatrixFilter`:t.push(new kn(...r.params));break;case`ConvolutionFilter`:t.push(new Nn(...r.params));break;case`DisplacementMapFilter`:t.push(new Ln(...r.params));break;case`DropShadowFilter`:t.push(new Hn(...r.params));break;case`GlowFilter`:t.push(new qn(...r.params));break;case`GradientBevelFilter`:t.push(new Qn(...r.params));break;case`GradientGlowFilter`:t.push(new rr(...r.params));break}}return t},ar=e=>{if(e.$filters)return e.$filters;let t=kt(e);return t&&t.surfaceFilterList?(t.filters||=ir(t.surfaceFilterList),t.filters):null},or=(e,t)=>{e.$filters=t,I(e)},sr=e=>{if(e.$blendMode)return e.$blendMode;let t=kt(e);return t&&t.blendMode?t.blendMode:`normal`},cr=(e,t)=>{e.$blendMode!==t&&(e.$blendMode=t,I(e))},lr=180/Math.PI,ur=e=>{let t=e.$matrix?e.$matrix.rawData:H(e);return t?Math.atan2(t[1],t[0])*lr:0},dr=Math.PI/180,fr=(e,t)=>{if(t=Qt(t%360,-360,360,0),e.$rotation===t)return;let n=e.$matrix;if(!n){let t=H(e);e.$matrix=n=t?new F(...t):new F}let r=Math.sqrt(n.a*n.a+n.b*n.b),i=Math.sqrt(n.c*n.c+n.d*n.d);if(t===0)n.a=r,n.b=0,n.c=0,n.d=i;else{let e=Math.atan2(n.b,n.a),a=Math.atan2(-n.c,n.d),o=t*dr;a=a+o-e,e=o,n.b=r*Math.sin(e),n.b===1||n.b===-1?n.a=0:n.a=r*Math.cos(e),n.c=-i*Math.sin(a),n.c===1||n.c===-1?n.d=0:n.d=i*Math.cos(a)}e.$scaleX=null,e.$scaleY=null,e.$rotation=t,I(e)},pr=e=>{let t=e.$matrix?e.$matrix.rawData:H(e);if(!t)return 1;let n=(Math.abs(t[0])>=1e-12?Math.sign(t[0]):Math.sign(t[1]))||1,r=Math.hypot(t[0],t[1]);return Math.round(r*n*1e4)/1e4},mr=(e,t)=>{t=Qt(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);let n=Math.round(t*1e4)/1e4;if(e.$scaleX===n)return;let r=e.$matrix;if(!r){let t=H(e);e.$matrix=r=t?new F(...t):new F}if(r.b===0||isNaN(r.b))r.a=n;else{let e=Math.atan2(r.b,r.a),t=(Math.hypot(r.a,r.b)*((Math.abs(r.a)>=1e-12?Math.sign(r.a):Math.sign(r.b))||1)>=0?e:e-Math.PI)+(n<0?Math.PI:0),i=Math.abs(n);r.a=i*Math.cos(t),r.b=i*Math.sin(t)}e.$scaleX=n,e.$rotation=null,I(e)},hr=e=>{let t=e.$matrix?e.$matrix.rawData:H(e);if(!t)return 1;let n=Math.hypot(t[0],t[1]),r=(Math.abs(t[0])>=1e-12?Math.sign(t[0]):Math.sign(t[1]))||1;return Math.round((t[0]*t[3]-t[1]*t[2])/(n*r)*1e4)/1e4},gr=(e,t)=>{t=Qt(t,-Number.MAX_VALUE,Number.MAX_VALUE,1);let n=Math.round(t*1e4)/1e4;if(e.$scaleY===n)return;let r=e.$matrix;if(!r){let t=H(e);e.$matrix=r=t?new F(...t):new F}if(r.c===0||isNaN(r.c))r.d=n;else{let e=Math.max(0,Math.abs(n)),t=Math.atan2(r.b,r.a);(r.a<0||Math.abs(r.a)<1e-12&&r.b<0)&&(t-=Math.PI),t<=-Math.PI&&(t+=2*Math.PI),t>Math.PI&&(t-=2*Math.PI);let i=t+(n<0?Math.PI:0);r.c=-e*Math.sin(i),r.d=e*Math.cos(i)}e.$scaleY=n,e.$rotation=null,I(e)},_r=e=>{let t=e.$matrix?e.$matrix.rawData:H(e);return t?t[4]:0},vr=(e,t)=>{let n=e.$matrix;if(!n){let t=H(e);e.$matrix=n=t?new F(...t):new F}e.$x!==t&&(e.$x=n.tx=t,I(e))},yr=e=>{let t=e.$matrix?e.$matrix.rawData:H(e);return t?t[5]:0},br=(e,t)=>{let n=e.$matrix;if(!n){let t=H(e);e.$matrix=n=t?new F(...t):new F}e.$y!==t&&(e.$y=n.ty=t,I(e))},W=(e,t,n,r,i)=>{let a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=n*a+r*s+l,f=n*a+t*s+l,p=e*a+r*s+l,m=e*a+t*s+l,h=n*o+r*c+u,g=n*o+t*c+u,_=e*o+r*c+u,v=e*o+t*c+u;return B(Math.min(d,f,p,m),Math.min(h,g,_,v),Math.max(d,f,p,m),Math.max(h,g,_,v))},xr=e=>{let t=e.graphics;return B(t.xMin,t.yMin,t.xMax,t.yMax)},Sr=(e,t=null)=>{let n=xr(e),r=H(e),i=e.cacheAsBitmap,a=null;if(i){let e=i.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);a=r?L(r[0]*t,r[1]*t,r[2]*n,r[3]*n,r[4],r[5]):L(t,0,0,n,0,0),r=a}if(!r){if(t){let e=W(n[0],n[1],n[2],n[3],t);return V(n),e}return n}let o=W(n[0],n[1],n[2],n[3],t?F.multiply(t,r):r);return a&&Rt(a),V(n),o},Cr=e=>B(0,0,e.videoWidth,e.videoHeight),wr=(e,t=null)=>{let n=Cr(e),r=H(e);if(!r){if(t){let e=W(n[0],n[1],n[2],n[3],t);return V(n),e}return n}let i=W(n[0],n[1],n[2],n[3],t?F.multiply(t,r):r);return V(n),i},Tr=e=>B(e.xMin,e.yMin,e.xMax,e.yMax),Er=(e,t=null)=>{let n=Tr(e),r=H(e),i=e.cacheAsBitmap,a=null;if(i){let e=i.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);a=r?L(r[0]*t,r[1]*t,r[2]*n,r[3]*n,r[4],r[5]):L(t,0,0,n,0,0),r=a}if(!r){if(t){let e=W(n[0],n[1],n[2],n[3],t);return V(n),e}return n}let o=W(n[0],n[1],n[2],n[3],t?F.multiply(t,r):r);return a&&Rt(a),V(n),o},Dr=(e,t=null)=>{let n=e.children;if(!n.length)return B(0,0,0,0);let r=H(e),i=e.cacheAsBitmap,a=null;if(i){let e=i.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);a=r?L(r[0]*t,r[1]*t,r[2]*n,r[3]*n,r[4],r[5]):L(t,0,0,n,0,0),r=a}let o=r?t?F.multiply(t,r):r:t,s=Number.MAX_VALUE,c=s,l=-s,u=s,d=-s;for(let e=0;e<n.length;e++){let t=n[e];if(!t.visible)continue;let r=null;switch(!0){case t.isContainerEnabled:r=Dr(t,o);break;case t.isShape:r=Sr(t,o);break;case t.isText:r=Er(t,o);break;case t.isVideo:r=wr(t,o);break}r&&(c=Math.min(c,r[0]),u=Math.min(u,r[1]),l=Math.max(l,r[2]),d=Math.max(d,r[3]),V(r))}return a&&Rt(a),B(c,u,l,d)},Or=e=>{switch(!0){case e.isContainerEnabled:return Dr(e);case e.isShape:return Sr(e);case e.isText:return Er(e);case e.isVideo:return wr(e);default:return B(0,0,0,0)}},kr=e=>{let t=Or(e),n=Math.abs(t[2]-t[0]);switch(V(t),!0){case n===0:case n===1/0:case n===-1/0:return 0;default:return Math.round(n*100)/100}},Ar=(e,t=null)=>{let n=e.children;if(!n.length)return B(0,0,0,0);let r=H(e),i=t;r&&(i=t?F.multiply(t,r):r);let a=Number.MAX_VALUE,o=a,s=-a,c=a,l=-a;for(let e=0;e<n.length;e++){let t=n[e];if(!t.visible)continue;let r=null;switch(!0){case t.isContainerEnabled:r=Ar(t,i);break;case t.isShape:r=Sr(t,i);break;case t.isText:r=Er(t,i);break;case t.isVideo:r=wr(t,i);break}r&&(o=Math.min(o,r[0]),c=Math.min(c,r[1]),s=Math.max(s,r[2]),l=Math.max(l,r[3]),V(r))}return B(o,c,s,l)},jr=e=>{switch(!0){case e.isContainerEnabled:return Ar(e);case e.isShape:return xr(e);case e.isText:return Tr(e);case e.isVideo:return Cr(e);default:return B(0,0,0,0)}},Mr=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;let n=jr(e),r=Math.abs(n[2]-n[0]);switch(!0){case r===0:case r===1/0:case r===-1/0:return;default:r=Math.round(r*100)/100;break}mr(e,t/r)},Nr=(e,t)=>{let n=e.concatenatedMatrix,r=new P(t.x*n.a+t.y*n.c+n.tx,t.x*n.b+t.y*n.d+n.ty);return F.release(n.rawData),r},Pr=(e,t)=>{let n=e.concatenatedMatrix;n.invert();let r=new P(t.x*n.a+t.y*n.c+n.tx,t.x*n.b+t.y*n.d+n.ty);return F.release(n.rawData),r},Fr=e=>{let t=Or(e),n=Math.abs(t[3]-t[1]);switch(V(t),!0){case n===0:case n===1/0:case n===-1/0:return 0;default:return Math.round(n*100)/100}},Ir=(e,t)=>{if(t=+t,isNaN(t)||0>t)return;let n=jr(e),r=Math.abs(n[3]-n[1]);switch(!0){case r===0:case r===1/0:case r===-1/0:return;default:r=Math.round(r*100)/100;break}gr(e,t/r)},Lr=e=>{let t=e.parent;t&&t.removeChild(e)},Rr=(e,t=null)=>{let n=e.concatenatedMatrix,r=jr(e),i=W(r[0],r[1],r[2],r[3],n.rawData);if(V(r),F.release(n.rawData),!t){let e=new Ot(i[0],i[1],Math.abs(i[2]-i[0]),Math.abs(i[3]-i[1]));return V(i),e}let a=t.concatenatedMatrix;a.invert();let o=W(i[0],i[1],i[2],i[3],a.rawData);V(i),F.release(a.rawData);let s=new Ot(o[0],o[1],Math.abs(o[2]-o[0]),Math.abs(o[3]-o[1]));return V(o),s},zr=(e,t)=>{let n=jr(e),r=e.concatenatedMatrix,i=W(n[0],n[1],n[2],n[3],r.rawData);V(n),F.release(r.rawData);let a=jr(t),o=t.concatenatedMatrix,s=W(a[0],a[1],a[2],a[3],o.rawData);V(a),F.release(o.rawData);let c=Math.max(i[0],s[0]),l=Math.max(i[1],s[1]),u=Math.min(i[2],s[2]),d=Math.min(i[3],s[3]);return V(i),V(s),u-c>=0&&d-l>=0},Br=class e{_$bitmapData;_$matrix;_$repeat;_$smooth;constructor(e,t=null,n=!0,r=!1){this._$bitmapData=e,this._$matrix=t,this._$repeat=n,this._$smooth=r}clone(){return new e(this._$bitmapData.clone(),this._$matrix?this._$matrix.clone():null,this._$repeat,this._$smooth)}toArray(){return R(this._$bitmapData,this._$matrix,this._$repeat,this._$smooth)}},Vr=class e{_$type;_$colors;_$alphas;_$ratios;_$matrix;_$spreadMethod;_$interpolationMethod;_$focalPointRatio;_$colorStops;constructor(e,t,n,r,i=null,a=`pad`,o=`rgb`,s=0){this._$type=e,this._$colors=t,this._$alphas=n,this._$ratios=r,this._$matrix=i,this._$spreadMethod=a,this._$interpolationMethod=o,this._$focalPointRatio=s,this._$colorStops=R()}get colorStops(){if(!this._$colorStops.length){let e=Math.min(Math.min(this._$alphas.length,this._$colors.length),this._$ratios.length);for(let t=0;t<e;++t){let e=this._$colors[t],n=typeof e==`string`?Zt(e):e;this._$colorStops[t]={ratio:this._$ratios[t]/255,R:n>>>16&255,G:n>>>8&255,B:n&255,A:this._$alphas[t]*255&255}}}return this._$colorStops}toArray(){return R(this._$type,this.colorStops,this._$matrix?this._$matrix.rawData:jt,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}clone(){return new e(this._$type,this._$colors.slice(),this._$alphas.slice(),this._$ratios.slice(),this._$matrix?this._$matrix.clone():null,this._$spreadMethod,this._$interpolationMethod,this._$focalPointRatio)}},Hr=(e,t=0,n=0)=>{e.xMin=Math.min(e.xMin,t),e.xMax=Math.max(e.xMax,t),e.yMin=Math.min(e.yMin,n),e.yMax=Math.max(e.yMax,n)},Ur=(e,t=0,n=0,r=0,i=0,a=0,o=`none`)=>{e.xMin=Math.min(e.xMin,Math.min(t,r)),e.xMax=Math.max(e.xMax,Math.max(t,r)),e.yMin=Math.min(e.yMin,Math.min(n,i)),e.yMax=Math.max(e.yMax,Math.max(n,i));let s=r-t,c=i-n,l=Math.sqrt(s*s+c*c);if(!l)return;let u=s/l,d=c/l,f=-d,p=u,m=a/2,h=Math.min(t+f*m,t-f*m,r+f*m,r-f*m),g=Math.max(t+f*m,t-f*m,r+f*m,r-f*m),_=Math.min(n+p*m,n-p*m,i+p*m,i-p*m),v=Math.max(n+p*m,n-p*m,i+p*m,i-p*m);if(e.xMin=Math.min(e.xMin,h),e.xMax=Math.max(e.xMax,g),e.yMin=Math.min(e.yMin,_),e.yMax=Math.max(e.yMax,v),o===`round`||o===`square`){let r=t+m*-u,i=n+m*-d,a=Math.min(r+m*u+m*f,r-m*u+m*f,r+m*u-m*f,r-m*u-m*f),o=Math.max(r+m*u+m*f,r-m*u+m*f,r+m*u-m*f,r-m*u-m*f),s=Math.min(i+m*d+m*p,i+m*d-m*p,i-m*d-m*p,i-m*d+m*p),c=Math.max(i+m*d+m*p,i+m*d-m*p,i-m*d-m*p,i-m*d+m*p);e.xMin=Math.min(e.xMin,a),e.xMax=Math.max(e.xMax,o),e.yMin=Math.min(e.yMin,s),e.yMax=Math.max(e.yMax,c)}},Wr=(e,t,n=0,r=0,i=0,a=`none`,...o)=>{for(let s=0;s<o.length;){let c=o[s++],l=o[s++];Hr(e,c,l),t&&(Ur(e,c,l,n,r,i,a),Ur(e,n,r,c,l,i,a))}},Gr=(e,t,n,r,i,...a)=>{e.isConfirmed=!1,t&&r&&r.push(...a),n&&i&&i.push(...a)},Kr=(e,t,n,r,i)=>{t=+t||0,n=+n||0,r=+r||0,i=+i||0,r=Math.round(r),i=Math.round(i);let a=r/2,o=i/2,s=t+a,c=n+o,l=t+r,u=n+i,d=4/3*(Math.SQRT2-1),f=d*a,p=d*o;return e.moveTo(s,n).cubicCurveTo(s+f,n,l,c-p,l,c).cubicCurveTo(l,c+p,s+f,u,s,u).cubicCurveTo(s-f,u,t,c+p,t,c).cubicCurveTo(t,c-p,s-f,n,s,n)},qr=(e,t,n,r,i)=>{t=+t||0,n=+n||0,r=+r||0,i=+i||0;let a=Math.round(t+r),o=Math.round(n+i);return e.moveTo(t,n).lineTo(t,o).lineTo(a,o).lineTo(a,n).lineTo(t,n)},Jr=(e,t,n,r,i,a,o=NaN)=>{t=+t||0,n=+n||0,r=+r||0,i=+i||0,a=+a||0,o=+o||a,r=Math.round(r),i=Math.round(i),a=Math.round(a),o=Math.round(o);let s=a/2,c=o/2,l=4/3*(Math.SQRT2-1),u=l*s,d=l*c,f=t+s,p=t+r,m=p-s,h=n+c,g=n+i,_=g-c;return e.moveTo(f,n).lineTo(m,n).cubicCurveTo(m+u,n,p,h-d,p,h).lineTo(p,_).cubicCurveTo(p,_+d,m+u,g,m,g).lineTo(f,g).cubicCurveTo(f-u,g,t,_+d,t,_).lineTo(t,h).cubicCurveTo(t,h-d,f-u,n,f,n)},Yr=e=>{if(!e)return[];let t=R();for(let n=0;n<e.length;){let r=e[n++];switch(t.push(r),r){case G.BEGIN_PATH:case G.END_FILL:case G.END_STROKE:case G.CLOSE_PATH:break;case G.MOVE_TO:case G.LINE_TO:t.push(e[n++],e[n++]);break;case G.CURVE_TO:case G.FILL_STYLE:t.push(e[n++],e[n++],e[n++],e[n++]);break;case G.CUBIC:t.push(e[n++],e[n++],e[n++],e[n++],e[n++],e[n++]);break;case G.STROKE_STYLE:switch(t.push(e[n++]),e[n++]){case`none`:t.push(0);break;case`round`:t.push(1);break;case`square`:t.push(2);break;default:t.push(0);break}switch(e[n++]){case`bevel`:t.push(0);break;case`miter`:t.push(1);break;case`round`:t.push(2);break;default:t.push(2);break}t.push(e[n++],e[n++],e[n++],e[n++],e[n++]);break;case G.ARC:t.push(e[n++],e[n++],e[n++]);break;case G.GRADIENT_FILL:{let r=e[n++],i=e[n++],a=e[n++],o=e[n++],s=e[n++],c=e[n++];t.push(r===`linear`?0:1),t.push(i.length);let l=i.sort((e,t)=>e.ratio-t.ratio);for(let e=0;e<l.length;++e){let n=l[e];t.push(n.ratio,n.R,n.G,n.B,n.A)}switch(t.push(...a),o){case`reflect`:t.push(0);break;case`repeat`:t.push(1);break;default:t.push(2);break}t.push(s===`linearRGB`?0:1),t.push(c)}break;case G.GRADIENT_STROKE:{switch(t.push(e[n++]),e[n++]){case`none`:t.push(0);break;case`round`:t.push(1);break;case`square`:t.push(2);break;default:t.push(0);break}switch(e[n++]){case`bevel`:t.push(0);break;case`miter`:t.push(1);break;case`round`:t.push(2);break;default:t.push(2);break}t.push(e[n++]);let r=e[n++],i=e[n++],a=e[n++],o=e[n++],s=e[n++],c=e[n++];t.push(r===`linear`?0:1),t.push(i.length);for(let e=0;e<i.length;++e){let n=i[e];t.push(n.ratio,n.R,n.G,n.B,n.A)}switch(t.push(...a),o){case`reflect`:t.push(0);break;case`repeat`:t.push(1);break;default:t.push(2);break}t.push(s===`linearRGB`?0:1),t.push(c)}break;case G.BITMAP_FILL:{let r=e[n++],i=r.buffer;if(!i){n+=3;break}t.push(r.width,r.height,i.length);for(let e=0;e<i.length;e+=4096)t.push(...i.subarray(e,e+4096));let a=e[n++];a?t.push(...a.rawData):t.push(1,0,0,1,0,0);let o=e[n++];t.push(o?1:0);let s=e[n++];t.push(s?1:0)}break;case G.BITMAP_STROKE:{switch(t.push(e[n++]),e[n++]){case`none`:t.push(0);break;case`round`:t.push(1);break;case`square`:t.push(2);break;default:t.push(0);break}switch(e[n++]){case`bevel`:t.push(0);break;case`miter`:t.push(1);break;case`round`:t.push(2);break;default:t.push(2);break}t.push(e[n++]);let r=e[n++],i=r.buffer;if(!i){n+=3;break}t.push(r.width,r.height,i.length);for(let e=0;e<i.length;e+=4096)t.push(...i.subarray(e,e+4096));let a=e[n++];a?t.push(...a.rawData):t.push(1,0,0,1,0,0);let o=e[n++];t.push(o?1:0);let s=e[n++];t.push(s?1:0)}break;default:break}}return t},G=class e{isConfirmed;xMin;yMin;xMax;yMax;$recodes;_$buffer;_$maxAlpha;_$isBeginning;_$positionX;_$positionY;_$hasFillEnabled;_$fillType;_$fillColor;_$fillGradient;_$fillBitmap;_$fills;_$hasLineEnabled;_$lineType;_$lineColor;_$lineGradient;_$joints;_$miterLimit;_$caps;_$lineWidth;_$lines;constructor(){this.isConfirmed=!1,this.xMin=Number.MAX_VALUE,this.yMin=Number.MAX_VALUE,this.xMax=-Number.MAX_VALUE,this.yMax=-Number.MAX_VALUE,this.$recodes=null,this._$buffer=null,this._$positionX=0,this._$positionY=0,this._$maxAlpha=0,this._$isBeginning=!1,this._$fills=null,this._$hasFillEnabled=!1,this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillColor=0,this._$caps=`none`,this._$lineWidth=1,this._$lines=null,this._$hasLineEnabled=!1,this._$lineType=0,this._$lineGradient=null,this._$joints=`round`,this._$miterLimit=0,this._$lineColor=0}static get MOVE_TO(){return 0}static get CURVE_TO(){return 1}static get LINE_TO(){return 2}static get CUBIC(){return 3}static get ARC(){return 4}static get FILL_STYLE(){return 5}static get STROKE_STYLE(){return 6}static get END_FILL(){return 7}static get END_STROKE(){return 8}static get BEGIN_PATH(){return 9}static get GRADIENT_FILL(){return 10}static get GRADIENT_STROKE(){return 11}static get CLOSE_PATH(){return 12}static get BITMAP_FILL(){return 13}static get BITMAP_STROKE(){return 14}get isDrawable(){if(!this._$isBeginning||!this._$maxAlpha)return!1;let e=Math.abs(this.xMax-this.xMin),t=Math.abs(this.yMax-this.yMin);return e>0&&t>0}beginBitmapFill(t,n=null,r=!0,i=!1){return this._$hasFillEnabled&&this.endFill(),this._$fills||=R(),this._$maxAlpha=1,this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(e.BEGIN_PATH),this._$fillType=e.BITMAP_FILL,this._$fillBitmap=new Br(t,n,r,i),this}beginFill(t=0,n=1){this._$hasFillEnabled&&this.endFill(),this._$fills||=R(),typeof t==`string`&&(t=Zt(t)),t=Qt(t,0,16777215,0),n=Qt(n,0,1,1),this._$maxAlpha=Math.max(this._$maxAlpha,n),this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(e.BEGIN_PATH),this._$fillType=e.FILL_STYLE;let r=t>>>16&255,i=t>>>8&255,a=t&255;return this._$fillColor=r<<24|i<<16|a<<8|n*255,this}beginGradientFill(t,n,r,i,a=null,o=`pad`,s=`rgb`,c=0){this._$hasFillEnabled&&this.endFill(),this._$fills||=R();for(let e=0;e<r.length;++e)this._$maxAlpha=Math.max(this._$maxAlpha,r[e]);return this._$hasFillEnabled=!0,this._$isBeginning=!0,this._$fills.push(e.BEGIN_PATH),this._$fillType=e.GRADIENT_FILL,this._$fillGradient=new Vr(t,n,r,i,a,o,s,c),this}clear(){return this._$maxAlpha=0,this._$isBeginning=!1,this._$positionX=0,this._$positionY=0,this._$fillType=0,this._$fillGradient=null,this._$fillBitmap=null,this._$fillColor=0,this._$hasFillEnabled=!1,this._$caps=`none`,this._$lineWidth=1,this._$lineType=0,this._$lineGradient=null,this._$joints=`round`,this._$miterLimit=0,this._$lineColor=0,this._$hasLineEnabled=!1,this.xMin=Number.MAX_VALUE,this.xMax=-Number.MAX_VALUE,this.yMin=Number.MAX_VALUE,this.yMax=-Number.MAX_VALUE,this.$recodes&&z(this.$recodes),this._$fills&&z(this._$fills),this._$lines&&z(this._$lines),this._$buffer=null,this.$recodes=null,this._$fills=null,this._$lines=null,this}clone(){let t=new e;return t.copyFrom(this),t}copyFrom(e){e._$fillGradient&&(this._$fillGradient=e._$fillGradient.clone()),e._$fillBitmap&&(this._$fillBitmap=e._$fillBitmap.clone()),this._$hasFillEnabled=e._$hasFillEnabled,this._$fillType=e._$fillType,this._$fillColor=e._$fillColor,e._$lineGradient&&(this._$lineGradient=e._$lineGradient.clone()),this._$hasLineEnabled=e._$hasLineEnabled,this._$lineType=e._$lineType,this._$caps=e._$caps,this._$joints=e._$joints,this._$miterLimit=e._$miterLimit,this._$lineWidth=e._$lineWidth,this._$lineColor=e._$lineColor,this.xMin=e.xMin,this.xMax=e.xMax,this.yMin=e.yMin,this.yMax=e.yMax,this._$maxAlpha=e._$maxAlpha,this._$positionX=e._$positionX,this._$positionY=e._$positionY,this._$isBeginning=e._$isBeginning,e._$fills&&(this._$fills=e._$fills.slice(0)),e._$lines&&(this._$lines=e._$lines.slice(0)),e.$recodes&&(this.$recodes=e.$recodes.slice(0)),this._$buffer=null}cubicCurveTo(t,n,r,i,a,o){return a=+a||0,o=+o||0,this._$positionX===a&&this._$positionY===o?this:(t=+t||0,n=+n||0,r=+r||0,i=+i||0,Wr(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,n,r,i,a,o),Gr(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,e.CUBIC,t,n,r,i,a,o),this._$positionX=a,this._$positionY=o,this)}curveTo(t,n,r,i){return r=+r||0,i=+i||0,this._$positionX===r&&this._$positionY===i?this:(t=+t||0,n=+n||0,Wr(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,n,r,i),Gr(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,e.CURVE_TO,t,n,r,i),this._$positionX=r,this._$positionY=i,this)}drawCircle(t,n,r){return t=+t||0,n=+n||0,r=+r||0,r=Math.round(r),Wr(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t-r,n-r,t+r,n+r),Gr(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,e.MOVE_TO,t+r,n,e.ARC,t,n,r),this._$positionX=t,this._$positionY=n,this}drawEllipse(e,t,n,r){return Kr(this,e,t,n,r)}drawRect(e,t,n,r){return qr(this,e,t,n,r)}drawRoundRect(e,t,n,r,i,a=NaN){return Jr(this,e,t,n,r,i,a)}endFill(){if(!this._$hasFillEnabled||!this._$fills||8>this._$fills.length)return this;switch(this.$recodes||=R(),(this._$fills[2]!==this._$fills[this._$fills.length-2]||this._$fills[3]!==this._$fills[this._$fills.length-1])&&this._$fills.push(e.LINE_TO,this._$fills[2],this._$fills[3]),this.$recodes.push(...this._$fills),z(this._$fills),this._$fills=null,this._$fillType){case e.FILL_STYLE:this.$recodes.push(this._$fillType,this._$fillColor>>>24&255,this._$fillColor>>>16&255,this._$fillColor>>>8&255,this._$fillColor&255,e.END_FILL);break;case e.GRADIENT_FILL:this._$fillGradient&&this.$recodes.push(this._$fillType,...this._$fillGradient.toArray());break;case e.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||=R(),this.$recodes.push(...this._$lines),z(this._$lines),this._$lines=null,this._$lineType){case e.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,e.END_STROKE);break;case e.GRADIENT_STROKE:this._$lineGradient&&this.$recodes.push(this._$lineType,this._$lineWidth,this._$caps,this._$joints,this._$miterLimit,...this._$lineGradient.toArray());break;case e.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,n=null,r=!0,i=!1){return this._$hasLineEnabled?(this._$lines||=R(),this._$maxAlpha=1,this._$hasLineEnabled=!0,this._$isBeginning=!0,this._$lines.push(e.BEGIN_PATH),this._$lineType=e.BITMAP_STROKE,this._$fillBitmap=new Br(t,n,r,i),this):this}lineGradientStyle(t,n,r,i,a=null,o=`pad`,s=`rgb`,c=0){if(!this._$hasLineEnabled)return this;this._$lines||=R();for(let e=0;e<r.length;++e)this._$maxAlpha=Math.max(this._$maxAlpha,r[e]);return this._$lines.push(e.BEGIN_PATH),this._$lineType=e.GRADIENT_STROKE,this._$lineGradient=new Vr(t,n,r,i,a,o,s,c),this}lineStyle(t=1,n=0,r=1,i=`round`,a=`round`,o=3){this._$hasLineEnabled&&this.endLine(),this._$lines||=R(),this._$maxAlpha=Math.max(this._$maxAlpha,r),this._$hasLineEnabled=!0,this._$isBeginning=!0,this._$positionX||this._$positionY?this._$lines.push(e.BEGIN_PATH,e.MOVE_TO,this._$positionX,this._$positionY):this._$lines.push(e.BEGIN_PATH),this._$lineType=e.STROKE_STYLE,typeof n==`string`&&(n=Zt(n)),n=Qt(n,0,16777215,0),r=Qt(r,0,1,1);let s=n>>>16&255,c=n>>>8&255,l=n&255;return this._$lineColor=s<<24|c<<16|l<<8|r*255,this._$lineWidth=t,this._$caps=`${i}`,this._$joints=`${a}`,this._$joints===`miter`&&(this._$miterLimit=o),this}lineTo(t,n){return t=+t||0,n=+n||0,this._$positionX===t&&this._$positionY===n?this:(Wr(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,n),Gr(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,e.LINE_TO,t,n),this._$positionX=t,this._$positionY=n,this)}moveTo(t,n){t=+t||0,n=+n||0,this._$positionX=t,this._$positionY=n,Wr(this,this._$hasLineEnabled,this._$positionX,this._$positionY,this._$lineWidth,this._$caps,t,n);let r=!1;return this._$hasFillEnabled&&this._$fills&&this._$fills[this._$fills.length-3]===e.MOVE_TO&&(r=!0,this._$fills[this._$fills.length-2]=t,this._$fills[this._$fills.length-1]=n),this._$hasLineEnabled&&this._$lines&&this._$lines[this._$lines.length-3]===e.MOVE_TO&&(r=!0,this._$lines[this._$lines.length-2]=t,this._$lines[this._$lines.length-1]=n),r||Gr(this,this._$hasFillEnabled,this._$hasLineEnabled,this._$fills,this._$lines,e.MOVE_TO,t,n),this}get buffer(){if(this.isConfirmed&&this._$buffer)return this._$buffer;this._$hasLineEnabled&&this.endLine(),this._$hasFillEnabled&&this.endFill();let e=Yr(this.$recodes);return this._$buffer=new Float32Array(e),z(e),this.isConfirmed=!0,this._$buffer}set buffer(e){this._$buffer=e,this.isConfirmed=!0,this._$isBeginning=!0,this._$maxAlpha=1}},Xr=(e,t,n)=>{for(let r=0;r<t.length;)switch(t[r++]){case G.BEGIN_PATH:e.beginPath();break;case G.MOVE_TO:e.moveTo(t[r++],t[r++]);break;case G.LINE_TO:e.lineTo(t[r++],t[r++]);break;case G.CURVE_TO:e.quadraticCurveTo(t[r++],t[r++],t[r++],t[r++]);break;case G.FILL_STYLE:r+=4;continue;case G.END_FILL:if(e.isPointInPath(n.x,n.y))return!0;break;case G.STROKE_STYLE:r+=8;continue;case G.END_STROKE:break;case G.CLOSE_PATH:e.closePath();break;case G.CUBIC:e.bezierCurveTo(t[r++],t[r++],t[r++],t[r++],t[r++],t[r++]);break;case G.ARC:e.arc(t[r++],t[r++],t[r++],0,2*Math.PI);break;case G.GRADIENT_FILL:if(e.isPointInPath(n.x,n.y))return!0;r+=6;continue;case G.GRADIENT_STROKE:r+=12;continue;case G.BITMAP_FILL:if(e.isPointInPath(n.x,n.y))return!0;r+=6;continue;case G.BITMAP_STROKE:r+=9;continue;default:break}return!1},Zr=(e,t,n,r)=>{let i=e.graphics,a=i.xMax-i.xMin,o=i.yMax-i.yMin;if(a<=0||o<=0)return!1;let s=H(e),c=e.cacheAsBitmap,l=null;if(c){let e=c.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);l=s?L(s[0]*t,s[1]*t,s[2]*n,s[3]*n,s[4],s[5]):L(t,0,0,n,0,0),s=l}let u=s?F.multiply(n,s):n;l&&Rt(l),t.beginPath(),t.setTransform(u[0],u[1],u[2],u[3],u[4],u[5]);let d=!1;return i.buffer.length?d=Xr(t,i.buffer,r):(t.moveTo(0,0),t.lineTo(a,0),t.lineTo(a,o),t.lineTo(0,o),t.lineTo(0,0),d=t.isPointInPath(r.x,r.y)),u!==n&&F.release(u),d},Qr=(e,t,n,r)=>{let i=Math.ceil(Math.abs(e.xMax-e.xMin)),a=Math.ceil(Math.abs(e.yMax-e.yMin));if(i<=0||a<=0)return!1;let o=H(e),s=e.cacheAsBitmap,c=null;if(s){let e=s.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);c=o?L(o[0]*t,o[1]*t,o[2]*n,o[3]*n,o[4],o[5]):L(t,0,0,n,0,0),o=c}let l=o?F.multiply(n,o):n;return c&&Rt(c),t.setTransform(l[0],l[1],l[2],l[3],l[4],l[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,a),t.lineTo(0,a),t.lineTo(0,0),l!==n&&F.release(l),t.isPointInPath(r.x,r.y)},$r=(e,t,n,r)=>{let i=e.videoWidth,a=e.videoHeight;if(i<=0||a<=0)return!1;let o=H(e),s=o?F.multiply(n,o):n;return t.beginPath(),t.setTransform(s[0],s[1],s[2],s[3],s[4],s[5]),t.beginPath(),t.moveTo(0,0),t.lineTo(i,0),t.lineTo(i,a),t.lineTo(0,a),t.lineTo(0,0),s!==n&&F.release(s),t.isPointInPath(r.x,r.y)},ei=(e,t,n,r,i=!0)=>{let a=e.children;if(!a.length)return!1;let o=H(e),s=e.cacheAsBitmap,c=null;if(s){let e=s.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);c=o?L(o[0]*t,o[1]*t,o[2]*n,o[3]*n,o[4],o[5]):L(t,0,0,n,0,0),o=c}let l=o?F.multiply(n,o):n;c&&Rt(c);let u=R(),d=R(),f=Vt(),p=0,m=0;for(let e=0;e<a.length;++e){let t=a[e];if(t&&!t.isMask){if(t.clipDepth){m=u.length,p=t.clipDepth,u.push(t);continue}t.visible&&(p&&t.placeId>p&&(m=0,p=0),m&&f.set(t.instanceId,m),d.push(t))}}let h=e.mouseChildren&&i;if(e.isSprite&&e.hitArea&&e.hitArea.isSprite){let n=ei(e.hitArea,t,l,r,h);return n&&h&&e.mouseEnabled&&((e.isTimelineEnabled||e.buttonMode&&e.useHandCursor)&&(r.pointer=`pointer`),r.hit||=e),n}let g=!1,_=e.mask;if(_){let e=!1;switch(!0){case _.isContainerEnabled:e=ei(_,t,l,r,h);break;case _.isShape:e=Zr(_,t,l,r);break;case _.isText:e=Qr(_,t,l,r);break;case _.isVideo:e=$r(_,t,l,r);break;default:break}if(!e)return!1}for(;d.length;){let e=d.pop();if(!e||e.isMask)continue;if(f.has(e.instanceId)){let n=f.get(e.instanceId);if(!n)continue;let i=u[n];if(!i)continue;let a=!1;switch(!0){case i.isContainerEnabled:a=ei(i,t,l,r,h);break;case i.isShape:a=Zr(i,t,l,r);break;case i.isText:a=Qr(i,t,l,r);break;case i.isVideo:a=$r(i,t,l,r);break;default:break}if(!a)continue}let n=!1;switch(!0){case e.isContainerEnabled:n=ei(e,t,l,r,h);break;case e.isShape:n=Zr(e,t,l,r);break;case e.isText:n=Qr(e,t,l,r);break;case e.isVideo:n=$r(e,t,l,r);break;default:break}if(n){if(g=!0,!h)break;if(e.isInteractive&&e.mouseEnabled){if(r.pointer===`auto`)switch(!0){case e.isText:e.type===`input`&&(r.pointer=`text`);break;case e.isSprite:(e.isTimelineEnabled||e.buttonMode&&e.useHandCursor)&&(r.pointer=`pointer`);break;default:r.pointer=`pointer`;break}r.hit||=e;break}}}return z(u),z(d),Ht(f),l!==n&&F.release(l),g},ti={x:0,y:0,pointer:``,hit:null},ni=(e,t,n,r=!1)=>{if(r){let r=e.parent,i=r?r.concatenatedMatrix.rawData:jt;switch(Xt.setTransform(1,0,0,1,0,0),Xt.beginPath(),ti.x=t,ti.y=n,ti.hit=null,!0){case e.isContainerEnabled:return ei(e,Xt,i,ti);case e.isShape:return Zr(e,Xt,i,ti);case e.isText:return Qr(e,Xt,i,ti);case e.isVideo:return $r(e,Xt,i,ti);default:return!1}}let i=jr(e),a=H(e),o=e.cacheAsBitmap,s=a||jt,c=null;if(o&&s){let e=o.rawData,t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=Math.sqrt(e[2]*e[2]+e[3]*e[3]);c=L(s[0]*t,s[1]*t,s[2]*n,s[3]*n,s[4],s[5]),s=c}let l=W(i[0],i[1],i[2],i[3],s);V(i),c&&Rt(c);let u=new Ot(l[0],l[1],Math.abs(l[2]-l[0]),Math.abs(l[3]-l[1]));V(l);let d=e.parent,f=d?d.globalToLocal(new P(t,n)):new P(t,n);return u.containsPoint(f)},ri=e=>{let t=H(e);return t?new F(t[0],t[1],t[2],t[3],t[4],t[5]):new F},ii=e=>{let t=sn(e);return t?new N(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]):new N},ai=class extends le{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;_$cacheAsBitmap;_$variables;isMask;parent;cacheTransform=null;constructor(){super(),this.instanceId=Nt(),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._$cacheAsBitmap=null,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 on(this)}get alpha(){return cn(this)}set alpha(e){ln(this,e)}get blendMode(){return sr(this)}set blendMode(e){cr(this,e)}get filters(){return ar(this)}set filters(e){or(this,e)}get dropTarget(){return an()}get height(){return Fr(this)}set height(e){Ir(this,e)}get loaderInfo(){return Gt.has(this)?Gt.get(this):null}get colorTransform(){return ii(this)}set colorTransform(e){this.$colorTransform=e}get matrix(){return ri(this)}set matrix(e){this.$matrix=e}get mouseX(){return this.globalToLocal(At).x}get mouseY(){return this.globalToLocal(At).y}get root(){return Kt.has(this)?Kt.get(this):null}get rotation(){return this.$rotation===null?ur(this):this.$rotation}set rotation(e){fr(this,e)}get scale9Grid(){return this._$scale9Grid}set scale9Grid(e){this._$scale9Grid!==e&&(this._$scale9Grid=e,I(this))}get scaleX(){let e=this.$scaleX===null?pr(this):this.$scaleX;if(this._$cacheAsBitmap){let t=this._$cacheAsBitmap.rawData;return e*Math.sqrt(t[0]*t[0]+t[1]*t[1])}return e}set scaleX(e){mr(this,e)}get scaleY(){let e=this.$scaleY===null?hr(this):this.$scaleY;if(this._$cacheAsBitmap){let t=this._$cacheAsBitmap.rawData;return e*Math.sqrt(t[2]*t[2]+t[3]*t[3])}return e}set scaleY(e){gr(this,e)}get visible(){return this._$visible}set visible(e){e=!!e,this._$visible!==e&&(this._$visible=e,I(this))}get cacheAsBitmap(){return this._$cacheAsBitmap}set cacheAsBitmap(e){e!==null&&!(e instanceof F)||this._$cacheAsBitmap!==e&&(this._$cacheAsBitmap=e,I(this))}get width(){return kr(this)}set width(e){Mr(this,e)}get x(){return this.$x===null?_r(this):this.$x}set x(e){vr(this,e)}get y(){return this.$y===null?yr(this):this.$y}set y(e){br(this,e)}getBounds(e=null){return Rr(this,e)}globalToLocal(e){return Pr(this,e)}hitTestObject(e){return zr(this,e)}hitTestPoint(e,t,n=!1){return ni(this,e,t,n)}localToGlobal(e){return Nr(this,e)}getLocalVariable(e){if(!this._$variables)return null;if(this._$variables.has(e))return this._$variables.get(e)}setLocalVariable(e,t){this._$variables||=new Map,this._$variables.set(e,t)}hasLocalVariable(e){return this._$variables?this._$variables.has(e):!1}deleteLocalVariable(e){this._$variables&&this._$variables.has(e)&&(this._$variables.delete(e),this._$variables.size||(this._$variables=null))}getGlobalVariable(e){return tn.has(e)?tn.get(e):null}setGlobalVariable(e,t){tn.set(e,t)}hasGlobalVariable(e){return tn.has(e)}deleteGlobalVariable(e){tn.has(e)&&tn.delete(e)}clearGlobalVariable(){return tn.clear()}remove(){Lr(this)}$syncLoaderInfo(e){Gt.set(this,e)}},oi=e=>{let t=e.children;for(let n=0;n<t.length;++n){let r=t[n];r&&(Kt.set(r,e.root),qt.add(r.instanceId),r.isContainerEnabled&&oi(r))}},si=e=>{e.$addedToStage||!qt.has(e.instanceId)||(e.$addedToStage=!0,e.willTrigger(w.ADDED_TO_STAGE)&&e.dispatchEvent(new w(w.ADDED_TO_STAGE)))},ci=e=>{let t=e.children;for(let e=0;e<t.length;++e){let n=t[e];n&&(si(n),n.isContainerEnabled&&ci(n))}},li=e=>{e.$added||(e.$added=!0,e.willTrigger(w.ADDED)&&e.dispatchEvent(new w(w.ADDED,!0)))},ui=(e,t,n=-1)=>{let r=t.parent;r&&r.removeChild(t);let i=e.children;return 0>n?i.push(t):i.splice(n,0,t),e.$container=null,t.parent=e,qt.has(e.instanceId)&&(Kt.set(t,e.root),qt.add(t.instanceId),t.isContainerEnabled&&oi(t)),li(t),qt.has(e.instanceId)&&(si(t),t.isContainerEnabled&&ci(t)),I(t),t},di=e=>{let t=e.children;for(let e=0;e<t.length;++e){let n=t[e];n&&(Kt.delete(n),qt.delete(n.instanceId),n.isVideo&&n.pause(),n.isContainerEnabled&&di(n))}},fi=e=>{e.$added&&(e.$added=!1,e.willTrigger(w.REMOVED)&&e.dispatchEvent(new w(w.REMOVED,!0)))},pi=e=>{!e.$addedToStage||!qt.has(e.instanceId)||(e.$addedToStage=!1,e.willTrigger(w.REMOVED_FROM_STAGE)&&e.dispatchEvent(new w(w.REMOVED_FROM_STAGE)),e.uniqueKey&&M.has(e.uniqueKey)&&M.removeTimer(e.uniqueKey))},mi=e=>{let t=e.children;for(let e=0;e<t.length;++e){let n=t[e];n&&(pi(n),n.isContainerEnabled&&mi(n))}},hi=(e,t)=>{let n=t.parent;if(n&&n.instanceId!==e.instanceId)return;let r=e.children,i=r.indexOf(t);i>-1&&r.splice(i,1),e.$container=null,t.hasEventListener(w.ENTER_FRAME)&&t.removeAllEventListener(w.ENTER_FRAME),t.hasEventListener(k.KEY_DOWN)&&t.removeAllEventListener(k.KEY_DOWN),t.hasEventListener(k.KEY_UP)&&t.removeAllEventListener(k.KEY_UP),fi(t),qt.has(e.instanceId)&&(pi(t),t.isContainerEnabled&&mi(t)),qt.has(e.instanceId)&&(Kt.delete(t),qt.delete(t.instanceId),t.isVideo&&t.pause(),t.isContainerEnabled&&di(t)),t.parent=null,I(e)},gi=(e,t)=>{let n=e.children;return t in n?n[t]:null},_i=(e,t)=>{let n=gi(e,t);n&&hi(e,n)},vi=(e,t)=>{if(e.instanceId===t.instanceId)return!0;let n=e.children;for(let e=0;e<n.length;++e){let r=n[e];if(r&&(r.instanceId===t.instanceId||r.isContainerEnabled&&r.contains(t)))return!0}return!1},yi=(e,t)=>{if(!t)return null;let n=e.children;for(let e=0;e<n.length;++e){let r=n[e];if(!(!r.name||r.name!==t))return r}return null},bi=(e,t)=>{let n=e.children.slice();if(n.length)for(let r=0;r<t.length;r++){let i=n[t[r]];i&&hi(e,i)}},xi=(e,t,n)=>{let r=e.getChildIndex(t);if(r===-1||r===n)return;let i=e.children;i.splice(r,1),i.splice(n,0,t),I(e)},Si=(e,t,n)=>{let r=e.getChildIndex(t),i=e.getChildIndex(n);if(r===-1||i===-1)return;let a=e.children;a[r]=n,a[i]=t,I(e)},Ci=(e,t,n)=>{let r=e.children,i=r[t],a=r[n];!i||!a||(r[t]=a,r[n]=i,I(e))},wi=class extends ai{mouseEnabled;isInteractive;constructor(){super(),this.isInteractive=!0,this.mouseEnabled=!0}},Ti=class extends wi{_$children;_$mask;mouseChildren;$container;isContainerEnabled;constructor(){super(),this.isContainerEnabled=!0,this.mouseChildren=!0,this._$mask=null,this._$children=R(),this.$container=null}get children(){return this._$children}get numChildren(){return this.children.length}get mask(){return this._$mask}set mask(e){e!==this._$mask&&(this._$mask&&=(this._$mask.isMask=!1,null),e&&(e.isMask=!0,this._$mask=e),I(this))}addChild(e){return ui(this,e)}addChildAt(e,t){return ui(this,e,t)}contains(e){return vi(this,e)}getChildAt(e){return gi(this,e)}getChildByName(e){return yi(this,e)}getChildIndex(e){return this.children.indexOf(e)}removeChild(e){hi(this,e)}removeChildAt(e){_i(this,e)}removeChildren(...e){bi(this,e)}setChildIndex(e,t){xi(this,e,t)}swapChildren(e,t){Si(this,e,t)}swapChildrenAt(e,t){Ci(this,e,t)}},Ei=class extends le{name;frame;constructor(e,t){super(),this.name=`${e}`,this.frame=t|0}},Di=class extends le{id;content;data;url;format;constructor(){super(),this.id=Nt(),this.url=``,this.content=null,this.data=null,this.format=`json`}},Oi=(e,t=!1,n=null)=>{let r=e.parent?e.parent.globalToLocal(At):e.globalToLocal(At);e.$lockCenter=t,e.$offsetX=e.x-r.x,e.$offsetY=e.y-r.y,e.$boundedRect=n,rn(e)},ki=e=>{e.$lockCenter=!1,e.$offsetX=0,e.$offsetY=0,e.$boundedRect=null,rn(null)},Ai=class extends Ti{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(e){this._$soundTransform=e}startDrag(e=!1,t=null){Oi(this,e,t)}stopDrag(){ki(this)}},ji=e=>{e.isBitmap=!1,e.$bitmapBuffer=null,e.graphics.clear(),e.uniqueKey!==``&&M.has(e.uniqueKey)&&(M.removeById(e.uniqueKey),M.$removeIds.push(+e.uniqueKey)),I(e)},Mi=(e,t,n,r)=>{ji(e),e.isBitmap=!0,e.$bitmapBuffer=r,e.graphics.xMin=0,e.graphics.yMin=0,e.graphics.xMax=t,e.graphics.yMax=n},Ni=(e,t)=>{let n=new Image;n.crossOrigin=`anonymous`,n.addEventListener(`load`,()=>{let t=n.width,r=n.height,i=M.getCanvas();i.width=t,i.height=r;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(n,0,0,t,r),Mi(e,t,r,new Uint8Array(a.getImageData(0,0,t,r).data)),M.destroy(a),e.hasEventListener(w.COMPLETE)&&e.dispatchEvent(new w(w.COMPLETE))}),n.src=t},Pi=(e,t)=>{let n=e.graphics,r=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:{let a=e.loaderInfo.data?.characters[t.bitmapId];if(!a)break;e.isBitmap=!0,a.imageBuffer||(a.imageBuffer=new Uint8Array(a.buffer),a.buffer=null);let o=Math.ceil(Math.abs(a.bounds.xMax-a.bounds.xMin)),s=Math.ceil(Math.abs(a.bounds.yMax-a.bounds.yMin));if(t.grid){if(t.recodes){let e=t.recodes.slice(0);e.splice(-6,6);let r=new Me(o,s);r.buffer=a.imageBuffer,e.push(G.BITMAP_FILL,r,null,!0,!1,9);let i=Yr(e);n.buffer=new Float32Array(i),z(e),z(i)}}else if(r===o&&i===s)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{let e=new Me(o,s);if(e.buffer=a.imageBuffer,t.recodes)if(t.recodes[t.recodes.length-10]===G.BITMAP_STROKE){let r=t.recodes.slice(0);r.splice(-5,5),r.push(e,null,!0,!1);let i=Yr(r);n.buffer=new Float32Array(i),z(r),z(i)}else n.beginBitmapFill(e).drawRect(0,0,r,i)}}break;case t.inBitmap:{e.isBitmap=!0;let a=t.recodes,o=a[a.length-4];if(r===o.width&&i===o.height)e.setBitmapBuffer(o.width,o.height,o.buffer);else{let e=new Me(o.width,o.height);e.buffer=o.buffer,n.beginBitmapFill(e).drawRect(0,0,r,i)}}break;case`buffer`in t:t.imageBuffer||(t.imageBuffer=new Uint8Array(t.buffer),t.buffer=null),e.setBitmapBuffer(Math.ceil(Math.abs(n.xMax-n.xMin)),Math.ceil(Math.abs(n.yMax-n.yMin)),t.imageBuffer);break;default:t.recodes&&=(t.recodeBuffer=new Float32Array(Yr(t.recodes)),z(t.recodes),null),t.recodeBuffer&&(n.buffer=t.recodeBuffer);break}n.xMin=t.bounds.xMin,n.xMax=t.bounds.xMax,n.yMin=t.bounds.yMin,n.yMax=t.bounds.yMax,t.grid&&(e.scale9Grid=new Ot(t.grid.x,t.grid.y,t.grid.w,t.grid.h))},Fi=(e,t)=>new Promise(n=>{let r=()=>{e.removeEventListener(w.COMPLETE,r),n()};e.addEventListener(w.COMPLETE,r),e.src=t}),Ii=class extends ai{_$graphics;_$src;isShape;cacheKey;cacheParams;isBitmap;$bitmapBuffer;constructor(){super(),this.isShape=!0,this.cacheKey=0,this.cacheParams=R(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 G,Jt.set(this._$graphics,this)),this._$graphics}get src(){return this._$src}set src(e){this._$src!==e&&(this._$src=e,Ni(this,e))}load(e){return Fi(this,e)}get bitmapData(){let e=new Me(this.width,this.height);return this.$bitmapBuffer&&(e.buffer=this.$bitmapBuffer),e}clearBitmapBuffer(){ji(this)}setBitmapBuffer(e,t,n){Mi(this,e,t,n)}$sync(e,t=null){t&&super.$syncLoaderInfo(t),Pi(this,e)}},Li=null,Ri=e=>{Li=e},zi=()=>Li,Bi=document.createElement(`textarea`);Bi.tabIndex=-1;var Vi=``;Vi+=`position: fixed;`,Vi+=`top: 0;`,Vi+=`left: 0;`,Vi+=`font-size: 16px;`,Vi+=`border: 0;`,Vi+=`resize: none;`,Vi+=`opacity: 0;`,Vi+=`z-index: -1;`,Vi+=`pointer-events: none;`,Bi.setAttribute(`style`,Vi);var Hi=document.createElement(`canvas`);Hi.width=Hi.height=1;var Ui=Hi.getContext(`2d`),Wi=0,Gi=()=>Wi,Ki=e=>{Wi=e},qi=e=>Ui?(Ui.fillStyle=e,+`0x${Ui.fillStyle.slice(1)}`):0,Ji=e=>isNaN(+e)?qi(`${e}`):+e,Yi=(e,t=1)=>({R:(e&16711680)>>16,G:(e&65280)>>8,B:e&255,A:t*255}),Xi=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},Zi,Qi=()=>Zi,$i=e=>{Zi=e},ea={x:0,y:0},ta=class e{align;bold;color;font;italic;leading;leftMargin;letterSpacing;rightMargin;size;underline;constructor(e=null,t=null,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null,u=null){this.font=e,this.size=t,this.color=n,this.bold=r,this.italic=i,this.underline=a,this.align=o,this.leftMargin=s,this.rightMargin=c,this.leading=l,this.letterSpacing=u}clone(){return new e(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:Ji(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}}},na=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},ra=e=>{let t=``;if(e.font&&(t+=`font-family: ${e.font};`),e.size&&(t+=`font-size: ${e.size}px;`),e.color){let n=Yi(Ji(e.color)),r=n.R.toString(16).padStart(2,`0`),i=n.G.toString(16).padStart(2,`0`),a=n.B.toString(16).padStart(2,`0`);t+=`color: #${r}${i}${a};`}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},ia=class{_$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 e=0;e<this.widthTable.length;++e)this._$textWidth=Math.max(this._$textWidth,this.widthTable[e]);return this._$textWidth}get textHeight(){if(this._$textHeight!==-1)return this._$textHeight;this._$textHeight=0;for(let e=0;e<this.heightTable.length;++e)this._$textHeight+=this.heightTable[e];return this._$textHeight}getLineWidth(e){return e in this.widthTable?this.widthTable[e]:0}getLineHeight(e){return e in this.heightTable?this.heightTable[e]:0}clear(){this._$textWidth=-1,this._$textHeight=-1,this.widthTable.length=0,this.heightTable.length=0,this.ascentTable.length=0,this.textTable.length=0,this.lineTable.length=0}},aa=e=>{let t=``;return e.italic&&(t=`italic `),e.bold&&(t+=`bold `),`${t}${e.size}px '${e.font}',sans-serif`},oa=(e,t)=>{Ki(0);let n=e.lineTable.length;Ui.font=aa(t);let r=Ui.measureText(``),i={mode:`break`,text:``,x:0,y:0,w:0,h:r.fontBoundingBoxAscent+r.fontBoundingBoxDescent,line:n,textFormat:t.toObject()};e.heightTable[n]=0,e.ascentTable[n]=0,e.widthTable[n]=0,e.lineTable.push(i),e.textTable.push(i)},sa=e=>{let t=e.heightTable.length-1;for(let n=1;n<t;++n){if(e.heightTable[n]>0)continue;let t=e.lineTable[n];t&&(e.heightTable[n]=t.h=e.heightTable[n-1])}},ca=e=>{let t=0;return e.leftMargin&&(t+=e.leftMargin),e.rightMargin&&(t+=e.rightMargin),t},la=(e,t,n,r)=>{let i=n.lineTable.length-1,a=r.width-ca(t)-4;for(let o=0;o<e.length;++o){let s=r.textFormats?r.textFormats.shift():t,c=e[o],l={mode:`text`,text:c,x:0,y:0,w:0,h:0,line:i,textFormat:s.toObject()};Ui.font=aa(s);let u=Ui.measureText(c||``),d=s.letterSpacing?u.width+s.letterSpacing:u.width,f=s.leading?u.fontBoundingBoxAscent+u.fontBoundingBoxDescent+s.leading:u.fontBoundingBoxAscent+u.fontBoundingBoxDescent;if(l.x=0,l.y=u.fontBoundingBoxAscent,l.w=d,l.h=f,Ki(Gi()+d),r.wordWrap&&Gi()>a){Ki(d),i++,l.line=i;let e={mode:`wrap`,text:``,x:0,y:0,w:0,h:0,line:i,textFormat:s.toObject()},t=1,r=!0,a=/[0-9a-zA-Z?!;:.,?!。、;:〜]/g;for(;;){let e=n.textTable.length-t;if(0>=e){r=!1,t=0;break}let i=n.textTable[e];if(!i){r=!1,t=0;break}if(i.mode!==`text`){r=!1;break}if(i.text===` `){t--;break}if(!i.text.match(a)){t--;break}t++}if(n.widthTable[i]=0,n.heightTable[i]=0,n.ascentTable[i]=0,t>0&&r){let r=n.textTable.length-t;n.textTable.splice(r,0,e),n.lineTable.push(e);let a=i-1;n.widthTable[a]=0,n.heightTable[a]=0,n.ascentTable[a]=0;for(let e=0;e<r;++e){let t=n.textTable[e];t&&t.line===a&&t.mode===`text`&&(n.widthTable[a]+=t.w,n.heightTable[a]=Math.max(n.heightTable[a],t.h),n.ascentTable[a]=Math.max(n.ascentTable[a],t.y))}Ki(0);for(let e=r+1;e<n.textTable.length;++e){let t=n.textTable[e];t.line=i,Ki(Gi()+t.w)}}else n.textTable.push(e),n.lineTable.push(e)}n.widthTable[i]=Gi(),n.heightTable[i]=Math.max(n.heightTable[i],f),n.ascentTable[i]=Math.max(n.ascentTable[i],l.y),n.textTable.push(l)}},ua=e=>{let t=e.trim().split(`;`),n=[];for(let e=0;e<t.length;++e){let r=t[e];if(!r)continue;let i=r.split(`:`),a=i[0].trim(),o=i[1].trim();switch(a){case`font-size`:n.push({name:`size`,value:parseInt(o)});break;case`font-family`:n.push({name:`face`,value:o.replace(/'|"/g,``)});break;case`letter-spacing`:n.push({name:`letterSpacing`,value:parseInt(o)});break;case`margin-bottom`:n.push({name:`leading`,value:parseInt(o)});break;case`margin-left`:n.push({name:`leftMargin`,value:parseInt(o)});break;case`margin-right`:n.push({name:`rightMargin`,value:parseInt(o)});break;case`color`:case`align`:n.push({name:a,value:o});break;case`text-decoration`:case`font-weight`:case`font-style`:n.push({name:o,value:!0});break;default:break}}return n},da=0,fa=1,pa=2,ma=3,ha=4,ga=5,_a=6,va=7,ya=8,K=``,q=0,J=0,ba=(e,t,n,r)=>{K=e,q=0,J=e.length,xa(da,t,n,r),K=``},xa=(e,t,n,r)=>{for(;q<J;){let i=K.indexOf(`<`,q);if(i===-1){la(K.substring(q),t,n,r),q=J;break}if(i>q&&la(K.substring(q,i),t,n,r),q=i+1,q>=J)break;if(K.charCodeAt(q)===47){q++;let t=K.indexOf(`>`,q);if(t===-1){q=J;break}if(e!==da&&Oa(q,t)===e){q=t+1;return}q=t+1;continue}let a=q;for(;q<J;){let e=K.charCodeAt(q);if(e===62||e===47||e===32||e===9)break;q++}let o=Oa(a,q);switch(o){case fa:{let e=t.bold;t.bold=!0,Sa(),xa(o,t,n,r),t.bold=e;continue}case pa:{let e=t.italic;t.italic=!0,Sa(),xa(o,t,n,r),t.italic=e;continue}case ma:{let e=t.underline;t.underline=!0,Sa(),xa(o,t,n,r),t.underline=e;continue}case _a:case ha:case va:case ya:{let e=t.font,i=t.size,a=t.color,s=t.bold,c=t.italic,l=t.underline,u=t.align,d=t.leftMargin,f=t.rightMargin,p=t.leading,m=t.letterSpacing;wa(t,r),Ca(),(o===ha||o===_a)&&r.multiline&&oa(n,t),xa(o,t,n,r),t.font=e,t.size=i,t.color=a,t.bold=s,t.italic=c,t.underline=l,t.align=u,t.leftMargin=d,t.rightMargin=f,t.leading=p,t.letterSpacing=m;continue}case ga:Sa(),r.multiline&&oa(n,t);continue;default:Sa();continue}}},Sa=()=>{let e=K.indexOf(`>`,q);q=e===-1?J:e+1},Ca=()=>{q<J&&K.charCodeAt(q)===47&&q++,q<J&&K.charCodeAt(q)===62&&q++},wa=(e,t)=>{for(;;){for(;q<J;){let e=K.charCodeAt(q);if(e!==32&&e!==9)break;q++}if(q>=J)break;let n=K.charCodeAt(q);if(n===62||n===47)break;let r=q;for(;q<J;){let e=K.charCodeAt(q);if(e===61||e===62||e===47||e===32||e===9)break;q++}if(q===r)break;let i=q-r,a=K.charCodeAt(r);for(;q<J;){let e=K.charCodeAt(q);if(e!==32&&e!==9)break;q++}if(q<J&&K.charCodeAt(q)===61){for(q++;q<J;){let e=K.charCodeAt(q);if(e!==32&&e!==9)break;q++}let n,r=K.charCodeAt(q);if(r===34||r===39){q++;let e=K.indexOf(r===34?`"`:`'`,q);e===-1?(n=K.substring(q),q=J):(n=K.substring(q,e),q=e+1)}else{let e=q;for(;q<J;){let e=K.charCodeAt(q);if(e===62||e===47||e===32||e===9)break;q++}n=K.substring(e,q)}Ta(i,a,n,e,t)}else Ea(i,a,e)}},Ta=(e,t,n,r,i)=>{switch(e){case 4:t===102||t===70?r.font=n:t===115||t===83?(r.size=+n,i.subFontSize&&(r.size-=i.subFontSize,1>r.size&&(r.size=1))):(t===98||t===66)&&(r.bold=!0);break;case 5:t===99||t===67?r.color=Ji(n):t===115||t===83?Da(ua(n),r,i):(t===97||t===65)&&(r.align=n);break;case 6:(t===105||t===73)&&(r.italic=!0);break;case 7:(t===108||t===76)&&(r.leading=parseInt(n));break;case 9:(t===117||t===85)&&(r.underline=!0);break;case 10:(t===108||t===76)&&(r.leftMargin=parseInt(n));break;case 11:(t===114||t===82)&&(r.rightMargin=parseInt(n));break;case 14:(t===108||t===76)&&(r.letterSpacing=parseInt(n));break;default:break}},Ea=(e,t,n)=>{e===4&&(t===98||t===66)?n.bold=!0:e===6&&(t===105||t===73)?n.italic=!0:e===9&&(t===117||t===85)&&(n.underline=!0)},Da=(e,t,n)=>{for(let r=0;r<e.length;++r){let i=e[r];switch(i.name){case`face`:t.font=i.value;break;case`size`:t.size=+i.value,n.subFontSize&&(t.size-=n.subFontSize,1>t.size&&(t.size=1));break;case`color`:t.color=Ji(i.value);break;case`align`:t.align=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;default:break}}},Oa=(e,t)=>{for(;e<t;){let t=K.charCodeAt(e);if(t!==32&&t!==9)break;e++}for(;t>e;){let e=K.charCodeAt(t-1);if(e!==32&&e!==9)break;t--}let n=t-e;if(n===1){let t=K.charCodeAt(e);return t>=97&&(t-=32),t===66?fa:t===73?pa:t===85?ma:t===80?ha:da}if(n===2){let t=K.charCodeAt(e),n=K.charCodeAt(e+1);return t>=97&&(t-=32),n>=97&&(n-=32),t===66&&n===82?ga:da}if(n===3){let t=K.charCodeAt(e);if(t>=97&&(t-=32),t===68){let t=K.charCodeAt(e+1),n=K.charCodeAt(e+2);if(t>=97&&(t-=32),n>=97&&(n-=32),t===73&&n===86)return _a}return da}if(n===4){let t=K.charCodeAt(e);if(t>=97&&(t-=32),t===70){let t=K.charCodeAt(e+1),n=K.charCodeAt(e+2),r=K.charCodeAt(e+3);if(t>=97&&(t-=32),n>=97&&(n-=32),r>=97&&(r-=32),t===79&&n===78&&r===84)return va}if(t===83){let t=K.charCodeAt(e+1),n=K.charCodeAt(e+2),r=K.charCodeAt(e+3);if(t>=97&&(t-=32),n>=97&&(n-=32),r>=97&&(r-=32),t===80&&n===65&&r===78)return ya}return da}return da},ka=(e,t,n)=>{let r=new ia;if(!e)return r;let i=e.trim().replace(/\r?\n/g,``).replace(/\t/g,``),a=t.clone();return n.subFontSize&&n.subFontSize>0&&a.size&&(a.size-=n.subFontSize,1>a.size&&(a.size=1)),oa(r,a),ba(i,a,r,n),sa(r),r},Y=(e,t=0)=>(e.$textData||=ka(e.htmlText,e.defaultTextFormat,{width:e.width,multiline:e.multiline,wordWrap:e.wordWrap,subFontSize:t,textFormats:e.$textFormats}),e.$textData),X=e=>{e.changed=!0;let t=e.parent;t&&!t.changed&&X(t)},Aa=e=>{e.$textData=null,X(e),e.uniqueKey!==``&&M.has(e.uniqueKey)&&(M.removeById(e.uniqueKey),M.$removeIds.push(+e.uniqueKey))},ja=e=>{if(X(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}let t=e.defaultTextFormat,n=e.textWidth+4+ca(t);if(e.wordWrap)e.xMin=e.bounds.xMin,e.xMax=e.bounds.xMax;else switch(e.autoSize){case`left`:e.xMax=n+e.xMin;break;case`center`:e.xMax=n+e.xMin;break;case`right`:e.xMax=e.bounds.xMax-(e.bounds.xMax-e.bounds.xMin-(n-e.bounds.xMin));break;default:break}e.yMax=e.textHeight+e.bounds.yMin+4},Ma=e=>{let t=0,n=Y(e);for(let e=0;e<n.textTable.length;++e){let r=n.textTable[e];t=Math.max(t,r.textFormat.size||0)}let r=1;if(e.width&&e.textWidth)for(;t>r&&e.textWidth+4>e.width;)Aa(e),Y(e,r++);if(e.height&&e.textHeight)for(;t>r&&e.textHeight+4>e.height;)Aa(e),Y(e,r++);X(e)},Na=e=>{Aa(e),Y(e),e.autoSize===`none`&&e.autoFontSize&&Ma(e),ja(e)},Pa=(e,t)=>{let n=Y(e);if(2>n.textTable.length)return;let r=2,i=0;for(let e=1;e<n.textTable.length;++e){let a=n.textTable[e];if(!a)continue;let o=!1;if(a.mode===`text`&&(o=!0,r+=a.w),i>=t){i=e;break}a.mode===`break`&&(o=!0,r=2),o&&i++}let a=n.textTable[i];if(!a)return;e.$scrollX=e.$scrollY=0;let o=a.line,s=0;for(let e=0;e<=o;++e)s+=n.heightTable[e];let c=Math.abs(e.yMax-e.yMin),l=0;for(let e=o;e>-1;--e){let t=n.heightTable[e];if(c<l+t)break;l+=t}if(s>c){let t=(e.textHeight-c)/c;e.$scrollY=Math.max(0,Math.min((s-l)/t,c))}let u=Math.abs(e.xMax-e.xMin),d=0;for(let e=i;e>0;--e){let t=n.textTable[e];if(t.mode===`text`){if(u<d+t.w)break;d+=t.w}}if(r>u){let t=(e.textWidth-u)/u;e.$scrollX=Math.max(0,Math.min((r-d)/t,u+.5))}X(e)},Fa=()=>{let e=Qi();e!==void 0&&clearTimeout(e),$i(void 0)},Ia=window.devicePixelRatio,La=e=>{let t=e.localToGlobal(new P),n=e.$textData;if(n){let r=n.textTable[e.focusIndex];if(r){for(let i=e.focusIndex-1;i>-1;--i){let e=n.textTable[i];if(!e||e.line!==r.line)break;t.x+=e.w}let i=r.mode===`break`?r.line-1:r.line;for(let e=0;e<i;++e)t.y+=n.heightTable[e]}}let r=Q.rendererScale/Ia;Bi.style.left=`${ea.x+t.x*r}px`,Bi.style.top=`${ea.y+t.y*r}px`},Ra=e=>{e.focusVisible=!e.focusVisible,X(e),$i(setTimeout(()=>Ra(e),500)),La(e)},za=(e,t)=>{e.willTrigger(t)&&e.dispatchEvent(new ue(t)),Bi.value=``,e.focus?(setTimeout(()=>{Bi.focus()},300),Qi()===void 0&&(e.focusIndex===-1&&(e.focusIndex=1,e.selectIndex=-1),Ra(e))):(e.focusIndex=-1,e.selectIndex=-1,e.focusVisible=!1,Fa(),Bi.blur()),X(e)},Ba=(e,t,n,r)=>e/r*n+t,Va=(e,t,n,r)=>(e/=r)*e*n+t,Ha=(e,t,n,r)=>-(e/=r)*(e-2)*n+t,Ua=(e,t,n,r)=>(e/=r/2)<1?e*e*n/2+t:-(--e*(e-2)-1)*n/2+t,Wa=(e,t,n,r)=>(e/=r)*e*e*n+t,Ga=(e,t,n,r)=>(e/=r,(--e*e*e+1)*n+t),Ka=(e,t,n,r)=>(e/=r/2)<1?e*e*e*n/2+t:((e-=2)*e*e+2)*n/2+t,qa=(e,t,n,r)=>(e/=r)*e*e*e*n+t,Ja=(e,t,n,r)=>(e/=r,(--e*e*e*e-1)*-n+t),Ya=(e,t,n,r)=>(e/=r/2)<1?e*e*e*e*n/2+t:((e-=2)*e*e*e-2)*-n/2+t,Xa=(e,t,n,r)=>(e/=r)*e*e*e*e*n+t,Za=(e,t,n,r)=>(e/=r,(--e*e*e*e*e+1)*n+t),Qa=(e,t,n,r)=>(e/=r/2)<1?e*e*e*e*e*n/2+t:((e-=2)*e*e*e*e+2)*n/2+t,$a=(e,t,n,r)=>-n*Math.cos(e/r*(Math.PI/2))+n+t,eo=(e,t,n,r)=>n*Math.sin(e/r*(Math.PI/2))+t,to=(e,t,n,r)=>-n/2*(Math.cos(Math.PI*e/r)-1)+t,no=(e,t,n,r)=>n*2**(10*(e/r-1))+t,ro=(e,t,n,r)=>n*(-(2**(-10*e/r))+1)+t,io=(e,t,n,r)=>(e/=r/2)<1?n/2*2**(10*(e-1))+t:n/2*(-(2**(-10*(e-1)))+2)+t,ao=(e,t,n,r)=>(1-Math.sqrt(1-(e/=r)*e))*n+t,oo=(e,t,n,r)=>(e/=r,Math.sqrt(1- --e*e)*n+t),so=(e,t,n,r)=>(e/=r*2)<1?(Math.sqrt(1-e*e)-1)/-2*n+t:(Math.sqrt(1-(e-=2)*e)+1)/2*n+t,co=(e,t,n,r)=>(2.70158*(e/=r)*e*e-1.70158*e*e)*n+t,lo=(e,t,n,r)=>(1+2.70158*((e/=r)-1)**3+1.70158*(e-1)**2)*n+t,uo=(e,t,n,r)=>{let i=1.70158;return(e/=r/2)<1?e*e*(((i*=1.525)+1)*e-i)*n/2+t:((e-=2)*e*(((i*=1.525)+1)*e+i)+2)*n/2+t},fo=(e,t,n,r)=>(e/=r)===0?t:e===1?n+t:-(2**((e*=10)-10))*Math.sin((e-10.75)*(2*Math.PI/3))*n+t,po=(e,t,n,r)=>(e/=r)===0?t:e===1?n+t:(2**(-10*e)*Math.sin((e*10-.75)*(2*Math.PI/3))+1)*n+t,mo=(e,t,n,r)=>(e/=r)===0?t:e===1?n+t:e<.5?-(2**(20*e-10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5)))/2*n+t:(2**(-20*e+10)*Math.sin((20*e-11.125)*(2*Math.PI/4.5))/2+1)*n+t,ho=(e,t,n,r)=>(e/=r)<1/2.75?7.5625*e*e*n+t:e<2/2.75?(7.5625*(e-=1.5/2.75)*e+.75)*n+t:e<2.5/2.75?(7.5625*(e-=2.25/2.75)*e+.9375)*n+t:(7.5625*(e-=2.625/2.75)*e+.984375)*n+t,go=(e,t,n,r)=>n-vo.outBounce(r-e,0,n,r)+t,_o=(e,t,n,r)=>e<r/2?vo.inBounce(e*2,t,n/2,r):vo.outBounce(e*2-r,t+n/2,n/2,r),vo=class{static linear(e,t,n,r){return Ba(e,t,n,r)}static inQuad(e,t,n,r){return Va(e,t,n,r)}static outQuad(e,t,n,r){return Ha(e,t,n,r)}static inOutQuad(e,t,n,r){return Ua(e,t,n,r)}static inCubic(e,t,n,r){return Wa(e,t,n,r)}static outCubic(e,t,n,r){return Ga(e,t,n,r)}static inOutCubic(e,t,n,r){return Ka(e,t,n,r)}static inQuart(e,t,n,r){return qa(e,t,n,r)}static outQuart(e,t,n,r){return Ja(e,t,n,r)}static inOutQuart(e,t,n,r){return Ya(e,t,n,r)}static inQuint(e,t,n,r){return Xa(e,t,n,r)}static outQuint(e,t,n,r){return Za(e,t,n,r)}static inOutQuint(e,t,n,r){return Qa(e,t,n,r)}static inSine(e,t,n,r){return $a(e,t,n,r)}static outSine(e,t,n,r){return eo(e,t,n,r)}static inOutSine(e,t,n,r){return to(e,t,n,r)}static inExpo(e,t,n,r){return no(e,t,n,r)}static outExpo(e,t,n,r){return ro(e,t,n,r)}static inOutExpo(e,t,n,r){return io(e,t,n,r)}static inCirc(e,t,n,r){return ao(e,t,n,r)}static outCirc(e,t,n,r){return oo(e,t,n,r)}static inOutCirc(e,t,n,r){return so(e,t,n,r)}static inBack(e,t,n,r){return co(e,t,n,r)}static outBack(e,t,n,r){return lo(e,t,n,r)}static inOutBack(e,t,n,r){return uo(e,t,n,r)}static inElastic(e,t,n,r){return fo(e,t,n,r)}static outElastic(e,t,n,r){return po(e,t,n,r)}static inOutElastic(e,t,n,r){return mo(e,t,n,r)}static outBounce(e,t,n,r){return ho(e,t,n,r)}static inBounce(e,t,n,r){return go(e,t,n,r)}static inOutBounce(e,t,n,r){return _o(e,t,n,r)}},yo=e=>{cancelAnimationFrame(e.$timerId),e.hasEventListener(me.STOP)&&e.dispatchEvent(new me(me.STOP)),e.entries=null,e.stopFlag=!0},bo=e=>{let t=[];for(let[n,r]of Object.entries(e))t.push({name:n,value:typeof r==`number`?r:bo(r)});return t},xo=(e,t,n,r,i)=>{for(let a=0;a<i.length;++a){let o=i[a];if(!o)continue;let s=o.name;if(!(s in t)||!(s in r))continue;if(typeof o.value!=`number`){xo(e,t[s],n[s],r[s],o.value);continue}let c=n[s];e.duration>e.currentTime?t[s]=e.ease(e.currentTime,c,r[s]-c,e.duration):t[s]=r[s]}},So=(e,t)=>e.stopFlag||!e.entries?-1:(e.currentTime=(t-e.startTime)/1e3,xo(e,e.target,e.from,e.to,e.entries),e.hasEventListener(me.UPDATE)&&e.dispatchEvent(new me(me.UPDATE)),e.currentTime>=e.duration?(e.hasEventListener(me.COMPLETE)&&e.dispatchEvent(new me(me.COMPLETE)),e.nextJob&&e.nextJob.start(),-1):requestAnimationFrame(t=>{So(e,t)})),Co=e=>{e.stopFlag||(e.entries=bo(e.from),e.entries&&(e.startTime=performance.now(),e.$timerId=So(e,e.startTime)))},wo=e=>{cancelAnimationFrame(e.$timerId),e.stopFlag=!1,e.delay?setTimeout(()=>{Co(e)},e.delay*1e3):Co(e)},To=class extends le{target;entries;startTime;stopFlag;$timerId;delay;duration;ease;from;to;currentTime;nextJob;constructor(e,t,n,r=0,i=1,a=null){super(),this.target=e,this.from=t,this.to=n,this.delay=r,this.duration=i,this.ease=a||vo.linear,this.currentTime=0,this.nextJob=null,this.entries=null,this.startTime=0,this.stopFlag=!1,this.$timerId=-1}chain(e){return this.nextJob=e,e}start(){wo(this)}stop(){yo(this)}},Eo=class{static add(e,t,n,r=0,i=1,a=null){return new To(e,t,n,r,i,a)}},Do=(e,t)=>{if(!e.scrollEnabled||e.autoSize!==`none`||e.yScrollShape.hasLocalVariable(`job`))return;let n=e.width;if(t=Xi(t,0,n,0),e.scrollX!==t){if(e.textWidth>n){X(e);let r=e.xScrollShape;r.width=n*n/e.textWidth;let i=e.parent;if(i){r.hasLocalVariable(`job`)&&r.getLocalVariable(`job`).stop(),r.alpha=.9,r.x=e.x+1+(n-1-r.width)/(n-1)*(t-1),r.y=e.y+e.height-r.height-.5,i.addChildAt(r,i.getChildIndex(e)+1);let a=Eo.add(r,{alpha:.9},{alpha:0},.5,.2,vo.outQuad);a.addEventListener(w.COMPLETE,e=>{let t=e.target.target;t.deleteLocalVariable(`job`),t.parent&&t.parent.removeChild(t)}),a.start(),r.setLocalVariable(`job`,a)}e.$scrollX=t}e.willTrigger(w.SCROLL)&&e.dispatchEvent(new w(w.SCROLL,!0))}},Oo=(e,t)=>{if(!e.scrollEnabled||e.autoSize!==`none`||!e.multiline&&!e.wordWrap||e.xScrollShape.hasLocalVariable(`job`))return;let n=e.height;if(t=Xi(t,0,n,0),e.scrollY!==t){if(e.textHeight>n){X(e);let r=e.yScrollShape;r.height=n*n/e.textHeight;let i=e.parent;if(i){r.hasLocalVariable(`job`)&&r.getLocalVariable(`job`).stop(),r.alpha=.9,r.x=e.x+e.width-r.width-.5,r.y=e.y+.5+(n-1-r.height)/(n-1)*(t-1),i.addChildAt(r,i.getChildIndex(e)+1);let a=Eo.add(r,{alpha:.9},{alpha:0},.5,.2,vo.outQuad);a.addEventListener(w.COMPLETE,e=>{let t=e.target.target;t.deleteLocalVariable(`job`),t.parent&&t.parent.removeChild(t)}),a.start(),r.setLocalVariable(`job`,a),e.$scrollY=t}}e.willTrigger(w.SCROLL)&&e.dispatchEvent(new w(w.SCROLL,!0))}},ko=e=>{let t=``,n=Y(e);for(let e=1;e<n.textTable.length;++e){let r=n.textTable[e];if(r)switch(r.mode){case`text`:t+=r.text;break;case`break`:t+=`\r`;break;default:continue}}return t},Ao=(e,t)=>{let n=``,r=Y(e);for(let e=1;e<r.textTable.length;e++){let i=r.textTable[e];if(i){if(i.line>t)break;i.line===t&&i.mode===`text`&&(n+=i.text)}}return n},jo=(e,t,n,r)=>{if(0>n||n>r)return;let i=e.text;e.text=(n?i.slice(0,n):``)+t+i.slice(r,i.length)},Mo=async e=>{if(e.focusIndex===-1||e.selectIndex===-1)return;let t=``,n=Math.min(e.focusIndex,e.selectIndex),r=Math.max(e.focusIndex,e.selectIndex)+1,i=Y(e);for(let e=n;e<r;++e){let n=i.textTable[e];if(n)switch(n.mode){case`text`:t+=n.text;break;case`break`:t+=`
|
|
3
|
+
`;break;default:break}}await navigator.clipboard.writeText(t)},No=async e=>{let t=await navigator.clipboard.readText();t===``||e.focusIndex===-1||e.insertText(t)},Po=e=>{if(e.compositionStartIndex>-1)return;let t=0,n=0;if(e.selectIndex>-1)t=Math.min(e.focusIndex,e.selectIndex),n=Math.max(e.focusIndex,e.selectIndex)+1,e.focusIndex=t;else{if(2>e.focusIndex)return;e.focusIndex--}let r=Y(e),i=r.textTable[e.focusIndex];i&&i.mode===`wrap`&&e.focusIndex--;let a=[],o=``;for(let i=1;i<r.textTable.length;++i){let s=r.textTable[i];if(s&&!(e.focusIndex===i||t<=i&&n>i))switch(s.mode){case`break`:a.push(new ta(...Object.values(s.textFormat))),o+=`
|
|
4
|
+
`;break;case`text`:a.push(new ta(...Object.values(s.textFormat))),o+=s.text;break;default:continue}}if(r.textTable.length===e.focusIndex&&(a.pop(),o=o.slice(0,-1)),e.selectIndex=-1,!o)e.text=``,e.focusIndex=1;else{let t=e.textWidth,n=e.textHeight;if(e.$textFormats=a,e.text=o,e.scrollX>0){let n=e.textWidth,r=e.width;switch(!0){case r>n:e.$scrollX=0;break;case t!==n:e.$scrollX-=(t-n)/(n/r);break;default:break}}if(e.scrollY>0){let t=e.textHeight,r=e.height;switch(!0){case r>t:e.$scrollY=0;break;case n!==t:e.$scrollY-=(n-t)/(t/r);break;default:break}}e.$textFormats=null}},Fo=(e,t)=>{if(e.focusIndex===-1||e.compositionStartIndex>-1)return;e.selectIndex>-1&&Po(e);let n=Y(e);if(2>n.textTable.length){e.focusIndex=2,e.appendText(t);return}let r=[],i=``;for(let a=1;a<n.textTable.length;++a){let o=n.textTable[a];if(o){if(e.focusIndex===a)for(let e=0;e<t.length;++e)r.push(new ta(...Object.values(o.textFormat))),i+=t[e];switch(o.mode){case`break`:r.push(new ta(...Object.values(o.textFormat))),i+=`
|
|
5
|
+
`;break;case`text`:r.push(new ta(...Object.values(o.textFormat))),i+=o.text;break;default:continue}}}if(n.textTable.length===e.focusIndex){let a;if(n.textTable.length){let e=n.textTable[n.textTable.length-1];a=new ta(...Object.values(e.textFormat))}else a=e.defaultTextFormat,e.focusIndex++;for(let e=0;e<t.length;++e)r.push(new ta(...Object.values(a.toObject()))),i+=t[e]}e.$textFormats=r,e.text=i,e.$textFormats=null,e.focusIndex+=t.length,e.selectIndex=-1,Bi.value=``},Io=e=>{if(e.selectIndex===-1)return;let t=Y(e);if(2>t.textTable.length)return;let n=t.textTable[e.selectIndex];if(!n)return;let r=n.mode===`text`?n.line:n.line-1,i=e.height,a=(e.textHeight-i)/i,o=-e.scrollY*a-2,s=0;for(let e=0;e<t.heightTable.length&&(o+=t.heightTable[e],!(o>i));++e)s++;o=-e.scrollY*a-2;let c=0;for(let e=0;e<t.heightTable.length&&(o+=t.heightTable[e],!(o>0));++e)c++;c>=n.line&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY-=t.heightTable[n.line]/a),n.line>=s&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY+=t.heightTable[n.line]/a);let l=e.width,u=(e.textWidth-l)/l,d=2,f=e.scrollX*u-2+l;for(let n=1;e.selectIndex>=n;++n){let i=t.textTable[n];if(!i||i.line>r)break;if(i.line===r&&(e.selectIndex!==n&&(d+=i.w),f-=i.w,!(f>0))){e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX+=i.w/u;break}}e.scrollX*u-2>d&&(e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=e.width*((d-2)/e.textWidth))},Lo=(e,t,n,r=!1)=>{if(e.type!==`input`)return;let i=Y(e);if(2>i.textTable.length){e.focusIndex=1,e.selectIndex=-1,Qi()===void 0&&Ra(e);return}let a=e.width,o=e.height,s=0;e.scrollX>0&&(s+=e.scrollX*(e.textWidth-a)/a);let c=0;e.scrollY>0&&(c+=e.scrollY*(e.textHeight-o)/o);let l=e.globalToLocal(new P(t,n)),u=l.x+s,d=l.y+c,f=2,p=2,m=p+i.heightTable[0];for(let t=1;t<i.textTable.length;++t){let n=i.textTable[t];if(n){switch(n.mode){case`break`:case`wrap`:if(u>f&&d>p&&m>d&&a>u){let n=t;r?e.selectIndex!==n&&(e.selectIndex=n,e.focusVisible&&(e.focusVisible=!1,Fa()),Io(e),X(e)):(e.focusIndex!==n||e.selectIndex>-1)&&(e.focusIndex=n,e.selectIndex=-1,X(e));return}f=2,p+=i.heightTable[n.line-1],m=p+i.heightTable[n.line];break;case`text`:if(u>f&&d>p&&m>d&&f+n.w>u){let a=t;if(r)e.focusIndex>a?e.focusIndex===a+1?f+n.w/2<u&&(a=-1):f+n.w/2<u&&(a+=1):e.focusIndex===a?f+n.w/2>u&&(a=-1):f+n.w/2>u&&--a,e.selectIndex!==a&&(e.selectIndex=a,e.selectIndex>-1&&(e.focusVisible=!1,Fa()),Io(e),X(e));else{if(f+n.w/2<u){let e=i.textTable[a+1];(!e||e.mode===`text`)&&(a+=1)}(e.focusIndex!==a||e.selectIndex>-1)&&(e.focusIndex=a,e.selectIndex=-1,X(e))}return}if(t===i.textTable.length-1&&u>f&&d>p&&m>d&&a>u){let t=i.textTable.length;r?e.selectIndex!==t&&(e.selectIndex=t,e.focusVisible&&(e.focusVisible=!1,Fa()),X(e)):(e.focusIndex!==t||e.selectIndex>-1)&&(e.focusIndex=t,e.selectIndex=-1,X(e));return}f+=n.w;break;default:break}if(!r)e.focusIndex=i.textTable.length,e.selectIndex=-1,Qi()===void 0?Ra(e):X(e);else{let t=0;for(let e=0;i.heightTable.length>e;++e)t+=i.heightTable[e];(d>t||2>d)&&(e.selectIndex=2>d?1:i.textTable.length,e.focusVisible&&(e.focusVisible=!1,Fa()),X(e))}}}},Ro=(e,t)=>{if(e.focusIndex===-1)return;let n=Y(e);if(2>n.textTable.length)return;let r=n.textTable[e.focusIndex];if(!r)return;let i=r.mode===`text`?r.line:r.line-1;if(i===n.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=n.textTable.length;let r=e.width,a=(e.textWidth-r)/r,o=0;for(let t=1;e.focusIndex>=t;++t){let e=n.textTable[t];if(!e||e.line>i)break;e.line===i&&(o+=e.w)}e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=(o-r)/a,Fa(),Ra(e);return}let a=e.height,o=(e.textHeight-a)/a,s=-e.scrollY*o-2,c=0;for(let e=0;e<n.heightTable.length&&(s+=n.heightTable[e],!(s>a));++e)c++;let l=2;for(let t=1;t<n.textTable.length;++t){let r=n.textTable[t];if(r){if(e.focusIndex===t){r.mode===`text`&&(l+=r.w/2);break}if(r.line>i)break;r.line!==i||r.mode!==`text`||(l+=r.w)}}let u=2,d=i+1;for(let r=1;r<n.textTable.length;++r){let i=n.textTable[r];if(i){if(i.line>d){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,i.line>=c&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY+=n.heightTable[i.line]/o),e.focusVisible=!1,e.focusIndex=i.mode===`text`?r-1:r,e.scrollX&&u<l&&(e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=e.width*((u-2)/e.textWidth)),Fa(),Ra(e);return}if(!(i.line!==d||i.mode!==`text`)&&(u+=i.w,u>l)){if(t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===r-1&&(e.selectIndex=-1):e.selectIndex=-1,i.line>=c&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY+=n.heightTable[i.line]/o),e.scrollX){let t=e.width,n=(e.textWidth-t)/t;e.scrollX*n-2>u&&(e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=e.width*((u-2)/e.textWidth))}e.focusVisible=!1,e.focusIndex=r,Fa(),Ra(e);return}}}t?e.selectIndex===-1&&(e.selectIndex=e.focusIndex):e.selectIndex=-1,e.focusVisible=!1,e.focusIndex=n.textTable.length,Fa(),Ra(e)},zo=(e,t)=>{if(e.focusIndex===-1)return;let n=Y(e);if(2>n.textTable.length)return;let r=n.textTable.length===e.focusIndex?e.focusIndex-1:e.focusIndex,i=n.textTable[r];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,Fa(),Ra(e);return}let a=i.mode===`text`?i.line:i.line-1,o=e.height,s=(e.textHeight-o)/o,c=0,l=-e.scrollY*s-2;for(let e=0;e<n.heightTable.length&&(l+=n.heightTable[e],!(l>0));++e)c++;let u=2;for(let t=1;t<n.textTable.length;++t){let r=n.textTable[t];if(r){if(e.focusIndex===t){r.mode===`text`&&(u+=r.w/2);break}if(r.line>a)break;r.line!==a||r.mode!==`text`||(u+=r.w)}}let d=2,f=a-1;for(let r=1;r<n.textTable.length;++r){let i=n.textTable[r];if(i){if(i.line>f){t?e.selectIndex===-1?e.selectIndex=e.focusIndex:e.selectIndex===e.focusIndex&&(e.selectIndex=-1):e.selectIndex=-1,c>=i.line&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY-=n.heightTable[i.line]/s),e.scrollX&&=(e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.width*((d-2)/e.textWidth)),e.focusVisible=!1,e.focusIndex=i.mode===`text`?r-1:r,Fa(),Ra(e);return}if(!(i.line!==f||i.mode!==`text`)&&(d+=i.w,d>u)){t?e.selectIndex===-1?e.selectIndex=e.focusIndex-1:e.selectIndex===r+1&&(e.selectIndex=-1):e.selectIndex=-1,c>i.line&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY-=n.heightTable[i.line]/s),e.focusVisible=!1,e.focusIndex=r,Fa(),Ra(e);return}}}},Bo=(e,t)=>{if(!e.focusIndex)return;let n=Y(e);if(n.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;let r=n.textTable[e.focusIndex];if(r){let t=r.mode===`text`?r.line:r.line-1,i=e.height,a=(e.textHeight-i)/i,o=-e.scrollY*a-2,s=0;for(let e=0;e<n.heightTable.length&&(o+=n.heightTable[e],!(o>0));++e)s++;s>t&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY-=n.heightTable[r.line]/a);let c=n.textTable[e.focusIndex+1];if(c){let r=c.mode===`text`?c.line:c.line-1,i=2;for(let r=1;e.focusIndex>r;++r){let e=n.textTable[r];if(!e||e.line>t)break;e.line===t&&(i+=e.w)}let a=e.width,o=(e.textWidth-a)/a,s=e.scrollX*o-2;if(i>a&&c&&t<r){e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=e.width;return}if(s>i){e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=e.width*((i-2)/e.textWidth);return}}}e.focusVisible=!1,Fa(),Ra(e)},Vo=(e,t)=>{let n=Y(e);if(n.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++,Fa(),Ra(e);let r=n.textTable[e.focusIndex];if(r){let t=r.mode===`text`?r.line:r.line-1,i=e.height,a=(e.textHeight-i)/i,o=-e.scrollY*a-2,s=0;for(let e=0;e<n.heightTable.length&&(o+=n.heightTable[e],!(o>i));++e)s++;t>=s&&(e.xScrollShape.hasLocalVariable(`job`)&&e.xScrollShape.deleteLocalVariable(`job`),e.scrollY+=n.heightTable[t]/a);let c=n.textTable[e.focusIndex-1],l=c.mode===`text`?c.line:c.line-1;if(c&&t>l){e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX=0;return}let u=e.width,d=(e.textWidth-u)/u,f=e.scrollX*d-2+u;for(let r=1;e.focusIndex>=r;++r){let i=n.textTable[r];if(!i||i.line>t)break;if(i.line===t&&(f-=i.w,!(f>0))){e.yScrollShape.hasLocalVariable(`job`)&&e.yScrollShape.deleteLocalVariable(`job`),e.scrollX+=i.w/d;break}}}},Ho=(e,t)=>{if(e.focusIndex!==-1)switch(t.key){case`Backspace`:case`Delete`:e.deleteText();break;case`Enter`:e.insertText(`
|
|
6
|
+
`);break;case`ArrowLeft`:Bo(e,t.shiftKey);break;case`ArrowRight`:Vo(e,t.shiftKey);break;case`ArrowUp`:zo(e,t.shiftKey);break;case`ArrowDown`:Ro(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;default:break}},Uo=e=>{let t=Y(e);2>t.textTable.length||(e.selectIndex=1,e.focusIndex=t.textTable.length,X(e))},Wo=(e,t)=>{let n=e.defaultTextFormat;switch(n.font=t.font,n.size=t.size,n.align=t.align,n.color=t.color,n.leading=t.leading,n.letterSpacing=t.letterSpacing,n.leftMargin=t.leftMargin,n.rightMargin=t.rightMargin,t.fontType){case 1:n.bold=!0;break;case 2:n.italic=!0;break;case 3:n.bold=!0,n.italic=!0;break}switch(e.defaultTextFormat=n,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;default: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},Go=class extends wi{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;let e=new ta;na(e),this._$defaultTextFormat=e,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 Ii,this.xScrollShape.graphics.beginFill(`#000`,.3).drawRoundRect(0,0,3,3,3),this.xScrollShape.scale9Grid=new Ot(1.5,1.5,.1,.1),this.yScrollShape=new Ii,this.yScrollShape.graphics.beginFill(`#000`,.3).drawRoundRect(0,0,3,3,3),this.yScrollShape.scale9Grid=new Ot(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(e){e!==this._$autoFontSize&&(this._$autoFontSize=!!e,Na(this))}get autoSize(){return this._$autoSize}set autoSize(e){e!==this._$autoSize&&(this._$autoSize=e,Na(this))}get background(){return this._$background}set background(e){e!==this._$background&&(this._$background=!!e,X(this))}get backgroundColor(){return this._$backgroundColor}set backgroundColor(e){e=Xi(Ji(e),0,16777215,16777215),e!==this._$backgroundColor&&(this._$backgroundColor=e,X(this))}get border(){return this._$border}set border(e){e!==this._$border&&(this._$border=!!e,X(this))}get borderColor(){return this._$borderColor}set borderColor(e){e=Xi(Ji(e),0,16777215,0),e!==this._$borderColor&&(this._$borderColor=e,X(this))}get stopIndex(){return this._$stopIndex}set stopIndex(e){e|=0,this._$stopIndex!==e&&(this._$stopIndex=e,Pa(this,e))}get defaultTextFormat(){return this._$defaultTextFormat.clone()}set defaultTextFormat(e){this._$rawHtmlText=``,this._$isHTML?this._$text=``:this._$htmlText=``,this._$defaultTextFormat=e,Na(this)}get focus(){return this._$focus}set focus(e){this._$focus!==e&&this.type===`input`&&(this._$focus=!!e,za(this,this._$focus?ue.FOCUS_IN:ue.FOCUS_OUT))}get htmlText(){return this._$htmlText||=`<span style="${ra(this.defaultTextFormat)}">${this._$text.replace(/\n/g,`<br>`)}</span>`,this._$htmlText}set htmlText(e){this._$htmlText!==e&&(this._$htmlText=`${e}`,this._$rawHtmlText=``,this._$text=``,this._$isHTML=!0,Na(this),this.hasEventListener(w.CHANGE)&&this.dispatchEvent(new w(w.CHANGE)))}get length(){return this.text.length}get multiline(){return this._$multiline}set multiline(e){e!==this._$multiline&&(this._$multiline=!!e,Na(this))}get numLines(){return Y(this).lineTable.length}get scrollX(){return this.$scrollX}set scrollX(e){Do(this,e)}get scrollY(){return this.$scrollY}set scrollY(e){Oo(this,e)}get text(){return this._$isHTML?(this._$rawHtmlText||=ko(this),this._$rawHtmlText):this._$text}set text(e){e=`${e}`,e===``&&(this.scrollX&&=0,this.scrollY&&=0),e!==this._$text&&(this._$htmlText=``,this._$rawHtmlText=``,this._$isHTML=!1,this._$text=e,Na(this),this.hasEventListener(w.CHANGE)&&this.dispatchEvent(new w(w.CHANGE)))}get textHeight(){return Y(this).textHeight}get textWidth(){return Y(this).textWidth}get thickness(){return this._$thickness}set thickness(e){e|=0,e!==this._$thickness&&(this._$thickness=e,X(this))}get thicknessColor(){return this._$thicknessColor}set thicknessColor(e){e=Xi(Ji(e),0,16777215,0),e!==this._$thicknessColor&&(this._$thicknessColor=e,X(this))}get wordWrap(){return this._$wordWrap}set wordWrap(e){this._$wordWrap!==e&&(this._$wordWrap=!!e,Na(this))}get width(){return super.width}set width(e){if(e=+e,!isNaN(e)&&0>e)return;let t=e+this.bounds.xMin;t!==this.bounds.xMax&&(this.bounds.xMax=t,Na(this))}get height(){return super.height}set height(e){if(e=+e,!isNaN(e)&&0>e)return;let t=e+this.bounds.yMin;t!==this.bounds.yMax&&(this.bounds.yMax=t,Na(this))}appendText(e){this.text+=`${e}`}insertText(e){Fo(this,e)}deleteText(){Po(this)}getLineText(e){return this._$text||this._$htmlText?Ao(this,e|0):``}replaceText(e,t,n){jo(this,e,t|0,n|0)}selectAll(){Uo(this)}copy(){Mo(this)}paste(){No(this)}setFocusIndex(e,t,n=!1){Lo(this,e,t,n)}keyDown(e){Ho(this,e)}$sync(e,t=null){t&&super.$syncLoaderInfo(t),Wo(this,e)}},Ko=e=>{e.compositionStartIndex=e.focusIndex},qo=()=>{let e=zi();e&&Ko(e)},Jo=(e,t)=>{if(e.compositionEndIndex>-1){let t=e.compositionStartIndex;e.focusIndex=e.compositionStartIndex,e.selectIndex=e.compositionEndIndex-1,e.compositionStartIndex=-1,Po(e),e.compositionStartIndex=t,e.selectIndex=-1}let n=Y(e),r=[],i=t.length,a=``;if(2>n.textTable.length)a=t,e.focusIndex=1,e.compositionStartIndex=1;else{for(let o=1;o<n.textTable.length;++o){let s=n.textTable[o];if(s){if(e.compositionStartIndex===o)for(let e=0;e<i;++e)r.push(new ta(...Object.values(s.textFormat))),a+=t[e];switch(s.mode){case`break`:r.push(new ta(...Object.values(s.textFormat))),a+=`
|
|
7
|
+
`;break;case`text`:r.push(new ta(...Object.values(s.textFormat))),a+=s.text;break;default:continue}}}if(e.compositionStartIndex===n.textTable.length){let o=n.textTable[e.compositionStartIndex-1];if(!o)return;for(let e=0;e<i;++e)r.push(new ta(...Object.values(o.textFormat))),a+=t[e]}}r.length&&(e.$textFormats=r),e.text=a,e.$textFormats=null,n=Y(e);let o=e.compositionStartIndex+i;for(let t=e.compositionStartIndex;t<o;++t){let r=n.textTable[t];if(!r)break;if(r.textFormat.underline=!0,r.mode===`wrap`){if(t===e.compositionStartIndex){let e=1;for(;;){let r=n.textTable[t-e];if(!r)break;if(r.mode===`text`){r.textFormat.underline=!0;break}e++}}t>e.compositionStartIndex&&o++}}e.compositionEndIndex=e.focusIndex=o},Yo=e=>{let t=zi();t&&Jo(t,e.data)},Xo=e=>{if(e.compositionEndIndex>-1){let t=Y(e);for(let n=e.compositionStartIndex;n<e.compositionEndIndex;++n){let e=t.textTable[n];e&&(e.textFormat.underline=!1)}e.focusIndex=e.compositionEndIndex}Bi.blur(),Bi.value=``,e.focus&&Bi.focus(),e.selectIndex=-1,e.compositionStartIndex=-1,e.compositionEndIndex=-1},Zo=()=>{let e=zi();e&&Xo(e)},Qo=e=>{if(!e.data)return;let t=zi();t&&(Fo(t,e.data),t.hasEventListener(w.INPUT)&&t.dispatchEvent(new w(w.INPUT)))};(e=>{e.addEventListener(`compositionstart`,qo),e.addEventListener(`compositionupdate`,Yo),e.addEventListener(`compositionend`,Zo),e.addEventListener(`input`,Qo)})(Bi);var $o=[],es=()=>$o,ts=e=>{$o.push(e)},ns=null,rs=()=>!!ns,is=()=>{ns||=new AudioContext,ns.resume()},as=()=>(ns||=new AudioContext,ns),os=e=>{let t=null;switch(e.method.toUpperCase()){case`GET`:if(e.data){let t=e.url.split(`?`);t[1]=t.length===1?e.data.toString():`${t[1]}&${e.data.toString()}`,e.url=t.join(`?`)}break;case`PUT`:case`POST`:e.data&&(t=e.data.toString());break;default:break}let n=new XMLHttpRequest;if(n.open(e.method,e.url,!0),n.responseType=e.format,n.withCredentials=e.withCredentials,e.event){let t=Object.keys(e.event);for(let r=0;r<t.length;++r){let i=t[r];n.addEventListener(i,e.event[i])}}for(let t=0;t<e.headers.length;++t){let r=e.headers[t];r&&n.setRequestHeader(r.name,r.value)}n.send(t)},ss=(e,t,n,r=null)=>{let i=+e;return isNaN(i)&&r!==null?r:Math.min(Math.max(t,isNaN(i)?0:i),n)},cs=1,ls=()=>cs,us=e=>{cs=ss(e,0,1,1)},ds=[],fs=()=>ds,ps=[],ms=()=>ps,hs=e=>{us(e);let t=fs();for(let n=0;n<t.length;++n){let r=t[n];r&&(r.volume=e)}let n=ms();for(let t=0;t<n.length;++t){let r=n[t];r&&(r.volume=e)}},gs=()=>{let e=fs();for(let t=0;t<e.length;++t){let n=e[t];n&&n.stop()}let t=ms();for(let e=0;e<t.length;++e){let n=t[e];n&&n.pause()}e.length=0,t.length=0},_s=class{static get volume(){return ls()}static set volume(e){hs(e)}static stopAll(){gs()}},vs=e=>{e.canLoop?e.play():(e.stop(),e.willTrigger(w.COMPLETE)&&e.dispatchEvent(new w(w.COMPLETE)))},ys=(e,t)=>{e.willTrigger(w.OPEN)&&e.dispatchEvent(new w(w.OPEN)),e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total))},bs=(e,t)=>{e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total))},xs=async e=>{if(e.byteLength)try{return await as().decodeAudioData(e)}catch{let t=new Uint8Array(e),n=0;for(;n>t.byteLength&&(n=t.indexOf(255,n),!(n===-1||(t[n+1]&224)==224));)++n;return await xs(t.subarray(n).buffer)}},Ss=async(e,t)=>{let n=t.target;if(n)if(e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total)),199<n.status&&400>n.status){let t=await xs(n.response);t&&(e.audioBuffer=t,e.willTrigger(w.COMPLETE)&&e.dispatchEvent(new w(w.COMPLETE)))}else e.willTrigger(fe.IO_ERROR)&&e.dispatchEvent(new fe(fe.IO_ERROR,!1,n.statusText))},Cs=async(e,t)=>{await new Promise(n=>{os({format:`arraybuffer`,url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:t=>{ys(e,t)},progress:t=>{bs(e,t)},loadend:async t=>{await Ss(e,t),n()}}})})},ws=async(e,t)=>{if(!t.audioBuffer){let e=await xs(new Uint8Array(t.buffer).buffer);if(!e)return;t.audioBuffer=e}e.audioBuffer=t.audioBuffer},Ts=class e extends le{_$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(e){this._$volume=ss(Math.min(_s.volume,e),0,1,1),this._$gainNode&&(this._$gainNode.gain.value=this._$volume)}get canLoop(){return!this._$stopFlag&&this.loopCount>=this._$currentCount}clone(){let t=new e;return t.volume=this._$volume,t.loopCount=this.loopCount,t.audioBuffer=this.audioBuffer,t}async load(e){await Cs(this,e)}play(e=0){if(!this._$stopFlag||!this.audioBuffer)return;this.stop();let t=as();this._$gainNode=t.createGain(),this._$gainNode.connect(t.destination),this._$gainNode.gain.value=Math.min(_s.volume,this._$volume),this._$source=t.createBufferSource(),this._$source.addEventListener(`ended`,()=>{vs(this)}),this._$source.buffer=this.audioBuffer,this._$source.connect(this._$gainNode),this._$source.start(e),this._$stopFlag=!1,this._$currentCount++,fs().push(this)}stop(){if(this._$stopFlag)return;this._$stopFlag=!0,this._$currentCount=0,this._$source&&=(this._$source.disconnect(),null),this._$gainNode&&=(this._$gainNode.gain.value=0,this._$gainNode.disconnect(),null);let e=fs(),t=e.indexOf(this);t>-1&&e.splice(t,1)}async $build(e){await ws(this,e)}},Es=class{volume;loopCount;constructor(e=1,t=0){this.volume=e,this.loopCount=t}},Ds=()=>{let e=document.createElement(`video`);return e.autoplay=!1,e.crossOrigin=`anonymous`,e.setAttribute(`playsinline`,``),e},Os=e=>{e.changed=!0;let t=e.parent;t&&!t.changed&&Os(t)},ks=async e=>{e.autoPlay&&(rs()||(e.muted=!0,ts(e)),await e.play()),e.loaded=!0,Os(e),e.willTrigger(w.COMPLETE)&&e.dispatchEvent(new w(w.COMPLETE))},As=(e,t)=>{t.currentTime=0,t.duration=e.duration,t.videoWidth=e.videoWidth,t.videoHeight=e.videoHeight;let n=new OffscreenCanvas(t.videoWidth,t.videoHeight);t.$context=n.getContext(`2d`),t.$offscreenCanvas=n},js=(e,t)=>{e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total))},Ms=e=>{if(e.willTrigger(pe.ENDED)&&e.dispatchEvent(new pe(pe.ENDED)),e.loop){e.currentTime=0;return}e.ended=!0,e.changed=!1,e.pause()},Ns=(e,t)=>{e.addEventListener(`loadedmetadata`,()=>{As(e,t)},{once:!0}),e.addEventListener(`progress`,e=>{js(t,e)}),e.addEventListener(`canplaythrough`,async()=>{await ks(t),e.volume=t.volume},{once:!0}),e.addEventListener(`ended`,()=>{Ms(t)})},Ps=e=>{if(e.paused||!e.loaded)return 0;e.willTrigger(pe.PLAY)&&e.dispatchEvent(new pe(pe.PLAY)),Os(e);let t=ms();return t.indexOf(e)===-1&&t.push(e),requestAnimationFrame(()=>{Ps(e)})},Fs=(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`}))},Is=class extends ai{duration;smoothing;loop;autoPlay;currentTime;videoWidth;videoHeight;loaded;ended;isVideo;$videoElement;$offscreenCanvas;$context;paused;_$timerId;_$volume;_$src;constructor(e=0,t=0){super(),this.videoWidth=e,this.videoHeight=t,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(e){this._$src!==e&&(this.loaded=!1,this.currentTime=0,this.$videoElement=null,this.$offscreenCanvas=null,this.$context=null,this.$videoElement=Ds(),Ns(this.$videoElement,this),this._$src=this.$videoElement.src=e,this.$videoElement.load())}get muted(){return this.$videoElement?this.$videoElement.muted:!1}set muted(e){this.$videoElement&&(this.$videoElement.muted=e)}get volume(){return this._$volume}set volume(e){this._$volume=ss(Math.min(_s.volume,e),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(pe.PAUSE)&&this.dispatchEvent(new pe(pe.PAUSE));let e=ms(),t=e.indexOf(this);t>-1&&e.splice(t,1)}async play(){!this.$videoElement||!this.paused||(this.paused=!1,this.ended=!1,this.$videoElement.volume=this._$volume,await this.$videoElement.play(),this._$timerId=Ps(this))}seek(e){this.$videoElement&&(this.currentTime=this.$videoElement.currentTime=Math.min(this.duration,e),this.willTrigger(pe.SEEK)&&this.dispatchEvent(new pe(pe.SEEK)))}$sync(e,t=null){t&&super.$syncLoaderInfo(t),Fs(this,e)}},Ls=(e,t,n,r,i=-1)=>{let a=r.loaderInfo;if(!a)throw Error(`the loaderInfo or data is null.`);e.parent=r,Kt.set(e,r.root),Gt.set(e,a),e.dictionaryId=t,e.characterId=n.characterId,e.clipDepth=n.clipDepth,e.startFrame=n.startFrame,e.endFrame=n.endFrame,e.name=n.name||``,e.placeId=i},Rs=(e,t,n,r,i=-1)=>{switch(n.extends){case rc.namespace:{let a=new rc;return Ls(a,e,t,r,i),a.$sync(n),a}case Ii.namespace:{let a=new Ii;return Ls(a,e,t,r,i),a.$sync(n),a}case Go.namespace:{let a=new Go;return Ls(a,e,t,r,i),a.$sync(n),a}case Is.namespace:{let a=new Is;return Ls(a,e,t,r,i),a.$sync(n),a}default:throw Error(`Character extends not found: ${n.extends}`)}},zs=new Map,Bs=(e,t)=>{let n=e.loaderInfo;if(!n||!n.data)return t;let r=n.data.characters[e.characterId];if(!r)return t;let i=e.currentFrame,a=r.controller[i];if(!a)return t;let o=[],s=r.dictionary;if(!t.length){for(let r=0;r<a.length;++r){if(!(r in a))continue;let i=a[r];if(typeof i!=`number`)continue;let c=s[i];if(!c)continue;let l=n.data.characters[c.characterId];if(!l)continue;let u=Rs(i,c,l,e,r);u&&(t.push(u),u.isContainerEnabled&&o.push(u))}return e.$container=o,t}for(let e=0;e<t.length;++e){let n=t[e];if(!n)continue;let r=n.startFrame,a=n.endFrame;if(r===1&&a===0||r<=i&&a>i){zs.set(n.dictionaryId,n);continue}n.uniqueKey&&M.has(n.uniqueKey)&&M.removeTimer(n.uniqueKey),n.willTrigger(w.REMOVED)&&n.dispatchEvent(new w(w.REMOVED,!0)),n.willTrigger(w.REMOVED_FROM_STAGE)&&n.dispatchEvent(new w(w.REMOVED_FROM_STAGE,!0)),n.isVideo&&n.pause(),n.isContainerEnabled&&mi(n)}t.length=0;for(let r=0;r<a.length;++r){if(!(r in a))continue;let i=a[r];if(typeof i!=`number`)continue;if(zs.has(i)){let e=zs.get(i);e.placeId=r,e.placeObject=null,t.push(e);continue}let c=s[i];if(!c)continue;let l=n.data.characters[c.characterId];if(!l)continue;let u=Rs(i,c,l,e,r);u&&(t.push(u),u.isContainerEnabled&&o.push(u))}return e.$container=o,zs.clear(),t},Vs=(e,t)=>{e.$labels||=new Map,e.$labels.set(t.frame,t)},Hs=e=>{if(!e.$labels)return null;let t=e.currentFrame;return e.$labels.has(t)&&e.$labels.get(t)||null},Us=e=>!e.$labels||!e.$labels.size?null:Array.from(e.$labels.values()),Ws=(e,t)=>{if(!e.$labels||!e.$labels.size)return 0;for(let[n,r]of e.$labels)if(r.name===t)return n;return 0},Gs=(e,t=null)=>{if(!t||!t.size)return;let n=e.currentFrame;if(!t.has(n))return;let r=t.get(n);r.willTrigger(w.FRAME_LABEL)&&r.dispatchEvent(new w(w.FRAME_LABEL))},Ks=(e,t=null)=>{if(!t||!t.size)return;let n=e.currentFrame;t.has(n)&&$t.push(e)},qs=e=>{e.$canAction&&(e.$canAction=!1,Gs(e,e.$labels),Ks(e,e.$actions))},Js=(e,t)=>{if(e.totalFrames===1)return;let n=+t;if(isNaN(n)&&(n=Ws(e,`${t}`)),1>n&&(n=1),e.currentFrame!==n){if(n>e.totalFrames){if(e.currentFrame===e.totalFrames)return;e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,e.currentFrame=e.totalFrames,qs(e),I(e);return}e.currentFrame=n,e.$wait=!0,e.$canSound=!0,e.$canAction=!0,e.$hasTimelineHeadMoved=!0,I(e),qs(e)}},Ys=(e,t)=>{e.play(),Js(e,t)},Xs=(e,t)=>{e.stop(),Js(e,t),e.$wait=!1},Zs=e=>{e.totalFrames<=e.currentFrame||(e.stop(),Js(e,e.currentFrame+1))},Qs=e=>{2>e.currentFrame||(e.stop(),Js(e,e.currentFrame-1))},$s=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];if(!r)continue;r.script||=Function(r.action);let i=r.frame;e.has(i)||e.set(i,R()),e.get(i)?.push(r.script)}},ec=(e,t)=>{for(let n=0;n<t.length;++n){let r=t[n];r&&e.set(r.frame,new Ei(r.name,r.frame))}},tc=async(e,t,n)=>{let r=e.loaderInfo;if(!r)return;let i=r.data;if(!i)return;let a=i.characters;for(let e=0;e<n.length;++e){let r=n[e];if(!r)continue;let i=R();for(let e=0;e<r.sound.length;++e){let t=r.sound[e];if(!t)continue;let n=a[t.characterId];if(!n)continue;let o=new Ts;o.loopCount=t.loopCount|0,o.volume=Math.min(_s.volume,t.volume),await o.$build(n),i.push(o)}t.set(r.frame,i)}},nc=(e,t)=>{t.actions&&(e.$actions||=new Map,$s(e.$actions,t.actions)),t.sounds&&(e.$sounds||=new Map,tc(e,e.$sounds,t.sounds)),t.labels&&(e.$labels||=new Map,ec(e.$labels,t.labels)),e.totalFrames=t.totalFrame||1},rc=class extends Ai{$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,Bs(this,this._$children))}get currentFrameLabel(){return Hs(this)}get currentLabels(){return Us(this)}get isPlaying(){return!this._$stopFlag}gotoAndPlay(e){Ys(this,e)}gotoAndStop(e){Xs(this,e)}nextFrame(){Zs(this)}play(){this._$stopFlag=!1,I(this)}prevFrame(){Qs(this)}stop(){this._$stopFlag=!0}addFrameLabel(e){Vs(this,e)}$sync(e,t=null){t&&super.$syncLoaderInfo(t),nc(this,e)}},ic=async(e,t)=>{let n=new Map;if(t.symbols.length)for(let e=0;e<t.symbols.length;++e){let r=t.symbols[e];n.set(r[0],r[1])}let r=e.contentLoaderInfo;r.data={stage:t.stage,characters:t.characters,symbols:n};let i=new rc,a=t.characters[0];Ls(i,-1,{characterId:0,name:`main`,clipDepth:0,depth:0,endFrame:a.controller.length,startFrame:1},e),i.$sync(a,r),i.parent=null,r.content=i,r.willTrigger(w.COMPLETE)&&r.dispatchEvent(new w(w.COMPLETE))},ac='"use strict";(function(){let e=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258]),t=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),n=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577]),r=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),i=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),a=new Uint32Array(17);for(let e=1;e<17;e++)a[e]=(1<<e)-1;let o=new Uint8Array(288);for(let e=0;e<=143;e++)o[e]=8;for(let e=144;e<=255;e++)o[e]=9;for(let e=256;e<=279;e++)o[e]=7;for(let e=280;e<=287;e++)o[e]=8;let s=new Uint8Array(32).fill(5),c=new TextDecoder,l=new Uint8Array(65536),u=new Uint16Array(16),d=new Uint16Array(16),f=new Uint8Array(19),p=new Uint8Array(320),m=new Uint32Array(128),h=new Uint32Array(2048),g=new Uint32Array(1024),_=(e,t,n)=>{let r=0;u.fill(0);for(let n=0;n<t;n++){let t=e[n];t&&(u[t]++,t>r&&(r=t))}if(!r)return n?(n[0]=0,[n,1]):[new Uint32Array(2),1];d.fill(0);for(let e=1,t=0;e<=r;e++)t=t+u[e-1]<<1,d[e]=t;let i=1<<r,a;n&&n.length>=i?(a=n,a.fill(0,0,i)):a=new Uint32Array(i);for(let n=0;n<t;n++){let t=e[n];if(!t)continue;let r=d[t]++,o=0;for(let e=0;e<t;e++)o=o<<1|r&1,r>>=1;let s=n<<4|t;for(let e=o;e<i;e+=1<<t)a[e]=s}return[a,r]},[v,y]=_(o,288),[b,x]=_(s,32),S=a[y],C=a[x],w,T,E,D,O=e=>{for(;D<e;)E|=w[T++]<<D,D+=8;let t=E&a[e];return E>>>=e,D-=e,t},k=(e,t,n)=>{for(;D<t;)E|=w[T++]<<D,D+=8;let r=e[E&n];return E>>>=r&15,D-=r&15,r>>4},A=(o,s)=>{w=o,T=s,E=0,D=0;let c=Math.max(o.length*6,4096);l.length<c&&(l=new Uint8Array(c));let u=l,d=0,A=0;for(;!A;){A=O(1);let o=O(2);if(o===0){let e=D&7;E>>>=e,D-=e;let t=O(16);if(O(16),d+t>u.length){let e=u.length;for(;e<d+t;)e<<=1;let n=new Uint8Array(e);n.set(u),u=n}u.set(w.subarray(T,T+t),d),T+=t,d+=t}else if(o===3)throw Error(`Invalid DEFLATE block type`);else{let s,c,l,A,j,M;if(o===1)s=v,l=y,c=S,A=b,M=x,j=C;else{let e=O(5)+257,t=O(5)+1,n=O(4)+4;f.fill(0);for(let e=0;e<n;e++)f[i[e]]=O(3);let r;[m,r]=_(f,19,m);let o=a[r],u=e+t;p.fill(0,0,u);for(let e=0;e<u;){let t=k(m,r,o);if(t<16)p[e++]=t;else if(t===16){let t=p[e-1];for(let n=O(2)+3;n>0;n--)p[e++]=t}else t===17?e+=O(3)+3:e+=O(7)+11}[h,l]=_(p.subarray(0,e),e,h),c=a[l],s=h,[g,M]=_(p.subarray(e,u),t,g),j=a[M],A=g}for(;;){for(;D<l;)E|=w[T++]<<D,D+=8;let i=s[E&c],o=i&15;E>>>=o,D-=o;let f=i>>4;if(f<256){if(d>=u.length){let e=new Uint8Array(u.length<<1);e.set(u),u=e}u[d++]=f}else if(f===256)break;else{let i=f-257,o=e[i],s=t[i];if(s){for(;D<s;)E|=w[T++]<<D,D+=8;o+=E&a[s],E>>>=s,D-=s}for(;D<M;)E|=w[T++]<<D,D+=8;let c=A[E&j],l=c&15;E>>>=l,D-=l;let p=c>>4,m=n[p],h=r[p];if(h){for(;D<h;)E|=w[T++]<<D,D+=8;m+=E&a[h],E>>>=h,D-=h}if(d+o>u.length){let e=u.length;for(;e<d+o;)e<<=1;let t=new Uint8Array(e);t.set(u),u=t}let g=d-m;if(m===1)u.fill(u[g],d,d+o),d+=o;else if(m>=o)u.copyWithin(d,g,g+o),d+=o;else{u.copyWithin(d,g,g+m);let e=m;for(;e<o;){let t=Math.min(e,o-e);u.copyWithin(d+e,d,d+t),e+=t}d+=o}}}}}return l=u,u.subarray(0,d)},j=e=>{let t=e[0],n=e[1];return A(e,(t&15)==8&&(t*256+n)%31==0&&!(n&32)?2:0)};self.addEventListener(`message`,e=>{try{let t=j(e.data);self.postMessage(JSON.parse(decodeURIComponent(c.decode(t))))}catch(e){self.postMessage({error:e instanceof Error?e.message:`Unknown decompression error`})}})})();',oc=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,ac],{type:`text/javascript;charset=utf-8`});function sc(e){let t;try{if(t=oc&&(self.URL||self.webkitURL).createObjectURL(oc),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(ac),{name:e?.name})}}var cc=new sc,lc=async(e,t)=>{t.type===`zlib`?await new Promise((n,r)=>{cc.onmessage=t=>{if(t.data&&t.data.error){r(Error(t.data.error));return}ic(e,t.data),n()},cc.onerror=e=>{r(Error(e.message))};let i=new Uint8Array(t.buffer);cc.postMessage(i,[i.buffer])}):ic(e,t)},uc=(e,t)=>{e.willTrigger(w.OPEN)&&e.dispatchEvent(new w(w.OPEN)),e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total))},dc=(e,t)=>{e.willTrigger(j.PROGRESS)&&e.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total))},fc=async(e,t)=>{let n=t.target;if(!n)return;let r=e.contentLoaderInfo;if(r.willTrigger(j.PROGRESS)&&r.dispatchEvent(new j(j.PROGRESS,!1,t.loaded,t.total)),r.willTrigger(de.HTTP_STATUS)){let e=Wt(n.getAllResponseHeaders());r.dispatchEvent(new de(de.HTTP_STATUS,!1,n.status,n.responseURL,e))}199<n.status&&400>n.status?(await lc(e,n.response),r.willTrigger(w.COMPLETE)&&r.dispatchEvent(new w(w.COMPLETE))):r.willTrigger(fe.IO_ERROR)&&r.dispatchEvent(new fe(fe.IO_ERROR,!1,n.statusText))},pc=async(e,t)=>{await new Promise(n=>{Ut({format:t.responseDataFormat,url:t.url,method:t.method,data:t.data,headers:t.headers,withCredentials:t.withCredentials,event:{loadstart:t=>{uc(e.contentLoaderInfo,t)},progress:t=>{dc(e.contentLoaderInfo,t)},loadend:async t=>{await fc(e,t),n()}}})})},mc=class{contentLoaderInfo;root;constructor(){this.root=null,this.contentLoaderInfo=new Di}get content(){return this.contentLoaderInfo.content}get loaderInfo(){return this.contentLoaderInfo}async load(e){if(e.responseDataFormat!==`json`)throw Error("The only format that can be loaded by this function is `json` format.");this.contentLoaderInfo.url=e.url,this.contentLoaderInfo.format=e.responseDataFormat,await pc(this,e)}async loadJSON(e){await lc(this,e)}},hc=()=>{for(;$t.length;){let e=$t.pop(),t=e.$actions;if(!t)continue;let n=e.currentFrame;if(!t.has(n))continue;let r=t.get(n);if(r)for(let t=0;t<r.length;t++)try{r[t].apply(e)}catch(e){console.error(e)}}},gc=()=>{for(;en.length;){let e=en.pop(),t=e.$sounds;if(!t)continue;let n=e.currentFrame;if(!t.has(n))continue;let r=t.get(n),i=e.soundTransform;for(let e=0;e<r.length;e++){let t=r[e];t&&(i&&(t.volume=i.volume,t.loopCount=i.loopCount),t.play())}}},_c=(e,t=null)=>{if(!t||!t.size)return;let n=e.currentFrame;t.has(n)&&en.push(e)},vc=e=>{e.$canSound&&(e.$canSound=!1,_c(e,e.$sounds))},yc=e=>{let t=e.children;for(let e=t.length-1;e>-1;--e){let n=t[e];n&&n.isContainerEnabled&&(yc(n),n.isTimelineEnabled&&(vc(n),qs(n)))}},bc=e=>{yc(e),gc(),hc()},xc=e=>(e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e),Z=new class{buffer;offset;constructor(){this.buffer=new Float32Array(256),this.offset=0}push(...e){this.buffer.length<this.offset+e.length&&this.resize(e.length);for(let t=0;t<e.length;t++)this.buffer[this.offset++]=e[t]}pushDisplayObjectBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){this.buffer.length<this.offset+22&&this.resize(22),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x}pushInstanceBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C){this.buffer.length<this.offset+24&&this.resize(24),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C}pushShapeBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,ee,te,O,ne){this.buffer.length<this.offset+32&&this.resize(32),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E,this.buffer[this.offset++]=D,this.buffer[this.offset++]=ee,this.buffer[this.offset++]=te,this.buffer[this.offset++]=O,this.buffer[this.offset++]=ne}pushTextFieldBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,ee,te){this.buffer.length<this.offset+30&&this.resize(30),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E,this.buffer[this.offset++]=D,this.buffer[this.offset++]=ee,this.buffer[this.offset++]=te}pushVideoBuffer(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E){this.buffer.length<this.offset+27&&this.resize(27),this.buffer[this.offset++]=e,this.buffer[this.offset++]=t,this.buffer[this.offset++]=n,this.buffer[this.offset++]=r,this.buffer[this.offset++]=i,this.buffer[this.offset++]=a,this.buffer[this.offset++]=o,this.buffer[this.offset++]=s,this.buffer[this.offset++]=c,this.buffer[this.offset++]=l,this.buffer[this.offset++]=u,this.buffer[this.offset++]=d,this.buffer[this.offset++]=f,this.buffer[this.offset++]=p,this.buffer[this.offset++]=m,this.buffer[this.offset++]=h,this.buffer[this.offset++]=g,this.buffer[this.offset++]=_,this.buffer[this.offset++]=v,this.buffer[this.offset++]=y,this.buffer[this.offset++]=b,this.buffer[this.offset++]=x,this.buffer[this.offset++]=S,this.buffer[this.offset++]=C,this.buffer[this.offset++]=w,this.buffer[this.offset++]=T,this.buffer[this.offset++]=E}set(e){this.buffer.length<this.offset+e.length&&this.resize(e.length),this.buffer.set(e,this.offset),this.offset+=e.length}resize(e){let t=new Float32Array(xc(this.offset+e));this.buffer.length&&t.set(this.buffer),this.buffer=t}},Sc=e=>{let t=new Uint32Array(e.buffer,e.byteOffset,e.length),n=t.length,r=2166136261,i=0,a=n&-8;for(;i<a;){let e=t[i++];r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619),e=t[i++],r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619)}for(;i<n;){let e=t[i++];r=Math.imul(r^e&255,16777619),r=Math.imul(r^e>>8&255,16777619),r=Math.imul(r^e>>16&255,16777619),r=Math.imul(r^e>>>24,16777619)}return r>>>8^r&255},Cc=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}},wc=(e,t,n,r,i)=>{if(!e.visible){Z.push(0);return}let a=e.graphics,o=a.isDrawable;if(!o&&!e.isBitmap){Z.push(0);return}let s=sn(e),c=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)?N.multiply(n,s):n;if(!Qt(c[3]+c[7]/255,0,1,0)){c!==n&&N.release(c),Z.push(0);return}let l=H(e),u=l&&(l[0]!==1||l[1]!==0||l[2]!==0||l[3]!==1||l[4]!==0||l[5]!==0)?F.multiply(t,l):t,d=W(a.xMin,a.yMin,a.xMax,a.yMax,u),f=d[0],p=d[1],m=d[2],h=d[3];V(d);let g=Math.ceil(Math.abs(m-f)),_=Math.ceil(Math.abs(h-p));switch(!0){case g===0:case _===0:case g===-1/0:case _===-1/0:case g===1/0:case _===1/0:c!==n&&N.release(c),u!==t&&F.release(u),Z.push(0);return;default:break}if(0>f+g||0>p+_||f>r||p>i){c!==n&&N.release(c),u!==t&&F.release(u),Z.push(0);return}let v=l&&e.scale9Grid?Math.abs(l[1])<.001&&Math.abs(l[2])<1e-4:!1;if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){let t=R(e.loaderInfo.id,e.characterId);e.uniqueKey=`${Sc(new Float32Array(t))}`,z(t)}else e.uniqueKey=e.isBitmap?`${Sc(new Float32Array(e.$bitmapBuffer.buffer))}`:`${Sc(a.buffer)}`;let y=e.cacheAsBitmap,b,x,S=1,C=1;if(y){let e=y.rawData;S=Math.sqrt(e[0]*e[0]+e[1]*e[1]),C=Math.sqrt(e[2]*e[2]+e[3]*e[3]);let t=l?Math.sqrt(l[0]*l[0]+l[1]*l[1]):1,n=l?Math.sqrt(l[2]*l[2]+l[3]*l[3]):1;if(b=S*t*Q.rendererScale,x=C*n*Q.rendererScale,S!==1||C!==1){let e=L(u[0]*S,u[1]*S,u[2]*C,u[3]*C,u[4],u[5]),t=W(a.xMin,a.yMin,a.xMax,a.yMax,e);f=t[0],p=t[1],m=t[2],h=t[3],V(t),Rt(e)}}else b=Math.sqrt(u[0]*u[0]+u[1]*u[1]),x=Math.sqrt(u[2]*u[2]+u[3]*u[3]);let w=Math.round(b*100)/100,T=Math.round(x*100)/100;y&&e.cacheKey&&e.cacheParams[0]===w&&e.cacheParams[1]===T||(!e.isBitmap&&!e.cacheKey||e.cacheParams[0]!==w||e.cacheParams[1]!==T||e.cacheParams[2]!==c[7])&&(e.cacheKey=M.generateKeys(w,T,c[7]),e.cacheParams[0]=w,e.cacheParams[1]=T,e.cacheParams[2]=c[7]);let E=e.isBitmap?0:e.cacheKey;if(Z.pushShapeBuffer(1,1,u[0]*S,u[1]*S,u[2]*C,u[3]*C,u[4],u[5],c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],f,p,m,h,a.xMin,a.yMin,a.xMax,a.yMax,+v,+o,e.isBitmap?1:y?2:0,+e.uniqueKey,E,b,x,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null),e.$cache?e.$cache.get(`${E}`):M.get(e.uniqueKey,`${E}`))e.$cache||(e.$cache=M.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),Z.push(1);else{if(Z.push(0),v){let t=Q.rendererScale,n=L(t,0,0,t,0,0),r=F.multiply(n,l||jt);Rt(n);let i=e.parent.concatenatedMatrix.rawData,o=L(i[0],i[1],i[2],i[3],i[4]*t-f,i[5]*t-p);F.release(i);let s=F.multiply(o,r),c=s[4]-(u[4]-f),d=s[5]-(u[5]-p);Rt(s);let m=W(a.xMin,a.yMin,a.xMax,a.yMax,r),h=m[0],g=m[1],_=m[2],v=m[3];V(m);let y=Math.ceil(Math.abs(_-h)),b=Math.ceil(Math.abs(v-g)),x=e.scale9Grid,S=Math.abs(a.xMax-a.xMin),C=Math.abs(a.yMax-a.yMin),w=x.width>0?(x.x-a.xMin)/S:1e-5,T=x.height>0?(x.y-a.yMin)/C:1e-5,E=x.width>0?(x.x+x.width-a.xMin)/S:.99999,D=x.height>0?(x.y+x.height-a.yMin)/C:.99999,ee=Math.ceil(S*t),te=Math.ceil(C*t),O=ee*w/y,ne=te*T/b,k=(y-ee*(1-E))/y,re=(b-te*(1-D))/b;if(O>=k){let e=w/(w+(1-E));O=Math.max(e-1e-5,0),k=Math.min(e+1e-5,1)}if(ne>=re){let e=T/(T+(1-D));ne=Math.max(e-1e-5,0),re=Math.min(e+1e-5,1)}Z.push(r[0],r[1],r[2],r[3],r[4],r[5],o[0],o[1],o[2],o[3],o[4]-c,o[5]-d,h,g,y,b,w,T,O,ne,E,D,k,re),Rt(o),Rt(r)}let t=o||v?a.buffer:e.$bitmapBuffer;Z.push(t.length),Z.set(t),M.set(e.uniqueKey,`${E}`,!0),e.$cache&&=null}Z.push(Cc(e.blendMode));let D=e.filters;if(D){let e=!1,t=[],n=B(0,0,0,0);for(let r=0;r<D.length;r++){let i=D[r];if(!i||!i.canApplyFilter())continue;i.$updated&&(e=!0),i.$updated=!1,i.getBounds(n);let a=i.toNumberArray();for(let e=0;e<a.length;e+=4096)t.push(...a.subarray(e,e+4096))}let r=t.length>0;r?(Z.push(+r,+e,n[0],n[1],n[2],n[3],t.length),Z.set(new Float32Array(t))):Z.push(0),V(n)}else Z.push(0);c!==n&&N.release(c),u!==t&&F.release(u)},Tc=(e,t)=>{let n=H(e),r=n?F.multiply(t,n):t;r!==t&&F.release(r);let i=n&&e.scale9Grid?Math.abs(n[1])<.001&&Math.abs(n[2])<1e-4:!1,a=e.graphics.buffer;Z.push(1,r[0],r[1],r[2],r[3],r[4],r[5],+i,a.length),Z.set(a)},Ec=new TextEncoder,Dc=(e,t,n,r,i)=>{if(!e.visible){Z.push(0);return}let a=sn(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)?N.multiply(n,a):n;if(!Qt(o[3]+o[7]/255,0,1,0)){o!==n&&N.release(o),Z.push(0);return}let s=H(e),c=s&&(s[0]!==1||s[1]!==0||s[2]!==0||s[3]!==1||s[4]!==0||s[5]!==0)?F.multiply(t,s):t,l=W(e.xMin,e.yMin,e.xMax,e.yMax,c),u=l[0],d=l[1],f=l[2],p=l[3];V(l);let m=Math.ceil(Math.abs(f-u)),h=Math.ceil(Math.abs(p-d));switch(!0){case m===0:case h===0:case m===-1/0:case h===-1/0:case m===1/0:case h===1/0:o!==n&&N.release(o),c!==t&&F.release(c),Z.push(0);return;default:break}if(0>u+m||0>d+h||u>r||d>i){o!==n&&N.release(o),c!==t&&F.release(c),Z.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){let t=R(e.loaderInfo.id,e.characterId);e.uniqueKey=`${Sc(new Float32Array(t))}`,z(t)}else e.uniqueKey=`${e.instanceId}`;let g=e.cacheAsBitmap,_,v,y=1,b=1;if(g){let t=g.rawData;y=Math.sqrt(t[0]*t[0]+t[1]*t[1]),b=Math.sqrt(t[2]*t[2]+t[3]*t[3]);let n=s?Math.sqrt(s[0]*s[0]+s[1]*s[1]):1,r=s?Math.sqrt(s[2]*s[2]+s[3]*s[3]):1;if(_=y*n*Q.rendererScale,v=b*r*Q.rendererScale,y!==1||b!==1){let t=L(c[0]*y,c[1]*y,c[2]*b,c[3]*b,c[4],c[5]),n=W(e.xMin,e.yMin,e.xMax,e.yMax,t);u=n[0],d=n[1],f=n[2],p=n[3],V(n),Rt(t)}}else _=Math.sqrt(c[0]*c[0]+c[1]*c[1]),v=Math.sqrt(c[2]*c[2]+c[3]*c[3]);let x=Math.round(_*100)/100,S=Math.round(v*100)/100;g&&e.cacheKey&&e.cacheParams[0]===x&&e.cacheParams[1]===S||(e.changed&&!e.cacheKey||e.cacheParams[0]!==x||e.cacheParams[1]!==S||e.cacheParams[2]!==o[7])&&(e.cacheKey=M.generateKeys(x,S,o[7]),e.cacheParams[0]=x,e.cacheParams[1]=S,e.cacheParams[2]=o[7]);let C=e.cacheKey;Z.pushTextFieldBuffer(1,2,c[0]*y,c[1]*y,c[2]*b,c[3]*b,c[4],c[5],o[0],o[1],o[2],o[3],o[4],o[5],o[6],o[7],u,d,f,p,e.xMin,e.yMin,e.xMax,e.yMax,+e.uniqueKey,C,e.changed|(g?2:0),_,v,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);let w=e.$cache?e.$cache.get(`${C}`):M.get(e.uniqueKey,`${C}`);if(!w||e.changed){Z.push(0,+w);let t=Ec.encode(JSON.stringify(e.$textData));switch(Z.push(t.length),Z.set(t),e.autoSize){case`center`:Z.push(0);break;case`left`:Z.push(1);break;case`none`:Z.push(2);break;case`right`:Z.push(3);break}Z.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||M.set(e.uniqueKey,`${C}`,!0),e.$cache&&=null}else e.$cache||(e.$cache=M.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),Z.push(1);if(Z.push(Cc(e.blendMode)),e.filters?.length){let t=!1,n=[],r=B(0,0,0,0);for(let i=0;i<e.filters.length;i++){let a=e.filters[i];if(!a||!a.canApplyFilter())continue;a.$updated&&(t=!0),a.$updated=!1,a.getBounds(r);let o=a.toNumberArray();for(let e=0;e<o.length;e+=4096)n.push(...o.subarray(e,e+4096))}let i=n.length>0;i?(Z.push(+i,+t,r[0],r[1],r[2],r[3],n.length),Z.set(new Float32Array(n))):Z.push(0),V(r)}else Z.push(0);o!==n&&N.release(o),c!==t&&F.release(c)},Oc=(e,t,n,r,i,a)=>{if(!e.visible||!e.$videoElement||!e.$offscreenCanvas||!e.loaded){Z.push(0);return}let o=sn(e),s=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)?N.multiply(r,o):r;if(!Qt(s[3]+s[7]/255,0,1,0)){s!==r&&N.release(s),Z.push(0);return}let c=H(e),l=c&&(c[0]!==1||c[1]!==0||c[2]!==0||c[3]!==1||c[4]!==0||c[5]!==0)?F.multiply(n,c):n,u=W(0,0,e.videoWidth,e.videoHeight,l),d=u[0],f=u[1],p=u[2],m=u[3];V(u);let h=Math.ceil(Math.abs(p-d)),g=Math.ceil(Math.abs(m-f));switch(!0){case h===0:case g===0:case h===-1/0:case g===-1/0:case h===1/0:case g===1/0:s!==r&&N.release(s),l!==n&&F.release(l),Z.push(0);return;default:break}if(0>d+h||0>f+g||d>i||f>a){s!==r&&N.release(s),l!==n&&F.release(l),Z.push(0);return}if(!e.uniqueKey)if(e.characterId&&e.loaderInfo){let t=R(e.loaderInfo.id,e.characterId);e.uniqueKey=`${Sc(new Float32Array(t))}`,z(t)}else e.uniqueKey=`${e.instanceId}`;Z.pushVideoBuffer(1,3,l[0],l[1],l[2],l[3],l[4],l[5],s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],d,f,p,m,0,0,e.videoWidth,e.videoHeight,+e.uniqueKey,+e.changed,e.instanceId),e.$cache&&!e.$cache.has(e.uniqueKey)&&(e.$cache=null);let _=e.$cache?e.$cache.get(`0`):M.get(e.uniqueKey,`0`);if(!_||e.changed){Z.push(0,+_);let n=e.$context;if(n){let r=e.videoWidth/2,i=e.videoHeight/2;n.save(),n.translate(r,i),n.rotate(Math.PI),n.scale(-1,1),n.drawImage(e.$videoElement,-r,-i,e.videoWidth,e.videoHeight),n.restore(),t.push(e.$offscreenCanvas.transferToImageBitmap())}_||M.set(e.uniqueKey,`0`,!0),e.$cache&&=null}else e.$cache||(e.$cache=M.getById(e.uniqueKey),e.$cache.set(e.uniqueKey,!0)),Z.push(1);if(Z.push(Cc(e.blendMode)),e.filters?.length){let t=!1,n=[],r=B(0,0,0,0);for(let i=0;i<e.filters.length;i++){let a=e.filters[i];if(!a||!a.canApplyFilter())continue;a.$updated&&(t=!0),a.$updated=!1,a.getBounds(r);let o=a.toNumberArray();for(let e=0;e<o.length;e+=4096)n.push(...o.subarray(e,e+4096))}let i=n.length>0;i?(Z.push(+i,+t,r[0],r[1],r[2],r[3],n.length),Z.set(new Float32Array(n))):Z.push(0),V(r)}else Z.push(0);s!==r&&N.release(s),l!==n&&F.release(l)},kc=(e,t,n,r)=>{let i=null;switch(!0){case e.isContainerEnabled:i=Dr(e,t);break;case e.isShape:i=Sr(e,t);break;case e.isText:i=Er(e,t);break;case e.isVideo:i=wr(e,t);break;default:break}if(!i)return null;let a=i[0],o=i[2],s=Math.abs(o-a);if(!s)return null;let c=i[1],l=i[3],u=Math.abs(l-c);return!u||0>a+s||0>c+u||a>n||c>r?null:i},Ac=(e,t)=>{let n=H(e),r=n?F.multiply(t,n):t,i=e.children;Z.push(0,i.length);for(let e=0;e<i.length;e++){let t=i[e];if(t&&!t.isMask)switch(!0){case t.isContainerEnabled:Ac(t,r);break;case t.isShape:Tc(t,r);break;default:break}}r!==t&&F.release(r)},jc=(e,t=null)=>{let n=Sr(e,t),r=e.filters;if(r){let e=B(0,0,0,0);for(let t=0;t<r.length;t++){let n=r[t];!n||!n.canApplyFilter()||n.getBounds(e)}n[0]+=e[0],n[1]+=e[1],n[2]+=e[2],n[3]+=e[3],V(e)}return n},Mc=(e,t=null)=>{let n=wr(e,t),r=e.filters;if(r){let e=B(0,0,0,0);for(let t=0;t<r.length;t++){let n=r[t];!n||!n.canApplyFilter()||n.getBounds(e)}n[0]+=e[0],n[1]+=e[1],n[2]+=e[2],n[3]+=e[3],V(e)}return n},Nc=(e,t=null)=>{let n=Er(e,t),r=e.filters;if(r){let e=B(0,0,0,0);for(let t=0;t<r.length;t++){let n=r[t];!n||!n.canApplyFilter()||n.getBounds(e)}n[0]+=e[0],n[1]+=e[1],n[2]+=e[2],n[3]+=e[3],V(e)}return n},Pc=(e,t=null)=>{let n=e.children;if(!n.length)return B(0,0,0,0);let r=H(e),i=r?t?F.multiply(t,r):r:t,a=Number.MAX_VALUE,o=a,s=-a,c=a,l=-a;for(let e=0;e<n.length;e++){let t=n[e];if(!t||!t.visible)continue;let r=null;switch(!0){case t.isContainerEnabled:r=Pc(t,i);break;case t.isShape:r=jc(t,i);break;case t.isText:r=Nc(t,i);break;case t.isVideo:r=Mc(t,i);break}r&&(o=Math.min(o,r[0]),c=Math.min(c,r[1]),s=Math.max(s,r[2]),l=Math.max(l,r[3]),V(r))}return B(o,c,s,l)},Fc=(e,t,n,r,i,a)=>{if(!e.visible){Z.push(0);return}let o=sn(e),s=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)?N.multiply(r,o):r;if(!Qt(s[3]+s[7]/255,0,1,0)){s!==r&&N.release(s),Z.push(0);return}let c=e.children;if(!c.length){s!==r&&N.release(s),Z.push(0);return}let l=H(e),u=l&&(l[0]!==1||l[1]!==0||l[2]!==0||l[3]!==1||l[4]!==0||l[5]!==0)?F.multiply(n,l):n;if(!u[0]&&!u[1]||!u[2]&&!u[3]){s!==r&&N.release(s),u!==n&&F.release(u),Z.push(0);return}Z.push(1,0);let d=e.blendMode;Z.push(Cc(d));let f=e.cacheAsBitmap;if(f){let t=f.rawData,i=Math.sqrt(t[0]*t[0]+t[1]*t[1]),a=Math.sqrt(t[2]*t[2]+t[3]*t[3]),o=l?Math.sqrt(l[0]*l[0]+l[1]*l[1]):1,c=l?Math.sqrt(l[2]*l[2]+l[3]*l[3]):1,d=Q.rendererScale,p=i*o*d,m=a*c*d,h=Math.round(p*100)/100,g=Math.round(m*100)/100,_=M.generateKeys(h,g,s[7]),v=M.get(`${e.instanceId}`,`bitmapKey`)===_,y=e.filters,b=B(0,0,0,0);if(y)for(let e=0;e<y.length;e++){let t=y[e];!t||!t.canApplyFilter()||t.getBounds(b)}if(v){let t=M.get(`${e.instanceId}`,`bLocalBounds`);if(t){let o=t[0]/(i*d),c=t[1]/(a*d),l=n[0]*o+n[2]*c+n[4],f=n[1]*o+n[3]*c+n[5];Z.push(1,0,0,2,1,e.instanceId,_,b[0],b[1],b[2],b[3],p,m,n[0]*i,n[1]*i,n[2]*a,n[3]*a,l,f,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7]),V(b),s!==r&&N.release(s),u!==n&&F.release(u);return}}let x=[];if(y)for(let e=0;e<y.length;e++){let t=y[e];if(!t||!t.canApplyFilter())continue;let n=t.toNumberArray();for(let e=0;e<n.length;e+=4096)x.push(...n.subarray(e,e+4096))}let S=L(i*d,0,0,a*d,0,0),C=Pc(e,S),w=Math.ceil(Math.abs(C[2]-C[0])),T=Math.ceil(Math.abs(C[3]-C[1])),E=C[0]/(i*d),D=C[1]/(a*d),ee=n[0]*E+n[2]*D+n[4],te=n[1]*E+n[3]*D+n[5];Z.push(1,w,T,2,0,e.instanceId,_,b[0],b[1],b[2],b[3],p,m,n[0]*i,n[1]*i,n[2]*a,n[3]*a,ee,te,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],x.length),x.length>0&&Z.set(new Float32Array(x));let O;O=l?F.multiply(S,l):L(S[0],0,0,S[3],0,0);let ne=O[4]-C[0],k=O[5]-C[1];u!==n&&F.release(u),u=L(O[0],O[1],O[2],O[3],ne,k),l?F.release(O):Rt(O),F.release(S),s!==r&&N.release(s),s=zt(1,1,1,1,0,0,0,0),M.set(`${e.instanceId}`,`bLocalBounds`,new Float32Array([C[0],C[1],C[2],C[3]])),V(C),V(b),M.set(`${e.instanceId}`,`bitmapKey`,_)}else{let t=e.filters;if(t){let i=M.generateFilterKeys(u[0],u[1],u[2],u[3]),a=M.get(`${e.instanceId}`,`${i}`),o=!1,c=[],l=B(0,0,0,0);for(let e=0;e<t.length;e++){let n=t[e];if(!n||!n.canApplyFilter())continue;n.$updated&&(o=!0),n.$updated=!1,n.getBounds(l);let r=n.toNumberArray();for(let e=0;e<r.length;e+=4096)c.push(...r.subarray(e,e+4096))}if(c.length>0){o||=e.changed;let t=Pc(e,n);if(a){if(!o){Z.push(1,Math.ceil(Math.abs(t[2]-t[0])),Math.ceil(Math.abs(t[3]-t[1])),1,1,e.instanceId,i,l[0],l[1],l[2],l[3],u[0],u[1],u[2],u[3],t[0],t[1],s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7]),V(t),V(l),s!==r&&N.release(s),u!==n&&F.release(u);return}M.removeById(`${e.instanceId}`)}Z.push(1,Math.ceil(Math.abs(t[2]-t[0])),Math.ceil(Math.abs(t[3]-t[1])),1,0,e.instanceId,i,l[0],l[1],l[2],l[3],u[0],u[1],u[2],u[3],t[0],t[1],s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],c.length),Z.set(new Float32Array(c));let d=u[0],f=u[1],p=u[2],m=u[3],h=u[4]-t[0],g=u[5]-t[1];u!==n&&F.release(u),u=L(d,f,p,m,h,g),s!==r&&N.release(s),s=zt(1,1,1,1,0,0,0,0),V(t),M.set(`${e.instanceId}`,`${i}`,!0)}else if(d===`normal`)Z.push(0);else{let t=Dr(e,n),i=t[0],a=t[1];Z.push(1,Math.ceil(Math.abs(t[2]-i)),Math.ceil(Math.abs(t[3]-a)),0,u[0],u[1],u[2],u[3],i,a,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7]);let o=u[0],c=u[1],l=u[2],d=u[3],f=u[4]-i,p=u[5]-a;u!==n&&F.release(u),u=L(o,c,l,d,f,p),V(t),s!==r&&N.release(s),s=zt(1,1,1,1,0,0,0,0)}V(l)}else if(d===`normal`)Z.push(0);else{let t=Dr(e,n),i=t[0],a=t[1];Z.push(1,Math.ceil(Math.abs(t[2]-i)),Math.ceil(Math.abs(t[3]-a)),0,u[0],u[1],u[2],u[3],i,a,s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7]);let o=u[0],c=u[1],l=u[2],d=u[3],f=u[4]-i,p=u[5]-a;u!==n&&F.release(u),u=L(o,c,l,d,f,p),V(t),s!==r&&N.release(s),s=zt(1,1,1,1,0,0,0,0)}}let p=e.mask;if(p){let e=kc(p,u,i,a);if(!e)Z.push(0);else switch(Z.push(1,e[0],e[1],e[2],e[3]),!0){case p.isContainerEnabled:Ac(p,u);break;case p.isShape:Tc(p,u);break;default:break}p.changed=!1}else Z.push(0);Z.push(c.length);let m=0,h=!0;for(let e=0;e<c.length;++e){let n=c[e];if(Z.push(n.placeId,n.clipDepth),n.isMask){Z.push(0),n.changed=!1;continue}if(m&&n.placeId>m&&(m=0,h=!0),!h){Z.push(0),n.changed=!1;continue}if(n.clipDepth){m=n.clipDepth;let e=kc(n,u,i,a);if(h=!!e,Z.push(+h),!e){n.changed=!1;continue}switch(Z.push(e[0],e[1],e[2],e[3]),!0){case n.isContainerEnabled:Ac(n,u);break;case n.isShape:Tc(n,u);break;default:break}n.changed=!1;continue}switch(!0){case n.isContainerEnabled:Fc(n,t,u,s,i,a);break;case n.isShape:wc(n,u,s,i,a);break;case n.isText:Dc(n,u,s,i,a);break;case n.isVideo:Oc(n,t,u,s,i,a);break;default:break}n.changed=!1}s!==r&&N.release(s),u!==n&&F.release(u)},Ic=(e,t,n,r,i,a)=>{switch(Z.push(Q.backgroundColor),!0){case e.isContainerEnabled:Fc(e,t,n,r,i,a);break;case e.isShape:wc(e,n,r,i,a);break;case e.isText:Dc(e,n,r,i,a);break;case e.isVideo:Oc(e,t,n,r,i,a);break;default:break}e.changed=!1},Lc=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,vc(e),qs(e),I(e))},Rc=e=>{let t=e.$container;if(t)for(let e=0;t.length>e;++e){let n=t[e];n.isTimelineEnabled&&Lc(n),Rc(n)}else{let t=[],n=e.children;for(let e=0;n.length>e;++e){let r=n[e];r.isContainerEnabled&&(r.isTimelineEnabled&&Lc(r),Rc(r),t.push(r))}e.$container=t}},zc=()=>{Rc(Q),gc(),hc()},Q=new class extends Ti{_$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(e){this._$backgroundColor=e===`transparent`?-1:parseInt(e.replace(`#`,``),16)}get pointer(){return At}set ready(e){!e||this._$ready||(this._$ready=e,bc(this))}addChild(e){return qt.add(e.instanceId),Kt.set(this,e),super.addChild(e),Kt.delete(this),Kt.set(e,e),e}$ticker(){zc()}$generateRenderQueue(e,t,n,r){Ic(e,t,n,r,this.rendererWidth,this.rendererHeight)}$mouseHit(e,t,n){ei(this,e,t,n,!0)}};qt.add(Q.instanceId);var Bc={command:`resize`,buffer:null},Vc=[],Hc=(e=!0)=>{Bc.buffer=new Float32Array([$.rendererWidth,$.rendererHeight,e?1:0]),Vc[0]=Bc.buffer.buffer,x.postMessage(Bc,Vc)},Uc=window.devicePixelRatio||1,Wc=()=>{ea.x=0,ea.y=0;let e=u();if(!e)return;let t=e.children[0];!t||t.localName!==`canvas`||(ea.x=(e.clientWidth-Q.rendererWidth/Uc)/2,ea.y=(e.clientHeight-Q.rendererHeight/Uc)/2)},Gc=()=>{let n=u();if(!n)return;let r=n.parentElement;if(!r)return;let i=$.fullScreen||r.tagName===`BODY`?window.innerWidth:r.clientWidth,a=$.fullScreen||r.tagName===`BODY`?window.innerHeight:r.clientHeight,o=n.style;if(o.width=`${i}px`,o.height=`${a}px`,!Q.stageWidth||!Q.stageHeight)return;let s=Math.min(i/Q.stageWidth,a/Q.stageHeight)*t,c=$.fullScreen?window.innerWidth*t:Q.stageWidth*s|0,l=$.fullScreen?window.innerHeight*t:Q.stageHeight*s|0;c===$.screenWidth&&l===$.screenHeight||($.screenWidth=i,$.screenHeight=a,Q.changed=!0,n.children.length>1&&n.children[1].dispatchEvent(new Event(`${e}_blur`)),Wc(),!(c===$.rendererWidth&&l===$.rendererHeight)&&(Q.rendererScale=$.rendererScale=s,Q.rendererWidth=$.rendererWidth=c,Q.rendererHeight=$.rendererHeight=l,d[0]=d[3]=s,d[4]=($.rendererWidth-Q.stageWidth*s)/2,d[5]=($.rendererHeight-Q.stageHeight*s)/2,M.reset(),Hc(),Q.hasEventListener(w.RESIZE)&&Q.dispatchEvent(new w(w.RESIZE))))},Kc=new Float32Array([1,1,1,1,0,0,0,0]),qc=[],Jc={command:`render`,buffer:null,length:0,imageBitmaps:null},Yc=[];x.addEventListener(`message`,e=>{if(e.data.message!==`render`)return;let t=e.data.buffer;Z.buffer.length>t.length||(Z.buffer=t)});var Xc=()=>{Z.offset=0,Yc.length=0,qc.length=0,Q.$generateRenderQueue(Q,qc,d,Kc),Z.offset&&(Jc.buffer=Z.buffer,Jc.length=Z.offset,Yc.push(Z.buffer.buffer),Jc.imageBitmaps=null,qc.length&&(Jc.imageBitmaps=qc,Yc.push(...qc)),x.postMessage(Jc,Yc))},Zc={command:`removeCache`,buffer:null},Qc=[],$c=()=>{let e=new Float32Array(M.$removeIds);M.$removeIds.length=0,Zc.buffer=e,Qc[0]=e.buffer,x.postMessage(Zc,Qc)},el=new w(w.ENTER_FRAME),tl=e=>{if($.stopFlag)return;M.$removeIds.length&&$c();let t=e-$.startTime;t>$.fps&&($.startTime=e-t%$.fps,Q.$ticker(),Q.hasEventListener(w.ENTER_FRAME)&&Q.dispatchEvent(el),Q.changed&&Xc(),M.$removeCache&&(M.removeTimerScheduledCache(),M.$removeIds.length&&$c())),$.timerId=requestAnimationFrame(e=>{tl(e)})},nl=()=>{$.stopFlag&&($.stopFlag=!1,Q.changed=!0,$.timerId>-1&&cancelAnimationFrame($.timerId),$.fps=1e3/Q.frameRate|0,$.startTime=performance.now(),$.timerId=requestAnimationFrame(e=>{tl(e)}))},rl=()=>{$.timerId>-1&&cancelAnimationFrame($.timerId),$.stopFlag=!0,$.timerId=-1,_s.stopAll()},il=e=>{let t=zi();if(t){t.keyDown(e);return}Q.hasEventListener(k.KEY_DOWN)&&(O(e),Q.dispatchEvent(new k(k.KEY_DOWN)))},al=e=>{zi()||Q.hasEventListener(k.KEY_UP)&&(O(e),Q.dispatchEvent(new k(k.KEY_UP)))},ol=()=>{window.addEventListener(k.KEY_DOWN,il),window.addEventListener(k.KEY_UP,al)},$=new class{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,ol()}get fullScreen(){return this._$fullScreen}set fullScreen(e){this._$fullScreen!==e&&(this._$fullScreen=e,Gc())}play(){nl()}stop(){rl()}cacheClear(){M.reset(),x.postMessage({command:`cacheClear`})}setOptions(e=null){e&&(this.fixedWidth=e.width||this.fixedWidth,this.fixedHeight=e.height||this.fixedHeight,this.tagId=e.tagId||this.tagId,this._$fullScreen=!!e.fullScreen,e.bgColor&&(Q.backgroundColor=e.bgColor))}},sl=`auto`,cl=()=>{$.stopFlag||(p.x=Q.pointer.x,p.y=Q.pointer.y,p.pointer=`auto`,p.hit=null,i.beginPath(),i.setTransform(1,0,0,1,0,0),Q.$mouseHit(i,f,p),$.mouseState===`up`&&sl!==p.pointer&&(l().style.cursor=sl=p.pointer))},ll=e=>{let n=window.scrollX,r=window.scrollY,i=u();if(i){let e=i.getBoundingClientRect();n+=e.left,r+=e.top}let a=e.target;if(a){let e=a.getBoundingClientRect();n+=e.left,r+=e.top}let o=($.rendererWidth-Q.stageWidth*$.rendererScale)/2,s=($.rendererHeight-Q.stageHeight*$.rendererScale)/2,c=$.rendererScale/t;Q.pointer.x=(e.pageX-n)/c-o/$.rendererScale,Q.pointer.y=(e.pageY-r)/c-s/$.rendererScale},ul=()=>{let e=p.hit,t=zi();t&&(!e||t.instanceId!==e.instanceId)&&(t.focus=!1,Ri(null)),e?(e.isText&&(e.focus?setTimeout(()=>{Bi.focus()},300):(e.focus=!0,Ri(e)),e.setFocusIndex(p.x-f[4],p.y-f[5])),e.willTrigger(A.POINTER_DOWN)&&e.dispatchEvent(new A(A.POINTER_DOWN))):Q.willTrigger(A.POINTER_DOWN)&&Q.dispatchEvent(new A(A.POINTER_DOWN))},dl=()=>{let e=p.hit;e?e.willTrigger(A.DOUBLE_CLICK)&&e.dispatchEvent(new A(A.DOUBLE_CLICK)):Q.willTrigger(A.DOUBLE_CLICK)&&Q.dispatchEvent(new A(A.DOUBLE_CLICK))},fl,pl=!1,ml=e=>{let t=e.target;t&&($.mouseState=`down`,t.setPointerCapture(e.pointerId),O(e),ll(e),cl(),p.hit&&e.preventDefault(),clearTimeout(fl),pl?(pl=!1,dl()):(pl=!0,fl=setTimeout(()=>{pl=!1},300),ul()))},hl=()=>{let e=Q.dropTarget,t=p.hit;t?(t.willTrigger(A.POINTER_UP)&&t.dispatchEvent(new A(A.POINTER_UP)),e&&e.instanceId!==t.instanceId&&e.willTrigger(A.POINTER_UP)&&e.dispatchEvent(new A(A.POINTER_UP))):e&&e.willTrigger(A.POINTER_UP)?e.dispatchEvent(new A(A.POINTER_UP)):Q.willTrigger(A.POINTER_UP)&&Q.dispatchEvent(new A(A.POINTER_UP))},gl=e=>{let t=e.target;t&&($.mouseState=`up`,t.releasePointerCapture(e.pointerId),O(e),ll(e),cl(),hl())},_l=()=>{let e=Q.dropTarget;if(e){let t=e.parent?e.parent.globalToLocal(Q.pointer):e.globalToLocal(Q.pointer),r=0,i=0;e.$lockCenter?(r=t.x-e.width/2,i=t.y-e.height/2):(r=t.x+e.$offsetX,i=t.y+e.$offsetY);let a=e.$boundedRect;a&&(r=n(r,a.left,a.right),i=n(i,a.top,a.bottom)),e.x=r,e.y=i}let t=zi();if(t&&$.mouseState===`down`){t.setFocusIndex(p.x-f[4],p.y-f[5],!0);return}let r=g(),i=p.hit;i?(i.willTrigger(A.POINTER_MOVE)&&i.dispatchEvent(new A(A.POINTER_MOVE)),r?r.instanceId!==i.instanceId&&(r.willTrigger(A.POINTER_OUT)&&r.dispatchEvent(new A(A.POINTER_OUT)),i.willTrigger(A.POINTER_OVER)&&i.dispatchEvent(new A(A.POINTER_OVER))):i.willTrigger(A.POINTER_OVER)&&i.dispatchEvent(new A(A.POINTER_OVER)),h(i)):(r&&(r.willTrigger(A.POINTER_OUT)&&r.dispatchEvent(new A(A.POINTER_OUT)),h(null)),Q.hasEventListener(A.POINTER_MOVE)&&Q.dispatchEvent(new A(A.POINTER_MOVE)))},vl=e=>{e.target&&(O(e),ll(e),cl(),p.hit&&e.preventDefault(),_l())},yl=e=>{O(e);let t=g();t&&t.willTrigger(A.POINTER_LEAVE)&&(e.preventDefault(),t.dispatchEvent(new A(A.POINTER_LEAVE)))},bl=e=>{O(e);let t=p.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}Q.willTrigger(he.WHEEL)&&(e.preventDefault(),Q.dispatchEvent(new he(he.WHEEL)))},xl=e=>{let t=()=>{is();let n=es();for(let e=0;e<n.length;++e){let t=n[e];t&&(t.muted=!1)}n.length=0,e.removeEventListener(A.POINTER_UP,t)};e.addEventListener(A.POINTER_UP,t),e.addEventListener(A.POINTER_DOWN,ml,{passive:!1}),e.addEventListener(A.POINTER_UP,gl),e.addEventListener(A.POINTER_CANCEL,gl),e.addEventListener(A.POINTER_MOVE,vl,{passive:!1}),e.addEventListener(A.POINTER_LEAVE,yl),e.addEventListener(he.WHEEL,bl)},Sl=document.createElement(`canvas`);c(Sl),_(Sl,t),xl(Sl),S(Sl);var Cl={Event:w,EventDispatcher:le,EventPhase:C,FocusEvent:ue,HTTPStatusEvent:de,IOErrorEvent:fe,PointerEvent:A,JobEvent:me,ProgressEvent:j,VideoEvent:pe};Object.entries(Cl).forEach(([e,t])=>{Object.defineProperty(Cl,e,{get(){return t}})});var wl={Sprite:Ai,MovieClip:rc,BitmapData:Me,BlendMode:Ne,DisplayObject:ai,DisplayObjectContainer:Ti,FrameLabel:Ei,Graphics:G,InteractiveObject:wi,Loader:mc,Shape:Ii,stage:Q};Object.entries(wl).forEach(([e,t])=>{Object.defineProperty(wl,e,{get(){return t}})});var Tl={BevelFilter:Cn,BlurFilter:En,ColorMatrixFilter:kn,ConvolutionFilter:Nn,DisplacementMapFilter:Ln,DropShadowFilter:Hn,GlowFilter:qn,GradientBevelFilter:Qn,GradientGlowFilter:rr};Object.entries(Tl).forEach(([e,t])=>{Object.defineProperty(Tl,e,{get(){return t}})});var El={ColorTransform:N,Matrix:F,Point:P,Rectangle:Ot};Object.entries(El).forEach(([e,t])=>{Object.defineProperty(El,e,{get(){return t}})});var Dl={Sound:Ts,SoundMixer:_s,SoundTransform:Es,Video:Is};Object.entries(Dl).forEach(([e,t])=>{Object.defineProperty(Dl,e,{get(){return t}})});var Ol=class{requestHeaders;url;contentType;data;method;responseDataFormat;withCredentials;constructor(e=``){this.url=`${e}`,this.contentType=`application/json`,this.data=null,this.method=`GET`,this.requestHeaders=[],this.responseDataFormat=`json`,this.withCredentials=!1}get headers(){let e=[];return e.push({name:`Content-Type`,value:this.contentType}),this.requestHeaders.length&&e.push(...this.requestHeaders),e}},kl={URLRequest:Ol};Object.entries(kl).forEach(([e,t])=>{Object.defineProperty(kl,e,{get(){return t}})});var Al={TextFormat:ta,TextField:Go};Object.entries(Al).forEach(([e,t])=>{Object.defineProperty(Al,e,{get(){return t}})});var jl={Easing:vo,Tween:Eo};Object.entries(jl).forEach(([e,t])=>{Object.defineProperty(jl,e,{get(){return t}})});var Ml=()=>{let e=u();if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},Nl=()=>{let e=u();if(!e)return;let t=l();t&&(e.appendChild(t),e.appendChild(Bi))},Pl=()=>{Q.ready=!0,Xc(),$.play(),Q.changed=!1},Fl=()=>{let t=document.createElement(`div`);if(o(t),t.id=e,t.tabIndex=-1,!$.tagId)document.body.appendChild(t);else{let e=document.getElementById($.tagId);if(!e)return alert(`Element not found with tag ID: ${$.tagId}`),t;e.appendChild(t)}return t},Il=(e,t=0,n=0)=>{let r=``;if(r+=`display:flex;`,r+=`align-items:center;`,r+=`justify-content:center;`,r+=`background-color:transparent;`,r+=`overflow:hidden;`,r+=`padding:0;`,r+=`margin:0;`,r+=`user-select:none;`,r+=`outline:none;`,t&&n)r+=`width:${t}px;`,r+=`height:${n}px;`;else{let t=e.parentElement;if(!t)throw Error(`parent element is null.`);t.tagName===`BODY`?(r+=`width:${window.innerWidth}px;`,r+=`height:${window.innerHeight}px;`):(r+=`width:${t.clientWidth}px;`,r+=`height:${t.clientHeight}px;`)}e.setAttribute(`style`,r)},Ll=t=>{let n=`${e}_loading`;t.innerHTML=`<style>
|
|
8
|
+
#${n} {
|
|
2347
9
|
width: 50px;
|
|
2348
10
|
height: 50px;
|
|
2349
11
|
border-radius: 50px;
|
|
2350
12
|
border: 8px solid #dcdcdc;
|
|
2351
13
|
border-right-color: transparent;
|
|
2352
14
|
box-sizing: border-box;
|
|
2353
|
-
animation: ${
|
|
15
|
+
animation: ${n} 0.8s infinite linear;
|
|
2354
16
|
}
|
|
2355
|
-
@keyframes ${
|
|
17
|
+
@keyframes ${n} {
|
|
2356
18
|
0% {
|
|
2357
19
|
transform: rotate(0deg);
|
|
2358
20
|
}
|
|
@@ -2361,4 +23,4 @@ fn main(
|
|
|
2361
23
|
}
|
|
2362
24
|
}
|
|
2363
25
|
</style>
|
|
2364
|
-
<div id="${
|
|
26
|
+
<div id="${n}"></div>`},Rl=-1,zl=()=>{window.addEventListener(`resize`,()=>{cancelAnimationFrame(Rl),Rl=requestAnimationFrame(Gc)})},Bl=(e=null)=>{$.setOptions(e);let t=Fl();Il(t,$.fixedWidth,$.fixedHeight),Ll(t),!$.fixedWidth&&!$.fixedHeight&&zl(),Gc()},Vl=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)),Bl(t);let r=new mc,i=r.contentLoaderInfo;if(i.addEventListener(fe.IO_ERROR,e=>{alert(`Error: `+e.text)}),await r.load(new Ol(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),Gc(),Pl(),Ml(),Nl(),Wc()},Hl=!1,Ul=(e=240,t=240,r=60,i=null)=>{if(Hl)return Q.getChildAt(0);Hl=!0,Q.stageWidth=e|0,Q.stageHeight=t|0,Q.frameRate=n(r,1,60,60),Bl(i);let a=Q.addChild(new Ai);return Pl(),Ml(),Nl(),Wc(),a},Wl={command:`capture`,buffer:null,bgColor:16777215,bgAlpha:0,width:0,height:0,length:0,imageBitmaps:null},Gl=[],Kl=[],ql=async(e,t,n,r,i=0,a=0)=>await new Promise(o=>{if(Z.offset=0,Gl.length=0,Kl.length=0,Q.$generateRenderQueue(e,Kl,t,n),!Z.offset)return o(r);Wl.buffer=Z.buffer,Wl.width=r.width,Wl.height=r.height,Wl.bgColor=i,Wl.bgAlpha=a,Wl.length=Z.offset,Gl.push(Z.buffer.buffer),Wl.imageBitmaps=null,Kl.length&&(Wl.imageBitmaps=Kl,Gl.push(...Kl));let s=e=>{if(e.data.message!==`capture`)return;let t=e.data.buffer;return Z.buffer.length<t.length&&(Z.buffer=t),r.getContext(`2d`).drawImage(e.data.imageBitmap,0,0),x.removeEventListener(`message`,s),o(r)};x.addEventListener(`message`,s),x.postMessage(Wl,Gl)}),Jl=async e=>{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<t.length;++e){let n=t[e];n&&(!n.isVideo&&!n.isContainerEnabled||await Jl(n))}}break;default:break}},Yl=new Float32Array([1,0,0,1,0,0]),Xl=new Float32Array([1,1,1,1,0,0,0,0]),Zl=async(e,n=null)=>{n&&n.videoSync&&await Jl(e);let r=n&&n.colorTransform?n.colorTransform.rawData:Xl,i=new Float32Array([1,0,0,1,-e.width/2,-e.height/2]),a=n&&n.matrix?F.multiply(n.matrix.rawData,i):F.multiply(Yl,i),o=n&&n.canvas?n.canvas:M.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,Hc(!1)),await ql(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,Hc(!1)),d||$.play(),F.release(a),n&&n.colorTransform&&N.release(r),o},Ql=class{display;events;filters;geom;media;net;text;ui;_$promise;constructor(){this.display=wl,this.events=Cl,this.filters=Tl,this.geom=El,this.media=Dl,this.net=kl,this.text=Al,this.ui=jl,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 Vl(e,t)}async createRootMovieClip(e=240,t=240,n=60,r=null){return await Promise.all([this._$promise]),Ul(e,t,n,r)}async captureToCanvas(e,t=null){return await Zl(e,t)}};`next2d`in window||(console.log(`%c Next2D Player %c 3.1.0 %c https://next2d.app`,`color: #fff; background: #5f5f5f`,`color: #fff; background: #4bc729`,``),window.next2d=new Ql);
|