/*!! * flipnote.js v6.3.0 * https://flipnote.js.org * A JavaScript library for Flipnote Studio animation files * 2018 - 2025 James Daniel * Flipnote Studio is (c) Nintendo Co., Ltd. This project isn't affiliated with or endorsed by them in any way. */ !function(i){var r,n,a,o,h,l;function c(i,r,n,a){var o,h=arguments.length,l=h<3?r:null===a?a=Object.getOwnPropertyDescriptor(r,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(i,r,n,a);else for(var c=i.length-1;c>=0;c--)(o=i[c])&&(l=(h<3?o(l):h>3?o(r,n,l):o(r,n))||l);return h>3&&l&&Object.defineProperty(r,n,l),l}function d(i,r,n,a){if("a"===n&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?i!==r||!a:!r.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?a:"a"===n?a.call(i):a?a.value:r.get(i)}function u(i,r,n,a,o){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?i!==r||!o:!r.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?o.call(i,n):o?o.value=n:r.set(i,n),n}i.FlipnoteRegion=void 0,(r=i.FlipnoteRegion||(i.FlipnoteRegion={})).EUR="EUR",r.USA="USA",r.JPN="JPN",r.UNKNOWN="UNKNOWN",i.FlipnoteFormat=void 0,(n=i.FlipnoteFormat||(i.FlipnoteFormat={})).PPM="PPM",n.KWZ="KWZ",i.FlipnoteThumbImageFormat=void 0,(a=i.FlipnoteThumbImageFormat||(i.FlipnoteThumbImageFormat={}))[a.Jpeg=0]="Jpeg",a[a.Rgba=1]="Rgba",i.FlipnoteStereoscopicEye=void 0,(o=i.FlipnoteStereoscopicEye||(i.FlipnoteStereoscopicEye={}))[o.Left=0]="Left",o[o.Right=1]="Right",i.FlipnoteAudioTrack=void 0,(h=i.FlipnoteAudioTrack||(i.FlipnoteAudioTrack={}))[h.BGM=0]="BGM",h[h.SE1=1]="SE1",h[h.SE2=2]="SE2",h[h.SE3=3]="SE3",h[h.SE4=4]="SE4",i.FlipnoteSoundEffectTrack=void 0,(l=i.FlipnoteSoundEffectTrack||(i.FlipnoteSoundEffectTrack={}))[l.SE1=1]="SE1",l[l.SE2=2]="SE2",l[l.SE3=3]="SE3",l[l.SE4=4]="SE4","function"==typeof SuppressedError&&SuppressedError;class ByteArray{constructor(){this.pageSize=4096,this.allocSize=0,this.realSize=0,this.pages=[],this.numPages=0,this.pageIdx=0,this.pagePtr=0,this.realPtr=0,this.newPage()}set pointer(i){this.setPointer(i)}get pointer(){return this.realPtr}newPage(){this.pages[this.numPages]=new Uint8Array(this.pageSize),this.numPages=this.pages.length,this.allocSize=this.numPages*this.pageSize}setPointer(i){for(;i>=this.allocSize;)this.newPage();i>this.realSize&&(this.realSize=i),this.pageIdx=Math.floor(i/this.pageSize),this.pagePtr=i%this.pageSize,this.realPtr=i}writeByte(i){this.pages[this.pageIdx][this.pagePtr]=i,this.setPointer(this.realPtr+1)}writeBytes(i,r,n){for(let a=n||i.length,o=r||0;o>>0&255),this.writeByte(i>>>8&255)}writeU32(i){this.writeByte(i>>>0&255),this.writeByte(i>>>8&255),this.writeByte(i>>>16&255),this.writeByte(i>>>24&255)}getBytes(){const i=new Uint8Array(this.realSize),r=this.numPages;for(let n=0;n{let n=[];for(let r=0;rthis.writeUint8(i)))}readHex(i,r=!1){const n=this.readBytes(i);return f(n,r)}readChar(){const i=this.readUint8();return String.fromCharCode(i)}readWideChar(){const i=this.readUint16();return String.fromCharCode(i)}readChars(i){const r=this.readBytes(i);let n="";for(let i=0;i=this.data.byteLength}}const p=(i,r,n)=>in?n:i,m=(i,r,n)=>i+n*(r-i);function g(i,r="Assert failed"){i||v(r)}const y=(i,r,n,a="")=>g(i>=r&&i<=n,`flipnote.js error: ${a||"value"} ${i} should be between ${r} and ${n}`),v=(i="Assert failed")=>{throw new Error("flipnote.js error: "+i)},w=()=>A?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},_="undefined"!=typeof window&&void 0!==window.document,P=()=>g(_,"This feature is only available in browser environments"),A="undefined"!=typeof process&&null!=process.versions&&null!=process.versions.node,E="object"==typeof self&&self.constructor&&"DedicatedWorkerGlobalScope"===self.constructor.name,C=_&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame);var F;!function(){if(!_)return function(){};document.createElement("a")}();class BaseParser extends DataStream{constructor(){super(...arguments),this[F]="Flipnote",this.titleFormats={COMMENT:"Comment by $USERNAME",FLIPNOTE:"Flipnote by $USERNAME",ICON:"Folder icon"},this.soundMeta=new Map,this.layerVisibility={1:!0,2:!0,3:!0},this.isFolderIcon=!1,this.isComment=!1,this.isDsiLibraryNote=!1}getTitle(i=this.titleFormats){return this.isFolderIcon?i.ICON:(this.isComment?i.COMMENT:i.FLIPNOTE).replace("$USERNAME",this.meta.current.username)}toString(){return this.getTitle()}*[(F=Symbol.toStringTag,Symbol.iterator)](){for(let i=0;ir[h]=o<<24|a<<16|n<<8|i)),r}getSoundEffectFlagsForTrack(i){return this.getSoundEffectFlags().map((r=>r[i]))}isSoundEffectUsedOnFrame(i,r){return y(r,0,this.frameCount-1,"Frame index"),!!this.soundEffectTracks.includes(i)&&this.getFrameSoundEffectFlags(r)[i]}hasAudioTrack(i){return this.soundMeta.has(i)&&this.soundMeta.get(i).length>0}}const x=/^[0159]{1}[0-9A-F]{6}0[0-9A-F]{8}$/,T=["01FACA7A4367FC5F","03D6E959E2F9A42D","03F80445160587FA","04068426E1008915","092A3EC8199FD5D5","0B8D56BA1BD441B8","0E61C75C9B5AD90B","14E494E35A443235"],U=i=>x.test(i)||T.includes(i),$=r=>{switch(r.charAt(0)){case"0":case"1":return i.FlipnoteRegion.JPN;case"5":return i.FlipnoteRegion.USA;case"9":return i.FlipnoteRegion.EUR;default:return i.FlipnoteRegion.UNKNOWN}},B=new Int8Array([-1,2,-1,2]),z=new Int8Array([-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8]),W=new Int16Array([7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767,0]),N=(i,r,n)=>n<0||n>=r?0:i[n],D=i=>{const r=i.length;let n=0;for(let a=0;a=32767)&&(n+=1)}return n/r},O=i=>{const r=i.length;let n=0;for(let a=0;anew Date(1e3*(i+K)),j=i=>Math.floor(i.getTime()/1e3-K),q=(i,r)=>100*i*(1/r)/100,Y=(()=>{if(_||E){const i=w();return(i.crypto||i.msCrypto).subtle}if(A)return((i,r)=>{try{return i.require(r)}catch{throw new Error(`Could not require(${r})`)}})(module,"crypto").webcrypto.subtle})(),X="RSASSA-PKCS1-v1_5",Z=async(i,r)=>{const n=i.split("\n").filter((i=>!i.startsWith("-----")&&!i.endsWith("-----"))).join(""),a=atob(n),o=new Uint8Array(a.length).map(((i,r)=>a.charCodeAt(r)));return await Y.importKey("spki",o.buffer,{name:X,hash:r},!1,["verify"])},Q=async(i,r,n)=>await Y.verify(X,i,r,n);var J,tt,et,it,st,rt,nt,at,ot,ht,lt,ct,dt,ut,ft,pt,mt,gt;const yt=[.5,.5,1,2,4,6,12,20,30],vt={WHITE:[255,255,255,255],BLACK:[14,14,14,255],RED:[255,42,42,255],BLUE:[10,57,255,255]},wt=[4294967295,4283585106,4294967295,4288453788,4282665215,4283388360,4289506815,4278255360,4294918216,4290269009,4294945709,4278255360,4290205622,4278255360,4278255360,4278255360],bt="-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCPLwTL6oSflv+gjywi/sM0TUB\n90xqOvuCpjduETjPoN2FwMebxNjdKIqHUyDu4AvrQ6BDJc6gKUbZ1E27BGZoCPH4\n9zQRb+zAM6M9EjHwQ6BABr0u2TcF7xGg2uQ9MBWz9AfbVQ91NjfrNWo0f7UPmffv\n1VvixmTk1BCtavZxBwIDAQAB\n-----END PUBLIC KEY-----";class PpmParser extends BaseParser{static matchBuffer(i){const r=new Uint8Array(i.slice(0,4));return 1346458177==(r[0]<<24|r[1]<<16|r[2]<<8|r[3])}constructor(r,n={}){super(r),J.add(this),this.format=i.FlipnoteFormat.PPM,this[gt]="Flipnote Studio PPM animation file",this.imageWidth=PpmParser.width,this.imageHeight=PpmParser.height,this.aspect=PpmParser.aspect,this.imageOffsetX=0,this.imageOffsetY=0,this.numLayers=PpmParser.numLayers,this.numLayerColors=PpmParser.numLayerColors,this.publicKey=PpmParser.publicKey,this.srcWidth=PpmParser.width,this.audioTracks=PpmParser.audioTracks,this.soundEffectTracks=PpmParser.soundEffectTracks,this.rawSampleRate=PpmParser.rawSampleRate,this.sampleRate=PpmParser.sampleRate,this.globalPalette=PpmParser.globalPalette,tt.set(this,void 0),et.set(this,void 0),it.set(this,void 0),st.set(this,void 0),rt.set(this,null),nt.set(this,void 0),at.set(this,void 0),ot.set(this,void 0),ht.set(this,void 0),d(this,J,"m",lt).call(this),d(this,J,"m",ut).call(this),d(this,J,"m",ft).call(this),this.version>>4&15&&d(this,J,"m",dt).call(this),u(this,tt,[new Uint8Array(PpmParser.width*PpmParser.height),new Uint8Array(PpmParser.width*PpmParser.height)],"f"),u(this,it,[new Uint8Array(PpmParser.width*PpmParser.height),new Uint8Array(PpmParser.width*PpmParser.height)],"f"),u(this,st,[new Uint8Array(PpmParser.height),new Uint8Array(PpmParser.height)],"f"),u(this,rt,null,"f")}getThumbnailImage(){this.seek(160);const r=this.readBytes(1536),n=new Uint32Array(3072);for(let i=0;i<48;i+=8)for(let a=0;a<64;a+=8)for(let o=0;o<8;o+=1)for(let h=0;h<8;h+=2){const l=a+h,c=i+o;n[64*c+l]=wt[15&r[0]],n[64*c+l+1]=wt[r[0]<<4&15]}return{format:i.FlipnoteThumbImageFormat.Rgba,width:64,height:48,data:n.buffer}}getMemoryMeterLevel(){const i=d(this,nt,"f")/736800;return i<0?0:i}decodeFrame(i){if(y(i,0,this.frameCount-1,"Frame index"),d(this,rt,"f")===i)return d(this,tt,"f");d(this,rt,"f")===i-1||d(this,J,"m",pt).call(this,i)||0===i||this.decodeFrame(i-1),u(this,rt,i,"f"),this.seek(d(this,ht,"f")[i]);const r=this.readUint8(),n=r>>7&1,a=r>>5&3;d(this,tt,"f")[0].fill(0),d(this,tt,"f")[1].fill(0);let o=0,h=0;a&&(o=this.readInt8(),h=this.readInt8());for(let i=0;i<2;i++){const r=d(this,st,"f")[i];r.fill(0);for(let i=0;i>2&3,r[i++]=n>>4&3,r[i++]=n>>6&3):i+=4}}for(let i=0;i<2;i++){const r=d(this,tt,"f")[i],n=d(this,st,"f")[i];for(let i=0;i>=1)r[a+n]=1&i}break;case 2:for(r.fill(1,a,a+PpmParser.width),l=this.readUint32(!1);0!==l;l<<=1,a+=8)if(2147483648&l){let i=this.readUint8();for(let n=0;n<8;n++,i>>=1)r[a+n]=1&i}break;case 3:for(let i=0,n=0;n>=1}}}const c=d(this,tt,"f")[0],f=d(this,tt,"f")[1],p=d(this,it,"f")[0],m=d(this,it,"f")[1];if(n||0!==o||0!==h){if(!n){const i=PpmParser.width,r=PpmParser.height,n=Math.max(o,0),a=Math.max(h,0),l=Math.min(i+o,i),d=Math.min(r+h,r),u=h*i+o;let g,y;for(let r=a;r>1&3],a[r>>3&3]]}getFramePalette(i){return y(i,0,this.frameCount-1,"Frame index"),this.getFramePaletteIndices(i).map((i=>this.globalPalette[i]))}getIsKeyFrame(i){const r=1===d(this,J,"m",pt).call(this,i);return[r,r]}getFrameLayerDepths(i){return[0,0]}getFrameAuthor(i){return this.meta.current.fsid}getFrameCameraFlags(i){return[!1,!1]}getFrameLayerOrder(i){return[1,0]}decodeSoundFlags(){if(void 0!==d(this,et,"f"))return d(this,et,"f");g(1696+d(this,nt,"f")({[i.FlipnoteSoundEffectTrack.SE1]:r[0],[i.FlipnoteSoundEffectTrack.SE2]:r[1],[i.FlipnoteSoundEffectTrack.SE3]:r[2],[i.FlipnoteSoundEffectTrack.SE4]:!1})))}getFrameSoundEffectFlags(r){y(r,0,this.frameCount-1,"Frame index"),this.seek(1696+d(this,nt,"f")+r);const n=this.readUint8();return{[i.FlipnoteSoundEffectTrack.SE1]:!!(1&n),[i.FlipnoteSoundEffectTrack.SE2]:!!(2&n),[i.FlipnoteSoundEffectTrack.SE3]:!!(4&n),[i.FlipnoteSoundEffectTrack.SE4]:!1}}getAudioTrackDuration(r){const n=this.soundMeta.get(r);if(0===n.length)return 0;if(r===i.FlipnoteAudioTrack.BGM){const i=1/this.bgmrate/(1/this.framerate),r=this.rawSampleRate*i;return 2*(n.length-4)/r}return 2*(n.length-4)/this.sampleRate}getAudioTrackRaw(i){const r=this.soundMeta.get(i);return g(r.ptr+r.length>4,f=!f;const i=W[l];let r=i>>3;1&o&&(r+=i>>2),2&o&&(r+=i>>1),4&o&&(r+=i),8&o&&(r=-r),h+=r,h=p(h,-32768,32767),l+=z[o],l=p(l,0,88),u[a++]=h}return u}getAudioTrackPcm(r,n=this.sampleRate){const a=this.decodeAudioTrack(r);let o=this.rawSampleRate;if(r===i.FlipnoteAudioTrack.BGM){const i=1/this.bgmrate/(1/this.framerate);o=this.rawSampleRate*i}return o!==n?((i,r,n)=>{const a=i.length,o=a/r*n,h=new Int16Array(o),l=r/n;for(let r=0;r>1&1),advancedTools:void 0,isSpinoff:this.isSpinoff,frameCount:this.frameCount,frameSpeed:this.frameSpeed,bgmSpeed:this.bgmSpeed,duration:this.duration,thumbIndex:r,timestamp:p,root:{username:n,fsid:f,region:$(f),filename:null},parent:{username:a,fsid:h,region:$(h),filename:c},current:{username:o,fsid:l,region:$(l),filename:u}}},ut=function(){this.seek(1696);const i=this.readUint16(),r=i/4;g(r<=this.frameCount),this.seek(1704);const n=new Uint32Array(r);for(let a=0;a>7&1},mt=function(i,r,n=0){const a=i.length,o=r.length;for(let h=0;ho);h++){const a=r[n+h]+i[h]/2;r[n+h]=p(a,-32768,32767)}},PpmParser.defaultSettings={},PpmParser.format=i.FlipnoteFormat.PPM,PpmParser.width=256,PpmParser.height=192,PpmParser.aspect=3/4,PpmParser.numLayers=2,PpmParser.numLayerColors=1,PpmParser.rawSampleRate=8180,PpmParser.sampleRate=32768,PpmParser.audioTracks=[i.FlipnoteAudioTrack.BGM,i.FlipnoteAudioTrack.SE1,i.FlipnoteAudioTrack.SE2,i.FlipnoteAudioTrack.SE3],PpmParser.soundEffectTracks=[i.FlipnoteSoundEffectTrack.SE1,i.FlipnoteSoundEffectTrack.SE2,i.FlipnoteSoundEffectTrack.SE3],PpmParser.globalPalette=[vt.WHITE,vt.BLACK,vt.RED,vt.BLUE],PpmParser.publicKey=bt;const St=/^[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{6}$/,_t=/^(00|10|12|14)[0-9a-f]{2}-[0-9a-f]{4}-[0-9a-f]{3}0-[0-9a-f]{4}[0159]{1}[0-9a-f]{1}$/,Pt=["5f-fc67-437a-cafa01","2d-a4f9-e259-e9d603","fa-8705-1645-04f803","15-8900-e126-840604","d5-d59f-19c8-3e2a09","b8-41d4-1bba-568d0b","0b-d95a-9b5c-c7610e","35-3244-5ae3-94e414"],At=i=>St.test(i),Et=i=>{if(_t.test(i))return!0;for(let r of Pt)if(i.endsWith(r))return!0;return!1},Ct=r=>{if(Et(r))switch(r.charAt(19)){case"0":case"1":return i.FlipnoteRegion.JPN;case"5":return i.FlipnoteRegion.USA;case"9":return i.FlipnoteRegion.EUR;default:return i.FlipnoteRegion.UNKNOWN}return i.FlipnoteRegion.UNKNOWN},Ft=i=>`${i.slice(0,4)}-${i.slice(4,8)}-${i.slice(8,12)}-${i.slice(12,18)}`.toLowerCase(),kt=i=>i.replace(/-/g,"").toUpperCase();var xt,Tt,Ut,Mt,$t,Bt,Lt,It,zt,Wt,Rt,Nt,Dt,Ot,Ht,Kt,Vt,Gt,jt,qt,Yt,Xt;const Zt=[.2,.5,1,2,4,6,8,12,20,24,30],Qt={WHITE:[255,255,255,255],BLACK:[16,16,16,255],RED:[255,16,16,255],YELLOW:[255,231,0,255],GREEN:[0,134,49,255],BLUE:[0,56,206,255],NONE:[255,255,255,0]},Jt="-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuv+zHAXXvbbtRqxADDeJ\nArX2b9RMxj3T+qpRg3FnIE/jeU3tj7eoDzsMduY+D/UT9CSnP+QHYY/vf0n5lqX9\ns6ljoZAmyUuruyj1e5Bg+fkDEu/yPEPQjqhbyywCyYL4TEAOJveopUBx9fdQxUJ6\nJ4J5oCE/Im1kFrlGW+puARiHmt3mmUyNzO8bI/Jx3cGSfoOHJG1foEaQsI5aaKqA\npBqxtzvwqMhudcZtAWSyRMBMlndvkRnVTDNTfTXLOYdHShCIgnKULCTH87uLBIP/\nnsmr4/bnQz8q2rp/HyVO+0yjR6mVr0NX5APJQ+6riJmGg3t3VOldhKP7aTHDUW+h\nkQIDAQAB\n-----END PUBLIC KEY-----",te=new Uint16Array(16);for(let i=0;i<16;i++)te[i]=(1<{const n=8*i,a=ee.subarray(n,n+8),o=ie.subarray(n,n+8);re.set(a,8*r),ne.set(o,8*r)}));class KwzParser extends BaseParser{static matchBuffer(i){const r=new Uint8Array(i.slice(0,4)),n=r[0]<<24|r[1]<<16|r[2]<<8;return 1262897152===n||1263092480===n}constructor(r,n={}){super(r),xt.add(this),this.format=i.FlipnoteFormat.KWZ,this[Xt]="Flipnote Studio 3D KWZ animation file",this.imageWidth=KwzParser.width,this.imageHeight=KwzParser.height,this.aspect=KwzParser.aspect,this.imageOffsetX=0,this.imageOffsetY=0,this.numLayers=KwzParser.numLayers,this.numLayerColors=KwzParser.numLayerColors,this.publicKey=KwzParser.publicKey,this.srcWidth=KwzParser.width,this.audioTracks=KwzParser.audioTracks,this.soundEffectTracks=KwzParser.soundEffectTracks,this.rawSampleRate=KwzParser.rawSampleRate,this.sampleRate=KwzParser.sampleRate,this.globalPalette=KwzParser.globalPalette,Tt.set(this,void 0),Ut.set(this,void 0),Mt.set(this,void 0),$t.set(this,void 0),Bt.set(this,void 0),Lt.set(this,null),It.set(this,void 0),zt.set(this,void 0),Wt.set(this,void 0),Rt.set(this,void 0),Nt.set(this,0),Dt.set(this,0),u(this,Tt,{...KwzParser.defaultSettings,...n},"f"),u(this,$t,[new Uint8Array(KwzParser.width*KwzParser.height),new Uint8Array(KwzParser.width*KwzParser.height),new Uint8Array(KwzParser.width*KwzParser.height)],"f"),d(this,xt,"m",Ot).call(this),d(this,Ut,"f").has("KIC")?(this.isFolderIcon=!0,this.imageWidth=24,this.imageHeight=24,this.frameCount=1,this.frameSpeed=0,this.framerate=Zt[0],this.thumbFrameIndex=0,d(this,xt,"m",qt).call(this)):d(this,Ut,"f").has("KSN")?(d(this,xt,"m",Gt).call(this),d(this,xt,"m",qt).call(this),d(this,xt,"m",Yt).call(this)):(this.isComment=!0,d(this,xt,"m",Gt).call(this),d(this,xt,"m",qt).call(this)),d(this,Tt,"f").dsiLibraryNote&&(this.isDsiLibraryNote=!0),d(this,Tt,"f").borderCrop&&(this.isDsiLibraryNote?(this.imageOffsetX=32,this.imageOffsetY=24,this.imageWidth=256,this.imageHeight=192):this.isFolderIcon||(this.imageOffsetX=5,this.imageOffsetY=5,this.imageWidth=310,this.imageHeight=230))}getThumbnailImage(){g(d(this,Ut,"f").has("KTN"),"KTN section missing - Note that folder icons and comments do not contain thumbnail data");const r=d(this,Ut,"f").get("KTN");this.seek(r.ptr+12);const n=this.readBytes(r.length-12);return{format:i.FlipnoteThumbImageFormat.Jpeg,width:80,height:64,data:n.buffer}}getMemoryMeterLevel(){g(d(this,Ut,"f").has("KMI")&&d(this,Ut,"f").has("KMC"));const i=this.rawSampleRate/2,r=60*i+2*i*4;return(d(this,Rt,"f")+57600)/(4219447-(r+39&4294967292))}getFramePaletteIndices(i){y(i,0,this.frameCount-1,"Frame index"),this.seek(d(this,It,"f")[i]);const r=this.readUint32();return[15&r,r>>8&15,r>>12&15,r>>16&15,r>>20&15,r>>24&15,r>>28&15]}getFramePalette(i){return y(i,0,this.frameCount-1,"Frame index"),this.getFramePaletteIndices(i).map((i=>this.globalPalette[i]))}getFrameDiffingFlag(i){return y(i,0,this.frameCount-1,"Frame index"),this.seek(d(this,It,"f")[i]),this.readUint32()>>4&7}getIsKeyFrame(i){const r=this.getFrameDiffingFlag(i);return[!(1&r),!(2&r),!(4&r)]}getFrameLayerDepths(i){return y(i,0,this.frameCount-1,"Frame index"),this.seek(d(this,It,"f")[i]+20),[this.readUint8(),this.readUint8(),this.readUint8()]}getFrameAuthor(i){return y(i,0,this.frameCount-1,"Frame index"),this.seek(d(this,It,"f")[i]+10),d(this,xt,"m",Kt).call(this)}getFrameCameraFlags(i){this.seek(d(this,It,"f")[i]+26);const r=this.readUint8();return[!!(1&r),!!(2&r),!!(4&r)]}getFrameLayerOrder(i){y(i,0,this.frameCount-1,"Frame index");const r=this.getFrameLayerDepths(i);return[2,1,0].sort(((i,n)=>r[n]-r[i]))}decodeFrame(i,r=7,n=!1){if(y(i,0,this.frameCount-1,"Frame index"),d(this,Lt,"f")===i)return d(this,$t,"f");d(this,Lt,"f")!==i-1&&0!==i&&(n&&(r&=~this.getFrameDiffingFlag(i+1)),0!==r&&this.decodeFrame(i-1,r,!0));let a=d(this,zt,"f")[i];const o=d(this,Wt,"f")[i];for(let i=0;i<3&&(!d(this,Tt,"f").dsiLibraryNote||3!==i);i++){this.seek(a);let n=o[i];a+=n;const h=d(this,$t,"f")[i];if(38===n)continue;if(!(r>>i&1))continue;u(this,Nt,16,"f"),u(this,Dt,0,"f");let l=0;for(let i=0;i<240;i+=128)for(let r=0;r<320;r+=128)for(let n=0;n<128;n+=8){const a=i+n;if(a>=240)break;for(let i=0;i<128;i+=8){const n=r+i;if(n>=320)break;if(l>0){l-=1;continue}let o=a*KwzParser.width+n;const c=d(this,xt,"m",Ht).call(this,3);if(0===c){const i=8*d(this,xt,"m",Ht).call(this,5),r=re.subarray(i,i+8);h.set(r,o),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320)}else if(1===c){const i=8*d(this,xt,"m",Ht).call(this,13),r=ee.subarray(i,i+8);h.set(r,o),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(r,o+=320)}else if(2===c){const i=8*d(this,xt,"m",Ht).call(this,5),r=re.subarray(i,i+8),n=ne.subarray(i,i+8);h.set(r,o),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320)}else if(3===c){const i=8*d(this,xt,"m",Ht).call(this,13),r=ee.subarray(i,i+8),n=ie.subarray(i,i+8);h.set(r,o),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320),h.set(r,o+=320),h.set(n,o+=320)}else if(4===c){const i=d(this,xt,"m",Ht).call(this,8);for(let r=1;r<255;r<<=1){if(i&r){const i=8*d(this,xt,"m",Ht).call(this,5),r=re.subarray(i,i+8);h.set(r,o)}else{const i=8*d(this,xt,"m",Ht).call(this,13),r=ee.subarray(i,i+8);h.set(r,o)}o+=320}}else{if(5===c){l=d(this,xt,"m",Ht).call(this,5);continue}if(7===c){let i,r,n=d(this,xt,"m",Ht).call(this,2);if(0!==d(this,xt,"m",Ht).call(this,1)){const a=8*d(this,xt,"m",Ht).call(this,5),o=8*d(this,xt,"m",Ht).call(this,5);i=re.subarray(a,a+8),r=re.subarray(o,o+8),n+=1}else{const n=8*d(this,xt,"m",Ht).call(this,13),a=8*d(this,xt,"m",Ht).call(this,13);i=ee.subarray(n,n+8),r=ee.subarray(a,a+8)}switch(n%4){case 0:h.set(i,o),h.set(r,o+=320),h.set(i,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(r,o+=320);break;case 1:h.set(i,o),h.set(i,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(i,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(i,o+=320);break;case 2:h.set(i,o),h.set(r,o+=320),h.set(i,o+=320),h.set(i,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(i,o+=320),h.set(r,o+=320);break;case 3:h.set(i,o),h.set(r,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(r,o+=320),h.set(r,o+=320),h.set(i,o+=320),h.set(r,o+=320)}}}}}}return u(this,Lt,i,"f"),d(this,$t,"f")}decodeFrameSoundFlags(i){y(i,0,this.frameCount-1,"Frame index"),this.seek(d(this,It,"f")[i]+23);const r=this.readUint8();return[!!(1&r),!!(2&r),!!(4&r),!!(8&r)]}decodeSoundFlags(){return void 0!==d(this,Bt,"f")||u(this,Bt,new Array(this.frameCount).fill(!1).map(((i,r)=>this.decodeFrameSoundFlags(r))),"f"),d(this,Bt,"f")}getSoundEffectFlags(){return this.decodeSoundFlags().map((r=>({[i.FlipnoteSoundEffectTrack.SE1]:r[0],[i.FlipnoteSoundEffectTrack.SE2]:r[1],[i.FlipnoteSoundEffectTrack.SE3]:r[2],[i.FlipnoteSoundEffectTrack.SE4]:r[3]})))}getFrameSoundEffectFlags(r){const n=this.decodeFrameSoundFlags(r);return{[i.FlipnoteSoundEffectTrack.SE1]:n[0],[i.FlipnoteSoundEffectTrack.SE2]:n[1],[i.FlipnoteSoundEffectTrack.SE3]:n[2],[i.FlipnoteSoundEffectTrack.SE4]:n[3]}}getAudioTrackDuration(r){if(0===this.soundMeta.get(r).length)return 0;const n=this.decodeAudioTrack(r);if(r===i.FlipnoteAudioTrack.BGM){const i=1/this.bgmrate/(1/this.framerate),r=this.rawSampleRate*i;return n.length/r}return n.length/this.sampleRate}getAudioTrackRaw(i){const r=this.soundMeta.get(i);return g(r.ptr+r.length4?(l=3&o,c=W[a],d=c>>3,1&l&&(d+=c),2&l&&(d=-d),n+=d,a+=B[l],o>>=2,f+=2):(l=15&o,c=W[a],d=c>>3,1&l&&(d+=c>>2),2&l&&(d+=c>>1),4&l&&(d+=c),8&l&&(d=-d),n+=d,a+=z[l],o>>=4,f+=4),a=p(a,0,79),n=p(n,-2048,2047),r[h]=16*n,h+=1}return h}decodeAudioTrack(r){const n=d(this,Tt,"f"),a=this.getAudioTrackRaw(r),o=60*this.rawSampleRate,h=new Int16Array(o);let l=0,c=40;if(this.isDsiLibraryNote)if(r===i.FlipnoteAudioTrack.BGM){let i=!0;if(null!==n.initialBgmPredictor&&(l=n.initialBgmPredictor,i=!1),null!==n.initialBgmStepIndex&&(c=n.initialBgmStepIndex,i=!1),i&&n.guessInitialBgmState){let i=4294967295,r=0;for(c=0;c<=40;c++){const n=this.decodeAdpcm(a,h,l,c),o=O(h.subarray(0,n));o{const a=i.length,o=a/r*n,h=new Int16Array(o),l=r/n;for(let r=0,n=0,c=0,d=0;ro);h++){const a=r[n+h]+i[h];r[n+h]=p(a,-32768,32767)}}getAudioMasterPcm(r=this.sampleRate){const n=Math.ceil(this.duration*r),a=new Int16Array(n),o=this.hasAudioTrack(i.FlipnoteAudioTrack.BGM),h=this.hasAudioTrack(i.FlipnoteAudioTrack.SE1),l=this.hasAudioTrack(i.FlipnoteAudioTrack.SE2),c=this.hasAudioTrack(i.FlipnoteAudioTrack.SE3),d=this.hasAudioTrack(i.FlipnoteAudioTrack.SE4);if(o){const n=this.getAudioTrackPcm(i.FlipnoteAudioTrack.BGM,r);this.pcmAudioMix(n,a,0)}if(h||l||c||d){const n=r/this.framerate,o=h?this.getAudioTrackPcm(i.FlipnoteAudioTrack.SE1,r):null,u=l?this.getAudioTrackPcm(i.FlipnoteAudioTrack.SE2,r):null,f=c?this.getAudioTrackPcm(i.FlipnoteAudioTrack.SE3,r):null,p=d?this.getAudioTrackPcm(i.FlipnoteAudioTrack.SE4,r):null,m=this.decodeSoundFlags();for(let i=0;i16){const i=this.readUint16();u(this,Dt,d(this,Dt,"f")|i<<16-d(this,Nt,"f"),"f"),u(this,Nt,d(this,Nt,"f")-16,"f")}const r=d(this,Dt,"f")&te[i];return u(this,Dt,d(this,Dt,"f")>>i,"f"),u(this,Nt,d(this,Nt,"f")+i,"f"),r},Kt=function(){return d(this,Tt,"f").dsiLibraryNote?this.readHex(10,!0).slice(2,18):Ft(this.readHex(10))},Vt=function(){const i=this.pointer,r=this.readChars(28);if(28===r.length)return r;this.seek(i);const n=this.readHex(3),a=this.readChars(13),o=this.readUint16().toString().padStart(3,"0");return this.seek(i+28),`${n}_${a}_${o}`},Gt=function(){if(d(this,Tt,"f").quickMeta)return d(this,xt,"m",jt).call(this);g(d(this,Ut,"f").has("KFH")),this.seek(d(this,Ut,"f").get("KFH").ptr+12);const i=G(this.readUint32()),r=G(this.readUint32());this.readUint32();const n=d(this,xt,"m",Kt).call(this),a=d(this,xt,"m",Kt).call(this),o=d(this,xt,"m",Kt).call(this),h=this.readWideChars(11),l=this.readWideChars(11),c=this.readWideChars(11),u=d(this,xt,"m",Vt).call(this),f=d(this,xt,"m",Vt).call(this),p=d(this,xt,"m",Vt).call(this),m=this.readUint16(),y=this.readUint16(),v=this.readUint16(),w=this.readUint8(),_=this.readUint8();this.isSpinoff=o!==a||o!==n,this.frameCount=m,this.frameSpeed=w,this.framerate=Zt[w],this.duration=q(this.frameCount,this.framerate),this.thumbFrameIndex=y,this.layerVisibility={1:!(1&_),2:!(2&_),3:!(3&_)},this.meta={lock:!!(1&v),loop:!!(2&v),advancedTools:!!(4&v),isSpinoff:this.isSpinoff,frameCount:m,frameSpeed:w,duration:this.duration,thumbIndex:y,timestamp:r,creationTimestamp:i,root:{username:h,fsid:n,region:Ct(n),filename:u,isDsiFilename:28!==u.length},parent:{username:l,fsid:a,region:Ct(a),filename:f,isDsiFilename:28!==f.length},current:{username:c,fsid:o,region:Ct(o),filename:p,isDsiFilename:28!==p.length}}},jt=function(){g(d(this,Ut,"f").has("KFH")),this.seek(d(this,Ut,"f").get("KFH").ptr+8+196);const i=this.readUint16(),r=this.readUint16();this.readUint16();const n=this.readUint8(),a=this.readUint8();this.frameCount=i,this.thumbFrameIndex=r,this.frameSpeed=n,this.framerate=Zt[n],this.duration=q(this.frameCount,this.framerate),this.layerVisibility={1:!(1&a),2:!(2&a),3:!(3&a)}},qt=function(){g(d(this,Ut,"f").has("KMI")&&d(this,Ut,"f").has("KMC"));const i=this.frameCount,r=d(this,Ut,"f").get("KMI"),n=d(this,Ut,"f").get("KMC");g(r.length/28>=i);const a=new Uint32Array(i),o=new Uint32Array(i),h=[];let l=r.ptr+8,c=n.ptr+12,f=0;for(let r=0;rU(i)?`${i.slice(14,16)}-${i.slice(12,14)}${i.slice(10,12)}-${i.slice(8,10)}${i.slice(6,8)}-${i.slice(4,6)}${i.slice(2,4)}${i.slice(0,2)}`.toLocaleLowerCase():null;var oe=Object.freeze({__proto__:null,getFsidRegion:r=>U(r)?$(r):At(r)?Ct(r):i.FlipnoteRegion.UNKNOWN,getKwzFsidRegion:Ct,getPpmFsidRegion:$,isFsid:i=>U(i)||At(i),isKwzDsiLibraryFsid:Et,isKwzFsid:At,isPpmFsid:U,kwzFsidFormat:Ft,kwzFsidToPpmFsid:i=>Et(i)?`${i.slice(19,21)}${i.slice(17,19)}${i.slice(15,17)}${i.slice(12,14)}${i.slice(10,12)}${i.slice(7,9)}${i.slice(5,7)}${i.slice(2,4)}`.toUpperCase():null,kwzFsidUnformat:kt,ppmFsidToKwzFsidSuffix:ae,ppmFsidToPossibleKwzFsids(i){const r=ae(i);return r?["00"+r,"10"+r,"12"+r,"14"+r]:null}});const he=/^[0-9A-Z]{1}[0-9A-F]{5}_[0-9A-F]{13}_[0-9]{3}$/,le=/^[0-9A-F]{6}_[0-9A-F]{13}_[0-9]{3}$/,ce=/^[0-5a-z]{28}$/,de="cwmfjordvegbalksnthpyxquiz012345";var ue=Object.freeze({__proto__:null,isKwzFilename:i=>ce.test(i),isPpmBasicFilename:i=>le.test(i),isPpmFilename:i=>he.test(i),kwzFilenameDecode(i){const r=(i=>{const r=i.length;let n=0;const a=new Uint8Array(5*r/8);let o=0,h=0;for(let l=0;l=8&&(a[o++]=h>>>n-8&255,n-=8);return a})(i),n=new DataView(r.buffer);return{fsid:Ft(f(r.slice(0,9))),created:G(n.getUint32(9,!0)),edited:G(n.getUint32(13,!0))}},kwzFilenameEncode(i){const r=new Uint8Array(17),n=new DataView(r.buffer),a=kt(i.fsid);return r.set(((i,r=!1)=>{const n=i.length,a=new Uint8Array(n/2);for(let r=0,o=0;r{const r=i.byteLength;let n=0,a="",o=0;for(let h=0;h=5;)a+=de[o>>>n-5&31],n-=5;return n>0&&(a+=de[o<<5-n&31]),a})(r)},ppmFilenameCalculateCheckDigit(i){let r=parseInt(i.slice(0,2),16);for(let n=1;n<16;n++)r=r+i.charCodeAt(n)&255;return"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[r%36]},ppmFilenameDecode:i=>({macSuffix:i.slice(0,6),random1:i.slice(7,12),random2:i.slice(12,19),edits:parseInt(i.slice(-3))}),ppmFilenameEncode(i){const r=i.edits.toString().padEnd(3,"0");return`${i.macSuffix}_${i.random1}_${i.random2}_${r}`}});const fe=[247,76,106,58,251,130,166,55,110,17,56,207,160,221,133,192,199,155,196,216,221,40,138,135,83,32,238,224,11,235,67,160,219,85,15,117,54,55,235,53,106,52,127,181,15,153,247,239,67,37,206,160,41,70,217,212,77,187,4,102,104,8,241,248];class BasePlaylistParser extends DataStream{constructor(i){super(i),this.entries=[]}addEntry(i){const r=i.split("/"),n=r.at(-1),a=i.lastIndexOf(".");this.entries.push({full:i,name:n,base:i.slice(0,a),ext:i.slice(a+1),folder:r.at(-2),parentFolder:r.at(-3)})}}class PpmPlaylist extends BasePlaylistParser{constructor(r){super(r),this.format=i.FlipnoteFormat.PPM;const n=this.bytes,a=this.numBytes;for(let i=0;i=200&&r.status<300,`Failed to load Flipnote from URL, response failed with status ${r.status}`),await r.arrayBuffer()}},me={name:"file",matches(i){return _&&"undefined"!=typeof File&&"undefined"!=typeof FileReader&&i instanceof File},async load(i){return i.arrayBuffer()}},ge={name:"blob",matches(i){return _&&"undefined"!=typeof Blob&&"undefined"!=typeof Response&&i instanceof Blob},async load(i){return i.arrayBuffer()}},ye={name:"node-buffer",matches(i){return A&&i instanceof Buffer},async load(i){return i.buffer}},ve={name:"array-buffer",matches(i){return i instanceof ArrayBuffer},async load(i){return i}},we=new Map,be=i=>{for(let[r,n]of we)if(n.matches(i))try{return n.load(i)}catch(i){v(`Failed to load Flipnote from source, loader "${r}" failed with error ${v}`)}v("No loader available for source type")},Se=i=>{we.set(i.name,i)};Se(ve),Se(ye),Se(ge),Se(me),Se(pe);var _e=Object.freeze({__proto__:null,clear:()=>we.clear(),list:()=>Object.fromEntries(we.entries()),load:be,register:Se}),Pe=Object.freeze({__proto__:null,KwzPlaylist,PpmPlaylist,async parse(r,n){const a=await be(n);return r===i.FlipnoteFormat.PPM||"ppm"===r?new PpmPlaylist(a):r===i.FlipnoteFormat.KWZ||"kwz"===r?new KwzPlaylist(a):void 0}});const Ae=async(i,r)=>{const n=await be(i);return PpmParser.matchBuffer(n)?new PpmParser(n,r):KwzParser.matchBuffer(n)?new KwzParser(n,r):void v("Could not identify source as a valid Flipnote file")};var Ee;i.PlayerEvent=void 0,(Ee=i.PlayerEvent||(i.PlayerEvent={})).__Any="any",Ee.Play="play",Ee.Pause="pause",Ee.CanPlay="canplay",Ee.CanPlayThrough="canplaythrough",Ee.SeekStart="seeking",Ee.SeekEnd="seeked",Ee.Duration="durationchange",Ee.Loop="loop",Ee.Ended="ended",Ee.VolumeChange="volumechange",Ee.Progress="progress",Ee.TimeUpdate="timeupdate",Ee.FrameUpdate="frameupdate",Ee.FrameNext="framenext",Ee.FramePrev="frameprev",Ee.FrameFirst="framefirst",Ee.FrameLast="framelast",Ee.Ready="ready",Ee.Load="load",Ee.LoadStart="loadstart",Ee.LoadedData="loadeddata",Ee.LoadedMeta="loadedmetadata",Ee.Emptied="emptied",Ee.Close="close",Ee.Error="error",Ee.Destroy="destroy";const Ce=[i.PlayerEvent.Play,i.PlayerEvent.Pause,i.PlayerEvent.CanPlay,i.PlayerEvent.CanPlayThrough,i.PlayerEvent.SeekStart,i.PlayerEvent.SeekEnd,i.PlayerEvent.Duration,i.PlayerEvent.Loop,i.PlayerEvent.Ended,i.PlayerEvent.VolumeChange,i.PlayerEvent.Progress,i.PlayerEvent.TimeUpdate,i.PlayerEvent.FrameUpdate,i.PlayerEvent.FrameNext,i.PlayerEvent.FramePrev,i.PlayerEvent.FrameFirst,i.PlayerEvent.FrameLast,i.PlayerEvent.Ready,i.PlayerEvent.Load,i.PlayerEvent.LoadStart,i.PlayerEvent.LoadedData,i.PlayerEvent.LoadedMeta,i.PlayerEvent.Emptied,i.PlayerEvent.Close,i.PlayerEvent.Error],Fe=i=>({length:i.length,start:r=>i[r][0],end:r=>i[r][1]}),ke=(i,r)=>i.toString().padStart(r,"0"),xe=i=>{const r=Math.floor(i%3600/60),n=Math.floor(i%60);return`${r}:${ke(n,2)}`};var Te;i.CanvasStereoscopicMode=void 0,(Te=i.CanvasStereoscopicMode||(i.CanvasStereoscopicMode={}))[Te.None=0]="None",Te[Te.Dual=1]="Dual",Te[Te.Anaglyph=2]="Anaglyph";const Ue=5120,Me=5121,$e=5122,Be=5123,Le=5124,Ie=5125,ze=5126,We={};{const i=We;i[Ue]=Int8Array,i[Me]=Uint8Array,i[$e]=Int16Array,i[Be]=Uint16Array,i[Le]=Int32Array,i[Ie]=Uint32Array,i[ze]=Float32Array,i[32819]=Uint16Array,i[32820]=Uint16Array,i[33635]=Uint16Array,i[5131]=Uint16Array,i[33640]=Uint32Array,i[35899]=Uint32Array,i[35902]=Uint32Array,i[36269]=Uint32Array,i[34042]=Uint32Array}function Re(i){if(i instanceof Int8Array)return Ue;if(i instanceof Uint8Array)return Me;if(i instanceof Uint8ClampedArray)return Me;if(i instanceof Int16Array)return $e;if(i instanceof Uint16Array)return Be;if(i instanceof Int32Array)return Le;if(i instanceof Uint32Array)return Ie;if(i instanceof Float32Array)return ze;throw new Error("unsupported typed array type")}function Ne(i){if(i===Int8Array)return Ue;if(i===Uint8Array)return Me;if(i===Uint8ClampedArray)return Me;if(i===Int16Array)return $e;if(i===Uint16Array)return Be;if(i===Int32Array)return Le;if(i===Uint32Array)return Ie;if(i===Float32Array)return ze;throw new Error("unsupported typed array type")}const De="undefined"!=typeof SharedArrayBuffer?function(i){return i&&i.buffer&&(i.buffer instanceof ArrayBuffer||i.buffer instanceof SharedArrayBuffer)}:function(i){return i&&i.buffer&&i.buffer instanceof ArrayBuffer},Oe=new Map;function He(i,r){if(!i||"object"!=typeof i)return!1;let n=Oe.get(r);n||(n=new WeakMap,Oe.set(r,n));let a=n.get(i);if(void 0===a){const o=Object.prototype.toString.call(i);a=o.substring(8,o.length-1)===r,n.set(i,a)}return a}function Ke(i,r){return"undefined"!=typeof WebGLTexture&&He(r,"WebGLTexture")}const Ve=35044,Ge=34962,je=5126,qe="";function Ye(i,r,n,a){if(function(i,r){return"undefined"!=typeof WebGLBuffer&&He(r,"WebGLBuffer")}(0,r))return r;n=n||Ge;const o=i.createBuffer();return function(i,r,n,a,o){i.bindBuffer(r,n),i.bufferData(r,a,o||Ve)}(i,n,o,r,a),o}function Xe(i){return"indices"===i}const Ze=/coord|texture/i,Qe=/color|colour/i;function Je(i,r){if(De(i))return i;if(De(i.data))return i.data;Array.isArray(i)&&(i={data:i});let n=i.type?ti(i.type):void 0;return n||(n=Xe(r)?Uint16Array:Float32Array),new n(i.data)}function ti(i){return"number"==typeof i?function(i){const r=We[i];if(!r)throw new Error("unknown gl type");return r}(i):i||Float32Array}function ei(i,r){return{buffer:r.buffer,numValues:24,type:(n=r.type,"number"==typeof n?n:n?Ne(n):je),arrayType:ti(r.type)};var n}function ii(i,r){const n=r.data||r,a=ti(r.type),o=n*a.BYTES_PER_ELEMENT,h=i.createBuffer();return i.bindBuffer(Ge,h),i.bufferData(Ge,o,r.drawType||Ve),{buffer:h,numValues:n,type:Ne(a),arrayType:a}}function si(i,r,n){const a=Je(r,n);return{arrayType:a.constructor,buffer:Ye(i,a,void 0,r.drawType),type:Re(a),numValues:0}}function ri(i,r){const n={};return Object.keys(r).forEach((function(a){if(!Xe(a)){const h=r[a],l=h.attrib||h.name||h.attribName||qe+a;if(h.value){if(!Array.isArray(h.value)&&!De(h.value))throw new Error("array.value is not array or typedarray");n[l]={value:h.value}}else{let r;r=h.buffer&&h.buffer instanceof WebGLBuffer?ei:"number"==typeof h||"number"==typeof h.data?ii:si;const{buffer:c,type:d,numValues:u,arrayType:f}=r(i,h,a),p=void 0!==h.normalize?h.normalize:(o=f)===Int8Array||o===Uint8Array,m=function(i,r,n){return i.numComponents||i.size||function(i,r){let n;if(n=Ze.test(i)?2:Qe.test(i)?4:3,r%n>0)throw new Error(`Can not guess numComponents for attribute '${i}'. Tried ${n} but ${r} values is not evenly divisible by ${n}. You should specify it.`);return n}(r,n||function(i){return i.length?i:i.data}(i).length)}(h,a,u);n[l]={buffer:c,numComponents:m,type:d,normalize:p,stride:h.stride||0,offset:h.offset||0,divisor:void 0===h.divisor?void 0:h.divisor,drawType:h.drawType}}}var o})),i.bindBuffer(Ge,null),n}const ni=["position","positions","a_position"];function ai(i){return!!i.texStorage2D}const oi=33984,hi=34962,li=5124,ci=3553,di=34067,ui=32879,fi=35866,pi={};function mi(i,r){return pi[r].bindPoint}function gi(i,r){return function(n){i.uniform1i(r,n)}}function yi(i,r){return function(n){i.uniform1iv(r,n)}}function vi(i,r){return function(n){i.uniform2iv(r,n)}}function wi(i,r){return function(n){i.uniform3iv(r,n)}}function bi(i,r){return function(n){i.uniform4iv(r,n)}}function Si(i,r,n,a){const o=mi(0,r);return ai(i)?function(r){let h,l;!r||Ke(0,r)?(h=r,l=null):(h=r.texture,l=r.sampler),i.uniform1i(a,n),i.activeTexture(oi+n),i.bindTexture(o,h),i.bindSampler(n,l)}:function(r){i.uniform1i(a,n),i.activeTexture(oi+n),i.bindTexture(o,r)}}function _i(i,r,n,a,o){const h=mi(0,r),l=new Int32Array(o);for(let i=0;ifunction(n){i.uniform1f(r,n)},arraySetter:(i,r)=>function(n){i.uniform1fv(r,n)}},pi[35664]={Type:Float32Array,size:8,setter:(i,r)=>function(n){i.uniform2fv(r,n)},cols:2},pi[35665]={Type:Float32Array,size:12,setter:(i,r)=>function(n){i.uniform3fv(r,n)},cols:3},pi[35666]={Type:Float32Array,size:16,setter:(i,r)=>function(n){i.uniform4fv(r,n)},cols:4},pi[li]={Type:Int32Array,size:4,setter:gi,arraySetter:yi},pi[35667]={Type:Int32Array,size:8,setter:vi,cols:2},pi[35668]={Type:Int32Array,size:12,setter:wi,cols:3},pi[35669]={Type:Int32Array,size:16,setter:bi,cols:4},pi[5125]={Type:Uint32Array,size:4,setter:(i,r)=>function(n){i.uniform1ui(r,n)},arraySetter:(i,r)=>function(n){i.uniform1uiv(r,n)}},pi[36294]={Type:Uint32Array,size:8,setter:(i,r)=>function(n){i.uniform2uiv(r,n)},cols:2},pi[36295]={Type:Uint32Array,size:12,setter:(i,r)=>function(n){i.uniform3uiv(r,n)},cols:3},pi[36296]={Type:Uint32Array,size:16,setter:(i,r)=>function(n){i.uniform4uiv(r,n)},cols:4},pi[35670]={Type:Uint32Array,size:4,setter:gi,arraySetter:yi},pi[35671]={Type:Uint32Array,size:8,setter:vi,cols:2},pi[35672]={Type:Uint32Array,size:12,setter:wi,cols:3},pi[35673]={Type:Uint32Array,size:16,setter:bi,cols:4},pi[35674]={Type:Float32Array,size:32,setter:(i,r)=>function(n){i.uniformMatrix2fv(r,!1,n)},rows:2,cols:2},pi[35675]={Type:Float32Array,size:48,setter:(i,r)=>function(n){i.uniformMatrix3fv(r,!1,n)},rows:3,cols:3},pi[35676]={Type:Float32Array,size:64,setter:(i,r)=>function(n){i.uniformMatrix4fv(r,!1,n)},rows:4,cols:4},pi[35685]={Type:Float32Array,size:32,setter:(i,r)=>function(n){i.uniformMatrix2x3fv(r,!1,n)},rows:2,cols:3},pi[35686]={Type:Float32Array,size:32,setter:(i,r)=>function(n){i.uniformMatrix2x4fv(r,!1,n)},rows:2,cols:4},pi[35687]={Type:Float32Array,size:48,setter:(i,r)=>function(n){i.uniformMatrix3x2fv(r,!1,n)},rows:3,cols:2},pi[35688]={Type:Float32Array,size:48,setter:(i,r)=>function(n){i.uniformMatrix3x4fv(r,!1,n)},rows:3,cols:4},pi[35689]={Type:Float32Array,size:64,setter:(i,r)=>function(n){i.uniformMatrix4x2fv(r,!1,n)},rows:4,cols:2},pi[35690]={Type:Float32Array,size:64,setter:(i,r)=>function(n){i.uniformMatrix4x3fv(r,!1,n)},rows:4,cols:3},pi[35678]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ci},pi[35680]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:di},pi[35679]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ui},pi[35682]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ci},pi[36289]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:fi},pi[36292]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:fi},pi[36293]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:di},pi[36298]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ci},pi[36299]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ui},pi[36300]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:di},pi[36303]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:fi},pi[36306]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ci},pi[36307]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:ui},pi[36308]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:di},pi[36311]={Type:null,size:0,setter:Si,arraySetter:_i,bindPoint:fi};const Fi={};function ki(i){const r=i.name;return r.startsWith("gl_")||r.startsWith("webgl_")}Fi[5126]={size:4,setter:Pi},Fi[35664]={size:8,setter:Pi},Fi[35665]={size:12,setter:Pi},Fi[35666]={size:16,setter:Pi},Fi[li]={size:4,setter:Ai},Fi[35667]={size:8,setter:Ai},Fi[35668]={size:12,setter:Ai},Fi[35669]={size:16,setter:Ai},Fi[5125]={size:4,setter:Ei},Fi[36294]={size:8,setter:Ei},Fi[36295]={size:12,setter:Ei},Fi[36296]={size:16,setter:Ei},Fi[35670]={size:4,setter:Ai},Fi[35671]={size:8,setter:Ai},Fi[35672]={size:12,setter:Ai},Fi[35673]={size:16,setter:Ai},Fi[35674]={size:4,setter:Ci,count:2},Fi[35675]={size:9,setter:Ci,count:3},Fi[35676]={size:16,setter:Ci,count:4};const xi=/(\.|\[|]|\w+)/g,Ti=i=>i>="0"&&i<="9";function Ui(i,r,n,a){const o=i.split(xi).filter((i=>""!==i));let h=0,l="";for(;;){const i=o[h++];l+=i;const c=Ti(i[0]),d=c?parseInt(i):i;if(c&&(l+=o[h++]),h===o.length){n[d]=r;break}{const i=o[h++],r="["===i,c=n[d]||(r?[]:{});n[d]=c,n=c,a[l]=a[l]||function(i){return function(r){Mi(i,r)}}(c),l+=i}}}function Mi(i,r){for(const n in r){const a=i[n];"function"==typeof a?a(r[n]):Mi(i[n],r[n])}}function $i(i,...r){const n=i.uniformSetters||i,a=r.length;for(let i=0;i{this.destroy(),i&&i.preventDefault(),d(this,Xi,"f")||d(this,Li,"f").onlost(),u(this,Xi,!0,"f")})),ds.set(this,(i=>{u(this,Xi,!1,"f"),d(this,Bi,"m",Zi).call(this),d(this,Li,"f").onrestored()})),P(),u(this,Li,{...WebglCanvas.defaultOptions,...o},"f"),this.width=n,this.height=a,this.canvas=document.createElement("canvas"),this.canvas.addEventListener("webglcontextlost",d(this,cs,"f"),!1),this.canvas.addEventListener("webglcontextrestored",d(this,ds,"f"),!1),this.canvas.className="FlipnoteCanvas FlipnoteCanvas--webgl",this.gl=this.canvas.getContext("webgl",{antialias:!1,alpha:!0}),r&&r.appendChild(this.canvas),d(this,Bi,"m",Zi).call(this)}setCanvasSize(i,r){const n=d(this,Li,"f").useDpi&&window.devicePixelRatio||1,a=i*n,o=r*n;this.width=i,this.height=r,this.canvas.width=a,this.canvas.height=o,this.dstWidth=a,this.dstHeight=o,this.canvas.style.width=`${i}px`,this.canvas.style.height=`${r}px`,d(this,Bi,"m",ls).call(this)}setNote(i){if(d(this,Bi,"m",ls).call(this))return;const r=i.imageWidth,n=i.imageHeight;this.note=i,this.srcWidth=r,this.srcHeight=n,d(this,Bi,"m",hs).call(this,d(this,Ki,"f"),r,n),d(this,Bi,"m",ns).call(this,d(this,Ni,"f"),r,n),u(this,Di,new Uint32Array(r*n),"f"),u(this,Oi,new Uint8Array(d(this,Di,"f").buffer),"f"),this.frameIndex=void 0,this.canvas.title=i.getTitle()}clear(i){if(d(this,Bi,"m",ls).call(this))return;const r=this.gl,n=i??this.note.getFramePalette(this.frameIndex)[0],[a,o,h,l]=n;r.clearColor(a/255,o/255,h/255,l/255),r.clear(r.COLOR_BUFFER_BIT)}drawFrame(r){if(d(this,Bi,"m",ls).call(this))return;const n=this.gl,a=this.stereoscopeMode,o=this.stereoscopeStrength;this.frameIndex=r,a===i.CanvasStereoscopicMode.None?(d(this,Bi,"m",Qi).call(this,r),d(this,Bi,"m",os).call(this,null),d(this,Bi,"m",Ji).call(this,n.drawingBufferWidth,n.drawingBufferHeight)):a===i.CanvasStereoscopicMode.Dual&&(d(this,Bi,"m",Qi).call(this,r,o,i.FlipnoteStereoscopicEye.Left),d(this,Bi,"m",os).call(this,null,0,0,n.drawingBufferWidth/2,n.drawingBufferHeight),d(this,Bi,"m",Ji).call(this,n.drawingBufferWidth/2,n.drawingBufferHeight),d(this,Bi,"m",Qi).call(this,r,o,i.FlipnoteStereoscopicEye.Right),d(this,Bi,"m",os).call(this,null,n.drawingBufferWidth/2,0,n.drawingBufferWidth/2,n.drawingBufferHeight),d(this,Bi,"m",Ji).call(this,n.drawingBufferWidth/2,n.drawingBufferHeight))}requestStereoScopeMode(r){this.supportedStereoscopeModes.includes(r)?this.stereoscopeMode=r:this.stereoscopeMode=i.CanvasStereoscopicMode.None,this.forceUpdate()}forceUpdate(){void 0!==this.frameIndex&&this.drawFrame(this.frameIndex)}isErrorState(){const i=this.gl;return null===i||i.getError()!==i.NO_ERROR}getDataUrl(i,r){return this.canvas.toDataURL(i,r)}async getBlob(i,r){return new Promise(((n,a)=>this.canvas.toBlob(n,i,r)))}destroy(){const i=d(this,Yi,"f"),r=this.gl,n=this.canvas;i.shaders.forEach((i=>{r.deleteShader(i)})),i.shaders=[],i.textures.forEach((i=>{r.deleteTexture(i)})),i.textures=[],i.buffers.forEach((i=>{r.deleteBuffer(i)})),i.buffers=[],i.frameBuffers.forEach((i=>{r.deleteFramebuffer(i)})),i.frameBuffers=[],i.programs.forEach((i=>{r.deleteProgram(i)})),i.programs=[],u(this,Ri,null,"f"),u(this,Di,null,"f"),u(this,Oi,null,"f"),d(this,Vi,"f").clear(),d(this,Gi,"f").clear(),d(this,ji,"f").clear(),n&&n.parentElement&&(n.width=1,n.height=1,n.parentNode.removeChild(n))}}Li=new WeakMap,Ii=new WeakMap,zi=new WeakMap,Wi=new WeakMap,Ri=new WeakMap,Ni=new WeakMap,Di=new WeakMap,Oi=new WeakMap,Hi=new WeakMap,Ki=new WeakMap,Vi=new WeakMap,Gi=new WeakMap,ji=new WeakMap,qi=new WeakMap,Yi=new WeakMap,Xi=new WeakMap,cs=new WeakMap,ds=new WeakMap,Bi=new WeakSet,Zi=function(){this.setCanvasSize(this.width,this.height);const i=this.gl;if(d(this,Bi,"m",ls).call(this))return;u(this,Ii,d(this,Bi,"m",ts).call(this,"#define GLSLIFY 1\nattribute vec4 position;attribute vec2 texcoord;varying vec2 v_uv;uniform bool u_flipY;uniform vec2 u_textureSize;uniform int u_3d_eye;uniform float u_3d_depth;uniform float u_3d_strength;void main(){vec4 pos=position;float depthDirection=u_3d_eye==0 ?-1.0 : 1.0;float depthShift=floor(u_3d_depth*u_3d_strength)/(u_textureSize.x/2.0)*depthDirection;pos.x+=depthShift;pos.y*=u_flipY ?-1.0 : 1.0;v_uv=texcoord;gl_Position=pos;}","precision highp float;\n#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_tex;uniform int u_3d_mode;void main(){vec4 col=texture2D(u_tex,v_uv);if(col.a==0.0){discard;}gl_FragColor=col;}"),"f"),u(this,zi,d(this,Bi,"m",ts).call(this,"#define GLSLIFY 1\nattribute vec4 position;attribute vec2 texcoord;varying vec2 v_texel;varying vec2 v_uv;varying float v_scale;uniform bool u_flipY;uniform vec2 u_textureSize;uniform vec2 u_screenSize;void main(){v_uv=texcoord;v_scale=floor(u_screenSize.y/u_textureSize.y+0.01);gl_Position=position;if(u_flipY){gl_Position.y*=-1.;}}","precision highp float;\n#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_tex;varying float v_scale;uniform vec2 u_textureSize;uniform vec2 u_screenSize;void main(){vec2 v_texel=v_uv*u_textureSize;vec2 texel_floored=floor(v_texel);vec2 s=fract(v_texel);float region_range=0.5-0.5/v_scale;vec2 center_dist=s-0.5;vec2 f=(center_dist-clamp(center_dist,-region_range,region_range))*v_scale+0.5;vec2 mod_texel=texel_floored+f;vec2 coord=mod_texel.xy/u_textureSize.xy;gl_FragColor=texture2D(u_tex,coord);}"),"f"),u(this,Wi,d(this,Bi,"m",is).call(this,-1,-1,2,2,1,1),"f"),d(this,Bi,"m",ss).call(this,d(this,Ii,"f"),d(this,Wi,"f")),u(this,Ni,d(this,Bi,"m",rs).call(this,i.RGBA,i.LINEAR,i.CLAMP_TO_EDGE),"f"),u(this,Hi,d(this,Bi,"m",rs).call(this,i.RGBA,i.LINEAR,i.CLAMP_TO_EDGE),"f"),u(this,Ki,d(this,Bi,"m",as).call(this,d(this,Hi,"f")),"f");const r=i.getExtension("WEBGL_debug_renderer_info"),n=i.getParameter(r.UNMASKED_RENDERER_WEBGL),a=navigator.userAgent,o=a.includes("Firefox")&&a.includes("Mac");u(this,qi,o&&n.includes("Apple M"),"f")},Qi=function(r,n=0,a=i.FlipnoteStereoscopicEye.Left,o=!0){const h=this.gl,l=this.note,c=this.srcWidth,u=this.srcHeight,f=l.numLayers,p=l.getFrameLayerOrder(r),m=l.getFrameLayerDepths(r);d(this,Bi,"m",os).call(this,d(this,Ki,"f")),o&&this.clear(),h.useProgram(d(this,Ii,"f").program);for(let i=0;ithis.canvas.toBlob(n,i,r)))}destroy(){u(this,ms,null,"f"),u(this,gs,null,"f"),u(this,ys,null,"f"),this.canvas.parentNode.removeChild(this.canvas),this.canvas.width=1,this.canvas.height=1,this.canvas=null,d(this,fs,"f").width=1,d(this,fs,"f").height=1,u(this,fs,null,"f")}}us=new WeakMap,fs=new WeakMap,ps=new WeakMap,ms=new WeakMap,gs=new WeakMap,ys=new WeakMap,Html5Canvas.defaultOptions={useDpi:!0,useSmoothing:!0};class UniversalCanvas{constructor(r,n=640,a=480,o={}){vs.add(this),this.isReady=!1,this.isHtml5=!1,this.supportedStereoscopeModes=[],this.stereoscopeMode=i.CanvasStereoscopicMode.None,this.stereoscopeStrength=1,ws.set(this,[WebglCanvas,Html5Canvas]),bs.set(this,0),Ss.set(this,void 0),_s.set(this,{}),this.width=n,this.height=a,u(this,Ss,r,"f"),u(this,_s,o,"f"),d(this,vs,"m",Ps).call(this,d(this,ws,"f")[0])}fallbackIfPossible(){if(d(this,bs,"f")>=d(this,ws,"f").length)throw new Error("No renderer to fall back to");u(this,bs,d(this,bs,"f")+1,"f"),d(this,vs,"m",Ps).call(this,d(this,ws,"f")[d(this,bs,"f")])}switchToHtml5(){d(this,vs,"m",Ps).call(this,Html5Canvas)}setCanvasSize(i,r){const n=this.renderer;n.setCanvasSize(i,r),this.width=i,this.width=r,this.dstWidth=n.dstWidth,this.dstHeight=n.dstHeight}setNote(i){this.note=i,this.renderer.setNote(i),this.frameIndex=void 0,this.srcWidth=this.renderer.srcWidth,this.srcHeight=this.renderer.srcHeight}clear(i){this.renderer.clear(i)}drawFrame(i){this.renderer.drawFrame(i),this.frameIndex=i}forceUpdate(){this.renderer.forceUpdate()}requestStereoScopeMode(i){this.renderer.requestStereoScopeMode(i),this.stereoscopeMode=this.renderer.stereoscopeMode}getDataUrl(i,r){return this.renderer.getDataUrl()}async getBlob(i,r){return this.renderer.getBlob()}destroy(){this.renderer.destroy(),this.note=null}}ws=new WeakMap,bs=new WeakMap,Ss=new WeakMap,_s=new WeakMap,vs=new WeakSet,Ps=function(i){let r=!1;const n=new i(d(this,Ss,"f"),this.width,this.height,{...d(this,_s,"f"),onlost:()=>{r=!0,this.fallbackIfPossible()}});r||(this.note&&(n.setNote(this.note),n.frameIndex=this.renderer?.frameIndex,n.forceUpdate()),this.renderer&&this.renderer.destroy(),this.isHtml5=n instanceof Html5Canvas,this.isReady=!0,this.renderer=n,u(this,bs,d(this,ws,"f").indexOf(i),"f"),this.supportedStereoscopeModes=n.supportedStereoscopeModes,n.stereoscopeStrength=this.stereoscopeStrength,this.requestStereoScopeMode(this.stereoscopeMode))};const Is=_?window.AudioContext||window.webkitAudioContext:null;class WebAudioPlayer{constructor(){As.add(this),this.useEq=!1,this.useAnalyser=!1,this.eqSettings=[[31.25,4.1],[62.5,1.2],[125,0],[250,-4.1],[500,-2.3],[1e3,.5],[2e3,6.5],[8e3,5.1],[16e3,5.1]],Es.set(this,1),Cs.set(this,!1),Fs.set(this,0),ks.set(this,0),xs.set(this,[]),Ts.set(this,void 0),Us.set(this,void 0),Ms.set(this,void 0),P()}set volume(i){this.setVolume(i)}get volume(){return d(this,Es,"f")}set loop(i){u(this,Cs,i,"f"),d(this,Ms,"f")&&(d(this,Ms,"f").loop=i)}get loop(){return d(this,Cs,"f")}setBuffer(i,r){const n=d(this,As,"m",$s).call(this),a=i.length,o=n.createBuffer(1,a,r),h=o.getChannelData(0);if(i instanceof Float32Array)h.set(i,0);else if(i instanceof Int16Array)for(let r=0;ri.disconnect())),u(this,xs,[],"f"),this.analyser=void 0,"closed"!==i.state&&"function"==typeof i.close&&await i.close(),u(this,Ts,null,"f")}}var zs,Ws,Rs;Es=new WeakMap,Cs=new WeakMap,Fs=new WeakMap,ks=new WeakMap,xs=new WeakMap,Ts=new WeakMap,Us=new WeakMap,Ms=new WeakMap,As=new WeakSet,$s=function(){return this.ctx||(this.ctx=new Is),this.ctx},Bs=function(i){const r=d(this,As,"m",$s).call(this),n=this.eqSettings;let a=i;return n.forEach((([i,o],h)=>{const l=r.createBiquadFilter();d(this,xs,"f").push(l),l.frequency.value=i,l.gain.value=o,0===h?l.type="lowshelf":h===n.length-1?l.type="highshelf":l.type="peaking",a.connect(l),a=l})),a},Ls=function(){const i=d(this,As,"m",$s).call(this);u(this,xs,[],"f");const r=i.createBufferSource();d(this,xs,"f").push(r),r.buffer=d(this,Ts,"f");const n=i.createGain();if(d(this,xs,"f").push(n),this.useEq?d(this,As,"m",Bs).call(this,r).connect(n):r.connect(n),this.useAnalyser){const r=i.createAnalyser();d(this,xs,"f").push(r),this.analyser=r,n.connect(r),r.connect(i.destination)}else this.analyser=void 0,n.connect(i.destination);u(this,Ms,r,"f"),u(this,Us,n,"f"),this.setVolume(d(this,Es,"f"))};class Player{constructor(r,n,a,o={}){zs.add(this),this.duration=0,this.autoplay=!1,this.supportedEvents=Ce,this._src=null,this._loop=!1,this._volume=1,this._muted=!1,this._frame=null,this._hasEnded=!1,this.isNoteLoaded=!1,this.events=new Map,this.playbackStartTime=0,this.playbackTime=0,this.playbackLoopId=null,this.showThumbnail=!0,this.hasPlaybackStarted=!1,this.isPlaying=!1,this.wasPlaying=!1,this.isSeeking=!1,this.playbackLoop=r=>{if(!this.isPlaying)return;const n=r/1e3,a=this.duration,o=this.audio.getCurrentTime();let h=n-this.playbackStartTime;if(Math.abs(h%a-o%a)>.01&&(h=o),h>=a){if(!this.loop)return this.pause(),this._hasEnded=!0,void this.emit(i.PlayerEvent.Ended);this.playbackStartTime=n,this.emit(i.PlayerEvent.Loop)}this.setCurrentTime(h%a),this.playbackLoopId=requestAnimationFrame(this.playbackLoop)},P();const h="string"==typeof r?document.querySelector(r):r;this.parserSettings=o,this.renderer=new UniversalCanvas(h,n,a,{onlost:()=>this.emit(i.PlayerEvent.Error),onrestored:()=>this.reload()}),this.audio=new WebAudioPlayer,this.el=h}get src(){return this._src}set src(i){throw new Error("Setting a Player source has been deprecated, please use the load() method instead")}get paused(){return!this.isPlaying}set paused(i){i?this.pause():this.play()}get currentFrame(){return this._frame}set currentFrame(i){this.setCurrentFrame(i)}get currentTime(){return this.isNoteLoaded?this.playbackTime:null}set currentTime(i){this.setCurrentTime(i)}get progress(){return this.isNoteLoaded?this.playbackTime/this.duration*100:null}set progress(i){this.setProgress(i)}get volume(){return this.getVolume()}set volume(i){this.setVolume(i)}get muted(){return this.getMuted()}set muted(i){this.setMuted(i)}get loop(){return this.getLoop()}set loop(i){this.setLoop(i)}get framerate(){return this.note.framerate}get frameCount(){return this.note.frameCount}get frameSpeed(){return this.note.frameSpeed}get buffered(){return Fe([[0,this.duration]])}get seekable(){return Fe([[0,this.duration]])}get currentSrc(){return this._src}get videoWidth(){return this.isNoteLoaded?this.note.imageWidth:0}get videoHeight(){return this.isNoteLoaded?this.note.imageHeight:0}async load(r){if(this.isNoteLoaded&&this.closeNote(),this._src=r,!r)return this.openNote(this.note);this.emit(i.PlayerEvent.LoadStart);const[n,a]=await(async i=>{try{return[null,await i().catch((i=>{throw i}))]}catch(i){return[i,null]}})((()=>Ae(r,this.parserSettings)));if(n)throw this.emit(i.PlayerEvent.Error,n),new Error(`Error loading Flipnote: ${n.message}`);this.openNote(a)}async reload(){if(this.note)return await this.load(this.note.buffer)}async updateSettings(i){return this.parserSettings=i,await this.reload()}closeNote(){this.pause(),this.note=null,this.isNoteLoaded=!1,this.meta=null,this._src=null,this._frame=0,this.playbackTime=0,this.duration=0,this.loop=!1,this.isPlaying=!1,this.wasPlaying=!1,this.hasPlaybackStarted=!1,this.showThumbnail=!0,this.renderer.clear()}openNote(r){this.isNoteLoaded&&this.closeNote(),this.note=r,this.meta=r.meta,this.emit(i.PlayerEvent.LoadedMeta),this.noteFormat=r.format,this.duration=r.duration,this.playbackTime=0,this._frame=0,this.isNoteLoaded=!0,this.isPlaying=!1,this.wasPlaying=!1,this.hasPlaybackStarted=!1,this.layerVisibility=r.layerVisibility,this.showThumbnail=!0,this.audio.setBuffer(r.getAudioMasterPcm(),r.sampleRate),this.emit(i.PlayerEvent.CanPlay),this.emit(i.PlayerEvent.CanPlayThrough),this.setLoop(r.meta.loop),this.renderer.setNote(r),this.drawFrame(r.thumbFrameIndex),this.emit(i.PlayerEvent.LoadedData),this.emit(i.PlayerEvent.Load),this.emit(i.PlayerEvent.Ready),this.autoplay&&this.play()}setCurrentTime(r){this.assertNoteLoaded();const n=Math.floor(r/(1/this.framerate));this.setCurrentFrame(n),this.playbackTime=r,this.emit(i.PlayerEvent.Progress,this.progress)}getCurrentTime(){return this.currentTime}getTimeCounter(){return`${xe(Math.max(this.currentTime,0))} / ${xe(this.duration)}`}getFrameCounter(){return`${ke(this.currentFrame+1,3)} / ${ke(this.frameCount,3)}`}setProgress(i){this.assertNoteLoaded(),y(i,0,100,"progress"),this.currentTime=this.duration*(i/100)}getProgress(){return this.progress}async play(){if(this.assertNoteLoaded(),this.isPlaying)return;this._hasEnded&&(this.playbackTime=0,this._hasEnded=!1);const r=performance.now();this.playbackStartTime=r/1e3-this.playbackTime,this.isPlaying=!0,this.hasPlaybackStarted=!0,d(this,zs,"m",Ws).call(this),this.playbackLoop(r),this.emit(i.PlayerEvent.Play)}pause(){this.isPlaying&&(this.isPlaying=!1,null!==this.playbackLoopId&&cancelAnimationFrame(this.playbackLoopId),d(this,zs,"m",Rs).call(this),this.emit(i.PlayerEvent.Pause))}togglePlay(){this.isPlaying?this.pause():this.play()}getPaused(){return!this.isPlaying}getDuration(){return this.duration}getLoop(){return this._loop}setLoop(i){this._loop=i,this.audio.loop=i}toggleLoop(){this.setLoop(!this._loop)}setCurrentFrame(r){this.assertNoteLoaded();const n=Math.max(0,Math.min(Math.floor(r),this.frameCount-1));(n!==this.currentFrame||this.showThumbnail)&&(this._frame=n,this.drawFrame(n),this.showThumbnail=!1,this.isPlaying||(this.playbackTime=n*(1/this.framerate),this.emit(i.PlayerEvent.SeekEnd)),this.emit(i.PlayerEvent.FrameUpdate,this.currentFrame),this.emit(i.PlayerEvent.Progress,this.progress),this.emit(i.PlayerEvent.TimeUpdate,this.currentFrame))}nextFrame(){this.loop&&this.currentFrame===this.frameCount-1?this.currentFrame=0:this.currentFrame+=1,this.emit(i.PlayerEvent.FrameNext)}prevFrame(){this.loop&&0===this.currentFrame?this.currentFrame=this.frameCount-1:this.currentFrame-=1,this.emit(i.PlayerEvent.FramePrev)}lastFrame(){this.currentFrame=this.frameCount-1,this.emit(i.PlayerEvent.FrameLast)}firstFrame(){this.currentFrame=0,this.emit(i.PlayerEvent.FrameFirst)}thumbnailFrame(){this.currentFrame=this.note.thumbFrameIndex}startSeek(){this.isSeeking||(this.emit(i.PlayerEvent.SeekStart),this.wasPlaying=this.isPlaying,this.pause(),this.isSeeking=!0)}seek(i){this.isSeeking&&(this.progress=100*i)}endSeek(){this.isSeeking&&!0===this.wasPlaying&&this.play(),this.wasPlaying=!1,this.isSeeking=!1}drawFrame(i){this.renderer.drawFrame(i)}forceUpdate(){this.renderer.forceUpdate()}resize(i,r){r!==.75*i&&console.warn(`Canvas width to height ratio should be 3:4 for best results (got ${i}x${r})`),this.renderer.setCanvasSize(i,r),this.forceUpdate()}setLayerVisibility(i,r){this.note.layerVisibility[i]=r,this.layerVisibility[i]=r,this.forceUpdate()}getLayerVisibility(i){return this.layerVisibility[i]}toggleLayerVisibility(i){this.setLayerVisibility(i,!this.layerVisibility[i])}toggleAudioEq(){this.setAudioEq(!this.audio.useEq)}setAudioEq(i){this.isPlaying&&(this.wasPlaying=!0,d(this,zs,"m",Rs).call(this)),this.audio.useEq=i,this.wasPlaying&&(this.wasPlaying=!1,d(this,zs,"m",Ws).call(this))}mute(){this.setMuted(!0)}unmute(){this.setMuted(!1)}setMuted(r){this.audio.volume=r?0:this._volume,this._muted=r,this.emit(i.PlayerEvent.VolumeChange,this.audio.volume)}getMuted(){return 0===this.volume||this._muted}toggleMuted(){this.setMuted(!this._muted)}setVolume(r){y(r,0,1,"volume"),this._volume=r,this.audio.volume=r,this.emit(i.PlayerEvent.VolumeChange,this.audio.volume)}getVolume(){return this._muted?0:this._volume}seekToNextFrame(){this.nextFrame()}fastSeek(i){this.currentTime=i}canPlayType(i){switch(i){case"application/x-ppm":case"application/x-kwz":case"video/x-ppm":case"video/x-kwz":case"video/vnd.nintendo.ugomemo.ppm":case"video/vnd.nintendo.ugomemo.kwz":return"probably";case"application/octet-stream":return"maybe";default:return""}}getVideoPlaybackQuality(){return{creationTime:0,droppedVideoFrames:0,corruptedVideoFrames:0,totalVideoFrames:this.frameCount}}requestPictureInPicture(){throw new Error("Not implemented")}captureStream(){throw new Error("Not implemented")}on(i,r){const n=this.events;(Array.isArray(i)?i:[i]).forEach((i=>{n.has(i)?n.get(i).push(r):n.set(i,[r])}))}off(i,r){const n=this.events;(Array.isArray(i)?i:[i]).forEach((i=>{if(!n.has(i))return;const a=n.get(i);n.set(i,a.splice(a.indexOf(r),1))}))}emit(r,...n){const a=this.events;if(r!==i.PlayerEvent.__Any&&a.has(r)){a.get(r).forEach((i=>i.apply(null,n)));const i=`on${r}`,o=this;"function"==typeof o[i]&&o[i].apply(null,n)}a.has(i.PlayerEvent.__Any)&&a.get(i.PlayerEvent.__Any).forEach((i=>i.apply(null,[r,...n])))}clearEvents(){this.events.clear()}async destroy(){this.clearEvents(),this.emit(i.PlayerEvent.Destroy),this.closeNote(),await this.renderer.destroy(),await this.audio.destroy()}assertNoteLoaded(){g(this.isNoteLoaded,"No Flipnote is currently loaded in this player")}}function Ns(i){class PlayerMixinClass extends i{get renderer(){return this.player.renderer}get note(){return this.player.note}get noteFormat(){return this.player.noteFormat}get meta(){return this.player.meta}get duration(){return this.player.duration}get layerVisibility(){return this.player.layerVisibility}get autoplay(){return this.player.autoplay}set autoplay(i){this.player.autoplay=i}}for(let r of Reflect.ownKeys(Player.prototype)){let n=Object.getOwnPropertyDescriptor(Player.prototype,r);r in i.prototype||"constructor"===r||"name"===r||"prototype"===r||"string"==typeof r&&r.startsWith("#")||(n.value&&"function"==typeof n.value?Object.defineProperty(PlayerMixinClass.prototype,r,{...n,value(...i){return this.player[r](...i)}}):(n.get||n.set)&&Object.defineProperty(PlayerMixinClass.prototype,r,{...n,set(i){this.player[r]=i},get(){return this.player[r]}}))}return PlayerMixinClass}zs=new WeakSet,Ws=function(){this.audio.playFrom(this.currentTime)},Rs=function(){this.audio.stop()};class EncoderBase{constructor(){this.dataUrl=null}getBuffer(){return g(A,"This feature is only available in NodeJS environments"),Buffer.from(this.getArrayBuffer())}getBlob(){return P(),new Blob([this.getArrayBuffer()],{type:this.mimeType})}getUrl(){return P(),this.dataUrl?this.dataUrl:window.URL.createObjectURL(this.getBlob())}revokeUrl(){P(),this.dataUrl&&window.URL.revokeObjectURL(this.dataUrl)}}const Ds=5003,Os=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];class LzwCompressor{constructor(i,r,n){this.accum=new Uint8Array(256),this.htab=new Int32Array(Ds),this.codetab=new Int32Array(Ds),this.cur_accum=0,this.cur_bits=0,this.curPixel=0,this.free_ent=0,this.clear_flg=!1,this.g_init_bits=void 0,this.ClearCode=void 0,this.EOFCode=void 0,this.width=i,this.height=r,this.colorDepth=n,this.reset()}reset(){this.initCodeSize=Math.max(2,this.colorDepth),this.accum.fill(0),this.htab.fill(0),this.codetab.fill(0),this.cur_accum=0,this.cur_bits=0,this.curPixel=0,this.free_ent=0,this.maxcode,this.clear_flg=!1,this.g_init_bits=void 0,this.ClearCode=void 0,this.EOFCode=void 0}char_out(i,r){this.accum[this.a_count++]=i,this.a_count>=254&&this.flush_char(r)}cl_block(i){this.cl_hash(Ds),this.free_ent=this.ClearCode+2,this.clear_flg=!0,this.output(this.ClearCode,i)}cl_hash(i){for(var r=0;r=0){l=c-o,0===o&&(l=1);do{if((o-=l)<0&&(o+=c),this.htab[o]===n){h=this.codetab[o];continue t}}while(this.htab[o]>=0)}this.output(h,r),h=a,this.free_ent<4096?(this.codetab[o]=this.free_ent++,this.htab[o]=n):this.cl_block(r)}else h=this.codetab[o];this.output(h,r),this.output(this.EOFCode,r)}encode(i,r){this.pixels=i,r.writeByte(this.initCodeSize),this.remaining=this.width*this.height,this.curPixel=0,this.compress(this.initCodeSize+1,r),r.writeByte(0)}flush_char(i){this.a_count>0&&(i.writeByte(this.a_count),i.writeBytes(this.accum,0,this.a_count),this.a_count=0)}get_maxcode(i){return(1<0?this.cur_accum|=i<=8;)this.char_out(255&this.cur_accum,r),this.cur_accum>>=8,this.cur_bits-=8;if((this.free_ent>this.maxcode||this.clear_flg)&&(this.clear_flg?(this.maxcode=this.get_maxcode(this.n_bits=this.g_init_bits),this.clear_flg=!1):(++this.n_bits,12==this.n_bits?this.maxcode=4096:this.maxcode=this.get_maxcode(this.n_bits))),i==this.EOFCode){for(;this.cur_bits>0;)this.char_out(255&this.cur_accum,r),this.cur_accum>>=8,this.cur_bits-=8;this.flush_char(r)}}}var Hs,Ks,Vs,Gs,js,qs,Ys,Xs,Zs,Qs,Js,tr,er,ir,sr;class GifImage extends EncoderBase{constructor(i,r,n={}){super(),Hs.add(this),this.mimeType="gif/image",this.frameCount=0,Ks.set(this,void 0),Vs.set(this,void 0),this.width=i,this.height=r,u(this,Ks,new ByteArray,"f"),this.settings={...GifImage.defaultSettings,...n},u(this,Vs,new LzwCompressor(i,r,n.colorDepth),"f")}static fromFlipnote(i,r={}){const n=new GifImage(i.imageWidth,i.imageHeight,{delay:100/i.framerate,repeat:i.meta?.loop?-1:0,...r});n.palette=i.globalPalette;for(let r=0;r{const n=1===i.length?i[0]:r.reduce(((r,n,a)=>r+(i=>{if(!0===i._$cssResult$)return i.cssText;if("number"==typeof i)return i;throw Error("Value passed to 'css' function must be a 'css' function result: "+i+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+i[a+1]),i[0]);return new hr(n,i,ar)},cr=nr?i=>i:i=>i instanceof CSSStyleSheet?(i=>{let r="";for(const n of i.cssRules)r+=n.cssText;return(i=>new hr("string"==typeof i?i:i+"",void 0,ar))(r)})(i):i,{is:dr,defineProperty:ur,getOwnPropertyDescriptor:fr,getOwnPropertyNames:pr,getOwnPropertySymbols:mr,getPrototypeOf:gr}=Object,yr=globalThis,vr=yr.trustedTypes,wr=vr?vr.emptyScript:"",br=yr.reactiveElementPolyfillSupport,Sr=(i,r)=>i,_r={toAttribute(i,r){switch(r){case Boolean:i=i?wr:null;break;case Object:case Array:i=null==i?i:JSON.stringify(i)}return i},fromAttribute(i,r){let n=i;switch(r){case Boolean:n=null!==i;break;case Number:n=null===i?null:Number(i);break;case Object:case Array:try{n=JSON.parse(i)}catch(i){n=null}}return n}},Pr=(i,r)=>!dr(i,r),Ar={attribute:!0,type:String,converter:_r,reflect:!1,hasChanged:Pr};Symbol.metadata??=Symbol("metadata"),yr.litPropertyMetadata??=new WeakMap;class b extends HTMLElement{static addInitializer(i){this._$Ei(),(this.l??=[]).push(i)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(i,r=Ar){if(r.state&&(r.attribute=!1),this._$Ei(),this.elementProperties.set(i,r),!r.noAccessor){const n=Symbol(),a=this.getPropertyDescriptor(i,n,r);void 0!==a&&ur(this.prototype,i,a)}}static getPropertyDescriptor(i,r,n){const{get:a,set:o}=fr(this.prototype,i)??{get(){return this[r]},set(i){this[r]=i}};return{get(){return a?.call(this)},set(r){const h=a?.call(this);o.call(this,r),this.requestUpdate(i,h,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(i){return this.elementProperties.get(i)??Ar}static _$Ei(){if(this.hasOwnProperty(Sr("elementProperties")))return;const i=gr(this);i.finalize(),void 0!==i.l&&(this.l=[...i.l]),this.elementProperties=new Map(i.elementProperties)}static finalize(){if(this.hasOwnProperty(Sr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Sr("properties"))){const i=this.properties,r=[...pr(i),...mr(i)];for(const n of r)this.createProperty(n,i[n])}const i=this[Symbol.metadata];if(null!==i){const r=litPropertyMetadata.get(i);if(void 0!==r)for(const[i,n]of r)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[i,r]of this.elementProperties){const n=this._$Eu(i,r);void 0!==n&&this._$Eh.set(n,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(i){const r=[];if(Array.isArray(i)){const n=new Set(i.flat(1/0).reverse());for(const i of n)r.unshift(cr(i))}else void 0!==i&&r.push(cr(i));return r}static _$Eu(i,r){const n=r.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof i?i.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((i=>this.enableUpdating=i)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((i=>i(this)))}addController(i){(this._$EO??=new Set).add(i),void 0!==this.renderRoot&&this.isConnected&&i.hostConnected?.()}removeController(i){this._$EO?.delete(i)}_$E_(){const i=new Map,r=this.constructor.elementProperties;for(const n of r.keys())this.hasOwnProperty(n)&&(i.set(n,this[n]),delete this[n]);i.size>0&&(this._$Ep=i)}createRenderRoot(){const i=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((i,r)=>{if(nr)i.adoptedStyleSheets=r.map((i=>i instanceof CSSStyleSheet?i:i.styleSheet));else for(const n of r){const r=document.createElement("style"),a=rr.litNonce;void 0!==a&&r.setAttribute("nonce",a),r.textContent=n.cssText,i.appendChild(r)}})(i,this.constructor.elementStyles),i}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((i=>i.hostConnected?.()))}enableUpdating(i){}disconnectedCallback(){this._$EO?.forEach((i=>i.hostDisconnected?.()))}attributeChangedCallback(i,r,n){this._$AK(i,n)}_$EC(i,r){const n=this.constructor.elementProperties.get(i),a=this.constructor._$Eu(i,n);if(void 0!==a&&!0===n.reflect){const o=(void 0!==n.converter?.toAttribute?n.converter:_r).toAttribute(r,n.type);this._$Em=i,null==o?this.removeAttribute(a):this.setAttribute(a,o),this._$Em=null}}_$AK(i,r){const n=this.constructor,a=n._$Eh.get(i);if(void 0!==a&&this._$Em!==a){const i=n.getPropertyOptions(a),o="function"==typeof i.converter?{fromAttribute:i.converter}:void 0!==i.converter?.fromAttribute?i.converter:_r;this._$Em=a,this[a]=o.fromAttribute(r,i.type),this._$Em=null}}requestUpdate(i,r,n){if(void 0!==i){if(n??=this.constructor.getPropertyOptions(i),!(n.hasChanged??Pr)(this[i],r))return;this.P(i,r,n)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(i,r,n){this._$AL.has(i)||this._$AL.set(i,r),!0===n.reflect&&this._$Em!==i&&(this._$Ej??=new Set).add(i)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}const i=this.scheduleUpdate();return null!=i&&await i,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[i,r]of this._$Ep)this[i]=r;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,n]of i)!0!==n.wrapped||this._$AL.has(r)||void 0===this[r]||this.P(r,this[r],n)}let i=!1;const r=this._$AL;try{i=this.shouldUpdate(r),i?(this.willUpdate(r),this._$EO?.forEach((i=>i.hostUpdate?.())),this.update(r)):this._$EU()}catch(r){throw i=!1,this._$EU(),r}i&&this._$AE(r)}willUpdate(i){}_$AE(i){this._$EO?.forEach((i=>i.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(i)),this.updated(i)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(i){return!0}update(i){this._$Ej&&=this._$Ej.forEach((i=>this._$EC(i,this[i]))),this._$EU()}updated(i){}firstUpdated(i){}}b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[Sr("elementProperties")]=new Map,b[Sr("finalized")]=new Map,br?.({ReactiveElement:b}),(yr.reactiveElementVersions??=[]).push("2.0.4");const Er=globalThis,Cr=Er.trustedTypes,Fr=Cr?Cr.createPolicy("lit-html",{createHTML:i=>i}):void 0,kr="$lit$",xr=`lit$${Math.random().toFixed(9).slice(2)}$`,Tr="?"+xr,Ur=`<${Tr}>`,Mr=document,$r=()=>Mr.createComment(""),Br=i=>null===i||"object"!=typeof i&&"function"!=typeof i,Lr=Array.isArray,Ir="[ \t\n\f\r]",zr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Wr=/-->/g,Rr=/>/g,Nr=RegExp(`>|${Ir}(?:([^\\s"'>=/]+)(${Ir}*=${Ir}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Dr=/'/g,Or=/"/g,Hr=/^(?:script|style|textarea|title)$/i,Kr=(i,...r)=>({_$litType$:1,strings:i,values:r}),Vr=Symbol.for("lit-noChange"),Gr=Symbol.for("lit-nothing"),jr=new WeakMap,qr=Mr.createTreeWalker(Mr,129);function Yr(i,r){if(!Array.isArray(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==Fr?Fr.createHTML(r):r}const Xr=(i,r)=>{const n=i.length-1,a=[];let o,h=2===r?"":"",l=zr;for(let r=0;r"===d[0]?(l=o??zr,u=-1):void 0===d[1]?u=-2:(u=l.lastIndex-d[2].length,c=d[1],l=void 0===d[3]?Nr:'"'===d[3]?Or:Dr):l===Or||l===Dr?l=Nr:l===Wr||l===Rr?l=zr:(l=Nr,o=void 0);const p=l===Nr&&i[r+1].startsWith("/>")?" ":"";h+=l===zr?n+Ur:u>=0?(a.push(c),n.slice(0,u)+kr+n.slice(u)+xr+p):n+xr+(-2===u?r:p)}return[Yr(i,h+(i[n]||"")+(2===r?"":"")),a]};class V{constructor({strings:i,_$litType$:r},n){let a;this.parts=[];let o=0,h=0;const l=i.length-1,c=this.parts,[d,u]=Xr(i,r);if(this.el=V.createElement(d,n),qr.currentNode=this.el.content,2===r){const i=this.el.content.firstChild;i.replaceWith(...i.childNodes)}for(;null!==(a=qr.nextNode())&&c.length0){a.textContent=Cr?Cr.emptyScript:"";for(let n=0;nLr(i)||"function"==typeof i?.[Symbol.iterator])(i)?this.k(i):this._(i)}S(i){return this._$AA.parentNode.insertBefore(i,this._$AB)}T(i){this._$AH!==i&&(this._$AR(),this._$AH=this.S(i))}_(i){this._$AH!==Gr&&Br(this._$AH)?this._$AA.nextSibling.data=i:this.T(Mr.createTextNode(i)),this._$AH=i}$(i){const{values:r,_$litType$:n}=i,a="number"==typeof n?this._$AC(i):(void 0===n.el&&(n.el=V.createElement(Yr(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===a)this._$AH.p(r);else{const i=new S(a,this),n=i.u(this.options);i.p(r),this.T(n),this._$AH=i}}_$AC(i){let r=jr.get(i.strings);return void 0===r&&jr.set(i.strings,r=new V(i)),r}k(i){Lr(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,a=0;for(const o of i)a===r.length?r.push(n=new M(this.S($r()),this.S($r()),this,this.options)):n=r[a],n._$AI(o),a++;a2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Gr}_$AI(i,r=this,n,a){const o=this.strings;let h=!1;if(void 0===o)i=Zr(this,i,r,0),h=!Br(i)||i!==this._$AH&&i!==Vr,h&&(this._$AH=i);else{const a=i;let l,c;for(i=o[0],l=0;l{const a=n?.renderBefore??r;let o=a._$litPart$;if(void 0===o){const i=n?.renderBefore??null;a._$litPart$=o=new M(r.insertBefore($r(),i),i,void 0,n??{})}return o._$AI(i),o})(r,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Vr}}s._$litElement$=!0,s.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const Jr=globalThis.litElementPolyfillSupport;Jr?.({LitElement:s}),(globalThis.litElementVersions??=[]).push("4.0.5");const tn=i=>(r,n)=>{void 0!==n?n.addInitializer((()=>{customElements.define(i,r)})):customElements.define(i,r)},en={attribute:!0,type:String,converter:_r,reflect:!1,hasChanged:Pr},sn=(i=en,r,n)=>{const{kind:a,metadata:o}=n;let h=globalThis.litPropertyMetadata.get(o);if(void 0===h&&globalThis.litPropertyMetadata.set(o,h=new Map),h.set(n.name,i),"accessor"===a){const{name:a}=n;return{set(n){const o=r.get.call(this);r.set.call(this,n),this.requestUpdate(a,o,i)},init(r){return void 0!==r&&this.P(a,void 0,i),r}}}if("setter"===a){const{name:a}=n;return function(n){const o=this[a];r.call(this,n),this.requestUpdate(a,o,i)}}throw Error("Unsupported decorator location: "+a)};function rn(i){return(r,n)=>"object"==typeof n?sn(i,r,n):((i,r,n)=>{const a=r.hasOwnProperty(n);return r.constructor.createProperty(n,a?{...i,wrapped:!0}:i),a?Object.getOwnPropertyDescriptor(r,n):void 0})(i,r,n)}function nn(i){return rn({...i,state:!0,attribute:!1})}function an(i,r){return(r,n,a)=>((i,r,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&"object"!=typeof r&&Object.defineProperty(i,r,n),n))(r,n,{get(){return(r=>r.renderRoot?.querySelector(i)??null)(this)}})}const on={a:"decrease",s:"decrease",d:"increase",w:"increase",ArrowLeft:"decrease",ArrowDown:"decrease",ArrowRight:"increase",ArrowUp:"increase"},hn={" ":"playpause",Enter:"playpause",a:"prev",s:"prev",d:"next",w:"next",ArrowLeft:"prev",ArrowDown:"prev",ArrowRight:"next",ArrowUp:"next"};i.PlayerComponent=class extends(Ns(s)){static get styles(){return lr`:host{display:inline-block}.Player{display:inline-block;position:relative;font-family:var(--flipnote-player-font-family,sans-serif)}.CanvasArea{cursor:pointer;position:relative;background:var(--flipnote-player-canvas-background,#fff)}.CanvasArea:focus{outline:var(--flipnote-player-focus-outline,3px solid #ffd3a6);outline-offset:2px}.PlayerCanvas{position:relative;display:block}.PlayerCanvas canvas{display:block}.Overlay{position:absolute;top:0;left:0;background:#ebf0f3;color:#4b4c53;width:100%;height:100%;display:flex;justify-content:center;align-items:center}.Overlay--error{background:#ff8b8b;color:#ca2a32}@keyframes spin{from{transform:rotateZ(0)}to{transform:rotateZ(360deg)}}.LoaderIcon{animation:spin infinite 1.2s linear}.Controls{background:var(--flipnote-player-controls-background,none)}.MuteIcon{width:28px;height:28px;cursor:pointer}.Controls__groupLeft,.Controls__groupRight,.Controls__row{display:flex;align-items:center}.Controls__groupLeft{margin-right:auto}.Controls__groupRight{margin-left:auto}.Controls__playButton{height:32px;width:32px;padding:2px}.MuteIcon{width:28px;height:28px}.LoaderIcon{width:40px;height:40px}.Controls.Controls--compact{margin:6px 0}.Controls__frameCounter{min-width:90px;font-variant-numeric:tabular-nums;cursor:pointer}.Controls__progressBar{flex:1}.Controls--compact .Controls__playButton{margin-right:12px}.Controls--compact .Controls__progressBar{flex:1}.Controls--default .Controls__playButton{margin-right:12px}.Controls--default .Controls__progressBar{margin-top:2px;margin-bottom:2px;display:block}.Controls--default .Controls__volumeBar{width:70px;margin-left:8px}.Button{border:0;padding:0;outline:0;-webkit-appearance:none;display:block;font-family:inherit;font-size:inherit;text-align:center;cursor:pointer;background:var(--flipnote-player-button-background,#ffd3a6);color:var(--flipnote-player-button-color,#f36a2d);border-radius:4px}.Button:focus{outline:3px solid var(--flipnote-player-button-background,#ffd3a6);outline-offset:2px}.Button flipnote-player-icon{display:block}`}get width(){return this._width}set width(i){const r=this._width;var n;this._width=i,this._cssWidth=isNaN(+i)?i:`${i}px`,n=()=>this.updateCanvasSize(),_?C((()=>C((()=>n())))):n(),this.requestUpdate("width",r)}get src(){return this._playerSrc}set src(i){const r=this._playerSrc;this._isPlayerAvailable&&this.player.load(i),this._playerSrc=i,this.requestUpdate("src",r)}get autoplay(){return this.player?.autoplay}set autoplay(i){if(this.player){const r=this.player.autoplay;this.player.autoplay=i,this.requestUpdate("autoplay",r)}}constructor(){super(),this._width="auto",this._cssWidth="auto",this._progress=0,this._counter="",this._frameCount=0,this._isLoading=!1,this._isError=!1,this._isPlaying=!1,this._isMuted=!1,this._volumeLevel=0,this._isPlayerAvailable=!1,this._keysDown={},this._counterMode="frame",this.handleResize=i=>{this.updateCanvasSize()},this.handleKeyInputDown=i=>{const r=this._keysDown[i.key],n=hn[i.key];if(n){switch(n){case"playpause":r||this.togglePlay();break;case"prev":i.shiftKey?this.firstFrame():this.prevFrame();break;case"next":i.shiftKey?this.lastFrame():this.nextFrame()}this._keysDown[i.key]=!0,i.preventDefault()}},this.handleKeyInputUp=i=>{this._keysDown[i.key]=!1},this.handlePlayToggle=i=>{this.focus(),this.togglePlay()},this.handleMuteToggle=i=>{this.focus(),this.toggleMuted()},this.handleProgressSliderChange=i=>{this.focus(),this.seek(i.detail.value)},this.handleProgressSliderInputStart=()=>{this.focus(),this.startSeek()},this.handleProgressSliderInputEnd=()=>{this.focus(),this.endSeek()},this.handleVolumeBarChange=i=>{this.focus(),this.setVolume(i.detail.value)},this.handleCounterClick=()=>{this._counterMode="frame"===this._counterMode?"time":"frame",this._counter="frame"===this._counterMode?this.getFrameCounter():this.getTimeCounter()},this._resizeObserver=new ResizeObserver(this.handleResize)}render(){return Kr`
${this._isLoading?Kr`
`:""} ${this._isError?Kr`
Error
`:""}
${this.renderControls()}
`}renderControls(){return"compact"===this.controls?Kr`
`:Kr`
${this._counter}
`}firstUpdated(r){this.updateSettingsFromProps();const n=new Player(this.playerCanvasWrapper,256,192,this.parserSettings);this._resizeObserver.observe(this),this.player=n,n.on(i.PlayerEvent.LoadStart,(()=>{this._isLoading=!0})),n.on(i.PlayerEvent.Load,(()=>{this.updateCanvasSize()})),n.on(i.PlayerEvent.Error,(()=>{this._isLoading=!1,this._isError=!0})),n.on([i.PlayerEvent.Load,i.PlayerEvent.Close,i.PlayerEvent.Progress],(()=>{this._isLoading=!1,this._isError=!1,this._progress=n.getProgress()/100,this._counter="frame"===this._counterMode?n.getFrameCounter():n.getTimeCounter(),this._frameCount=n.frameCount})),n.on(i.PlayerEvent.Play,(()=>{this._isPlaying=!0})),n.on(i.PlayerEvent.Pause,(()=>{this._isPlaying=!1})),n.on([i.PlayerEvent.Load,i.PlayerEvent.VolumeChange],(()=>{this._volumeLevel=n.volume,this._isMuted=n.muted})),n.on(i.PlayerEvent.__Any,((i,r)=>{this.dispatchEvent(new Event(i))})),this._playerSrc&&n.load(this._playerSrc),this._isPlayerAvailable=!0}disconnectedCallback(){this._resizeObserver.disconnect(),this.destroy()}updateSettingsFromProps(){this.parserSettings={dsiLibraryNote:this.dsiLibrary,borderCrop:this.cropBorder,initialBgmPredictor:this.bgmPredictor,initialBgmStepIndex:this.bgmStepIndex,initialSePredictors:this.parseListProp(this?.sePredictors),initialSeStepIndices:this.parseListProp(this?.seStepIndices)}}parseListProp(i){if(i)return i.split(",").map((i=>/^\s*$/.test(i)?void 0:parseInt(i)))}updateCanvasSize(){const i=this._isPlayerAvailable,r=this.player.note;let n=256;"auto"===this._width&&i&&this.player.isNoteLoaded?n=r.imageWidth:"auto"!==this._width&&(n=this.getBoundingClientRect().width),i&&r&&this.player.resize(n,n*r.aspect)}},c([rn({type:String})],i.PlayerComponent.prototype,"controls",void 0),c([rn({type:Boolean})],i.PlayerComponent.prototype,"dsiLibrary",void 0),c([rn({type:Boolean})],i.PlayerComponent.prototype,"cropBorder",void 0),c([rn({type:Number})],i.PlayerComponent.prototype,"bgmPredictor",void 0),c([rn({type:Number})],i.PlayerComponent.prototype,"bgmStepIndex",void 0),c([rn({type:String})],i.PlayerComponent.prototype,"sePredictors",void 0),c([rn({type:String})],i.PlayerComponent.prototype,"seStepIndices",void 0),c([rn({type:String})],i.PlayerComponent.prototype,"width",null),c([rn({type:String})],i.PlayerComponent.prototype,"src",null),c([rn({type:Boolean})],i.PlayerComponent.prototype,"autoplay",null),c([nn()],i.PlayerComponent.prototype,"_width",void 0),c([nn()],i.PlayerComponent.prototype,"_cssWidth",void 0),c([nn()],i.PlayerComponent.prototype,"_progress",void 0),c([nn()],i.PlayerComponent.prototype,"_counter",void 0),c([nn()],i.PlayerComponent.prototype,"_frameCount",void 0),c([nn()],i.PlayerComponent.prototype,"_isLoading",void 0),c([nn()],i.PlayerComponent.prototype,"_isError",void 0),c([nn()],i.PlayerComponent.prototype,"_isPlaying",void 0),c([nn()],i.PlayerComponent.prototype,"_isMuted",void 0),c([nn()],i.PlayerComponent.prototype,"_volumeLevel",void 0),c([an("#canvasWrapper")],i.PlayerComponent.prototype,"playerCanvasWrapper",void 0),i.PlayerComponent=c([tn("flipnote-player")],i.PlayerComponent);const ln=i=>(...r)=>({_$litDirective$:i,values:r});let cn=class{constructor(i){}get _$AU(){return this._$AM._$AU}_$AT(i,r,n){this._$Ct=i,this._$AM=r,this._$Ci=n}_$AS(i,r){return this.update(i,r)}update(i,r){return this.render(...r)}};const dn=ln(class extends cn{constructor(i){if(super(i),1!==i.type||"class"!==i.name||i.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(i){return" "+Object.keys(i).filter((r=>i[r])).join(" ")+" "}update(i,[r]){if(void 0===this.st){this.st=new Set,void 0!==i.strings&&(this.nt=new Set(i.strings.join(" ").split(/\s/).filter((i=>""!==i))));for(const i in r)r[i]&&!this.nt?.has(i)&&this.st.add(i);return this.render(r)}const n=i.element.classList;for(const i of this.st)i in r||(n.remove(i),this.st.delete(i));for(const i in r){const a=!!r[i];a===this.st.has(i)||this.nt?.has(i)||(a?(n.add(i),this.st.add(i)):(n.remove(i),this.st.delete(i)))}return Vr}}),un="important",fn=" !"+un,pn=ln(class extends cn{constructor(i){if(super(i),1!==i.type||"style"!==i.name||i.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(i){return Object.keys(i).reduce(((r,n)=>{const a=i[n];return null==a?r:r+`${n=n.includes("-")?n:n.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${a};`}),"")}update(i,[r]){const{style:n}=i.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const i of this.ft)null==r[i]&&(this.ft.delete(i),i.includes("-")?n.removeProperty(i):n[i]=null);for(const i in r){const a=r[i];if(null!=a){this.ft.add(i);const r="string"==typeof a&&a.endsWith(fn);i.includes("-")||r?n.setProperty(i,r?a.slice(0,-11):a,r?un:""):n[i]=a}}return Vr}}),mn=ln(class extends cn{render(i){return Object.keys(i).filter((r=>i[r])).join(" ")}});let gn=class extends s{constructor(){super(...arguments),this.value=0,this.step=.1,this.label="",this.orientation="horizontal",this.isActive=!1,this.onSliderMouseStart=i=>{i.preventDefault(),this.isActive=!0,document.addEventListener("mousemove",this.onSliderMouseMove),document.addEventListener("mouseup",this.onSliderMouseEnd),this.dispatch("inputstart"),this.onSliderInput(i.clientX,i.clientY)},this.onSliderMouseEnd=i=>{i.preventDefault(),document.removeEventListener("mousemove",this.onSliderMouseMove),document.removeEventListener("mouseup",this.onSliderMouseEnd),this.dispatch("inputend"),this.onSliderInput(i.clientX,i.clientY),this.isActive=!1},this.onSliderMouseMove=i=>{i.preventDefault(),this.onSliderInput(i.clientX,i.clientY)},this.onSliderTouchStart=i=>{const r=i.changedTouches[0];i.preventDefault(),this.isActive=!0,document.addEventListener("touchmove",this.onSliderTouchMove),document.addEventListener("touchend",this.onSliderTouchEnd),this.dispatch("inputstart"),this.onSliderInput(r.clientX,r.clientY)},this.onSliderTouchEnd=i=>{const r=i.changedTouches[0];i.preventDefault(),document.removeEventListener("touchmove",this.onSliderTouchMove),document.removeEventListener("touchend",this.onSliderTouchEnd),this.dispatch("inputend"),this.onSliderInput(r.clientX,r.clientY),this.isActive=!1},this.onSliderTouchMove=i=>{const r=i.changedTouches[0];i.preventDefault(),this.onSliderInput(r.clientX,r.clientY)},this.onSliderInput=(i,r)=>{const n=this.sliderElement.getBoundingClientRect();let a;if("horizontal"===this.orientation){const r=n.height/2,o=n.width-2*r,h=(i-n.left-r)/o;a=Math.max(0,Math.min(h,1))}else if("vertical"===this.orientation){const i=n.width/2,o=n.height-2*i,h=1-(r-n.top-i)/o;a=Math.max(0,Math.min(h,1))}this.updateValue(a)},this.onKeyInput=i=>{const r=on[i.key];if(r){switch(this.dispatch("inputstart"),r){case"decrease":i.shiftKey?this.updateValue(0):this.updateValue(this.value-this.step);break;case"increase":i.shiftKey?this.updateValue(1):this.updateValue(this.value+this.step)}this.dispatch("inputend"),i.preventDefault()}},this.updateValue=i=>{i=p(i,0,1),this.value!==i&&(this.value=i,this.dispatch("change",{value:i}))}}static get styles(){return lr`.Slider{touch-action:none;padding:4px 0;cursor:pointer}.Slider:focus{position:relative;z-index:1;outline:0}.Slider--vertical{height:100px;width:14px}.Slider__track{position:relative;border-radius:3px;background:var(--flipnote-player-slider-track,#ffd3a6)}.Slider:focus .Slider__track{outline:var(--flipnote-player-focus-outline,3px solid #ffd3a6);outline-offset:3px}.Slider--horizontal .Slider__track{height:4px;margin:6px 0}.Slider--vertical .Slider__track{width:4px;height:100%;margin:0 6px}.Slider__levelWrapper{position:absolute;left:0;right:0;height:6px;margin:-1px}.Slider__level{position:absolute;width:100%;left:0;height:8px;border-radius:8px;background:var(--flipnote-player-slider-level,#f36a2d)}.Slider--horizontal .Slider__level{width:100%;height:6px}.Slider--vertical .Slider__level{width:6px;height:100%;bottom:0}.Slider__handle{display:none;position:absolute;height:10px;width:10px;border-radius:5px;box-sizing:border-box;border:3px solid var(--flipnote-player-slider-handle,#f36a2d);background:var(--flipnote-player-slider-handle-fill,#fff)}.Slider--isActive .Slider__handle,.Slider:focus .Slider__handle,.Slider:hover .Slider__handle{display:block}.Slider--horizontal .Slider__handle{top:0;margin-top:-3px;margin-left:-6px}.Slider--vertical .Slider__handle{left:0;margin-bottom:-6px;margin-left:-3px}`}render(){const i=100*this.value+"%",r="horizontal"===this.orientation?"width":"height",n="horizontal"===this.orientation?"left":"bottom",a={Slider:!0,"Slider--horizontal":"horizontal"===this.orientation,"Slider--vertical":"vertical"===this.orientation,"Slider--isActive":this.isActive};return Kr`
`}dispatch(i,r){const n=new CustomEvent(i,{detail:r});this.dispatchEvent(n)}};c([rn({type:Number})],gn.prototype,"value",void 0),c([rn({type:Number})],gn.prototype,"step",void 0),c([rn({type:String})],gn.prototype,"label",void 0),c([rn({type:String})],gn.prototype,"orientation",void 0),c([nn()],gn.prototype,"isActive",void 0),c([an(".Slider__track")],gn.prototype,"sliderElement",void 0),gn=c([tn("flipnote-player-slider")],gn);class e extends cn{constructor(i){if(super(i),this.it=Gr,2!==i.type)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(i){if(i===Gr||null==i)return this._t=void 0,this.it=i;if(i===Vr)return i;if("string"!=typeof i)throw Error(this.constructor.directiveName+"() called with a non-string value");if(i===this.it)return this._t;this.it=i;const r=[i];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;class t extends e{}t.directiveName="unsafeSVG",t.resultType=2;const yn=ln(t),vn=i=>i.replace(/]*)>/,((i,r)=>``)),wn={play:vn(''),pause:vn(''),loader:vn(''),volumeOn:vn(''),volumeOff:vn('')};let bn=class extends s{constructor(){super(...arguments),this.icon="loader"}static get styles(){return lr`.Icon{width:100%;height:100%;color:var(--flipnote-player-icon-color,#f36a2d)}`}render(){return Kr`${yn(wn[this.icon])}`}};var Sn,_n,Pn,An,En,Cn;c([rn({type:String})],bn.prototype,"icon",void 0),bn=c([tn("flipnote-player-icon")],bn),i.ImageComponent=class extends s{constructor(){super(...arguments),Sn.add(this),_n.set(this,""),Pn.set(this,"thumb"),this.cropped=!1,this._gifUrl="",this._imgTitle=""}static get styles(){return lr`.Image{width:inherit;height:inherit;image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges;-ms-interpolation-mode:nearest-neighbor}`}set src(i){this.load(i)}get src(){return d(this,_n,"f")}set frame(i){u(this,Pn,i,"f"),this.note&&this.loadNote(this.note)}get frame(){return d(this,Pn,"f")}render(){return Kr``}loadNote(i){this.note=i,d(this,Sn,"m",An).call(this);const r=d(this,Pn,"f");if("all"===r)this.gif=GifImage.fromFlipnote(i),this._gifUrl=this.gif.getUrl();else if("thumb"===r)this.gif=GifImage.fromFlipnoteFrame(i,i.thumbFrameIndex),this._gifUrl=this.gif.getUrl();else if(!isNaN(+r)){const n=parseInt(r);this.gif=GifImage.fromFlipnoteFrame(i,n),this._gifUrl=this.gif.getUrl()}this._gifUrl?(d(this,Sn,"m",En).call(this),this._imgTitle=i.getTitle()):d(this,Sn,"m",Cn).call(this,"Invalid frame attribute")}load(i){u(this,_n,i,"f"),this.note=void 0;const r="true"===this.getAttribute("cropped");Ae(i,{borderCrop:r}).then((i=>this.loadNote(i))).catch((i=>d(this,Sn,"m",Cn).call(this,i)))}disconnectedCallback(){d(this,Sn,"m",An).call(this)}},_n=new WeakMap,Pn=new WeakMap,Sn=new WeakSet,An=function(){this.gif&&this.gif.dataUrl&&(this.gif.revokeUrl(),this._gifUrl="")},En=function(){this.dispatchEvent(new Event("load"))},Cn=function(i){throw this.dispatchEvent(new ErrorEvent("error",{error:i})),new Error(i)},c([rn()],i.ImageComponent.prototype,"src",null),c([rn()],i.ImageComponent.prototype,"frame",null),c([rn({type:Boolean})],i.ImageComponent.prototype,"cropped",void 0),c([nn()],i.ImageComponent.prototype,"_gifUrl",void 0),c([nn()],i.ImageComponent.prototype,"_imgTitle",void 0),i.ImageComponent=c([tn("flipnote-image")],i.ImageComponent),i.CanvasInterface=class{constructor(i,r,n,a){}},i.GifImage=GifImage,i.Html5Canvas=Html5Canvas,i.KwzParser=KwzParser,i.Player=Player,i.PlayerMixin=Ns,i.PpmParser=PpmParser,i.UniversalCanvas=UniversalCanvas,i.WavAudio=WavAudio,i.WebAudioPlayer=WebAudioPlayer,i.WebglCanvas=WebglCanvas,i.filename=ue,i.id=oe,i.loaders=_e,i.parse=Ae,i.parseSource=(...i)=>(console.warn("parseSource() is deprecated, please use parse() instead"),Ae(...i)),i.playlist=Pe,i.supportedEvents=Ce,i.version="6.3.0"}({}); //# sourceMappingURL=flipnote.webcomponent.min.js.map