summaryrefslogtreecommitdiff
path: root/2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js
diff options
context:
space:
mode:
Diffstat (limited to '2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js')
-rw-r--r--2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js b/2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js
new file mode 100644
index 0000000..72bfc86
--- /dev/null
+++ b/2026/games_submissions/sunshoes/assets/CanvasRenderer-Yf_04ykh.js
@@ -0,0 +1 @@
+import{x as vt,y as ne,z as _,A as Dt,D as re,F as z,H as ae,V as oe,J as ot,d as E,v as W,K as T,p as At,L as Ft,M as ct,N as L,w as ie,O as Ut,P as Ht,Q as le,e as Et,T as Wt,U as ce,W as he,X as de,Y as ue,Z as Lt,_ as pe,$ as fe}from"./index-DvAPfvr6.js";import{c as me,R as xe,S as ge,B as Ce,a as _e,b as ye,d as ve,A as be,C as Te}from"./RenderTargetSystem-Cp6tD-lP.js";import{S as qt}from"./Filter-BiIvpnZm.js";class Se{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Pe{constructor(){this.instructions=new ne}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const bt=class yt{constructor(t){this._renderer=t,this._managedContexts=new vt({renderer:t,type:"resource",name:"graphicsContext"})}init(t){yt.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??yt.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new Pe,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new Se;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};bt.extension={type:[_.CanvasSystem],name:"graphicsContext"};bt.defaultOptions={bezierSmoothness:.5};let Me=bt;class Ot{constructor(t,e){this.state=qt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new vt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}Ot.extension={type:[_.CanvasPipes],name:"graphics"};class ke{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Dt.return(t)}),this.batches.length=0}}class Vt{constructor(t,e){this.state=qt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new vt({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,r=this.renderer.graphicsContext.updateGpuContext(e);return!!(r.isBatchable||s!==r.isBatchable)}addRenderable(t,e){const n=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),n.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const r=s[n];r._batcher.updateElement(r)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const r=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const o=r.resources.localUniforms.uniforms;o.uTransformMatrix=t.groupTransform,o.uRound=e._roundPixels|t._roundPixels,me(t.groupColorAlpha,o.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),n=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),n.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let r=0;r<n.length;r++){const o=n[r];s.addToBatch(o,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new ke;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,r=this.renderer.graphicsContext.getGpuContext(s),o=this.renderer._roundPixels|t._roundPixels;e.batches=r.batches.map(l=>{const i=Dt.get(re);return l.copyTo(i),i.renderable=t,i.roundPixels=o,i})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Vt.extension={type:[_.WebGLPipes,_.WebGPUPipes],name:"graphics"};z.add(Ot);z.add(Vt);z.add(Me);z.add(ae);class dt extends oe{constructor(t){t instanceof ot&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new ot,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new dt(this._context.clone()):(this._ownedContext=null,new dt(this._context))}lineStyle(t,e,s){E(W,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){E(W,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){E(W,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==ot.defaultStrokeStyle.width||t.color!==ot.defaultStrokeStyle.color||t.alpha!==ot.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return E(W,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return E(W,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return E(W,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return E(W,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return E(W,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return E(W,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Tt=class K{static _getPatternRepeat(t,e){const s=t&&t!=="clamp-to-edge",n=e&&e!=="clamp-to-edge";return s&&n?"repeat":s?"repeat-x":n?"repeat-y":"no-repeat"}start(t,e,s){}execute(t,e){var l,i,p,f;const s=e.elements;if(!s||!s.length)return;const n=t.renderer,r=n.canvasContext,o=r.activeContext;for(let y=0;y<s.length;y++){const A=s[y];if(!A.packAsQuad)continue;const g=A,m=g.texture,k=m?T.getCanvasSource(m):null;if(!k)continue;const C=m.source.style,B=r.smoothProperty,$=C.scaleMode!=="nearest";o[B]!==$&&(o[B]=$),r.setBlendMode(e.blendMode);const q=((l=n.globalUniforms.globalUniformData)==null?void 0:l.worldColor)??4294967295,F=g.color,S=(q>>>24&255)/255,v=(F>>>24&255)/255,X=((i=n.filter)==null?void 0:i.alphaMultiplier)??1,et=S*v*X;if(et<=0)continue;o.globalAlpha=et;const st=q&16777215,Q=F&16777215,P=Ft(ct(Q,st)),w=m.frame,R=C.addressModeU??C.addressMode,ut=C.addressModeV??C.addressMode,nt=K._getPatternRepeat(R,ut),O=m.source._resolution??m.source.resolution??1,J=(f=(p=g.renderable)==null?void 0:p.renderGroup)==null?void 0:f.isCachedAsTexture,d=w.x*O,u=w.y*O,x=w.width*O,V=w.height*O,G=g.bounds,M=n.renderTarget.renderTarget.isRoot,U=G.minX,H=G.minY,I=G.maxX-G.minX,D=G.maxY-G.minY,N=m.rotate,c=m.uvs,Y=Math.min(c.x0,c.x1,c.x2,c.x3,c.y0,c.y1,c.y2,c.y3),j=Math.max(c.x0,c.x1,c.x2,c.x3,c.y0,c.y1,c.y2,c.y3),b=nt!=="no-repeat"&&(Y<0||j>1),it=N&&!(!b&&(P!==16777215||N));it?(K._tempPatternMatrix.copyFrom(g.transform),At.matrixAppendRotationInv(K._tempPatternMatrix,N,U,H,I,D),r.setContextTransform(K._tempPatternMatrix,g.roundPixels===1,void 0,J&&M)):r.setContextTransform(g.transform,g.roundPixels===1,void 0,J&&M);const pt=I,ft=D;let rt=it?0:U,at=it?0:H;if(!it&&g.roundPixels===1&&(rt|=0,at|=0),b){let mt=k;const Z=P!==16777215&&!N,tt=w.width<=m.source.width&&w.height<=m.source.height;Z&&tt&&(mt=T.getTintedCanvas({texture:m},P));const xt=o.createPattern(mt,nt);if(!xt)continue;const Pt=pt,Mt=ft;if(Pt===0||Mt===0)continue;const kt=1/Pt,wt=1/Mt,Rt=(c.x1-c.x0)*kt,Gt=(c.y1-c.y0)*kt,Bt=(c.x3-c.x0)*wt,It=(c.y3-c.y0)*wt,ee=c.x0-Rt*rt-Bt*at,se=c.y0-Gt*rt-It*at,gt=m.source.pixelWidth,Ct=m.source.pixelHeight;K._tempPatternMatrix.set(Rt*gt,Gt*Ct,Bt*gt,It*Ct,ee*gt,se*Ct),T.applyPatternTransform(xt,K._tempPatternMatrix),o.fillStyle=xt,o.fillRect(rt,at,pt,ft)}else{const Z=P!==16777215||N?T.getTintedCanvas({texture:m},P):k,tt=Z!==k;o.drawImage(Z,tt?0:d,tt?0:u,tt?Z.width:x,tt?Z.height:V,rt,at,pt,ft)}}}};Tt._tempPatternMatrix=new L;Tt.extension={type:[_.CanvasPipesAdaptor],name:"batch"};let we=Tt;class Nt{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(t,e,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Nt.extension={type:[_.CanvasPipes],name:"colorMask"};function Re(a,t,e,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(t+r,e),a.lineTo(t+s-r,e),a.quadraticCurveTo(t+s,e,t+s,e+r),a.lineTo(t+s,e+n-r),a.quadraticCurveTo(t+s,e+n,t+s-r,e+n),a.lineTo(t+r,e+n),a.quadraticCurveTo(t,e+n,t,e+n-r),a.lineTo(t,e+r),a.quadraticCurveTo(t,e,t+r,e)}function Yt(a,t){switch(t.type){case"rectangle":{const e=t;a.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;Re(a,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;a.moveTo(e.x+e.radius,e.y),a.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;a.ellipse?(a.moveTo(e.x+e.halfWidth,e.y),a.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(a.save(),a.translate(e.x,e.y),a.scale(e.halfWidth,e.halfHeight),a.moveTo(1,0),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const e=t;a.moveTo(e.x,e.y),a.lineTo(e.x2,e.y2),a.lineTo(e.x3,e.y3),a.closePath();break}case"polygon":default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);e.closePath&&a.closePath();break}}}function Ge(a,t,e){const s=[],n=[],r=[],o=Ut[t.type];if(!(o!=null&&o.build(t,s)))return!1;const l=t.closePath??!0;Ht(s,e,!1,l,n,r);for(let i=0;i<r.length;i+=3){const p=r[i]*2,f=r[i+1]*2,y=r[i+2]*2;a.moveTo(n[p],n[p+1]),a.lineTo(n[f],n[f+1]),a.lineTo(n[y],n[y+1]),a.closePath()}return!0}function Be(a,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const n=s.transform,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Yt(a,s.shape),r&&a.restore()}return!0}class jt{constructor(t){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=t}push(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){var f,y,A;if(t.action!=="pushMaskBegin"&&t.action!=="popMaskEnd")return;const e=this._renderer,s=e.canvasContext,n=s==null?void 0:s.activeContext;if(!n)return;if(t.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}t.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const r=t.mask.mask;if(!(r instanceof dt)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=r,l=(f=o.context)==null?void 0:f.instructions;if(!(l!=null&&l.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(o.groupTransform,(e._roundPixels|o._roundPixels)===1),n.beginPath();let i=!1,p=!1;for(let g=0;g<l.length;g++){const m=l[g],k=m.action;if(k!=="fill"&&k!=="stroke")continue;const C=m.data,B=(y=C==null?void 0:C.path)==null?void 0:y.shapePath;if(!((A=B==null?void 0:B.shapePrimitives)!=null&&A.length))continue;const $=k==="stroke",q=B.shapePrimitives;for(let F=0;F<q.length;F++){const S=q[F];if(!(S!=null&&S.shape))continue;const v=S.transform,X=v&&!v.isIdentity();X&&(n.save(),n.transform(v.a,v.b,v.c,v.d,v.tx,v.ty)),$&&C.style?i=Ge(n,S.shape,C.style)||i:(Yt(n,S.shape),p=Be(n,S.holes)||p,i=!0),X&&n.restore()}}if(!i){n.restore(),this._canvasMaskStack.push(!1);return}p?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(t,e){this._warnedMaskTypes.has(t)||(this._warnedMaskTypes.add(t),ie(e))}}jt.extension={type:[_.CanvasPipes],name:"stencilMask"};const h="source-over";function Ie(){const a=le(),t=Object.create(null);return t.inherit=h,t.none=h,t.normal="source-over",t.add="lighter",t.multiply=a?"multiply":h,t.screen=a?"screen":h,t.overlay=a?"overlay":h,t.darken=a?"darken":h,t.lighten=a?"lighten":h,t["color-dodge"]=a?"color-dodge":h,t["color-burn"]=a?"color-burn":h,t["hard-light"]=a?"hard-light":h,t["soft-light"]=a?"soft-light":h,t.difference=a?"difference":h,t.exclusion=a?"exclusion":h,t.saturation=a?"saturation":h,t.color=a?"color":h,t.luminosity=a?"luminosity":h,t["linear-burn"]=a?"color-burn":h,t["linear-dodge"]=a?"color-dodge":h,t["linear-light"]=a?"hard-light":h,t["pin-light"]=a?"hard-light":h,t["vivid-light"]=a?"hard-light":h,t["hard-mix"]=h,t.negation=a?"difference":h,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=h,t.divide=h,t.min=h,t.max=h,t}const De=new L;class zt{constructor(t){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=Ie(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=t}resolutionChange(t){this.activeResolution=t}init(){const t=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:t}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(t,e,s,n){var p;const r=n?L.IDENTITY:((p=this._renderer.globalUniforms.globalUniformData)==null?void 0:p.worldTransformMatrix)||L.IDENTITY;let o=De;o.copyFrom(r),o.append(t);const l=this._projTransform,i=this.activeResolution;if(s=s||i,l){const f=L.shared;f.copyFrom(o),f.prepend(l),o=f}e?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i|0,o.ty*i|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i,o.ty*i)}clear(t,e){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),t){const r=Et.shared.setValue(t);s.globalAlpha=e??r.alpha,s.fillStyle=r.toHex(),s.fillRect(0,0,n.width,n.height),s.globalAlpha=1}}setBlendMode(t){if(this._activeBlendMode===t)return;this._activeBlendMode=t,this._outerBlend=!1;const e=this.blendModes[t];if(!e){this._warnedBlendModes.has(t)||(console.warn(`CanvasRenderer: blend mode "${t}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(t)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=e}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}zt.extension={type:[_.CanvasSystem],name:"canvasContext"};class $t{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}$t.extension={type:[_.CanvasSystem],name:"limits"};const Ae="#808080",lt=new L,Fe=new L,Ue=new L,_t=new L;function He(a,t,e){a.beginPath();for(let s=0;s<e.length;s+=3){const n=e[s]*2,r=e[s+1]*2,o=e[s+2]*2;a.moveTo(t[n],t[n+1]),a.lineTo(t[r],t[r+1]),a.lineTo(t[o],t[o+1]),a.closePath()}a.fill()}function Ee(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function We(a,t,e,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(t+r,e),a.lineTo(t+s-r,e),a.quadraticCurveTo(t+s,e,t+s,e+r),a.lineTo(t+s,e+n-r),a.quadraticCurveTo(t+s,e+n,t+s-r,e+n),a.lineTo(t+r,e+n),a.quadraticCurveTo(t,e+n,t,e+n-r),a.lineTo(t,e+r),a.quadraticCurveTo(t,e,t+r,e)}function ht(a,t){switch(t.type){case"rectangle":{const e=t;a.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;We(a,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;a.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;a.ellipse?a.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2):(a.save(),a.translate(e.x,e.y),a.scale(e.halfWidth,e.halfHeight),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const e=t;a.moveTo(e.x,e.y),a.lineTo(e.x2,e.y2),a.lineTo(e.x3,e.y3),a.closePath();break}case"polygon":default:{const e=t,s=e.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);e.closePath&&a.closePath();break}}}function Le(a,t){if(!(t!=null&&t.length))return!1;for(let e=0;e<t.length;e++){const s=t[e];if(!(s!=null&&s.shape))continue;const n=s.transform,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ht(a,s.shape),r&&a.restore()}return!0}function qe(a,t,e,s){const n=a.fill;if(n instanceof he){n.buildGradient();const o=n.texture;if(o){const l=T.getTintedPattern(o,t),i=e?_t.copyFrom(e).scale(o.source.pixelWidth,o.source.pixelHeight):_t.copyFrom(n.transform);return s&&!a.textureSpace&&i.append(s),T.applyPatternTransform(l,i),l}}if(n instanceof de){const o=T.getTintedPattern(n.texture,t);return T.applyPatternTransform(o,n.transform,!1),o}const r=a.texture;if(r&&r!==Wt.WHITE){if(!r.source.resource)return Ae;const o=T.getTintedPattern(r,t),l=e?_t.copyFrom(e).scale(r.source.pixelWidth,r.source.pixelHeight):a.matrix;return T.applyPatternTransform(o,l),o}return Ee(t)}class Xt{constructor(){this.shader=null}contextChange(t){}execute(t,e){var $,q,F,S,v,X,et;const s=t.renderer,n=s.canvasContext,r=n.activeContext,o=e.groupTransform,l=(($=s.globalUniforms.globalUniformData)==null?void 0:$.worldColor)??4294967295,i=e.groupColorAlpha,p=(l>>>24&255)/255,f=(i>>>24&255)/255,y=((q=s.filter)==null?void 0:q.alphaMultiplier)??1,A=p*f*y;if(A<=0)return;const g=l&16777215,m=i&16777215,k=Ft(ct(m,g)),C=s._roundPixels|e._roundPixels;r.save(),n.setContextTransform(o,C===1),n.setBlendMode(e.groupBlendMode);const B=e.context.instructions;for(let st=0;st<B.length;st++){const Q=B[st];if(Q.action==="texture"){const d=Q.data,u=d.image,x=u?T.getCanvasSource(u):null;if(!x)continue;const V=d.alpha*A;if(V<=0)continue;const G=ct(d.style,k);r.globalAlpha=V;let M=x;G!==16777215&&(M=T.getTintedCanvas({texture:u},G));const U=u.frame,H=u.source._resolution??u.source.resolution??1;let I=U.x*H,D=U.y*H;const N=U.width*H,c=U.height*H;M!==x&&(I=0,D=0);const Y=d.transform,j=Y&&!Y.isIdentity(),b=u.rotate;j||b?(lt.copyFrom(o),j&&lt.append(Y),b&&At.matrixAppendRotationInv(lt,b,d.dx,d.dy,d.dw,d.dh),n.setContextTransform(lt,C===1)):n.setContextTransform(o,C===1),r.drawImage(M,I,D,M===x?N:M.width,M===x?c:M.height,b?0:d.dx,b?0:d.dy,d.dw,d.dh),(j||b)&&n.setContextTransform(o,C===1);continue}const P=Q.data,w=(F=P==null?void 0:P.path)==null?void 0:F.shapePath;if(!((S=w==null?void 0:w.shapePrimitives)!=null&&S.length))continue;const R=P.style,ut=ct(R.color,k),nt=R.alpha*A;if(nt<=0)continue;const O=Q.action==="stroke";if(r.globalAlpha=nt,O){const d=R;r.lineWidth=d.width,r.lineCap=d.cap,r.lineJoin=d.join,r.miterLimit=d.miterLimit}const J=w.shapePrimitives;if(!O&&((et=(X=(v=P.hole)==null?void 0:v.shapePath)==null?void 0:X.shapePrimitives)!=null&&et.length)){const d=J[J.length-1];d.holes=P.hole.shapePath.shapePrimitives}for(let d=0;d<J.length;d++){const u=J[d];if(!(u!=null&&u.shape))continue;const x=u.transform,V=x&&!x.isIdentity(),G=R.texture&&R.texture!==Wt.WHITE,M=R.textureSpace==="global"?x:null,U=G?ce(Fe,R,u.shape,M):null,H=V?Ue.copyFrom(o).append(x):o,I=qe(R,ut,U,H);if(V&&(r.save(),r.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),O){const D=R;if(D.alignment!==.5&&!D.pixelLine){const c=[],Y=[],j=[],b=Ut[u.shape.type];if(b!=null&&b.build(u.shape,c)){const St=u.shape.closePath??!0;Ht(c,D,!1,St,Y,j),r.fillStyle=I,He(r,Y,j)}else r.strokeStyle=I,r.beginPath(),ht(r,u.shape),r.stroke()}else r.strokeStyle=I,r.beginPath(),ht(r,u.shape),r.stroke()}else r.fillStyle=I,r.beginPath(),ht(r,u.shape),Le(r,u.holes)?r.fill("evenodd"):r.fill();V&&r.restore()}}r.restore()}destroy(){this.shader=null}}Xt.extension={type:[_.CanvasPipesAdaptor],name:"graphics"};class Oe{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:s,context:n}=this._ensureCanvas(e);return{canvas:s,context:n,width:s.width,height:s.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:s}=this._ensureCanvas(e);s.width=t.pixelWidth,s.height=t.pixelHeight}startRenderPass(t,e,s,n){const r=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=r.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,s,n)}clear(t,e,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(t).context,l=n||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(l.x,l.y,l.width,l.height),s){const i=Et.shared.setValue(s);i.alpha>0&&(o.globalAlpha=i.alpha,o.fillStyle=i.toHex(),o.fillRect(l.x,l.y,l.width,l.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,s,n,r){const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,i=e.source,{context:p}=this._ensureCanvas(i),f=(r==null?void 0:r.x)??0,y=(r==null?void 0:r.y)??0;return p.drawImage(l,s.x,s.y,n.width,n.height,f,y,n.width,n.height),i.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!ue.test(e))&&(e=Lt.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const s=e.getContext("2d");return{canvas:e,context:s}}}class Jt extends xe{constructor(t){super(t),this.adaptor=new Oe,this.adaptor.init(t,this)}}Jt.extension={type:[_.CanvasSystem],name:"renderTarget"};class Kt{constructor(t){}init(){}initSource(t){}generateCanvas(t){const e=Lt.get().createCanvas(),s=e.getContext("2d"),n=T.getCanvasSource(t);if(!n)return e;const r=t.frame,o=t.source._resolution??t.source.resolution??1,l=r.x*o,i=r.y*o,p=r.width*o,f=r.height*o;return e.width=Math.ceil(p),e.height=Math.ceil(f),s.drawImage(n,l,i,p,f,0,0,p,f),e}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}Kt.extension={type:[_.CanvasSystem],name:"texture"};const Ve=[...ge,zt,$t,Kt,Jt],Ne=[Ce,_e,ye,ve,be,jt,Nt,Te],Ye=[we,Xt],Qt=[],Zt=[],te=[];z.handleByNamedList(_.CanvasSystem,Qt);z.handleByNamedList(_.CanvasPipes,Zt);z.handleByNamedList(_.CanvasPipesAdaptor,te);z.add(...Ve,...Ne,...Ye);class Xe extends pe{constructor(){const t={name:"canvas",type:fe.CANVAS,systems:Qt,renderPipes:Zt,renderPipeAdaptors:te};super(t)}}export{Xe as CanvasRenderer};