Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cdgplayer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdgplayer - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

4

dist/cdgplayer.js
/**
* @package CDGPlayer
* @version 0.1.4
* @version 0.1.5
* @license GPLv3

@@ -28,3 +28,3 @@ * @copyright Copyright (c) 2018 Stephen G Blades, Jr (AKA 'Cutter')

*/
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function u(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t))&&"[object Arguments]"!==Object.prototype.toString.call(t))return;var i=[],n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(i.push(s.value),!e||i.length!==e);n=!0);}catch(t){r=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function l(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}l(".cdg-video-wrapper{position:relative;text-align:center;background-color:#000}.cdg-video-wrapper .cdg-video-player{position:relative;width:72%;margin:0 auto}.cdg-video-wrapper .titleImage{position:absolute;top:0;left:0;width:100%;height:100%;z-index:auto;background-color:transparent}.cdg-video-wrapper .titleImage.hide{display:none}");var c=[6,12,294,204],h=["top","bottom"],f=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.width,o=void 0===r?300:r,s=i.height,a=void 0===s?216:s,u=i.canvas,l=void 0===u?this.createCanvas(o,a):u,c=i.ctx,h=void 0===c?this.createCanvasContext(l):c,f=i.imageData,p=void 0===f?this.createImageData(l,h,o,a):f;t(this,e),n(this,"hOffset",0),n(this,"vOffset",0),n(this,"keyColor",null),n(this,"backgroundContainer",null),n(this,"borderColor",null),n(this,"memoryColor",null),n(this,"clut",new Array(16).fill([0,0,0])),n(this,"pixels",new Array(64800).fill(0)),n(this,"buffer",new Array(64800).fill(0)),this.canvas=l,this.ctx=h,this.imageData=p}return i(e,[{key:"createCanvas",value:function(t,e){var i=document.createElement("canvas");return i.width=t,i.height=e,i}},{key:"createCanvasContext",value:function(t){var e=t.getContext("2d");return e.mozImageSmoothingEnabled=!1,e.webkitImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}},{key:"createImageData",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.width,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.height;return e.createImageData(i,n)}},{key:"reset",value:function(){this.hOffset=0,this.vOffset=0,this.keyColor=null,this.backgroundColor=null,this.borderColor=null,this.memoryColor=null,this.pixels.fill(0)}},{key:"setCLUTEntry",value:function(t,e,i,n){this.clut[t]=[e,i,n].map((function(t){return 17*t}))}},{key:"setPixel",value:function(t,e,i){this.pixels[t+300*e]=i}},{key:"getPixel",value:function(t,e){return this.pixels[t+300*e]}},{key:"getBackground",value:function(){switch(!0){case null!=this.keyColor:return this.keyColor;case null!=this.backgroundColor:return this.backgroundColor;case null!=this.memoryColor:return this.memoryColor;case null!=this.borderColor:return this.borderColor;default:return 0}}},{key:"generateImageData",value:function(){for(var t=0;t<300;t++)for(var e=0;e<216;e++){var i=4*(t+300*e),n=(t-this.hOffset+300)%300+300*((e-this.vOffset+216)%216),r=this.pixels[n],o=u(this.clut[r],3),s=o[0],a=o[1],l=o[2];this.imageData.data[i]=s,this.imageData.data[i+1]=a,this.imageData.data[i+2]=l,this.imageData.data[i+3]=r===this.keyColor?0:255}return this.imageData}},{key:"renderFrame",value:function(){this.ctx.putImageData(this.generateImageData(),0,0)}}]),e}();function p(){var t;console&&console.warn&&(t=console).warn.apply(t,arguments)}var d=function(){function e(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,e),this.bytes=i.slice(n,n+24)}return i(e,[{key:"instruction",get:function(){return this.constructor.instruction}},{key:"opcode",get:function(){return this.constructor.opcode}}]),i(e,[{key:"execute",value:function(){}},{key:"bytecodeToString",value:function(){return this.bytes.map((function(t){return t.toString(16).padStart(2,"0")})).join("")}},{key:"detailsToString",value:function(){return""}},{key:"toString",value:function(){return this.instruction}}]),e}();n(d,"instruction",""),n(d,"opcode",null);var v=function(e){function i(){return t(this,i),a(this,o(i).apply(this,arguments))}return r(i,d),i}();n(v,"instruction","No-op"),n(v,"opcode",0);var g=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,n);var s=r+4;return(i=a(this,o(n).call(this,e,r))).color=15&e[s],i.repeat=15&e[s+1],i}return r(n,d),i(n,[{key:"execute",value:function(t){t.memoryColor=this.color,t.backgroundColor=this.color,t.pixels.fill(this.color)}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),n}();n(g,"instruction","Memory Preset"),n(g,"opcode",1);var m=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,n),(i=a(this,o(n).call(this,e,r))).color=15&e[r+4],i}return r(n,d),i(n,[{key:"execute",value:function(t){t.borderColor=this.color,t.backgroundColor=this.color;for(var e=u(c,4),i=e[0],n=e[1],r=e[2],o=e[3],s=0;s<300;s++){for(var a=0;a<n;a++)t.setPixel(s,a,this.color);for(var l=o+1;l<216;l++)t.setPixel(s,l,this.color)}for(var h=n;h<=o;h++){for(var f=0;f<i;f++)t.setPixel(f,h,this.color);for(var p=r+1;p<300;p++)t.setPixel(p,h,this.color)}}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),n}();n(m,"instruction","Border Preset"),n(m,"opcode",2);var y=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,n);var s=r+4;return(i=a(this,o(n).call(this,e,r))).colors=[15&e[s],15&e[s+1]],i.row=31&e[s+2],i.column=63&e[s+3],i.pixels=e.slice(s+4,s+16),i}return r(n,d),i(n,[{key:"execute",value:function(t){var e=6*this.column,i=12*this.row;if(e+6>300||i+12>216)p("TileBlock out of bounds (".concat(this.row,", ").concat(this.column,")"));else for(var n=0;n<12;n++)for(var r=this.pixels[n],o=0;o<6;o++){var s=this.colors[r>>5-o&1];this.op(t,e+o,i+n,s)}}},{key:"op",value:function(t,e,i,n){t.setPixel(e,i,n)}},{key:"detailsToString",value:function(){return"row: ".concat(this.row,", column: ").concat(this.column,", color indexes: [").concat(this.colors.join(", "),"]")}}]),n}();n(y,"instruction","Tile Block"),n(y,"opcode",6);var A=function(e){function n(){return t(this,n),a(this,o(n).apply(this,arguments))}return r(n,y),i(n,[{key:"op",value:function(t,e,i,n){t.setPixel(e,i,t.getPixel(e,i)^n)}}]),n}();n(A,"instruction","Tile Block (XOR)"),n(A,"opcode",38);var k=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,n);var s=r+4;(i=a(this,o(n).call(this,e,r))).color=15&e[s];var u=63&e[s+1];i.hCmd=(48&u)>>4,i.hOffset=7&u;var l=63&e[s+2];return i.vCmd=(48&l)>>4,i.vOffset=15&l,i}return r(n,d),i(n,[{key:"execute",value:function(t){t.backgroundColor=this.color,t.hOffset=Math.min(this.hOffset,5),t.vOffset=Math.min(this.vOffset,11);var e=0;switch(this.hCmd){case 2:e=6;break;case 1:e=-6}var i=0;switch(this.hCmd){case 2:i=12;break;case 1:i=-12}if(e||i){for(var n=0;n<300;n++)for(var r=0;r<216;r++)t.buffer[n+300*r]=this.getPixel(t,n+e,r+i);var o=[t.buffer,t.pixels];t.pixels=o[0],t.buffer=o[1]}}},{key:"getPixel",value:function(t,e,i){return e>0&&e<300&&i>0&&i<216?t.pixels[e+300*i]:this.color}},{key:"detailsToString",value:function(){var t=!1,e=!1;return 1===this.vCmd?t="up":2===this.vCmd&&(t="down"),1===this.vCmd?e="left":2===this.vCmd&&(e="right"),[t,e,"vOffset: ".concat(this.vOffset),"hOffset: ".concat(this.hOffset)].filter((function(t){return t})).join(" ")}}]),n}();n(k,"instruction","Scroll Preset"),n(k,"opcode",20);var b=function(e){function n(){return t(this,n),a(this,o(n).apply(this,arguments))}return r(n,k),i(n,[{key:"getPixel",value:function(t,e,i){return e=(e+300)%300,i=(i+216)%216,t.pixels[e+300*i]}}]),n}();n(b,"instruction","Scroll Copy"),n(b,"opcode",24);var w=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,n),(i=a(this,o(n).call(this,e,r))).color=15&e[r+4],i}return r(n,d),i(n,[{key:"execute",value:function(t){t.keyColor=this.color}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),n}();n(w,"instruction","Set Key Color"),n(w,"opcode",28);var B=function(e){function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,n);var s=r+4;(i=a(this,o(n).call(this,e,r))).colors=[];for(var u=0;u<8;u++){var l=s+2*u,c=((63&e[l])<<6)+(63&e[l+1]);i.colors[u]=[c>>8,(240&c)>>4,15&c]}return i}return r(n,d),i(n,[{key:"clutOffset",get:function(){return 0}}]),i(n,[{key:"execute",value:function(t){for(var e=0;e<8;e++)t.setCLUTEntry(e+this.clutOffset,this.colors[e][0],this.colors[e][1],this.colors[e][2])}},{key:"detailsToString",value:function(){var t=this;return"colors: [".concat(this.colors.map((function(e,i){return"".concat(i+t.clutOffset,": #").concat(e.map((function(t){return t.toString(16)})).join(""))})).join(", "),"]")}}]),n}();n(B,"instruction","Load CLUT (Low)"),n(B,"opcode",30);var x=function(e){function n(){return t(this,n),a(this,o(n).apply(this,arguments))}return r(n,B),i(n,[{key:"clutOffset",get:function(){return 8}}]),n}();n(x,"instruction","Load CLUT (High)"),n(x,"opcode",31);var C=function(){function e(){t(this,e),n(this,"instructionClassByType",this.constructor.instructionClassByType)}return i(e,[{key:"registerInstruction",value:function(t,e){this.instructionClassByType[t]=e}},{key:"createInstruction",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t in this.instructionClassByType||p("Unknown CDG instruction (instruction = ".concat(t,")"));var n=this.instructionClassByType[t]||v;return new n(e,i)}},{key:"parseInstruction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=63&t[e];if(9===i){var n=63&t[e+1];return this.createInstruction(n,t,e)}return new v(t,e)}},{key:"parseInstructions",value:function(t){for(var e=[],i=t.length,n=0;n<i;n+=24)e.push(this.parseInstruction(t,n));return e.filter((function(t){return t}))}}],[{key:"instructionClassByType",get:function(){var t;return n(t={},0,v),n(t,1,g),n(t,2,m),n(t,6,y),n(t,20,k),n(t,24,b),n(t,28,w),n(t,30,B),n(t,31,x),n(t,38,A),t}}]),e}();function P(){if("undefined"!=typeof performance&&"function"==typeof performance.now)return performance.now();if("undefined"!=typeof process&&"function"==typeof process.hrtime){var t=u(process.hrtime(),2);return 1e3*t[0]+t[1]/1e6}return Date.now()}function S(t){return"function"==typeof requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,25)}var _=function(){function e(){var i=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.contextOptions,s=void 0===o?{}:o,a=r.context,u=void 0===a?this.createContext(s):a,l=r.afterRender;t(this,e),n(this,"instructions",[]),n(this,"pc",-1),n(this,"frameId",null),n(this,"pos",0),n(this,"lastSyncPos",null),n(this,"lastTimestamp",null),n(this,"update",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:P();if(-1===i.pc)return i;i.frameId=S(i.update),i.lastSyncPos?i.pos=i.lastSyncPos+(t-i.lastTimestamp):(i.pos+=t-i.lastTimestamp,i.lastTimestamp=t);var e=Math.floor(i.pos/1e3*300),n=e-i.pc;return n>0&&(i.fastForward(n),i.render()),i})),this.context=u,this.afterRender=l}return i(e,[{key:"createContext",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new f(t)}},{key:"load",value:function(t){var e=new C;return this.instructions=e.parseInstructions(t),this.reset(),this}},{key:"reset",value:function(){return this.pc=0,this.pos=0,this.lastSyncPos=null,this.context.reset(),this}},{key:"render",value:function(){return this.context.renderFrame(),this.afterRender&&this.afterRender(this.context),this}},{key:"executeInstruction",value:function(t){return t&&"function"==typeof t.execute&&t.execute(this.context),this}},{key:"step",value:function(){return this.pc>=0&&this.pc<this.instructions.length?(this.executeInstruction(this.instructions[this.pc]),this.pc+=1):(this.pc=-1,this.stop()),this}},{key:"fastForward",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this.pc+t;this.pc>=0&&this.pc<e;)this.step();return this}},{key:"play",value:function(){return this.frameId||(this.frameId=S(this.update),this.lastTimestamp=P()),this}},{key:"stop",value:function(){var t;return t=this.frameId,"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t),this.frameId=null,this.lastSyncPos=null,this}},{key:"sync",value:function(t){return this.lastSyncPos=t,this.lastTimestamp=P(),this}}]),e}(),L=function(){return"undefined"!=typeof Promise&&Promise.defer?Promise.defer():"undefined"!=typeof PromiseUtils&&PromiseUtils.defer?PromiseUtils.defer():(this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),void Object.freeze(this))},I=function(t){return JSZip.loadAsync(t).catch((function(t){return Promise.reject(new Error("There was an error reading the zip file.",t))}))},E=function(t){var e=t.filter((function(t){return t.endsWith(".cdg")||t.endsWith(".mp3")}));return 2===e.length?Promise.resolve(e):Promise.reject("The file is not a karaoke .zip file")},O=function(t){var e=t.filter((function(t){return t.name.endsWith(".mp3")})),i=t.filter((function(t){return t.name.endsWith(".cdg")})),n=[];if(e.length&&i.length)return n.push(e[0].async("arraybuffer").catch((function(){return Promise.reject(new Error("Unable to load the audio file"))}))),n.push(function(t){return t.async("uint8array").catch((function(){return Promise.reject(new Error("Unable to load the video file"))}))}(i[0])),n.push(function(t){return t.async("blob").then((function(e){return new Promise((function(i){new jsmediatags.Reader(e).setTagsToRead(["title","artist","album","track","year","genre","picture"]).read({onSuccess:function(t){return i(t)},onError:function(){return i((e=t.name,n=e.split(" - "),(r={tags:{}}).tags.album=n[0].trim(),r.tags.artist=n[1]?n[1].trim():r.tags.album,r.tags.title=n[2]?n[2].trim():r.tags.artist,r));var e,n,r}})}))})).catch((function(){return Promise.reject(new Error("Unable to parse tag data"))}))}(e[0])),Promise.all(n).catch((function(){return Promise.reject(new Error("Processing audio and video failed"))}));var r=[];return e.length||r.push("No mp3 audio file present."),i.length||r.push("No cdg video file present."),Promise.reject(new Error(r.join(" ")))},T=function(){function e(){t(this,e)}return i(e,null,[{key:"loadZipFile",value:function(t){return function(t){var e=new L;return JSZipUtils.getBinaryContent(t,(function(i,n){i?e.reject(new Error("There was an error retrieving ".concat(t),i)):e.resolve(n)})),e.promise}(t).then((function(t){return I(t)})).then((function(t){return E(t)})).then((function(t){return O(t)})).catch((function(t){return Promise.reject(t)}))}},{key:"loadFileBuffer",value:function(t){return I(t).then((function(t){return E(t)})).then((function(t){return O(t)})).catch((function(t){return Promise.reject(t)}))}}]),e}();function R(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function j(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function M(t,e,i){return e&&j(t.prototype,e),i&&j(t,i),t}function D(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&F(t,e)}function Y(t){return(Y=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function F(t,e){return(F=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function H(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function z(t,e,i){return(z="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=Y(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(i):r.value}})(t,e,i||t)}var q=function(){function t(){R(this,t),this._vector=new Float32Array,this._position=0,this._frameCount=0}return M(t,[{key:"clear",value:function(){this.receive(this._frameCount),this.rewind()}},{key:"put",value:function(t){this._frameCount+=t}},{key:"putSamples",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=2*(e=e||0);i>=0||(i=(t.length-n)/2);var r=2*i;this.ensureCapacity(i+this._frameCount);var o=this.endIndex;this.vector.set(t.subarray(n,n+r),o),this._frameCount+=i}},{key:"putBuffer",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}},{key:"receive",value:function(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}},{key:"receiveSamples",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=2*e,n=this.startIndex;t.set(this._vector.subarray(n,n+i)),this.receive(e)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.startIndex+2*e,r=2*i;t.set(this._vector.subarray(n,n+r))}},{key:"ensureCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=parseInt(2*t);if(this._vector.length<e){var i=new Float32Array(e);i.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=i,this._position=0}else this.rewind()}},{key:"ensureAdditionalCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+t)}},{key:"rewind",value:function(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}},{key:"vector",get:function(){return this._vector}},{key:"position",get:function(){return this._position}},{key:"startIndex",get:function(){return 2*this._position}},{key:"frameCount",get:function(){return this._frameCount}},{key:"endIndex",get:function(){return 2*(this._position+this._frameCount)}}]),t}(),N=function(){function t(e){R(this,t),e?(this._inputBuffer=new q,this._outputBuffer=new q):this._inputBuffer=this._outputBuffer=null}return M(t,[{key:"clear",value:function(){this._inputBuffer.clear(),this._outputBuffer.clear()}},{key:"inputBuffer",get:function(){return this._inputBuffer},set:function(t){this._inputBuffer=t}},{key:"outputBuffer",get:function(){return this._outputBuffer},set:function(t){this._outputBuffer=t}}]),t}(),U=function(t){function e(t){var i;return R(this,e),(i=H(this,Y(e).call(this,t))).reset(),i._rate=1,i}return D(e,N),M(e,[{key:"reset",value:function(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}},{key:"clone",value:function(){var t=new e;return t.rate=this._rate,t}},{key:"process",value:function(){var t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);var e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}},{key:"transpose",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===t)return 0;for(var e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,n=this._outputBuffer.vector,r=this._outputBuffer.endIndex,o=0,s=0;this.slopeCount<1;)n[r+2*s]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],n[r+2*s+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],s+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,(o+=1)>=t-1)break t;var a=i+2*o;n[r+2*s]=(1-this.slopeCount)*e[a]+this.slopeCount*e[a+2],n[r+2*s+1]=(1-this.slopeCount)*e[a+1]+this.slopeCount*e[a+3],s+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],s}},{key:"rate",set:function(t){this._rate=t}}]),e}(),W=function(){function t(e){R(this,t),this._pipe=e}return M(t,[{key:"fillInputBuffer",value:function(){throw new Error("fillInputBuffer() not overridden")}},{key:"fillOutputBuffer",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.outputBuffer.frameCount<t;){var e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}},{key:"clear",value:function(){this._pipe.clear()}},{key:"pipe",get:function(){return this._pipe}},{key:"inputBuffer",get:function(){return this._pipe.inputBuffer}},{key:"outputBuffer",get:function(){return this._pipe.outputBuffer}}]),t}(),Q=function(){},G=function(t){function e(t,i){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Q;return R(this,e),(n=H(this,Y(e).call(this,i))).callback=r,n.sourceSound=t,n.historyBufferSize=22050,n._sourcePosition=0,n.outputBufferPosition=0,n._position=0,n}return D(e,W),M(e,[{key:"onEnd",value:function(){this.callback()}},{key:"fillInputBuffer",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+e);var i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);var n=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,n),this.outputBuffer.receive(Math.max(n-this.historyBufferSize,0)),this._position+=i,i}},{key:"handleSampleData",value:function(t){this.extract(t.data,4096)}},{key:"clear",value:function(){z(Y(e.prototype),"clear",this).call(this),this.outputBufferPosition=0}},{key:"position",get:function(){return this._position},set:function(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");var e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}},{key:"sourcePosition",get:function(){return this._sourcePosition},set:function(t){this.clear(),this._sourcePosition=t}}]),e}(),J=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],Z=function(t){function e(t){var i;return R(this,e),(i=H(this,Y(e).call(this,t)))._quickSeek=!0,i.midBufferDirty=!1,i.midBuffer=null,i.overlapLength=0,i.autoSeqSetting=!0,i.autoSeekSetting=!0,i._tempo=1,i.setParameters(44100,0,0,8),i}return D(e,N),M(e,[{key:"clear",value:function(){z(Y(e.prototype),"clear",this).call(this),this.clearMidBuffer()}},{key:"clearMidBuffer",value:function(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}},{key:"setParameters",value:function(t,e,i,n){t>0&&(this.sampleRate=t),n>0&&(this.overlapMs=n),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}},{key:"calculateOverlapLength",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=(t=this.sampleRate*e/1e3)<16?16:t,t-=t%8,this.overlapLength=t,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}},{key:"checkLimits",value:function(t,e,i){return t<e?e:t>i?i:t}},{key:"calculateSequenceParameters",value:function(){var t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=25- -10/1.5*.5+-10/1.5*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}},{key:"clone",value:function(){var t=new e;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}},{key:"seekBestOverlapPosition",value:function(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}},{key:"seekBestOverlapPositionStereo",value:function(){var t,e,i,n=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;n<this.seekLength;n+=1)(i=this.calculateCrossCorrelationStereo(2*n,this.refMidBuffer))>e&&(e=i,t=n);return t}},{key:"seekBestOverlapPositionStereoQuick",value:function(){var t,e,i,n,r,o=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,n=0,r=0;o<4;o+=1){for(var s=0;J[o][s]&&!((r=n+J[o][s])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>e&&(e=i,t=r),s+=1;n=t}return t}},{key:"preCalculateCorrelationReferenceStereo",value:function(){for(var t,e,i=0;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}},{key:"calculateCrossCorrelationStereo",value:function(t,e){var i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var n,r=0,o=2,s=2*this.overlapLength;o<s;o+=2)r+=i[n=o+t]*e[o]+i[n+1]*e[o+1];return r}},{key:"overlap",value:function(t){this.overlapStereo(2*t)}},{key:"overlapStereo",value:function(t){var e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var i,n,r,o,s,a=this._outputBuffer.vector,u=this._outputBuffer.endIndex,l=0,c=1/this.overlapLength;l<this.overlapLength;l+=1)n=(this.overlapLength-l)*c,r=l*c,o=(i=2*l)+t,a[(s=i+u)+0]=e[o+0]*r+this.midBuffer[i+0]*n,a[s+1]=e[o+1]*r+this.midBuffer[i+1]*n}},{key:"process",value:function(){var t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),(e=this.seekWindowLength-2*this.overlapLength)>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);var n=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(n,n+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}},{key:"tempo",set:function(t){var e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength},get:function(){return this._tempo}},{key:"inputChunkSize",get:function(){return this.sampleReq}},{key:"outputChunkSize",get:function(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}},{key:"quickSeek",set:function(t){this._quickSeek=t}}]),e}(),V=function(t,e){return(t>e?t-e:e-t)>1e-10},K=function(){function t(){R(this,t),this.transposer=new U(!1),this.stretch=new Z(!1),this._inputBuffer=new q,this._intermediateBuffer=new q,this._outputBuffer=new q,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}return M(t,[{key:"clear",value:function(){this.transposer.clear(),this.stretch.clear()}},{key:"clone",value:function(){var e=new t;return e.rate=this.rate,e.tempo=this.tempo,e}},{key:"calculateEffectiveRateAndTempo",value:function(){var t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,V(this._tempo,t)&&(this.stretch.tempo=this._tempo),V(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}},{key:"process",value:function(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}},{key:"rate",get:function(){return this._rate},set:function(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}},{key:"rateChange",set:function(t){this._rate=1+.01*t}},{key:"tempo",get:function(){return this._tempo},set:function(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}},{key:"tempoChange",set:function(t){this.tempo=1+.01*t}},{key:"pitch",set:function(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}},{key:"pitchOctaves",set:function(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}},{key:"pitchSemitones",set:function(t){this.pitchOctaves=t/12}},{key:"inputBuffer",get:function(){return this._inputBuffer}},{key:"outputBuffer",get:function(){return this._outputBuffer}}]),t}(),X=function(){function t(e){R(this,t),this.buffer=e,this._position=0}return M(t,[{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var n=this.buffer.getChannelData(0),r=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),o=0;o<e;o++)t[2*o]=n[o+i],t[2*o+1]=r[o+i];return Math.min(e,n.length-i)}},{key:"dualChannel",get:function(){return this.buffer.numberOfChannels>1}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}}]),t}(),$=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Q,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4096,r=t.createScriptProcessor(n,2,2),o=new Float32Array(2*n);return r.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=e.extract(o,n);i(e.sourcePosition),0===a&&e.onEnd();for(var u=0;u<a;u++)r[u]=o[2*u],s[u]=o[2*u+1]},r},tt=function(t){var e,i,n,r=Math.floor(t/60),o=t-60*r;return"".concat(r,":").concat((e=parseInt(o),n=n||"0",(e+="").length>=(i=2)?e:new Array(i-e.length+1).join(n)+e))},et=function(t){var e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){var n=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(n)}},it=function(){function t(e,i,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Q;R(this,t),this._soundtouch=new K;var s=new X(i);this.timePlayed=0,this.sourcePosition=0,this._filter=new G(s,this._soundtouch,o),this._node=$(e,this._filter,(function(t){return et.call(r,t)}),n),this.tempo=1,this.rate=1,this.duration=i.duration,this.sampleRate=e.sampleRate,this.listeners=[]}return M(t,[{key:"connect",value:function(t){this._node.connect(t)}},{key:"disconnect",value:function(){this._node.disconnect()}},{key:"on",value:function(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(function(t){return e(t.detail)}))}},{key:"off",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this.listeners;e&&(i=i.filter((function(t){return t.name===e}))),i.forEach((function(e){t._node.removeEventListener(e.name,(function(t){return e.cb(t.detail)}))}))}},{key:"formattedDuration",get:function(){return tt(this.duration)}},{key:"formattedTimePlayed",get:function(){return tt(this.timePlayed)}},{key:"percentagePlayed",get:function(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)},set:function(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate)}},{key:"node",get:function(){return this._node}},{key:"pitch",set:function(t){this._soundtouch.pitch=t}},{key:"pitchSemitones",set:function(t){this._soundtouch.pitchSemitones=t}},{key:"rate",set:function(t){this._soundtouch.rate=t}},{key:"tempo",set:function(t){this._soundtouch.tempo=t}}]),t}(),nt=function(){function e(){t(this,e),this.fns={any:[]}}return i(e,[{key:"has",value:function(t){return t in this.fns&&this.fns[t].length>0||this.fns.any.length>0}},{key:"on",value:function(t,e){return t in this.fns==!1&&(this.fns[t]=[]),this.fns[t].push(e),e}},{key:"fire",value:function(t,e,i){return this.fns.any.concat(t in this.fns?this.fns[t]:[]).forEach((function(n){return n(e,i,t)})),this}},{key:"off",value:function(t){for(var e in this.fns)for(var i=this.fns[e],n=0;n<i.length;n++)if(i[n]===t)return i.splice(n,1),!0;return!1}},{key:"once",value:function(t,e){var i=this;return this.on(t,(function t(n,r,o){e(n,r,o),i.off(t)})),e}}]),e}(),rt=function(t){if(t.on&&t.off)return t;var e=new nt,i=new Proxy(t,{get:function(t,n){if(n in t){if(t.constructor===Array){var r=i;"pop"===n?r=t[t.length-1]:"shift"===n&&(r=t[0]),"push"!==n&&"length"!==n&&e.fire(n,r)}return t[n]}return"on"===n?e.on.bind(e):"once"===n?e.once.bind(e):"off"===n?e.off.bind(e):void 0},set:function(t,i,n){return t.constructor===Array?"length"!==i&&e.fire("change",n):e.has(i)&&e.fire(i,n,t[i]),t[i]=n,!0}});return i},ot=function(t){t.keyColor>=0&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(t.canvas,0,0,t.canvas.width,t.canvas.height,0,0,this.canvas.width,this.canvas.height)},st=function(t,e){t.clearRect(0,0,e.width,e.height)},at=function(t){var e=this;return this.shifter&&this.shifter.off(),this.audio.decodeAudioData(t).then((function(t){e.shifter=rt(new it(e.audio,t,1024,(function(){e.stop()}))),e.shifter.on("play",(function(t){e.props.timePlayed=t.formattedTimePlayed,e.props.percentagePlayed=t.percentagePlayed,e.player.sync(1e3*t.timePlayed-800)})),e.shifter.pitch=1,e.props.trackLength=e.shifter.formattedDuration})).catch((function(t){return Promise.reject(new Error("There was an error decoding the audio file",t))}))},ut=function(t){var e=new L;return t?(this.player.load(Array.from(t)),e.resolve()):e.reject(new Error("There was an error loading the video file")),e.promise},lt=function(t,e,i,n,r,o){for(var s=e.split(" "),a="",u=0;u<s.length;u++){var l=a+s[u]+" ";t.measureText(l).width>r&&u>0?(t.fillText(a.trim(),i,n),a=s[u]+" ",n+=o):a=l}t.fillText(a.trim(),i,n)},ct=function(){var t=this.ctx,e=this.canvas,i=e.width-10,n=i/2,r=60;t.font="30px sans-serif",t.fillStyle="#fff",t.textAlign="center",lt(t,this.tag.title,n,r,i,30),t.font="20px sans-serif",r=e.height-60,lt(t,"by ".concat(this.tag.artist),n,r,i,30)},ht=function(t){if(this.tag=t&&t.tags,this.tag)return ct.call(this)},ft=function(t){var e=this,i=[];return i.push(at.call(this,t[0])),i.push(ut.call(this,t[1])),Promise.all(i).then((function(){e.props.status="File Loaded",e.props.loaded=!0,ht.call(e,t[2])})).catch((function(t){return e.props.status="File Loading Failed",Promise.reject(t)})).then((function(){e.props.loading=!1}))},pt=function(t){this.gainNode.gain.value=t},dt=function(){function e(i){var r,o,s,a=this;if(t(this,e),n(this,"audio",null),n(this,"gainNode",null),n(this,"shifter",null),n(this,"wrapper",null),n(this,"player",null),n(this,"currentSize",1),n(this,"canvas",null),n(this,"ctx",null),n(this,"props",rt({status:"",loaded:!1,loading:!1,isPlaying:!1,timePlayed:"0:00",trackLength:"0:00",percentagePlayed:0,songVolume:1,destroy:!1})),this.wrapper=document.querySelector(i),!this.wrapper)throw new Error('CDGPlayer: and element was not found with the "'.concat(i,'" selector'));this.wrapper.classList.add("cdg-video-wrapper"),this.canvas=(r=300,o=216,(s=document.createElement("canvas")).width=r,s.height=o,s),this.canvas.classList.add("cdg-video-player"),this.ctx=function(t){var e=t.getContext("2d");return e.webkitImageSmoothingEnabled=!1,e.mozImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}(this.canvas),this.player=new _({afterRender:function(t){return ot.call(a,t)}}),this.wrapper.appendChild(this.canvas);var u=document.createElement("div");u.classList.add("titleImage"),this.wrapper.appendChild(u),this.onloaded=this.props.on("loaded",(function(t){t?u.classList.add("hide"):u.classList.remove("hide")})),this.audio=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.audio.createGain(),this.onvolume=this.props.on("songVolume",(function(t){pt.call(a,t)})),this.props.songVolume=1}return i(e,[{key:"destroy",value:function(){this.wrapper.classList.remove("cdg-video-wrapper"),this.stop(),this.gainNode.disconnect(),this.shifter&&this.shifter.off(),this.shifter=null,this.gainNode=null,this.audio=null,this.canvas.remove(),this.props.destroy=!0,this.props.off("onvolume")}},{key:"load",value:function(t){var e,i=this;if(this.stop(),st(this.ctx,this.canvas),this.props.loading=!0,"string"==typeof t){if(!t.toLowerCase().endsWith(".zip"))return this.props.loading=!1,this.props.status="".concat(t,' doesn\'t appear to be a ".zip" file.'),Promise.reject(this.props.status);this.props.status="Retrieving File...",e=T.loadZipFile(t)}else this.props.status="Loading File...",e=T.loadFileBuffer(t);return e.then((function(t){return ft.call(i,t)})).catch((function(t){return Promise.reject(t)}))}},{key:"togglePlay",value:function(){this.props.isPlaying?this.pause():this.start()}},{key:"start",value:function(){var t=this;st.call(this,this.ctx,this.canvas),this.shifter.connect(this.gainNode),this.gainNode.connect(this.audio.destination),this.audio.resume().then((function(){t.props.isPlaying=!0,t.player.play()}))}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.props.isPlaying=t,this.shifter.disconnect(),this.player.stop()}},{key:"stop",value:function(){this.shifter&&(this.pause(),this.changePlayerPosition(0),ct.call(this))}},{key:"changePlayerPosition",value:function(t){t=t<0?0:t>100?100:t,this.shifter.percentagePlayed=t,this.props.percentagePlayed=this.shifter.percentagePlayed,this.props.timePlayed=this.shifter.formattedTimePlayed,this.player.reset(),t||(this.props.isPlaying=!1,this.props.timePlayed="0:00")}},{key:"changeKey",value:function(t){t=t<-7?-7:t>7?7:t,this.shifter.pitchSemitones=t,this.shifter.tempo=1}},{key:"volume",value:function(t){var e=+(this.gainNode.gain.value+t).toFixed(2);this.props.songVolume=e<0?0:e>1?1:e}},{key:"toggleMute",value:function(){var t=this.gainNode.gain.value;this.props.songVolume=t?0:this.fallbackVolume,this.fallbackVolume=t}}]),e}(),vt='<cdg-controls> <span class="playControl"> <button class="playButton" disabled><i class="icofont-play-alt-1"></i></button> </span> <span class="timePlayed"></span> <div class="progress-container"> <progress class="progressMeter" ng-disabled="$ctrls.loading" value="0" max="100"></progress> </div> <span class="trackLength"></span> <span> <input type="number" class="pitch" step="1" min="-7" max="7" value="0" disabled> </span> <span class="volumeControl"> <div> <button class="volumeButton" id="song_volume_button" disabled><i class="icofont-audio"></i></button> <div class="volumeSlider"> <input type="range" min="0.00" max="1.00" step="0.01" class="volumeRange" id="song_volume"> </div> </div> </span> \x3c!-- <span class="volumeControl">\n <div>\n <button class="volumeButton" id="mic_volume_button"><i class="icofont-mic"></i></button>\n <div class="volumeSlider">\n <input type="range" min="0.0" max="1" step="0.1" class="volumeRange" id="mic_volume" />\n </div>\n </div>\n </span> --\x3e </cdg-controls>';l('@font-face{font-family:IcoFont;font-weight:400;font-style:normal;src:url("data:font/woff2;base64,d09GMgABAAAAAAXMAAsAAAAACvwAAAWAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGVgCDOAqJVIgXATYCJAMYCw4ABCAFhAoHVRtpCcgehXEsbKBS2ff0eD//bvrn5iZI8AbZnNUErxlUN8cqSmkqFgaZOO3UCHtqgjxR+3rwwHPL34lFvSywNDsu4naDTHgW0YYjGp7xP/z9TH/a1mBl6RiRb1HUZZE0HUfhgOLuLKK4wQ7wRPkUxHOgigy6cB9AAGgWDYilba0XlOcAPwdLkIJhBOpidJ4cD4BEtyAZVESiFxH2jb5DZ4ACxJV4DABO5BnoBdaAEEejIggutHFtHYWm//W/CtidOUJv5IH4ckEAAC0PMIDS49jQmegeg8tYKYx2IqQaIG+WIMBPN/xy069CRoKvR2KySwESdPgvD4BCwggIoBQCjVzC15ooN00aS2rtDSIHkOCXmzgAg19jJiBErSDKHo5BtOAuGoA2ACKHgFAKEKjwvQm47NAq9E61QafXiRardXL5+OXJZOWLaZT2zy+54plU4rWnll3mg0QwTtPHYgDRRZclEo7nUimE5rsH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Oj8gBoAnrT/vLVzrRWGrWs7kOpbv+YrefoAj2Zx0Tg7j/4tPLju5vMuBGbs7D+2Cc0/1+62WwB4nGNgZGBgAOIP9qt64vltvjJwM78AijBcPxB1Akb///8/i/kFczCQy8HABBIFAJztDyEAeJxjYGRgYA76nwUkX/z/DyIZgCIogA0Ai8sFm3icY37BwMCMgv//B9EAUrkHgQAAAAAAAACEAUwB3AIgAmoAAHicY2BkYGBgY+hkYGUAASYg5gJCBob/YD4DABbAAasAeJxdkE1qwzAQhZ/zS2MIhdKsStGqXRScn2UOkJBtFoYuHUd2HGzLyEogPUFP0BP0FD1A6bH6bKaLRkLSN2+epJEA3OIbHprmYdjOTeuQh8Jd0li4R74X7sPHg/CA+rPwCC8IhH3c4ZUneL0bKmPkwh3ym3CX/C7cI38I9zHBp/CA+pfwCCF+hH08eY+b2KxM6bY6PeWRzWKTMJIl1LbOTKnmwUyUtS61jZzeq91F1ed04VyiEmsK1Ryi89yoypqjjl1wcK5aTqeJ6EFsCmwQw2DFUcJhC40UJ74rgkXW5hLJ/Y9COi1qqk2sMOcfza48a3rK1hcx0tjTt8OFc40z71lQdXQrDss9BemvEs0acrJC1eaOVGLqAQ7trgpLTNmTK3/QVlD8AsE9WlYAeJxjYGKAAC4G7ICNkYmRmZGFkZWRjZGdgTk3M5kDiHVzS0tSWRNLUzLzuQpyEit1E3NKdA1ZCxJLi1MZGAD/FgxfAAA=") format("woff")}[class*=" icofont-"],[class^=icofont-]{font-family:IcoFont!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;white-space:nowrap;word-wrap:normal;direction:ltr;line-height:1;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}.icofont-mic:before{content:"\\ef95"}.icofont-mic-mute:before{content:"\\ef94"}.icofont-audio:before{content:"\\eea8"}.icofont-play-alt-1:before{content:"\\eca6"}.icofont-pause:before{content:"\\eca5"}.icofont-md,cdg-controls .playButton>i,cdg-controls .volumeButton>i{font-size:2em}.icofont-fw,cdg-controls .playButton>i,cdg-controls .volumeButton>i{text-align:center;width:1.25em}.mute,cdg-controls .pitch[disabled],cdg-controls .playButton[disabled],cdg-controls .volumeButton[disabled]{color:#a9a9a9}cdg-controls{position:relative;display:-ms-flexbox;display:-webkit-box;display:flex;height:40px;-ms-flex-direction:row;-webkit-box-orient:horizontal;-webkit-box-direction:normal;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:100%;font-size:1.25em}cdg-controls>div,cdg-controls>span{margin:3px 5px}cdg-controls>div:first-child,cdg-controls>span:first-child{margin-left:0}cdg-controls>div:last-child,cdg-controls>span:last-child{margin-right:0}cdg-controls .playButton,cdg-controls .volumeButton{outline:none;border:none;border-radius:3px;padding:5px;width:34px;height:34px}cdg-controls .playButton[disabled],cdg-controls .volumeButton[disabled]{cursor:not-allowed}cdg-controls .volumeControl>div{position:relative;width:100%;height:100%}cdg-controls .volumeControl>div:hover .volumeSlider{display:block}cdg-controls .volumeControl>div .volumeSlider{display:none;position:absolute;top:-75px;left:-55px;z-index:100;width:100px;-webkit-transform:rotate(270deg);transform:rotate(270deg);padding:10px 20px}cdg-controls .volumeControl>div .volumeSlider.under{top:75px;-webkit-transform:rotate(90deg);transform:rotate(90deg)}cdg-controls .volumeControl>div .volumeSlider:hover{display:block}cdg-controls .volumeControl>div .volumeSlider .volumeRange{-webkit-appearance:none;width:100%;height:5px;background:#d3d3d3;border:1px solid;border-radius:2.5px;outline:none;opacity:.7;-webkit-transition:.2s;-webkit-transition:opacity .2s;transition:opacity .2s}cdg-controls .volumeControl>div .volumeSlider .volumeRange:hover{opacity:1}cdg-controls .volumeControl>div .volumeSlider .volumeRange::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;border-radius:50%;border:1px solid #00f;background:#fff;cursor:pointer}cdg-controls .pitch{height:28px;font-size:.8em;text-align:right}cdg-controls .pitch[disabled]{cursor:not-allowed}cdg-controls .progress-container{position:relative;-webkit-box-flex:0;-ms-flex:0 1 auto;flex:0 1 auto;width:100%;display:inline-block}cdg-controls .progress-container progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;height:1em}cdg-controls .progress-container progress::-webkit-progress-bar{background-color:#eee;border-radius:.5em;-webkit-box-shadow:0 2px 5px rgba(0,0,0,.25) inset;box-shadow:inset 0 2px 5px rgba(0,0,0,.25)}cdg-controls .progress-container progress::-webkit-progress-value{background-image:-webkit-linear-gradient(-45deg,transparent 33%,transparent 0,rgba(0,0,0,.1) 66%,transparent 0),-webkit-linear-gradient(top,hsla(0,0%,100%,.25),rgba(0,0,0,.25)),-webkit-linear-gradient(left,#09c,#f44);border-radius:.5em;background-size:35px 20px,100% 100%,100% 100%}');var gt=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},mt=function(){var t=this,e=this.player.props;this.onloaded=e.on("loaded",(function(e){e?(t.playBtn.removeAttribute("disabled"),t.pitch.removeAttribute("disabled"),t.volumeBtn.removeAttribute("disabled")):(t.playBtn.setAttribute("disabled","disabled"),t.pitch.setAttribute("disabled","disabled"),t.volumeBtn.setAttribute("disabled","disabled"))})),this.ontimeplayed=e.on("timePlayed",(function(e,i){e!==i&&(t.timePlayed.innerHTML=e)})),this.onpercentageplayed=e.on("percentagePlayed",(function(e,i){e!==i&&(t.progress.value=e)})),this.ontracklength=e.on("trackLength",(function(e,i){e!==i&&(t.trackLength.innerHTML=e)})),this.ondestroy=e.on("destroy",(function(e){e&&yt.call(t)})),this.onplay=e.on("isPlaying",(function(e){t.playIcn.classList.remove("icofont-play-alt-1","icofont-pause"),t.playIcn.classList.add(e?"icofont-pause":"icofont-play-alt-1")})),this.onvolume=e.on("songVolume",(function(e){var i=t.volumeIcn;if(t.volumeSlider.value=e,e)return i.classList.contains("mute")?void i.classList.remove("mute"):void 0;i.classList.add("mute")})),this.playBtn.addEventListener("click",(function(){return t.player.togglePlay()})),this.progress.addEventListener("click",(function(e){return At.call(t,e)})),this.pitch.addEventListener("change",(function(){return kt.call(t)})),this.volumeSlider.addEventListener("change",(function(){return bt.call(t)}))},yt=function(){var t=this,e=this.player.props;e.off(this.onloaded),e.off(this.ontimeplayed),e.off(this.onpercentageplayed),e.off(this.ontracklength),e.off(this.ondestroy),e.off(this.onplay),e.off(this.onvolume),this.playBtn.removeEventListener("click",(function(){return t.player.togglePlay()})),this.progress.removeEventListener("click",(function(e){return At.call(t,e)})),this.pitch.removeEventListener("change",(function(){return kt.call(t)})),this.volumeSlider.removeEventListener("change",(function(){return bt.call(t)}))},At=function(t){var e=t.target.getBoundingClientRect(),i=(t.pageX-e.x)/t.target.offsetWidth;this.player.changePlayerPosition(i)},kt=function(){var t=this.pitch.value;isNaN(t)?this.pitch.value=this.fallbackPitch:(this.fallbackPitch=t<-7?-7:t>7?7:t,this.player.changeKey(this.fallbackPitch))},bt=function(){this.player.props.songVolume=+(parseFloat(this.volumeSlider.value)+0).toFixed(2)},wt=function e(i,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{position:"bottom"};t(this,e),n(this,"controls",gt(vt)),n(this,"player",null),n(this,"playBtn",null),n(this,"playIcn",null),n(this,"timePlayed",null),n(this,"progress",null),n(this,"trackLength",null),n(this,"pitch",null);var s=document.querySelector(i);s.appendChild(this.controls),this.player=r;var a=this.player.props;if(this.playBtn=this.controls.querySelector(".playButton"),this.playIcn=this.playBtn.querySelector("i"),this.timePlayed=this.controls.querySelector(".timePlayed"),this.timePlayed.innerHTML=a.timePlayed,this.progress=this.controls.querySelector(".progressMeter"),this.progress.value=a.percentagePlayed,this.trackLength=this.controls.querySelector(".trackLength"),this.trackLength.innerHTML=a.trackLength,this.pitch=this.controls.querySelector(".pitch"),this.fallbackPitch=0,!h.includes(o.position))throw new Error("Panel Position must be either 'top' or 'bottom'.");if(this.volumeBtn=this.controls.querySelector("#song_volume_button"),this.volumeIcn=this.volumeBtn.querySelector("i"),this.volumeSlider=this.controls.querySelector("#song_volume"),this.volumeSlider.value=a.songVolume,"top"===o.position){var u=this.controls.querySelector(".volumeSlider");u.classList.add("under")}mt.call(this)};export{wt as CDGControls,dt as CDGPlayer};
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function o(t){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(t){return function(){var e,i=o(t);if(a()){var n=o(this).constructor;e=Reflect.construct(i,arguments,n)}else e=i.apply(this,arguments);return u(this,e)}}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var i=[],n=!0,r=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(i.push(s.value),!e||i.length!==e);n=!0);}catch(t){r=!0,o=t}finally{try{n||null==a.return||a.return()}finally{if(r)throw o}}return i}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(i);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return h(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function f(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}f(".cdg-video-wrapper{position:relative;text-align:center;background-color:#000}.cdg-video-wrapper .cdg-video-player{position:relative;width:72%;margin:0 auto}.cdg-video-wrapper .titleImage{position:absolute;top:0;left:0;width:100%;height:100%;z-index:auto;background-color:transparent}.cdg-video-wrapper .titleImage.hide{display:none}");var p=[6,12,294,204],d=["top","bottom"],v=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.width,o=void 0===r?300:r,s=i.height,a=void 0===s?216:s,u=i.canvas,c=void 0===u?this.createCanvas(o,a):u,l=i.ctx,h=void 0===l?this.createCanvasContext(c):l,f=i.imageData,p=void 0===f?this.createImageData(c,h,o,a):f;t(this,e),n(this,"hOffset",0),n(this,"vOffset",0),n(this,"keyColor",null),n(this,"backgroundContainer",null),n(this,"borderColor",null),n(this,"memoryColor",null),n(this,"clut",new Array(16).fill([0,0,0])),n(this,"pixels",new Array(64800).fill(0)),n(this,"buffer",new Array(64800).fill(0)),this.canvas=c,this.ctx=h,this.imageData=p}return i(e,[{key:"createCanvas",value:function(t,e){var i=document.createElement("canvas");return i.width=t,i.height=e,i}},{key:"createCanvasContext",value:function(t){var e=t.getContext("2d");return e.mozImageSmoothingEnabled=!1,e.webkitImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}},{key:"createImageData",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.width,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.height;return e.createImageData(i,n)}},{key:"reset",value:function(){this.hOffset=0,this.vOffset=0,this.keyColor=null,this.backgroundColor=null,this.borderColor=null,this.memoryColor=null,this.pixels.fill(0)}},{key:"setCLUTEntry",value:function(t,e,i,n){this.clut[t]=[e,i,n].map((function(t){return 17*t}))}},{key:"setPixel",value:function(t,e,i){this.pixels[t+300*e]=i}},{key:"getPixel",value:function(t,e){return this.pixels[t+300*e]}},{key:"getBackground",value:function(){switch(!0){case null!=this.keyColor:return this.keyColor;case null!=this.backgroundColor:return this.backgroundColor;case null!=this.memoryColor:return this.memoryColor;case null!=this.borderColor:return this.borderColor;default:return 0}}},{key:"generateImageData",value:function(){for(var t=0;t<300;t++)for(var e=0;e<216;e++){var i=4*(t+300*e),n=(t-this.hOffset+300)%300+300*((e-this.vOffset+216)%216),r=this.pixels[n],o=l(this.clut[r],3),s=o[0],a=o[1],u=o[2];this.imageData.data[i]=s,this.imageData.data[i+1]=a,this.imageData.data[i+2]=u,this.imageData.data[i+3]=r===this.keyColor?0:255}return this.imageData}},{key:"renderFrame",value:function(){this.ctx.putImageData(this.generateImageData(),0,0)}}]),e}();function g(){var t;console&&console.warn&&(t=console).warn.apply(t,arguments)}var m=function(){function e(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,e),this.bytes=i.slice(n,n+24)}return i(e,[{key:"instruction",get:function(){return this.constructor.instruction}},{key:"opcode",get:function(){return this.constructor.opcode}}]),i(e,[{key:"execute",value:function(){}},{key:"bytecodeToString",value:function(){return this.bytes.map((function(t){return t.toString(16).padStart(2,"0")})).join("")}},{key:"detailsToString",value:function(){return""}},{key:"toString",value:function(){return this.instruction}}]),e}();n(m,"instruction",""),n(m,"opcode",null);var y=function(e){r(n,m);var i=c(n);function n(){return t(this,n),i.apply(this,arguments)}return n}();n(y,"instruction","No-op"),n(y,"opcode",0);var A=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).color=15&e[s],i.repeat=15&e[s+1],i}return i(o,[{key:"execute",value:function(t){t.memoryColor=this.color,t.backgroundColor=this.color,t.pixels.fill(this.color)}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(A,"instruction","Memory Preset"),n(A,"opcode",1);var k=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.borderColor=this.color,t.backgroundColor=this.color;for(var e=l(p,4),i=e[0],n=e[1],r=e[2],o=e[3],s=0;s<300;s++){for(var a=0;a<n;a++)t.setPixel(s,a,this.color);for(var u=o+1;u<216;u++)t.setPixel(s,u,this.color)}for(var c=n;c<=o;c++){for(var h=0;h<i;h++)t.setPixel(h,c,this.color);for(var f=r+1;f<300;f++)t.setPixel(f,c,this.color)}}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(k,"instruction","Border Preset"),n(k,"opcode",2);var b=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).colors=[15&e[s],15&e[s+1]],i.row=31&e[s+2],i.column=63&e[s+3],i.pixels=e.slice(s+4,s+16),i}return i(o,[{key:"execute",value:function(t){var e=6*this.column,i=12*this.row;if(e+6>300||i+12>216)g("TileBlock out of bounds (".concat(this.row,", ").concat(this.column,")"));else for(var n=0;n<12;n++)for(var r=this.pixels[n],o=0;o<6;o++){var s=this.colors[r>>5-o&1];this.op(t,e+o,i+n,s)}}},{key:"op",value:function(t,e,i,n){t.setPixel(e,i,n)}},{key:"detailsToString",value:function(){return"row: ".concat(this.row,", column: ").concat(this.column,", color indexes: [").concat(this.colors.join(", "),"]")}}]),o}();n(b,"instruction","Tile Block"),n(b,"opcode",6);var w=function(e){r(o,b);var n=c(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"op",value:function(t,e,i,n){t.setPixel(e,i,t.getPixel(e,i)^n)}}]),o}();n(w,"instruction","Tile Block (XOR)"),n(w,"opcode",38);var B=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).color=15&e[s];var a=63&e[s+1];i.hCmd=(48&a)>>4,i.hOffset=7&a;var u=63&e[s+2];return i.vCmd=(48&u)>>4,i.vOffset=15&u,i}return i(o,[{key:"execute",value:function(t){t.backgroundColor=this.color,t.hOffset=Math.min(this.hOffset,5),t.vOffset=Math.min(this.vOffset,11);var e=0;switch(this.hCmd){case 2:e=6;break;case 1:e=-6}var i=0;switch(this.hCmd){case 2:i=12;break;case 1:i=-12}if(e||i){for(var n=0;n<300;n++)for(var r=0;r<216;r++)t.buffer[n+300*r]=this.getPixel(t,n+e,r+i);var o=[t.buffer,t.pixels];t.pixels=o[0],t.buffer=o[1]}}},{key:"getPixel",value:function(t,e,i){return e>0&&e<300&&i>0&&i<216?t.pixels[e+300*i]:this.color}},{key:"detailsToString",value:function(){var t=!1,e=!1;return 1===this.vCmd?t="up":2===this.vCmd&&(t="down"),1===this.vCmd?e="left":2===this.vCmd&&(e="right"),[t,e,"vOffset: ".concat(this.vOffset),"hOffset: ".concat(this.hOffset)].filter((function(t){return t})).join(" ")}}]),o}();n(B,"instruction","Scroll Preset"),n(B,"opcode",20);var x=function(e){r(o,B);var n=c(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"getPixel",value:function(t,e,i){return e=(e+300)%300,i=(i+216)%216,t.pixels[e+300*i]}}]),o}();n(x,"instruction","Scroll Copy"),n(x,"opcode",24);var C=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.keyColor=this.color}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(C,"instruction","Set Key Color"),n(C,"opcode",28);var P=function(e){r(o,m);var n=c(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).colors=[];for(var a=0;a<8;a++){var u=s+2*a,c=((63&e[u])<<6)+(63&e[u+1]);i.colors[a]=[c>>8,(240&c)>>4,15&c]}return i}return i(o,[{key:"clutOffset",get:function(){return 0}}]),i(o,[{key:"execute",value:function(t){for(var e=0;e<8;e++)t.setCLUTEntry(e+this.clutOffset,this.colors[e][0],this.colors[e][1],this.colors[e][2])}},{key:"detailsToString",value:function(){var t=this;return"colors: [".concat(this.colors.map((function(e,i){return"".concat(i+t.clutOffset,": #").concat(e.map((function(t){return t.toString(16)})).join(""))})).join(", "),"]")}}]),o}();n(P,"instruction","Load CLUT (Low)"),n(P,"opcode",30);var S=function(e){r(o,P);var n=c(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"clutOffset",get:function(){return 8}}]),o}();n(S,"instruction","Load CLUT (High)"),n(S,"opcode",31);var _=function(){function e(){t(this,e),n(this,"instructionClassByType",this.constructor.instructionClassByType)}return i(e,[{key:"registerInstruction",value:function(t,e){this.instructionClassByType[t]=e}},{key:"createInstruction",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t in this.instructionClassByType||g("Unknown CDG instruction (instruction = ".concat(t,")"));var n=this.instructionClassByType[t]||y;return new n(e,i)}},{key:"parseInstruction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=63&t[e];if(9===i){var n=63&t[e+1];return this.createInstruction(n,t,e)}return new y(t,e)}},{key:"parseInstructions",value:function(t){for(var e=[],i=t.length,n=0;n<i;n+=24)e.push(this.parseInstruction(t,n));return e.filter((function(t){return t}))}}],[{key:"instructionClassByType",get:function(){var t;return n(t={},0,y),n(t,1,A),n(t,2,k),n(t,6,b),n(t,20,B),n(t,24,x),n(t,28,C),n(t,30,P),n(t,31,S),n(t,38,w),t}}]),e}();function L(){if("undefined"!=typeof performance&&"function"==typeof performance.now)return performance.now();if("undefined"!=typeof process&&"function"==typeof process.hrtime){var t=l(process.hrtime(),2);return 1e3*t[0]+t[1]/1e6}return Date.now()}function I(t){return"function"==typeof requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,25)}var E=function(){function e(){var i=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.contextOptions,s=void 0===o?{}:o,a=r.context,u=void 0===a?this.createContext(s):a,c=r.afterRender;t(this,e),n(this,"instructions",[]),n(this,"pc",-1),n(this,"frameId",null),n(this,"pos",0),n(this,"lastSyncPos",null),n(this,"lastTimestamp",null),n(this,"update",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L();if(-1===i.pc)return i;i.frameId=I(i.update),i.lastSyncPos?i.pos=i.lastSyncPos+(t-i.lastTimestamp):(i.pos+=t-i.lastTimestamp,i.lastTimestamp=t);var e=Math.floor(i.pos/1e3*300),n=e-i.pc;return n>0&&(i.fastForward(n),i.render()),i})),this.context=u,this.afterRender=c}return i(e,[{key:"createContext",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new v(t)}},{key:"load",value:function(t){var e=new _;return this.instructions=e.parseInstructions(t),this.reset(),this}},{key:"reset",value:function(){return this.pc=0,this.pos=0,this.lastSyncPos=null,this.context.reset(),this}},{key:"render",value:function(){return this.context.renderFrame(),this.afterRender&&this.afterRender(this.context),this}},{key:"executeInstruction",value:function(t){return t&&"function"==typeof t.execute&&t.execute(this.context),this}},{key:"step",value:function(){return this.pc>=0&&this.pc<this.instructions.length?(this.executeInstruction(this.instructions[this.pc]),this.pc+=1):(this.pc=-1,this.stop()),this}},{key:"fastForward",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this.pc+t;this.pc>=0&&this.pc<e;)this.step();return this}},{key:"play",value:function(){return this.frameId||(this.frameId=I(this.update),this.lastTimestamp=L()),this}},{key:"stop",value:function(){var t;return t=this.frameId,"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t),this.frameId=null,this.lastSyncPos=null,this}},{key:"sync",value:function(t){return this.lastSyncPos=t,this.lastTimestamp=L(),this}}]),e}(),O=function(){return"undefined"!=typeof Promise&&Promise.defer?Promise.defer():"undefined"!=typeof PromiseUtils&&PromiseUtils.defer?PromiseUtils.defer():(this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),void Object.freeze(this))},R=function(t){return JSZip.loadAsync(t).catch((function(t){return Promise.reject(new Error("There was an error reading the zip file.",t))}))},T=function(t){var e=t.filter((function(t){return t.endsWith(".cdg")||t.endsWith(".mp3")}));return 2===e.length?Promise.resolve(e):Promise.reject("The file is not a karaoke .zip file")},j=function(t){var e=t.filter((function(t){return t.name.endsWith(".mp3")})),i=t.filter((function(t){return t.name.endsWith(".cdg")})),n=[];if(e.length&&i.length)return n.push(e[0].async("arraybuffer").catch((function(){return Promise.reject(new Error("Unable to load the audio file"))}))),n.push(function(t){return t.async("uint8array").catch((function(){return Promise.reject(new Error("Unable to load the video file"))}))}(i[0])),n.push(function(t){return t.async("blob").then((function(e){return new Promise((function(i){new jsmediatags.Reader(e).setTagsToRead(["title","artist","album","track","year","genre","picture"]).read({onSuccess:function(t){return i(t)},onError:function(){return i((e=t.name,n=e.split(" - "),(r={tags:{}}).tags.album=n[0].trim(),r.tags.artist=n[1]?n[1].trim():r.tags.album,r.tags.title=n[2]?n[2].trim():r.tags.artist,r));var e,n,r}})}))})).catch((function(){return Promise.reject(new Error("Unable to parse tag data"))}))}(e[0])),Promise.all(n).catch((function(){return Promise.reject(new Error("Processing audio and video failed"))}));var r=[];return e.length||r.push("No mp3 audio file present."),i.length||r.push("No cdg video file present."),Promise.reject(new Error(r.join(" ")))},M=function(){function e(){t(this,e)}return i(e,null,[{key:"loadZipFile",value:function(t){return function(t){var e=new O;return JSZipUtils.getBinaryContent(t,(function(i,n){i?e.reject(new Error("There was an error retrieving ".concat(t),i)):e.resolve(n)})),e.promise}(t).then((function(t){return R(t)})).then((function(t){return T(t)})).then((function(t){return j(t)})).catch((function(t){return Promise.reject(t)}))}},{key:"loadFileBuffer",value:function(t){return R(t).then((function(t){return T(t)})).then((function(t){return j(t)})).catch((function(t){return Promise.reject(t)}))}}]),e}();function D(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Y(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function F(t,e,i){return e&&Y(t.prototype,e),i&&Y(t,i),t}function H(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&q(t,e)}function z(t){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function q(t,e){return(q=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function N(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function U(t,e,i){return(U="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=z(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(i):r.value}})(t,e,i||t)}var W=function(){function t(){D(this,t),this._vector=new Float32Array,this._position=0,this._frameCount=0}return F(t,[{key:"clear",value:function(){this.receive(this._frameCount),this.rewind()}},{key:"put",value:function(t){this._frameCount+=t}},{key:"putSamples",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=2*(e=e||0);i>=0||(i=(t.length-n)/2);var r=2*i;this.ensureCapacity(i+this._frameCount);var o=this.endIndex;this.vector.set(t.subarray(n,n+r),o),this._frameCount+=i}},{key:"putBuffer",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}},{key:"receive",value:function(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}},{key:"receiveSamples",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=2*e,n=this.startIndex;t.set(this._vector.subarray(n,n+i)),this.receive(e)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.startIndex+2*e,r=2*i;t.set(this._vector.subarray(n,n+r))}},{key:"ensureCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=parseInt(2*t);if(this._vector.length<e){var i=new Float32Array(e);i.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=i,this._position=0}else this.rewind()}},{key:"ensureAdditionalCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+t)}},{key:"rewind",value:function(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}},{key:"vector",get:function(){return this._vector}},{key:"position",get:function(){return this._position}},{key:"startIndex",get:function(){return 2*this._position}},{key:"frameCount",get:function(){return this._frameCount}},{key:"endIndex",get:function(){return 2*(this._position+this._frameCount)}}]),t}(),Q=function(){function t(e){D(this,t),e?(this._inputBuffer=new W,this._outputBuffer=new W):this._inputBuffer=this._outputBuffer=null}return F(t,[{key:"clear",value:function(){this._inputBuffer.clear(),this._outputBuffer.clear()}},{key:"inputBuffer",get:function(){return this._inputBuffer},set:function(t){this._inputBuffer=t}},{key:"outputBuffer",get:function(){return this._outputBuffer},set:function(t){this._outputBuffer=t}}]),t}(),G=function(t){function e(t){var i;return D(this,e),(i=N(this,z(e).call(this,t))).reset(),i._rate=1,i}return H(e,Q),F(e,[{key:"reset",value:function(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}},{key:"clone",value:function(){var t=new e;return t.rate=this._rate,t}},{key:"process",value:function(){var t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);var e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}},{key:"transpose",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===t)return 0;for(var e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,n=this._outputBuffer.vector,r=this._outputBuffer.endIndex,o=0,s=0;this.slopeCount<1;)n[r+2*s]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],n[r+2*s+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],s+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,(o+=1)>=t-1)break t;var a=i+2*o;n[r+2*s]=(1-this.slopeCount)*e[a]+this.slopeCount*e[a+2],n[r+2*s+1]=(1-this.slopeCount)*e[a+1]+this.slopeCount*e[a+3],s+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],s}},{key:"rate",set:function(t){this._rate=t}}]),e}(),J=function(){function t(e){D(this,t),this._pipe=e}return F(t,[{key:"fillInputBuffer",value:function(){throw new Error("fillInputBuffer() not overridden")}},{key:"fillOutputBuffer",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.outputBuffer.frameCount<t;){var e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}},{key:"clear",value:function(){this._pipe.clear()}},{key:"pipe",get:function(){return this._pipe}},{key:"inputBuffer",get:function(){return this._pipe.inputBuffer}},{key:"outputBuffer",get:function(){return this._pipe.outputBuffer}}]),t}(),Z=function(){},V=function(t){function e(t,i){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Z;return D(this,e),(n=N(this,z(e).call(this,i))).callback=r,n.sourceSound=t,n.historyBufferSize=22050,n._sourcePosition=0,n.outputBufferPosition=0,n._position=0,n}return H(e,J),F(e,[{key:"onEnd",value:function(){this.callback()}},{key:"fillInputBuffer",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+e);var i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);var n=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,n),this.outputBuffer.receive(Math.max(n-this.historyBufferSize,0)),this._position+=i,i}},{key:"handleSampleData",value:function(t){this.extract(t.data,4096)}},{key:"clear",value:function(){U(z(e.prototype),"clear",this).call(this),this.outputBufferPosition=0}},{key:"position",get:function(){return this._position},set:function(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");var e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}},{key:"sourcePosition",get:function(){return this._sourcePosition},set:function(t){this.clear(),this._sourcePosition=t}}]),e}(),K=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],X=function(t){function e(t){var i;return D(this,e),(i=N(this,z(e).call(this,t)))._quickSeek=!0,i.midBufferDirty=!1,i.midBuffer=null,i.overlapLength=0,i.autoSeqSetting=!0,i.autoSeekSetting=!0,i._tempo=1,i.setParameters(44100,0,0,8),i}return H(e,Q),F(e,[{key:"clear",value:function(){U(z(e.prototype),"clear",this).call(this),this.clearMidBuffer()}},{key:"clearMidBuffer",value:function(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}},{key:"setParameters",value:function(t,e,i,n){t>0&&(this.sampleRate=t),n>0&&(this.overlapMs=n),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}},{key:"calculateOverlapLength",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=(t=this.sampleRate*e/1e3)<16?16:t,t-=t%8,this.overlapLength=t,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}},{key:"checkLimits",value:function(t,e,i){return t<e?e:t>i?i:t}},{key:"calculateSequenceParameters",value:function(){var t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=25- -10/1.5*.5+-10/1.5*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}},{key:"clone",value:function(){var t=new e;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}},{key:"seekBestOverlapPosition",value:function(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}},{key:"seekBestOverlapPositionStereo",value:function(){var t,e,i,n=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;n<this.seekLength;n+=1)(i=this.calculateCrossCorrelationStereo(2*n,this.refMidBuffer))>e&&(e=i,t=n);return t}},{key:"seekBestOverlapPositionStereoQuick",value:function(){var t,e,i,n,r,o=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,n=0,r=0;o<4;o+=1){for(var s=0;K[o][s]&&!((r=n+K[o][s])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>e&&(e=i,t=r),s+=1;n=t}return t}},{key:"preCalculateCorrelationReferenceStereo",value:function(){for(var t,e,i=0;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}},{key:"calculateCrossCorrelationStereo",value:function(t,e){var i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var n,r=0,o=2,s=2*this.overlapLength;o<s;o+=2)r+=i[n=o+t]*e[o]+i[n+1]*e[o+1];return r}},{key:"overlap",value:function(t){this.overlapStereo(2*t)}},{key:"overlapStereo",value:function(t){var e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var i,n,r,o,s,a=this._outputBuffer.vector,u=this._outputBuffer.endIndex,c=0,l=1/this.overlapLength;c<this.overlapLength;c+=1)n=(this.overlapLength-c)*l,r=c*l,o=(i=2*c)+t,a[(s=i+u)+0]=e[o+0]*r+this.midBuffer[i+0]*n,a[s+1]=e[o+1]*r+this.midBuffer[i+1]*n}},{key:"process",value:function(){var t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),(e=this.seekWindowLength-2*this.overlapLength)>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);var n=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(n,n+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}},{key:"tempo",set:function(t){var e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength},get:function(){return this._tempo}},{key:"inputChunkSize",get:function(){return this.sampleReq}},{key:"outputChunkSize",get:function(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}},{key:"quickSeek",set:function(t){this._quickSeek=t}}]),e}(),$=function(t,e){return(t>e?t-e:e-t)>1e-10},tt=function(){function t(){D(this,t),this.transposer=new G(!1),this.stretch=new X(!1),this._inputBuffer=new W,this._intermediateBuffer=new W,this._outputBuffer=new W,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}return F(t,[{key:"clear",value:function(){this.transposer.clear(),this.stretch.clear()}},{key:"clone",value:function(){var e=new t;return e.rate=this.rate,e.tempo=this.tempo,e}},{key:"calculateEffectiveRateAndTempo",value:function(){var t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,$(this._tempo,t)&&(this.stretch.tempo=this._tempo),$(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}},{key:"process",value:function(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}},{key:"rate",get:function(){return this._rate},set:function(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}},{key:"rateChange",set:function(t){this._rate=1+.01*t}},{key:"tempo",get:function(){return this._tempo},set:function(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}},{key:"tempoChange",set:function(t){this.tempo=1+.01*t}},{key:"pitch",set:function(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}},{key:"pitchOctaves",set:function(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}},{key:"pitchSemitones",set:function(t){this.pitchOctaves=t/12}},{key:"inputBuffer",get:function(){return this._inputBuffer}},{key:"outputBuffer",get:function(){return this._outputBuffer}}]),t}(),et=function(){function t(e){D(this,t),this.buffer=e,this._position=0}return F(t,[{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var n=this.buffer.getChannelData(0),r=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),o=0;o<e;o++)t[2*o]=n[o+i],t[2*o+1]=r[o+i];return Math.min(e,n.length-i)}},{key:"dualChannel",get:function(){return this.buffer.numberOfChannels>1}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}}]),t}(),it=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Z,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4096,r=t.createScriptProcessor(n,2,2),o=new Float32Array(2*n);return r.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=e.extract(o,n);i(e.sourcePosition),0===a&&e.onEnd();for(var u=0;u<a;u++)r[u]=o[2*u],s[u]=o[2*u+1]},r},nt=function(t){var e,i,n,r=Math.floor(t/60),o=t-60*r;return"".concat(r,":").concat((e=parseInt(o),n=n||"0",(e+="").length>=(i=2)?e:new Array(i-e.length+1).join(n)+e))},rt=function(t){var e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){var n=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(n)}},ot=function(){function t(e,i,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Z;D(this,t),this._soundtouch=new tt;var s=new et(i);this.timePlayed=0,this.sourcePosition=0,this._filter=new V(s,this._soundtouch,o),this._node=it(e,this._filter,(function(t){return rt.call(r,t)}),n),this.tempo=1,this.rate=1,this.duration=i.duration,this.sampleRate=e.sampleRate,this.listeners=[]}return F(t,[{key:"connect",value:function(t){this._node.connect(t)}},{key:"disconnect",value:function(){this._node.disconnect()}},{key:"on",value:function(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(function(t){return e(t.detail)}))}},{key:"off",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this.listeners;e&&(i=i.filter((function(t){return t.name===e}))),i.forEach((function(e){t._node.removeEventListener(e.name,(function(t){return e.cb(t.detail)}))}))}},{key:"formattedDuration",get:function(){return nt(this.duration)}},{key:"formattedTimePlayed",get:function(){return nt(this.timePlayed)}},{key:"percentagePlayed",get:function(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)},set:function(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate)}},{key:"node",get:function(){return this._node}},{key:"pitch",set:function(t){this._soundtouch.pitch=t}},{key:"pitchSemitones",set:function(t){this._soundtouch.pitchSemitones=t}},{key:"rate",set:function(t){this._soundtouch.rate=t}},{key:"tempo",set:function(t){this._soundtouch.tempo=t}}]),t}(),st=function(){function e(){t(this,e),this.fns={any:[]}}return i(e,[{key:"has",value:function(t){return t in this.fns&&this.fns[t].length>0||this.fns.any.length>0}},{key:"on",value:function(t,e){return t in this.fns==!1&&(this.fns[t]=[]),this.fns[t].push(e),e}},{key:"fire",value:function(t,e,i){return this.fns.any.concat(t in this.fns?this.fns[t]:[]).forEach((function(n){return n(e,i,t)})),this}},{key:"off",value:function(t){for(var e in this.fns)for(var i=this.fns[e],n=0;n<i.length;n++)if(i[n]===t)return i.splice(n,1),!0;return!1}},{key:"once",value:function(t,e){var i=this;return this.on(t,(function t(n,r,o){e(n,r,o),i.off(t)})),e}}]),e}(),at=function(t){if(t.on&&t.off)return t;var e=new st,i=new Proxy(t,{get:function(t,n){if(n in t){if(t.constructor===Array){var r=i;"pop"===n?r=t[t.length-1]:"shift"===n&&(r=t[0]),"push"!==n&&"length"!==n&&e.fire(n,r)}return t[n]}return"on"===n?e.on.bind(e):"once"===n?e.once.bind(e):"off"===n?e.off.bind(e):void 0},set:function(t,i,n){return t.constructor===Array?"length"!==i&&e.fire("change",n):e.has(i)&&e.fire(i,n,t[i]),t[i]=n,!0}});return i},ut=function(t){t.keyColor>=0&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(t.canvas,0,0,t.canvas.width,t.canvas.height,0,0,this.canvas.width,this.canvas.height)},ct=function(t,e){t.clearRect(0,0,e.width,e.height)},lt=function(t){var e=this;return this.shifter&&this.shifter.off(),this.audio.decodeAudioData(t).then((function(t){e.shifter=at(new ot(e.audio,t,1024,(function(){e.stop()}))),e.shifter.on("play",(function(t){e.props.timePlayed=t.formattedTimePlayed,e.props.percentagePlayed=t.percentagePlayed,e.player.sync(1e3*t.timePlayed-800)})),e.shifter.pitch=1,e.props.trackLength=e.shifter.formattedDuration})).catch((function(t){return Promise.reject(new Error("There was an error decoding the audio file",t))}))},ht=function(t){var e=new O;return t?(this.player.load(Array.from(t)),e.resolve()):e.reject(new Error("There was an error loading the video file")),e.promise},ft=function(t,e,i,n,r,o){for(var s=e.split(" "),a="",u=0;u<s.length;u++){var c=a+s[u]+" ";t.measureText(c).width>r&&u>0?(t.fillText(a.trim(),i,n),a=s[u]+" ",n+=o):a=c}t.fillText(a.trim(),i,n)},pt=function(){var t=this.ctx,e=this.canvas,i=e.width-10,n=i/2,r=60;t.font="30px sans-serif",t.fillStyle="#fff",t.textAlign="center",ft(t,this.tag.title,n,r,i,30),t.font="20px sans-serif",r=e.height-60,ft(t,"by ".concat(this.tag.artist),n,r,i,30)},dt=function(t){if(this.tag=t&&t.tags,this.tag)return pt.call(this)},vt=function(t){var e=this,i=[];return i.push(lt.call(this,t[0])),i.push(ht.call(this,t[1])),Promise.all(i).then((function(){e.props.status="File Loaded",e.props.loaded=!0,dt.call(e,t[2])})).catch((function(t){return e.props.status="File Loading Failed",Promise.reject(t)})).then((function(){e.props.loading=!1}))},gt=function(t){this.gainNode.gain.value=t},mt=function(){function e(i){var r,o,s,a=this;if(t(this,e),n(this,"audio",null),n(this,"gainNode",null),n(this,"shifter",null),n(this,"wrapper",null),n(this,"player",null),n(this,"currentSize",1),n(this,"canvas",null),n(this,"ctx",null),n(this,"props",at({status:"",loaded:!1,loading:!1,isPlaying:!1,timePlayed:"0:00",trackLength:"0:00",percentagePlayed:0,songVolume:1,destroy:!1})),this.wrapper=document.querySelector(i),!this.wrapper)throw new Error('CDGPlayer: and element was not found with the "'.concat(i,'" selector'));this.wrapper.classList.add("cdg-video-wrapper"),this.canvas=(r=300,o=216,(s=document.createElement("canvas")).width=r,s.height=o,s),this.canvas.classList.add("cdg-video-player"),this.ctx=function(t){var e=t.getContext("2d");return e.webkitImageSmoothingEnabled=!1,e.mozImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}(this.canvas),this.player=new E({afterRender:function(t){return ut.call(a,t)}}),this.wrapper.appendChild(this.canvas);var u=document.createElement("div");u.classList.add("titleImage"),this.wrapper.appendChild(u),this.onloaded=this.props.on("loaded",(function(t){t?u.classList.add("hide"):u.classList.remove("hide")})),this.audio=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.audio.createGain(),this.onvolume=this.props.on("songVolume",(function(t){gt.call(a,t)})),this.props.songVolume=1}return i(e,[{key:"destroy",value:function(){this.wrapper.classList.remove("cdg-video-wrapper"),this.stop(),this.gainNode.disconnect(),this.shifter&&this.shifter.off(),this.shifter=null,this.gainNode=null,this.audio=null,this.canvas.remove(),this.props.destroy=!0,this.props.off("onvolume")}},{key:"load",value:function(t){var e,i=this;if(this.stop(),ct(this.ctx,this.canvas),this.props.loading=!0,"string"==typeof t){if(!t.toLowerCase().endsWith(".zip"))return this.props.loading=!1,this.props.status="".concat(t,' doesn\'t appear to be a ".zip" file.'),Promise.reject(this.props.status);this.props.status="Retrieving File...",e=M.loadZipFile(t)}else this.props.status="Loading File...",e=M.loadFileBuffer(t);return e.then((function(t){return vt.call(i,t)})).catch((function(t){return Promise.reject(t)}))}},{key:"togglePlay",value:function(){this.props.isPlaying?this.pause():this.start()}},{key:"start",value:function(){var t=this;ct.call(this,this.ctx,this.canvas),this.shifter.connect(this.gainNode),this.gainNode.connect(this.audio.destination),this.audio.resume().then((function(){t.props.isPlaying=!0,t.player.play()}))}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.props.isPlaying=t,this.shifter.disconnect(),this.player.stop()}},{key:"stop",value:function(){this.shifter&&(this.pause(),this.changePlayerPosition(0),pt.call(this))}},{key:"changePlayerPosition",value:function(t){t=t<0?0:t>100?100:t,this.shifter.percentagePlayed=t,this.props.percentagePlayed=this.shifter.percentagePlayed,this.props.timePlayed=this.shifter.formattedTimePlayed,this.player.reset(),t||(this.props.isPlaying=!1,this.props.timePlayed="0:00")}},{key:"changeKey",value:function(t){t=t<-7?-7:t>7?7:t,this.shifter.pitchSemitones=t,this.shifter.tempo=1}},{key:"volume",value:function(t){var e=+(this.gainNode.gain.value+t).toFixed(2);this.props.songVolume=e<0?0:e>1?1:e}},{key:"toggleMute",value:function(){var t=this.gainNode.gain.value;this.props.songVolume=t?0:this.fallbackVolume,this.fallbackVolume=t}}]),e}(),yt='<cdg-controls> <span class="playControl"> <button class="playButton" disabled><i class="icofont-play-alt-1"></i></button> </span> <span class="timePlayed"></span> <div class="progress-container"> <progress class="progressMeter" ng-disabled="$ctrls.loading" value="0" max="100"></progress> </div> <span class="trackLength"></span> <span> <input type="number" class="pitch" step="1" min="-7" max="7" value="0" disabled> </span> <span class="volumeControl"> <div> <button class="volumeButton" id="song_volume_button" disabled><i class="icofont-audio"></i></button> <div class="volumeSlider"> <input type="range" min="0.00" max="1.00" step="0.01" class="volumeRange" id="song_volume"> </div> </div> </span> \x3c!-- <span class="volumeControl">\n <div>\n <button class="volumeButton" id="mic_volume_button"><i class="icofont-mic"></i></button>\n <div class="volumeSlider">\n <input type="range" min="0.0" max="1" step="0.1" class="volumeRange" id="mic_volume" />\n </div>\n </div>\n </span> --\x3e </cdg-controls>';f('@font-face{font-family:IcoFont;font-weight:400;font-style:normal;src:url("data:font/woff2;base64,d09GMgABAAAAAAXMAAsAAAAACvwAAAWAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGVgCDOAqJVIgXATYCJAMYCw4ABCAFhAoHVRtpCcgehXEsbKBS2ff0eD//bvrn5iZI8AbZnNUErxlUN8cqSmkqFgaZOO3UCHtqgjxR+3rwwHPL34lFvSywNDsu4naDTHgW0YYjGp7xP/z9TH/a1mBl6RiRb1HUZZE0HUfhgOLuLKK4wQ7wRPkUxHOgigy6cB9AAGgWDYilba0XlOcAPwdLkIJhBO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-]{font-family:IcoFont!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;white-space:nowrap;word-wrap:normal;direction:ltr;line-height:1;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased}.icofont-mic:before{content:"\\ef95"}.icofont-mic-mute:before{content:"\\ef94"}.icofont-audio:before{content:"\\eea8"}.icofont-play-alt-1:before{content:"\\eca6"}.icofont-pause:before{content:"\\eca5"}.icofont-md,cdg-controls .playButton>i,cdg-controls .volumeButton>i{font-size:2em}.icofont-fw,cdg-controls .playButton>i,cdg-controls .volumeButton>i{text-align:center;width:1.25em}.mute,cdg-controls .pitch[disabled],cdg-controls .playButton[disabled],cdg-controls .volumeButton[disabled]{color:#a9a9a9}cdg-controls{position:relative;display:-ms-flexbox;display:-webkit-box;display:flex;height:40px;-ms-flex-direction:row;-webkit-box-orient:horizontal;-webkit-box-direction:normal;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:100%;font-size:1.25em}cdg-controls>div,cdg-controls>span{margin:3px 5px}cdg-controls>div:first-child,cdg-controls>span:first-child{margin-left:0}cdg-controls>div:last-child,cdg-controls>span:last-child{margin-right:0}cdg-controls .playButton,cdg-controls .volumeButton{outline:none;border:none;border-radius:3px;padding:5px;width:34px;height:34px}cdg-controls .playButton[disabled],cdg-controls .volumeButton[disabled]{cursor:not-allowed}cdg-controls .volumeControl>div{position:relative;width:100%;height:100%}cdg-controls .volumeControl>div:hover .volumeSlider{display:block}cdg-controls .volumeControl>div .volumeSlider{display:none;position:absolute;top:-75px;left:-55px;z-index:100;width:100px;-webkit-transform:rotate(270deg);transform:rotate(270deg);padding:10px 20px}cdg-controls .volumeControl>div .volumeSlider.under{top:75px;-webkit-transform:rotate(90deg);transform:rotate(90deg)}cdg-controls .volumeControl>div .volumeSlider:hover{display:block}cdg-controls .volumeControl>div .volumeSlider .volumeRange{-webkit-appearance:none;width:100%;height:5px;background:#d3d3d3;border:1px solid;border-radius:2.5px;outline:none;opacity:.7;-webkit-transition:.2s;-webkit-transition:opacity .2s;transition:opacity .2s}cdg-controls .volumeControl>div .volumeSlider .volumeRange:hover{opacity:1}cdg-controls .volumeControl>div .volumeSlider .volumeRange::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:15px;height:15px;border-radius:50%;border:1px solid #00f;background:#fff;cursor:pointer}cdg-controls .pitch{height:28px;font-size:.8em;text-align:right}cdg-controls .pitch[disabled]{cursor:not-allowed}cdg-controls .progress-container{position:relative;-webkit-box-flex:0;-ms-flex:0 1 auto;flex:0 1 auto;width:100%;display:inline-block}cdg-controls .progress-container progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;height:1em}cdg-controls .progress-container progress::-webkit-progress-bar{background-color:#eee;border-radius:.5em;-webkit-box-shadow:0 2px 5px rgba(0,0,0,.25) inset;box-shadow:inset 0 2px 5px rgba(0,0,0,.25)}cdg-controls .progress-container progress::-webkit-progress-value{background-image:-webkit-linear-gradient(-45deg,transparent 33%,transparent 0,rgba(0,0,0,.1) 66%,transparent 0),-webkit-linear-gradient(top,hsla(0,0%,100%,.25),rgba(0,0,0,.25)),-webkit-linear-gradient(left,#09c,#f44);border-radius:.5em;background-size:35px 20px,100% 100%,100% 100%}');var At=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},kt=function(){var t=this,e=this.player.props;this.onloaded=e.on("loaded",(function(e){e?(t.playBtn.removeAttribute("disabled"),t.pitch.removeAttribute("disabled"),t.volumeBtn.removeAttribute("disabled")):(t.playBtn.setAttribute("disabled","disabled"),t.pitch.setAttribute("disabled","disabled"),t.volumeBtn.setAttribute("disabled","disabled"))})),this.ontimeplayed=e.on("timePlayed",(function(e,i){e!==i&&(t.timePlayed.innerHTML=e)})),this.onpercentageplayed=e.on("percentagePlayed",(function(e,i){e!==i&&(t.progress.value=e)})),this.ontracklength=e.on("trackLength",(function(e,i){e!==i&&(t.trackLength.innerHTML=e)})),this.ondestroy=e.on("destroy",(function(e){e&&bt.call(t)})),this.onplay=e.on("isPlaying",(function(e){t.playIcn.classList.remove("icofont-play-alt-1","icofont-pause"),t.playIcn.classList.add(e?"icofont-pause":"icofont-play-alt-1")})),this.onvolume=e.on("songVolume",(function(e){var i=t.volumeIcn;if(t.volumeSlider.value=e,e)return i.classList.contains("mute")?void i.classList.remove("mute"):void 0;i.classList.add("mute")})),this.playBtn.addEventListener("click",(function(){return t.player.togglePlay()})),this.progress.addEventListener("click",(function(e){return wt.call(t,e)})),this.pitch.addEventListener("change",(function(){return Bt.call(t)})),this.volumeSlider.addEventListener("change",(function(){return xt.call(t)}))},bt=function(){var t=this,e=this.player.props;e.off(this.onloaded),e.off(this.ontimeplayed),e.off(this.onpercentageplayed),e.off(this.ontracklength),e.off(this.ondestroy),e.off(this.onplay),e.off(this.onvolume),this.playBtn.removeEventListener("click",(function(){return t.player.togglePlay()})),this.progress.removeEventListener("click",(function(e){return wt.call(t,e)})),this.pitch.removeEventListener("change",(function(){return Bt.call(t)})),this.volumeSlider.removeEventListener("change",(function(){return xt.call(t)}))},wt=function(t){var e=t.target.getBoundingClientRect(),i=(t.pageX-e.x)/t.target.offsetWidth;this.player.changePlayerPosition(i)},Bt=function(){var t=this.pitch.value;isNaN(t)?this.pitch.value=this.fallbackPitch:(this.fallbackPitch=t<-7?-7:t>7?7:t,this.player.changeKey(this.fallbackPitch))},xt=function(){this.player.props.songVolume=+(parseFloat(this.volumeSlider.value)+0).toFixed(2)},Ct=function e(i,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{position:"bottom"};t(this,e),n(this,"controls",At(yt)),n(this,"player",null),n(this,"playBtn",null),n(this,"playIcn",null),n(this,"timePlayed",null),n(this,"progress",null),n(this,"trackLength",null),n(this,"pitch",null);var s=document.querySelector(i);s.appendChild(this.controls),this.player=r;var a=this.player.props;if(this.playBtn=this.controls.querySelector(".playButton"),this.playIcn=this.playBtn.querySelector("i"),this.timePlayed=this.controls.querySelector(".timePlayed"),this.timePlayed.innerHTML=a.timePlayed,this.progress=this.controls.querySelector(".progressMeter"),this.progress.value=a.percentagePlayed,this.trackLength=this.controls.querySelector(".trackLength"),this.trackLength.innerHTML=a.trackLength,this.pitch=this.controls.querySelector(".pitch"),this.fallbackPitch=0,!d.includes(o.position))throw new Error("Panel Position must be either 'top' or 'bottom'.");if(this.volumeBtn=this.controls.querySelector("#song_volume_button"),this.volumeIcn=this.volumeBtn.querySelector("i"),this.volumeSlider=this.controls.querySelector("#song_volume"),this.volumeSlider.value=a.songVolume,"top"===o.position){var u=this.controls.querySelector(".volumeSlider");u.classList.add("under")}kt.call(this)};export{Ct as CDGControls,mt as CDGPlayer};
//# sourceMappingURL=cdgplayer.js.map
{
"name": "cdgplayer",
"version": "0.1.5",
"version": "0.1.6",
"description": "A browser based HTML5/JS karaoke 'Player', that takes a zip file containing an mp3 and cdg file, allowing the user to render and play directly in the browser.",

@@ -19,3 +19,3 @@ "main": "dist/cdgplayer.js",

"type": "git",
"url": ""
"url": "https://github.com/cutterbl/CDGPlayer.git"
},

@@ -38,25 +38,26 @@ "author": {

"devDependencies": {
"@babel/core": "7.7.5",
"@babel/core": "7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "7.7.6",
"@babel/preset-env": "7.9.0",
"@fortawesome/fontawesome-free": "^5.13.0",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-regular-svg-icons": "^5.13.0",
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"acorn": "^7.1.1",
"autoprefixer": "^9.7.5",
"babel-eslint": "10.0.3",
"babel-eslint": "10.1.0",
"connect": "^3.7.0",
"eslint": "6.7.2",
"node-sass": "4.13.0",
"eslint": "6.8.0",
"node-sass": "4.13.1",
"postcss-assets": "^5.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.2",
"regenerator-runtime": "^0.13.5",
"rollup": "^1.32.1",
"rollup": "^2.2.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-clear": "^2.0.7",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-embed-css": "^1.0.16",
"rollup-plugin-eslint": "^7.0.0",
"rollup-plugin-html": "^0.2.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^2.5.0",

@@ -63,0 +64,0 @@ "rollup-plugin-terser": "^5.3.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc