@rive-app/canvas-lite 2.43.1 → 2.44.1

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/rive.js CHANGED
@@ -349,104 +349,109 @@ __webpack_require__.r(__webpack_exports__);
349
349
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
350
350
  /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
351
351
  /* harmony export */ });
352
- var Rive=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var h=moduleArg,aa=!!globalThis.window,ca=!!globalThis.WorkerGlobalScope;
353
- function da(){function b(g){const f=d;c=a=0;d=new Map;f.forEach(m=>{try{m(g)}catch(n){console.error(n)}});this.Ja();e&&e.ib()}let a=0,c=0,d=new Map,e=null,k=null;this.requestAnimationFrame=function(g){a||=requestAnimationFrame(b.bind(this));const f=++c;d.set(f,g);return f};this.cancelAnimationFrame=function(g){d.delete(g);a&&0==d.size&&(cancelAnimationFrame(a),a=0)};this.gb=function(g){k&&(document.body.remove(k),k=null);g||(k=document.createElement("div"),k.style.backgroundColor="black",k.style.position=
354
- "fixed",k.style.right=0,k.style.top=0,k.style.color="white",k.style.padding="4px",k.innerHTML="RIVE FPS",g=function(f){k.innerHTML="RIVE FPS "+f.toFixed(1)},document.body.appendChild(k));e=new function(){let f=0,m=0;this.ib=function(){var n=performance.now();m?(++f,n-=m,1E3<n&&(g(1E3*f/n),f=m=0)):(m=n,f=0)}}};this.cb=function(){k&&(document.body.remove(k),k=null);e=null};this.Ja=function(){}}
355
- function ea(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}const ia=h.onRuntimeInitialized;
356
- h.onRuntimeInitialized=function(){ia&&ia();let b=h.decodeAudio;h.decodeAudio=function(g,f,m=null){g=b(g,m??null);f(g)};let a=h.decodeFont;h.decodeFont=function(g,f,m=null){g=a(g,m??null);f(g)};const c=h.FileAsset.prototype.decode;h.FileAsset.prototype.decode=function(g,f){return c.call(this,g,f??null)};let d=h.setFallbackFontCb;h.setFallbackFontCallback="function"===typeof d?function(g){d(g)}:function(){console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.")};
357
- const e=h.FileAssetLoader;h.ptrToAsset=g=>{let f=h.ptrToFileAsset(g);return f.isImage?h.ptrToImageAsset(g):f.isFont?h.ptrToFontAsset(g):f.isAudio?h.ptrToAudioAsset(g):f};h.CustomFileAssetLoader=e.extend("CustomFileAssetLoader",{__construct:function({loadContents:g}){this.__parent.__construct.call(this);this.Xa=g},loadContents:function(g,f){g=h.ptrToAsset(g);return this.Xa(g,f)}});h.CDNFileAssetLoader=e.extend("CDNFileAssetLoader",{__construct:function(g){this.__parent.__construct.call(this);this.Ya=
358
- g??null},loadContents:function(g){let f=h.ptrToAsset(g);g=f.cdnUuid;if(""===g)return!1;const m=this.Ya??null;(function(n,r){var w=new XMLHttpRequest;w.responseType="arraybuffer";w.onreadystatechange=function(){4==w.readyState&&200==w.status&&r(w)};w.open("GET",n,!0);w.send(null)})(f.cdnBaseUrl+"/"+g,n=>{f.decode(new Uint8Array(n.response),m)});return!0}});h.FallbackFileAssetLoader=e.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);this.Ia=[]},addLoader:function(g){this.Ia.push(g)},
359
- loadContents:function(g,f){for(let m of this.Ia)if(m.loadContents(g,f))return!0;return!1}});let k=h.computeAlignment;h.computeAlignment=function(g,f,m,n,r=1){return k.call(this,g,f,m,n,r)}};
360
- const ka="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),la=new function(){function b(){if(!a){var v=document.createElement("canvas"),x={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,powerPreference:"high-performance",failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,
361
- renderViaOffscreenBackBuffer:1};let q;if(/iPhone|iPad|iPod/i.test(navigator.userAgent)){if(q=v.getContext("webgl",x),c=1,!q)return console.log("No WebGL support. Image mesh will not be drawn."),!1}else if(q=v.getContext("webgl2",x))c=2;else if(q=v.getContext("webgl",x))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;q=new Proxy(q,{get(I,u){if(I.isContextLost()){if(m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ",u),m=!0),
362
- "function"===typeof I[u])return function(){}}else return"function"===typeof I[u]?function(...J){return I[u].apply(I,J)}:I[u]},set(I,u,J){if(I.isContextLost())m||(console.error("Cannot render the mesh because the GL Context was lost. Tried to set property "+u),m=!0);else return I[u]=J,!0}});d=Math.min(q.getParameter(q.MAX_RENDERBUFFER_SIZE),q.getParameter(q.MAX_TEXTURE_SIZE));function L(I,u,J){u=q.createShader(u);q.shaderSource(u,J);q.compileShader(u);J=q.getShaderInfoLog(u);if(0<(J||"").length)throw J;
363
- q.attachShader(I,u)}v=q.createProgram();L(v,q.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");L(v,q.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");
364
- q.bindAttribLocation(v,0,"vertex");q.bindAttribLocation(v,1,"uv");q.linkProgram(v);x=q.getProgramInfoLog(v);if(0<(x||"").trim().length)throw x;e=q.getUniformLocation(v,"mat");k=q.getUniformLocation(v,"translate");q.useProgram(v);q.bindBuffer(q.ARRAY_BUFFER,q.createBuffer());q.enableVertexAttribArray(0);q.enableVertexAttribArray(1);q.bindBuffer(q.ELEMENT_ARRAY_BUFFER,q.createBuffer());q.uniform1i(q.getUniformLocation(v,"image"),0);q.pixelStorei(q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=q}return!0}let a=
365
- null,c=0,d=0,e=null,k=null,g=0,f=0,m=!1;b();this.rb=function(){b();return d};this.bb=function(v){a&&a.deleteTexture&&a.deleteTexture(v)};this.ab=function(v){if(!b())return null;const x=a.createTexture();if(!x)return null;a.bindTexture(a.TEXTURE_2D,x);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,v);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==
366
- c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return x};const n=new ea(8),r=new ea(8),w=new ea(10),z=new ea(10);this.fb=function(v,x,q,L,I){if(b()){var u=n.push(v),J=r.push(x);if(a.canvas){if(a.canvas.width!=u||a.canvas.height!=J)a.canvas.width=u,a.canvas.height=J;a.viewport(0,J-x,v,x);a.disable(a.SCISSOR_TEST);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);a.enable(a.SCISSOR_TEST);
367
- q.sort((E,ba)=>ba.Na-E.Na);u=w.push(L);g!=u&&(a.bufferData(a.ARRAY_BUFFER,8*u,a.DYNAMIC_DRAW),g=u);u=0;for(var K of q)a.bufferSubData(a.ARRAY_BUFFER,u,K.ta),u+=4*K.ta.length;console.assert(u==4*L);for(var R of q)a.bufferSubData(a.ARRAY_BUFFER,u,R.Qa),u+=4*R.Qa.length;console.assert(u==8*L);u=z.push(I);f!=u&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*u,a.DYNAMIC_DRAW),f=u);K=0;for(var X of q)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,K,X.indices),K+=2*X.indices.length;console.assert(K==2*I);X=0;R=!0;u=K=0;
368
- for(const E of q){E.image.na!=X&&(a.bindTexture(a.TEXTURE_2D,E.image.la||null),X=E.image.na);E.ub?(a.scissor(E.Aa,J-E.Ba-E.Ha,E.Bb,E.Ha),R=!0):R&&(a.scissor(0,J-x,v,x),R=!1);q=2/v;const ba=-2/x;a.uniform4f(e,E.O[0]*q*E.da,E.O[1]*ba*E.ea,E.O[2]*q*E.da,E.O[3]*ba*E.ea);a.uniform2f(k,E.O[4]*q*E.da+q*(E.Aa-E.sb*E.da)-1,E.O[5]*ba*E.ea+ba*(E.Ba-E.tb*E.ea)+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,u);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,u+4*L);a.drawElements(a.TRIANGLES,E.indices.length,a.UNSIGNED_SHORT,
369
- K);u+=4*E.ta.length;K+=2*E.indices.length}console.assert(u==4*L);console.assert(K==2*I)}}};this.canvas=function(){return b()&&a.canvas}},ma=h.onRuntimeInitialized;
370
- h.onRuntimeInitialized=function(){function b(l){switch(l){case n.srcOver:return"source-over";case n.Cb:return"plus-lighter";case n.screen:return"screen";case n.overlay:return"overlay";case n.darken:return"darken";case n.lighten:return"lighten";case n.colorDodge:return"color-dodge";case n.colorBurn:return"color-burn";case n.hardLight:return"hard-light";case n.softLight:return"soft-light";case n.difference:return"difference";case n.exclusion:return"exclusion";case n.multiply:return"multiply";case n.hue:return"hue";
371
- case n.saturation:return"saturation";case n.color:return"color";case n.luminosity:return"luminosity"}}function a(l){return"rgba("+((16711680&l)>>>16)+","+((65280&l)>>>8)+","+((255&l)>>>0)+","+((4278190080&l)>>>24)/255+")"}function c(){0<R.length&&(la.fb(K.drawWidth(),K.drawHeight(),R,X,E),R=[],E=X=0,K.reset(512,512));for(const l of u){for(const p of l.D)p();l.D=[]}u.clear()}ma&&ma();var d=h.RenderPaintStyle;const e=h.RenderPath,k=h.RenderPaint,g=h.Renderer,f=h.StrokeCap,m=h.StrokeJoin,n=h.BlendMode,
372
- r=d.fill,w=d.stroke,z=h.FillRule.evenOdd;let v=1;var x=h.RenderImage.extend("CanvasRenderImage",{__construct:function({U:l,ca:p}={}){this.__parent.__construct.call(this);this.na=v;v=v+1&2147483647||1;this.U=l;this.ca=p},__destruct:function(){this.la&&(la.bb(this.la),URL.revokeObjectURL(this.ya));this.__parent.__destruct.call(this)},decode:function(l){var p=this;p.ca&&p.ca(p);var A=new Image;p.ya=URL.createObjectURL(new Blob([l],{type:"image/png"}));A.onload=function(){p.Wa=A;p.la=la.ab(A);p.size(A.width,
373
- A.height);p.U&&p.U(p)};A.src=p.ya}});class q{constructor(){this.Z=this.$=0;this.K=new Path2D}clear(){this.Z=this.$=0;this.K=new Path2D}Za(l){for(0<this.$&&this.Z<l.length&&this.clear();this.Z<l.length;)l[this.Z++](this.K);this.$++;return this.K}release(l){l===this.K&&this.$--}}var L=e.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.ja=[];this.K=new q;this.ia=!1;this.S=null},rewind:function(){this.ja.length=0;this.K.clear();this.ia=!1;this.S=null},addPath:function(l,
374
- p,A,t,G,B,C){const y=l.Sa();this.R(F=>{const H=new DOMMatrix;H.a=p;H.b=A;H.c=t;H.d=G;H.e=B;H.f=C;F.addPath(y,H)})},fillRule:function(l){this.xa=l},moveTo:function(l,p){this.ia=!0;const A={Ca:!0};this.S=A;this.R(t=>{t.moveTo(l,p);A.Ca&&t.lineTo(l,p)})},lineTo:function(l,p){this.wa();this.ga();this.R(A=>{A.lineTo(l,p)})},cubicTo:function(l,p,A,t,G,B){this.wa();this.ga();this.R(C=>{C.bezierCurveTo(l,p,A,t,G,B)})},close:function(){this.ga();this.R(l=>{l.closePath()})},wa:function(){this.ia||this.moveTo(0,
375
- 0)},ga:function(){null!==this.S&&(this.S.Ca=!1,this.S=null)},R:function(l){this.ja.push(l)},fa:function(){return this.K.Za(this.ja)},za:function(l){this.K.release(l)},Sa:function(){const l=this.fa();this.K.clear();return l}}),I=k.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.B=[];this.ha=0;this.ka=r;this.oa=a(4278190080);this.ma=1;this.Y="miter";this.X="butt";this.ua=b(n.srcOver);this.N=null},color:function(l){this.B.push(()=>{this.oa=a(l)})},thickness:function(l){this.B.push(()=>
376
- {this.ma=Math.abs(l)})},join:function(l){this.B.push(()=>{switch(l){case m.miter:this.Y="miter";break;case m.round:this.Y="round";break;case m.bevel:this.Y="bevel"}})},cap:function(l){this.B.push(()=>{switch(l){case f.butt:this.X="butt";break;case f.round:this.X="round";break;case f.square:this.X="square"}})},style:function(l){this.B.push(()=>{this.ka=l})},blendMode:function(l){this.B.push(()=>{this.ua=b(l)})},clearGradient:function(){this.B.push(()=>{this.N=null})},linearGradient:function(l,p,A,
377
- t){this.B.push(()=>{this.N={Oa:l,Pa:p,Ea:A,Fa:t,sa:[]}})},radialGradient:function(l,p,A,t){this.B.push(()=>{this.N={Oa:l,Pa:p,Ea:A,Fa:t,sa:[],pb:!0}})},addStop:function(l,p){this.B.push(()=>{this.N.sa.push({color:l,stop:p})})},completeGradient:function(){},Ta:function(l,p,A,t){if(this.ka!==w||0<this.ma){var G=this.ka,B=this.oa,C=this.N,y=l.globalCompositeOperation,F=l.globalAlpha;l.globalCompositeOperation=this.ua;l.globalAlpha=t;if(null!=C){B=C.Oa;const O=C.Pa,Q=C.Ea;var H=C.Fa;t=C.sa;C.pb?(C=Q-
378
- B,H-=O,B=l.createRadialGradient(B,O,0,B,O,Math.sqrt(C*C+H*H))):B=l.createLinearGradient(B,O,Q,H);for(let S=0,Ca=t.length;S<Ca;S++)C=t[S],B.addColorStop(C.stop,a(C.color));this.oa=B;this.N=null}switch(G){case w:l.strokeStyle=B;l.lineWidth=this.ma;l.lineCap=this.X;l.lineJoin=this.Y;l.stroke(p);break;case r:l.fillStyle=B,l.fill(p,A)}l.globalCompositeOperation=y;l.globalAlpha=F}},Va:function(){return this.ha+this.B.length},Ua:function(l){const p=l-this.ha;for(let A=0;A<p;A++)this.B[A]();this.B.splice(0,
379
- p);this.ha=l}});const u=new Set,J=Object.prototype.hasOwnProperty;let K=null,R=[],X=0,E=0;var ba=h.CanvasRenderer=g.extend("Renderer",{__construct:function(l){this.__parent.__construct.call(this);this.J=[1,0,0,1,0,0];this.A=[1];this.u=l.getContext("2d");this.va=l;this.D=[]},save:function(){this.J.push(...this.J.slice(this.J.length-6));this.A.push(this.A[this.A.length-1]);this.D.push(this.u.save.bind(this.u))},restore:function(){const l=this.J.length-6;if(6>l)throw"restore() called without matching save().";
380
- this.J.splice(l);this.A.pop();this.D.push(this.u.restore.bind(this.u))},transform:function(l,p,A,t,G,B){const C=this.J,y=C.length-6;C.splice(y,6,C[y]*l+C[y+2]*p,C[y+1]*l+C[y+3]*p,C[y]*A+C[y+2]*t,C[y+1]*A+C[y+3]*t,C[y]*G+C[y+2]*B+C[y+4],C[y+1]*G+C[y+3]*B+C[y+5]);this.D.push(this.u.transform.bind(this.u,l,p,A,t,G,B))},rotate:function(l){const p=Math.sin(l);l=Math.cos(l);this.transform(l,p,-p,l,0,0)},modulateOpacity:function(l){this.A[this.A.length-1]*=l},_drawPath:function(l,p){const A=l.xa===z?"evenodd":
381
- "nonzero",t=Math.max(0,this.A[this.A.length-1]),G=l.fa(),B=p.Va();this.D.push(()=>{p.Ua(B);p.Ta(this.u,G,A,t);l.za(G)})},_drawRiveImage:function(l,p,A){var t=l.Wa;if(t){var G=this.u,B=b(p),C=Math.max(0,A*this.A[this.A.length-1]);this.D.push(function(){G.globalCompositeOperation=B;G.globalAlpha=C;G.drawImage(t,0,0);G.globalAlpha=1})}},_getMatrix:function(l){const p=this.J,A=p.length-6;for(let t=0;6>t;++t)l[t]=p[A+t]},_drawImageMesh:function(l,p,A,t,G,B,C,y,F,H,O,Q,S){let Ca,rb,sb;try{Ca=h.HEAPF32.slice(t>>
382
- 2,(t>>2)+G),rb=h.HEAPF32.slice(B>>2,(B>>2)+C),sb=h.HEAPU16.slice(y>>1,(y>>1)+F)}catch(Ta){console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame.");return}t=this.u.canvas.width;B=this.u.canvas.height;C=Q-H;y=S-O;H=Math.max(H,0);O=Math.max(O,0);Q=Math.min(Q,t);S=Math.min(S,B);const ra=Q-H,sa=S-O;console.assert(ra<=Math.min(C,t));console.assert(sa<=Math.min(y,B));if(!(0>=ra||0>=sa)){Q=ra<C||sa<y;t=S=1;var fa=Math.ceil(ra*S),ha=Math.ceil(sa*t);B=la.rb();
383
- fa>B&&(S*=B/fa,fa=B);ha>B&&(t*=B/ha,ha=B);K||(K=new h.DynamicRectanizer(B),K.reset(512,512));B=K.addRect(fa,ha);0>B&&(c(),u.add(this),B=K.addRect(fa,ha),console.assert(0<=B));var tb=B&65535,ub=B>>16;R.push({O:this.J.slice(this.J.length-6),image:l,Aa:tb,Ba:ub,sb:H,tb:O,Bb:fa,Ha:ha,da:S,ea:t,ta:Ca,Qa:rb,indices:sb,ub:Q,Na:l.na<<1|(Q?1:0)});X+=G;E+=F;var ja=this.u,dc=b(p),ec=Math.max(0,A*this.A[this.A.length-1]);this.D.push(function(){ja.save();ja.resetTransform();ja.globalCompositeOperation=dc;ja.globalAlpha=
384
- ec;const Ta=la.canvas();Ta&&ja.drawImage(Ta,tb,ub,fa,ha,H,O,ra,sa);ja.restore()})}},_clipPath:function(l){const p=l.xa===z?"evenodd":"nonzero",A=l.fa();this.D.push(()=>{this.u.clip(A,p);l.za(A)})},beginFrame:function(l=!0){u.add(this);l&&this.D.push(this.u.clearRect.bind(this.u,0,0,this.va.width,this.va.height))},clear:function(){this.beginFrame(!0)},flush:function(){},translate:function(l,p){this.transform(1,0,0,1,l,p)}});h.makeRenderer=function(l){const p=new ba(l),A=p.u;let t=null,G=null;const B=
385
- {attachSession:function(y){if(y&&t===y)return!0;if(!y||t||"function"!==typeof h.c2dDeferredClaim||"function"!==typeof h.c2dDeferredRenderer||!h.c2dDeferredClaim(y))return!1;const F=h.c2dDeferredRenderer(y);if(!F)return!1;t=y;G=F;return!0},detachSession:function(){t&&h.c2dDeferredDetach(t);G=t=null},deferredActive:function(){return null!==G}},C={save:function(){h.c2dDeferredSave(t)},restore:function(){h.c2dDeferredRestore(t)},transform:function(y,F,H,O,Q,S){h.c2dDeferredTransform(t,y,F,H,O,Q,S)},translate:function(y,
386
- F){h.c2dDeferredTransform(t,1,0,0,1,y,F)},rotate:function(y){const F=Math.sin(y);y=Math.cos(y);h.c2dDeferredTransform(t,y,F,-F,y,0,0)},align:function(y,F,H,O,Q){h.c2dDeferredAlign(t,y,F,H.minX,H.minY,H.maxX,H.maxY,O.minX,O.minY,O.maxX,O.maxY,void 0===Q?1:Q)},beginFrame:function(y=!0){p.beginFrame(y);h.c2dDeferredBeginFrame(t)},clear:function(){p.beginFrame(!0);h.c2dDeferredBeginFrame(t)},flush:function(){h.c2dDeferredReplay(t,p)}};return new Proxy(p,{get(y,F){if(J.call(B,F))return B[F];if("_deferredRecorder"===
387
- F)return G;if(null!==G&&J.call(C,F))return C[F];if("function"===typeof y[F])return function(...H){return y[F].apply(y,H)};if("function"===typeof A[F]){if(-1<ka.indexOf(F))throw Error("RiveException: Method call to '"+F+"()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");return function(...H){p.D.push(A[F].bind(A,...H))}}return y[F]},set(y,F,H){if(F in A)return p.D.push(()=>{A[F]=H}),!0}})};h.decodeImage=function(l,
388
- p){(new x({U:p})).decode(l)};h.renderFactory={makeRenderPaint:function(){return new I},makeRenderPath:function(){return new L},makeRenderImage:function(){let l=Ua;return new x({ca:()=>{l.total++},U:()=>{l.loaded++;if(l.loaded===l.total){const p=l.ready;p&&(p(),l.ready=null)}}})}};let fc=h.load,Ua=null;h.load=function(l,p,A=!0,t=null){const G=new h.FallbackFileAssetLoader;void 0!==p&&G.addLoader(p);A&&(p=new h.CDNFileAssetLoader(t),G.addLoader(p));return new Promise(function(B){let C=null;Ua={total:0,
389
- loaded:0,ready:function(){B(C)}};C=fc(l,G,t??null);0==Ua.total&&B(C)})};const gc=h.Artboard.prototype.draw;h.Artboard.prototype.draw=function(l){gc.call(this,l._deferredRecorder||l)};let hc=h.RendererWrapper.prototype.align;h.RendererWrapper.prototype.align=function(l,p,A,t,G=1){hc.call(this,l,p,A,t,G)};d=new da;h.requestAnimationFrame=d.requestAnimationFrame.bind(d);h.cancelAnimationFrame=d.cancelAnimationFrame.bind(d);h.enableFPSCounter=d.gb.bind(d);h.disableFPSCounter=d.cb;d.Ja=c;h.resolveAnimationFrame=
390
- c;h.cleanup=function(){K&&K.delete()}};var na="./this.program";ca&&(_scriptName=self.location.href);var oa="",pa,qa;
391
- if(aa||ca){try{oa=(new URL(".",_scriptName)).href}catch{}ca&&(qa=b=>{var a=new XMLHttpRequest;a.open("GET",b,!1);a.responseType="arraybuffer";a.send(null);return new Uint8Array(a.response)});pa=async b=>{if(ta(b))return new Promise((c,d)=>{var e=new XMLHttpRequest;e.open("GET",b,!0);e.responseType="arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?c(e.response):d(e.status)};e.onerror=d;e.send(null)});var a=await fetch(b,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+
392
- " : "+a.url);}}var ua=console.log.bind(console),va=console.error.bind(console),wa,xa=!1,ya,ta=b=>b.startsWith("file://"),za,Aa,Ba,D,Da,Ea,Fa,M,Ga,Ha,Ia=!1;function Ja(){var b=Ka.buffer;h.HEAP8=Ba=new Int8Array(b);Da=new Int16Array(b);h.HEAPU8=D=new Uint8Array(b);h.HEAPU16=Ea=new Uint16Array(b);h.HEAP32=Fa=new Int32Array(b);h.HEAPU32=M=new Uint32Array(b);h.HEAPF32=Ga=new Float32Array(b);Ha=new Float64Array(b)}
393
- function La(b){h.onAbort?.(b);b="Aborted("+b+")";va(b);xa=!0;b=new WebAssembly.RuntimeError(b+". Build with -sASSERTIONS for more info.");Aa?.(b);throw b;}var Ma;async function Na(b){if(!wa)try{var a=await pa(b);return new Uint8Array(a)}catch{}if(b==Ma&&wa)b=new Uint8Array(wa);else if(qa)b=qa(b);else throw"both async and sync fetching of the wasm failed";return b}
394
- async function Oa(b,a){try{var c=await Na(b);return await WebAssembly.instantiate(c,a)}catch(d){va(`failed to asynchronously prepare wasm: ${d}`),La(d)}}async function Pa(b){var a=Ma;if(!wa&&!ta(a))try{var c=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,b)}catch(d){va(`wasm streaming compile failed: ${d}`),va("falling back to ArrayBuffer instantiation")}return Oa(a,b)}var Qa,Ra;
395
- class Sa{name="ExitStatus";constructor(b){this.message=`Program terminated with exit(${b})`;this.status=b}}
396
- var Va=b=>{for(;0<b.length;)b.shift()(h)},Wa=[],Xa=[],Ya=()=>{var b=h.preRun.shift();Xa.push(b)},Za=!0,$a=(b,a)=>Object.defineProperty(a,"name",{value:b}),ab=[],bb=[0,1,,1,null,1,!0,1,!1,1],N=class extends Error{constructor(b){super(b);this.name="BindingError"}},P=b=>{if(!b)throw new N(`Cannot use deleted val. handle = ${b}`);return bb[b]},T=b=>{switch(b){case void 0:return 2;case null:return 4;case !0:return 6;case !1:return 8;default:const a=ab.pop()||bb.length;bb[a]=b;bb[a+1]=1;return a}};
397
- class cb extends Error{}
398
- var U=b=>{for(var a="";;){var c=D[b++];if(!c)return a;a+=String.fromCharCode(c)}},db={},eb=(b,a)=>{if(void 0===a)throw new N("ptr should not be undefined");for(;b.s;)a=b.V(a),b=b.s;return a},fb={},ib=b=>{b=gb(b);var a=U(b);hb(b);return a},jb=(b,a)=>{var c=fb[b];if(void 0===c)throw b=`${a} has unknown type ${ib(b)}`,new N(b);return c},kb=()=>{},lb=!1,mb=b=>{if(!globalThis.FinalizationRegistry)return mb=a=>a,b;lb=new FinalizationRegistry(a=>{a=a.g;--a.count.value;0===a.count.value&&(a.v?a.G.I(a.v):
399
- a.l.h.I(a.j))});mb=a=>{var c=a.g;c.v&&lb.register(a,{g:c},a);return a};kb=a=>{lb.unregister(a)};return mb(b)},nb={},ob=b=>{for(;b.length;){var a=b.pop();b.pop()(a)}};function pb(b){return this.i(M[b>>2])}
400
- var qb={},vb={},wb=class extends Error{constructor(b){super(b);this.name="InternalError"}},W=(b,a,c)=>{function d(f){f=c(f);if(f.length!==b.length)throw new wb("Mismatched type converter count");for(var m=0;m<b.length;++m)V(b[m],f[m])}b.forEach(f=>vb[f]=a);var e=Array(a.length),k=[],g=0;for(let [f,m]of a.entries())fb.hasOwnProperty(m)?e[f]=fb[m]:(k.push(m),qb.hasOwnProperty(m)||(qb[m]=[]),qb[m].push(()=>{e[f]=fb[m];++g;g===k.length&&d(e)}));0===k.length&&d(e)};
401
- function xb(b,a,c={}){var d=a.name;if(!b)throw new N(`type "${d}" must have a positive integer typeid pointer`);if(fb.hasOwnProperty(b)){if(c.ob)return;throw new N(`Cannot register type '${d}' twice`);}fb[b]=a;delete vb[b];qb.hasOwnProperty(b)&&(a=qb[b],delete qb[b],a.forEach(e=>e()))}function V(b,a,c={}){return xb(b,a,c)}var yb=b=>{throw new N(b.g.l.h.name+" instance already deleted");},zb=[];function Ab(){}
402
- var Bb={},Cb=(b,a,c)=>{if(void 0===b[a].m){var d=b[a];b[a]=function(...e){if(!b[a].m.hasOwnProperty(e.length))throw new N(`Function '${c}' called with an invalid number of arguments (${e.length}) - expects one of (${b[a].m})!`);return b[a].m[e.length].apply(this,e)};b[a].m=[];b[a].m[d.L]=d}},Db=(b,a,c)=>{if(h.hasOwnProperty(b)){if(void 0===c||void 0!==h[b].m&&void 0!==h[b].m[c])throw new N(`Cannot register public name '${b}' twice`);Cb(h,b,b);if(h[b].m.hasOwnProperty(c))throw new N(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);
403
- h[b].m[c]=a}else h[b]=a,h[b].L=c},Eb=b=>{b=b.replace(/[^a-zA-Z0-9_]/g,"$");var a=b.charCodeAt(0);return 48<=a&&57>=a?`_${b}`:b};function Fb(b,a,c,d,e,k,g,f){this.name=b;this.constructor=a;this.H=c;this.I=d;this.s=e;this.jb=k;this.V=g;this.eb=f;this.Ka=[]}
404
- var Gb=(b,a,c)=>{for(;a!==c;){if(!a.V)throw new N(`Expected null or instance of ${c.name}, got an instance of ${a.name}`);b=a.V(b);a=a.s}return b},Hb=b=>{if(null===b)return"null";var a=typeof b;return"object"===a||"array"===a||"function"===a?b.toString():""+b};
405
- function Ib(b,a){if(null===a){if(this.pa)throw new N(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new N(`Cannot pass "${Hb(a)}" as a ${this.name}`);if(!a.g.j)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);return Gb(a.g.j,a.g.l.h,this.h)}
406
- function Jb(b,a){if(null===a){if(this.pa)throw new N(`null is not a valid ${this.name}`);if(this.ba){var c=this.ra();null!==b&&b.push(this.I,c);return c}return 0}if(!a||!a.g)throw new N(`Cannot pass "${Hb(a)}" as a ${this.name}`);if(!a.g.j)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.aa&&a.g.l.aa)throw new N(`Cannot convert argument of type ${a.g.G?a.g.G.name:a.g.l.name} to parameter type ${this.name}`);c=Gb(a.g.j,a.g.l.h,this.h);if(this.ba){if(void 0===a.g.v)throw new N("Passing raw pointer to smart pointer is illegal");
407
- switch(this.Ab){case 0:if(a.g.G===this)c=a.g.v;else throw new N(`Cannot convert argument of type ${a.g.G?a.g.G.name:a.g.l.name} to parameter type ${this.name}`);break;case 1:c=a.g.v;break;case 2:if(a.g.G===this)c=a.g.v;else{var d=a.clone();c=this.wb(c,T(()=>d["delete"]()));null!==b&&b.push(this.I,c)}break;default:throw new N("Unsupported sharing policy");}}return c}
408
- function Kb(b,a){if(null===a){if(this.pa)throw new N(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new N(`Cannot pass "${Hb(a)}" as a ${this.name}`);if(!a.g.j)throw new N(`Cannot pass deleted object as a pointer of type ${this.name}`);if(a.g.l.aa)throw new N(`Cannot convert argument of type ${a.g.l.name} to parameter type ${this.name}`);return Gb(a.g.j,a.g.l.h,this.h)}
409
- var Lb=(b,a,c)=>{if(a===c)return b;if(void 0===c.s)return null;b=Lb(b,a,c.s);return null===b?null:c.eb(b)},Mb=(b,a)=>{a=eb(b,a);return db[a]},Nb=(b,a)=>{if(!a.l||!a.j)throw new wb("makeClassHandle requires ptr and ptrType");if(!!a.G!==!!a.v)throw new wb("Both smartPtrType and smartPtr must be specified");a.count={value:1};return mb(Object.create(b,{g:{value:a,writable:!0}}))};
410
- function Ob(b,a,c,d,e,k,g,f,m,n,r){this.name=b;this.h=a;this.pa=c;this.aa=d;this.ba=e;this.vb=k;this.Ab=g;this.La=f;this.ra=m;this.wb=n;this.I=r;e||void 0!==a.s?this.o=Jb:(this.o=d?Ib:Kb,this.C=null)}
411
- var Pb=(b,a,c)=>{if(!h.hasOwnProperty(b))throw new wb("Replacing nonexistent public symbol");void 0!==h[b].m&&void 0!==c?h[b].m[c]=a:(h[b]=a,h[b].L=c)},Y={},Rb=(b,a,c=[])=>{b.includes("j")?(b=b.replace(/p/g,"i"),a=(0,Y[b])(a,...c)):a=Qb.get(a)(...c);return a},Sb=(b,a)=>(...c)=>Rb(b,a,c),Z=(b,a)=>{b=U(b);var c=b.includes("j")?Sb(b,a):Qb.get(a);if("function"!=typeof c)throw new N(`unknown function pointer with signature ${b}: ${a}`);return c};class Tb extends Error{}
412
- var Ub=(b,a)=>{function c(k){e[k]||fb[k]||(vb[k]?vb[k].forEach(c):(d.push(k),e[k]=!0))}var d=[],e={};a.forEach(c);throw new Tb(`${b}: `+d.map(ib).join([", "]));};function Vb(b){for(var a=1;a<b.length;++a)if(null!==b[a]&&void 0===b[a].C)return!0;return!1}
413
- function Wb(b,a,c,d,e){var k=a.length;if(2>k)throw new N("argTypes array size mismatch! Must at least get return value and 'this' types!");var g=null!==a[1]&&null!==c,f=Vb(a),m=!a[0].qb,n=k-2,r=Array(n),w=[],z=[];return $a(b,function(...v){z.length=0;w.length=g?2:1;w[0]=e;if(g){var x=a[1].o(z,this);w[1]=x}for(var q=0;q<n;++q)r[q]=a[q+2].o(z,v[q]),w.push(r[q]);v=d(...w);if(f)ob(z);else for(q=g?1:2;q<a.length;q++){var L=1===q?x:r[q-2];null!==a[q].C&&a[q].C(L)}x=m?a[0].i(v):void 0;return x})}
414
- var Xb=(b,a)=>{for(var c=[],d=0;d<b;d++)c.push(M[a+4*d>>2]);return c},Yb=b=>{b=b.trim();const a=b.indexOf("(");return-1===a?b:b.slice(0,a)},Zb=(b,a,c)=>{if(!(b instanceof Object))throw new N(`${c} with invalid "this": ${b}`);if(!(b instanceof a.h.constructor))throw new N(`${c} incompatible with "this" of type ${b.constructor.name}`);if(!b.g.j)throw new N(`cannot call emscripten binding method ${c} on deleted object`);return Gb(b.g.j,b.g.l.h,a.h)},$b=b=>{9<b&&0===--bb[b+1]&&(bb[b]=void 0,ab.push(b))},
415
- ac={name:"emscripten::val",i:b=>{var a=P(b);$b(b);return a},o:(b,a)=>T(a),F:pb,C:null},bc=(b,a,c)=>{switch(a){case 1:return c?function(d){return this.i(Ba[d])}:function(d){return this.i(D[d])};case 2:return c?function(d){return this.i(Da[d>>1])}:function(d){return this.i(Ea[d>>1])};case 4:return c?function(d){return this.i(Fa[d>>2])}:function(d){return this.i(M[d>>2])};default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},cc=(b,a)=>{switch(a){case 4:return function(c){return this.i(Ga[c>>
416
- 2])};case 8:return function(c){return this.i(Ha[c>>3])};default:throw new TypeError(`invalid float width (${a}): ${b}`);}},ic=(b,a,c)=>{switch(a){case 1:return c?d=>Ba[d]:d=>D[d];case 2:return c?d=>Da[d>>1]:d=>Ea[d>>1];case 4:return c?d=>Fa[d>>2]:d=>M[d>>2];default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},jc=(b,a,c)=>{var d=D;if(!(0<c))return 0;var e=a;c=a+c-1;for(var k=0;k<b.length;++k){var g=b.codePointAt(k);if(127>=g){if(a>=c)break;d[a++]=g}else if(2047>=g){if(a+1>=c)break;
417
- d[a++]=192|g>>6;d[a++]=128|g&63}else if(65535>=g){if(a+2>=c)break;d[a++]=224|g>>12;d[a++]=128|g>>6&63;d[a++]=128|g&63}else{if(a+3>=c)break;d[a++]=240|g>>18;d[a++]=128|g>>12&63;d[a++]=128|g>>6&63;d[a++]=128|g&63;k++}}d[a]=0;return a-e},kc=b=>{for(var a=0,c=0;c<b.length;++c){var d=b.charCodeAt(c);127>=d?a++:2047>=d?a+=2:55296<=d&&57343>=d?(a+=4,++c):a+=3}return a},lc=globalThis.TextDecoder&&new TextDecoder,mc=(b,a,c,d)=>{c=a+c;if(d)return c;for(;b[a]&&!(a>=c);)++a;return a},nc=(b,a=0,c,d)=>{c=mc(b,
418
- a,c,d);if(16<c-a&&b.buffer&&lc)return lc.decode(b.subarray(a,c));for(d="";a<c;){var e=b[a++];if(e&128){var k=b[a++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|k);else{var g=b[a++]&63;e=224==(e&240)?(e&15)<<12|k<<6|g:(e&7)<<18|k<<12|g<<6|b[a++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d},oc=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,pc=(b,a,c)=>{b>>=1;a=mc(Ea,b,a/2,c);if(16<a-b&&oc)return oc.decode(Ea.subarray(b,
419
- a));for(c="";b<a;++b)c+=String.fromCharCode(Ea[b]);return c},qc=(b,a,c)=>{c??=2147483647;if(2>c)return 0;c-=2;var d=a;c=c<2*b.length?c/2:b.length;for(var e=0;e<c;++e)Da[a>>1]=b.charCodeAt(e),a+=2;Da[a>>1]=0;return a-d},rc=b=>2*b.length,sc=(b,a,c)=>{var d="";b>>=2;for(var e=0;!(e>=a/4);e++){var k=M[b+e];if(!k&&!c)break;d+=String.fromCodePoint(k)}return d},tc=(b,a,c)=>{c??=2147483647;if(4>c)return 0;var d=a;c=d+c-4;for(var e=0;e<b.length;++e){var k=b.codePointAt(e);65535<k&&e++;Fa[a>>2]=k;a+=4;if(a+
420
- 4>c)break}Fa[a>>2]=0;return a-d},uc=b=>{for(var a=0,c=0;c<b.length;++c)65535<b.codePointAt(c)&&c++,a+=4;return a},vc=0,wc=[],xc=b=>{var a=wc.length;wc.push(b);return a},yc=(b,a)=>{for(var c=Array(b),d=0;d<b;++d)c[d]=jb(M[a+4*d>>2],`parameter ${d}`);return c},zc={},Ac=b=>{var a=zc[b];return void 0===a?U(b):a},Bc={},Cc=b=>{if(!(b instanceof Sa||"unwind"==b))throw b;},Dc=b=>{ya=b;Za||0<vc||(h.onExit?.(b),xa=!0);throw new Sa(b);},Ec=b=>{if(!xa)try{if(b(),!(Za||0<vc))try{ya=b=ya,Dc(b)}catch(a){Cc(a)}}catch(a){Cc(a)}},
421
- Fc={},Hc=()=>{if(!Gc){var b={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:na||"./this.program"},a;for(a in Fc)void 0===Fc[a]?delete b[a]:b[a]=Fc[a];var c=[];for(a in b)c.push(`${a}=${b[a]}`);Gc=c}return Gc},Gc,Ic=[null,[],[]];
422
- (()=>{let b=Ab.prototype;Object.assign(b,{isAliasOf:function(c){if(!(this instanceof Ab&&c instanceof Ab))return!1;var d=this.g.l.h,e=this.g.j;c.g=c.g;var k=c.g.l.h;for(c=c.g.j;d.s;)e=d.V(e),d=d.s;for(;k.s;)c=k.V(c),k=k.s;return d===k&&e===c},clone:function(){this.g.j||yb(this);if(this.g.P)return this.g.count.value+=1,this;var c=mb,d=Object,e=d.create,k=Object.getPrototypeOf(this),g=this.g;c=c(e.call(d,k,{g:{value:{count:g.count,T:g.T,P:g.P,j:g.j,l:g.l,v:g.v,G:g.G}}}));c.g.count.value+=1;c.g.T=!1;
423
- return c},["delete"](){this.g.j||yb(this);if(this.g.T&&!this.g.P)throw new N("Object already scheduled for deletion");kb(this);var c=this.g;--c.count.value;0===c.count.value&&(c.v?c.G.I(c.v):c.l.h.I(c.j));this.g.P||(this.g.v=void 0,this.g.j=void 0)},isDeleted:function(){return!this.g.j},deleteLater:function(){this.g.j||yb(this);if(this.g.T&&!this.g.P)throw new N("Object already scheduled for deletion");zb.push(this);this.g.T=!0;return this}});const a=Symbol.dispose;a&&(b[a]=b["delete"])})();
424
- Object.assign(Ob.prototype,{kb(b){this.La&&(b=this.La(b));return b},Da(b){this.I?.(b)},F:pb,i:function(b){function a(){return this.ba?Nb(this.h.H,{l:this.vb,j:c,G:this,v:b}):Nb(this.h.H,{l:this,j:b})}var c=this.kb(b);if(!c)return this.Da(b),null;var d=Mb(this.h,c);if(void 0!==d){if(0===d.g.count.value)return d.g.j=c,d.g.v=b,d.clone();d=d.clone();this.Da(b);return d}d=this.h.jb(c);d=Bb[d];if(!d)return a.call(this);d=this.aa?d.$a:d.pointerType;var e=Lb(c,this.h,d.h);return null===e?a.call(this):this.ba?
425
- Nb(d.h.H,{l:d,j:e,G:this,v:b}):Nb(d.h.H,{l:d,j:e})}});h.noExitRuntime&&(Za=h.noExitRuntime);h.print&&(ua=h.print);h.printErr&&(va=h.printErr);h.wasmBinary&&(wa=h.wasmBinary);h.thisProgram&&(na=h.thisProgram);if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.shift()();
426
- var hb,Jc,gb,Kc,Ka,Qb,Lc={_abort_js:()=>La(""),_embind_create_inheriting_constructor:(b,a,c)=>{b=U(b);a=jb(a,"wrapper");c=P(c);var d=a.h,e=d.H,k=d.s.H,g=d.s.constructor;b=$a(b,function(...f){for(var m of d.s.Ka)if(this[m]===k[m])throw new cb(`Pure virtual function ${m} must be implemented in JavaScript`);Object.defineProperty(this,"__parent",{value:e});this.__construct(...f)});e.__construct=function(...f){if(this===e)throw new N("Pass correct 'this' to __construct");f=g.implement(this,...f);kb(f);
427
- var m=f.g;f.notifyOnDestruction();m.P=!0;Object.defineProperties(this,{g:{value:m}});mb(this);f=m.j;f=eb(d,f);if(db.hasOwnProperty(f))throw new N(`Tried to register registered instance: ${f}`);db[f]=this};e.__destruct=function(){if(this===e)throw new N("Pass correct 'this' to __destruct");kb(this);var f=this.g.j;f=eb(d,f);if(db.hasOwnProperty(f))delete db[f];else throw new N(`Tried to unregister unregistered instance: ${f}`);};b.prototype=Object.create(e);Object.assign(b.prototype,c);return T(b)},
428
- _embind_finalize_value_object:b=>{var a=nb[b];delete nb[b];var c=a.ra,d=a.I,e=a.Ga,k=e.map(g=>g.nb).concat(e.map(g=>g.yb));W([b],k,g=>{var f={},m,n;for([m,n]of e.entries()){const r=g[m],w=n.lb,z=n.mb,v=g[m+e.length],x=n.xb,q=n.zb;f[n.hb]={read:L=>r.i(w(z,L)),write:(L,I)=>{var u=[];x(q,L,v.o(u,I));ob(u)},optional:r.optional}}return[{name:a.name,i:r=>{var w={},z;for(z in f)w[z]=f[z].read(r);d(r);return w},o:(r,w)=>{for(var z in f)if(!(z in w||f[z].optional))throw new TypeError(`Missing field: "${z}"`);
429
- var v=c();for(z in f)f[z].write(v,w[z]);null!==r&&r.push(d,v);return v},F:pb,C:d}]})},_embind_register_bigint:()=>{},_embind_register_bool:(b,a,c,d)=>{a=U(a);V(b,{name:a,i:function(e){return!!e},o:function(e,k){return k?c:d},F:function(e){return this.i(D[e])},C:null})},_embind_register_class:(b,a,c,d,e,k,g,f,m,n,r,w,z)=>{r=U(r);k=Z(e,k);f&&=Z(g,f);n&&=Z(m,n);z=Z(w,z);var v=Eb(r);Db(v,function(){Ub(`Cannot construct ${r} due to unbound types`,[d])});W([b,a,c],d?[d]:[],x=>{x=x[0];if(d){var q=x.h;var L=
430
- q.H}else L=Ab.prototype;x=$a(r,function(...K){if(Object.getPrototypeOf(this)!==I)throw new N(`Use 'new' to construct ${r}`);if(void 0===u.M)throw new N(`${r} has no accessible constructor`);var R=u.M[K.length];if(void 0===R)throw new N(`Tried to invoke ctor of ${r} with invalid number of parameters (${K.length}) - expected (${Object.keys(u.M).toString()}) parameters instead!`);return R.apply(this,K)});var I=Object.create(L,{constructor:{value:x}});x.prototype=I;var u=new Fb(r,x,I,z,q,k,f,n);if(u.s){var J;
431
- (J=u.s).W??(J.W=[]);u.s.W.push(u)}q=new Ob(r,u,!0,!1,!1);J=new Ob(r+"*",u,!1,!1,!1);L=new Ob(r+" const*",u,!1,!0,!1);Bb[b]={pointerType:J,$a:L};Pb(v,x);return[q,J,L]})},_embind_register_class_class_function:(b,a,c,d,e,k,g)=>{var f=Xb(c,d);a=U(a);a=Yb(a);k=Z(e,k);W([],[b],m=>{function n(){Ub(`Cannot call ${r} due to unbound types`,f)}m=m[0];var r=`${m.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);var w=m.h.constructor;void 0===w[a]?(n.L=c-1,w[a]=n):(Cb(w,a,r),w[a].m[c-1]=n);W([],f,z=>
432
- {z=Wb(r,[z[0],null].concat(z.slice(1)),null,k,g);void 0===w[a].m?(z.L=c-1,w[a]=z):w[a].m[c-1]=z;if(m.h.W)for(const v of m.h.W)v.constructor.hasOwnProperty(a)||(v.constructor[a]=z);return[]});return[]})},_embind_register_class_class_property:(b,a,c,d,e,k,g,f)=>{a=U(a);k=Z(e,k);W([],[b],m=>{m=m[0];var n=`${m.name}.${a}`,r={get(){Ub(`Cannot access ${n} due to unbound types`,[c])},enumerable:!0,configurable:!0};r.set=f?()=>{Ub(`Cannot access ${n} due to unbound types`,[c])}:()=>{throw new N(`${n} is a read-only property`);
433
- };Object.defineProperty(m.h.constructor,a,r);W([],[c],w=>{w=w[0];var z={get(){return w.i(k(d))},enumerable:!0};f&&(f=Z(g,f),z.set=v=>{var x=[];f(d,w.o(x,v));ob(x)});Object.defineProperty(m.h.constructor,a,z);return[]});return[]})},_embind_register_class_constructor:(b,a,c,d,e,k)=>{var g=Xb(a,c);e=Z(d,e);W([],[b],f=>{f=f[0];var m=`constructor ${f.name}`;void 0===f.h.M&&(f.h.M=[]);if(void 0!==f.h.M[a-1])throw new N(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
434
- f.h.M[a-1]=()=>{Ub(`Cannot construct ${f.name} due to unbound types`,g)};W([],g,n=>{n.splice(1,0,null);f.h.M[a-1]=Wb(m,n,null,e,k);return[]});return[]})},_embind_register_class_function:(b,a,c,d,e,k,g,f)=>{var m=Xb(c,d);a=U(a);a=Yb(a);k=Z(e,k);W([],[b],n=>{function r(){Ub(`Cannot call ${w} due to unbound types`,m)}n=n[0];var w=`${n.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);f&&n.h.Ka.push(a);var z=n.h.H,v=z[a];void 0===v||void 0===v.m&&v.className!==n.name&&v.L===c-2?(r.L=c-2,r.className=
435
- n.name,z[a]=r):(Cb(z,a,w),z[a].m[c-2]=r);W([],m,x=>{x=Wb(w,x,n,k,g);void 0===z[a].m?(x.L=c-2,z[a]=x):z[a].m[c-2]=x;return[]});return[]})},_embind_register_class_property:(b,a,c,d,e,k,g,f,m,n)=>{a=U(a);e=Z(d,e);W([],[b],r=>{r=r[0];var w=`${r.name}.${a}`,z={get(){Ub(`Cannot access ${w} due to unbound types`,[c,g])},enumerable:!0,configurable:!0};z.set=m?()=>Ub(`Cannot access ${w} due to unbound types`,[c,g]):()=>{throw new N(w+" is a read-only property");};Object.defineProperty(r.h.H,a,z);W([],m?[c,
436
- g]:[c],v=>{var x=v[0],q={get(){var I=Zb(this,r,w+" getter");return x.i(e(k,I))},enumerable:!0};if(m){m=Z(f,m);var L=v[1];q.set=function(I){var u=Zb(this,r,w+" setter"),J=[];m(n,u,L.o(J,I));ob(J)}}Object.defineProperty(r.h.H,a,q);return[]});return[]})},_embind_register_emval:b=>V(b,ac),_embind_register_enum:(b,a,c,d,e)=>{a=U(a);e=0===e?"object":1===e?"number":"string";switch(e){case "object":function g(){}g.values={};V(b,{name:a,constructor:g,valueType:e,i:function(f){return this.constructor.values[f]},
437
- o:(f,m)=>m.value,F:bc(a,c,d),C:null});Db(a,g);break;case "number":var k={};V(b,{name:a,qa:k,valueType:e,i:f=>f,o:(f,m)=>m,F:bc(a,c,d),C:null});Db(a,k);delete h[a].L;break;case "string":k={},V(b,{name:a,Ra:{},Ma:{},qa:k,valueType:e,i:function(f){return this.Ma[f]},o:function(f,m){return this.Ra[m]},F:bc(a,c,d),C:null}),Db(a,k),delete h[a].L}},_embind_register_enum_value:(b,a,c)=>{var d=jb(b,"enum");a=U(a);switch(d.valueType){case "object":b=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},
438
- constructor:{value:$a(`${d.name}_${a}`,function(){})}});b.values[c]=d;b[a]=d;break;case "number":d.qa[a]=c;break;case "string":d.Ra[a]=c,d.Ma[c]=a,d.qa[a]=a}},_embind_register_float:(b,a,c)=>{a=U(a);V(b,{name:a,i:d=>d,o:(d,e)=>e,F:cc(a,c),C:null})},_embind_register_function:(b,a,c,d,e,k)=>{var g=Xb(a,c);b=U(b);b=Yb(b);e=Z(d,e);Db(b,function(){Ub(`Cannot call ${b} due to unbound types`,g)},a-1);W([],g,f=>{Pb(b,Wb(b,[f[0],null].concat(f.slice(1)),null,e,k),a-1);return[]})},_embind_register_integer:(b,
439
- a,c,d,e)=>{a=U(a);let k=f=>f;if(0===d){var g=32-8*c;k=f=>f<<g>>>g;e=k(e)}V(b,{name:a,i:k,o:(f,m)=>m,F:ic(a,c,0!==d),C:null})},_embind_register_memory_view:(b,a,c)=>{function d(k){return new e(Ba.buffer,M[k+4>>2],M[k>>2])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][a];c=U(c);V(b,{name:c,i:d,F:d},{ob:!0})},_embind_register_std_string:(b,a)=>{a=U(a);V(b,{name:a,i(c){var d=(d=c+4)?nc(D,d,M[c>>2],!0):"";hb(c);return d},o(c,d){d instanceof ArrayBuffer&&
440
- (d=new Uint8Array(d));var e="string"==typeof d;if(!(e||ArrayBuffer.isView(d)&&1==d.BYTES_PER_ELEMENT))throw new N("Cannot pass non-string to std::string");var k=e?kc(d):d.length;var g=Jc(4+k+1),f=g+4;M[g>>2]=k;e?jc(d,f,k+1):D.set(d,f);null!==c&&c.push(hb,g);return g},F:pb,C(c){hb(c)}})},_embind_register_std_wstring:(b,a,c)=>{c=U(c);if(2===a){var d=pc;var e=qc;var k=rc}else d=sc,e=tc,k=uc;V(b,{name:c,i:g=>{var f=d(g+4,M[g>>2]*a,!0);hb(g);return f},o:(g,f)=>{if("string"!=typeof f)throw new N(`Cannot pass non-string to C++ string type ${c}`);
441
- var m=k(f),n=Jc(4+m+a);M[n>>2]=m/a;e(f,n+4,m+a);null!==g&&g.push(hb,n);return n},F:pb,C(g){hb(g)}})},_embind_register_value_object:(b,a,c,d,e,k)=>{nb[b]={name:U(a),ra:Z(c,d),I:Z(e,k),Ga:[]}},_embind_register_value_object_field:(b,a,c,d,e,k,g,f,m,n)=>{nb[b].Ga.push({hb:U(a),nb:c,lb:Z(d,e),mb:k,yb:g,xb:Z(f,m),zb:n})},_embind_register_void:(b,a)=>{a=U(a);V(b,{qb:!0,name:a,i:()=>{},o:()=>{}})},_emscripten_runtime_keepalive_clear:()=>{Za=!1;vc=0},_emval_create_invoker:(b,a,c)=>{var [d,...e]=yc(b,a),k=
442
- d.o.bind(d),g=e.map(m=>m.F.bind(m));b--;var f=Array(b);a=`methodCaller<(${e.map(m=>m.name)}) => ${d.name}>`;return xc($a(a,(m,n,r,w)=>{for(var z=0,v=0;v<b;++v)f[v]=g[v](w+z),z+=8;switch(c){case 0:var x=P(m).apply(null,f);break;case 2:x=Reflect.construct(P(m),f);break;case 3:x=f[0];break;case 1:x=P(m)[Ac(n)](...f)}m=[];x=k(m,x);m.length&&(M[r>>2]=T(m));return x}))},_emval_decref:$b,_emval_get_module_property:b=>{b=Ac(b);return T(h[b])},_emval_get_property:(b,a)=>{b=P(b);a=P(a);return T(b[a])},_emval_incref:b=>
443
- {9<b&&(bb[b+1]+=1)},_emval_invoke:(b,a,c,d,e)=>wc[b](a,c,d,e),_emval_new_array:()=>T([]),_emval_new_cstring:b=>T(Ac(b)),_emval_new_object:()=>T({}),_emval_run_destructors:b=>{var a=P(b);ob(a);$b(b)},_emval_set_property:(b,a,c)=>{b=P(b);a=P(a);c=P(c);b[a]=c},_setitimer_js:(b,a)=>{Bc[b]&&(clearTimeout(Bc[b].id),delete Bc[b]);if(!a)return 0;var c=setTimeout(()=>{delete Bc[b];Ec(()=>Kc(b,performance.now()))},a);Bc[b]={id:c,Db:a};return 0},_tzset_js:(b,a,c,d)=>{var e=(new Date).getFullYear(),k=(new Date(e,
444
- 0,1)).getTimezoneOffset();e=(new Date(e,6,1)).getTimezoneOffset();M[b>>2]=60*Math.max(k,e);Fa[a>>2]=Number(k!=e);a=g=>{var f=Math.abs(g);return`UTC${0<=g?"-":"+"}${String(Math.floor(f/60)).padStart(2,"0")}${String(f%60).padStart(2,"0")}`};b=a(k);a=a(e);e<k?(jc(b,c,17),jc(a,d,17)):(jc(b,d,17),jc(a,c,17))},clock_time_get:function(b,a,c,d){if(!(0<=b&&3>=b))return 28;b=Math.round(1E6*(0===b?Date.now():performance.now()));Ra=[b>>>0,(Qa=b,1<=+Math.abs(Qa)?0<Qa?+Math.floor(Qa/4294967296)>>>0:~~+Math.ceil((Qa-
445
- +(~~Qa>>>0))/4294967296)>>>0:0)];Fa[d>>2]=Ra[0];Fa[d+4>>2]=Ra[1];return 0},emscripten_resize_heap:b=>{var a=D.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(b,d)/65536))-Ka.buffer.byteLength+65535)/65536|0;try{Ka.grow(d);Ja();var e=1;break a}catch(k){}e=void 0}if(e)return!0}return!1},environ_get:(b,a)=>{var c=0,d=0,e;for(e of Hc()){var k=a+c;M[b+d>>2]=k;c+=jc(e,k,Infinity)+1;d+=4}return 0},
446
- environ_sizes_get:(b,a)=>{var c=Hc();M[b>>2]=c.length;b=0;for(var d of c)b+=kc(d)+1;M[a>>2]=b;return 0},fd_close:()=>52,fd_seek:function(){return 70},fd_write:(b,a,c,d)=>{for(var e=0,k=0;k<c;k++){var g=M[a>>2],f=M[a+4>>2];a+=8;for(var m=0;m<f;m++){var n=b,r=D[g+m],w=Ic[n];0===r||10===r?((1===n?ua:va)(nc(w)),w.length=0):w.push(r)}e+=f}M[d>>2]=e;return 0},proc_exit:Dc},Mc;
447
- Mc=await (async function(){function b(c){c=Mc=c.exports;hb=c.free;Jc=c.malloc;gb=c.__getTypeName;Kc=c._emscripten_timeout;Y.vij=c.dynCall_vij;Y.iij=c.dynCall_iij;Y.ji=c.dynCall_ji;Y.jiji=c.dynCall_jiji;Y.viijii=c.dynCall_viijii;Y.iiiiij=c.dynCall_iiiiij;Y.iiiiijj=c.dynCall_iiiiijj;Y.iiiiiijj=c.dynCall_iiiiiijj;Ka=c.memory;Qb=c.__indirect_function_table;Ja();return Mc}var a={env:Lc,wasi_snapshot_preview1:Lc};if(h.instantiateWasm)return new Promise(c=>{h.instantiateWasm(a,(d,e)=>{c(b(d,e))})});
448
- Ma??=h.locateFile?h.locateFile("canvas_advanced.wasm",oa):oa+"canvas_advanced.wasm";return b((await Pa(a)).instance)}());
449
- (function(){function b(){h.calledRun=!0;if(!xa){Ia=!0;Mc.__wasm_call_ctors();za?.(h);h.onRuntimeInitialized?.();if(h.postRun)for("function"==typeof h.postRun&&(h.postRun=[h.postRun]);h.postRun.length;){var a=h.postRun.shift();Wa.push(a)}Va(Wa)}}if(h.preRun)for("function"==typeof h.preRun&&(h.preRun=[h.preRun]);h.preRun.length;)Ya();Va(Xa);h.setStatus?(h.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>h.setStatus(""),1);b()},1)):b()})();Ia?moduleRtn=h:moduleRtn=new Promise((b,a)=>{za=b;Aa=a});
352
+ var Rive=(()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var m=moduleArg,aa=!!globalThis.window,ca=!!globalThis.WorkerGlobalScope;
353
+ function da(){function b(h){const g=d;c=a=0;d=new Map;g.forEach(n=>{try{n(h)}catch(r){console.error(r)}});this.Ya();f&&f.Bb()}let a=0,c=0,d=new Map,f=null,l=null;this.requestAnimationFrame=function(h){a||=requestAnimationFrame(b.bind(this));const g=++c;d.set(g,h);return g};this.cancelAnimationFrame=function(h){d.delete(h);a&&0==d.size&&(cancelAnimationFrame(a),a=0)};this.zb=function(h){l&&(document.body.remove(l),l=null);h||(l=document.createElement("div"),l.style.backgroundColor="black",l.style.position=
354
+ "fixed",l.style.right=0,l.style.top=0,l.style.color="white",l.style.padding="4px",l.innerHTML="RIVE FPS",h=function(g){l.innerHTML="RIVE FPS "+g.toFixed(1)},document.body.appendChild(l));f=new function(){let g=0,n=0;this.Bb=function(){var r=performance.now();n?(++g,r-=n,1E3<r&&(h(1E3*g/r),g=n=0)):(n=r,g=0)}}};this.wb=function(){l&&(document.body.remove(l),l=null);f=null};this.Ya=function(){}}
355
+ function fa(b){console.assert(!0);const a=new Map;let c=-Infinity;this.push=function(d){d=d+((1<<b)-1)>>b;a.has(d)&&clearTimeout(a.get(d));a.set(d,setTimeout(function(){a.delete(d);0==a.length?c=-Infinity:d==c&&(c=Math.max(...a.keys()),console.assert(c<d))},1E3));c=Math.max(d,c);return c<<b}}const ha=m.onRuntimeInitialized;
356
+ m.onRuntimeInitialized=function(){ha&&ha();m.startFileScripts=function(h){const g=m.riveScripting;return h&&g&&h.startScripts?g.prepare().then(function(){h.startScripts();return h}):Promise.resolve(h)};let b=m.decodeAudio;m.decodeAudio=function(h,g,n=null){h=b(h,n??null);g(h)};let a=m.decodeFont;m.decodeFont=function(h,g,n=null){h=a(h,n??null);g(h)};const c=m.FileAsset.prototype.decode;m.FileAsset.prototype.decode=function(h,g){return c.call(this,h,g??null)};let d=m.setFallbackFontCb;m.setFallbackFontCallback=
357
+ "function"===typeof d?function(h){d(h)}:function(){console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.")};const f=m.FileAssetLoader;m.ptrToAsset=h=>{let g=m.ptrToFileAsset(h);return g.isImage?m.ptrToImageAsset(h):g.isFont?m.ptrToFontAsset(h):g.isAudio?m.ptrToAudioAsset(h):g};m.CustomFileAssetLoader=f.extend("CustomFileAssetLoader",{__construct:function({loadContents:h}){this.__parent.__construct.call(this);this.kb=h},loadContents:function(h,g){h=m.ptrToAsset(h);
358
+ return this.kb(h,g)}});m.CDNFileAssetLoader=f.extend("CDNFileAssetLoader",{__construct:function(h){this.__parent.__construct.call(this);this.lb=h??null},loadContents:function(h){let g=m.ptrToAsset(h);h=g.cdnUuid;if(""===h)return!1;const n=this.lb??null;(function(r,z){var q=new XMLHttpRequest;q.responseType="arraybuffer";q.onreadystatechange=function(){4==q.readyState&&200==q.status&&z(q)};q.open("GET",r,!0);q.send(null)})(g.cdnBaseUrl+"/"+h,r=>{g.decode(new Uint8Array(r.response),n)});return!0}});
359
+ m.FallbackFileAssetLoader=f.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);this.Wa=[]},addLoader:function(h){this.Wa.push(h)},loadContents:function(h,g){for(let n of this.Wa)if(n.loadContents(h,g))return!0;return!1}});let l=m.computeAlignment;m.computeAlignment=function(h,g,n,r,z=1){return l.call(this,h,g,n,r,z)}};function ja(){}const G=new Int32Array(5);
360
+ function ka(b,a,c,d,f){b(a,c,G);b=Math.max(G[0],0);const l=Math.max(G[1],0);a=Math.min(G[2],Math.ceil(d*a));c=Math.min(G[3],Math.ceil(f*c));G[4]=b!==G[0]||l!==G[1]||a!==G[2]||c!==G[3]?1:0;G[0]=b;G[1]=l;G[2]=a;G[3]=c;return a>b&&c>l}function la(){const b=ma.Kb();return 0===b?0:b}
361
+ function na(b,a,c,d,f,l,h,g,n,r,z){var q=la(),w=q-1,p=w-6;if(!(0<p))return r(),ja;let C=1,B=1;if(!ka(g,C,B,c,d))return r(),ja;const H=G[2]-G[0],F=G[3]-G[1];if(H>w||F>w)if(C*=Math.min(1,p/H),B*=Math.min(1,p/F),!ka(g,C,B,c,d))return r(),ja;c=G[0];d=G[1];w=G[2];p=G[3];g=0!==G[4];if(1>C||1>B)--c,--d,w+=1,p+=1;const D=w-c,K=p-d;b.i||(b.i=new m.DynamicRectanizer(q),b.i.reset(512,512));q=b.i.addRect(D+1,K+1);if(0>q&&(z(),q=b.i.addRect(D+1,K+1),0>q))return console.assert(!1,"draw does not fit in an empty atlas"),
362
+ r(),ja;const O=q&65535,M=q>>16;b.m.push({nb:[C*f[0],B*f[1],C*f[2],B*f[3],C*f[4]-c+O,B*f[5]-d+M],ob:O,pb:M,Tb:D,Ua:K,Xa:g,M:n,Nb:()=>{r()}});const S=c/C,Y=d/B,ea=D/C,Na=K/B,Oa=b.L;return function(){const ba=Oa.canvas();ba&&(a.save(),a.resetTransform(),a.globalCompositeOperation=l,a.globalAlpha=h,a.drawImage(ba,O,M,D,K,S,Y,ea,Na),a.restore())}}class oa{constructor(){this.L=new pa;this.i=null;this.m=[];this.ma=new fa(8);this.Z=new fa(8)}}
363
+ const ma=new function(){function b(){if(!a){var q=document.createElement("canvas"),w={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,powerPreference:"high-performance",failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,renderViaOffscreenBackBuffer:1};let p;if(/iPhone|iPad|iPod/i.test(navigator.userAgent)){if(p=q.getContext("webgl",w),c=1,!p)return console.log("No WebGL support. Image mesh will not be drawn."),!1}else if(p=q.getContext("webgl2",
364
+ w))c=2;else if(p=q.getContext("webgl",w))c=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;p=new Proxy(p,{get(B,H){if(B.isContextLost()){if(n||(console.error("Cannot render the mesh because the GL Context was lost. Tried to invoke ",H),n=!0),"function"===typeof B[H])return function(){}}else return"function"===typeof B[H]?function(...F){return B[H].apply(B,F)}:B[H]},set(B,H,F){if(B.isContextLost())n||(console.error("Cannot render the mesh because the GL Context was lost. Tried to set property "+
365
+ H),n=!0);else return B[H]=F,!0}});d=Math.min(p.getParameter(p.MAX_RENDERBUFFER_SIZE),p.getParameter(p.MAX_TEXTURE_SIZE));function C(B,H,F){H=p.createShader(H);p.shaderSource(H,F);p.compileShader(H);F=p.getShaderInfoLog(H);if(0<(F||"").length)throw F;p.attachShader(B,H)}q=p.createProgram();C(q,p.VERTEX_SHADER,"attribute vec2 vertex;\n attribute vec2 uv;\n uniform vec4 mat;\n uniform vec2 translate;\n varying vec2 st;\n void main() {\n st = uv;\n gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);\n }");
366
+ C(q,p.FRAGMENT_SHADER,"precision highp float;\n uniform sampler2D image;\n varying vec2 st;\n void main() {\n gl_FragColor = texture2D(image, st);\n }");p.bindAttribLocation(q,0,"vertex");p.bindAttribLocation(q,1,"uv");p.linkProgram(q);w=p.getProgramInfoLog(q);if(0<(w||"").trim().length)throw w;f=p.getUniformLocation(q,"mat");l=p.getUniformLocation(q,"translate");p.useProgram(q);p.bindBuffer(p.ARRAY_BUFFER,p.createBuffer());
367
+ p.enableVertexAttribArray(0);p.enableVertexAttribArray(1);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,p.createBuffer());p.uniform1i(p.getUniformLocation(q,"image"),0);p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);a=p}return!0}let a=null,c=0,d=0,f=null,l=null,h=0,g=0,n=!1;b();this.Kb=function(){b();return d};this.vb=function(q){a&&a.deleteTexture&&a.deleteTexture(q)};this.tb=function(q){if(!b())return null;const w=a.createTexture();if(!w)return null;a.bindTexture(a.TEXTURE_2D,w);a.texImage2D(a.TEXTURE_2D,
368
+ 0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,q);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR);2==c?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR_MIPMAP_LINEAR),a.generateMipmap(a.TEXTURE_2D)):a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);return w};const r=new fa(10),z=new fa(10);this.yb=function(q,w,p){if(b()&&a.canvas){if(a.canvas.width!=q||a.canvas.height!=
369
+ w)a.canvas.width=q,a.canvas.height=w;a.viewport(0,0,q,w);a.disable(a.SCISSOR_TEST);a.clearColor(0,0,0,0);a.clear(a.COLOR_BUFFER_BIT);var C=M=>M.M.image.za<<1|(M.Xa?1:0);p.sort((M,S)=>C(S)-C(M));var B=0,H=0;for(var F of p)B+=F.M.oa.length,H+=F.M.indices.length;F=r.push(B);h!=F&&(a.bufferData(a.ARRAY_BUFFER,8*F,a.DYNAMIC_DRAW),h=F);F=0;for(var D of p)a.bufferSubData(a.ARRAY_BUFFER,F,D.M.oa),F+=4*D.M.oa.length;console.assert(F==4*B);for(var K of p)a.bufferSubData(a.ARRAY_BUFFER,F,K.M.fb),F+=4*K.M.fb.length;
370
+ console.assert(F==8*B);F=z.push(H);g!=F&&(a.bufferData(a.ELEMENT_ARRAY_BUFFER,2*F,a.DYNAMIC_DRAW),g=F);D=0;for(var O of p)a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,D,O.M.indices),D+=2*O.M.indices.length;console.assert(D==2*H);O=0;K=!1;F=D=0;for(const M of p){p=M.M;p.image.za!=O&&(a.bindTexture(a.TEXTURE_2D,p.image.T||null),O=p.image.za);M.Xa?(a.scissor(M.ob,w-M.pb-M.Ua,M.Tb,M.Ua),K||(a.enable(a.SCISSOR_TEST),K=!0)):K&&(a.disable(a.SCISSOR_TEST),K=!1);const S=M.nb,Y=2/q,ea=-2/w;a.uniform4f(f,S[0]*Y,S[1]*
371
+ ea,S[2]*Y,S[3]*ea);a.uniform2f(l,S[4]*Y-1,S[5]*ea+1);a.vertexAttribPointer(0,2,a.FLOAT,!1,0,F);a.vertexAttribPointer(1,2,a.FLOAT,!1,0,F+4*B);a.drawElements(a.TRIANGLES,p.indices.length,a.UNSIGNED_SHORT,D);F+=4*p.oa.length;D+=2*p.indices.length}console.assert(F==4*B);console.assert(D==2*H)}};this.canvas=function(){return b()&&a.canvas}};class pa{constructor(){this.bb=!1}canvas(){return ma.canvas()||null}}const qa=new oa;
372
+ function ra(b,a,c,d,f,l){const h=new DOMMatrix;h.a=b;h.b=a;h.c=c;h.d=d;h.e=f;h.f=l;return h}const sa="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),ta=m.onRuntimeInitialized;
373
+ m.onRuntimeInitialized=function(){function b(e){switch(e){case p.srcOver:return"source-over";case p.Ub:return"plus-lighter";case p.screen:return"screen";case p.overlay:return"overlay";case p.darken:return"darken";case p.lighten:return"lighten";case p.colorDodge:return"color-dodge";case p.colorBurn:return"color-burn";case p.hardLight:return"hard-light";case p.softLight:return"soft-light";case p.difference:return"difference";case p.exclusion:return"exclusion";case p.multiply:return"multiply";case p.hue:return"hue";
374
+ case p.saturation:return"saturation";case p.color:return"color";case p.luminosity:return"luminosity"}}function a(e){return"rgba("+((16711680&e)>>>16)+","+((65280&e)>>>8)+","+((255&e)>>>0)+","+((4278190080&e)>>>24)/255+")"}function c(e,k,t,u,v){return{cb:e,eb:k,Pa:t,Qa:u,Va:v,Ha:[],Y:null}}function d(e,k,t,u){if(k.W===B&&!(0<k.X))return null;t=1===t;return{Ea:e.Ia(t?k.va:null),gradientTransform:t?k.ba:null,Sb:t?k.X*k.ya:k.X,fillRule:e.ga===H?"evenodd":"nonzero",opacity:u,style:k.W,color:k.ra,Ta:k.J,
375
+ rb:k.qa,join:k.wa,qb:k.pa}}function f(e,k){return k.W!==B||0<k.X?{path:e.hb(e.ga),Da:k.ib()}:null}function l(){if(0!==D.m.length){var e=la();if(0!==e){var k=Math.min(D.ma.push(D.i.drawWidth()),e);e=Math.min(D.Z.push(D.i.drawHeight()),e);ma.yb(k,e,D.m)}}for(const t of ba){for(const u of t.F)u();t.F=[]}ba.clear();for(const t of D.m)t.Nb();D.m=[];D.i&&D.i.reset(512,512)}ta&&ta();var h=m.RenderPaintStyle;const g=m.FillRule,n=m.RenderPath,r=m.RenderPaint,z=m.Renderer,q=m.StrokeCap,w=m.StrokeJoin,p=m.BlendMode,
376
+ C=h.fill,B=h.stroke,H=g.evenOdd,F=g.nonZero,D=qa,K=D.L;let O=1;var M=m.RenderImage.extend("CanvasRenderImage",{__construct:function({da:e,na:k}={}){this.__parent.__construct.call(this);this.za=O;O=O+1&2147483647||1;this.da=e;this.na=k;this.T=this.mb=this.ha=this.Ma=null},__destruct:function(){this.T&&(ma.vb(this.T),this.T=null);this.ha&&URL.revokeObjectURL(this.ha);this.__parent.__destruct.call(this)},decode:function(e){var k=this;k.na&&k.na(k);var t=new Image;k.ha=URL.createObjectURL(new Blob([e],
377
+ {type:"image/png"}));t.onload=function(){k.Ma=t;k.T=ma.tb(t);k.size(t.width,t.height);k.da&&k.da(k)};t.src=k.ha}});class S{constructor(e){this.i=e;this.path=new Path2D;this.m=null;this.ta=!1}L(){null!==this.m&&(this.path.lineTo(this.m.x,this.m.y),this.m=null)}moveTo(e,k){this.L();let t=e,u=k;null!==this.i&&(e=this.i.transformPoint({x:e,y:k}),t=e.x,u=e.y);this.path.moveTo(t,u);this.m={x:t,y:u}}lineTo(e,k){this.m=null;null!==this.i?(e=this.i.transformPoint({x:e,y:k}),this.path.lineTo(e.x,e.y)):this.path.lineTo(e,
378
+ k)}ub(e,k,t,u,v,A){this.m=null;null!==this.i?(e=this.i.transformPoint({x:e,y:k}),t=this.i.transformPoint({x:t,y:u}),v=this.i.transformPoint({x:v,y:A}),this.path.bezierCurveTo(e.x,e.y,t.x,t.y,v.x,v.y)):this.path.bezierCurveTo(e,k,t,u,v,A)}close(){this.m=null;this.path.closePath()}addPath(e,k,t,u,v,A,E){this.L();const y=new S(null);for(const x of e)x(y);y.Sa();e=ra(k,t,u,v,A,E);null!==this.i&&(e=this.i.multiply(e));this.path.addPath(y.path,e)}Sa(){null===this.m||this.ta||(this.L(),this.ta=!0)}dispose(){}}
379
+ class Y{constructor(e){this.Jb=e;this.Z=this.L=0;this.m=null;this.i=e(null)}clear(){this.ma(null)}Aa(e,k){for(((null===k?null!==this.m:null===this.m||this.m.a!==k.a||this.m.b!==k.b||this.m.c!==k.c||this.m.d!==k.d||this.m.e!==k.e||this.m.f!==k.f)||this.Z<e.length&&(0<this.L||this.i.ta))&&this.ma(k);this.Z<e.length;)e[this.Z++](this.i);this.i.Sa();this.L++;return this.i.path}Ga(e){null!==this.i&&e===this.i.path&&this.L--}dispose(){this.i.dispose();this.i=null}ma(e){this.i.dispose();this.Z=this.L=0;
380
+ this.m=e;this.i=this.Jb(e)}}var ea=n.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this);this.U=[];this.ia=new Y(e=>new S(e));this.ja=new Y(e=>new S(e));this.V=new Map;this.ga=F;this.ua=!1},__destruct:function(){this.ia.dispose();this.ja.dispose();for(const e of this.V.values())e.dispose();this.V.clear();this.__parent.__destruct.call(this)},rewind:function(){this.U.length=0;this.ia.clear();this.ja.clear();for(const e of this.V.values())e.clear();this.ua=!1},addPath:function(e,
381
+ k,t,u,v,A,E){const y=e.U.slice();this.aa(x=>x.addPath(y,k,t,u,v,A,E))},fillRule:function(e){this.ga=e},moveTo:function(e,k){this.ua=!0;this.aa(t=>t.moveTo(e,k))},lineTo:function(e,k){this.La();this.aa(t=>t.lineTo(e,k))},cubicTo:function(e,k,t,u,v,A){this.La();this.aa(E=>E.ub(e,k,t,u,v,A))},close:function(){this.aa(e=>e.close())},La:function(){this.ua||this.moveTo(0,0)},aa:function(e){this.U.push(e)},Ia:function(e){e=null===e?this.ia.Aa(this.U,null):this.ja.Aa(this.U,e);e.ref&&e.ref();return e},hb:function(e){var k=
382
+ this.V.get(e);void 0===k&&(k=new Y(()=>K.Vb(e)),this.V.set(e,k));k=k.Aa(this.U,null);k.ref&&k.ref();return k},xa:function(e){this.ia.Ga(e);this.ja.Ga(e);for(const k of this.V.values())k.Ga(e);e.unref&&e.unref()}});const Na=c(0,0,0,0,!1);var Oa=r.extend("CanvasRenderPaint",{__construct:function(){this.__parent.__construct.call(this);this.W=C;this.ra=4278190080;this.X=1;this.wa=w.miter;this.qa=q.butt;this.sa=0;this.pa=b(p.srcOver);this.va=this.ba=this.J=null;this.ya=1;this.D=0;this.R=null;this.Na=-1},
383
+ __destruct:function(){null!==this.R&&(m.unrefWebGL2Paint(this.R),this.R=null);this.__parent.__destruct.call(this)},color:function(e){this.ra=e;this.J=null;this.D++},thickness:function(e){this.X=Math.abs(e);this.D++},join:function(e){this.wa=e;this.D++},cap:function(e){this.qa=e;this.D++},feather:function(e){this.sa=Math.abs(e);this.D++},style:function(e){this.W=e;this.D++},blendMode:function(e){this.pa=b(e);this.D++},clearGradient:function(){this.J=null;this.D++},linearGradient:function(e,k,t,u){this.J=
384
+ c(e,k,t,u,!1);this.D++},radialGradient:function(e,k,t,u){this.J=c(e,k,t,u,!0);this.D++},addStop:function(e,k){this.J.Ha.push({color:e,stop:k});this.J.Y=null;this.D++},completeGradient:function(){},_setGradientTransform:function(e,k,t,u,v,A,E,y,x,I,J,R,W){1===e&&0===k&&0===t&&1===u&&0===v&&0===A?this.va=this.ba=null:(this.ba=ra(e,k,t,u,v,A),this.va=ra(E,y,x,I,J,R));this.ya=W;this.D++},ib:function(){if(this.Na!==this.D){null!==this.R&&m.unrefWebGL2Paint(this.R);const k=null!==this.J?this.J:Na;let t=
385
+ null,u=null;if(null!==this.J){var e=k.Ha;t=new Uint32Array(e.length);u=new Float32Array(e.length);for(let J=0,R=e.length;J<R;J++)t[J]=e[J].color,u[J]=e[J].stop}e=1;let v=0,A=0,E=1,y=0,x=0;const I=this.ba;null!==I&&(e=I.a,v=I.b,A=I.c,E=I.d,y=I.e,x=I.f);this.R=m.makeWebGL2Paint(this.W,this.ra,this.X,this.wa,this.qa,this.sa,t,u,k.Va,k.cb,k.eb,k.Pa,k.Qa,e,v,A,E,y,x);this.Na=this.D}m.refWebGL2Paint(this.R);return this.R}});const ba=new Set,nb=Object.prototype.hasOwnProperty;var Vb=m.CanvasRenderer=z.extend("Renderer",
386
+ {__construct:function(e){this.__parent.__construct.call(this);this.K=[1,0,0,1,0,0];this.C=[1];this.s=e.getContext("2d");this.Ka=e;this.F=[]},save:function(){this.K.push(...this.K.slice(this.K.length-6));this.C.push(this.C[this.C.length-1]);this.F.push(this.s.save.bind(this.s))},restore:function(){const e=this.K.length-6;if(6>e)throw"restore() called without matching save().";this.K.splice(e);this.C.pop();this.F.push(this.s.restore.bind(this.s))},transform:function(e,k,t,u,v,A){const E=this.K,y=E.length-
387
+ 6;E.splice(y,6,E[y]*e+E[y+2]*k,E[y+1]*e+E[y+3]*k,E[y]*t+E[y+2]*u,E[y+1]*t+E[y+3]*u,E[y]*v+E[y+2]*A+E[y+4],E[y+1]*v+E[y+3]*A+E[y+5]);this.F.push(this.s.transform.bind(this.s,e,k,t,u,v,A))},rotate:function(e){const k=Math.sin(e);e=Math.cos(e);this.transform(e,k,-k,e,0,0)},modulateOpacity:function(e){this.C[this.C.length-1]*=e},_drawPath:function(e,k){const t=Math.max(0,this.C[this.C.length-1]),u=0!==k.sa?K.bb?2:0:null===k.J||null===k.ba?0:k.W!==B||0<k.ya?1:K.bb?2:0;if(2===u)this.jb(e,k,t);else{var v=
388
+ d(e,k,u,t);null!==v&&this.F.push(()=>{var A=this.s;const E=A.globalCompositeOperation,y=A.globalAlpha;A.globalCompositeOperation=v.qb;A.globalAlpha=v.opacity;if(null!==v.Ta){var x=v.Ta;if(null===x.Y){var I=x.cb;const W=x.eb;var J=x.Pa,R=x.Qa;x.Va?(J-=I,R-=W,x.Y=A.createRadialGradient(I,W,0,I,W,Math.sqrt(J*J+R*R))):x.Y=A.createLinearGradient(I,W,J,R);I=x.Ha;for(let ia=0,Qa=I.length;ia<Qa;ia++)x.Y.addColorStop(I[ia].stop,a(I[ia].color))}x=x.Y}else x=a(v.color);null!==v.gradientTransform&&(A.save(),
389
+ A.transform(v.gradientTransform.a,v.gradientTransform.b,v.gradientTransform.c,v.gradientTransform.d,v.gradientTransform.e,v.gradientTransform.f));switch(v.style){case B:A.strokeStyle=x;A.lineWidth=v.Sb;a:{switch(v.rb){case q.butt:x="butt";break a;case q.round:x="round";break a;case q.square:x="square";break a}x=void 0}A.lineCap=x;a:{switch(v.join){case w.miter:x="miter";break a;case w.round:x="round";break a;case w.bevel:x="bevel";break a}x=void 0}A.lineJoin=x;A.miterLimit=4;A.stroke(v.Ea);break;
390
+ case C:A.fillStyle=x,A.fill(v.Ea,v.fillRule)}null!==v.gradientTransform&&A.restore();A.globalCompositeOperation=E;A.globalAlpha=y;e.xa(v.Ea)})}},jb:function(e,k,t){const u=f(e,k);if(null!==u){var v=this.K.slice(this.K.length-6);k=na(D,this.s,this.s.canvas.width,this.s.canvas.height,v,k.pa,t,(A,E,y)=>m.webGL2PathPixelBounds(u.path,u.Da,A*v[0],E*v[1],A*v[2],E*v[3],A*v[4],E*v[5],y),A=>A.drawPath(u.path,u.Da),()=>{e.xa(u.path);m.unrefWebGL2Paint(u.Da)},l);ba.add(this);this.F.push(k)}},_drawRiveImage:function(e,
391
+ k,t){var u=e.Ma;if(u){var v=this.s,A=b(k),E=Math.max(0,t*this.C[this.C.length-1]);this.F.push(function(){v.globalCompositeOperation=A;v.globalAlpha=E;v.drawImage(u,0,0);v.globalAlpha=1})}},_getMatrix:function(e){const k=this.K,t=k.length-6;for(let u=0;6>u;++u)e[u]=k[t+u]},_drawImageMesh:function(e,k,t,u,v,A,E,y){const x=e.mb;x?this.Ja(t,u,v,A,E,y,I=>m.drawWebGL2PendingMesh(I,k,x),()=>k.unref()):k.unref()},_drawImageMeshFromHeap:function(e,k,t,u,v,A,E,y,x,I,J,R,W){if(e.T){try{var ia=m.HEAPF32.slice(u>>
392
+ 2,(u>>2)+v);var Qa=m.HEAPF32.slice(A>>2,(A>>2)+E);var Ub=m.HEAPU16.slice(y>>1,(y>>1)+x)}catch(Cc){console.error("[Rive] _drawImageMesh: failed to read mesh data from WASM heap. Mesh skipped for this frame.");return}this.Ja(k,t,I,J,R,W,{image:e,oa:ia,fb:Qa,indices:Ub},()=>{})}},Ja:function(e,k,t,u,v,A,E,y){e=na(D,this.s,this.s.canvas.width,this.s.canvas.height,this.K.slice(this.K.length-6),b(e),Math.max(0,k*this.C[this.C.length-1]),(x,I,J)=>{J[0]=Math.floor(t*x);J[1]=Math.floor(u*I);J[2]=Math.ceil(v*
393
+ x);J[3]=Math.ceil(A*I)},E,y,l);ba.add(this);this.F.push(e)},_clipPath:function(e){const k=e.ga===H?"evenodd":"nonzero",t=e.Ia(null);this.F.push(()=>{this.s.clip(t,k);e.xa(t)})},beginFrame:function(e=!0){ba.add(this);e&&this.F.push(this.s.clearRect.bind(this.s,0,0,this.Ka.width,this.Ka.height))},clear:function(){this.beginFrame(!0)},flush:function(){},translate:function(e,k){this.transform(1,0,0,1,e,k)}});m.makeRenderer=function(e){const k=new Vb(e),t=k.s;let u=null,v=null;const A={attachSession:function(y){if(y&&
394
+ u===y)return!0;if(!y||u||"function"!==typeof m.c2dDeferredClaim||"function"!==typeof m.c2dDeferredRenderer||!m.c2dDeferredClaim(y))return!1;const x=m.c2dDeferredRenderer(y);if(!x)return!1;u=y;v=x;return!0},detachSession:function(){u&&m.c2dDeferredDetach(u);v=u=null},deferredActive:function(){return null!==v}},E={save:function(){m.c2dDeferredSave(u)},restore:function(){m.c2dDeferredRestore(u)},transform:function(y,x,I,J,R,W){m.c2dDeferredTransform(u,y,x,I,J,R,W)},translate:function(y,x){m.c2dDeferredTransform(u,
395
+ 1,0,0,1,y,x)},rotate:function(y){const x=Math.sin(y);y=Math.cos(y);m.c2dDeferredTransform(u,y,x,-x,y,0,0)},align:function(y,x,I,J,R){m.c2dDeferredAlign(u,y,x,I.minX,I.minY,I.maxX,I.maxY,J.minX,J.minY,J.maxX,J.maxY,void 0===R?1:R)},beginFrame:function(y=!0){k.beginFrame(y);m.c2dDeferredBeginFrame(u)},clear:function(){k.beginFrame(!0);m.c2dDeferredBeginFrame(u)},flush:function(){m.c2dDeferredReplay(u,k)}};return new Proxy(k,{get(y,x){if(nb.call(A,x))return A[x];if("_deferredRecorder"===x)return v;if(null!==
396
+ v&&nb.call(E,x))return E[x];if("function"===typeof y[x])return function(...I){return y[x].apply(y,I)};if("function"===typeof t[x]){if(-1<sa.indexOf(x))throw Error("RiveException: Method call to '"+x+"()' is not allowed, as the renderer cannot immediately pass through the return values of any canvas 2d context methods.");return function(...I){k.F.push(t[x].bind(t,...I))}}return y[x]},set(y,x,I){if(x in t)return k.F.push(()=>{t[x]=I}),!0}})};m.decodeImage=function(e,k){(new M({da:k})).decode(e)};
397
+ m.renderFactory={makeRenderPaint:function(){return new Oa},makeRenderPath:function(){return new ea},makeRenderImage:function(){let e=Ra;return new M({na:()=>{e.total++},da:()=>{e.loaded++;if(e.loaded===e.total){const k=e.ready;k&&(k(),e.ready=null)}}})}};let Wb=m.load,Ra=null;m.load=function(e,k,t=!0,u=null){const v=new m.FallbackFileAssetLoader;void 0!==k&&v.addLoader(k);t&&(k=new m.CDNFileAssetLoader(u),v.addLoader(k));return(new Promise(function(A){let E=null;Ra={total:0,loaded:0,ready:function(){A(E)}};
398
+ E=Wb(e,v,u??null);const y=m.riveScripting;y&&y.prepare();0==Ra.total&&A(E)})).then(m.startFileScripts)};const Xb=m.Artboard.prototype.draw;m.Artboard.prototype.draw=function(e){Xb.call(this,e._deferredRecorder||e)};let Yb=m.RendererWrapper.prototype.align;m.RendererWrapper.prototype.align=function(e,k,t,u,v=1){Yb.call(this,e,k,t,u,v)};h=new da;m.requestAnimationFrame=h.requestAnimationFrame.bind(h);m.cancelAnimationFrame=h.cancelAnimationFrame.bind(h);m.enableFPSCounter=h.zb.bind(h);m.disableFPSCounter=
399
+ h.wb;h.Ya=l;m.resolveAnimationFrame=l;m.cleanup=function(){D.i&&(D.i["delete"](),D.i=null)}};ca&&(_scriptName=self.location.href);var ua="",va,wa;
400
+ if(aa||ca){try{ua=(new URL(".",_scriptName)).href}catch{}ca&&(wa=b=>{var a=new XMLHttpRequest;a.open("GET",b,!1);a.responseType="arraybuffer";a.send(null);return new Uint8Array(a.response)});va=async b=>{if(xa(b))return new Promise((c,d)=>{var f=new XMLHttpRequest;f.open("GET",b,!0);f.responseType="arraybuffer";f.onload=()=>{200==f.status||0==f.status&&f.response?c(f.response):d(f.status)};f.onerror=d;f.send(null)});var a=await fetch(b,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw Error(a.status+
401
+ " : "+a.url);}}var ya=console.log.bind(console),za=console.error.bind(console),Aa,Ba=!1,xa=b=>b.startsWith("file://"),Ca,Da,Ea,L,Fa,Ga,Ha,N,Ia,Ja,Ka=!1;function La(){var b=Ma.buffer;m.HEAP8=Ea=new Int8Array(b);Fa=new Int16Array(b);m.HEAPU8=L=new Uint8Array(b);m.HEAPU16=Ga=new Uint16Array(b);m.HEAP32=Ha=new Int32Array(b);m.HEAPU32=N=new Uint32Array(b);m.HEAPF32=Ia=new Float32Array(b);Ja=new Float64Array(b)}
402
+ function Pa(b){m.onAbort?.(b);b="Aborted("+b+")";za(b);Ba=!0;b=new WebAssembly.RuntimeError(b+". Build with -sASSERTIONS for more info.");Da?.(b);throw b;}var Sa;async function Ta(b){if(!Aa)try{var a=await va(b);return new Uint8Array(a)}catch{}if(b==Sa&&Aa)b=new Uint8Array(Aa);else if(wa)b=wa(b);else throw"both async and sync fetching of the wasm failed";return b}
403
+ async function Ua(b,a){try{var c=await Ta(b);return await WebAssembly.instantiate(c,a)}catch(d){za(`failed to asynchronously prepare wasm: ${d}`),Pa(d)}}async function Va(b){var a=Sa;if(!Aa&&!xa(a))try{var c=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(c,b)}catch(d){za(`wasm streaming compile failed: ${d}`),za("falling back to ArrayBuffer instantiation")}return Ua(a,b)}
404
+ var Wa,Xa,Ya=b=>{for(;0<b.length;)b.shift()(m)},Za=[],$a=[],ab=()=>{var b=m.preRun.shift();$a.push(b)},bb=(b,a)=>Object.defineProperty(a,"name",{value:b}),cb=[],db=[0,1,,1,null,1,!0,1,!1,1],P=class extends Error{constructor(b){super(b);this.name="BindingError"}},Q=b=>{if(!b)throw new P(`Cannot use deleted val. handle = ${b}`);return db[b]},T=b=>{switch(b){case void 0:return 2;case null:return 4;case !0:return 6;case !1:return 8;default:const a=cb.pop()||db.length;db[a]=b;db[a+1]=1;return a}};
405
+ class eb extends Error{}
406
+ var U=b=>{for(var a="";;){var c=L[b++];if(!c)return a;a+=String.fromCharCode(c)}},fb={},gb=(b,a)=>{if(void 0===a)throw new P("ptr should not be undefined");for(;b.A;)a=b.ea(a),b=b.A;return a},hb={},kb=b=>{b=ib(b);var a=U(b);jb(b);return a},lb=(b,a)=>{var c=hb[b];if(void 0===c)throw b=`${a} has unknown type ${kb(b)}`,new P(b);return c},mb=()=>{},ob=!1,pb=b=>{if(!globalThis.FinalizationRegistry)return pb=a=>a,b;ob=new FinalizationRegistry(a=>{a=a.g;--a.count.value;0===a.count.value&&(a.B?a.I.O(a.B):
407
+ a.o.h.O(a.l))});pb=a=>{var c=a.g;c.B&&ob.register(a,{g:c},a);return a};mb=a=>{ob.unregister(a)};return pb(b)},qb={},rb=b=>{for(;b.length;){var a=b.pop();b.pop()(a)}};function sb(b){return this.j(N[b>>2])}
408
+ var tb={},ub={},vb=class extends Error{constructor(b){super(b);this.name="InternalError"}},X=(b,a,c)=>{function d(g){g=c(g);if(g.length!==b.length)throw new vb("Mismatched type converter count");for(var n=0;n<b.length;++n)V(b[n],g[n])}b.forEach(g=>ub[g]=a);var f=Array(a.length),l=[],h=0;for(let [g,n]of a.entries())hb.hasOwnProperty(n)?f[g]=hb[n]:(l.push(n),tb.hasOwnProperty(n)||(tb[n]=[]),tb[n].push(()=>{f[g]=hb[n];++h;h===l.length&&d(f)}));0===l.length&&d(f)};
409
+ function wb(b,a,c={}){var d=a.name;if(!b)throw new P(`type "${d}" must have a positive integer typeid pointer`);if(hb.hasOwnProperty(b)){if(c.Hb)return;throw new P(`Cannot register type '${d}' twice`);}hb[b]=a;delete ub[b];tb.hasOwnProperty(b)&&(a=tb[b],delete tb[b],a.forEach(f=>f()))}function V(b,a,c={}){return wb(b,a,c)}var xb=b=>{throw new P(b.g.o.h.name+" instance already deleted");},yb=[];function zb(){}
410
+ var Ab={},Bb=(b,a,c)=>{if(void 0===b[a].u){var d=b[a];b[a]=function(...f){if(!b[a].u.hasOwnProperty(f.length))throw new P(`Function '${c}' called with an invalid number of arguments (${f.length}) - expects one of (${b[a].u})!`);return b[a].u[f.length].apply(this,f)};b[a].u=[];b[a].u[d.P]=d}},Cb=(b,a,c)=>{if(m.hasOwnProperty(b)){if(void 0===c||void 0!==m[b].u&&void 0!==m[b].u[c])throw new P(`Cannot register public name '${b}' twice`);Bb(m,b,b);if(m[b].u.hasOwnProperty(c))throw new P(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);
411
+ m[b].u[c]=a}else m[b]=a,m[b].P=c},Db=b=>{b=b.replace(/[^a-zA-Z0-9_]/g,"$");var a=b.charCodeAt(0);return 48<=a&&57>=a?`_${b}`:b};function Eb(b,a,c,d,f,l,h,g){this.name=b;this.constructor=a;this.N=c;this.O=d;this.A=f;this.Cb=l;this.ea=h;this.xb=g;this.Za=[]}
412
+ var Fb=(b,a,c)=>{for(;a!==c;){if(!a.ea)throw new P(`Expected null or instance of ${c.name}, got an instance of ${a.name}`);b=a.ea(b);a=a.A}return b},Gb=b=>{if(null===b)return"null";var a=typeof b;return"object"===a||"array"===a||"function"===a?b.toString():""+b};
413
+ function Hb(b,a){if(null===a){if(this.Ba)throw new P(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new P(`Cannot pass "${Gb(a)}" as a ${this.name}`);if(!a.g.l)throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);return Fb(a.g.l,a.g.o.h,this.h)}
414
+ function Ib(b,a){if(null===a){if(this.Ba)throw new P(`null is not a valid ${this.name}`);if(this.la){var c=this.Fa();null!==b&&b.push(this.O,c);return c}return 0}if(!a||!a.g)throw new P(`Cannot pass "${Gb(a)}" as a ${this.name}`);if(!a.g.l)throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.ka&&a.g.o.ka)throw new P(`Cannot convert argument of type ${a.g.I?a.g.I.name:a.g.o.name} to parameter type ${this.name}`);c=Fb(a.g.l,a.g.o.h,this.h);if(this.la){if(void 0===a.g.B)throw new P("Passing raw pointer to smart pointer is illegal");
415
+ switch(this.Rb){case 0:if(a.g.I===this)c=a.g.B;else throw new P(`Cannot convert argument of type ${a.g.I?a.g.I.name:a.g.o.name} to parameter type ${this.name}`);break;case 1:c=a.g.B;break;case 2:if(a.g.I===this)c=a.g.B;else{var d=a.clone();c=this.Mb(c,T(()=>d["delete"]()));null!==b&&b.push(this.O,c)}break;default:throw new P("Unsupported sharing policy");}}return c}
416
+ function Jb(b,a){if(null===a){if(this.Ba)throw new P(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new P(`Cannot pass "${Gb(a)}" as a ${this.name}`);if(!a.g.l)throw new P(`Cannot pass deleted object as a pointer of type ${this.name}`);if(a.g.o.ka)throw new P(`Cannot convert argument of type ${a.g.o.name} to parameter type ${this.name}`);return Fb(a.g.l,a.g.o.h,this.h)}
417
+ var Kb=(b,a,c)=>{if(a===c)return b;if(void 0===c.A)return null;b=Kb(b,a,c.A);return null===b?null:c.xb(b)},Lb=(b,a)=>{a=gb(b,a);return fb[a]},Mb=(b,a)=>{if(!a.o||!a.l)throw new vb("makeClassHandle requires ptr and ptrType");if(!!a.I!==!!a.B)throw new vb("Both smartPtrType and smartPtr must be specified");a.count={value:1};return pb(Object.create(b,{g:{value:a,writable:!0}}))};
418
+ function Nb(b,a,c,d,f,l,h,g,n,r,z){this.name=b;this.h=a;this.Ba=c;this.ka=d;this.la=f;this.Lb=l;this.Rb=h;this.$a=g;this.Fa=n;this.Mb=r;this.O=z;f||void 0!==a.A?this.v=Ib:(this.v=d?Hb:Jb,this.G=null)}
419
+ var Ob=(b,a,c)=>{if(!m.hasOwnProperty(b))throw new vb("Replacing nonexistent public symbol");void 0!==m[b].u&&void 0!==c?m[b].u[c]=a:(m[b]=a,m[b].P=c)},Pb={},Rb=(b,a,c=[])=>{b.includes("j")?(b=b.replace(/p/g,"i"),a=(0,Pb[b])(a,...c)):a=Qb.get(a)(...c);return a},Sb=(b,a)=>(...c)=>Rb(b,a,c),Z=(b,a)=>{b=U(b);var c=b.includes("j")?Sb(b,a):Qb.get(a);if("function"!=typeof c)throw new P(`unknown function pointer with signature ${b}: ${a}`);return c};class Tb extends Error{}
420
+ var Zb=(b,a)=>{function c(l){f[l]||hb[l]||(ub[l]?ub[l].forEach(c):(d.push(l),f[l]=!0))}var d=[],f={};a.forEach(c);throw new Tb(`${b}: `+d.map(kb).join([", "]));};function $b(b){for(var a=1;a<b.length;++a)if(null!==b[a]&&void 0===b[a].G)return!0;return!1}
421
+ function ac(b,a,c,d,f){var l=a.length;if(2>l)throw new P("argTypes array size mismatch! Must at least get return value and 'this' types!");var h=null!==a[1]&&null!==c,g=$b(a),n=!a[0].Ib,r=l-2,z=Array(r),q=[],w=[];return bb(b,function(...p){w.length=0;q.length=h?2:1;q[0]=f;if(h){var C=a[1].v(w,this);q[1]=C}for(var B=0;B<r;++B)z[B]=a[B+2].v(w,p[B]),q.push(z[B]);p=d(...q);if(g)rb(w);else for(B=h?1:2;B<a.length;B++){var H=1===B?C:z[B-2];null!==a[B].G&&a[B].G(H)}C=n?a[0].j(p):void 0;return C})}
422
+ var bc=(b,a)=>{for(var c=[],d=0;d<b;d++)c.push(N[a+4*d>>2]);return c},cc=b=>{b=b.trim();const a=b.indexOf("(");return-1===a?b:b.slice(0,a)},dc=(b,a,c)=>{if(!(b instanceof Object))throw new P(`${c} with invalid "this": ${b}`);if(!(b instanceof a.h.constructor))throw new P(`${c} incompatible with "this" of type ${b.constructor.name}`);if(!b.g.l)throw new P(`cannot call emscripten binding method ${c} on deleted object`);return Fb(b.g.l,b.g.o.h,a.h)},ec=b=>{9<b&&0===--db[b+1]&&(db[b]=void 0,cb.push(b))},
423
+ fc={name:"emscripten::val",j:b=>{var a=Q(b);ec(b);return a},v:(b,a)=>T(a),H:sb,G:null},gc=(b,a,c)=>{switch(a){case 1:return c?function(d){return this.j(Ea[d])}:function(d){return this.j(L[d])};case 2:return c?function(d){return this.j(Fa[d>>1])}:function(d){return this.j(Ga[d>>1])};case 4:return c?function(d){return this.j(Ha[d>>2])}:function(d){return this.j(N[d>>2])};default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},hc=(b,a)=>{switch(a){case 4:return function(c){return this.j(Ia[c>>
424
+ 2])};case 8:return function(c){return this.j(Ja[c>>3])};default:throw new TypeError(`invalid float width (${a}): ${b}`);}},ic=(b,a,c)=>{switch(a){case 1:return c?d=>Ea[d]:d=>L[d];case 2:return c?d=>Fa[d>>1]:d=>Ga[d>>1];case 4:return c?d=>Ha[d>>2]:d=>N[d>>2];default:throw new TypeError(`invalid integer width (${a}): ${b}`);}},jc=globalThis.TextDecoder&&new TextDecoder,kc=(b,a,c,d)=>{c=a+c;if(d)return c;for(;b[a]&&!(a>=c);)++a;return a},lc=(b,a=0,c,d)=>{c=kc(b,a,c,d);if(16<c-a&&b.buffer&&jc)return jc.decode(b.subarray(a,
425
+ c));for(d="";a<c;){var f=b[a++];if(f&128){var l=b[a++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|l);else{var h=b[a++]&63;f=224==(f&240)?(f&15)<<12|l<<6|h:(f&7)<<18|l<<12|h<<6|b[a++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d},mc=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,nc=(b,a,c)=>{b>>=1;a=kc(Ga,b,a/2,c);if(16<a-b&&mc)return mc.decode(Ga.subarray(b,a));for(c="";b<a;++b)c+=String.fromCharCode(Ga[b]);
426
+ return c},oc=(b,a,c)=>{c??=2147483647;if(2>c)return 0;c-=2;var d=a;c=c<2*b.length?c/2:b.length;for(var f=0;f<c;++f)Fa[a>>1]=b.charCodeAt(f),a+=2;Fa[a>>1]=0;return a-d},pc=b=>2*b.length,qc=(b,a,c)=>{var d="";b>>=2;for(var f=0;!(f>=a/4);f++){var l=N[b+f];if(!l&&!c)break;d+=String.fromCodePoint(l)}return d},rc=(b,a,c)=>{c??=2147483647;if(4>c)return 0;var d=a;c=d+c-4;for(var f=0;f<b.length;++f){var l=b.codePointAt(f);65535<l&&f++;Ha[a>>2]=l;a+=4;if(a+4>c)break}Ha[a>>2]=0;return a-d},sc=b=>{for(var a=
427
+ 0,c=0;c<b.length;++c)65535<b.codePointAt(c)&&c++,a+=4;return a},tc=[],uc=b=>{var a=tc.length;tc.push(b);return a},vc=(b,a)=>{for(var c=Array(b),d=0;d<b;++d)c[d]=lb(N[a+4*d>>2],`parameter ${d}`);return c},wc={},xc=b=>{var a=wc[b];return void 0===a?U(b):a},yc=[null,[],[]];
428
+ (()=>{let b=zb.prototype;Object.assign(b,{isAliasOf:function(c){if(!(this instanceof zb&&c instanceof zb))return!1;var d=this.g.o.h,f=this.g.l;c.g=c.g;var l=c.g.o.h;for(c=c.g.l;d.A;)f=d.ea(f),d=d.A;for(;l.A;)c=l.ea(c),l=l.A;return d===l&&f===c},clone:function(){this.g.l||xb(this);if(this.g.$)return this.g.count.value+=1,this;var c=pb,d=Object,f=d.create,l=Object.getPrototypeOf(this),h=this.g;c=c(f.call(d,l,{g:{value:{count:h.count,ca:h.ca,$:h.$,l:h.l,o:h.o,B:h.B,I:h.I}}}));c.g.count.value+=1;c.g.ca=
429
+ !1;return c},["delete"](){this.g.l||xb(this);if(this.g.ca&&!this.g.$)throw new P("Object already scheduled for deletion");mb(this);var c=this.g;--c.count.value;0===c.count.value&&(c.B?c.I.O(c.B):c.o.h.O(c.l));this.g.$||(this.g.B=void 0,this.g.l=void 0)},isDeleted:function(){return!this.g.l},deleteLater:function(){this.g.l||xb(this);if(this.g.ca&&!this.g.$)throw new P("Object already scheduled for deletion");yb.push(this);this.g.ca=!0;return this}});const a=Symbol.dispose;a&&(b[a]=b["delete"])})();
430
+ Object.assign(Nb.prototype,{Db(b){this.$a&&(b=this.$a(b));return b},Oa(b){this.O?.(b)},H:sb,j:function(b){function a(){return this.la?Mb(this.h.N,{o:this.Lb,l:c,I:this,B:b}):Mb(this.h.N,{o:this,l:b})}var c=this.Db(b);if(!c)return this.Oa(b),null;var d=Lb(this.h,c);if(void 0!==d){if(0===d.g.count.value)return d.g.l=c,d.g.B=b,d.clone();d=d.clone();this.Oa(b);return d}d=this.h.Cb(c);d=Ab[d];if(!d)return a.call(this);d=this.ka?d.sb:d.pointerType;var f=Kb(c,this.h,d.h);return null===f?a.call(this):this.la?
431
+ Mb(d.h.N,{o:d,l:f,I:this,B:b}):Mb(d.h.N,{o:d,l:f})}});m.print&&(ya=m.print);m.printErr&&(za=m.printErr);m.wasmBinary&&(Aa=m.wasmBinary);if(m.preInit)for("function"==typeof m.preInit&&(m.preInit=[m.preInit]);0<m.preInit.length;)m.preInit.shift()();
432
+ var jb,zc,ib,Ma,Qb,Ac={_abort_js:()=>Pa(""),_embind_create_inheriting_constructor:(b,a,c)=>{b=U(b);a=lb(a,"wrapper");c=Q(c);var d=a.h,f=d.N,l=d.A.N,h=d.A.constructor;b=bb(b,function(...g){for(var n of d.A.Za)if(this[n]===l[n])throw new eb(`Pure virtual function ${n} must be implemented in JavaScript`);Object.defineProperty(this,"__parent",{value:f});this.__construct(...g)});f.__construct=function(...g){if(this===f)throw new P("Pass correct 'this' to __construct");g=h.implement(this,...g);mb(g);var n=
433
+ g.g;g.notifyOnDestruction();n.$=!0;Object.defineProperties(this,{g:{value:n}});pb(this);g=n.l;g=gb(d,g);if(fb.hasOwnProperty(g))throw new P(`Tried to register registered instance: ${g}`);fb[g]=this};f.__destruct=function(){if(this===f)throw new P("Pass correct 'this' to __destruct");mb(this);var g=this.g.l;g=gb(d,g);if(fb.hasOwnProperty(g))delete fb[g];else throw new P(`Tried to unregister unregistered instance: ${g}`);};b.prototype=Object.create(f);Object.assign(b.prototype,c);return T(b)},_embind_finalize_value_object:b=>
434
+ {var a=qb[b];delete qb[b];var c=a.Fa,d=a.O,f=a.Ra,l=f.map(h=>h.Gb).concat(f.map(h=>h.Pb));X([b],l,h=>{var g={},n,r;for([n,r]of f.entries()){const z=h[n],q=r.Eb,w=r.Fb,p=h[n+f.length],C=r.Ob,B=r.Qb;g[r.Ab]={read:H=>z.j(q(w,H)),write:(H,F)=>{var D=[];C(B,H,p.v(D,F));rb(D)},optional:z.optional}}return[{name:a.name,j:z=>{var q={},w;for(w in g)q[w]=g[w].read(z);d(z);return q},v:(z,q)=>{for(var w in g)if(!(w in q||g[w].optional))throw new TypeError(`Missing field: "${w}"`);var p=c();for(w in g)g[w].write(p,
435
+ q[w]);null!==z&&z.push(d,p);return p},H:sb,G:d}]})},_embind_register_bigint:()=>{},_embind_register_bool:(b,a,c,d)=>{a=U(a);V(b,{name:a,j:function(f){return!!f},v:function(f,l){return l?c:d},H:function(f){return this.j(L[f])},G:null})},_embind_register_class:(b,a,c,d,f,l,h,g,n,r,z,q,w)=>{z=U(z);l=Z(f,l);g&&=Z(h,g);r&&=Z(n,r);w=Z(q,w);var p=Db(z);Cb(p,function(){Zb(`Cannot construct ${z} due to unbound types`,[d])});X([b,a,c],d?[d]:[],C=>{C=C[0];if(d){var B=C.h;var H=B.N}else H=zb.prototype;C=bb(z,
436
+ function(...O){if(Object.getPrototypeOf(this)!==F)throw new P(`Use 'new' to construct ${z}`);if(void 0===D.S)throw new P(`${z} has no accessible constructor`);var M=D.S[O.length];if(void 0===M)throw new P(`Tried to invoke ctor of ${z} with invalid number of parameters (${O.length}) - expected (${Object.keys(D.S).toString()}) parameters instead!`);return M.apply(this,O)});var F=Object.create(H,{constructor:{value:C}});C.prototype=F;var D=new Eb(z,C,F,w,B,l,g,r);if(D.A){var K;(K=D.A).fa??(K.fa=[]);
437
+ D.A.fa.push(D)}B=new Nb(z,D,!0,!1,!1);K=new Nb(z+"*",D,!1,!1,!1);H=new Nb(z+" const*",D,!1,!0,!1);Ab[b]={pointerType:K,sb:H};Ob(p,C);return[B,K,H]})},_embind_register_class_class_function:(b,a,c,d,f,l,h)=>{var g=bc(c,d);a=U(a);a=cc(a);l=Z(f,l);X([],[b],n=>{function r(){Zb(`Cannot call ${z} due to unbound types`,g)}n=n[0];var z=`${n.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);var q=n.h.constructor;void 0===q[a]?(r.P=c-1,q[a]=r):(Bb(q,a,z),q[a].u[c-1]=r);X([],g,w=>{w=ac(z,[w[0],null].concat(w.slice(1)),
438
+ null,l,h);void 0===q[a].u?(w.P=c-1,q[a]=w):q[a].u[c-1]=w;if(n.h.fa)for(const p of n.h.fa)p.constructor.hasOwnProperty(a)||(p.constructor[a]=w);return[]});return[]})},_embind_register_class_class_property:(b,a,c,d,f,l,h,g)=>{a=U(a);l=Z(f,l);X([],[b],n=>{n=n[0];var r=`${n.name}.${a}`,z={get(){Zb(`Cannot access ${r} due to unbound types`,[c])},enumerable:!0,configurable:!0};z.set=g?()=>{Zb(`Cannot access ${r} due to unbound types`,[c])}:()=>{throw new P(`${r} is a read-only property`);};Object.defineProperty(n.h.constructor,
439
+ a,z);X([],[c],q=>{q=q[0];var w={get(){return q.j(l(d))},enumerable:!0};g&&(g=Z(h,g),w.set=p=>{var C=[];g(d,q.v(C,p));rb(C)});Object.defineProperty(n.h.constructor,a,w);return[]});return[]})},_embind_register_class_constructor:(b,a,c,d,f,l)=>{var h=bc(a,c);f=Z(d,f);X([],[b],g=>{g=g[0];var n=`constructor ${g.name}`;void 0===g.h.S&&(g.h.S=[]);if(void 0!==g.h.S[a-1])throw new P(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${g.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);
440
+ g.h.S[a-1]=()=>{Zb(`Cannot construct ${g.name} due to unbound types`,h)};X([],h,r=>{r.splice(1,0,null);g.h.S[a-1]=ac(n,r,null,f,l);return[]});return[]})},_embind_register_class_function:(b,a,c,d,f,l,h,g)=>{var n=bc(c,d);a=U(a);a=cc(a);l=Z(f,l);X([],[b],r=>{function z(){Zb(`Cannot call ${q} due to unbound types`,n)}r=r[0];var q=`${r.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);g&&r.h.Za.push(a);var w=r.h.N,p=w[a];void 0===p||void 0===p.u&&p.className!==r.name&&p.P===c-2?(z.P=c-2,z.className=
441
+ r.name,w[a]=z):(Bb(w,a,q),w[a].u[c-2]=z);X([],n,C=>{C=ac(q,C,r,l,h);void 0===w[a].u?(C.P=c-2,w[a]=C):w[a].u[c-2]=C;return[]});return[]})},_embind_register_class_property:(b,a,c,d,f,l,h,g,n,r)=>{a=U(a);f=Z(d,f);X([],[b],z=>{z=z[0];var q=`${z.name}.${a}`,w={get(){Zb(`Cannot access ${q} due to unbound types`,[c,h])},enumerable:!0,configurable:!0};w.set=n?()=>Zb(`Cannot access ${q} due to unbound types`,[c,h]):()=>{throw new P(q+" is a read-only property");};Object.defineProperty(z.h.N,a,w);X([],n?[c,
442
+ h]:[c],p=>{var C=p[0],B={get(){var F=dc(this,z,q+" getter");return C.j(f(l,F))},enumerable:!0};if(n){n=Z(g,n);var H=p[1];B.set=function(F){var D=dc(this,z,q+" setter"),K=[];n(r,D,H.v(K,F));rb(K)}}Object.defineProperty(z.h.N,a,B);return[]});return[]})},_embind_register_emval:b=>V(b,fc),_embind_register_enum:(b,a,c,d,f)=>{a=U(a);f=0===f?"object":1===f?"number":"string";switch(f){case "object":function h(){}h.values={};V(b,{name:a,constructor:h,valueType:f,j:function(g){return this.constructor.values[g]},
443
+ v:(g,n)=>n.value,H:gc(a,c,d),G:null});Cb(a,h);break;case "number":var l={};V(b,{name:a,Ca:l,valueType:f,j:g=>g,v:(g,n)=>n,H:gc(a,c,d),G:null});Cb(a,l);delete m[a].P;break;case "string":l={},V(b,{name:a,gb:{},ab:{},Ca:l,valueType:f,j:function(g){return this.ab[g]},v:function(g,n){return this.gb[n]},H:gc(a,c,d),G:null}),Cb(a,l),delete m[a].P}},_embind_register_enum_value:(b,a,c)=>{var d=lb(b,"enum");a=U(a);switch(d.valueType){case "object":b=d.constructor;d=Object.create(d.constructor.prototype,{value:{value:c},
444
+ constructor:{value:bb(`${d.name}_${a}`,function(){})}});b.values[c]=d;b[a]=d;break;case "number":d.Ca[a]=c;break;case "string":d.gb[a]=c,d.ab[c]=a,d.Ca[a]=a}},_embind_register_float:(b,a,c)=>{a=U(a);V(b,{name:a,j:d=>d,v:(d,f)=>f,H:hc(a,c),G:null})},_embind_register_function:(b,a,c,d,f,l)=>{var h=bc(a,c);b=U(b);b=cc(b);f=Z(d,f);Cb(b,function(){Zb(`Cannot call ${b} due to unbound types`,h)},a-1);X([],h,g=>{Ob(b,ac(b,[g[0],null].concat(g.slice(1)),null,f,l),a-1);return[]})},_embind_register_integer:(b,
445
+ a,c,d,f)=>{a=U(a);let l=g=>g;if(0===d){var h=32-8*c;l=g=>g<<h>>>h;f=l(f)}V(b,{name:a,j:l,v:(g,n)=>n,H:ic(a,c,0!==d),G:null})},_embind_register_memory_view:(b,a,c)=>{function d(l){return new f(Ea.buffer,N[l+4>>2],N[l>>2])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][a];c=U(c);V(b,{name:c,j:d,H:d},{Hb:!0})},_embind_register_std_string:(b,a)=>{a=U(a);V(b,{name:a,j(c){var d=(d=c+4)?lc(L,d,N[c>>2],!0):"";jb(c);return d},v(c,d){d instanceof ArrayBuffer&&
446
+ (d=new Uint8Array(d));var f,l="string"==typeof d;if(!(l||ArrayBuffer.isView(d)&&1==d.BYTES_PER_ELEMENT))throw new P("Cannot pass non-string to std::string");var h;if(l)for(f=h=0;f<d.length;++f){var g=d.charCodeAt(f);127>=g?h++:2047>=g?h+=2:55296<=g&&57343>=g?(h+=4,++f):h+=3}else h=d.length;f=h;h=zc(4+f+1);g=h+4;N[h>>2]=f;if(l){if(l=g,g=f+1,f=L,0<g){g=l+g-1;for(var n=0;n<d.length;++n){var r=d.codePointAt(n);if(127>=r){if(l>=g)break;f[l++]=r}else if(2047>=r){if(l+1>=g)break;f[l++]=192|r>>6;f[l++]=128|
447
+ r&63}else if(65535>=r){if(l+2>=g)break;f[l++]=224|r>>12;f[l++]=128|r>>6&63;f[l++]=128|r&63}else{if(l+3>=g)break;f[l++]=240|r>>18;f[l++]=128|r>>12&63;f[l++]=128|r>>6&63;f[l++]=128|r&63;n++}}f[l]=0}}else L.set(d,g);null!==c&&c.push(jb,h);return h},H:sb,G(c){jb(c)}})},_embind_register_std_wstring:(b,a,c)=>{c=U(c);if(2===a){var d=nc;var f=oc;var l=pc}else d=qc,f=rc,l=sc;V(b,{name:c,j:h=>{var g=d(h+4,N[h>>2]*a,!0);jb(h);return g},v:(h,g)=>{if("string"!=typeof g)throw new P(`Cannot pass non-string to C++ string type ${c}`);
448
+ var n=l(g),r=zc(4+n+a);N[r>>2]=n/a;f(g,r+4,n+a);null!==h&&h.push(jb,r);return r},H:sb,G(h){jb(h)}})},_embind_register_value_object:(b,a,c,d,f,l)=>{qb[b]={name:U(a),Fa:Z(c,d),O:Z(f,l),Ra:[]}},_embind_register_value_object_field:(b,a,c,d,f,l,h,g,n,r)=>{qb[b].Ra.push({Ab:U(a),Gb:c,Eb:Z(d,f),Fb:l,Pb:h,Ob:Z(g,n),Qb:r})},_embind_register_void:(b,a)=>{a=U(a);V(b,{Ib:!0,name:a,j:()=>{},v:()=>{}})},_emval_create_invoker:(b,a,c)=>{var [d,...f]=vc(b,a),l=d.v.bind(d),h=f.map(n=>n.H.bind(n));b--;var g=Array(b);
449
+ a=`methodCaller<(${f.map(n=>n.name)}) => ${d.name}>`;return uc(bb(a,(n,r,z,q)=>{for(var w=0,p=0;p<b;++p)g[p]=h[p](q+w),w+=8;switch(c){case 0:var C=Q(n).apply(null,g);break;case 2:C=Reflect.construct(Q(n),g);break;case 3:C=g[0];break;case 1:C=Q(n)[xc(r)](...g)}n=[];C=l(n,C);n.length&&(N[z>>2]=T(n));return C}))},_emval_decref:ec,_emval_get_module_property:b=>{b=xc(b);return T(m[b])},_emval_get_property:(b,a)=>{b=Q(b);a=Q(a);return T(b[a])},_emval_incref:b=>{9<b&&(db[b+1]+=1)},_emval_invoke:(b,a,c,d,
450
+ f)=>tc[b](a,c,d,f),_emval_new_array:()=>T([]),_emval_new_cstring:b=>T(xc(b)),_emval_new_object:()=>T({}),_emval_run_destructors:b=>{var a=Q(b);rb(a);ec(b)},_emval_set_property:(b,a,c)=>{b=Q(b);a=Q(a);c=Q(c);b[a]=c},clock_time_get:function(b,a,c,d){if(!(0<=b&&3>=b))return 28;b=Math.round(1E6*(0===b?Date.now():performance.now()));Xa=[b>>>0,(Wa=b,1<=+Math.abs(Wa)?0<Wa?+Math.floor(Wa/4294967296)>>>0:~~+Math.ceil((Wa-+(~~Wa>>>0))/4294967296)>>>0:0)];Ha[d>>2]=Xa[0];Ha[d+4>>2]=Xa[1];return 0},emscripten_resize_heap:b=>
451
+ {var a=L.length;b>>>=0;if(2147483648<b)return!1;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,b+100663296);a:{d=(Math.min(2147483648,65536*Math.ceil(Math.max(b,d)/65536))-Ma.buffer.byteLength+65535)/65536|0;try{Ma.grow(d);La();var f=1;break a}catch(l){}f=void 0}if(f)return!0}return!1},fd_close:()=>52,fd_seek:function(){return 70},fd_write:(b,a,c,d)=>{for(var f=0,l=0;l<c;l++){var h=N[a>>2],g=N[a+4>>2];a+=8;for(var n=0;n<g;n++){var r=b,z=L[h+n],q=yc[r];0===z||10===z?((1===r?ya:za)(lc(q)),q.length=
452
+ 0):q.push(z)}f+=g}N[d>>2]=f;return 0}},Bc;
453
+ Bc=await (async function(){function b(c){c=Bc=c.exports;jb=c.free;zc=c.malloc;ib=c.__getTypeName;Pb.vij=c.dynCall_vij;Pb.iij=c.dynCall_iij;Pb.ji=c.dynCall_ji;Pb.jiji=c.dynCall_jiji;Ma=c.memory;Qb=c.__indirect_function_table;La();return Bc}var a={env:Ac,wasi_snapshot_preview1:Ac};if(m.instantiateWasm)return new Promise(c=>{m.instantiateWasm(a,(d,f)=>{c(b(d,f))})});Sa??=m.locateFile?m.locateFile("canvas_advanced_c2d_only.wasm",ua):ua+"canvas_advanced_c2d_only.wasm";return b((await Va(a)).instance)}());
454
+ (function(){function b(){m.calledRun=!0;if(!Ba){Ka=!0;Bc.__wasm_call_ctors();Ca?.(m);m.onRuntimeInitialized?.();if(m.postRun)for("function"==typeof m.postRun&&(m.postRun=[m.postRun]);m.postRun.length;){var a=m.postRun.shift();Za.push(a)}Ya(Za)}}if(m.preRun)for("function"==typeof m.preRun&&(m.preRun=[m.preRun]);m.preRun.length;)ab();Ya($a);m.setStatus?(m.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>m.setStatus(""),1);b()},1)):b()})();Ka?moduleRtn=m:moduleRtn=new Promise((b,a)=>{Ca=b;Da=a});
450
455
  ;return moduleRtn}})();
451
456
  /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rive);
452
457
 
@@ -455,7 +460,7 @@ Ma??=h.locateFile?h.locateFile("canvas_advanced.wasm",oa):oa+"canvas_advanced.wa
455
460
  /* 5 */
456
461
  /***/ ((module) => {
457
462
 
458
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.43.1","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
463
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@rive-app/canvas-lite","version":"2.44.1","description":"A lite version of Rive\'s canvas based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)"],"license":"MIT","files":["rive.js","rive.js.map","rive.wasm","rive_fallback.wasm","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils","semantics"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}');
459
464
 
460
465
  /***/ }),
461
466
  /* 6 */
@@ -581,6 +586,17 @@ var SemanticTreeModel = /** @class */ (function () {
581
586
  SemanticTreeModel.prototype.nodeById = function (id) {
582
587
  return this._nodesById.get(id);
583
588
  };
589
+ /** The node with SemanticState.Focused, or undefined. */
590
+ SemanticTreeModel.prototype.focusedNode = function () {
591
+ // Manual iteration: runs every frame and must stop at the first hit (the
592
+ // TS target forbids for-of over Map iterators).
593
+ var it = this._nodesById.values();
594
+ for (var r = it.next(); !r.done; r = it.next()) {
595
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(r.value.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused))
596
+ return r.value;
597
+ }
598
+ return;
599
+ };
584
600
  /** Current index of a node among its siblings (or roots), or -1 if absent. */
585
601
  SemanticTreeModel.prototype.siblingIndexOf = function (id) {
586
602
  var node = this._nodesById.get(id);
@@ -1128,8 +1144,42 @@ __webpack_require__.r(__webpack_exports__);
1128
1144
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1129
1145
  /* harmony export */ AccessibilityOverlay: () => (/* binding */ AccessibilityOverlay)
1130
1146
  /* harmony export */ });
1131
- /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
1147
+ /* harmony import */ var _claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
1148
+ /* harmony import */ var _utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(11);
1149
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
1150
+
1132
1151
 
1152
+
1153
+ var warnedUnpositionedWrapper = false;
1154
+ /**
1155
+ * Warns once per page when no positioned element sits at or inside the canvas's
1156
+ * nearest scroll container: the overlay then can't scroll with the canvas. Reads only.
1157
+ */
1158
+ function warnIfWrapperUnpositioned(canvas) {
1159
+ if (warnedUnpositionedWrapper)
1160
+ return;
1161
+ // Null when detached (or display:none / fixed); nothing to judge yet.
1162
+ var offsetParent = canvas.offsetParent;
1163
+ if (!offsetParent)
1164
+ return;
1165
+ var scrolls = function (v) { return v === "auto" || v === "scroll" || v === "overlay"; };
1166
+ var scroller = null;
1167
+ var el = canvas.parentElement;
1168
+ // Bounds pathological nesting.
1169
+ var MAX_ANCESTOR_WALK = 32;
1170
+ for (var i = 0; el && el !== document.documentElement && i < MAX_ANCESTOR_WALK; i++, el = el.parentElement) {
1171
+ var style = getComputedStyle(el);
1172
+ if (scrolls(style.overflowX) || scrolls(style.overflowY)) {
1173
+ scroller = el;
1174
+ break;
1175
+ }
1176
+ }
1177
+ // Only the viewport scrolls: any offsetParent scrolls with the page.
1178
+ if (!scroller || scroller.contains(offsetParent))
1179
+ return;
1180
+ warnedUnpositionedWrapper = true;
1181
+ console.warn('[Rive] Semantics: give the element wrapping the <canvas> "position: relative" (or another positioned value) so the semantic overlay scrolls with the canvas. Without it, screen readers may scroll to stale positions when the canvas is inside a scrolling container.');
1182
+ }
1133
1183
  /**
1134
1184
  * Creates and manages an invisible DOM tree overlaying a Rive canvas. This is for
1135
1185
  * screen readers to discover and interact with the Rive content.
@@ -1147,7 +1197,7 @@ __webpack_require__.r(__webpack_exports__);
1147
1197
  var AccessibilityOverlay = /** @class */ (function () {
1148
1198
  function AccessibilityOverlay(options) {
1149
1199
  var _this = this;
1150
- var _a;
1200
+ var _a, _b;
1151
1201
  this.elements = new Map();
1152
1202
  /** Visually-hidden description spans keyed by node ID, referenced by aria-describedby. */
1153
1203
  this.descElements = new Map();
@@ -1157,6 +1207,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1157
1207
  this.pendingTextGeometry = [];
1158
1208
  /** Last measured box-size|text key per text element, to skip redundant re-measures. */
1159
1209
  this.textGeometryKeys = new WeakMap();
1210
+ /** Node data last passed to applyAttributes per element; see {@link setEditingHostNode}. */
1211
+ this.appliedNodes = new WeakMap();
1160
1212
  this.lastCanvasPositioning = {
1161
1213
  width: -1, height: -1, offsetTop: -1, offsetLeft: -1,
1162
1214
  };
@@ -1169,6 +1221,10 @@ var AccessibilityOverlay = /** @class */ (function () {
1169
1221
  this._geometryDirty = true;
1170
1222
  /** True while reconciling the DOM (reserved for future focus-sync guards). */
1171
1223
  this.isUpdating = false;
1224
+ /** Node whose element the editing host stands in for, or null. */
1225
+ this.editingHostNodeId = null;
1226
+ /** Semantic version last folded into the editing host's decoration. */
1227
+ this.editingHostSemanticVersion = -1;
1172
1228
  /**
1173
1229
  * Single child div of the overlay container that carries the artboard→CSS
1174
1230
  * transform. All semantic node elements are children of this div and express
@@ -1193,9 +1249,116 @@ var AccessibilityOverlay = /** @class */ (function () {
1193
1249
  this.canvas = options.canvas;
1194
1250
  this.semanticsOptions = options.semanticsOptions;
1195
1251
  this.allowFocusInterrupt = (_a = options.allowFocusInterrupt) !== null && _a !== void 0 ? _a : false;
1252
+ this.isEditingHostFocused = (_b = options.isEditingHostFocused) !== null && _b !== void 0 ? _b : (function () { return false; });
1196
1253
  this.container = this.createContainer(options.canvas);
1197
1254
  this.attachPositionObservers();
1255
+ warnIfWrapperUnpositioned(options.canvas);
1198
1256
  }
1257
+ /**
1258
+ * Hide the stood-in node's element (no duplicate textbox for AT); re-derive the previous
1259
+ * one's aria-hidden.
1260
+ */
1261
+ AccessibilityOverlay.prototype.setEditingHostNode = function (nodeId) {
1262
+ if (this.editingHostNodeId === nodeId)
1263
+ return;
1264
+ var previous = this.editingHostNodeId;
1265
+ this.editingHostNodeId = nodeId;
1266
+ if (previous !== null) {
1267
+ var previousEl = this.elements.get(previous);
1268
+ // Re-derive rather than un-hide: the node may have become Hidden mid-session.
1269
+ if (previousEl) {
1270
+ var previousNode = this.appliedNodes.get(previousEl);
1271
+ if (previousNode && this.isAriaHidden(previousNode)) {
1272
+ setAttr(previousEl, "aria-hidden", "true");
1273
+ }
1274
+ else {
1275
+ removeAttr(previousEl, "aria-hidden");
1276
+ }
1277
+ }
1278
+ }
1279
+ if (nodeId !== null) {
1280
+ var el = this.elements.get(nodeId);
1281
+ if (el)
1282
+ setAttr(el, "aria-hidden", "true");
1283
+ }
1284
+ };
1285
+ /**
1286
+ * Describe the focused text field on the host and hide its element; no-op unless
1287
+ * semantics changed.
1288
+ * @param force - apply even if semantics are unchanged (session start).
1289
+ */
1290
+ AccessibilityOverlay.prototype.syncEditingHost = function (tree, host, force) {
1291
+ var _a;
1292
+ if (!force && tree.semanticVersion === this.editingHostSemanticVersion)
1293
+ return;
1294
+ this.editingHostSemanticVersion = tree.semanticVersion;
1295
+ var node = tree.focusedNode();
1296
+ if (node === undefined || node.role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
1297
+ // Nothing to describe; drop the stale description rather than misname the host.
1298
+ if (this.editingHostNodeId !== null) {
1299
+ host.resetDecoration();
1300
+ this.setEditingHostNode(null);
1301
+ }
1302
+ return;
1303
+ }
1304
+ // Every key is passed on every call, nulls included, so nothing survives from
1305
+ // the previously described field.
1306
+ host.setSecure((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured));
1307
+ host.decorate({
1308
+ "aria-label": node.label || null,
1309
+ "aria-readonly": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly) ? "true" : null,
1310
+ "aria-multiline": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline) ? "true" : null,
1311
+ // Trait-gated to match applyAttributes.
1312
+ "aria-required": (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) &&
1313
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(node.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required)
1314
+ ? "true"
1315
+ : null,
1316
+ // The hint span applyAttributes maintains (update() runs earlier in the frame).
1317
+ "aria-describedby": (node.hint && ((_a = this.descElements.get(node.id)) === null || _a === void 0 ? void 0 : _a.id)) || null,
1318
+ });
1319
+ this.setEditingHostNode(node.id);
1320
+ };
1321
+ /** True while the editing host stands in for a node's element. */
1322
+ AccessibilityOverlay.prototype.hasEditingHost = function () {
1323
+ return this.editingHostNodeId !== null;
1324
+ };
1325
+ /**
1326
+ * Undo the stand-in; if the host still has DOM focus, move it to the focused node's
1327
+ * element so AT announces it.
1328
+ */
1329
+ AccessibilityOverlay.prototype.releaseEditingHost = function (tree, host) {
1330
+ var _a;
1331
+ host === null || host === void 0 ? void 0 : host.resetDecoration();
1332
+ this.setEditingHostNode(null);
1333
+ this.editingHostSemanticVersion = -1;
1334
+ if (!(host === null || host === void 0 ? void 0 : host.hasDomFocus()))
1335
+ return;
1336
+ var focusedNodeId = (_a = tree === null || tree === void 0 ? void 0 : tree.focusedNode()) === null || _a === void 0 ? void 0 : _a.id;
1337
+ if (focusedNodeId !== undefined)
1338
+ this.focusNodeElement(focusedNodeId);
1339
+ };
1340
+ /** Move DOM focus onto a node's element. No-op for a node with no element. */
1341
+ AccessibilityOverlay.prototype.focusNodeElement = function (nodeId) {
1342
+ var el = this.elements.get(nodeId);
1343
+ if (!el)
1344
+ return;
1345
+ this.focusElementInPlace(el);
1346
+ };
1347
+ // The overlay is positioned outside the canvas's scroll chain, so a plain focus()
1348
+ // would scroll the root instead; scroll the canvas into view through its real ancestors.
1349
+ AccessibilityOverlay.prototype.focusElementInPlace = function (el) {
1350
+ var _a, _b;
1351
+ this.syncContainerBeforeFocus();
1352
+ el.focus({ preventScroll: true });
1353
+ (_b = (_a = this.canvas).scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, {
1354
+ block: "nearest",
1355
+ inline: "nearest",
1356
+ behavior: "instant",
1357
+ });
1358
+ // The scroll moved the canvas; re-align now rather than after the observer throttle.
1359
+ this.syncContainerGeometry();
1360
+ this.observePosition();
1361
+ };
1199
1362
  AccessibilityOverlay.prototype.getSemanticOverlayContainer = function () {
1200
1363
  return this.container;
1201
1364
  };
@@ -1273,15 +1436,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1273
1436
  _this.observePosition();
1274
1437
  }, 500); // Throttle to avoid rapid style recalculations
1275
1438
  };
1439
+ /** Returns true when the container's size changed (node transforms need recomputing). */
1276
1440
  AccessibilityOverlay.prototype.syncContainerGeometry = function () {
1277
1441
  var rect = this.canvas.getBoundingClientRect();
1278
- var top = this.canvas.offsetTop;
1279
- var left = this.canvas.offsetLeft;
1280
- if (rect.width === this.lastCanvasPositioning.width &&
1281
- rect.height === this.lastCanvasPositioning.height &&
1442
+ var _a = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _a.top, left = _a.left;
1443
+ var sizeChanged = rect.width !== this.lastCanvasPositioning.width ||
1444
+ rect.height !== this.lastCanvasPositioning.height;
1445
+ if (!sizeChanged &&
1282
1446
  top === this.lastCanvasPositioning.offsetTop &&
1283
1447
  left === this.lastCanvasPositioning.offsetLeft)
1284
- return;
1448
+ return false;
1285
1449
  this.container.style.top = top + "px";
1286
1450
  this.container.style.left = left + "px";
1287
1451
  this.container.style.width = rect.width + "px";
@@ -1291,6 +1455,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1291
1455
  this.lastCanvasPositioning.height = rect.height;
1292
1456
  this.lastCanvasPositioning.offsetTop = top;
1293
1457
  this.lastCanvasPositioning.offsetLeft = left;
1458
+ return sizeChanged;
1459
+ };
1460
+ /**
1461
+ * Re-align the container right before focusing one of its elements. The position
1462
+ * observer re-syncs after scrolling on a throttle; focusing an element while the
1463
+ * container is stale would make the browser scroll the page to where it sits.
1464
+ */
1465
+ AccessibilityOverlay.prototype.syncContainerBeforeFocus = function () {
1466
+ if (this.syncContainerGeometry())
1467
+ this._geometryDirty = true;
1294
1468
  };
1295
1469
  AccessibilityOverlay.prototype.createContainer = function (canvas) {
1296
1470
  var _a, _b;
@@ -1300,10 +1474,13 @@ var AccessibilityOverlay = /** @class */ (function () {
1300
1474
  container.setAttribute("aria-label", (_b = (_a = this.semanticsOptions) === null || _a === void 0 ? void 0 : _a.riveCanvasLabel) !== null && _b !== void 0 ? _b : "Rive animation");
1301
1475
  // Size to the canvas's CSS layout box, not the parent container.
1302
1476
  var rect = canvas.getBoundingClientRect();
1477
+ var _c = (0,_utils_canvasOffset__WEBPACK_IMPORTED_MODULE_1__.canvasOffset)(this.canvas), top = _c.top, left = _c.left;
1303
1478
  container.style.cssText = [
1304
1479
  "position:absolute",
1305
- "top:".concat(canvas.offsetTop, "px"),
1306
- "left:".concat(canvas.offsetLeft, "px"),
1480
+ "top:".concat(top, "px"),
1481
+ "left:".concat(left, "px"),
1482
+ "line-height:normal",
1483
+ "font-size:16px",
1307
1484
  "width:".concat(rect.width, "px"),
1308
1485
  "height:".concat(rect.height, "px"),
1309
1486
  "overflow:hidden",
@@ -1480,8 +1657,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1480
1657
  // The cheap trait/state flag checks gate the (per-node) DOM queries below,
1481
1658
  // so the activeElement/closest/contains walks only run for a node that is
1482
1659
  // actually focusable + focused — not for every node on every frame.
1483
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) &&
1484
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Focused)) {
1660
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(nodeData.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) &&
1661
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(nodeData.stateFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Focused)) {
1485
1662
  var active = document.activeElement;
1486
1663
  // While focus is inside one of our modal dialogs, don't pull it back
1487
1664
  // out to a background node.
@@ -1489,8 +1666,16 @@ var AccessibilityOverlay = /** @class */ (function () {
1489
1666
  var trappedByModal = !!focusedModal &&
1490
1667
  this.container.contains(focusedModal) &&
1491
1668
  !focusedModal.contains(el);
1492
- if (active !== el && !trappedByModal && this.canMoveFocus()) {
1493
- el.focus();
1669
+ // Not while the proxy has focus (would steal the caret, drop the keyboard) nor onto
1670
+ // its aria-hidden stand-in.
1671
+ if (nodeId !== this.editingHostNodeId &&
1672
+ active !== el &&
1673
+ !trappedByModal &&
1674
+ !this.isEditingHostFocused() &&
1675
+ this.canMoveFocus()) {
1676
+ // No scrollIntoView: this runs on semantic diffs and must not drag the page.
1677
+ this.syncContainerBeforeFocus();
1678
+ el.focus({ preventScroll: true });
1494
1679
  }
1495
1680
  }
1496
1681
  // Recurse into children with this node's absolute artboard position.
@@ -1629,7 +1814,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1629
1814
  var el = document.createElement(tag);
1630
1815
  el.id = "".concat(this.nodeIdPrefix).concat(node.id);
1631
1816
  el.style.cssText = BASE_NODE_STYLE;
1632
- if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
1817
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
1633
1818
  // The positioned outer div is the AX element
1634
1819
  // VoiceOver uses for its highlight box; an inner <span> carries the text
1635
1820
  // without position:absolute (which would strip the span from VoiceOver's
@@ -1661,7 +1846,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1661
1846
  target = "last";
1662
1847
  if (!target)
1663
1848
  return;
1664
- e.preventDefault();
1849
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1665
1850
  var members = opts.members();
1666
1851
  var idx = members.indexOf(el);
1667
1852
  if (idx < 0)
@@ -1672,10 +1857,10 @@ var AccessibilityOverlay = /** @class */ (function () {
1672
1857
  : target === "first" ? members[0]
1673
1858
  : members[n - 1];
1674
1859
  if (next && next !== el) {
1675
- next.focus();
1860
+ _this.focusElementInPlace(next);
1676
1861
  var nextId = _this.nodeIdFromElement(next);
1677
1862
  if (nextId !== null)
1678
- _this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1863
+ _this.fireAction(nextId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1679
1864
  }
1680
1865
  });
1681
1866
  };
@@ -1685,31 +1870,31 @@ var AccessibilityOverlay = /** @class */ (function () {
1685
1870
  var nodeId = node.id;
1686
1871
  if (isClickableRole(role)) {
1687
1872
  el.addEventListener("click", function () {
1688
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1873
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1689
1874
  });
1690
1875
  // Links activate on Enter only (Space scrolls the page per browser
1691
1876
  // convention). All other clickable roles accept both Enter and Space.
1692
- var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
1877
+ var activationKeys_1 = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link ? ["Enter"] : ["Enter", " "];
1693
1878
  el.addEventListener("keydown", function (e) {
1694
1879
  if (activationKeys_1.includes(e.key)) {
1695
- e.preventDefault();
1696
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.tap);
1880
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1881
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.tap);
1697
1882
  }
1698
1883
  });
1699
1884
  }
1700
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
1885
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
1701
1886
  el.addEventListener("keydown", function (e) {
1702
1887
  if (e.key === "ArrowRight" || e.key === "ArrowUp") {
1703
- e.preventDefault();
1704
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.increase);
1888
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1889
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.increase);
1705
1890
  }
1706
1891
  else if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
1707
- e.preventDefault();
1708
- _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticActionType.decrease);
1892
+ (0,_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_0__.claimKeyEvent)(e);
1893
+ _this.fireAction(nodeId, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticActionType.decrease);
1709
1894
  }
1710
1895
  });
1711
1896
  }
1712
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
1897
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
1713
1898
  this.attachRovingNav(el, {
1714
1899
  includeHomeEnd: true,
1715
1900
  members: function () {
@@ -1722,7 +1907,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1722
1907
  },
1723
1908
  });
1724
1909
  }
