import{A as yt,Ba as It,Ca as An,Da as Cn,Dc as En,H as vn,Hc as Rn,I as Tt,La as Mt,P as Re,V as mn,W as gn,Y as Pt,_ as kt,a as ie,ba as yn,ca as bn,ea as oe,ga as Lt,j as ae,la as wn,ma as Te,n as fn,pb as xn,r as Wt,u as ln,v as dn,z as pn}from"./chunk-QBQIXSUA.js";var rr=(()=>{var p=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(V={}){var i=V,d,m;i.ready=new Promise((e,t)=>{d=e,m=t});function w(){function e(u){let s=r;n=t=0,r=new Map,s.forEach(h=>{try{h(u)}catch(c){console.error(c)}}),this.Sa(),a&&a.pb()}let t=0,n=0,r=new Map,a=null,o=null;this.requestAnimationFrame=function(u){t||(t=requestAnimationFrame(e.bind(this)));let s=++n;return r.set(s,u),s},this.cancelAnimationFrame=function(u){r.delete(u),t&&r.size==0&&(cancelAnimationFrame(t),t=0)},this.nb=function(u){o&&(document.body.remove(o),o=null),u||(o=document.createElement("div"),o.style.backgroundColor="black",o.style.position="fixed",o.style.right=0,o.style.top=0,o.style.color="white",o.style.padding="4px",o.innerHTML="RIVE FPS",u=function(s){o.innerHTML="RIVE FPS "+s.toFixed(1)},document.body.appendChild(o)),a=new function(){let s=0,h=0;this.pb=function(){var c=performance.now();h?(++s,c-=h,1e3<c&&(u(1e3*s/c),s=h=0)):(h=c,s=0)}}},this.kb=function(){o&&(document.body.remove(o),o=null),a=null},this.Sa=function(){}}function x(e){console.assert(!0);let t=new Map,n=-1/0;this.push=function(r){return r=r+((1<<e)-1)>>e,t.has(r)&&clearTimeout(t.get(r)),t.set(r,setTimeout(function(){t.delete(r),t.length==0?n=-1/0:r==n&&(n=Math.max(...t.keys()),console.assert(n<r))},1e3)),n=Math.max(r,n),n<<e}}let O="createConicGradient createImageData createLinearGradient createPattern createRadialGradient getContextAttributes getImageData getLineDash getTransform isContextLost isPointInPath isPointInStroke measureText".split(" "),W=new function(){function e(){if(!t){let Y=function(P,R,D){if(R=y.createShader(R),y.shaderSource(R,D),y.compileShader(R),D=y.getShaderInfoLog(R),0<D.length)throw D;y.attachShader(P,R)};var C=Y,g=document.createElement("canvas"),A={alpha:1,depth:0,stencil:0,antialias:0,premultipliedAlpha:1,preserveDrawingBuffer:0,preferLowPowerToHighPerformance:0,failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:1,explicitSwapControl:1,renderViaOffscreenBackBuffer:1};let y=g.getContext("webgl2",A);if(y)n=2;else if(y=g.getContext("webgl",A))n=1;else return console.log("No WebGL support. Image mesh will not be drawn."),!1;if(r=Math.min(y.getParameter(y.MAX_RENDERBUFFER_SIZE),y.getParameter(y.MAX_TEXTURE_SIZE)),g=y.createProgram(),Y(g,y.VERTEX_SHADER,`attribute vec2 vertex;
                attribute vec2 uv;
                uniform vec4 mat;
                uniform vec2 translate;
                varying vec2 st;
                void main() {
                    st = uv;
                    gl_Position = vec4(mat2(mat) * vertex + translate, 0, 1);
                }`),Y(g,y.FRAGMENT_SHADER,`precision highp float;
                uniform sampler2D image;
                varying vec2 st;
                void main() {
                    gl_FragColor = texture2D(image, st);
                }`),y.bindAttribLocation(g,0,"vertex"),y.bindAttribLocation(g,1,"uv"),y.linkProgram(g),A=y.getProgramInfoLog(g),0<A.trim().length)throw A;a=y.getUniformLocation(g,"mat"),o=y.getUniformLocation(g,"translate"),y.useProgram(g),y.bindBuffer(y.ARRAY_BUFFER,y.createBuffer()),y.enableVertexAttribArray(0),y.enableVertexAttribArray(1),y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,y.createBuffer()),y.uniform1i(y.getUniformLocation(g,"image"),0),y.pixelStorei(y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),t=y}return!0}let t=null,n=0,r=0,a=null,o=null,u=0,s=0;this.yb=function(){return e(),r},this.ib=function(g){if(!e())return null;let A=t.createTexture();return t.bindTexture(t.TEXTURE_2D,A),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,g),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),n==2?(t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.generateMipmap(t.TEXTURE_2D)):t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),A};let h=new x(8),c=new x(8),l=new x(10),v=new x(10);this.mb=function(g,A,C,y,Y){if(e()){var P=h.push(g),R=c.push(A);(t.canvas.width!=P||t.canvas.height!=R)&&(t.canvas.width=P,t.canvas.height=R),t.viewport(0,R-A,g,A),t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.enable(t.SCISSOR_TEST),C.sort((M,lt)=>lt.Wa-M.Wa),P=l.push(y),u!=P&&(t.bufferData(t.ARRAY_BUFFER,8*P,t.DYNAMIC_DRAW),u=P),P=0;for(var D of C)t.bufferSubData(t.ARRAY_BUFFER,P,D.Fa),P+=4*D.Fa.length;console.assert(P==4*y);for(var G of C)t.bufferSubData(t.ARRAY_BUFFER,P,G.Za),P+=4*G.Za.length;console.assert(P==8*y),P=v.push(Y),s!=P&&(t.bufferData(t.ELEMENT_ARRAY_BUFFER,2*P,t.DYNAMIC_DRAW),s=P),D=0;for(var ct of C)t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,D,ct.indices),D+=2*ct.indices.length;console.assert(D==2*Y),ct=0,G=!0,P=D=0;for(let M of C){M.image.Ba!=ct&&(t.bindTexture(t.TEXTURE_2D,M.image.fb||null),ct=M.image.Ba),M.Bb?(t.scissor(M.Ka,R-M.La-M.Ra,M.Ib,M.Ra),G=!0):G&&(t.scissor(0,R-A,g,A),G=!1),C=2/g;let lt=-2/A;t.uniform4f(a,M.qa[0]*C*M.xa,M.qa[1]*lt*M.ya,M.qa[2]*C*M.xa,M.qa[3]*lt*M.ya),t.uniform2f(o,M.qa[4]*C*M.xa+C*(M.Ka-M.zb*M.xa)-1,M.qa[5]*lt*M.ya+lt*(M.La-M.Ab*M.ya)+1),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,P),t.vertexAttribPointer(1,2,t.FLOAT,!1,0,P+4*y),t.drawElements(t.TRIANGLES,M.indices.length,t.UNSIGNED_SHORT,D),P+=4*M.Fa.length,D+=2*M.indices.length}console.assert(P==4*y),console.assert(D==2*Y)}},this.canvas=function(){return e()&&t.canvas}};i.onRuntimeInitialized=function(){function e(f){switch(f){case c.srcOver:return"source-over";case c.screen:return"screen";case c.overlay:return"overlay";case c.darken:return"darken";case c.lighten:return"lighten";case c.colorDodge:return"color-dodge";case c.colorBurn:return"color-burn";case c.hardLight:return"hard-light";case c.softLight:return"soft-light";case c.difference:return"difference";case c.exclusion:return"exclusion";case c.multiply:return"multiply";case c.hue:return"hue";case c.saturation:return"saturation";case c.color:return"color";case c.luminosity:return"luminosity"}}function t(f){return"rgba("+((16711680&f)>>>16)+","+((65280&f)>>>8)+","+((255&f)>>>0)+","+((4278190080&f)>>>24)/255+")"}function n(){0<D.length&&(W.mb(R.drawWidth(),R.drawHeight(),D,G,ct),D=[],ct=G=0,R.reset(512,512));for(let f of P){for(let b of f.fa)b();f.fa=[]}P.clear()}var r=i.RenderPaintStyle;let a=i.RenderPath,o=i.RenderPaint,u=i.Renderer,s=i.StrokeCap,h=i.StrokeJoin,c=i.BlendMode,l=r.fill,v=r.stroke,g=i.FillRule.evenOdd,A=1;var C=i.RenderImage.extend("CanvasRenderImage",{__construct:function(){this.__parent.__construct.call(this),this.Ba=A,A=A+1&2147483647||1},decode:function(f){let b=Ee;b.total++;var _=this,I=new Image;I.src=URL.createObjectURL(new Blob([f],{type:"image/png"})),I.onload=function(){if(_.cb=I,_.fb=W.ib(I),_.size(I.width,I.height),b.loaded++,b.loaded===b.total){let T=b.ready;T&&(T(),b.ready=null)}}}}),y=a.extend("CanvasRenderPath",{__construct:function(){this.__parent.__construct.call(this),this.ka=new Path2D},rewind:function(){this.ka=new Path2D},addPath:function(f,b,_,I,T,S,$){var F=this.ka,J=F.addPath;f=f.ka;let U=new DOMMatrix;U.a=b,U.b=_,U.c=I,U.d=T,U.e=S,U.f=$,J.call(F,f,U)},fillRule:function(f){this.Ia=f},moveTo:function(f,b){this.ka.moveTo(f,b)},lineTo:function(f,b){this.ka.lineTo(f,b)},cubicTo:function(f,b,_,I,T,S){this.ka.bezierCurveTo(f,b,_,I,T,S)},close:function(){this.ka.closePath()}}),Y=o.extend("CanvasRenderPaint",{color:function(f){this.Ja=t(f)},thickness:function(f){this.gb=f},join:function(f){switch(f){case h.miter:this.Aa="miter";break;case h.round:this.Aa="round";break;case h.bevel:this.Aa="bevel"}},cap:function(f){switch(f){case s.butt:this.za="butt";break;case s.round:this.za="round";break;case s.square:this.za="square"}},style:function(f){this.eb=f},blendMode:function(f){this.bb=e(f)},clearGradient:function(){this.sa=null},linearGradient:function(f,b,_,I){this.sa={Xa:f,Ya:b,Na:_,Oa:I,Ea:[]}},radialGradient:function(f,b,_,I){this.sa={Xa:f,Ya:b,Na:_,Oa:I,Ea:[],wb:!0}},addStop:function(f,b){this.sa.Ea.push({color:f,stop:b})},completeGradient:function(){},draw:function(f,b,_){let I=this.eb;var T=this.Ja,S=this.sa;if(f.globalCompositeOperation=this.bb,S!=null){T=S.Xa;var $=S.Ya;let J=S.Na;var F=S.Oa;let U=S.Ea;S.wb?(S=J-T,F-=$,T=f.createRadialGradient(T,$,0,T,$,Math.sqrt(S*S+F*F))):T=f.createLinearGradient(T,$,J,F);for(let nt=0,L=U.length;nt<L;nt++)$=U[nt],T.addColorStop($.stop,t($.color));this.Ja=T,this.sa=null}switch(I){case v:f.strokeStyle=T,f.lineWidth=this.gb,f.lineCap=this.za,f.lineJoin=this.Aa,f.stroke(b);break;case l:f.fillStyle=T,f.fill(b,_)}}});let P=new Set,R=null,D=[],G=0,ct=0;var M=i.CanvasRenderer=u.extend("Renderer",{__construct:function(f){this.__parent.__construct.call(this),this.ja=[1,0,0,1,0,0],this.da=f.getContext("2d"),this.Ha=f,this.fa=[]},save:function(){this.ja.push(...this.ja.slice(this.ja.length-6)),this.fa.push(this.da.save.bind(this.da))},restore:function(){let f=this.ja.length-6;if(6>f)throw"restore() called without matching save().";this.ja.splice(f),this.fa.push(this.da.restore.bind(this.da))},transform:function(f,b,_,I,T,S){let $=this.ja,F=$.length-6;$.splice(F,6,$[F]*f+$[F+2]*b,$[F+1]*f+$[F+3]*b,$[F]*_+$[F+2]*I,$[F+1]*_+$[F+3]*I,$[F]*T+$[F+2]*S+$[F+4],$[F+1]*T+$[F+3]*S+$[F+5]),this.fa.push(this.da.transform.bind(this.da,f,b,_,I,T,S))},rotate:function(f){let b=Math.sin(f);f=Math.cos(f),this.transform(f,b,-b,f,0,0)},_drawPath:function(f,b){this.fa.push(b.draw.bind(b,this.da,f.ka,f.Ia===g?"evenodd":"nonzero"))},_drawRiveImage:function(f,b,_){var I=f.cb;if(I){var T=this.da,S=e(b);this.fa.push(function(){T.globalCompositeOperation=S,T.globalAlpha=_,T.drawImage(I,0,0),T.globalAlpha=1})}},_getMatrix:function(f){let b=this.ja,_=b.length-6;for(let I=0;6>I;++I)f[I]=b[_+I]},_drawImageMesh:function(f,b,_,I,T,S,$,F,J,U){var nt=this.da.canvas.width,L=this.da.canvas.height;let sn=J-$,un=U-F;$=Math.max($,0),F=Math.max(F,0),J=Math.min(J,nt),U=Math.min(U,L);let Bt=J-$,Ut=U-F;if(console.assert(Bt<=Math.min(sn,nt)),console.assert(Ut<=Math.min(un,L)),!(0>=Bt||0>=Ut)){J=Bt<sn||Ut<un,nt=U=1;var mt=Math.ceil(Bt*U),gt=Math.ceil(Ut*nt);L=W.yb(),mt>L&&(U*=L/mt,mt=L),gt>L&&(nt*=L/gt,gt=L),R||(R=new i.DynamicRectanizer(L),R.reset(512,512)),L=R.addRect(mt,gt),0>L&&(n(),P.add(this),L=R.addRect(mt,gt),console.assert(0<=L));var cn=L&65535,hn=L>>16;D.push({qa:this.ja.slice(this.ja.length-6),image:f,Ka:cn,La:hn,zb:$,Ab:F,Ib:mt,Ra:gt,xa:U,ya:nt,Fa:new Float32Array(I),Za:new Float32Array(T),indices:new Uint16Array(S),Bb:J,Wa:f.Ba<<1|(J?1:0)}),G+=I.length,ct+=S.length;var Rt=this.da,nr=e(b);this.fa.push(function(){Rt.save(),Rt.resetTransform(),Rt.globalCompositeOperation=nr,Rt.globalAlpha=_,Rt.drawImage(W.canvas(),cn,hn,mt,gt,$,F,Bt,Ut),Rt.restore()})}},_clipPath:function(f){this.fa.push(this.da.clip.bind(this.da,f.ka,f.Ia===g?"evenodd":"nonzero"))},clear:function(){P.add(this),this.fa.push(this.da.clearRect.bind(this.da,0,0,this.Ha.width,this.Ha.height))},flush:function(){},translate:function(f,b){this.transform(1,0,0,1,f,b)}});i.makeRenderer=function(f){let b=new M(f),_=b.da;return new Proxy(b,{get(I,T){if(typeof I[T]=="function")return function(...S){return I[T].apply(I,S)};if(typeof _[T]=="function"){if(-1<O.indexOf(T))throw Error("RiveException: Method call to '"+T+"()' is not allowed, as the renderer cannot immediately pass through the return                 values of any canvas 2d context methods.");return function(...S){b.fa.push(_[T].bind(_,...S))}}return I[T]},set(I,T,S){if(T in _)return _[T]=S,!0}})},i.renderFactory={makeRenderPaint:function(){return new Y},makeRenderPath:function(){return new y},makeRenderImage:function(){return new C}};let lt=i.load,Ee=null;i.load=function(f){return new Promise(function(b){let _=null;Ee={total:0,loaded:0,ready:function(){b(_)}},_=lt(f),Ee.total==0&&b(_)})},r=new w,i.requestAnimationFrame=r.requestAnimationFrame.bind(r),i.cancelAnimationFrame=r.cancelAnimationFrame.bind(r),i.enableFPSCounter=r.nb.bind(r),i.disableFPSCounter=r.kb,r.Sa=n,i.cleanup=function(){R&&R.delete()}};var N=Object.assign({},i),k="./this.program",rt=typeof window=="object",K=typeof importScripts=="function",H="",se,ue;(rt||K)&&(K?H=self.location.href:typeof document<"u"&&document.currentScript&&(H=document.currentScript.src),p&&(H=p),H.indexOf("blob:")!==0?H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1):H="",K&&(ue=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),se=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var $n=i.print||console.log.bind(console),bt=i.printErr||console.error.bind(console);Object.assign(i,N),N=null,i.thisProgram&&(k=i.thisProgram);var _t;i.wasmBinary&&(_t=i.wasmBinary);var vr=i.noExitRuntime||!0;typeof WebAssembly!="object"&&fe("no native wasm support detected");var Nt,it,Ie=!1,wt,z,dt,$t,ht,B,Me,_e;function $e(){var e=Nt.buffer;i.HEAP8=wt=new Int8Array(e),i.HEAP16=dt=new Int16Array(e),i.HEAP32=ht=new Int32Array(e),i.HEAPU8=z=new Uint8Array(e),i.HEAPU16=$t=new Uint16Array(e),i.HEAPU32=B=new Uint32Array(e),i.HEAPF32=Me=new Float32Array(e),i.HEAPF64=_e=new Float64Array(e)}var ce,Fe=[],Se=[],De=[];function Fn(){var e=i.preRun.shift();Fe.unshift(e)}var pt=0,he=null,Ft=null;function fe(e){throw i.onAbort&&i.onAbort(e),e="Aborted("+e+")",bt(e),Ie=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),m(e),e}function Oe(e){return e.startsWith("data:application/octet-stream;base64,")}var At;if(At="canvas_advanced.wasm",!Oe(At)){var Ye=At;At=i.locateFile?i.locateFile(Ye,H):H+Ye}function je(e){if(e==At&&_t)return new Uint8Array(_t);if(ue)return ue(e);throw"both async and sync fetching of the wasm failed"}function Sn(e){if(!_t&&(rt||K)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(t=>{if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()}).catch(()=>je(e));if(se)return new Promise((t,n)=>{se(e,r=>t(new Uint8Array(r)),n)})}return Promise.resolve().then(()=>je(e))}function Be(e,t,n){return Sn(e).then(r=>WebAssembly.instantiate(r,t)).then(r=>r).then(n,r=>{bt("failed to asynchronously prepare wasm: "+r),fe(r)})}function Dn(e,t){var n=At;return _t||typeof WebAssembly.instantiateStreaming!="function"||Oe(n)||n.startsWith("file://")||typeof fetch!="function"?Be(n,e,t):fetch(n,{credentials:"same-origin"}).then(r=>WebAssembly.instantiateStreaming(r,e).then(t,function(a){return bt("wasm streaming compile failed: "+a),bt("falling back to ArrayBuffer instantiation"),Be(n,e,t)}))}var le=e=>{for(;0<e.length;)e.shift()(i)};function Ue(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var t=e.charCodeAt(0);return 48<=t&&57>=t?`_${e}`:e}function Zt(e,t){return e=Ue(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function We(){this.la=[void 0],this.Qa=[]}var Q=new We,Ct=void 0;function E(e){throw new Ct(e)}var q=e=>(e||E("Cannot use deleted val. handle = "+e),Q.get(e).value),tt=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Q.ab({Va:1,value:e})}};function ke(e){var t=Error,n=Zt(e,function(r){this.name=e,this.message=r,r=Error(r).stack,r!==void 0&&(this.stack=this.toString()+`
`+r.replace(/^Error(:[^\n]*)?\n/,""))});return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},n}var Le=void 0,Ne=void 0;function j(e){for(var t="";z[e];)t+=Ne[z[e++]];return t}var St=[];function de(){for(;St.length;){var e=St.pop();e.Y.pa=!1,e.delete()}}var Dt=void 0,at={};function pe(e,t){for(t===void 0&&E("ptr should not be undefined");e.ba;)t=e.ta(t),e=e.ba;return t}var vt={};function Ze(e){e=an(e);var t=j(e);return ut(e),t}function Ot(e,t){var n=vt[e];return n===void 0&&E(t+" has unknown type "+Ze(e)),n}function Vt(){}var ve=!1;function Ve(e){--e.count.value,e.count.value===0&&(e.ea?e.ha.ma(e.ea):e.aa.Z.ma(e.$))}function He(e,t,n){return t===n?e:n.ba===void 0?null:(e=He(e,t,n.ba),e===null?null:n.lb(e))}var ze={};function On(e,t){return t=pe(e,t),at[t]}var Xe=void 0;function Ht(e){throw new Xe(e)}function zt(e,t){return t.aa&&t.$||Ht("makeClassHandle requires ptr and ptrType"),!!t.ha!=!!t.ea&&Ht("Both smartPtrType and smartPtr must be specified"),t.count={value:1},xt(Object.create(e,{Y:{value:t}}))}function xt(e){return typeof FinalizationRegistry>"u"?(xt=t=>t,e):(ve=new FinalizationRegistry(t=>{Ve(t.Y)}),xt=t=>{var n=t.Y;return n.ea&&ve.register(t,{Y:n},t),t},Vt=t=>{ve.unregister(t)},xt(e))}var Xt={};function Yt(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function jt(e){return this.fromWireType(ht[e>>2])}var Et={},Gt={};function X(e,t,n){function r(s){s=n(s),s.length!==e.length&&Ht("Mismatched type converter count");for(var h=0;h<e.length;++h)et(e[h],s[h])}e.forEach(function(s){Gt[s]=t});var a=Array(t.length),o=[],u=0;t.forEach((s,h)=>{vt.hasOwnProperty(s)?a[h]=vt[s]:(o.push(s),Et.hasOwnProperty(s)||(Et[s]=[]),Et[s].push(()=>{a[h]=vt[s],++u,u===o.length&&r(a)}))}),o.length===0&&r(a)}function Qt(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}function Yn(e,t,n={}){var r=t.name;if(e||E(`type "${r}" must have a positive integer typeid pointer`),vt.hasOwnProperty(e)){if(n.vb)return;E(`Cannot register type '${r}' twice`)}vt[e]=t,delete Gt[e],Et.hasOwnProperty(e)&&(t=Et[e],delete Et[e],t.forEach(a=>a()))}function et(e,t,n={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");Yn(e,t,n)}function me(e){E(e.Y.aa.Z.name+" instance already deleted")}function ft(){}function ge(e,t,n){if(e[t].ca===void 0){var r=e[t];e[t]=function(){return e[t].ca.hasOwnProperty(arguments.length)||E(`Function '${n}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[t].ca})!`),e[t].ca[arguments.length].apply(this,arguments)},e[t].ca=[],e[t].ca[r.oa]=r}}function ye(e,t,n){i.hasOwnProperty(e)?((n===void 0||i[e].ca!==void 0&&i[e].ca[n]!==void 0)&&E(`Cannot register public name '${e}' twice`),ge(i,e,e),i.hasOwnProperty(n)&&E(`Cannot register multiple overloads of a function with the same number of arguments (${n})!`),i[e].ca[n]=t):(i[e]=t,n!==void 0&&(i[e].Jb=n))}function jn(e,t,n,r,a,o,u,s){this.name=e,this.constructor=t,this.ia=n,this.ma=r,this.ba=a,this.qb=o,this.ta=u,this.lb=s,this.Ta=[]}function Jt(e,t,n){for(;t!==n;)t.ta||E(`Expected null or instance of ${n.name}, got an instance of ${t.name}`),e=t.ta(e),t=t.ba;return e}function Bn(e,t){return t===null?(this.Ca&&E(`null is not a valid ${this.name}`),0):(t.Y||E(`Cannot pass "${we(t)}" as a ${this.name}`),t.Y.$||E(`Cannot pass deleted object as a pointer of type ${this.name}`),Jt(t.Y.$,t.Y.aa.Z,this.Z))}function Un(e,t){if(t===null){if(this.Ca&&E(`null is not a valid ${this.name}`),this.wa){var n=this.Da();return e!==null&&e.push(this.ma,n),n}return 0}if(t.Y||E(`Cannot pass "${we(t)}" as a ${this.name}`),t.Y.$||E(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.va&&t.Y.aa.va&&E(`Cannot convert argument of type ${t.Y.ha?t.Y.ha.name:t.Y.aa.name} to parameter type ${this.name}`),n=Jt(t.Y.$,t.Y.aa.Z,this.Z),this.wa)switch(t.Y.ea===void 0&&E("Passing raw pointer to smart pointer is illegal"),this.Hb){case 0:t.Y.ha===this?n=t.Y.ea:E(`Cannot convert argument of type ${t.Y.ha?t.Y.ha.name:t.Y.aa.name} to parameter type ${this.name}`);break;case 1:n=t.Y.ea;break;case 2:if(t.Y.ha===this)n=t.Y.ea;else{var r=t.clone();n=this.Db(n,tt(function(){r.delete()})),e!==null&&e.push(this.ma,n)}break;default:E("Unsupporting sharing policy")}return n}function Wn(e,t){return t===null?(this.Ca&&E(`null is not a valid ${this.name}`),0):(t.Y||E(`Cannot pass "${we(t)}" as a ${this.name}`),t.Y.$||E(`Cannot pass deleted object as a pointer of type ${this.name}`),t.Y.aa.va&&E(`Cannot convert argument of type ${t.Y.aa.name} to parameter type ${this.name}`),Jt(t.Y.$,t.Y.aa.Z,this.Z))}function ot(e,t,n,r){this.name=e,this.Z=t,this.Ca=n,this.va=r,this.wa=!1,this.ma=this.Db=this.Da=this.Ua=this.Hb=this.Cb=void 0,t.ba!==void 0?this.toWireType=Un:(this.toWireType=r?Bn:Wn,this.ga=null)}function Ge(e,t,n){i.hasOwnProperty(e)||Ht("Replacing nonexistant public symbol"),i[e].ca!==void 0&&n!==void 0?i[e].ca[n]=t:(i[e]=t,i[e].oa=n)}var kn=(e,t)=>{var n=[];return function(){if(n.length=0,Object.assign(n,arguments),e.includes("j")){var r=i["dynCall_"+e];r=n&&n.length?r.apply(null,[t].concat(n)):r.call(null,t)}else r=ce.get(t).apply(null,n);return r}};function Z(e,t){e=j(e);var n=e.includes("j")?kn(e,t):ce.get(t);return typeof n!="function"&&E(`unknown function pointer with signature ${e}: ${t}`),n}var Qe=void 0;function st(e,t){function n(o){a[o]||vt[o]||(Gt[o]?Gt[o].forEach(n):(r.push(o),a[o]=!0))}var r=[],a={};throw t.forEach(n),new Qe(`${e}: `+r.map(Ze).join([", "]))}function qt(e,t,n,r,a){var o=t.length;2>o&&E("argTypes array size mismatch! Must at least get return value and 'this' types!");var u=t[1]!==null&&n!==null,s=!1;for(n=1;n<t.length;++n)if(t[n]!==null&&t[n].ga===void 0){s=!0;break}var h=t[0].name!=="void",c=o-2,l=Array(c),v=[],g=[];return function(){if(arguments.length!==c&&E(`function ${e} called with ${arguments.length} arguments, expected ${c} args!`),g.length=0,v.length=u?2:1,v[0]=a,u){var A=t[1].toWireType(g,this);v[1]=A}for(var C=0;C<c;++C)l[C]=t[C+2].toWireType(g,arguments[C]),v.push(l[C]);if(C=r.apply(null,v),s)Yt(g);else for(var y=u?1:2;y<t.length;y++){var Y=y===1?A:l[y-2];t[y].ga!==null&&t[y].ga(Y)}return A=h?t[0].fromWireType(C):void 0,A}}function Kt(e,t){for(var n=[],r=0;r<e;r++)n.push(B[t+4*r>>2]);return n}function Je(e,t,n){return e instanceof Object||E(`${n} with invalid "this": ${e}`),e instanceof t.Z.constructor||E(`${n} incompatible with "this" of type ${e.constructor.name}`),e.Y.$||E(`cannot call emscripten binding method ${n} on deleted object`),Jt(e.Y.$,e.Y.aa.Z,t.Z)}function be(e){e>=Q.Ga&&--Q.get(e).Va===0&&Q.$a(e)}function Ln(e,t,n){switch(t){case 0:return function(r){return this.fromWireType((n?wt:z)[r])};case 1:return function(r){return this.fromWireType((n?dt:$t)[r>>1])};case 2:return function(r){return this.fromWireType((n?ht:B)[r>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function we(e){if(e===null)return"null";var t=typeof e;return t==="object"||t==="array"||t==="function"?e.toString():""+e}function Nn(e,t){switch(t){case 2:return function(n){return this.fromWireType(Me[n>>2])};case 3:return function(n){return this.fromWireType(_e[n>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Zn(e,t,n){switch(t){case 0:return n?function(r){return wt[r]}:function(r){return z[r]};case 1:return n?function(r){return dt[r>>1]}:function(r){return $t[r>>1]};case 2:return n?function(r){return ht[r>>2]}:function(r){return B[r>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var qe=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Ke=(e,t,n)=>{var r=t+n;for(n=t;e[n]&&!(n>=r);)++n;if(16<n-t&&e.buffer&&qe)return qe.decode(e.subarray(t,n));for(r="";t<n;){var a=e[t++];if(a&128){var o=e[t++]&63;if((a&224)==192)r+=String.fromCharCode((a&31)<<6|o);else{var u=e[t++]&63;a=(a&240)==224?(a&15)<<12|o<<6|u:(a&7)<<18|o<<12|u<<6|e[t++]&63,65536>a?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|a&1023))}}else r+=String.fromCharCode(a)}return r},tn=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Vn=(e,t)=>{for(var n=e>>1,r=n+t/2;!(n>=r)&&$t[n];)++n;if(n<<=1,32<n-e&&tn)return tn.decode(z.subarray(e,n));for(n="",r=0;!(r>=t/2);++r){var a=dt[e+2*r>>1];if(a==0)break;n+=String.fromCharCode(a)}return n},Hn=(e,t,n)=>{if(n===void 0&&(n=2147483647),2>n)return 0;n-=2;var r=t;n=n<2*e.length?n/2:e.length;for(var a=0;a<n;++a)dt[t>>1]=e.charCodeAt(a),t+=2;return dt[t>>1]=0,t-r},zn=e=>2*e.length,Xn=(e,t)=>{for(var n=0,r="";!(n>=t/4);){var a=ht[e+4*n>>2];if(a==0)break;++n,65536<=a?(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|a&1023)):r+=String.fromCharCode(a)}return r},Gn=(e,t,n)=>{if(n===void 0&&(n=2147483647),4>n)return 0;var r=t;n=r+n-4;for(var a=0;a<e.length;++a){var o=e.charCodeAt(a);if(55296<=o&&57343>=o){var u=e.charCodeAt(++a);o=65536+((o&1023)<<10)|u&1023}if(ht[t>>2]=o,t+=4,t+4>n)break}return ht[t>>2]=0,t-r},Qn=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);55296<=r&&57343>=r&&++n,t+=4}return t},Jn={};function te(e){var t=Jn[e];return t===void 0?j(e):t}var ee=[];function qn(e){var t=ee.length;return ee.push(e),t}function Kn(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=Ot(B[t+4*r>>2],"parameter "+r);return n}var en=[],Ae={},nn=()=>{if(!Ce){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:k||"./this.program"},t;for(t in Ae)Ae[t]===void 0?delete e[t]:e[t]=Ae[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);Ce=n}return Ce},Ce,tr=[null,[],[]];Object.assign(We.prototype,{get(e){return this.la[e]},has(e){return this.la[e]!==void 0},ab(e){var t=this.Qa.pop()||this.la.length;return this.la[t]=e,t},$a(e){this.la[e]=void 0,this.Qa.push(e)}}),Ct=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},Q.la.push({value:void 0},{value:null},{value:!0},{value:!1}),Q.Ga=Q.la.length,i.count_emval_handles=function(){for(var e=0,t=Q.Ga;t<Q.la.length;++t)Q.la[t]!==void 0&&++e;return e},Le=i.PureVirtualError=ke("PureVirtualError");for(var rn=Array(256),ne=0;256>ne;++ne)rn[ne]=String.fromCharCode(ne);Ne=rn,i.getInheritedInstanceCount=function(){return Object.keys(at).length},i.getLiveInheritedInstances=function(){var e=[],t;for(t in at)at.hasOwnProperty(t)&&e.push(at[t]);return e},i.flushPendingDeletes=de,i.setDelayFunction=function(e){Dt=e,St.length&&Dt&&Dt(de)},Xe=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},ft.prototype.isAliasOf=function(e){if(!(this instanceof ft&&e instanceof ft))return!1;var t=this.Y.aa.Z,n=this.Y.$,r=e.Y.aa.Z;for(e=e.Y.$;t.ba;)n=t.ta(n),t=t.ba;for(;r.ba;)e=r.ta(e),r=r.ba;return t===r&&n===e},ft.prototype.clone=function(){if(this.Y.$||me(this),this.Y.ra)return this.Y.count.value+=1,this;var e=xt,t=Object,n=t.create,r=Object.getPrototypeOf(this),a=this.Y;return e=e(n.call(t,r,{Y:{value:{count:a.count,pa:a.pa,ra:a.ra,$:a.$,aa:a.aa,ea:a.ea,ha:a.ha}}})),e.Y.count.value+=1,e.Y.pa=!1,e},ft.prototype.delete=function(){this.Y.$||me(this),this.Y.pa&&!this.Y.ra&&E("Object already scheduled for deletion"),Vt(this),Ve(this.Y),this.Y.ra||(this.Y.ea=void 0,this.Y.$=void 0)},ft.prototype.isDeleted=function(){return!this.Y.$},ft.prototype.deleteLater=function(){return this.Y.$||me(this),this.Y.pa&&!this.Y.ra&&E("Object already scheduled for deletion"),St.push(this),St.length===1&&Dt&&Dt(de),this.Y.pa=!0,this},ot.prototype.rb=function(e){return this.Ua&&(e=this.Ua(e)),e},ot.prototype.Ma=function(e){this.ma&&this.ma(e)},ot.prototype.argPackAdvance=8,ot.prototype.readValueFromPointer=jt,ot.prototype.deleteObject=function(e){e!==null&&e.delete()},ot.prototype.fromWireType=function(e){function t(){return this.wa?zt(this.Z.ia,{aa:this.Cb,$:n,ha:this,ea:e}):zt(this.Z.ia,{aa:this,$:e})}var n=this.rb(e);if(!n)return this.Ma(e),null;var r=On(this.Z,n);if(r!==void 0)return r.Y.count.value===0?(r.Y.$=n,r.Y.ea=e,r.clone()):(r=r.clone(),this.Ma(e),r);if(r=this.Z.qb(n),r=ze[r],!r)return t.call(this);r=this.va?r.hb:r.pointerType;var a=He(n,this.Z,r.Z);return a===null?t.call(this):this.wa?zt(r.Z.ia,{aa:r,$:a,ha:this,ea:e}):zt(r.Z.ia,{aa:r,$:a})},Qe=i.UnboundTypeError=ke("UnboundTypeError");var er={L:function(e,t,n){e=j(e),t=Ot(t,"wrapper"),n=q(n);var r=[].slice,a=t.Z,o=a.ia,u=a.ba.ia,s=a.ba.constructor;e=Zt(e,function(){a.ba.Ta.forEach(function(c){if(this[c]===u[c])throw new Le(`Pure virtual function ${c} must be implemented in JavaScript`)}.bind(this)),Object.defineProperty(this,"__parent",{value:o}),this.__construct.apply(this,r.call(arguments))}),o.__construct=function(){this===o&&E("Pass correct 'this' to __construct");var c=s.implement.apply(void 0,[this].concat(r.call(arguments)));Vt(c);var l=c.Y;c.notifyOnDestruction(),l.ra=!0,Object.defineProperties(this,{Y:{value:l}}),xt(this),c=l.$,c=pe(a,c),at.hasOwnProperty(c)?E(`Tried to register registered instance: ${c}`):at[c]=this},o.__destruct=function(){this===o&&E("Pass correct 'this' to __destruct"),Vt(this);var c=this.Y.$;c=pe(a,c),at.hasOwnProperty(c)?delete at[c]:E(`Tried to unregister unregistered instance: ${c}`)},e.prototype=Object.create(o);for(var h in n)e.prototype[h]=n[h];return tt(e)},N:function(e){var t=Xt[e];delete Xt[e];var n=t.Da,r=t.ma,a=t.Pa,o=a.map(u=>u.ub).concat(a.map(u=>u.Fb));X([e],o,u=>{var s={};return a.forEach((h,c)=>{var l=u[c],v=h.sb,g=h.tb,A=u[c+a.length],C=h.Eb,y=h.Gb;s[h.ob]={read:Y=>l.fromWireType(v(g,Y)),write:(Y,P)=>{var R=[];C(y,Y,A.toWireType(R,P)),Yt(R)}}}),[{name:t.name,fromWireType:function(h){var c={},l;for(l in s)c[l]=s[l].read(h);return r(h),c},toWireType:function(h,c){for(var l in s)if(!(l in c))throw new TypeError(`Missing field: "${l}"`);var v=n();for(l in s)s[l].write(v,c[l]);return h!==null&&h.push(r,v),v},argPackAdvance:8,readValueFromPointer:jt,ga:r}]})},C:function(){},J:function(e,t,n,r,a){var o=Qt(n);t=j(t),et(e,{name:t,fromWireType:function(u){return!!u},toWireType:function(u,s){return s?r:a},argPackAdvance:8,readValueFromPointer:function(u){if(n===1)var s=wt;else if(n===2)s=dt;else if(n===4)s=ht;else throw new TypeError("Unknown boolean type size: "+t);return this.fromWireType(s[u>>o])},ga:null})},f:function(e,t,n,r,a,o,u,s,h,c,l,v,g){l=j(l),o=Z(a,o),s&&(s=Z(u,s)),c&&(c=Z(h,c)),g=Z(v,g);var A=Ue(l);ye(A,function(){st(`Cannot construct ${l} due to unbound types`,[r])}),X([e,t,n],r?[r]:[],function(C){if(C=C[0],r)var y=C.Z,Y=y.ia;else Y=ft.prototype;C=Zt(A,function(){if(Object.getPrototypeOf(this)!==P)throw new Ct("Use 'new' to construct "+l);if(R.na===void 0)throw new Ct(l+" has no accessible constructor");var G=R.na[arguments.length];if(G===void 0)throw new Ct(`Tried to invoke ctor of ${l} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(R.na).toString()}) parameters instead!`);return G.apply(this,arguments)});var P=Object.create(Y,{constructor:{value:C}});C.prototype=P;var R=new jn(l,C,P,g,y,o,s,c);R.ba&&(R.ba.ua===void 0&&(R.ba.ua=[]),R.ba.ua.push(R)),y=new ot(l,R,!0,!1),Y=new ot(l+"*",R,!1,!1);var D=new ot(l+" const*",R,!1,!0);return ze[e]={pointerType:Y,hb:D},Ge(A,C),[y,Y,D]})},l:function(e,t,n,r,a,o,u){var s=Kt(n,r);t=j(t),o=Z(a,o),X([],[e],function(h){function c(){st(`Cannot call ${l} due to unbound types`,s)}h=h[0];var l=`${h.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var v=h.Z.constructor;return v[t]===void 0?(c.oa=n-1,v[t]=c):(ge(v,t,l),v[t].ca[n-1]=c),X([],s,function(g){if(g=qt(l,[g[0],null].concat(g.slice(1)),null,o,u),v[t].ca===void 0?(g.oa=n-1,v[t]=g):v[t].ca[n-1]=g,h.Z.ua)for(let A of h.Z.ua)A.constructor.hasOwnProperty(t)||(A.constructor[t]=g);return[]}),[]})},w:function(e,t,n,r,a,o,u,s){t=j(t),o=Z(a,o),X([],[e],function(h){h=h[0];var c=`${h.name}.${t}`,l={get(){st(`Cannot access ${c} due to unbound types`,[n])},enumerable:!0,configurable:!0};return l.set=s?()=>{st(`Cannot access ${c} due to unbound types`,[n])}:()=>{E(`${c} is a read-only property`)},Object.defineProperty(h.Z.constructor,t,l),X([],[n],function(v){v=v[0];var g={get(){return v.fromWireType(o(r))},enumerable:!0};return s&&(s=Z(u,s),g.set=A=>{var C=[];s(r,v.toWireType(C,A)),Yt(C)}),Object.defineProperty(h.Z.constructor,t,g),[]}),[]})},r:function(e,t,n,r,a,o){var u=Kt(t,n);a=Z(r,a),X([],[e],function(s){s=s[0];var h=`constructor ${s.name}`;if(s.Z.na===void 0&&(s.Z.na=[]),s.Z.na[t-1]!==void 0)throw new Ct(`Cannot register multiple constructors with identical number of parameters (${t-1}) for class '${s.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return s.Z.na[t-1]=()=>{st(`Cannot construct ${s.name} due to unbound types`,u)},X([],u,function(c){return c.splice(1,0,null),s.Z.na[t-1]=qt(h,c,null,a,o),[]}),[]})},b:function(e,t,n,r,a,o,u,s){var h=Kt(n,r);t=j(t),o=Z(a,o),X([],[e],function(c){function l(){st(`Cannot call ${v} due to unbound types`,h)}c=c[0];var v=`${c.name}.${t}`;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&c.Z.Ta.push(t);var g=c.Z.ia,A=g[t];return A===void 0||A.ca===void 0&&A.className!==c.name&&A.oa===n-2?(l.oa=n-2,l.className=c.name,g[t]=l):(ge(g,t,v),g[t].ca[n-2]=l),X([],h,function(C){return C=qt(v,C,c,o,u),g[t].ca===void 0?(C.oa=n-2,g[t]=C):g[t].ca[n-2]=C,[]}),[]})},e:function(e,t,n,r,a,o,u,s,h,c){t=j(t),a=Z(r,a),X([],[e],function(l){l=l[0];var v=`${l.name}.${t}`,g={get(){st(`Cannot access ${v} due to unbound types`,[n,u])},enumerable:!0,configurable:!0};return g.set=h?()=>{st(`Cannot access ${v} due to unbound types`,[n,u])}:()=>{E(v+" is a read-only property")},Object.defineProperty(l.Z.ia,t,g),X([],h?[n,u]:[n],function(A){var C=A[0],y={get(){var P=Je(this,l,v+" getter");return C.fromWireType(a(o,P))},enumerable:!0};if(h){h=Z(s,h);var Y=A[1];y.set=function(P){var R=Je(this,l,v+" setter"),D=[];h(c,R,Y.toWireType(D,P)),Yt(D)}}return Object.defineProperty(l.Z.ia,t,y),[]}),[]})},I:function(e,t){t=j(t),et(e,{name:t,fromWireType:function(n){var r=q(n);return be(n),r},toWireType:function(n,r){return tt(r)},argPackAdvance:8,readValueFromPointer:jt,ga:null})},o:function(e,t,n,r){function a(){}n=Qt(n),t=j(t),a.values={},et(e,{name:t,constructor:a,fromWireType:function(o){return this.constructor.values[o]},toWireType:function(o,u){return u.value},argPackAdvance:8,readValueFromPointer:Ln(t,n,r),ga:null}),ye(t,a)},c:function(e,t,n){var r=Ot(e,"enum");t=j(t),e=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:Zt(`${r.name}_${t}`,function(){})}}),e.values[n]=r,e[t]=r},y:function(e,t,n){n=Qt(n),t=j(t),et(e,{name:t,fromWireType:function(r){return r},toWireType:function(r,a){return a},argPackAdvance:8,readValueFromPointer:Nn(t,n),ga:null})},t:function(e,t,n,r,a,o){var u=Kt(t,n);e=j(e),a=Z(r,a),ye(e,function(){st(`Cannot call ${e} due to unbound types`,u)},t-1),X([],u,function(s){return Ge(e,qt(e,[s[0],null].concat(s.slice(1)),null,a,o),t-1),[]})},k:function(e,t,n,r,a){t=j(t),a===-1&&(a=4294967295),a=Qt(n);var o=s=>s;if(r===0){var u=32-8*n;o=s=>s<<u>>>u}n=t.includes("unsigned")?function(s,h){return h>>>0}:function(s,h){return h},et(e,{name:t,fromWireType:o,toWireType:n,argPackAdvance:8,readValueFromPointer:Zn(t,a,r!==0),ga:null})},g:function(e,t,n){function r(o){o>>=2;var u=B;return new a(u.buffer,u[o+1],u[o])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];n=j(n),et(e,{name:n,fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{vb:!0})},z:function(e,t){t=j(t);var n=t==="std::string";et(e,{name:t,fromWireType:function(r){var a=B[r>>2],o=r+4;if(n)for(var u=o,s=0;s<=a;++s){var h=o+s;if(s==a||z[h]==0){if(u=u?Ke(z,u,h-u):"",c===void 0)var c=u;else c+="\0",c+=u;u=h+1}}else{for(c=Array(a),s=0;s<a;++s)c[s]=String.fromCharCode(z[o+s]);c=c.join("")}return ut(r),c},toWireType:function(r,a){a instanceof ArrayBuffer&&(a=new Uint8Array(a));var o,u=typeof a=="string";u||a instanceof Uint8Array||a instanceof Uint8ClampedArray||a instanceof Int8Array||E("Cannot pass non-string to std::string");var s;if(n&&u)for(o=s=0;o<a.length;++o){var h=a.charCodeAt(o);127>=h?s++:2047>=h?s+=2:55296<=h&&57343>=h?(s+=4,++o):s+=3}else s=a.length;if(o=s,s=xe(4+o+1),h=s+4,B[s>>2]=o,n&&u){if(u=h,h=o+1,o=z,0<h){h=u+h-1;for(var c=0;c<a.length;++c){var l=a.charCodeAt(c);if(55296<=l&&57343>=l){var v=a.charCodeAt(++c);l=65536+((l&1023)<<10)|v&1023}if(127>=l){if(u>=h)break;o[u++]=l}else{if(2047>=l){if(u+1>=h)break;o[u++]=192|l>>6}else{if(65535>=l){if(u+2>=h)break;o[u++]=224|l>>12}else{if(u+3>=h)break;o[u++]=240|l>>18,o[u++]=128|l>>12&63}o[u++]=128|l>>6&63}o[u++]=128|l&63}}o[u]=0}}else if(u)for(u=0;u<o;++u)c=a.charCodeAt(u),255<c&&(ut(h),E("String has UTF-16 code units that do not fit in 8 bits")),z[h+u]=c;else for(u=0;u<o;++u)z[h+u]=a[u];return r!==null&&r.push(ut,s),s},argPackAdvance:8,readValueFromPointer:jt,ga:function(r){ut(r)}})},v:function(e,t,n){if(n=j(n),t===2)var r=Vn,a=Hn,o=zn,u=()=>$t,s=1;else t===4&&(r=Xn,a=Gn,o=Qn,u=()=>B,s=2);et(e,{name:n,fromWireType:function(h){for(var c=B[h>>2],l=u(),v,g=h+4,A=0;A<=c;++A){var C=h+4+A*t;(A==c||l[C>>s]==0)&&(g=r(g,C-g),v===void 0?v=g:(v+="\0",v+=g),g=C+t)}return ut(h),v},toWireType:function(h,c){typeof c!="string"&&E(`Cannot pass non-string to C++ string type ${n}`);var l=o(c),v=xe(4+l+t);return B[v>>2]=l>>s,a(c,v+4,l+t),h!==null&&h.push(ut,v),v},argPackAdvance:8,readValueFromPointer:jt,ga:function(h){ut(h)}})},P:function(e,t,n,r,a,o){Xt[e]={name:j(t),Da:Z(n,r),ma:Z(a,o),Pa:[]}},O:function(e,t,n,r,a,o,u,s,h,c){Xt[e].Pa.push({ob:j(t),ub:n,sb:Z(r,a),tb:o,Fb:u,Eb:Z(s,h),Gb:c})},K:function(e,t){t=j(t),et(e,{xb:!0,name:t,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},u:function(e,t,n){e=q(e),t=Ot(t,"emval::as");var r=[],a=tt(r);return B[n>>2]=a,t.toWireType(r,e)},A:function(e,t,n,r,a){e=ee[e],t=q(t),n=te(n);var o=[];return B[r>>2]=tt(o),e(t,n,o,a)},i:function(e,t,n,r){e=ee[e],t=q(t),n=te(n),e(t,n,null,r)},d:be,h:function(e,t){var n=Kn(e,t),r=n[0];t=r.name+"_$"+n.slice(1).map(function(u){return u.name}).join("_")+"$";var a=en[t];if(a!==void 0)return a;var o=Array(e-1);return a=qn((u,s,h,c)=>{for(var l=0,v=0;v<e-1;++v)o[v]=n[v+1].readValueFromPointer(c+l),l+=n[v+1].argPackAdvance;for(u=u[s].apply(u,o),v=0;v<e-1;++v)n[v+1].jb&&n[v+1].jb(o[v]);if(!r.xb)return r.toWireType(h,u)}),en[t]=a},s:function(e){return e=te(e),tt(i[e])},M:function(e,t){return e=q(e),t=q(t),tt(e[t])},n:function(e){4<e&&(Q.get(e).Va+=1)},m:function(e){return tt(te(e))},x:function(){return tt({})},p:function(e){var t=q(e);Yt(t),be(e)},j:function(e,t,n){e=q(e),t=q(t),n=q(n),e[t]=n},q:function(e,t){return e=Ot(e,"_emval_take_value"),e=e.readValueFromPointer(t),tt(e)},a:()=>{fe("")},D:e=>{var t=z.length;if(e>>>=0,2147483648<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math;r=Math.max(e,r);t:{a=a.min.call(a,2147483648,r+(65536-r%65536)%65536)-Nt.buffer.byteLength+65535>>>16;try{Nt.grow(a),$e();var o=1;break t}catch{}o=void 0}if(o)return!0}return!1},E:(e,t)=>{var n=0;return nn().forEach(function(r,a){var o=t+n;for(a=B[e+4*a>>2]=o,o=0;o<r.length;++o)wt[a++>>0]=r.charCodeAt(o);wt[a>>0]=0,n+=r.length+1}),0},F:(e,t)=>{var n=nn();B[e>>2]=n.length;var r=0;return n.forEach(function(a){r+=a.length+1}),B[t>>2]=r,0},G:()=>52,B:function(){return 70},H:(e,t,n,r)=>{for(var a=0,o=0;o<n;o++){var u=B[t>>2],s=B[t+4>>2];t+=8;for(var h=0;h<s;h++){var c=z[u+h],l=tr[e];c===0||c===10?((e===1?$n:bt)(Ke(l,0)),l.length=0):l.push(c)}a+=s}return B[r>>2]=a,0}};(function(){function e(n){if(it=n=n.exports,Nt=it.Q,$e(),ce=it.W,Se.unshift(it.R),pt--,i.monitorRunDependencies&&i.monitorRunDependencies(pt),pt==0&&(he!==null&&(clearInterval(he),he=null),Ft)){var r=Ft;Ft=null,r()}return n}var t={a:er};if(pt++,i.monitorRunDependencies&&i.monitorRunDependencies(pt),i.instantiateWasm)try{return i.instantiateWasm(t,e)}catch(n){bt("Module.instantiateWasm callback failed with error: "+n),m(n)}return Dn(t,function(n){e(n.instance)}).catch(m),{}})();var ut=e=>(ut=it.S)(e),xe=e=>(xe=it.T)(e),an=e=>(an=it.U)(e);i.__embind_initialize_bindings=()=>(i.__embind_initialize_bindings=it.V)(),i.dynCall_jiji=(e,t,n,r,a)=>(i.dynCall_jiji=it.X)(e,t,n,r,a);var re;Ft=function e(){re||on(),re||(Ft=e)};function on(){function e(){if(!re&&(re=!0,i.calledRun=!0,!Ie)){if(le(Se),d(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for(typeof i.postRun=="function"&&(i.postRun=[i.postRun]);i.postRun.length;){var t=i.postRun.shift();De.unshift(t)}le(De)}}if(!(0<pt)){if(i.preRun)for(typeof i.preRun=="function"&&(i.preRun=[i.preRun]);i.preRun.length;)Fn();le(Fe),0<pt||(i.setStatus?(i.setStatus("Running..."),setTimeout(function(){setTimeout(function(){i.setStatus("")},1),e()},1)):e())}}if(i.preInit)for(typeof i.preInit=="function"&&(i.preInit=[i.preInit]);0<i.preInit.length;)i.preInit.pop()();return on(),V.ready}})(),Tn=rr;var ir=p=>new fn(V=>{let i=0,d=!0,m=w=>{let x=w-i;i=w,d?(V.next(16),d=!1):V.next(x),!V.closed&&p.requestAnimationFrame(m)};p.requestAnimationFrame(m)}),ar=new oe("Folder with Rive files"),or=new oe("Version used to load rive WASM"),sr=new oe("Local path to rive WASM"),_n=(()=>{class p{constructor(i,d,m,w){this.http=i;let x=w??"2.4.0";this.folder=d??"assets/rive",this.wasmPath=m??`https://unpkg.com/@rive-app/canvas-advanced@${x}/rive.wasm`}getRive(){return ae(this,null,function*(){if(!this.rive){let i=()=>this.wasmPath;this.rive=yield Tn({locateFile:i}),this.frame=ir(this.rive).pipe(mn())}return this.rive})}getAsset(i){return pn(this.http.get(i,{responseType:"arraybuffer"}))}load(i){return ae(this,null,function*(){if(typeof i!="string"){let[x,O]=yield Promise.all([this.getRive(),i.arrayBuffer()]);return x?.load(new Uint8Array(O))}let d=`${this.folder}/${i}.riv`,[m,w]=yield Promise.all([this.getRive(),this.getAsset(d)]);if(!m)throw new Error("Could not load rive");return m.load(new Uint8Array(w))})}static{this.\u0275fac=function(d){return new(d||p)(Lt(En),Lt(ar,8),Lt(sr,8),Lt(or,8))}}static{this.\u0275prov=yn({token:p,factory:p.\u0275fac,providedIn:"root"})}}return p})();function Pn(p){let V=typeof p=="string"?parseInt(p):p;if(typeof V=="number")return V}function ur(p){return["touchstart","touchmove"].indexOf(p.type)>-1&&p.touches?.length?(p.preventDefault(),{clientX:p.touches[0].clientX,clientY:p.touches[0].clientY}):p.type==="touchend"&&p.changedTouches?.length?{clientX:p.changedTouches[0].clientX,clientY:p.changedTouches[0].clientY}:{clientX:p.clientX,clientY:p.clientY}}var cr=p=>p!=null,hr=p=>new Promise((V,i)=>{if(typeof window>"u")return V(!1);if(!("IntersectionObserver"in window))return V(!0);let d=!1,m=new IntersectionObserver(w=>{w.forEach(x=>{x.intersectionRatio!==0!==d&&(V(d),m.disconnect())})},{threshold:[0]});m.observe(p)});var fr=(()=>{class p{set riv(i){this.url.next(i)}set name(i){this.arboardName.next(i)}set width(i){let d=Pn(i)??this.canvas.width;this.canvas.width=d}get width(){return this.canvas.width}set height(i){let d=Pn(i)??this.canvas.height;this.canvas.height=d}get height(){return this.canvas.height}pointerMove(i){let d=Object.values(this.stateMachines).filter(w=>"pointerMove"in w);if(!d.length)return;let m=this.getTransform(i);if(m)for(let w of d)w.pointerMove(m.x,m.y)}pointerDown(i){let d=Object.values(this.stateMachines).filter(w=>"pointerDown"in w);if(!d.length)return;let m=this.getTransform(i);if(m)for(let w of d)w.pointerDown(m.x,m.y)}pointerUp(i){let d=Object.values(this.stateMachines).filter(w=>"pointerUp"in w);if(!d.length)return;let m=this.getTransform(i);if(m)for(let w of d)w.pointerUp(m.x,m.y)}constructor(i,d){this.service=i,this.url=new Wt(null),this.arboardName=new Wt(null),this.boxes={},this.stateMachines={},this.viewbox="0 0 100% 100%",this.lazy=!1,this.fit="contain",this.alignment="center",this.artboardChange=new It,this.canvas=d.nativeElement,this.whenVisible=hr(d.nativeElement),this.loaded=this.url.pipe(Tt(cr),Re(),Tt(()=>typeof window<"u"&&!!this.ctx),Pt(m=>ae(this,null,function*(){if(this.file=yield this.service.load(m),this.rive=this.service.rive,!this.rive)throw new Error("Service could not load rive");this.renderer=this.rive.makeRenderer(this.canvas)})),Pt(m=>this.setArtboard()),gn({bufferSize:1,refCount:!0}))}ngOnInit(){this.onReady()}ngOnDestroy(){setTimeout(()=>{this.renderer?.delete(),this.artboard?.delete(),this.file?.delete()},100)}get ctx(){return this._ctx||(this._ctx=this.canvas.getContext("2d")),this._ctx}setArtboard(){return this.arboardName.pipe(kt(()=>this.artboard?.delete()),yt(i=>i?this.file?.artboardByName(i):this.file?.defaultArtboard()),kt(i=>this.artboard=i),kt(()=>this.artboardChange.emit(this.artboard)),yt(()=>!0))}get box(){let i=this.width,d=this.height,m=`${this.viewbox} ${i} ${d}`;if(!this.boxes[m]){let w=this.viewbox.split(" ");if(w.length!==4)throw new Error('View box should look like "0 0 100% 100%"');let[x,O,W,N]=w.map((k,rt)=>{let K=rt%2===0?i:d,H=k.endsWith("%")?parseInt(k.slice(0,-1),10)/100:parseInt(k,10)/K;return rt<2?-K*H:K/H});this.boxes[m]={minX:x,minY:O,maxX:W,maxY:N}}return this.boxes[m]}get isLazy(){return this.lazy===!0||this.lazy===""}get count(){return this.artboard?.animationCount()}onReady(){return this.isLazy?ln(this.whenVisible).pipe(Tt(i=>i),Pt(()=>this.loaded)):this.loaded}draw(i,d,m){if(!this.rive)throw new Error("Could not load rive before registrating instance");if(!this.artboard)throw new Error("Could not load artboard before registrating instance");if(!this.renderer)throw new Error("Could not load renderer before registrating instance");this.renderer.clear(),lr(i)?(i.advance(d),i.apply(m??1)):i.advance(d),this.artboard.advance(d),this.renderer.save();let w=this.rive.Fit[this.fit],x=this.rive.Alignment[this.alignment],O=this.box,W=this.artboard.bounds;this.renderer.align(w,x,O,W),this.artboard.draw(this.renderer),this.renderer.restore()}getTransform(i){if(!this.rive||!this.artboard)return;let d=this.canvas.getBoundingClientRect(),{clientX:m,clientY:w}=ur(i);if(!m&&!w)return;let x=m-d.left,O=w-d.top,W=this.rive.computeAlignment(this.rive.Fit[this.fit],this.rive.Alignment[this.alignment],{minX:0,minY:0,maxX:d.width,maxY:d.height},this.artboard.bounds),N=new this.rive.Mat2D;W.invert(N);let k=new this.rive.Vec2D(x,O),rt=this.rive.mapXY(N,k),K=rt.x(),H=rt.y();return rt.delete(),N.delete(),k.delete(),W.delete(),{x:K,y:H}}static{this.\u0275fac=function(d){return new(d||p)(Mt(_n),Mt(Cn))}}static{this.\u0275dir=Te({type:p,selectors:[["canvas","riv",""]],hostBindings:function(d,m){d&1&&xn("touchmove",function(x){return m.pointerMove(x)})("mouseover",function(x){return m.pointerMove(x)})("mouseout",function(x){return m.pointerMove(x)})("mousemove",function(x){return m.pointerMove(x)})("touchstart",function(x){return m.pointerDown(x)})("mousedown",function(x){return m.pointerDown(x)})("touchend",function(x){return m.pointerUp(x)})("mouseup",function(x){return m.pointerUp(x)})},inputs:{riv:"riv",name:[0,"artboard","name"],viewbox:"viewbox",lazy:"lazy",fit:"fit",alignment:"alignment",width:"width",height:"height"},outputs:{artboardChange:"artboardChange"},exportAs:["rivCanvas"],standalone:!0})}}return p})();function lr(p){return"didLoop"in p}function In(p={}){return ie({speed:1,playing:!1,mix:1,autoreset:!1},p)}function Pe(p){return Math.round((p+Number.EPSILON)*1e4)/1e4}function Mn(p){return p!=null}function dr(p){return!p.workStart||p.workStart===-1?0:Pe(p.workStart/p.fps)}function pr(p){let V=!p.workEnd||p.workEnd===-1?p.duration:p.workEnd;return Pe(V/p.fps)}var Wr=(()=>{class p{set name(i){typeof i=="string"&&this.zone.runOutsideAngular(()=>{this.register(i)})}set index(i){let d=typeof i=="string"?parseInt(i):i;typeof d=="number"&&this.zone.runOutsideAngular(()=>{this.register(d)})}set mix(i){let d=typeof i=="string"?parseFloat(i):i;d&&d>=0&&d<=1&&this.update({mix:d})}get mix(){return this.state.getValue().mix}set speed(i){let d=typeof i=="string"?parseFloat(i):i;typeof d=="number"&&this.update({speed:d})}get speed(){return this.state.getValue().speed}set play(i){i===!0||i===""?this.update({playing:!0}):i===!1&&this.update({playing:!1})}get play(){return this.state.getValue().playing}set time(i){let d=typeof i=="string"?parseFloat(i):i;typeof d=="number"&&this.distance.next(d)}set autoreset(i){i===!0||i===""?this.update({autoreset:!0}):i===!1&&this.update({autoreset:!1})}get autoreset(){return this.state.getValue().autoreset}set mode(i){i&&this.update({mode:i})}get mode(){return this.state.getValue().mode}constructor(i,d,m){this.zone=i,this.canvas=d,this.service=m,this.distance=new Wt(null),this.state=new Wt(In()),this.load=new It,this.timeChange=new It,this.playChange=new It,this.speedChange=new It}ngOnDestroy(){this.sub?.unsubscribe(),setTimeout(()=>this.instance?.delete(),100)}update(i){let d=In(ie(ie({},this.state.getValue()),i));this.state.next(d)}initAnimation(i){if(!this.service.rive)throw new Error("Could not load animation instance before rive");if(!this.canvas.artboard)throw new Error("Could not load animation instance before artboard");let d=typeof i=="string"?this.canvas.artboard.animationByName(i):this.canvas.artboard.animationByIndex(i);this.animation=d,this.instance=new this.service.rive.LinearAnimationInstance(d,this.canvas.artboard),this.startTime=dr(this.instance),this.endTime=pr(this.instance),this.load.emit(this.instance)}getFrame(i){return i.playing&&this.service.frame?this.service.frame.pipe(yt(d=>[i,d])):dn(null)}register(i){this.sub?.unsubscribe(),this.instance?.delete();let d=this.distance.pipe(Tt(Mn),Re(),yt(w=>w-this.instance.time)),m=this.state.pipe(Pt(w=>this.getFrame(w)),Tt(Mn),yt(([w,x])=>this.moveFrame(w,x)),kt(w=>{this.zone.run(()=>this.timeChange.emit(this.instance.time+w))}));this.sub=this.canvas.onReady().pipe(yt(()=>this.initAnimation(i)),Pt(()=>vn(d,m))).subscribe(w=>this.applyChange(w))}moveFrame(i,d){if(!this.instance)throw new Error("Could not load animation instance before running it");if(!this.animation)throw new Error("Could not load animation before running it");let{speed:m,autoreset:w,mode:x}=i;if(!x)return d/1e3*m;let O=d/1e3*m,W=this.startTime??0,N=this.endTime??this.instance.duration/this.instance.fps,k=Pe(this.instance.time);return k+O<W&&(x==="loop"&&m<0&&N?O=N-k:x==="ping-pong"?(O=-O,this.update({speed:-m}),this.zone.run(()=>this.speedChange.emit(-m))):x==="one-shot"&&(this.update({playing:!1}),this.zone.run(()=>this.playChange.emit(!1)),O=W-k)),x==="one-shot"&&w&&(m>0&&k===N&&(O=W-N),m<0&&k===W&&(O=N-W)),k+O>N&&(x==="loop"&&m>0?O=W-k:x==="ping-pong"?(O=-O,this.update({speed:-m}),this.zone.run(()=>this.speedChange.emit(-m))):x==="one-shot"&&(this.update({playing:!1}),this.zone.run(()=>this.playChange.emit(!1)),O=N-k)),O}applyChange(i){this.service.rive?.requestAnimationFrame(()=>{if(!this.instance)throw new Error("Could not load animation instance before running it");this.canvas.draw(this.instance,i,this.state.getValue().mix)})}static{this.\u0275fac=function(d){return new(d||p)(Mt(An),Mt(fr),Mt(_n))}}static{this.\u0275dir=Te({type:p,selectors:[["riv-player"],["","rivPlayer",""]],inputs:{name:"name",index:"index",mix:"mix",speed:"speed",play:"play",time:"time",autoreset:"autoreset",mode:"mode"},outputs:{load:"load",timeChange:"timeChange",playChange:"playChange",speedChange:"speedChange"},exportAs:["rivPlayer"],standalone:!0})}}return p})();var kr=(()=>{class p{static{this.\u0275fac=function(d){return new(d||p)}}static{this.\u0275mod=wn({type:p})}static{this.\u0275inj=bn({imports:[Rn]})}}return p})();export{fr as a,Wr as b,kr as c};
