// SVGA.Lite v2.1.1 function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SVGA={})}(this,(function(exports){"use strict";function __awaiter(e,t,r,i){return new(r||(r=Promise))((function(n,o){function a(e){try{u(i.next(e))}catch(e){o(e)}}function s(e){try{u(i.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((i=i.apply(e,t||[])).next())}))}function __generator(e,t){var r,i,n,o,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,i&&(n=2&s[0]?i.return:s[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,s[1])).done)return n;switch(i=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(n=a.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]0&&n[n.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]0?0:2147483648,r,i);else if(isNaN(e))t(2143289344,r,i);else if(e>34028234663852886e22)t((n<<31|2139095040)>>>0,r,i);else if(e<11754943508222875e-54)t((n<<31|Math.round(e/1401298464324817e-60))>>>0,r,i);else{var s=Math.floor(Math.log(e)/Math.LN2);t((n<<31|s+127<<23|8388607&Math.round(e*Math.pow(2,-s)*8388608))>>>0,r,i)}}function r(t,e,r){var i=t(e,r),n=2*(i>>31)+1,s=i>>>23&255,o=8388607&i;return 255===s?o?NaN:n*(1/0):0===s?1401298464324817e-60*n*o:n*Math.pow(2,s-150)*(o+8388608)}t.writeFloatLE=e.bind(null,v),t.writeFloatBE=e.bind(null,m),t.readFloatLE=r.bind(null,g),t.readFloatBE=r.bind(null,b)}(),\"undefined\"!=typeof Float64Array?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),i=128===r[7];function n(t,i,n){e[0]=t,i[n]=r[0],i[n+1]=r[1],i[n+2]=r[2],i[n+3]=r[3],i[n+4]=r[4],i[n+5]=r[5],i[n+6]=r[6],i[n+7]=r[7]}function s(t,i,n){e[0]=t,i[n]=r[7],i[n+1]=r[6],i[n+2]=r[5],i[n+3]=r[4],i[n+4]=r[3],i[n+5]=r[2],i[n+6]=r[1],i[n+7]=r[0]}function o(t,i){return r[0]=t[i],r[1]=t[i+1],r[2]=t[i+2],r[3]=t[i+3],r[4]=t[i+4],r[5]=t[i+5],r[6]=t[i+6],r[7]=t[i+7],e[0]}function a(t,i){return r[7]=t[i],r[6]=t[i+1],r[5]=t[i+2],r[4]=t[i+3],r[3]=t[i+4],r[2]=t[i+5],r[1]=t[i+6],r[0]=t[i+7],e[0]}t.writeDoubleLE=i?n:s,t.writeDoubleBE=i?s:n,t.readDoubleLE=i?o:a,t.readDoubleBE=i?a:o}():function(){function e(t,e,r,i,n,s){var o=i<0?1:0;if(o&&(i=-i),0===i)t(0,n,s+e),t(1/i>0?0:2147483648,n,s+r);else if(isNaN(i))t(0,n,s+e),t(2146959360,n,s+r);else if(i>17976931348623157e292)t(0,n,s+e),t((o<<31|2146435072)>>>0,n,s+r);else{var a;if(i<22250738585072014e-324)t((a=i/5e-324)>>>0,n,s+e),t((o<<31|a/4294967296)>>>0,n,s+r);else{var l=Math.floor(Math.log(i)/Math.LN2);1024===l&&(l=1023),t(4503599627370496*(a=i*Math.pow(2,-l))>>>0,n,s+e),t((o<<31|l+1023<<20|1048576*a&1048575)>>>0,n,s+r)}}}function r(t,e,r,i,n){var s=t(i,n+e),o=t(i,n+r),a=2*(o>>31)+1,l=o>>>20&2047,f=4294967296*(1048575&o)+s;return 2047===l?f?NaN:a*(1/0):0===l?5e-324*a*f:a*Math.pow(2,l-1075)*(f+4503599627370496)}t.writeDoubleLE=e.bind(null,v,0,4),t.writeDoubleBE=e.bind(null,m,4,0),t.readDoubleLE=r.bind(null,g,0,4),t.readDoubleBE=r.bind(null,b,4,0)}(),t}function v(t,e,r){e[r]=255&t,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function m(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function g(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function b(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}var w={};!function(t){var e=t;e.length=function(t){for(var e=0,r=0,i=0;i191&&i<224?s[o++]=(31&i)<<6|63&t[e++]:i>239&&i<365?(i=((7&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,s[o++]=55296+(i>>10),s[o++]=56320+(1023&i)):s[o++]=(15&i)<<12|(63&t[e++])<<6|63&t[e++],o>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,s)),o=0);return n?(o&&n.push(String.fromCharCode.apply(String,s.slice(0,o))),n.join(\"\")):String.fromCharCode.apply(String,s.slice(0,o))},e.write=function(t,e,r){for(var i,n,s=r,o=0;o>6|192,e[r++]=63&i|128):55296==(64512&i)&&56320==(64512&(n=t.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&n),++o,e[r++]=i>>18|240,e[r++]=i>>12&63|128,e[r++]=i>>6&63|128,e[r++]=63&i|128):(e[r++]=i>>12|224,e[r++]=i>>6&63|128,e[r++]=63&i|128);return r-s}}(w),function(t){var e=t;e.float=c,e.utf8=w,e.emptyArray=Object.freeze?Object.freeze([]):[],e.emptyObject=Object.freeze?Object.freeze({}):{},e.isInteger=Number.isInteger||function(t){return\"number\"==typeof t&&isFinite(t)&&Math.floor(t)===t},e.isString=function(t){return\"string\"==typeof t||t instanceof String},e.isObject=function(t){return t&&\"object\"===_typeof(t)},e.Array=\"undefined\"!=typeof Uint8Array?Uint8Array:Array,e._configure=function(){var t=e.Buffer;t?(e._Buffer_from=t.from!==Uint8Array.from&&t.from||function(e,r){return new t(e,r)},e._Buffer_allocUnsafe=t.allocUnsafe||function(e){return new t(e)}):e._Buffer_from=e._Buffer_allocUnsafe=null}}(d);var A=k;function k(t,e){\"string\"==typeof t&&(e=t,t=void 0);var r=[];function i(t){if(\"string\"!=typeof t){var e=n();if(k.verbose&&console.log(\"codegen: \"+e),e=\"return \"+e,t){for(var s=Object.keys(t),o=new Array(s.length+1),a=new Array(s.length),l=0;l=e)return!0;return!1},P.isReservedName=function(t,e){if(t)for(var r=0;r-1)return i}else if(i instanceof P&&(i=i.lookup(t.slice(1),e,!0)))return i}else for(var n=0;n-1&&this.oneof.splice(e,1),t.partOf=null,this},H.prototype.onAdd=function(t){V.prototype.onAdd.call(this,t);for(var e=0;e \"+t.len)}function ct(t){this.buf=t,this.pos=0,this.len=t.length}var yt,vt=\"undefined\"!=typeof Uint8Array?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new ct(t);throw Error(\"illegal buffer\")}:function(t){if(Array.isArray(t))return new ct(t);throw Error(\"illegal buffer\")};function mt(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}ct.create=ut.Buffer?function(t){return(ct.create=function(t){return ut.Buffer.isBuffer(t)?new(void 0)(t):vt(t)})(t)}:vt,ct.prototype._slice=ut.Array.prototype.subarray||ut.Array.prototype.slice,ct.prototype.uint32=(yt=4294967295,function(){if(yt=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return yt;if(yt=(yt|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return yt;if(yt=(yt|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return yt;if(yt=(yt|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return yt;if(yt=(yt|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return yt;if((this.pos+=5)>this.len)throw this.pos=this.len,dt(this,10);return yt}),ct.prototype.int32=function(){return 0|this.uint32()},ct.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(1&t)|0},ct.prototype.bool=function(){return 0!==this.uint32()},ct.prototype.fixed32=function(){if(this.pos+4>this.len)throw dt(this,4);return mt(this.buf,this.pos+=4)},ct.prototype.sfixed32=function(){if(this.pos+4>this.len)throw dt(this,4);return 0|mt(this.buf,this.pos+=4)},ct.prototype.float=function(){if(this.pos+4>this.len)throw dt(this,4);var t=ut.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t},ct.prototype.double=function(){if(this.pos+8>this.len)throw dt(this,4);var t=ut.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t},ct.prototype.bytes=function(){var t=this.uint32(),e=this.pos,r=this.pos+t;if(r>this.len)throw dt(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(e,r):e===r?new this.buf.constructor(0):this._slice.call(this.buf,e,r)},ct.prototype.string=function(){var t=this.bytes();return pt.read(t,0,t.length)},ct.prototype.skip=function(t){if(\"number\"==typeof t){if(this.pos+t>this.len)throw dt(this,t);this.pos+=t}else do{if(this.pos>=this.len)throw dt(this)}while(128&this.buf[this.pos++]);return this},ct.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(t=7&this.uint32());)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(\"invalid wire type \"+t+\" at offset \"+this.pos)}return this};var gt=function(t){var e=At.codegen([\"r\",\"l\"],t.name+\"$decode\")(\"if(!(r instanceof Reader))\")(\"r=Reader.create(r)\")(\"var c=l===undefined?r.len:r.pos+l,m=new this.ctor\"+(t.fieldsArray.filter((function(t){return t.map})).length?\",k\":\"\"))(\"while(r.pos>>3){\");for(var r=0;rd&&(d=t[f]),t[f]>=1;for(u=n<<16|f,h=a;h>>=1){case 0:var r=this.input,s=this.a,l=this.c,f=this.b,h=r.length,u=t,d=l.length,c=t;if(this.d=this.f=0,s+1>=h)throw Error(\"invalid uncompressed block header: LEN\");if(u=r[s++]|r[s++]<<8,s+1>=h)throw Error(\"invalid uncompressed block header: NLEN\");if(u===~(r[s++]|r[s++]<<8))throw Error(\"invalid uncompressed block header: length verify\");if(s+u>r.length)throw Error(\"input buffer is broken\");switch(this.i){case o:for(;f+u>l.length;){if(u-=c=d-f,i)l.set(r.subarray(s,s+c),f),f+=c,s+=c;else for(;c--;)l[f++]=r[s++];this.b=f,l=this.e(),f=this.b}break;case a:for(;f+u>l.length;)l=this.e({p:2});break;default:throw Error(\"invalid inflate mode\")}if(i)l.set(r.subarray(s,s+u),f),f+=u,s+=u;else for(;u--;)l[f++]=r[s++];this.a=s,this.b=f,this.c=l;break;case 1:this.j(O,x);break;case 2:var y,v,m,g,b=_(this,5)+257,w=_(this,5)+1,A=_(this,4)+4,k=new(i?Uint8Array:Array)(p.length),E=t,S=t,T=t,N=t,j=t;for(j=0;j=f?8:255>=f?9:279>=f?7:8;var k,E,O=n(A),S=new(i?Uint8Array:Array)(30);for(k=0,E=S.length;k=a)throw Error(\"input buffer is broken\");i|=s[o++]<>>e,t.d=n-e,t.a=o,r}function I(t,e){for(var r,i,n=t.f,s=t.d,o=t.input,a=t.a,l=o.length,f=e[0],h=e[1];s=l);)n|=o[a++]<>>16)>s)throw Error(\"invalid code length: \"+i);return t.f=n>>i,t.d=s-i,t.a=a,65535&r}function T(t,e){var r,i;switch(this.input=t,this.a=0,!e&&(e={})||(e.index&&(this.a=e.index),e.verify&&(this.A=e.verify)),r=t[this.a++],i=t[this.a++],15&r){case N:this.method=N;break;default:throw Error(\"unsupported compression method\")}if(0!=((r<<8)+i)%31)throw Error(\"invalid fcheck flag:\"+((r<<8)+i)%31);if(32&i)throw Error(\"fdict flag is not supported\");this.q=new s(t,{index:this.a,bufferSize:e.bufferSize,bufferType:e.bufferType,resize:e.resize})}s.prototype.j=function(t,e){var r=this.c,i=this.b;this.o=t;for(var n,s,o,a,l=r.length-258;256!==(n=I(this,t));)if(256>n)i>=l&&(this.b=i,r=this.e(),i=this.b),r[i++]=n;else for(a=c[s=n-257],0=l&&(this.b=i,r=this.e(),i=this.b);a--;)r[i]=r[i++-o];for(;8<=this.d;)this.d-=8,this.a--;this.b=i},s.prototype.w=function(t,e){var r=this.c,i=this.b;this.o=t;for(var n,s,o,a,l=r.length;256!==(n=I(this,t));)if(256>n)i>=l&&(l=(r=this.e()).length),r[i++]=n;else for(a=c[s=n-257],0l&&(l=(r=this.e()).length);a--;)r[i]=r[i++-o];for(;8<=this.d;)this.d-=8,this.a--;this.b=i},s.prototype.e=function(){var t,e,r=new(i?Uint8Array:Array)(this.b-32768),n=this.b-32768,s=this.c;if(i)r.set(s.subarray(32768,r.length));else for(t=0,e=r.length;tt;++t)s[t]=s[n+t];return this.b=32768,s},s.prototype.z=function(t){var e,r,n,s=this.input.length/this.a+1|0,o=this.input,a=this.c;return t&&(\"number\"==typeof t.p&&(s=t.p),\"number\"==typeof t.u&&(s+=t.u)),2>s?r=(n=(o.length-this.a)/this.o[2]/2*258|0)e&&(this.c.length=e),t=this.c),this.buffer=t},T.prototype.k=function(){var t,e,r=this.input;if(t=this.q.k(),this.a=this.q.a,this.A){e=(r[this.a++]<<24|r[this.a++]<<16|r[this.a++]<<8|r[this.a++])>>>0;var i=t;if(\"string\"==typeof i){var n,s,o=i.split(\"\");for(n=0,s=o.length;n>>0;i=o}for(var a,l=1,f=0,h=i.length,u=0;0>>0)throw Error(\"invalid adler-32 checksum\")}return t};var N=8;r(\"Zlib.Inflate\",T),r(\"Zlib.Inflate.prototype.decompress\",T.prototype.k);var j,B,D,L,R={ADAPTIVE:l.s,BLOCK:l.t};if(Object.keys)j=Object.keys(R);else for(B in j=[],D=0,R)j[D++]=B;for(D=0,L=j.length;D0&&c.push(d.lineDashI),null!==d.lineDashII&&d.lineDashII>0&&(c.length<1&&c.push(0),c.push(d.lineDashII)),null!==d.lineDashIII&&d.lineDashIII>0&&(c.length<2&&(c.push(0),c.push(0)),c[2]=d.lineDashIII);var y=null;switch(d.lineCap){case 0:y=\"butt\";break;case 1:y=\"round\";break;case 2:y=\"square\"}var v=null;switch(d.lineJoin){case 2:v=\"bevel\";break;case 1:v=\"round\";break;case 0:v=\"miter\"}var m=null;null!==d.fill&&(m=\"rgba(\".concat(parseInt((255*d.fill.r).toString()),\", \").concat(parseInt((255*d.fill.g).toString()),\", \").concat(parseInt((255*d.fill.b).toString()),\", \").concat(parseInt((1*d.fill.a).toString()),\")\"));var g=null;null!==d.stroke&&(g=\"rgba(\".concat(parseInt((255*d.stroke.r).toString()),\", \").concat(parseInt((255*d.stroke.g).toString()),\", \").concat(parseInt((255*d.stroke.b).toString()),\", \").concat(parseInt((1*d.stroke.a).toString()),\")\"));var b={lineDash:c,fill:m,stroke:g,lineCap:y,lineJoin:v,strokeWidth:d.strokeWidth,miterLimit:d.miterLimit},w={a:null!==(r=null===(e=t.transform)||void 0===e?void 0:e.a)&&void 0!==r?r:1,b:null!==(n=null===(i=t.transform)||void 0===i?void 0:i.b)&&void 0!==n?n:0,c:null!==(o=null===(s=t.transform)||void 0===s?void 0:s.c)&&void 0!==o?o:0,d:null!==(l=null===(a=t.transform)||void 0===a?void 0:a.d)&&void 0!==l?l:1,tx:null!==(h=null===(f=t.transform)||void 0===f?void 0:f.tx)&&void 0!==h?h:0,ty:null!==(p=null===(u=t.transform)||void 0===u?void 0:u.ty)&&void 0!==p?p:0};0===t.type&&null!==t.shape?I.push({type:\"shape\",path:t.shape,styles:b,transform:w}):1===t.type&&null!==t.rect?I.push({type:\"rect\",path:t.rect,styles:b,transform:w}):2===t.type&&null!==t.ellipse&&I.push({type:\"ellipse\",path:t.ellipse,styles:b,transform:w})}})),void 0!==t.shapes[0]&&3===t.shapes[0].type&&void 0!==e?I=e:e=I;var T=x.a*S.x+x.c*S.y+x.tx,N=x.a*(S.x+S.width)+x.c*S.y+x.tx,j=x.a*S.x+x.c*(S.y+S.height)+x.tx,B=x.a*(S.x+S.width)+x.c*(S.y+S.height)+x.tx,D=x.b*S.x+x.d*S.y+x.ty,L=x.b*(S.x+S.width)+x.d*S.y+x.ty,R=x.b*S.x+x.d*(S.y+S.height)+x.ty,U=x.b*(S.x+S.width)+x.d*(S.y+S.height)+x.ty,J=Math.min(Math.min(j,B),Math.min(T,N)),C=Math.min(Math.min(R,U),Math.min(D,L)),F=_.length>0?{d:_,transform:void 0,styles:{fill:\"rgba(0, 0, 0, 0)\",stroke:null,strokeWidth:null,lineCap:null,lineJoin:null,miterLimit:null,lineDash:null}}:null;i.frames.push({alpha:null!==(O=t.alpha)&&void 0!==O?O:0,layout:S,transform:x,clipPath:_,shapes:I,nx:J,ny:C,maskPath:F})})),r.sprites.push(i)})),this.images=e},Jt=function(t){var e=new Uint8Array(t,0,4);return 80===e[0]&&75===e[1]&&3===e[2]&&4===e[3]?1:2};\n/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */var Ct,Ft=Lt.Root.fromJSON({nested:{com:{nested:{opensource:{nested:{svga:{options:{objc_class_prefix:\"SVGAProto\",java_package:\"com.opensource.svgaplayer\"},nested:{MovieParams:{fields:{viewBoxWidth:{type:\"float\",id:1},viewBoxHeight:{type:\"float\",id:2},fps:{type:\"int32\",id:3},frames:{type:\"int32\",id:4}}},SpriteEntity:{fields:{imageKey:{type:\"string\",id:1},frames:{rule:\"repeated\",type:\"FrameEntity\",id:2}}},Layout:{fields:{x:{type:\"float\",id:1},y:{type:\"float\",id:2},width:{type:\"float\",id:3},height:{type:\"float\",id:4}}},Transform:{fields:{a:{type:\"float\",id:1},b:{type:\"float\",id:2},c:{type:\"float\",id:3},d:{type:\"float\",id:4},tx:{type:\"float\",id:5},ty:{type:\"float\",id:6}}},ShapeEntity:{oneofs:{args:{oneof:[\"shape\",\"rect\",\"ellipse\"]}},fields:{type:{type:\"ShapeType\",id:1},shape:{type:\"ShapeArgs\",id:2},rect:{type:\"RectArgs\",id:3},ellipse:{type:\"EllipseArgs\",id:4},styles:{type:\"ShapeStyle\",id:10},transform:{type:\"Transform\",id:11}},nested:{ShapeType:{values:{SHAPE:0,RECT:1,ELLIPSE:2,KEEP:3}},ShapeArgs:{fields:{d:{type:\"string\",id:1}}},RectArgs:{fields:{x:{type:\"float\",id:1},y:{type:\"float\",id:2},width:{type:\"float\",id:3},height:{type:\"float\",id:4},cornerRadius:{type:\"float\",id:5}}},EllipseArgs:{fields:{x:{type:\"float\",id:1},y:{type:\"float\",id:2},radiusX:{type:\"float\",id:3},radiusY:{type:\"float\",id:4}}},ShapeStyle:{fields:{fill:{type:\"RGBAColor\",id:1},stroke:{type:\"RGBAColor\",id:2},strokeWidth:{type:\"float\",id:3},lineCap:{type:\"LineCap\",id:4},lineJoin:{type:\"LineJoin\",id:5},miterLimit:{type:\"float\",id:6},lineDashI:{type:\"float\",id:7},lineDashII:{type:\"float\",id:8},lineDashIII:{type:\"float\",id:9}},nested:{RGBAColor:{fields:{r:{type:\"float\",id:1},g:{type:\"float\",id:2},b:{type:\"float\",id:3},a:{type:\"float\",id:4}}},LineCap:{values:{LineCap_BUTT:0,LineCap_ROUND:1,LineCap_SQUARE:2}},LineJoin:{values:{LineJoin_MITER:0,LineJoin_ROUND:1,LineJoin_BEVEL:2}}}}}},FrameEntity:{fields:{alpha:{type:\"float\",id:1},layout:{type:\"Layout\",id:2},transform:{type:\"Transform\",id:3},clipPath:{type:\"string\",id:4},shapes:{rule:\"repeated\",type:\"ShapeEntity\",id:5}}},MovieEntity:{fields:{version:{type:\"string\",id:1},params:{type:\"MovieParams\",id:2},images:{keyType:\"string\",type:\"bytes\",id:3},sprites:{rule:\"repeated\",type:\"SpriteEntity\",id:4}}}}}}}}}}}).lookupType(\"com.opensource.svga.MovieEntity\");function Mt(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){var i=new XMLHttpRequest;i.open(\"GET\",r,!0),i.responseType=\"arraybuffer\",i.onloadend=function(){void 0===i.response||200!==i.status&&304!==i.status?e(new Error(\"XMLHttpRequest, \".concat(i.statusText))):t(i.response)},i.send()}))];case 1:return[2,t.sent()]}}))}))}function Pt(r){return t(this,void 0,void 0,(function(){var t,i,n,s,o,a,l,f,h,u,p,d,c,y,v,m,g,b,w;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,7,,8]),t=r.data,i=t.url,n=t.options,[4,Mt(i)];case 1:if(s=e.sent(),o=new Uint8Array(s,0,4),2!==Jt(o))throw new Error(\"this parser only support version@2 of SVGA.\");for(p in a=new Rt.Inflate(new Uint8Array(s)).decompress(),l=Ft.decode(a),f={},h=l.images,u=[],h)u.push(p);d=0,e.label=2;case 2:return d=this.loopStart+(this.duration-this.loopStart)*this.loop?(this.currentFrication=1===this.fillRule?0:1,this.isRunning=!1):this.currentFrication=e<=this.duration?e/this.duration:((e-this.loopStart)%(this.duration-this.loopStart)+this.loopStart)/this.duration,this.onUpdate(this.animatedValue),this.isRunning||(null!==this.worker&&(this.worker.terminate(),this.worker=null),this.onEnd())},e}(),validMethods="MLHVCSQRZmlhvcsqrz";function render(e,t,r,i,n,o){var a=e.getContext("2d");if(null===a)throw new Error("Render Context cannot be null");if(!("save"in a))throw new Error("Render Context is not context2d");n.sprites.forEach((function(e){var n=t[e.imageKey],s=i[e.imageKey],u=r[e.imageKey];drawSprite(a,e,o,n,s,u)}))}function drawSprite(e,t,r,i,n,o){var a,s,u,l,c,h,d,f,m,v,p,y,b=t.frames[r];b.alpha<.05||(e.save(),e.globalAlpha=b.alpha,e.transform(null!==(s=null===(a=b.transform)||void 0===a?void 0:a.a)&&void 0!==s?s:1,null!==(l=null===(u=b.transform)||void 0===u?void 0:u.b)&&void 0!==l?l:0,null!==(h=null===(c=b.transform)||void 0===c?void 0:c.c)&&void 0!==h?h:0,null!==(f=null===(d=b.transform)||void 0===d?void 0:d.d)&&void 0!==f?f:1,null!==(v=null===(m=b.transform)||void 0===m?void 0:m.tx)&&void 0!==v?v:0,null!==(y=null===(p=b.transform)||void 0===p?void 0:p.ty)&&void 0!==y?y:0),void 0!==i&&(null!==b.maskPath&&(drawBezier(e,b.maskPath.d,b.maskPath.transform,b.maskPath.styles),e.clip()),void 0!==n?e.drawImage(n,0,0,b.layout.width,b.layout.height):e.drawImage(i,0,0,b.layout.width,b.layout.height)),void 0!==o&&e.drawImage(o,(b.layout.width-o.width)/2,(b.layout.height-o.height)/2),b.shapes.forEach((function(t){return drawShape(e,t)})),e.restore())}function drawShape(e,t){var r,i,n,o,a,s,u,l,c;switch(t.type){case"shape":drawBezier(e,t.path.d,t.transform,t.styles);break;case"ellipse":drawEllipse(e,null!==(r=t.path.x)&&void 0!==r?r:0,null!==(i=t.path.y)&&void 0!==i?i:0,null!==(n=t.path.radiusX)&&void 0!==n?n:0,null!==(o=t.path.radiusY)&&void 0!==o?o:0,t.transform,t.styles);break;case"rect":drawRect(e,null!==(a=t.path.x)&&void 0!==a?a:0,null!==(s=t.path.y)&&void 0!==s?s:0,null!==(u=t.path.width)&&void 0!==u?u:0,null!==(l=t.path.height)&&void 0!==l?l:0,null!==(c=t.path.cornerRadius)&&void 0!==c?c:0,t.transform,t.styles)}}function resetShapeStyles(e,t){void 0!==t&&(null!==t.stroke?e.strokeStyle=t.stroke:e.strokeStyle="transparent",null!==t.strokeWidth&&t.strokeWidth>0&&(e.lineWidth=t.strokeWidth),null!==t.miterLimit&&t.miterLimit>0&&(e.miterLimit=t.miterLimit),null!==t.lineCap&&(e.lineCap=t.lineCap),null!==t.lineJoin&&(e.lineJoin=t.lineJoin),null!==t.fill?e.fillStyle=t.fill:e.fillStyle="transparent",null!==t.lineDash&&e.setLineDash(t.lineDash))}function drawBezier(e,t,r,i){e.save(),resetShapeStyles(e,i),void 0!==r&&e.transform(r.a,r.b,r.c,r.d,r.tx,r.ty);var n={x:0,y:0,x1:0,y1:0,x2:0,y2:0};e.beginPath(),(t=t.replace(/([a-zA-Z])/g,"|||$1 ").replace(/,/g," ")).split("|||").forEach((function(t){if(0!==t.length){var r=t.substr(0,1);if(validMethods.includes(r)){var i=t.substr(1).trim().split(" ");drawBezierElement(e,n,r,i)}}})),null!==i.fill&&e.fill(),null!==i.stroke&&e.stroke(),e.restore()}function drawBezierElement(e,t,r,i){switch(r){case"M":t.x=Number(i[0]),t.y=Number(i[1]),e.moveTo(t.x,t.y);break;case"m":t.x+=Number(i[0]),t.y+=Number(i[1]),e.moveTo(t.x,t.y);break;case"L":t.x=Number(i[0]),t.y=Number(i[1]),e.lineTo(t.x,t.y);break;case"l":t.x+=Number(i[0]),t.y+=Number(i[1]),e.lineTo(t.x,t.y);break;case"H":t.x=Number(i[0]),e.lineTo(t.x,t.y);break;case"h":t.x+=Number(i[0]),e.lineTo(t.x,t.y);break;case"V":t.y=Number(i[0]),e.lineTo(t.x,t.y);break;case"v":t.y+=Number(i[0]),e.lineTo(t.x,t.y);break;case"C":t.x1=Number(i[0]),t.y1=Number(i[1]),t.x2=Number(i[2]),t.y2=Number(i[3]),t.x=Number(i[4]),t.y=Number(i[5]),e.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"c":t.x1=t.x+Number(i[0]),t.y1=t.y+Number(i[1]),t.x2=t.x+Number(i[2]),t.y2=t.y+Number(i[3]),t.x+=Number(i[4]),t.y+=Number(i[5]),e.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y);break;case"S":void 0!==t.x1&&void 0!==t.y1&&void 0!==t.x2&&void 0!==t.y2?(t.x1=t.x-t.x2+t.x,t.y1=t.y-t.y2+t.y,t.x2=Number(i[0]),t.y2=Number(i[1]),t.x=Number(i[2]),t.y=Number(i[3]),e.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y)):(t.x1=Number(i[0]),t.y1=Number(i[1]),t.x=Number(i[2]),t.y=Number(i[3]),e.quadraticCurveTo(t.x1,t.y1,t.x,t.y));break;case"s":void 0!==t.x1&&void 0!==t.y1&&void 0!==t.x2&&void 0!==t.y2?(t.x1=t.x-t.x2+t.x,t.y1=t.y-t.y2+t.y,t.x2=t.x+Number(i[0]),t.y2=t.y+Number(i[1]),t.x+=Number(i[2]),t.y+=Number(i[3]),e.bezierCurveTo(t.x1,t.y1,t.x2,t.y2,t.x,t.y)):(t.x1=t.x+Number(i[0]),t.y1=t.y+Number(i[1]),t.x+=Number(i[2]),t.y+=Number(i[3]),e.quadraticCurveTo(t.x1,t.y1,t.x,t.y));break;case"Q":t.x1=Number(i[0]),t.y1=Number(i[1]),t.x=Number(i[2]),t.y=Number(i[3]),e.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"q":t.x1=t.x+Number(i[0]),t.y1=t.y+Number(i[1]),t.x+=Number(i[2]),t.y+=Number(i[3]),e.quadraticCurveTo(t.x1,t.y1,t.x,t.y);break;case"A":case"a":break;case"Z":case"z":e.closePath()}}function drawEllipse(e,t,r,i,n,o,a){e.save(),resetShapeStyles(e,a),void 0!==o&&e.transform(o.a,o.b,o.c,o.d,o.tx,o.ty);var s=2*i,u=2*n,l=s/2*.5522848,c=u/2*.5522848,h=(t-=i)+s,d=(r-=n)+u,f=t+s/2,m=r+u/2;e.beginPath(),e.moveTo(t,m),e.bezierCurveTo(t,m-c,f-l,r,f,r),e.bezierCurveTo(f+l,r,h,m-c,h,m),e.bezierCurveTo(h,m+c,f+l,d,f,d),e.bezierCurveTo(f-l,d,t,m+c,t,m),null!==a.fill&&e.fill(),null!==a.stroke&&e.stroke(),e.restore()}function drawRect(e,t,r,i,n,o,a,s){e.save(),resetShapeStyles(e,s),void 0!==a&&e.transform(a.a,a.b,a.c,a.d,a.tx,a.ty);var u=o;i<2*u&&(u=i/2),n<2*u&&(u=n/2),e.beginPath(),e.moveTo(t+u,r),e.arcTo(t+i,r,t+i,r+n,u),e.arcTo(t+i,r+n,t,r+n,u),e.arcTo(t,r+n,t,r,u),e.arcTo(t,r,t+i,r,u),e.closePath(),null!==s.fill&&e.fill(),null!==s.stroke&&e.stroke(),e.restore()}var inBrowser="undefined"!=typeof window,hasIntersectionObserver=inBrowser&&"IntersectionObserver"in window,Player=function(){function e(e){var t,r=this;this.currentFrame=0,this.totalFrames=0,this.videoEntity=void 0,this.config={container:document.createElement("canvas"),loop:0,fillMode:"forwards",playMode:"forwards",startFrame:0,endFrame:0,loopStartFrame:0,isCacheFrames:!1,isUseIntersectionObserver:!1,isOpenNoExecutionDelay:!1},this.isBeIntersection=!0,this.intersectionObserver=null,this.bitmapsCache={},this.cacheFrames={},this.animator=new Animator,this.animator.onEnd=function(){void 0!==r.onEnd&&r.onEnd()},e instanceof HTMLCanvasElement?t=e:void 0!==e.container&&(t=e.container,this.setConfig(e)),this.config.container=null!=t?t:this.config.container,this.ofsCanvas=void 0!==window.OffscreenCanvas?new window.OffscreenCanvas(this.config.container.width,this.config.container.height):document.createElement("canvas")}return e.prototype.setConfig=function(e){var t,r,i,n,o,a,s,u,l,c,h;if(void 0!==e.startFrame&&void 0!==e.endFrame&&e.startFrame>e.endFrame)throw new Error("StartFrame should > EndFrame");this.config.container=null!==(t=e.container)&&void 0!==t?t:this.config.container,this.config.loop=null!==(r=e.loop)&&void 0!==r?r:0,this.config.fillMode=null!==(i=e.fillMode)&&void 0!==i?i:"forwards",this.config.playMode=null!==(n=e.playMode)&&void 0!==n?n:"forwards",this.config.startFrame=null!==(o=e.startFrame)&&void 0!==o?o:0,this.config.endFrame=null!==(a=e.endFrame)&&void 0!==a?a:0,this.config.loopStartFrame=null!==(s=e.loopStartFrame)&&void 0!==s?s:0,this.config.isCacheFrames=null!==(u=e.isCacheFrames)&&void 0!==u&&u,this.config.isUseIntersectionObserver=null!==(l=e.isUseIntersectionObserver)&&void 0!==l&&l,this.config.isOpenNoExecutionDelay=null!==(c=e.isOpenNoExecutionDelay)&&void 0!==c&&c,this.animator.isOpenNoExecutionDelay=null!==(h=e.isOpenNoExecutionDelay)&&void 0!==h&&h,this.setIntersectionObserver()},e.prototype.setIntersectionObserver=function(){var e=this;hasIntersectionObserver&&this.config.isUseIntersectionObserver?(this.intersectionObserver=new IntersectionObserver((function(t){e.isBeIntersection=!(t[0].intersectionRatio<=0)}),{rootMargin:"0px",threshold:[0,.5,1]}),this.intersectionObserver.observe(this.config.container)):(null!==this.intersectionObserver&&this.intersectionObserver.disconnect(),this.config.isUseIntersectionObserver=!1,this.isBeIntersection=!0)},e.prototype.mount=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(r,i){if(t.currentFrame=0,t.totalFrames=e.frames-1,t.videoEntity=e,t.clearContainer(),t.setSize(),t.bitmapsCache={},void 0!==t.videoEntity)if(0!==Object.keys(t.videoEntity.images).length){var n=0,o=0;for(var a in t.videoEntity.images){var s=t.videoEntity.images[a];if("string"==typeof s){n++;var u=document.createElement("img");u.src="data:image/png;base64,"+s,t.bitmapsCache[a]=u,u.onload=function(){++o===n&&r()}}else t.bitmapsCache[a]=s,n++,++o===n&&r()}}else r();else r()}))];case 1:return[2,r.sent()]}}))}))},e.prototype.clearContainer=function(){var e=this.config.container.width;this.config.container.width=e},e.prototype.start=function(){if(void 0===this.videoEntity)throw new Error("videoEntity undefined");this.clearContainer(),this.startAnimation(),void 0!==this.onStart&&this.onStart()},e.prototype.resume=function(){this.startAnimation(),void 0!==this.onResume&&this.onResume()},e.prototype.pause=function(){this.animator.stop(),void 0!==this.onPause&&this.onPause()},e.prototype.stop=function(){this.animator.stop(),this.currentFrame=0,this.clearContainer(),void 0!==this.onStop&&this.onStop()},e.prototype.clear=function(){this.clearContainer()},e.prototype.destroy=function(){this.animator.stop(),this.clearContainer(),this.animator=null,this.videoEntity=null},e.prototype.startAnimation=function(){var e=this;if(void 0===this.videoEntity)throw new Error("videoEntity undefined");var t=this.config,r=this.totalFrames,i=this.videoEntity,n=t.playMode,o=t.startFrame,a=t.endFrame,s=t.loopStartFrame,u=t.fillMode,l=t.loop;this.currentFrame===r&&(this.currentFrame=o>0?o:0),"forwards"===n?(this.animator.startValue=o>0?o:0,this.animator.endValue=a>0?a:r):(this.animator.startValue=a>0?a:r,this.animator.endValue=o>0?o:0);var c=i.frames;a>0&&a>o?c=a-o:a<=0&&o>0&&(c=i.frames-o),this.animator.duration=c*(1/i.fps)*1e3,this.animator.loopStart=s>o?(s-o)*(1/i.fps)*1e3:0,this.animator.loop=!0===l||l<=0?1/0:!1===l?1:l,this.animator.fillRule="backwards"===u?1:0,this.animator.onUpdate=function(t){e.currentFrame!==t&&(e.currentFrame=t,e.drawFrame(e.currentFrame),void 0!==e.onProcess&&e.onProcess())},this.animator.start()},e.prototype.setSize=function(){if(void 0===this.videoEntity)throw new Error("videoEntity undefined");var e=this.videoEntity.size;this.config.container.width=e.width,this.config.container.height=e.height},e.prototype.drawFrame=function(e){if(void 0===this.videoEntity)throw new Error("Player VideoEntity undefined");if(!this.config.isUseIntersectionObserver||this.isBeIntersection){this.clearContainer();var t=this.config.container.getContext("2d");if(null===t)throw new Error("Canvas Context cannot be null");if(this.config.isCacheFrames&&void 0!==this.cacheFrames[e]){var r=this.cacheFrames[e];t.drawImage(r,0,0,r.width,r.height,0,0,r.width,r.height)}else{var i=this.ofsCanvas;if(void 0!==window.OffscreenCanvas&&window.navigator.userAgent.includes("Firefox")&&(i=new window.OffscreenCanvas(this.config.container.width,this.config.container.height)),i.width=this.config.container.width,i.height=this.config.container.height,render(i,this.bitmapsCache,this.videoEntity.dynamicElements,this.videoEntity.replaceElements,this.videoEntity,this.currentFrame),t.drawImage(i,0,0,i.width,i.height,0,0,i.width,i.height),this.config.isCacheFrames)if("toDataURL"in i){var n=i.toDataURL(),o=new Image;o.src=n,this.cacheFrames[e]=o}else this.cacheFrames[e]=i.transferToImageBitmap()}}},e}(),DB=function(){function e(e){var t=void 0===e?{name:"SVGA.DB",version:1,storeName:"files"}:e,r=t.name,i=t.version,n=t.storeName;this.storeName=n,this.dbPromise=new Promise((function(e,t){if(void 0===window.indexedDB)throw new Error("[SVGA.DB] indexedDB not supported");var o=window.indexedDB.open(r,i);o.onerror=function(e){return t(new Error("[SVGA.DB] indexedDB open fail, ".concat(e.type)))},o.onsuccess=function(){return e(o.result)},o.onupgradeneeded=function(){o.result.createObjectStore(n)}}))}return e.prototype.find=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.dbPromise.then((function(r){return __awaiter(t,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){switch(i.label){case 0:return[4,new Promise((function(i,n){var o=r.transaction([t.storeName],"readonly").objectStore(t.storeName).get(e);o.onsuccess=function(){"string"==typeof o.result?i(JSON.parse(o.result)):i(void 0)},o.onerror=function(){return n(new Error("find error"))}}))];case 1:return[2,i.sent()]}}))}))}))];case 1:return[2,r.sent()]}}))}))},e.prototype.insert=function(e,t){return __awaiter(this,void 0,void 0,(function(){var r=this;return __generator(this,(function(i){switch(i.label){case 0:return[4,this.dbPromise.then((function(i){return __awaiter(r,void 0,void 0,(function(){var r=this;return __generator(this,(function(n){switch(n.label){case 0:return[4,new Promise((function(n,o){var a=i.transaction([r.storeName],"readwrite"),s=a.objectStore(r.storeName).put(JSON.stringify(t),e);a.oncomplete=function(){return n()},s.onerror=function(){return o(new Error("insert error"))}}))];case 1:return[2,n.sent()]}}))}))}))];case 1:return[2,i.sent()]}}))}))},e.prototype.delete=function(e){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.dbPromise.then((function(r){return __awaiter(t,void 0,void 0,(function(){var t=this;return __generator(this,(function(i){switch(i.label){case 0:return[4,new Promise((function(i,n){var o=r.transaction([t.storeName],"readwrite").objectStore(t.storeName).delete(e);o.onsuccess=function(){return i()},o.onerror=function(){return n(new Error("delete error"))}}))];case 1:return[2,i.sent()]}}))}))}))];case 1:return[2,r.sent()]}}))}))},e}();exports.DB=DB,exports.Parser=Parser,exports.Player=Player,Object.defineProperty(exports,"__esModule",{value:!0})}));