1725
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton) {
1910
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton) {
1726
1911
  this.attachRovingNav(el, {
1727
1912
  includeHomeEnd: false,
1728
1913
  members: function () {
@@ -1737,15 +1922,31 @@ var AccessibilityOverlay = /** @class */ (function () {
1737
1922
  // Focus handler for nodes with the Focusable trait. When AT focuses an
1738
1923
  // element, notify the C++ runtime so it can update internal focus state
1739
1924
  // (visual focus rings, etc.). Gated on Focusable trait
1740
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable)) {
1925
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable)) {
1741
1926
  el.addEventListener("focus", function () {
1742
1927
  _this.requestFocus(nodeId);
1743
1928
  });
1744
1929
  }
1745
1930
  };
1746
1931
  // ---- Attribute application ----
1932
+ AccessibilityOverlay.prototype.isAriaHidden = function (node) {
1933
+ var role = node.role;
1934
+ var flags = node.stateFlags;
1935
+ // Hide from AT when explicitly hidden, or when an image has no accessible
1936
+ // name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
1937
+ // decorative instead.
1938
+ var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image && !node.label;
1939
+ // The <input> proxy is the accessible element for the node it stands in for.
1940
+ var isEditingHostStandIn = node.id === this.editingHostNodeId;
1941
+ return ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Hidden) ||
1942
+ // Obscured text fields stay reachable (value withheld, like a native password input).
1943
+ ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured) && role !== _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) ||
1944
+ isDecorativeImage ||
1945
+ isEditingHostStandIn);
1946
+ };
1747
1947
  AccessibilityOverlay.prototype.applyAttributes = function (el, node) {
1748
1948
  var _a, _b, _c;
1949
+ this.appliedNodes.set(el, node);
1749
1950
  var role = node.role;
1750
1951
  var flags = node.stateFlags;
1751
1952
  var traits = node.traitFlags;
@@ -1759,7 +1960,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1759
1960
  }
1760
1961
  // Links: a bare <a> with no href has no link semantics, so set the role
1761
1962
  // explicitly (ariaRoleForSemantic returns null for link → native <a>).
1762
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link) {
1963
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link) {
1763
1964
  setAttr(el, "role", "link");
1764
1965
  }
1765
1966
  // Tabindex — keep the screen-reader overlay out of the browser's sequential
@@ -1767,8 +1968,8 @@ var AccessibilityOverlay = /** @class */ (function () {
1767
1968
  // so AT/runtime focus sync can still target them when needed. List items are
1768
1969
  // included because Mobile Safari won't iterate them otherwise.
1769
1970
  if (isInteractiveRole(role) ||
1770
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable) ||
1771
- role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem) {
1971
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable) ||
1972
+ role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem) {
1772
1973
  setAttr(el, "tabindex", "-1");
1773
1974
  }
1774
1975
  else {
@@ -1781,7 +1982,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1781
1982
  else {
1782
1983
  removeAttr(el, "aria-label");
1783
1984
  }
1784
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider) {
1985
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider) {
1785
1986
  if (node.value) {
1786
1987
  // aria-valuenow must be numeric; keep the display string (e.g. "75%")
1787
1988
  // in aria-valuetext only.
@@ -1801,7 +2002,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1801
2002
  // TODO: aria-valuemin / aria-valuemax are required by ARIA.
1802
2003
  // Defaulting to horizontal; vertical sliders need orientation data from C++.
1803
2004
  setAttr(el, "aria-orientation", "horizontal");
1804
- setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
2005
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
1805
2006
  }
1806
2007
  else {
1807
2008
  removeAttr(el, "aria-valuenow");
@@ -1835,7 +2036,7 @@ var AccessibilityOverlay = /** @class */ (function () {
1835
2036
  // Text nodes: use textContent rather than aria-label so screen readers
1836
2037
  // announce the text in virtual/browse mode (aria-label on a bare <span>
1837
2038
  // with no widget role is ignored by some AT in document browse mode).
1838
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
2039
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
1839
2040
  var textSpan = (_a = el.querySelector(":scope > span")) !== null && _a !== void 0 ? _a : el;
1840
2041
  var text = (_b = node.label) !== null && _b !== void 0 ? _b : "";
1841
2042
  if (textSpan.textContent !== text)
@@ -1855,77 +2056,73 @@ var AccessibilityOverlay = /** @class */ (function () {
1855
2056
  // Only set the ARIA property when the trait is present. When the trait
1856
2057
  // is absent, remove the attribute so AT sees "not applicable" rather
1857
2058
  // than "false".
1858
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
1859
- setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Expanded));
2059
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Expandable) && ARIA_EXPANDED_ROLES.has(role)) {
2060
+ setBoolAttr(el, "aria-expanded", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Expanded));
1860
2061
  }
1861
2062
  else {
1862
2063
  removeAttr(el, "aria-expanded");
1863
2064
  }
1864
2065
  // aria-selected is required on ALL tabs per ARIA spec regardless of trait;
1865
2066
  // for other roles it is trait-gated and guarded to ARIA_SELECTED_ROLES.
1866
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab) {
1867
- setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
2067
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab) {
2068
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
1868
2069
  }
1869
- else if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
1870
- setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Selected));
2070
+ else if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Selectable) && ARIA_SELECTED_ROLES.has(role)) {
2071
+ setBoolAttr(el, "aria-selected", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Selected));
1871
2072
  }
1872
2073
  else {
1873
2074
  removeAttr(el, "aria-selected");
1874
2075
  }
1875
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
2076
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Checkable) && ARIA_CHECKED_ROLES.has(role)) {
1876
2077
  // Check state is a tri-state field, but not every checkable role
1877
2078
  // accepts all three values — see ARIA_MIXED_ROLES.
1878
- var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_0__.checkStateOf)(flags);
1879
- if (checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Mixed &&
2079
+ var checkState = (0,_types__WEBPACK_IMPORTED_MODULE_2__.checkStateOf)(flags);
2080
+ if (checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Mixed &&
1880
2081
  ARIA_MIXED_ROLES.has(role)) {
1881
2082
  setAttr(el, "aria-checked", "mixed");
1882
2083
  }
1883
2084
  else {
1884
- setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticCheckState.Checked);
2085
+ setBoolAttr(el, "aria-checked", checkState === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticCheckState.Checked);
1885
2086
  }
1886
2087
  }
1887
2088
  else {
1888
2089
  removeAttr(el, "aria-checked");
1889
2090
  }
1890
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Toggleable)) {
2091
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Toggleable)) {
1891
2092
  if (ARIA_PRESSED_ROLES.has(role)) {
1892
- setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
2093
+ setBoolAttr(el, "aria-pressed", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
1893
2094
  }
1894
2095
  else {
1895
2096
  removeAttr(el, "aria-pressed");
1896
2097
  }
1897
2098
  // switch uses aria-checked (not aria-pressed) for its on/off state.
1898
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl) {
1899
- setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Toggled));
2099
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl) {
2100
+ setBoolAttr(el, "aria-checked", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Toggled));
1900
2101
  }
1901
2102
  }
1902
2103
  else {
1903
2104
  removeAttr(el, "aria-pressed");
1904
2105
  }
1905
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
1906
- setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Required));
2106
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Requirable) && ARIA_REQUIRED_ROLES.has(role)) {
2107
+ setBoolAttr(el, "aria-required", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Required));
1907
2108
  }
1908
2109
  else {
1909
2110
  removeAttr(el, "aria-required");
1910
2111
  }
1911
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Enablable)) {
1912
- setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Disabled));
2112
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(traits, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Enablable)) {
2113
+ setBoolAttr(el, "aria-disabled", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Disabled));
1913
2114
  }
1914
2115
  else {
1915
2116
  removeAttr(el, "aria-disabled");
1916
2117
  }
1917
2118
  // ---- Non-trait states ----
1918
- // Hide from AT when explicitly hidden, or when an image has no accessible
1919
- // name — a nameless role="img" is a WCAG 1.1.1 violation; treat it as
1920
- // decorative instead.
1921
- var isDecorativeImage = role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image && !node.label;
1922
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Hidden) || (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Obscured) || isDecorativeImage) {
2119
+ if (this.isAriaHidden(node)) {
1923
2120
  setAttr(el, "aria-hidden", "true");
1924
2121
  }
1925
2122
  else {
1926
2123
  removeAttr(el, "aria-hidden");
1927
2124
  }
1928
- if ((0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.LiveRegion)) {
2125
+ if ((0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.LiveRegion)) {
1929
2126
  setAttr(el, "aria-live", "polite");
1930
2127
  }
1931
2128
  else {
@@ -1933,17 +2130,26 @@ var AccessibilityOverlay = /** @class */ (function () {
1933
2130
  }
1934
2131
  // textField-specific
1935
2132
  // TODO: Details here may change once we implement text inputs
1936
- if (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField) {
1937
- setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.ReadOnly));
1938
- setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Multiline));
2133
+ if (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField) {
2134
+ setBoolAttr(el, "aria-readonly", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.ReadOnly));
2135
+ setBoolAttr(el, "aria-multiline", (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Multiline));
1939
2136
  // Surface the current field value as DOM text so screen readers can
1940
2137
  // announce it. Only safe when the node has no semantic children —
1941
2138
  // setting textContent would remove any child elements from the DOM.
1942
2139
  if (node.children.length === 0) {
1943
- var value = (_c = node.value) !== null && _c !== void 0 ? _c : "";
2140
+ var value = (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Obscured) ? "" : ((_c = node.value) !== null && _c !== void 0 ? _c : "");
1944
2141
  if (el.textContent !== value)
1945
2142
  el.textContent = value;
1946
2143
  }
2144
+ else {
2145
+ // A value rendered earlier (before the node had children) must not linger,
2146
+ // least of all once the field turns Obscured.
2147
+ for (var _i = 0, _d = Array.from(el.childNodes); _i < _d.length; _i++) {
2148
+ var child = _d[_i];
2149
+ if (child.nodeType === Node.TEXT_NODE)
2150
+ child.remove();
2151
+ }
2152
+ }
1947
2153
  }
1948
2154
  else {
1949
2155
  removeAttr(el, "aria-multiline");
@@ -2007,7 +2213,7 @@ var AccessibilityOverlay = /** @class */ (function () {
2007
2213
  // Clear any CSS transform from a previous render pass.
2008
2214
  if (el.style.transform)
2009
2215
  el.style.transform = "";
2010
- if (node.role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text) {
2216
+ if (node.role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text) {
2011
2217
  this.pendingTextGeometry.push(el);
2012
2218
  }
2013
2219
  };
@@ -2066,7 +2272,8 @@ var AccessibilityOverlay = /** @class */ (function () {
2066
2272
  * Creates (on first call) and updates the artboard-space transform container.
2067
2273
  *
2068
2274
  * The container is sized to the artboard dimensions and carries a CSS
2069
- * `transform: matrix(...)` equivalent to `forwardMat / dpr`. All semantic
2275
+ * `transform: matrix(...)` that maps artboard coordinates to the canvas's CSS box
2276
+ * (forwardMat in backing-store pixels, scaled by CSS size / backing-store size). All semantic
2070
2277
  * node elements are children of this container and use raw artboard
2071
2278
  * coordinates as their CSS `left/top/width/height`, so the CSS compositor
2072
2279
  * applies the artboard→screen mapping in one pass.
@@ -2091,13 +2298,20 @@ var AccessibilityOverlay = /** @class */ (function () {
2091
2298
  var h = artboardBounds.maxY - artboardBounds.minY;
2092
2299
  this.transformContainer.style.width = Math.round(w) + "px";
2093
2300
  this.transformContainer.style.height = Math.round(h) + "px";
2094
- var s = 1 / (dpr || 1);
2095
- var a = forwardMat.xx * s;
2096
- var b = forwardMat.xy * s;
2097
- var c = forwardMat.yx * s;
2098
- var d = forwardMat.yy * s;
2099
- var tx = forwardMat.tx * s;
2100
- var ty = forwardMat.ty * s;
2301
+ // Backing-store pixels → CSS pixels. Measured rather than 1/dpr: a canvas can be
2302
+ // stretched by CSS, or have a stale backing store after a resize, and the drawn
2303
+ // content follows the CSS box either way. Equal to 1/dpr when they match.
2304
+ var cssWidth = this.lastCanvasPositioning.width;
2305
+ var cssHeight = this.lastCanvasPositioning.height;
2306
+ var fallback = 1 / (dpr || 1);
2307
+ var sx = this.canvas.width > 0 && cssWidth > 0 ? cssWidth / this.canvas.width : fallback;
2308
+ var sy = this.canvas.height > 0 && cssHeight > 0 ? cssHeight / this.canvas.height : fallback;
2309
+ var a = forwardMat.xx * sx;
2310
+ var b = forwardMat.xy * sy;
2311
+ var c = forwardMat.yx * sx;
2312
+ var d = forwardMat.yy * sy;
2313
+ var tx = forwardMat.tx * sx;
2314
+ var ty = forwardMat.ty * sy;
2101
2315
  this.transformContainer.style.transform =
2102
2316
  "matrix(".concat(a, ",").concat(b, ",").concat(c, ",").concat(d, ",").concat(tx, ",").concat(ty, ")");
2103
2317
  };
@@ -2120,11 +2334,11 @@ var AccessibilityOverlay = /** @class */ (function () {
2120
2334
  // ---------------------------------------------------------------------------
2121
2335
  /** aria-expanded: button, link, checkbox, switch (inherits button), tab. */
2122
2336
  var ARIA_EXPANDED_ROLES = new Set([
2123
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
2124
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link,
2125
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2126
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
2127
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
2337
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
2338
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link,
2339
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2340
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
2341
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
2128
2342
  ]);
2129
2343
  /**
2130
2344
  * aria-selected: tab is the only role in our current set that natively
@@ -2133,13 +2347,13 @@ var ARIA_EXPANDED_ROLES = new Set([
2133
2347
  * the set still lists it so the constraint is visible in one place.
2134
2348
  */
2135
2349
  var ARIA_SELECTED_ROLES = new Set([
2136
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab,
2350
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab,
2137
2351
  ]);
2138
2352
  /** aria-checked: checkbox, radio, switch. */
2139
2353
  var ARIA_CHECKED_ROLES = new Set([
2140
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2141
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton,
2142
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl,
2354
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2355
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton,
2356
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl,
2143
2357
  ]);
2144
2358
  /**
2145
2359
  * aria-checked="mixed": checkbox only. ARIA defines checkbox as three-valued
@@ -2148,7 +2362,7 @@ var ARIA_CHECKED_ROLES = new Set([
2148
2362
  * emitting a value they do not support.
2149
2363
  */
2150
2364
  var ARIA_MIXED_ROLES = new Set([
2151
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2365
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2152
2366
  ]);
2153
2367
  /**
2154
2368
  * aria-pressed: button only. switch is a button subclass in ARIA but uses
@@ -2156,13 +2370,13 @@ var ARIA_MIXED_ROLES = new Set([
2156
2370
  * excluded here and handled separately in the Toggleable block.
2157
2371
  */
2158
2372
  var ARIA_PRESSED_ROLES = new Set([
2159
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button,
2373
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button,
2160
2374
  ]);
2161
2375
  /** aria-required: checkbox, textbox, radiogroup. */
2162
2376
  var ARIA_REQUIRED_ROLES = new Set([
2163
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox,
2164
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField,
2165
- _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup,
2377
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox,
2378
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField,
2379
+ _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup,
2166
2380
  ]);
2167
2381
  // ---------------------------------------------------------------------------
2168
2382
  /** Style for visually-hidden description spans used with aria-describedby. */
@@ -2211,12 +2425,12 @@ function setBoolAttr(el, attr, value) {
2211
2425
  /** Roles that receive click/Enter/Space action handlers. */
2212
2426
  function isClickableRole(role) {
2213
2427
  switch (role) {
2214
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2215
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2216
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2217
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2218
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2219
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2428
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2429
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2430
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2431
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2432
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2433
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2220
2434
  return true;
2221
2435
  default:
2222
2436
  return false;
@@ -2225,14 +2439,14 @@ function isClickableRole(role) {
2225
2439
  /** Roles that receive tabindex="-1" for programmatic/AT focus (not Tab order). */
2226
2440
  function isInteractiveRole(role) {
2227
2441
  switch (role) {
2228
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2229
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2230
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2231
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2232
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
2233
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2234
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2235
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
2442
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2443
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2444
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2445
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2446
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
2447
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2448
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2449
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
2236
2450
  return true;
2237
2451
  default:
2238
2452
  return false;
@@ -2243,13 +2457,13 @@ function isInteractiveRole(role) {
2243
2457
  * dialog only when the Modal state flag is set.
2244
2458
  */
2245
2459
  function isModalDialogRole(role, flags) {
2246
- return (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog ||
2247
- (role === _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticState.Modal)));
2460
+ return (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog ||
2461
+ (role === _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog && (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasState)(flags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticState.Modal)));
2248
2462
  }
2249
2463
  /** Whether a node can receive focus: an interactive role or the Focusable trait. */
2250
2464
  function isFocusableNode(node) {
2251
2465
  return (isInteractiveRole(node.role) ||
2252
- (0,_types__WEBPACK_IMPORTED_MODULE_0__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_0__.SemanticTrait.Focusable));
2466
+ (0,_types__WEBPACK_IMPORTED_MODULE_2__.hasTrait)(node.traitFlags, _types__WEBPACK_IMPORTED_MODULE_2__.SemanticTrait.Focusable));
2253
2467
  }
2254
2468
  /**
2255
2469
  * Choose an HTML tag for a given role. Prefer native semantic elements
@@ -2258,9 +2472,9 @@ function isFocusableNode(node) {
2258
2472
  */
2259
2473
  function tagForRole(role) {
2260
2474
  switch (role) {
2261
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2475
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2262
2476
  return "a";
2263
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
2477
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
2264
2478
  // The outer div is the positioned AX element VoiceOver measures for its
2265
2479
  // highlight box. The text itself lives in a child <span> (see createElement).
2266
2480
  return "div";
@@ -2276,43 +2490,43 @@ function tagForRole(role) {
2276
2490
  */
2277
2491
  function ariaRoleForSemantic(role) {
2278
2492
  switch (role) {
2279
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.none:
2493
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.none:
2280
2494
  // TODO: Role "none" removes the node from the accessibility tree. For now, setting to Group, but maybe we want to switch to "none"
2281
2495
  // or "presentation".
2282
2496
  return "group";
2283
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.button:
2497
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.button:
2284
2498
  return "button";
2285
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.link:
2499
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.link:
2286
2500
  return null; // native <a>
2287
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.checkbox:
2501
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.checkbox:
2288
2502
  return "checkbox";
2289
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.switchControl:
2503
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.switchControl:
2290
2504
  return "switch";
2291
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.slider:
2505
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.slider:
2292
2506
  return "slider";
2293
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.textField:
2507
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField:
2294
2508
  return "textbox";
2295
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.image:
2509
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.image:
2296
2510
  return "img";
2297
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.group:
2511
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.group:
2298
2512
  return "group";
2299
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.list:
2513
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.list:
2300
2514
  return "list";
2301
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.listItem:
2515
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.listItem:
2302
2516
  return "listitem";
2303
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tab:
2517
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tab:
2304
2518
  return "tab";
2305
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.tabList:
2519
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.tabList:
2306
2520
  return "tablist";
2307
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.dialog:
2521
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.dialog:
2308
2522
  return "dialog";
2309
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.alertDialog:
2523
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.alertDialog:
2310
2524
  return "alertdialog";
2311
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioGroup:
2525
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioGroup:
2312
2526
  return "radiogroup";
2313
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.radioButton:
2527
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.radioButton:
2314
2528
  return "radio";
2315
- case _types__WEBPACK_IMPORTED_MODULE_0__.SemanticRole.text:
2529
+ case _types__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.text:
2316
2530
  // Text nodes use <span>; heading role is applied separately
2317
2531
  // when headingLevel > 0.
2318
2532
  return null;
@@ -2326,6 +2540,56 @@ function ariaRoleForSemantic(role) {
2326
2540
  /* 10 */
2327
2541
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2328
2542
 
2543
+ __webpack_require__.r(__webpack_exports__);
2544
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2545
+ /* harmony export */ claimKeyEvent: () => (/* binding */ claimKeyEvent),
2546
+ /* harmony export */ isKeyEventClaimed: () => (/* binding */ isKeyEventClaimed)
2547
+ /* harmony export */ });
2548
+ var claimed = new WeakSet();
2549
+ /**
2550
+ * Marks a key event as handled by a semantic overlay widget (and prevents its
2551
+ * default), so the Rive keyboard handler leaves it alone. A plain
2552
+ * `defaultPrevented` check can't tell these apart from host-page handlers.
2553
+ */
2554
+ function claimKeyEvent(event) {
2555
+ event.preventDefault();
2556
+ claimed.add(event);
2557
+ }
2558
+ function isKeyEventClaimed(event) {
2559
+ return claimed.has(event);
2560
+ }
2561
+
2562
+
2563
+ /***/ }),
2564
+ /* 11 */
2565
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2566
+
2567
+ __webpack_require__.r(__webpack_exports__);
2568
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2569
+ /* harmony export */ canvasOffset: () => (/* binding */ canvasOffset)
2570
+ /* harmony export */ });
2571
+ /**
2572
+ * Canvas offset within its offsetParent, minus the scroll of ancestors in between (they
2573
+ * move the canvas, not absolutely positioned siblings).
2574
+ */
2575
+ function canvasOffset(canvas) {
2576
+ var top = canvas.offsetTop;
2577
+ var left = canvas.offsetLeft;
2578
+ var offsetParent = canvas.offsetParent;
2579
+ if (!offsetParent)
2580
+ return { top: top, left: left };
2581
+ for (var el = canvas.parentElement; el && el !== offsetParent; el = el.parentElement) {
2582
+ top -= el.scrollTop;
2583
+ left -= el.scrollLeft;
2584
+ }
2585
+ return { top: top, left: left };
2586
+ }
2587
+
2588
+
2589
+ /***/ }),
2590
+ /* 12 */
2591
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2592
+
2329
2593
  __webpack_require__.r(__webpack_exports__);
2330
2594
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2331
2595
  /* harmony export */ AudioAssetWrapper: () => (/* reexport safe */ _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__.AudioAssetWrapper),
@@ -2346,11 +2610,11 @@ __webpack_require__.r(__webpack_exports__);
2346
2610
  /* harmony export */ registerTouchInteractions: () => (/* reexport safe */ _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__.registerTouchInteractions),
2347
2611
  /* harmony export */ sanitizeUrl: () => (/* reexport safe */ _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__.sanitizeUrl)
2348
2612
  /* harmony export */ });
2349
- /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
2350
- /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
2351
- /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(13);
2352
- /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
2353
- /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
2613
+ /* harmony import */ var _registerTouchInteractions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
2614
+ /* harmony import */ var _registerKeyboardInteractions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
2615
+ /* harmony import */ var _sanitizeUrl__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
2616
+ /* harmony import */ var _finalizationRegistry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(18);
2617
+ /* harmony import */ var _riveFont__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(19);
2354
2618
 
2355
2619
 
2356
2620
 
@@ -2359,7 +2623,7 @@ __webpack_require__.r(__webpack_exports__);
2359
2623
 
2360
2624
 
2361
2625
  /***/ }),
2362
- /* 11 */
2626
+ /* 13 */
2363
2627
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2364
2628
 
2365
2629
  __webpack_require__.r(__webpack_exports__);
@@ -2367,6 +2631,11 @@ __webpack_require__.r(__webpack_exports__);
2367
2631
  /* harmony export */ registerTouchInteractions: () => (/* binding */ registerTouchInteractions)
2368
2632
  /* harmony export */ });
2369
2633
  var _this = undefined;
2634
+ // A detented wheel reports lines; the runtime wants pixels.
2635
+ var PIXELS_PER_LINE = 16;
2636
+ // ScrollPhase.update. The DOM reports no gesture phase, so every wheel event
2637
+ // is an update and the runtime closes the gesture once it goes quiet.
2638
+ var SCROLL_PHASE_UPDATE = 1;
2370
2639
  /**
2371
2640
  * Extracts ClientCoordinates from a TouchList, respecting multi-touch vs.
2372
2641
  * single-touch mode. In single-touch mode, only the touch matching
@@ -2434,11 +2703,12 @@ var getClientCoordinates = function (event, isTouchScrollEnabled, enableMultiTou
2434
2703
  ];
2435
2704
  };
2436
2705
  /**
2437
- * Registers mouse move/up/down callback handlers on the canvas to send meaningful coordinates to
2438
- * the state machine pointer move/up/down functions based on cursor interaction
2706
+ * Registers mouse move/up/down and wheel callback handlers on the canvas to send meaningful
2707
+ * coordinates to the state machine pointer move/up/down/scroll functions based on cursor
2708
+ * interaction
2439
2709
  */
2440
2710
  var registerTouchInteractions = function (_a) {
2441
- var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f, advanceAndDrain = _a.advanceAndDrain;
2711
+ var canvas = _a.canvas, artboard = _a.artboard, _b = _a.stateMachines, stateMachines = _b === void 0 ? [] : _b, renderer = _a.renderer, rive = _a.rive, fit = _a.fit, alignment = _a.alignment, _c = _a.isTouchScrollEnabled, isTouchScrollEnabled = _c === void 0 ? false : _c, _d = _a.dispatchPointerExit, dispatchPointerExit = _d === void 0 ? true : _d, _e = _a.enableMultiTouch, enableMultiTouch = _e === void 0 ? false : _e, _f = _a.layoutScaleFactor, layoutScaleFactor = _f === void 0 ? 1.0 : _f, advanceAndDrain = _a.advanceAndDrain, summonKeyboard = _a.summonKeyboard, isTextProxyFocused = _a.isTextProxyFocused;
2442
2712
  if (!canvas ||
2443
2713
  !stateMachines.length ||
2444
2714
  !renderer ||
@@ -2447,6 +2717,13 @@ var registerTouchInteractions = function (_a) {
2447
2717
  typeof window === "undefined") {
2448
2718
  return null;
2449
2719
  }
2720
+ // A gesture latched before the previous listeners came down (a pause, say)
2721
+ // never reached its idle timeout, and would take the next wheel wherever
2722
+ // it lands. These instances are live here; at teardown they may not be.
2723
+ for (var _i = 0, stateMachines_1 = stateMachines; _i < stateMachines_1.length; _i++) {
2724
+ var stateMachine = stateMachines_1[_i];
2725
+ stateMachine.cancelScroll();
2726
+ }
2450
2727
  /**
2451
2728
  * After a touchend event, some browsers may fire synthetic mouse events
2452
2729
  * (mouseover, mousedown, mousemove, mouseup) if the touch interaction did not cause
@@ -2458,8 +2735,10 @@ var registerTouchInteractions = function (_a) {
2458
2735
  * We're keeping track of the previous event to not send the synthetic mouse events if the
2459
2736
  * touch event was a click (touchstart -> touchend).
2460
2737
  *
2461
- * This is only needed when `isTouchScrollEnabled` is false
2462
- * When true, `preventDefault()` is called which prevents this behaviour.
2738
+ * Emulated events only occur when `isTouchScrollEnabled` is true; when false,
2739
+ * touchstart is default-prevented, which suppresses them.
2740
+ * Emulated mousedown is prevented while the proxy is focused, or it would blur it and
2741
+ * drop the keyboard.
2463
2742
  **/
2464
2743
  var _prevEventType = null;
2465
2744
  var _syntheticEventsActive = false;
@@ -2470,12 +2749,43 @@ var registerTouchInteractions = function (_a) {
2470
2749
  * Reset to null when the primary finger lifts (or touchcancel is called)
2471
2750
  */
2472
2751
  var _primaryTouchId = null;
2752
+ /**
2753
+ * Maps client-space points into Artboard space through the fit and alignment
2754
+ * of the canvas.
2755
+ */
2756
+ var mapToArtboard = function (boundingRect, points) {
2757
+ var forwardMatrix = rive.computeAlignment(fit, alignment, {
2758
+ minX: 0,
2759
+ minY: 0,
2760
+ maxX: boundingRect.width,
2761
+ maxY: boundingRect.height,
2762
+ }, artboard.bounds, layoutScaleFactor);
2763
+ var invertedMatrix = new rive.Mat2D();
2764
+ forwardMatrix.invert(invertedMatrix);
2765
+ var mapped = points.map(function (_a) {
2766
+ var clientX = _a.clientX, clientY = _a.clientY;
2767
+ var canvasX = clientX - boundingRect.left;
2768
+ var canvasY = clientY - boundingRect.top;
2769
+ var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
2770
+ var transformedVector = rive.mapXY(invertedMatrix, canvasCoordinatesVector);
2771
+ var point = { x: transformedVector.x(), y: transformedVector.y() };
2772
+ transformedVector.delete();
2773
+ canvasCoordinatesVector.delete();
2774
+ return point;
2775
+ });
2776
+ invertedMatrix.delete();
2777
+ forwardMatrix.delete();
2778
+ return mapped;
2779
+ };
2473
2780
  var processEventCallback = function (event) {
2474
2781
  var _a;
2475
2782
  // Exit early out of all synthetic mouse events
2476
2783
  // https://stackoverflow.com/questions/9656990/how-to-prevent-simulated-mouse-events-in-mobile-browsers
2477
2784
  // https://stackoverflow.com/questions/25572070/javascript-touchend-versus-click-dilemma
2478
2785
  if (_syntheticEventsActive && event instanceof MouseEvent) {
2786
+ if (event.type === "mousedown" && (isTextProxyFocused === null || isTextProxyFocused === void 0 ? void 0 : isTextProxyFocused())) {
2787
+ event.preventDefault();
2788
+ }
2479
2789
  // Synthetic event finished
2480
2790
  if (event.type == "mouseup") {
2481
2791
  _syntheticEventsActive = false;
@@ -2499,33 +2809,11 @@ var registerTouchInteractions = function (_a) {
2499
2809
  }
2500
2810
  }
2501
2811
  var coordinateSets = getClientCoordinates(event, isTouchScrollEnabled, enableMultiTouch, enableMultiTouch ? null : _primaryTouchId);
2502
- var forwardMatrix = rive.computeAlignment(fit, alignment, {
2503
- minX: 0,
2504
- minY: 0,
2505
- maxX: boundingRect.width,
2506
- maxY: boundingRect.height,
2507
- }, artboard.bounds, layoutScaleFactor);
2508
- var invertedMatrix = new rive.Mat2D();
2509
- forwardMatrix.invert(invertedMatrix);
2510
- coordinateSets.forEach(function (coordinateSet) {
2511
- var clientX = coordinateSet.clientX;
2512
- var clientY = coordinateSet.clientY;
2513
- if (!clientX && !clientY) {
2514
- return;
2515
- }
2516
- var canvasX = clientX - boundingRect.left;
2517
- var canvasY = clientY - boundingRect.top;
2518
- var canvasCoordinatesVector = new rive.Vec2D(canvasX, canvasY);
2519
- var transformedVector = rive.mapXY(invertedMatrix, canvasCoordinatesVector);
2520
- var transformedX = transformedVector.x();
2521
- var transformedY = transformedVector.y();
2522
- coordinateSet.transformedX = transformedX;
2523
- coordinateSet.transformedY = transformedY;
2524
- transformedVector.delete();
2525
- canvasCoordinatesVector.delete();
2812
+ var positionedSets = coordinateSets.filter(function (coordinateSet) { return coordinateSet.clientX || coordinateSet.clientY; });
2813
+ mapToArtboard(boundingRect, positionedSets).forEach(function (point, i) {
2814
+ positionedSets[i].transformedX = point.x;
2815
+ positionedSets[i].transformedY = point.y;
2526
2816
  });
2527
- invertedMatrix.delete();
2528
- forwardMatrix.delete();
2529
2817
  switch (event.type) {
2530
2818
  /**
2531
2819
  * There's a 2px buffer for a hitRadius when translating the pointer coordinates
@@ -2549,8 +2837,8 @@ var registerTouchInteractions = function (_a) {
2549
2837
  });
2550
2838
  }
2551
2839
  };
2552
- for (var _i = 0, stateMachines_1 = stateMachines; _i < stateMachines_1.length; _i++) {
2553
- var stateMachine = stateMachines_1[_i];
2840
+ for (var _i = 0, stateMachines_2 = stateMachines; _i < stateMachines_2.length; _i++) {
2841
+ var stateMachine = stateMachines_2[_i];
2554
2842
  _loop_1(stateMachine);
2555
2843
  }
2556
2844
  break;
@@ -2563,8 +2851,8 @@ var registerTouchInteractions = function (_a) {
2563
2851
  stateMachine.pointerMove(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
2564
2852
  });
2565
2853
  };
2566
- for (var _b = 0, stateMachines_2 = stateMachines; _b < stateMachines_2.length; _b++) {
2567
- var stateMachine = stateMachines_2[_b];
2854
+ for (var _b = 0, stateMachines_3 = stateMachines; _b < stateMachines_3.length; _b++) {
2855
+ var stateMachine = stateMachines_3[_b];
2568
2856
  _loop_2(stateMachine);
2569
2857
  }
2570
2858
  break;
@@ -2577,12 +2865,12 @@ var registerTouchInteractions = function (_a) {
2577
2865
  stateMachine.pointerDown(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
2578
2866
  });
2579
2867
  };
2580
- for (var _c = 0, stateMachines_3 = stateMachines; _c < stateMachines_3.length; _c++) {
2581
- var stateMachine = stateMachines_3[_c];
2868
+ for (var _c = 0, stateMachines_4 = stateMachines; _c < stateMachines_4.length; _c++) {
2869
+ var stateMachine = stateMachines_4[_c];
2582
2870
  _loop_3(stateMachine);
2583
2871
  }
2584
2872
  // Advance the state machine immediately so pointer down(s) takes effect synchronously
2585
- advanceAndDrain(0);
2873
+ advanceAndDrain(0, { pointerDown: true });
2586
2874
  break;
2587
2875
  }
2588
2876
  // Pointer click released on the canvas
@@ -2593,12 +2881,15 @@ var registerTouchInteractions = function (_a) {
2593
2881
  stateMachine.pointerExit(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
2594
2882
  });
2595
2883
  };
2596
- for (var _d = 0, stateMachines_4 = stateMachines; _d < stateMachines_4.length; _d++) {
2597
- var stateMachine = stateMachines_4[_d];
2884
+ for (var _d = 0, stateMachines_5 = stateMachines; _d < stateMachines_5.length; _d++) {
2885
+ var stateMachine = stateMachines_5[_d];
2598
2886
  _loop_4(stateMachine);
2599
2887
  }
2600
2888
  // Advance the state machine immediately so pointer up(s) takes effect synchronously
2601
2889
  advanceAndDrain(0);
2890
+ // Still inside the touch gesture — summon the keyboard if the tap focused a
2891
+ // text input
2892
+ summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
2602
2893
  // Release the primary touch lock once that finger lifts so the next
2603
2894
  // touchstart can claim a new primary finger.
2604
2895
  if (!enableMultiTouch &&
@@ -2613,12 +2904,13 @@ var registerTouchInteractions = function (_a) {
2613
2904
  stateMachine.pointerUp(coordinateSet.transformedX, coordinateSet.transformedY, coordinateSet.identifier);
2614
2905
  });
2615
2906
  };
2616
- for (var _e = 0, stateMachines_5 = stateMachines; _e < stateMachines_5.length; _e++) {
2617
- var stateMachine = stateMachines_5[_e];
2907
+ for (var _e = 0, stateMachines_6 = stateMachines; _e < stateMachines_6.length; _e++) {
2908
+ var stateMachine = stateMachines_6[_e];
2618
2909
  _loop_5(stateMachine);
2619
2910
  }
2620
2911
  // Advance the state machine immediately so pointer up(s) takes effect synchronously
2621
2912
  advanceAndDrain(0);
2913
+ summonKeyboard === null || summonKeyboard === void 0 ? void 0 : summonKeyboard();
2622
2914
  break;
2623
2915
  }
2624
2916
  default:
@@ -2627,6 +2919,71 @@ var registerTouchInteractions = function (_a) {
2627
2919
  var touchCancelCallback = function () {
2628
2920
  _primaryTouchId = null;
2629
2921
  };
2922
+ /**
2923
+ * Forwards wheel and trackpad scrolling to the state machines. The page keeps
2924
+ * the wheel unless a scroll view actually moves, so it still scrolls when
2925
+ * Rive has nothing to scroll or a view sits at its edge.
2926
+ */
2927
+ var wheelCallback = function (event) {
2928
+ // Pinch zoom arrives as a ctrl+wheel and belongs to the page. A wheel that
2929
+ // can't be cancelled is part of a sequence the page is already scrolling;
2930
+ // taking it too would move both.
2931
+ if (event.ctrlKey || !event.cancelable) {
2932
+ return;
2933
+ }
2934
+ // Read before the deltas: Firefox reports pixels once a delta has been
2935
+ // read first.
2936
+ var deltaMode = event.deltaMode;
2937
+ var deltaX = event.deltaX;
2938
+ var deltaY = event.deltaY;
2939
+ // Shift+wheel scrolls sideways. Most browsers already report it on the x
2940
+ // axis; a vertical-only view would decline it on y.
2941
+ if (event.shiftKey && !deltaX) {
2942
+ deltaX = deltaY;
2943
+ deltaY = 0;
2944
+ }
2945
+ var boundingRect = event.currentTarget.getBoundingClientRect();
2946
+ // A page is the canvas's visible size, the nearest the host can get to the
2947
+ // scroll view's own.
2948
+ var toPixelsX = deltaMode === WheelEvent.DOM_DELTA_LINE
2949
+ ? PIXELS_PER_LINE
2950
+ : deltaMode === WheelEvent.DOM_DELTA_PAGE
2951
+ ? boundingRect.width
2952
+ : 1;
2953
+ var toPixelsY = deltaMode === WheelEvent.DOM_DELTA_LINE
2954
+ ? PIXELS_PER_LINE
2955
+ : deltaMode === WheelEvent.DOM_DELTA_PAGE
2956
+ ? boundingRect.height
2957
+ : 1;
2958
+ // The DOM reports how far to scroll; the runtime wants how far content
2959
+ // travels.
2960
+ var scrollX = -deltaX * toPixelsX;
2961
+ var scrollY = -deltaY * toPixelsY;
2962
+ if (!scrollX && !scrollY) {
2963
+ return;
2964
+ }
2965
+ // Mapping both ends of the delta keeps only the scale of the fit.
2966
+ var _a = mapToArtboard(boundingRect, [
2967
+ { clientX: event.clientX, clientY: event.clientY },
2968
+ { clientX: event.clientX + scrollX, clientY: event.clientY + scrollY },
2969
+ ]), position = _a[0], moved = _a[1];
2970
+ // The DOM never says whether a pixel delta came from a trackpad, so it
2971
+ // counts as precise either way, as it does in the browser's own scrolling.
2972
+ var precise = deltaMode === WheelEvent.DOM_DELTA_PIXEL;
2973
+ var timeStamp = event.timeStamp / 1000;
2974
+ // A latched state machine owns the rest of its gesture, even past its edge.
2975
+ var latched = stateMachines.filter(function (sm) { return sm.hasScrollLatch(); });
2976
+ var ordered = latched.concat(stateMachines.filter(function (sm) { return latched.indexOf(sm) === -1; }));
2977
+ var consumed = ordered.some(function (stateMachine) {
2978
+ return stateMachine.pointerScroll(position.x, position.y, moved.x - position.x, moved.y - position.y, SCROLL_PHASE_UPDATE, precise, timeStamp, 0) !== 0;
2979
+ });
2980
+ if (!consumed) {
2981
+ return;
2982
+ }
2983
+ event.preventDefault();
2984
+ // Advance now so the scroll lands on the next frame drawn.
2985
+ advanceAndDrain(0);
2986
+ };
2630
2987
  var callback = processEventCallback.bind(_this);
2631
2988
  canvas.addEventListener("mouseover", callback);
2632
2989
  canvas.addEventListener("mouseout", callback);
@@ -2641,6 +2998,8 @@ var registerTouchInteractions = function (_a) {
2641
2998
  });
2642
2999
  canvas.addEventListener("touchend", callback);
2643
3000
  canvas.addEventListener("touchcancel", touchCancelCallback);
3001
+ // Not passive, or preventDefault could not keep the page from scrolling.
3002
+ canvas.addEventListener("wheel", wheelCallback, { passive: false });
2644
3003
  return function () {
2645
3004
  canvas.removeEventListener("mouseover", callback);
2646
3005
  canvas.removeEventListener("mouseout", callback);
@@ -2651,12 +3010,13 @@ var registerTouchInteractions = function (_a) {
2651
3010
  canvas.removeEventListener("touchstart", callback);
2652
3011
  canvas.removeEventListener("touchend", callback);
2653
3012
  canvas.removeEventListener("touchcancel", touchCancelCallback);
3013
+ canvas.removeEventListener("wheel", wheelCallback);
2654
3014
  };
2655
3015
  };
2656
3016
 
2657
3017
 
2658
3018
  /***/ }),
2659
- /* 12 */
3019
+ /* 14 */
2660
3020
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2661
3021
 
2662
3022
  __webpack_require__.r(__webpack_exports__);
@@ -2664,6 +3024,43 @@ __webpack_require__.r(__webpack_exports__);
2664
3024
  /* harmony export */ FocusSessionState: () => (/* binding */ FocusSessionState),
2665
3025
  /* harmony export */ KeyboardInteractions: () => (/* binding */ KeyboardInteractions)
2666
3026
  /* harmony export */ });
3027
+ /* harmony import */ var _keyMap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
3028
+ /* harmony import */ var _semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);
3029
+ /* harmony import */ var _textInputProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
3030
+
3031
+
3032
+
3033
+ /**
3034
+ * Defaults suppressed while typing (scroll/navigate/submit). Tab is traversal's; proxy
3035
+ * Space returns earlier as a printable.
3036
+ */
3037
+ var EDITING_NAV_CODES = new Set([
3038
+ "Space",
3039
+ "ArrowLeft",
3040
+ "ArrowRight",
3041
+ "ArrowUp",
3042
+ "ArrowDown",
3043
+ "Backspace",
3044
+ "Delete",
3045
+ "Home",
3046
+ "End",
3047
+ "Enter",
3048
+ "NumpadEnter",
3049
+ ]);
3050
+ /** A keystroke that types a character (not a Ctrl/Cmd shortcut). */
3051
+ function isPrintable(event) {
3052
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
3053
+ }
3054
+ function isArrowKey(key) {
3055
+ return (key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.left || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.right || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.up || key === _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.down);
3056
+ }
3057
+ /**
3058
+ * Alt/Ctrl/Meta arrows are browser/OS shortcuts (Alt+Left = back, Cmd+Arrow, etc.).
3059
+ * Shift is allowed: it is the spatial-navigation chord in Vivaldi/Opera.
3060
+ */
3061
+ function hasShortcutModifier(event) {
3062
+ return event.altKey || event.ctrlKey || event.metaKey;
3063
+ }
2667
3064
  /**
2668
3065
  * Tracks the relationship between DOM focus inside this Rive focus domain (canvas or semantic overlay)
2669
3066
  * and Rive's internal focus for the current focus session.
@@ -2689,7 +3086,8 @@ var FocusSessionState;
2689
3086
  FocusSessionState["RiveFocused"] = "riveFocused";
2690
3087
  })(FocusSessionState || (FocusSessionState = {}));
2691
3088
  /**
2692
- * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas> or semantic overlay).
3089
+ * Manages keyboard and DOM focus interactions for Rive's focus domain (<canvas>, semantic
3090
+ * overlay, text input proxy). Owns the proxy and the text input session state.
2693
3091
  * Because keyboard events can apply on either part of the domain, we need to track what events we should
2694
3092
  * handle/intercept, and when to release focus back to the page outside of the domain.
2695
3093
  *
@@ -2701,7 +3099,7 @@ var KeyboardInteractions = /** @class */ (function () {
2701
3099
  function KeyboardInteractions(_a) {
2702
3100
  var canvas = _a.canvas, stateMachine = _a.stateMachine, hasFocusNodes = _a.hasFocusNodes, getOverlayElement = _a.getOverlayElement;
2703
3101
  var _this = this;
2704
- var _b;
3102
+ var _b, _c;
2705
3103
  this.focusSessionState = FocusSessionState.NotFocused;
2706
3104
  /** Whether the canvas currently has browser DOM focus. */
2707
3105
  this.canvasHasFocus = false;
@@ -2709,6 +3107,19 @@ var KeyboardInteractions = /** @class */ (function () {
2709
3107
  this.focusDomainReleased = false;
2710
3108
  /** Overlay element currently wired with focusin/keydown listeners, if any. */
2711
3109
  this.currentOverlayElement = null;
3110
+ /** Codes whose keydown an overlay widget took, so their keyup is skipped too. */
3111
+ this.claimedKeyCodes = new Set();
3112
+ this.textInputSessionActive = false;
3113
+ /**
3114
+ * The proxy is always empty: copy Rive's selection; always preventDefault.
3115
+ */
3116
+ this.onCopy = function (event) {
3117
+ var _a;
3118
+ event.preventDefault();
3119
+ var selected = _this.mainSm.selectedText();
3120
+ if (selected)
3121
+ (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.setData("text/plain", selected);
3122
+ };
2712
3123
  /**
2713
3124
  * Handles the canvas gaining browser focus. The behavior differs based on how focus was gained -
2714
3125
  *
@@ -2724,10 +3135,11 @@ var KeyboardInteractions = /** @class */ (function () {
2724
3135
  _this.syncOverlayListener();
2725
3136
  _this.canvasHasFocus = true;
2726
3137
  _this.focusDomainReleased = false;
2727
- if (!_this.hasFocusNodes)
2728
- return;
2729
- if (_this.mainSm.focusState().hasFocus)
3138
+ if (_this.isInFocusDomain(event.relatedTarget) ||
3139
+ !_this.hasFocusNodes ||
3140
+ _this.mainSm.focusState().hasFocus) {
2730
3141
  return;
3142
+ }
2731
3143
  _this.focusSessionState = FocusSessionState.EntryPending;
2732
3144
  // Pointer focus waits for the user's next Tab (handled in onKeyDown). Keyboard focus enters now.
2733
3145
  if (!_this.isKeyboardDrivenFocus())
@@ -2746,11 +3158,13 @@ var KeyboardInteractions = /** @class */ (function () {
2746
3158
  * When we're not in either of those buckets, it's safe to call `clearFocus()` on the SMI.
2747
3159
  */
2748
3160
  this.onCanvasBlur = function (event) {
3161
+ // Must stay before the state reset because beginTextInputSession sets the session state and
3162
+ // then focuses the proxy, which synchronously blurs the canvas.
3163
+ if (_this.inputProxy.owns(event.relatedTarget))
3164
+ return;
2749
3165
  _this.focusSessionState = FocusSessionState.NotFocused;
2750
3166
  _this.canvasHasFocus = false;
2751
- var movedWithinFocusDomain = _this.isInFocusDomain(event.relatedTarget);
2752
- var documentLostFocus = event.relatedTarget === null && !document.hasFocus();
2753
- if (movedWithinFocusDomain || documentLostFocus)
3167
+ if (_this.blurStaysWithRive(event.relatedTarget))
2754
3168
  return;
2755
3169
  _this.mainSm.clearFocus();
2756
3170
  };
@@ -2776,15 +3190,44 @@ var KeyboardInteractions = /** @class */ (function () {
2776
3190
  this.onFocusDomainHostFocusIn = function (event) {
2777
3191
  _this.syncOverlayListener();
2778
3192
  _this.onOverlayFocusIn(event);
3193
+ // Focus entering the proxy re-enters the focus domain, so clear any earlier Tab-out
3194
+ // release, or onKeyDown would drop the session's keystrokes.
3195
+ if (_this.inputProxy.owns(event.target)) {
3196
+ _this.focusDomainReleased = false;
3197
+ }
2779
3198
  };
3199
+ /**
3200
+ * Handles keydown events in the Rive focus domain. We route certain keys to different functions, with the following
3201
+ * fallback behavior:
3202
+ * 1. Tab/Shift+Tab - check if keyInput() takes this key, if not, call focusNext/Previous traversal if there are focus nodes
3203
+ * 2. Check - if a semantic overlay element's key handler claimed the event, don't intercept the key event further
3204
+ * 3. Send key to `keyInput()` on Rive state machine if applicable.
3205
+ * 4. If the keyInput returned false, and the key is directional arrow keys, call directional focus methods on state machine
3206
+ * 5. Printables: in a session the proxy's input event supplies text; otherwise textInput().
3207
+ * A printable fires both keyInput and textInput even if a listener claims it.
3208
+ * @param event KeyboardEvent
3209
+ * @returns void
3210
+ */
2780
3211
  this.onKeyDown = function (event) {
2781
3212
  _this.syncOverlayListener();
3213
+ // Keys that are part of an IME composition belong to the IME (candidate
3214
+ // navigation, commit). Safari reports the first one as keyCode 229 with
3215
+ // isComposing still false.
3216
+ if (event.isComposing || event.keyCode === 229)
3217
+ return;
2782
3218
  // After Tab exits the last Rive node, ignore keys until focus re-enters the focus domain.
2783
3219
  if (_this.focusDomainReleased)
2784
3220
  return;
2785
3221
  if (!_this.shouldRiveHandleKeyEvent(event))
2786
3222
  return;
2787
- if (event.code === "Tab" && _this.hasFocusNodes) {
3223
+ if (event.key === "Tab" && _this.hasFocusNodes) {
3224
+ // Tab listeners are matched per phase (down/repeat/up), as in the editor, so
3225
+ // each event is offered on its own; one that isn't claimed traverses.
3226
+ if (_this.mainSm.focusState().hasFocus &&
3227
+ _this.mainSm.keyInput(_keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.tab, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat)) {
3228
+ event.preventDefault();
3229
+ return;
3230
+ }
2788
3231
  var forward = !event.shiftKey;
2789
3232
  var focusMoved = forward ? _this.mainSm.focusNext() : _this.mainSm.focusPrevious();
2790
3233
  var focusState = _this.mainSm.focusState();
@@ -2797,13 +3240,74 @@ var KeyboardInteractions = /** @class */ (function () {
2797
3240
  }
2798
3241
  else {
2799
3242
  // No more traversable nodes — release Tab to the page.
3243
+ if (document.activeElement !== _this.canvas &&
3244
+ _this.isInFocusDomain(document.activeElement)) {
3245
+ // The browser's default Tab starts from the focused element; from an overlay element,
3246
+ // the nearest stop backward is the canvas itself. Start it from the
3247
+ // canvas instead, so a Shift+Tab goes to the proper element before Rive.
3248
+ _this.canvas.focus({ preventScroll: true });
3249
+ }
2800
3250
  _this.focusSessionState = FocusSessionState.NotFocused;
2801
3251
  _this.focusDomainReleased = true;
2802
3252
  _this.canvasHasFocus = false;
2803
3253
  }
2804
3254
  _this.syncOverlayListener();
3255
+ return;
3256
+ }
3257
+ // A semantic overlay widget (roving radio/tab group, slider, Enter/Space activation)
3258
+ // already acted on this key at its target, so don't act on it twice.
3259
+ if ((0,_semantics_claimedKeyEvents__WEBPACK_IMPORTED_MODULE_1__.isKeyEventClaimed)(event)) {
3260
+ _this.claimedKeyCodes.add(event.code);
3261
+ return;
3262
+ }
3263
+ // A new unclaimed press: drop any claim whose keyup never arrived.
3264
+ _this.claimedKeyCodes.delete(event.code);
3265
+ var fromProxy = _this.textInputSessionActive && _this.inputProxy.owns(event.target);
3266
+ var expectsKeyboardInput = _this.mainSm.focusState().expectsKeyboardInput;
3267
+ // The focused node gets first refusal (a TextInput's caret, or a keyboard listener
3268
+ // on that key). Keys with no Rive equivalent map to null and aren't dispatched.
3269
+ var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
3270
+ var consumed = key !== null &&
3271
+ _this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), true, event.repeat);
3272
+ // An arrow key with no consumed key input moves focus spatially. While a Rive node holds focus,
3273
+ // arrows never scroll the page
3274
+ if (!consumed && key !== null && isArrowKey(key) && !hasShortcutModifier(event)) {
3275
+ consumed =
3276
+ _this.focusInDirection(key) || _this.mainSm.focusState().hasFocus;
3277
+ }
3278
+ if (isPrintable(event)) {
3279
+ // During a session the printable must reach the proxy: its input event is the
3280
+ // (IME- and dead-key-correct) text source, and C++ inserts nothing from keyInput.
3281
+ if (fromProxy)
3282
+ return;
3283
+ // Session live but focus elsewhere in Rive: refocus the proxy so the default inserts there.
3284
+ if (_this.textInputSessionActive && _this.isInFocusDomain(event.target)) {
3285
+ _this.inputProxy.focus();
3286
+ return;
3287
+ }
3288
+ if (!_this.textInputSessionActive && expectsKeyboardInput) {
3289
+ _this.mainSm.textInput(event.key);
3290
+ }
3291
+ }
3292
+ // Rive consumed it, or an unmodified editing key while typing (would scroll/submit).
3293
+ var typing = fromProxy || expectsKeyboardInput;
3294
+ if (consumed ||
3295
+ (typing && !hasShortcutModifier(event) && EDITING_NAV_CODES.has(event.code))) {
3296
+ event.preventDefault();
2805
3297
  }
2806
3298
  };
3299
+ this.onKeyUp = function (event) {
3300
+ if (event.isComposing || event.keyCode === 229)
3301
+ return;
3302
+ if (_this.claimedKeyCodes.delete(event.code))
3303
+ return;
3304
+ if (_this.focusSessionState === FocusSessionState.NotFocused)
3305
+ return;
3306
+ var key = (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.keyboardEventToRiveKey)(event);
3307
+ if (key === null)
3308
+ return;
3309
+ _this.mainSm.keyInput(key, (0,_keyMap__WEBPACK_IMPORTED_MODULE_0__.modifiersFromEvent)(event), false, false);
3310
+ };
2807
3311
  this.canvas = canvas;
2808
3312
  this.mainSm = stateMachine;
2809
3313
  this.hasFocusNodes = hasFocusNodes;
@@ -2812,9 +3316,74 @@ var KeyboardInteractions = /** @class */ (function () {
2812
3316
  canvas.addEventListener("focus", this.onCanvasFocus);
2813
3317
  canvas.addEventListener("blur", this.onCanvasBlur);
2814
3318
  canvas.addEventListener("keydown", this.onKeyDown);
3319
+ canvas.addEventListener("keyup", this.onKeyUp);
2815
3320
  this.focusDomainHost.addEventListener("focusin", this.onFocusDomainHostFocusIn);
2816
3321
  this.syncOverlayListener();
3322
+ this.inputProxy = new _textInputProxy__WEBPACK_IMPORTED_MODULE_2__.TextInputProxy({
3323
+ container: (_c = canvas.parentElement) !== null && _c !== void 0 ? _c : document.body,
3324
+ canvas: canvas,
3325
+ textInput: function (text) { return _this.mainSm.textInput(text); },
3326
+ // Proxy keystrokes go through the same handlers as the canvas.
3327
+ onKeyDown: this.onKeyDown,
3328
+ onKeyUp: this.onKeyUp,
3329
+ onCopy: this.onCopy,
3330
+ onBlur: function (relatedTarget) { return _this.handleProxyBlur(relatedTarget); },
3331
+ });
2817
3332
  }
3333
+ KeyboardInteractions.prototype.isTextInputSessionActive = function () {
3334
+ return this.textInputSessionActive;
3335
+ };
3336
+ /** Session active and the proxy holds DOM focus. */
3337
+ KeyboardInteractions.prototype.isEditingHostFocused = function () {
3338
+ return this.textInputSessionActive && this.inputProxy.hasDomFocus();
3339
+ };
3340
+ /** @param focusProxy move DOM focus to the proxy; false leaves it where it is. */
3341
+ KeyboardInteractions.prototype.beginTextInputSession = function (focusProxy) {
3342
+ this.textInputSessionActive = true;
3343
+ this.focusSessionState = FocusSessionState.RiveFocused;
3344
+ if (focusProxy)
3345
+ this.inputProxy.focus();
3346
+ };
3347
+ /** @param fromBlur focus is already leaving; don't park it on the canvas. */
3348
+ KeyboardInteractions.prototype.endTextInputSession = function (fromBlur) {
3349
+ if (fromBlur === void 0) { fromBlur = false; }
3350
+ if (!this.textInputSessionActive)
3351
+ return;
3352
+ this.textInputSessionActive = false;
3353
+ this.inputProxy.endSession();
3354
+ if (fromBlur || !this.inputProxy.hasDomFocus())
3355
+ return;
3356
+ // Nothing took DOM focus from the proxy (e.g. semantics is off). Park it on the
3357
+ // canvas so keys keep reaching Rive; onCanvasFocus ignores focus from the input proxy.
3358
+ this.canvas.focus({ preventScroll: true });
3359
+ };
3360
+ /** Must run synchronously in the pointer gesture or mobile keyboards won't open. */
3361
+ KeyboardInteractions.prototype.summonForPointer = function () {
3362
+ if (this.textInputSessionActive)
3363
+ this.inputProxy.focus();
3364
+ else
3365
+ this.beginTextInputSession(true);
3366
+ };
3367
+ Object.defineProperty(KeyboardInteractions.prototype, "editingHost", {
3368
+ /** The text-input proxy, for the semantics layer to decorate while editing. */
3369
+ get: function () {
3370
+ return this.inputProxy;
3371
+ },
3372
+ enumerable: false,
3373
+ configurable: true
3374
+ });
3375
+ KeyboardInteractions.prototype.handleProxyBlur = function (relatedTarget) {
3376
+ // Teardown already in progress (endTextInputSession blurred the proxy).
3377
+ if (!this.textInputSessionActive)
3378
+ return;
3379
+ // Still in Rive or the document blurred: keep the session (pollFocusState tears down).
3380
+ if (this.blurStaysWithRive(relatedTarget))
3381
+ return;
3382
+ // Blurred out of Rive entirely: release C++ focus and end the session.
3383
+ this.mainSm.clearFocus();
3384
+ this.endTextInputSession(true);
3385
+ this.focusSessionState = FocusSessionState.NotFocused;
3386
+ };
2818
3387
  /**
2819
3388
  * Set the FocusSessionState. Useful for invoking a Rive "blur" without actually blurring from the <canvas>. This
2820
3389
  * helps put the DOM focus state on the canvas rather than the <body>, so the user doesn't lose the spot in page navigation
@@ -2833,6 +3402,26 @@ var KeyboardInteractions = /** @class */ (function () {
2833
3402
  KeyboardInteractions.prototype.notifyRiveFocused = function () {
2834
3403
  this.focusSessionState = FocusSessionState.RiveFocused;
2835
3404
  };
3405
+ /** Blur into the focus domain, or the whole document losing focus (tab/window switch). */
3406
+ KeyboardInteractions.prototype.blurStaysWithRive = function (relatedTarget) {
3407
+ return (this.isInFocusDomain(relatedTarget) ||
3408
+ (relatedTarget === null && !document.hasFocus()));
3409
+ };
3410
+ /** Arrow keys map to directional focus; anything else is not a focus move. */
3411
+ KeyboardInteractions.prototype.focusInDirection = function (key) {
3412
+ switch (key) {
3413
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.left:
3414
+ return this.mainSm.focusLeft();
3415
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.right:
3416
+ return this.mainSm.focusRight();
3417
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.up:
3418
+ return this.mainSm.focusUp();
3419
+ case _keyMap__WEBPACK_IMPORTED_MODULE_0__.Key.down:
3420
+ return this.mainSm.focusDown();
3421
+ default:
3422
+ return false;
3423
+ }
3424
+ };
2836
3425
  /**
2837
3426
  * Determine if Rive should handle keyboard input. If session state is `NotFocused` - no.
2838
3427
  * DOM focus stays parked on the canvas after Rive releases focus internally, and that Tab
@@ -2850,14 +3439,12 @@ var KeyboardInteractions = /** @class */ (function () {
2850
3439
  var eventOnCanvas = event.target === this.canvas;
2851
3440
  return inFocusDomain || this.canvasHasFocus || eventOnCanvas;
2852
3441
  };
2853
- /**
2854
- * The Rive focus domain: the DOM that counts as "inside" Rive for focus purposes — today the
2855
- * canvas itself OR the accessibility overlay subtree. Anything added later belongs here, so
2856
- * session bookkeeping and keydown routing pick it up for free.
2857
- */
3442
+ /** DOM that counts as inside Rive for focus: canvas, overlay subtree, text-input proxy. */
2858
3443
  KeyboardInteractions.prototype.isInFocusDomain = function (target) {
2859
3444
  if (target === this.canvas)
2860
3445
  return true;
3446
+ if (this.inputProxy.owns(target))
3447
+ return true;
2861
3448
  return this.isInOverlay(target);
2862
3449
  };
2863
3450
  /** Overlay only (excludes the canvas) — the accessibility overlay subtree. */
@@ -2868,15 +3455,19 @@ var KeyboardInteractions = /** @class */ (function () {
2868
3455
  return (_c = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) === null || _b === void 0 ? void 0 : _b.contains(target)) !== null && _c !== void 0 ? _c : false;
2869
3456
  };
2870
3457
  KeyboardInteractions.prototype.syncOverlayListener = function () {
2871
- var _a, _b, _c, _d, _e, _f;
3458
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2872
3459
  var nextOverlayElement = (_b = (_a = this.getOverlayElement) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : null;
2873
3460
  if (nextOverlayElement === this.currentOverlayElement)
2874
3461
  return;
2875
3462
  (_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("focusin", this.onOverlayFocusIn);
2876
- (_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown, true);
3463
+ (_d = this.currentOverlayElement) === null || _d === void 0 ? void 0 : _d.removeEventListener("keydown", this.onKeyDown);
3464
+ (_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.removeEventListener("keyup", this.onKeyUp);
2877
3465
  this.currentOverlayElement = nextOverlayElement;
2878
- (_e = this.currentOverlayElement) === null || _e === void 0 ? void 0 : _e.addEventListener("focusin", this.onOverlayFocusIn);
2879
- (_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("keydown", this.onKeyDown, true);
3466
+ (_f = this.currentOverlayElement) === null || _f === void 0 ? void 0 : _f.addEventListener("focusin", this.onOverlayFocusIn);
3467
+ // Bubble phase, so a semantic widget's own key handler runs first and can claim
3468
+ // the key via claimKeyEvent (see onKeyDown).
3469
+ (_g = this.currentOverlayElement) === null || _g === void 0 ? void 0 : _g.addEventListener("keydown", this.onKeyDown);
3470
+ (_h = this.currentOverlayElement) === null || _h === void 0 ? void 0 : _h.addEventListener("keyup", this.onKeyUp);
2880
3471
  };
2881
3472
  /**
2882
3473
  * Whether the canvas currently matches :focus-visible — the browser's heuristic for keyboard-
@@ -2902,13 +3493,22 @@ var KeyboardInteractions = /** @class */ (function () {
2902
3493
  return true;
2903
3494
  };
2904
3495
  KeyboardInteractions.prototype.cleanup = function () {
2905
- var _a, _b;
3496
+ var _a, _b, _c;
2906
3497
  this.canvas.removeEventListener("focus", this.onCanvasFocus);
2907
3498
  this.canvas.removeEventListener("blur", this.onCanvasBlur);
2908
3499
  this.canvas.removeEventListener("keydown", this.onKeyDown);
3500
+ this.canvas.removeEventListener("keyup", this.onKeyUp);
3501
+ this.claimedKeyCodes.clear();
2909
3502
  this.focusDomainHost.removeEventListener("focusin", this.onFocusDomainHostFocusIn);
2910
3503
  (_a = this.currentOverlayElement) === null || _a === void 0 ? void 0 : _a.removeEventListener("focusin", this.onOverlayFocusIn);
2911
- (_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown, true);
3504
+ (_b = this.currentOverlayElement) === null || _b === void 0 ? void 0 : _b.removeEventListener("keydown", this.onKeyDown);
3505
+ (_c = this.currentOverlayElement) === null || _c === void 0 ? void 0 : _c.removeEventListener("keyup", this.onKeyUp);
3506
+ // Removing a focused element drops focus to <body> with no blur; park on the canvas.
3507
+ if (this.inputProxy.hasDomFocus()) {
3508
+ this.canvas.focus({ preventScroll: true });
3509
+ }
3510
+ this.inputProxy.cleanup();
3511
+ this.textInputSessionActive = false;
2912
3512
  };
2913
3513
  return KeyboardInteractions;
2914
3514
  }());
@@ -2916,7 +3516,592 @@ var KeyboardInteractions = /** @class */ (function () {
2916
3516
 
2917
3517
 
2918
3518
  /***/ }),
2919
- /* 13 */
3519
+ /* 15 */
3520
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3521
+
3522
+ __webpack_require__.r(__webpack_exports__);
3523
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3524
+ /* harmony export */ Key: () => (/* binding */ Key),
3525
+ /* harmony export */ KeyModifiers: () => (/* binding */ KeyModifiers),
3526
+ /* harmony export */ keyboardEventToRiveKey: () => (/* binding */ keyboardEventToRiveKey),
3527
+ /* harmony export */ modifiersFromEvent: () => (/* binding */ modifiersFromEvent)
3528
+ /* harmony export */ });
3529
+ /*
3530
+ * Maps DOM keyboard events to the GLFW-style key codes and modifier bitmask
3531
+ * that StateMachineInstance.keyInput() expects. Values mirror `enum class Key`
3532
+ * and `enum class KeyModifiers` in rive-runtime focusable.hpp;
3533
+ * they are stable GLFW codes, so they live here as constants instead of an
3534
+ * embind enum.
3535
+ */
3536
+ var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
3537
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3538
+ if (ar || !(i in from)) {
3539
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
3540
+ ar[i] = from[i];
3541
+ }
3542
+ }
3543
+ return to.concat(ar || Array.prototype.slice.call(from));
3544
+ };
3545
+ var Key = {
3546
+ space: 32,
3547
+ apostrophe: 39, // '
3548
+ comma: 44, // ,
3549
+ minus: 45, // -
3550
+ period: 46, // .
3551
+ slash: 47, // /
3552
+ key0: 48,
3553
+ key1: 49,
3554
+ key2: 50,
3555
+ key3: 51,
3556
+ key4: 52,
3557
+ key5: 53,
3558
+ key6: 54,
3559
+ key7: 55,
3560
+ key8: 56,
3561
+ key9: 57,
3562
+ semicolon: 59, // ;
3563
+ equal: 61, // =
3564
+ a: 65,
3565
+ b: 66,
3566
+ c: 67,
3567
+ d: 68,
3568
+ e: 69,
3569
+ f: 70,
3570
+ g: 71,
3571
+ h: 72,
3572
+ i: 73,
3573
+ j: 74,
3574
+ k: 75,
3575
+ l: 76,
3576
+ m: 77,
3577
+ n: 78,
3578
+ o: 79,
3579
+ p: 80,
3580
+ q: 81,
3581
+ r: 82,
3582
+ s: 83,
3583
+ t: 84,
3584
+ u: 85,
3585
+ v: 86,
3586
+ w: 87,
3587
+ x: 88,
3588
+ y: 89,
3589
+ z: 90,
3590
+ leftBracket: 91, // [
3591
+ backslash: 92, // \
3592
+ rightBracket: 93, // ]
3593
+ graveAccent: 96, // `
3594
+ world1: 161, // non-US #1
3595
+ world2: 162, // non-US #2
3596
+ escape: 256,
3597
+ enter: 257,
3598
+ tab: 258,
3599
+ backspace: 259,
3600
+ insert: 260,
3601
+ deleteKey: 261,
3602
+ right: 262,
3603
+ left: 263,
3604
+ down: 264,
3605
+ up: 265,
3606
+ pageUp: 266,
3607
+ pageDown: 267,
3608
+ home: 268,
3609
+ end: 269,
3610
+ capsLock: 280,
3611
+ scrollLock: 281,
3612
+ numLock: 282,
3613
+ printScreen: 283,
3614
+ pause: 284,
3615
+ f1: 290,
3616
+ f2: 291,
3617
+ f3: 292,
3618
+ f4: 293,
3619
+ f5: 294,
3620
+ f6: 295,
3621
+ f7: 296,
3622
+ f8: 297,
3623
+ f9: 298,
3624
+ f10: 299,
3625
+ f11: 300,
3626
+ f12: 301,
3627
+ f13: 302,
3628
+ f14: 303,
3629
+ f15: 304,
3630
+ f16: 305,
3631
+ f17: 306,
3632
+ f18: 307,
3633
+ f19: 308,
3634
+ f20: 309,
3635
+ f21: 310,
3636
+ f22: 311,
3637
+ f23: 312,
3638
+ f24: 313,
3639
+ f25: 314,
3640
+ kp0: 320,
3641
+ kp1: 321,
3642
+ kp2: 322,
3643
+ kp3: 323,
3644
+ kp4: 324,
3645
+ kp5: 325,
3646
+ kp6: 326,
3647
+ kp7: 327,
3648
+ kp8: 328,
3649
+ kp9: 329,
3650
+ kpDecimal: 330,
3651
+ kpDivide: 331,
3652
+ kpMultiply: 332,
3653
+ kpSubtract: 333,
3654
+ kpAdd: 334,
3655
+ kpEnter: 335,
3656
+ kpEqual: 336,
3657
+ leftShift: 340,
3658
+ leftControl: 341,
3659
+ leftAlt: 342,
3660
+ leftSuper: 343,
3661
+ rightShift: 344,
3662
+ rightControl: 345,
3663
+ rightAlt: 346,
3664
+ rightSuper: 347,
3665
+ menu: 348,
3666
+ };
3667
+ var KeyModifiers = {
3668
+ none: 0,
3669
+ shift: 1 << 0,
3670
+ ctrl: 1 << 1,
3671
+ alt: 1 << 2,
3672
+ meta: 1 << 3,
3673
+ };
3674
+ // Physical key (KeyboardEvent.code) to Rive key, by US-QWERTY position.
3675
+ var CODE_TO_KEY = {
3676
+ // Modifiers are keys too (the editor sends them), and are also in the bitmask.
3677
+ ShiftLeft: Key.leftShift,
3678
+ ShiftRight: Key.rightShift,
3679
+ ControlLeft: Key.leftControl,
3680
+ ControlRight: Key.rightControl,
3681
+ AltLeft: Key.leftAlt,
3682
+ AltRight: Key.rightAlt,
3683
+ MetaLeft: Key.leftSuper,
3684
+ MetaRight: Key.rightSuper,
3685
+ KeyA: Key.a,
3686
+ KeyB: Key.b,
3687
+ KeyC: Key.c,
3688
+ KeyD: Key.d,
3689
+ KeyE: Key.e,
3690
+ KeyF: Key.f,
3691
+ KeyG: Key.g,
3692
+ KeyH: Key.h,
3693
+ KeyI: Key.i,
3694
+ KeyJ: Key.j,
3695
+ KeyK: Key.k,
3696
+ KeyL: Key.l,
3697
+ KeyM: Key.m,
3698
+ KeyN: Key.n,
3699
+ KeyO: Key.o,
3700
+ KeyP: Key.p,
3701
+ KeyQ: Key.q,
3702
+ KeyR: Key.r,
3703
+ KeyS: Key.s,
3704
+ KeyT: Key.t,
3705
+ KeyU: Key.u,
3706
+ KeyV: Key.v,
3707
+ KeyW: Key.w,
3708
+ KeyX: Key.x,
3709
+ KeyY: Key.y,
3710
+ KeyZ: Key.z,
3711
+ Digit0: Key.key0,
3712
+ Digit1: Key.key1,
3713
+ Digit2: Key.key2,
3714
+ Digit3: Key.key3,
3715
+ Digit4: Key.key4,
3716
+ Digit5: Key.key5,
3717
+ Digit6: Key.key6,
3718
+ Digit7: Key.key7,
3719
+ Digit8: Key.key8,
3720
+ Digit9: Key.key9,
3721
+ Numpad0: Key.kp0,
3722
+ Numpad1: Key.kp1,
3723
+ Numpad2: Key.kp2,
3724
+ Numpad3: Key.kp3,
3725
+ Numpad4: Key.kp4,
3726
+ Numpad5: Key.kp5,
3727
+ Numpad6: Key.kp6,
3728
+ Numpad7: Key.kp7,
3729
+ Numpad8: Key.kp8,
3730
+ Numpad9: Key.kp9,
3731
+ NumpadDecimal: Key.kpDecimal,
3732
+ NumpadDivide: Key.kpDivide,
3733
+ NumpadMultiply: Key.kpMultiply,
3734
+ NumpadSubtract: Key.kpSubtract,
3735
+ NumpadAdd: Key.kpAdd,
3736
+ NumpadEnter: Key.kpEnter,
3737
+ NumpadEqual: Key.kpEqual,
3738
+ Minus: Key.minus,
3739
+ Equal: Key.equal,
3740
+ BracketLeft: Key.leftBracket,
3741
+ BracketRight: Key.rightBracket,
3742
+ Backslash: Key.backslash,
3743
+ Semicolon: Key.semicolon,
3744
+ Quote: Key.apostrophe,
3745
+ Backquote: Key.graveAccent,
3746
+ Comma: Key.comma,
3747
+ Period: Key.period,
3748
+ Slash: Key.slash,
3749
+ IntlBackslash: Key.world1,
3750
+ IntlRo: Key.world2,
3751
+ Space: Key.space,
3752
+ Enter: Key.enter,
3753
+ Tab: Key.tab,
3754
+ Backspace: Key.backspace,
3755
+ Insert: Key.insert,
3756
+ Delete: Key.deleteKey,
3757
+ Escape: Key.escape,
3758
+ ArrowRight: Key.right,
3759
+ ArrowLeft: Key.left,
3760
+ ArrowDown: Key.down,
3761
+ ArrowUp: Key.up,
3762
+ PageUp: Key.pageUp,
3763
+ PageDown: Key.pageDown,
3764
+ Home: Key.home,
3765
+ End: Key.end,
3766
+ CapsLock: Key.capsLock,
3767
+ ScrollLock: Key.scrollLock,
3768
+ NumLock: Key.numLock,
3769
+ PrintScreen: Key.printScreen,
3770
+ Pause: Key.pause,
3771
+ ContextMenu: Key.menu,
3772
+ F1: Key.f1,
3773
+ F2: Key.f2,
3774
+ F3: Key.f3,
3775
+ F4: Key.f4,
3776
+ F5: Key.f5,
3777
+ F6: Key.f6,
3778
+ F7: Key.f7,
3779
+ F8: Key.f8,
3780
+ F9: Key.f9,
3781
+ F10: Key.f10,
3782
+ F11: Key.f11,
3783
+ F12: Key.f12,
3784
+ F13: Key.f13,
3785
+ F14: Key.f14,
3786
+ F15: Key.f15,
3787
+ F16: Key.f16,
3788
+ F17: Key.f17,
3789
+ F18: Key.f18,
3790
+ F19: Key.f19,
3791
+ F20: Key.f20,
3792
+ F21: Key.f21,
3793
+ F22: Key.f22,
3794
+ F23: Key.f23,
3795
+ F24: Key.f24,
3796
+ F25: Key.f25,
3797
+ };
3798
+ // Unshifted characters (event.key, lowercased) that name a Rive key.
3799
+ var CHAR_TO_KEY = (function () {
3800
+ var map = {
3801
+ " ": Key.space,
3802
+ "'": Key.apostrophe,
3803
+ ",": Key.comma,
3804
+ "-": Key.minus,
3805
+ ".": Key.period,
3806
+ "/": Key.slash,
3807
+ ";": Key.semicolon,
3808
+ "=": Key.equal,
3809
+ "[": Key.leftBracket,
3810
+ "\\": Key.backslash,
3811
+ "]": Key.rightBracket,
3812
+ "`": Key.graveAccent,
3813
+ };
3814
+ for (var c = 0; c < 26; c++)
3815
+ map[String.fromCharCode(97 + c)] = Key.a + c;
3816
+ for (var d = 0; d <= 9; d++)
3817
+ map[String(d)] = Key.key0 + d;
3818
+ return map;
3819
+ })();
3820
+ // Non-printable event.key values; each shares its name with its code.
3821
+ var NAMED_KEYS = new Set(__spreadArray([
3822
+ "Enter",
3823
+ "Tab",
3824
+ "Backspace",
3825
+ "Insert",
3826
+ "Delete",
3827
+ "Escape",
3828
+ "ArrowRight",
3829
+ "ArrowLeft",
3830
+ "ArrowDown",
3831
+ "ArrowUp",
3832
+ "PageUp",
3833
+ "PageDown",
3834
+ "Home",
3835
+ "End",
3836
+ "CapsLock",
3837
+ "ScrollLock",
3838
+ "NumLock",
3839
+ "PrintScreen",
3840
+ "Pause",
3841
+ "ContextMenu"
3842
+ ], Array.from({ length: 25 }, function (_, i) { return "F".concat(i + 1); }), true));
3843
+ /**
3844
+ * Maps a KeyboardEvent to a Rive key, or null if Rive has no equivalent.
3845
+ *
3846
+ * Resolves the logical key: what the user's layout labels the key, ignoring
3847
+ * Shift, so a listener on "A" fires on AZERTY's A too. `event.key` is preferred;
3848
+ * `event.code` is the fallback when `key` isn't a plain unshifted character
3849
+ * (shifted symbols, Option/AltGr output, non-Latin letters, dead keys).
3850
+ * Digit-row and numpad keys skip the character lookup so AZERTY's digit row
3851
+ * still reports digits and numpad digits stay distinct from the digit row.
3852
+ */
3853
+ function keyboardEventToRiveKey(event) {
3854
+ var _a, _b;
3855
+ var code = event.code, key = event.key;
3856
+ if (NAMED_KEYS.has(key)) {
3857
+ // NumpadEnter reports key "Enter"; keep it distinct.
3858
+ return code === "NumpadEnter" ? Key.kpEnter : (_a = CODE_TO_KEY[key]) !== null && _a !== void 0 ? _a : null;
3859
+ }
3860
+ if (!code.startsWith("Digit") && !code.startsWith("Numpad") && key) {
3861
+ var fromChar = CHAR_TO_KEY[key.toLowerCase()];
3862
+ if (fromChar !== undefined)
3863
+ return fromChar;
3864
+ }
3865
+ return (_b = CODE_TO_KEY[code]) !== null && _b !== void 0 ? _b : null;
3866
+ }
3867
+ function modifiersFromEvent(event) {
3868
+ var modifiers = KeyModifiers.none;
3869
+ if (event.shiftKey)
3870
+ modifiers |= KeyModifiers.shift;
3871
+ if (event.ctrlKey)
3872
+ modifiers |= KeyModifiers.ctrl;
3873
+ if (event.altKey)
3874
+ modifiers |= KeyModifiers.alt;
3875
+ if (event.metaKey)
3876
+ modifiers |= KeyModifiers.meta;
3877
+ return modifiers;
3878
+ }
3879
+
3880
+
3881
+ /***/ }),
3882
+ /* 16 */
3883
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3884
+
3885
+ __webpack_require__.r(__webpack_exports__);
3886
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3887
+ /* harmony export */ TextInputProxy: () => (/* binding */ TextInputProxy)
3888
+ /* harmony export */ });
3889
+ /* harmony import */ var _canvasOffset__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
3890
+
3891
+ // 16px: the smallest font size at which iOS Safari doesn't zoom on focus
3892
+ var FONT_SIZE_PX = 16;
3893
+ /** Capture-critical attributes decorate() must not touch. */
3894
+ var PROTECTED_ATTRS = new Set([
3895
+ "type",
3896
+ "value",
3897
+ "style",
3898
+ "tabindex",
3899
+ "autocapitalize",
3900
+ "autocomplete",
3901
+ "autocorrect",
3902
+ "spellcheck",
3903
+ ]);
3904
+ /**
3905
+ * Invisible per-instance <input> capturing IME/dead-key/paste text; focusable inside a
3906
+ * gesture to raise mobile keyboards. Always empty: C++ owns value and caret. Decorated
3907
+ * for AT only while it holds DOM focus.
3908
+ */
3909
+ var TextInputProxy = /** @class */ (function () {
3910
+ function TextInputProxy(params) {
3911
+ var _this = this;
3912
+ // True between compositionstart/compositionend; we never commit mid-composition.
3913
+ this.composing = false;
3914
+ // Names set by decorate(), removed by resetDecoration().
3915
+ this.decoratedKeys = new Set();
3916
+ // Last written left/top, to skip no-op style writes.
3917
+ this.lastLeft = NaN;
3918
+ this.lastTop = NaN;
3919
+ /** Re-sync before input: the canvas may have scrolled since the session began. */
3920
+ this.reposition = function () { return _this.positionOverCanvas(); };
3921
+ this.onCompositionStart = function () {
3922
+ _this.composing = true;
3923
+ };
3924
+ this.onCompositionEnd = function () {
3925
+ _this.composing = false;
3926
+ // The composed text is now committed in element.value; forward it here. A
3927
+ // trailing `input` event (order varies by browser) then sees an empty field.
3928
+ _this.commit();
3929
+ };
3930
+ this.onInput = function () {
3931
+ if (_this.composing)
3932
+ return;
3933
+ _this.commit();
3934
+ };
3935
+ // An <input type=text> strips line breaks from its value, so forward the clipboard
3936
+ // text directly. Core's single-line fields strip them themselves.
3937
+ this.onPaste = function (event) {
3938
+ var _a;
3939
+ var text = (_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("text/plain");
3940
+ if (!text)
3941
+ return;
3942
+ event.preventDefault();
3943
+ _this.params.textInput(text.replace(/\r\n?/g, "\n"));
3944
+ };
3945
+ this.onBlur = function (event) {
3946
+ _this.params.onBlur(event.relatedTarget);
3947
+ };
3948
+ this.params = params;
3949
+ this.element = this.createElement();
3950
+ this.positionOverCanvas();
3951
+ // Order vs. the overlay is unspecified; fine, Tab release starts from the canvas.
3952
+ this.params.container.appendChild(this.element);
3953
+ }
3954
+ // Registered first so it runs before the key handler inserts or moves the caret.
3955
+ TextInputProxy.prototype.listeners = function () {
3956
+ return [
3957
+ ["keydown", this.reposition],
3958
+ ["beforeinput", this.reposition],
3959
+ ["keydown", this.params.onKeyDown],
3960
+ ["keyup", this.params.onKeyUp],
3961
+ ["input", this.onInput],
3962
+ ["compositionstart", this.onCompositionStart],
3963
+ ["compositionend", this.onCompositionEnd],
3964
+ ["paste", this.onPaste],
3965
+ ["copy", this.params.onCopy],
3966
+ ["blur", this.onBlur],
3967
+ ];
3968
+ };
3969
+ TextInputProxy.prototype.createElement = function () {
3970
+ var el = document.createElement("input");
3971
+ el.type = "text";
3972
+ // Focusable but never in native tab order (Rive drives traversal synthetically),
3973
+ // and invisible without display:none (which would forbid focus).
3974
+ el.tabIndex = -1;
3975
+ el.setAttribute("aria-hidden", "true");
3976
+ // Always empty, so autocapitalize/autocorrect would misfire.
3977
+ el.setAttribute("autocapitalize", "off");
3978
+ el.setAttribute("autocomplete", "off");
3979
+ el.setAttribute("autocorrect", "off");
3980
+ el.spellcheck = false;
3981
+ // Over the canvas (not display:none) so iOS doesn't scroll-jump on keyboard open.
3982
+ // font-size must stay 16px or iOS Safari zooms on focus.
3983
+ el.style.cssText =
3984
+ "position:absolute;width:1px;height:1px;padding:0;margin:0;border:0;" +
3985
+ "outline:none;opacity:0;background:transparent;color:transparent;" +
3986
+ "caret-color:transparent;overflow:hidden;resize:none;z-index:0;" +
3987
+ // Focused programmatically only; must not swallow clicks
3988
+ "pointer-events:none;" +
3989
+ "font-size:".concat(FONT_SIZE_PX, "px;line-height:1;");
3990
+ for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
3991
+ var _b = _a[_i], type = _b[0], listener = _b[1];
3992
+ el.addEventListener(type, listener);
3993
+ }
3994
+ return el;
3995
+ };
3996
+ TextInputProxy.prototype.positionOverCanvas = function () {
3997
+ // Track the canvas (browsers scroll to the caret); clamp on-screen, one caret line box
3998
+ // (FONT_SIZE_PX) from the far edges, or the root scrolls to reveal it.
3999
+ var _a = (0,_canvasOffset__WEBPACK_IMPORTED_MODULE_0__.canvasOffset)(this.params.canvas), top = _a.top, left = _a.left;
4000
+ if (window.innerHeight > 0) {
4001
+ var r = this.params.canvas.getBoundingClientRect();
4002
+ top += clamp(r.top, 0, window.innerHeight - FONT_SIZE_PX) - r.top;
4003
+ left += clamp(r.left, 0, window.innerWidth - FONT_SIZE_PX) - r.left;
4004
+ }
4005
+ if (left !== this.lastLeft) {
4006
+ this.element.style.left = "".concat(left, "px");
4007
+ this.lastLeft = left;
4008
+ }
4009
+ if (top !== this.lastTop) {
4010
+ this.element.style.top = "".concat(top, "px");
4011
+ this.lastTop = top;
4012
+ }
4013
+ };
4014
+ /**
4015
+ * Forward the field's text to Rive and clear it.
4016
+ *
4017
+ * TODO: iOS won't autorepeat Backspace in an empty field (needs a text mirror).
4018
+ * */
4019
+ TextInputProxy.prototype.commit = function () {
4020
+ var text = this.element.value;
4021
+ if (!text)
4022
+ return;
4023
+ this.element.value = "";
4024
+ this.params.textInput(text);
4025
+ };
4026
+ /** Clear any transient value and decoration. Does not blur the element. */
4027
+ TextInputProxy.prototype.endSession = function () {
4028
+ this.element.value = "";
4029
+ // Browsers fire compositionend on blur, but a stuck flag would drop every
4030
+ // keystroke of the next session.
4031
+ this.composing = false;
4032
+ // Also covers blur-out, which bypasses the overlay.
4033
+ this.resetDecoration();
4034
+ };
4035
+ /** Must be called synchronously inside a gesture on iOS to raise the keyboard. */
4036
+ TextInputProxy.prototype.focus = function () {
4037
+ // Reposition first: iOS scrolls the focused input into view when the keyboard opens.
4038
+ this.positionOverCanvas();
4039
+ this.element.focus({ preventScroll: true });
4040
+ };
4041
+ TextInputProxy.prototype.hasDomFocus = function () {
4042
+ return document.activeElement === this.element;
4043
+ };
4044
+ TextInputProxy.prototype.owns = function (target) {
4045
+ return target === this.element;
4046
+ };
4047
+ /** See EditingHost.decorate. */
4048
+ TextInputProxy.prototype.decorate = function (attrs) {
4049
+ // aria-hidden outranks every attribute set below, so it must come off before this
4050
+ // element can stand in as the accessible element for the focused node.
4051
+ this.element.removeAttribute("aria-hidden");
4052
+ for (var _i = 0, _a = Object.entries(attrs); _i < _a.length; _i++) {
4053
+ var _b = _a[_i], name_1 = _b[0], value = _b[1];
4054
+ // Never override capture attrs.
4055
+ if (PROTECTED_ATTRS.has(name_1.toLowerCase()))
4056
+ continue;
4057
+ if (value === null) {
4058
+ this.element.removeAttribute(name_1);
4059
+ this.decoratedKeys.delete(name_1);
4060
+ }
4061
+ else {
4062
+ // Skip no-op writes: setting an attribute to the value it already has still
4063
+ // emits a mutation, and assistive tech is focused on this element mid-edit.
4064
+ if (this.element.getAttribute(name_1) !== value) {
4065
+ this.element.setAttribute(name_1, value);
4066
+ }
4067
+ this.decoratedKeys.add(name_1);
4068
+ }
4069
+ }
4070
+ };
4071
+ /**
4072
+ * type=password for obscured fields so AT doesn't echo keys.
4073
+ * TODO: source "type" from Core, not semantics.
4074
+ */
4075
+ TextInputProxy.prototype.setSecure = function (secure) {
4076
+ var type = secure ? "password" : "text";
4077
+ if (this.element.type !== type)
4078
+ this.element.type = type;
4079
+ };
4080
+ /** Drop all decoration and return to the AT-invisible baseline. */
4081
+ TextInputProxy.prototype.resetDecoration = function () {
4082
+ var _this = this;
4083
+ this.setSecure(false);
4084
+ this.decoratedKeys.forEach(function (name) { return _this.element.removeAttribute(name); });
4085
+ this.decoratedKeys.clear();
4086
+ this.element.setAttribute("aria-hidden", "true");
4087
+ };
4088
+ TextInputProxy.prototype.cleanup = function () {
4089
+ for (var _i = 0, _a = this.listeners(); _i < _a.length; _i++) {
4090
+ var _b = _a[_i], type = _b[0], listener = _b[1];
4091
+ this.element.removeEventListener(type, listener);
4092
+ }
4093
+ this.element.remove();
4094
+ };
4095
+ return TextInputProxy;
4096
+ }());
4097
+
4098
+ function clamp(v, min, max) {
4099
+ return Math.min(Math.max(v, min), Math.max(min, max));
4100
+ }
4101
+
4102
+
4103
+ /***/ }),
4104
+ /* 17 */
2920
4105
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2921
4106
 
2922
4107
  __webpack_require__.r(__webpack_exports__);
@@ -2969,7 +4154,7 @@ function sanitizeUrl(url) {
2969
4154
 
2970
4155
 
2971
4156
  /***/ }),
2972
- /* 14 */
4157
+ /* 18 */
2973
4158
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2974
4159
 
2975
4160
  __webpack_require__.r(__webpack_exports__);
@@ -3269,7 +4454,7 @@ var createFinalization = function (target, finalizable) {
3269
4454
 
3270
4455
 
3271
4456
  /***/ }),
3272
- /* 15 */
4457
+ /* 19 */
3273
4458
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3274
4459
 
3275
4460
  __webpack_require__.r(__webpack_exports__);
@@ -3441,7 +4626,7 @@ __webpack_require__.r(__webpack_exports__);
3441
4626
  /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
3442
4627
  /* harmony import */ var _runtimeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
3443
4628
  /* harmony import */ var _semantics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
3444
- /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(10);
4629
+ /* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
3445
4630
  var __extends = (undefined && undefined.__extends) || (function () {
3446
4631
  var extendStatics = function (d, b) {
3447
4632
  extendStatics = Object.setPrototypeOf ||
@@ -5329,6 +6514,10 @@ var Rive = /** @class */ (function () {
5329
6514
  this._dataEnums = null;
5330
6515
  this._tabIndex = null;
5331
6516
  this._prevHasFocus = false;
6517
+ this._prevWantsTextInputSession = false;
6518
+ // Pointer-down defers the proxy focus: mousedown's default would refocus the canvas and
6519
+ // touchstart isn't user activation; pointer-up focuses it.
6520
+ this._inPointerDownDrain = false;
5332
6521
  this._focusOptions = {
5333
6522
  allowFocusInterrupt: false,
5334
6523
  };
@@ -5364,6 +6553,7 @@ var Rive = /** @class */ (function () {
5364
6553
  _this.resizeToCanvas();
5365
6554
  }
5366
6555
  };
6556
+ this.isEditingHostFocused = function () { var _a, _b; return (_b = (_a = _this._keyboardInteractions) === null || _a === void 0 ? void 0 : _a.isEditingHostFocused()) !== null && _b !== void 0 ? _b : false; };
5367
6557
  // Tracks the current animation frame request
5368
6558
  this.frameRequestId = null;
5369
6559
  /**
@@ -5684,11 +6874,21 @@ var Rive = /** @class */ (function () {
5684
6874
  dispatchPointerExit: dispatchPointerExit,
5685
6875
  enableMultiTouch: enableMultiTouch,
5686
6876
  layoutScaleFactor: this._layout.layoutScaleFactor,
5687
- advanceAndDrain: this.advanceAndReportChanges.bind(this)
6877
+ advanceAndDrain: this.advanceAndDrainForPointer.bind(this),
6878
+ summonKeyboard: this.summonKeyboardForGesture.bind(this),
6879
+ isTextProxyFocused: this.isEditingHostFocused,
5688
6880
  });
5689
6881
  this.ensureKeyboardInteractions();
5690
6882
  }
5691
6883
  };
6884
+ Object.defineProperty(Rive.prototype, "focusStateMachine", {
6885
+ // Assumes a single state machine drives focus.
6886
+ get: function () {
6887
+ return this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
6888
+ },
6889
+ enumerable: false,
6890
+ configurable: true
6891
+ });
5692
6892
  /**
5693
6893
  * Wire keyboard interactions when a playing state machine has focus nodes.
5694
6894
  * Called at listener setup and lazily each frame so late-bound bindable artboards work.
@@ -5701,7 +6901,7 @@ var Rive = /** @class */ (function () {
5701
6901
  !(this.canvas instanceof HTMLCanvasElement)) {
5702
6902
  return;
5703
6903
  }
5704
- var smWithFocusNodes = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; });
6904
+ var smWithFocusNodes = this.focusStateMachine;
5705
6905
  if (!smWithFocusNodes) {
5706
6906
  return;
5707
6907
  }
@@ -5711,16 +6911,51 @@ var Rive = /** @class */ (function () {
5711
6911
  }
5712
6912
  this._keyboardInteractions = new _utils__WEBPACK_IMPORTED_MODULE_3__.KeyboardInteractions({
5713
6913
  canvas: this.canvas,
5714
- stateMachine: smWithFocusNodes.instance, // work off assumption of single state machine
6914
+ stateMachine: smWithFocusNodes.instance,
5715
6915
  hasFocusNodes: true,
5716
6916
  getOverlayElement: function () { var _a, _b; return (_b = (_a = _this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer()) !== null && _b !== void 0 ? _b : null; },
5717
6917
  });
5718
6918
  };
6919
+ /** Runs inside touchend/mouseup so focusing the proxy raises the mobile keyboard. */
6920
+ Rive.prototype.summonKeyboardForGesture = function () {
6921
+ if (!this._keyboardInteractions)
6922
+ return;
6923
+ var activeSm = this.focusStateMachine;
6924
+ if (!activeSm)
6925
+ return;
6926
+ if (this.wantsTextInputSession(activeSm.focusState().expectsKeyboardInput)) {
6927
+ this._keyboardInteractions.summonForPointer();
6928
+ }
6929
+ };
6930
+ /** expectsKeyboardInput, and (with semantics on) the focused node is a textField. */
6931
+ Rive.prototype.wantsTextInputSession = function (expectsKeyboardInput) {
6932
+ var _a;
6933
+ if (!expectsKeyboardInput)
6934
+ return false;
6935
+ var node = (_a = this._semanticTree) === null || _a === void 0 ? void 0 : _a.focusedNode();
6936
+ return node === undefined || node.role === _semantics__WEBPACK_IMPORTED_MODULE_2__.SemanticRole.textField;
6937
+ };
6938
+ Rive.prototype.advanceAndDrainForPointer = function (elapsedTime, options) {
6939
+ if (!(options === null || options === void 0 ? void 0 : options.pointerDown)) {
6940
+ this.advanceAndReportChanges(elapsedTime);
6941
+ return;
6942
+ }
6943
+ this._inPointerDownDrain = true;
6944
+ try {
6945
+ this.advanceAndReportChanges(elapsedTime);
6946
+ }
6947
+ finally {
6948
+ this._inPointerDownDrain = false;
6949
+ }
6950
+ };
5719
6951
  Rive.prototype.cleanupKeyboardInteractions = function () {
6952
+ var _a;
5720
6953
  if (this._keyboardInteractions) {
5721
6954
  this._keyboardInteractions.cleanup();
5722
6955
  this._keyboardInteractions = null;
5723
6956
  }
6957
+ this._prevWantsTextInputSession = false;
6958
+ (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.releaseEditingHost(null, null);
5724
6959
  };
5725
6960
  /**
5726
6961
  * Remove Rive Listeners setup on the canvas
@@ -5812,6 +7047,7 @@ var Rive = /** @class */ (function () {
5812
7047
  _c.label = 4;
5813
7048
  case 4:
5814
7049
  this.file = this.riveFile.getInstance();
7050
+ this.reportDisplayScale();
5815
7051
  // Initialize and draw frame
5816
7052
  this.initArtboard(artboardName, animationNames, stateMachineNames, autoplay, autoBind);
5817
7053
  // Initialize the artboard size
@@ -6056,56 +7292,69 @@ var Rive = /** @class */ (function () {
6056
7292
  var _a, _b, _c;
6057
7293
  return (_c = (_b = (_a = this.riveFile) === null || _a === void 0 ? void 0 : _a.deferredSession) === null || _b === void 0 ? void 0 : _b.recordedThisFrame()) !== null && _c !== void 0 ? _c : false;
6058
7294
  };
6059
- /**
6060
- * Poll focus state each frame to see if we should focus/blur the canvas in case
6061
- * Rive internally updated focus outside of user interaction (e.g., via listener action)
6062
- */
7295
+ /** Rive can move focus on its own, so reconcile the text session and DOM focus each frame. */
6063
7296
  Rive.prototype.pollFocusState = function () {
6064
- var _a, _b;
6065
7297
  this.ensureKeyboardInteractions();
6066
- if (!this._keyboardInteractions) {
7298
+ var ki = this._keyboardInteractions;
7299
+ var activeSm = ki ? this.focusStateMachine : undefined;
7300
+ if (!ki || !activeSm || !(this.canvas instanceof HTMLCanvasElement)) {
6067
7301
  this._prevHasFocus = false;
7302
+ this._prevWantsTextInputSession = false;
6068
7303
  return;
6069
7304
  }
6070
- var activeSm = this.animator.stateMachines.find(function (sm) { return sm.playing && sm.hasFocusNodes; }); // work off assumption of single state machine
6071
- if (!activeSm) {
6072
- this._prevHasFocus = false;
6073
- return;
7305
+ var _a = activeSm.focusState(), hasFocus = _a.hasFocus, expectsKeyboardInput = _a.expectsKeyboardInput;
7306
+ this.syncTextInputSession(ki, this.wantsTextInputSession(expectsKeyboardInput));
7307
+ this.syncRiveFocus(ki, this.canvas, hasFocus);
7308
+ };
7309
+ /** Begin/end the text session on wantsSession edges; decorate the proxy while it has DOM focus. */
7310
+ Rive.prototype.syncTextInputSession = function (ki, wantsSession) {
7311
+ var host = ki.editingHost;
7312
+ var overlay = this._accessibilityOverlay;
7313
+ if (wantsSession) {
7314
+ var began = !this._prevWantsTextInputSession;
7315
+ if (began) {
7316
+ // In-domain or opted-in only; during pointer-down, pointer-up focuses instead.
7317
+ var focusProxy = !this._inPointerDownDrain &&
7318
+ (ki.isInFocusDomain(document.activeElement) ||
7319
+ !!this._focusOptions.allowFocusInterrupt);
7320
+ ki.beginTextInputSession(focusProxy);
7321
+ }
7322
+ // The <input> proxy stands in for the semantic DOM field only while it holds DOM focus.
7323
+ if (overlay && this._semanticTree) {
7324
+ if (host.hasDomFocus()) {
7325
+ overlay.syncEditingHost(this._semanticTree, host, began || !overlay.hasEditingHost());
7326
+ }
7327
+ else if (overlay.hasEditingHost()) {
7328
+ overlay.releaseEditingHost(this._semanticTree, host);
7329
+ }
7330
+ }
6074
7331
  }
6075
- if (this.canvas instanceof HTMLCanvasElement) {
6076
- var hasFocus = activeSm.focusState().hasFocus;
6077
- if (hasFocus) {
6078
- // Rive has an active focus node. Mark the session RiveFocused so Tab stays
6079
- // trapped and a later internal release (hasFocus true → false) is detected.
6080
- this._keyboardInteractions.notifyRiveFocused();
6081
- // Only steal DOM focus on the false→true transition. Rive can hold focus across
6082
- // frames while DOM focus sits elsewhere — a window switch preserves runtime focus
6083
- // by design — and that must not re-focus the canvas again.
6084
- if (!this._prevHasFocus) {
6085
- // Steal DOM focus to the canvas only when focus isn't already held
6086
- // somewhere inside this instance's focus scope. When the accessibility
6087
- // overlay has driven focus onto a specific semantic node element (e.g.
6088
- // an appearing alert dialog), focus is already in-scope. The steal
6089
- // stays a fallback for runtime focus nodes that have no overlay element
6090
- // to hold DOM focus.
6091
- var scope = (_a = this._accessibilityOverlay) === null || _a === void 0 ? void 0 : _a.getSemanticOverlayContainer();
6092
- var focusAlreadyInScope = document.activeElement === this.canvas ||
6093
- ((_b = scope === null || scope === void 0 ? void 0 : scope.contains(document.activeElement)) !== null && _b !== void 0 ? _b : false);
6094
- if (!focusAlreadyInScope && this._focusOptions.allowFocusInterrupt) {
6095
- this.canvas.focus();
6096
- }
6097
- this._prevHasFocus = true;
7332
+ else if (this._prevWantsTextInputSession) {
7333
+ // Overlay hand-off first, ahead of endTextInputSession's park-on-canvas fallback.
7334
+ overlay === null || overlay === void 0 ? void 0 : overlay.releaseEditingHost(this._semanticTree, host);
7335
+ ki.endTextInputSession();
7336
+ }
7337
+ this._prevWantsTextInputSession = wantsSession;
7338
+ };
7339
+ /** Mirror Rive's hasFocus into the keyboard session state and, on opt-in, canvas focus. */
7340
+ Rive.prototype.syncRiveFocus = function (ki, canvas, hasFocus) {
7341
+ if (hasFocus) {
7342
+ ki.notifyRiveFocused();
7343
+ // Pull focus from outside Rive only with allowFocusInterrupt.
7344
+ if (!this._prevHasFocus) {
7345
+ if (!ki.isInFocusDomain(document.activeElement) &&
7346
+ this._focusOptions.allowFocusInterrupt) {
7347
+ canvas.focus();
6098
7348
  }
6099
- return;
7349
+ this._prevHasFocus = true;
6100
7350
  }
7351
+ }
7352
+ else {
6101
7353
  this._prevHasFocus = false;
6102
- // hasFocus is false — only act when Rive previously held focus and released it internally
6103
- // (state change clears focus). Release the DOM Tab trap so the next Tab moves to the next
6104
- // page element. A DOM blur reaches here too now that onCanvasBlur clears Rive focus, but it
6105
- // has already set NotFocused, so this is a no-op. EntryPending and NotFocused are likewise
6106
- // intentional no-ops — EntryPending must stay put (a click awaiting its first Tab).
6107
- if (this._keyboardInteractions.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
6108
- this._keyboardInteractions.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
7354
+ // Rive released focus internally (e.g. a state change): drop the Tab trap so the next
7355
+ // Tab leaves the canvas.
7356
+ if (ki.focusSessionState === _utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.RiveFocused) {
7357
+ ki.setFocusSessionState(_utils__WEBPACK_IMPORTED_MODULE_3__.FocusSessionState.NotFocused);
6109
7358
  }
6110
7359
  }
6111
7360
  };
@@ -6203,6 +7452,7 @@ var Rive = /** @class */ (function () {
6203
7452
  instanceId: this._instanceId,
6204
7453
  semanticsOptions: this.semanticsOptions,
6205
7454
  allowFocusInterrupt: this._focusOptions.allowFocusInterrupt,
7455
+ isEditingHostFocused: this.isEditingHostFocused,
6206
7456
  fireAction: function (nodeId, actionType) {
6207
7457
  mainSm_1.fireSemanticAction(nodeId, actionType);
6208
7458
  },
@@ -6740,6 +7990,7 @@ var Rive = /** @class */ (function () {
6740
7990
  // Sets a new layout
6741
7991
  set: function (layout) {
6742
7992
  this._layout = layout;
7993
+ this.reportDisplayScale();
6743
7994
  // Fit/alignment/bounds feed the overlay transform.
6744
7995
  this._overlayTransformDirty = true;
6745
7996
  // If the maxX or maxY are 0, then set them to the canvas width and height
@@ -7447,10 +8698,17 @@ var Rive = /** @class */ (function () {
7447
8698
  this._overlayTransformDirty = true;
7448
8699
  }
7449
8700
  this._devicePixelRatioUsed = value;
8701
+ this.reportDisplayScale();
7450
8702
  },
7451
8703
  enumerable: false,
7452
8704
  configurable: true
7453
8705
  });
8706
+ // Not per frame: the scale is per file, and instances sharing one would trade
8707
+ // it every frame.
8708
+ Rive.prototype.reportDisplayScale = function () {
8709
+ var _a;
8710
+ (_a = this.file) === null || _a === void 0 ? void 0 : _a.displayScale(this._devicePixelRatioUsed * this._layout.layoutScaleFactor);
8711
+ };
7454
8712
  /**
7455
8713
  * Sets the main view model instance and applies it (rebinds). Equivalent to
7456
8714
  * `setViewModelInstance(vmi)` followed by `bind()`.