text: !function(){"use strict";window.cancelAnimationFrame=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame,window.requestAnimationFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,angular.module("angularAudioRecorder",["angularAudioRecorder.config","angularAudioRecorder.services","angularAudioRecorder.controllers","angularAudioRecorder.directives"]),angular.module("angularAudioRecorder.config",[]).constant("recorderScriptUrl",function(){var e=document.getElementsByTagName("script"),t=e[e.length-1].getAttribute("src"),n=t.substr(0,t.lastIndexOf("/")+1),r=document.createElement("a");return r.href=n,r.href}()).constant("recorderPlaybackStatus",{STOPPED:0,PLAYING:1,PAUSED:2}),angular.module("angularAudioRecorder.controllers",["angularAudioRecorder.config","angularAudioRecorder.services"]);var e=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&Object.defineProperty(t,n,{get:function(t){var n=t;return function(){return e[n]}}(n),enumerable:!0,configurable:!0});return t},t=function(e,t){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.readAsDataURL(e)},n=function(n,r,o,i,a,c,s){var l=function(e){var t=i.$root.$$phase;return"$apply"!==t&&"$digest"!==t?i.$apply(e):void 0},d=this,u={recorder:null,url:null,player:null},f=null,p="recorded-audio-"+d.id,v={isRecording:!1,playback:s.STOPPED,isDenied:null,isSwfLoaded:null,isConverting:!1,get isPlaying(){return v.playback===s.PLAYING},get isStopped(){return v.playback===s.STOPPED},get isPaused(){return v.playback===s.PAUSED}},g=angular.isDefined(d.convertMp3)?!!d.convertMp3:r.shouldConvertToMp3(),m=g?new MP3Converter(r.getMp3Config()):null;d.timeLimit=d.timeLimit||0,d.status=e(v),d.isAvailable=r.isAvailable(),d.elapsedTime=0,d.id||(d.id=o.generateUuid(),n.attr("id",d.id)),r.isHtml5||r.isCordova||(v.isSwfLoaded=r.swfIsLoaded(),i.$watch(function(){return r.swfIsLoaded()},function(e){v.isSwfLoaded=e})),r.setController(d.id,this);var h=function(){v.playback=s.STOPPED,d.onPlaybackComplete(),l()},w=function(){v.playback=s.PAUSED,d.onPlaybackPause()},y=function(){v.playback=s.PLAYING,d.onPlaybackStart()},b=function(){v.playback=s.PLAYING,d.onPlaybackResume()},A=function(e){if(null==document.getElementById(p)){n.append('<audio type="audio/mp3" id="'+p+'"></audio>');var r=document.getElementById(p);d.showPlayer&&r.setAttribute("controls",""),r.addEventListener("ended",h),r.addEventListener("pause",function(e){this.duration!==this.currentTime&&(w(),l())}),r.addEventListener("playing",function(e){v.isPaused?b():y(),l()})}e?t(e,function(e){document.getElementById(p).src=e}):document.getElementById(p).removeAttribute("src")},R=function(e,t){m&&(v.isConverting=!0,m.convert(e,function(e){v.isConverting=!1,t&&t(e),l(d.onConversionComplete)},function(){v.isConverting=!1}),d.onConversionStart())};d.getAudioPlayer=function(){return r.isCordova?u.player:document.getElementById(p)},d.startRecord=function(){if(r.isAvailable()){v.isPlaying&&(d.playbackPause(),v.playback=s.STOPPED),d.audioModel=null;var e=d.id,t=r.getHandler(),n=function(){if(r.isCordova)u.url=o.cordovaAudioUrl(d.id),u.recorder=new Media(u.url,function(){console.log("Media successfully played")},function(e){console.log("Media could not be launched"+e.code,e)}),console.log("CordovaRecording"),u.recorder.startRecord();else if(r.isHtml5){if(!t)return;console.log("HTML5Recording"),t.clear(),t.record()}else{if(!r.isReady)return;console.log("FlashRecording"),t.record(e,"audio.wav")}v.isRecording=!0,d.onRecordStart(),d.elapsedTime=0,f=c(function(){++d.elapsedTime,d.timeLimit&&d.timeLimit>0&&d.elapsedTime>=d.timeLimit&&d.stopRecord()},1e3)};r.isCordova||t?n():v.isDenied||r.showPermission({onDenied:function(){v.isDenied=!0,i.$apply()},onAllowed:function(){v.isDenied=!1,t=r.getHandler(),n(),l()}})}},d.stopRecord=function(){var e=d.id;if(!r.isAvailable()||!v.isRecording)return!1;var t=r.getHandler(),n=function(e){c.cancel(f),v.isRecording=!1;var t=function(e){d.audioModel=e,A(e)};g?R(e,t):t(e),A(null),d.onRecordComplete()};r.isCordova?(u.recorder.stopRecord(),window.resolveLocalFileSystemURL(u.url,function(e){e.file(function(e){n(e)})},function(e){console.log("Could not retrieve file, error code:",e.code)})):r.isHtml5?(t.stop(),t.getBuffer(function(){t.exportWAV(function(e){n(e),l()})})):(t.stopRecording(e),n(t.getBlob(e)))},d.playbackRecording=function(){return v.isPlaying||!r.isAvailable()||v.isRecording||!d.audioModel?!1:void(r.isCordova?(u.player=new Media(u.url,h,function(){console.log("Playback failed")}),u.player.play(),y()):d.getAudioPlayer().play())},d.playbackPause=function(){return v.isPlaying&&r.isAvailable()&&!v.isRecording&&d.audioModel?(d.getAudioPlayer().pause(),void(r.isCordova&&w())):!1},d.playbackResume=function(){return v.isPlaying||!r.isAvailable()||v.isRecording||!d.audioModel?!1:void(v.isPaused?(d.getAudioPlayer().play(),r.isCordova&&b()):d.playbackRecording())},d.save=function(e){if(!r.isAvailable()||v.isRecording||!d.audioModel)return!1;e||(e="audio_recording_"+d.id+(d.audioModel.type.indexOf("mp3")>-1?"mp3":"wav"));var t=window.URL.createObjectURL(d.audioModel),n=document.createElement("a");n.href=t,n.target="_blank",n.download=e;var o=document.createEvent("Event");o.initEvent("click",!0,!0),n.dispatchEvent(o)},d.isHtml5=function(){return r.isHtml5},d.autoStart&&a(function(){d.startRecord()},1e3),n.on("$destroy",function(){c.cancel(f)})};n.$inject=["$element","recorderService","recorderUtils","$scope","$timeout","$interval","recorderPlaybackStatus"],angular.module("angularAudioRecorder.controllers").controller("recorderController",n),angular.module("angularAudioRecorder.directives",["angularAudioRecorder.config","angularAudioRecorder.services","angularAudioRecorder.controllers"]),angular.module("angularAudioRecorder.directives").directive("ngAudioRecorderAnalyzer",["recorderService","recorderUtils",function(e,t){var n=function(n,r,o,i){function a(e){if(!u){var t=r.find("canvas")[0];o.width&&!isNaN(o.width)&&(t.width=o.width),o.height&&!isNaN(o.height)&&(t.height=parseInt(o.height)),s=t.width,l=t.height,u=t.getContext("2d")}var n=3,i=1,c=Math.round(s/n),p=new Uint8Array(f.analyserNode.frequencyBinCount);f.analyserNode.getByteFrequencyData(p),u.clearRect(0,0,s,l),u.lineCap="round";for(var v=f.analyserNode.frequencyBinCount/c,g=0;c>g;++g){for(var m=0,h=Math.floor(g*v),w=0;v>w;w++)m+=p[h+w];m/=v;p[g*v];o.waveColor?u.fillStyle=o.waveColor:u.fillStyle="hsl( "+Math.round(360*g/c)+", 100%, 50%)",u.fillRect(g*n,l,i,-m)}d=window.requestAnimationFrame(a)}function c(){window.cancelAnimationFrame(d),d=null}if(!e.isHtml5)return void(n.hide=!0);var s,l,d,u,f=e.$html5AudioProps;r.on("$destroy",function(){c()}),i.onRecordStart=function(e){return function(){e.apply(),a()}}(i.onRecordStart),t.appendActionToCallback(i,"onRecordStart",a,"analyzer"),t.appendActionToCallback(i,"onRecordComplete",c,"analyzer")};return{restrict:"E",require:"^ngAudioRecorder",template:'<div ng-if="!hide" class="audioRecorder-analyzer"><canvas class="analyzer" width="1200" height="400" style="max-width: 100%;"></canvas></div>',link:n}}]),angular.module("angularAudioRecorder.directives").directive("ngAudioRecorderWaveView",["recorderService","recorderUtils","$log",function(e,t,n){return{restrict:"E",require:"^ngAudioRecorder",link:function(e,r,o,i){if(!window.WaveSurfer)return void n.warn("WaveSurfer was found.");var a;r.html('<div class="waveSurfer"></div>');var c=angular.extend({container:r.find("div")[0]},o),s=WaveSurfer.create(c);s.setVolume(0),t.appendActionToCallback(i,"onPlaybackStart|onPlaybackResume",function(){s.play()},"waveView"),t.appendActionToCallback(i,"onPlaybackComplete|onPlaybackPause",function(){s.pause()},"waveView"),t.appendActionToCallback(i,"onRecordComplete",function(){a||(a=i.getAudioPlayer(),a.addEventListener("seeking",function(e){var t=a.currentTime/a.duration;s.seekTo(t)}))},"waveView"),e.$watch(function(){return i.audioModel},function(e){e instanceof Blob&&s.loadBlob(e)})}}}]),angular.module("angularAudioRecorder.directives").directive("ngAudioRecorder",["recorderService","$timeout",function(e,t){return{restrict:"EA",scope:{audioModel:"=",id:"@",onRecordStart:"&",onRecordComplete:"&",onPlaybackComplete:"&",onPlaybackStart:"&",onPlaybackPause:"&",onPlaybackResume:"&",onConversionStart:"&",onConversionComplete:"&",showPlayer:"=?",autoStart:"=?",convertMp3:"=?",timeLimit:"=?"},controllerAs:"recorder",bindToController:!0,template:function(e,t){return'<div class="audioRecorder"><div style="width: 250px; margin: 0 auto;"><div id="audioRecorder-fwrecorder"></div></div>'+e.html()+"</div>"},controller:"recorderController",link:function(n,r,o){t(function(){if(e.isAvailable&&!e.isHtml5&&!e.isCordova){var t={allowscriptaccess:"always"},n={id:"recorder-app",name:"recorder-app"},r={save_text:""};swfobject.embedSWF(e.getSwfUrl(),"audioRecorder-fwrecorder","0","0","11.0.0","",r,t,n)}},100)}}}]),angular.module("angularAudioRecorder.services",["angularAudioRecorder.config"]),angular.module("angularAudioRecorder.services").provider("recorderService",["recorderScriptUrl",function(e){var t,n=null,r={isHtml5:!1,isReady:!1},o={onDenied:null,onClosed:null,onAllow:null},i=!1,a=e+"../lib/recorder.swf",c=!1,s={bitRate:92,lameJsUrl:e+"../lib/lame.min.js"},l={isAvailable:!1,loaded:!1,configureMic:function(){FWRecorder.isReady&&(FWRecorder.configure(44,100,0,2e3),FWRecorder.setUseEchoSuppression(!1),FWRecorder.setLoopBack(!1))},allowed:!1,externalEvents:function(e){arguments[1];switch(arguments[0]){case"ready":parseInt(arguments[1]),parseInt(arguments[2]);FWRecorder.connect("recorder-app",0),FWRecorder.recorderOriginalWidth=1,FWRecorder.recorderOriginalHeight=1,l.loaded=!0;break;case"microphone_user_request":FWRecorder.showPermissionWindow({permanent:!0});break;case"microphone_connected":console.log("Permission to use MIC granted"),l.allowed=!0;break;case"microphone_not_connected":console.log("Permission to use MIC denied"),l.allowed=!1;break;case"permission_panel_closed":l.allowed?l.setAllowed():l.setDeclined(),FWRecorder.defaultSize(),angular.isFunction(o.onClosed)&&o.onClosed();break;case"recording":FWRecorder.hide();break;case"recording_stopped":FWRecorder.hide();break;case"playing":break;case"playback_started":arguments[2];break;case"save_pressed":FWRecorder.updateForm();break;case"saving":break;case"saved":var t=$.parseJSON(arguments[2]);t.saved;break;case"save_failed":arguments[2];break;case"save_progress":arguments[2],arguments[3];break;case"stopped":case"playing_paused":case"no_microphone_found":case"observing_level":case"microphone_level":case"microphone_activity":case"observing_level_stopped":}},isInstalled:function(){return swfobject.getFlashPlayerVersion().major>0},init:function(){return r.isHtml5=!1,l.isInstalled()?(l.isAvailable=!0,window.fwr_event_handler=l.externalEvents,void(window.configureMicrophone=l.configureMic)):void console.log("Flash is not installed, application cannot be initialized")},setAllowed:function(){r.isReady=!0,n=FWRecorder,angular.isFunction(o.onAllowed)&&o.onAllowed()},setDeclined:function(){r.isReady=!1,n=null,angular.isFunction(o.onDenied)&&o.onDenied()},getPermission:function(){l.isAvailable&&(FWRecorder.isMicrophoneAccessible()?(l.allowed=!0,setTimeout(function(){l.setAllowed()},100)):FWRecorder.showPermissionWindow({permanent:!0}))}},d={audioContext:null,inputPoint:null,audioInput:null,audioRecorder:null,analyserNode:null},u={gotStream:function(e){var t=d.audioContext;d.audioInput=t.createMediaStreamSource(e),d.audioInput.connect(d.inputPoint=t.createGain()),d.analyserNode=t.createAnalyser(),d.analyserNode.fftSize=2048,d.inputPoint.connect(d.analyserNode),d.audioRecorder=new Recorder(d.audioInput);var i=t.createGain();i.gain.value=0,d.inputPoint.connect(i),i.connect(t.destination),r.isReady=!0,n=d.audioRecorder,angular.isFunction(o.onAllowed)&&("https:"==window.location.protocol&&localStorage.setItem("permission","given"),o.onAllowed())},failStream:function(e){angular.isDefined(o.onDenied)&&o.onDenied()},getPermission:function(){navigator.getUserMedia({audio:!0},u.gotStream,u.failStream)},init:function(){r.isHtml5=!0;var e=window.AudioContext||window.webkitAudioContext;e&&!d.audioContext&&(d.audioContext=new e),null!==localStorage.getItem("permission")&&u.getPermission()}};navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia,r.isCordova=!1;var f=function(){"cordova"in window?r.isCordova=!0:!i&&navigator.getUserMedia?u.init():l.init()},p={};r.controller=function(e){return p[e]},r.getSwfUrl=function(){return a},r.setController=function(e,t){p[e]=t},r.isAvailable=function(){if(r.isCordova){if(!("Media"in window))throw new Error('The Media plugin for cordova is required for this library, add plugin using "cordova plugin add cordova-plugin-media"');return!0}return r.isHtml5||l.isInstalled()},r.getHandler=function(){return n},r.showPermission=function(e){return r.isAvailable()?(e&&angular.extend(o,e),void(r.isHtml5?u.getPermission():l.getPermission())):void console.warn("Neither HTML5 nor SWF is supported.")},r.swfIsLoaded=function(){return l.loaded},r.shouldConvertToMp3=function(){return c},r.getMp3Config=function(){return s},r.$html5AudioProps=d;var v={$get:["recorderUtils",function(e){return t=e,f(),r}],forceSwf:function(e){return i=e,v},setSwfUrl:function(e){return a=e,v},withMp3Conversion:function(e,t){return c=!!e,s=angular.extend(s,t||{}),v}};return v}]),angular.module("angularAudioRecorder.services").factory("recorderUtils",[function(){var e={generateUuid:function(){function e(e){var t=(Math.random().toString(16)+"000000000").substr(2,8);return e?"-"+t.substr(0,4)+"-"+t.substr(4,4):t}return e()+e(!0)+e(!0)+e()},cordovaAudioUrl:function(e){if(!window.cordova)return"record-audio"+e+".wav";var t=cordova.file.tempDirectory||cordova.file.externalApplicationStorageDirectory||cordova.file.sharedDirectory;switch(t+=Date.now()+"_recordedAudio_"+e.replace("/[^A-Za-z0-9_-]+/gi","-"),window.cordova.platformId){case"ios":t+=".wav";break;case"android":t+=".amr";break;case"wp":t+=".wma";break;default:t+=".mp3"}return t}};return e.appendActionToCallback=function(e,t,n,r){t.split(/\|/).forEach(function(t){if(!(angular.isObject(e)&&angular.isFunction(n)&&t in e&&angular.isFunction(e[t])))throw new Error("One or more parameter supplied is not valid");"$$appendTrackers"in e||(e.$$appendTrackers=[]);var o=t+"|"+r;return e.$$appendTrackers.indexOf(o)>-1?void console.log("Already appended: ",o):(e[t]=function(t){return function(){t.apply(e,arguments),n.apply(e,arguments)}}(e[t]),void e.$$appendTrackers.push(o))})},e}])}(),function(e){"use strict";function t(e,t,n){t=t||"",n=n||512;for(var r=atob(e),o=[],i=0;i<r.length;i+=n){for(var a=r.slice(i,i+n),c=new Array(a.length),s=0;s<a.length;s++)c[s]=a.charCodeAt(s);var l=new Uint8Array(c);o.push(l)}return new Blob(o,{type:t})}var n,r="audio/wav";n={recorder:null,recorderOriginalWidth:0,recorderOriginalHeight:0,uploadFormId:null,uploadFieldName:null,isReady:!1,connect:function(e,t){if(-1!=navigator.appName.indexOf("Microsoft")?n.recorder=window[e]:n.recorder=document[e],!(t>=40))if(n.recorder&&n.recorder.init){if(n.recorderOriginalWidth=n.recorder.width,n.recorderOriginalHeight=n.recorder.height,n.uploadFormId&&$){var r=$(n.uploadFormId);n.recorder.init(r.attr("action").toString(),n.uploadFieldName,r.serializeArray())}}else setTimeout(function(){n.connect(e,t+1)},100)},playBack:function(e){n.recorder.playBack(e)},pausePlayBack:function(e){n.recorder.pausePlayBack(e)},playBackFrom:function(e,t){n.recorder.playBackFrom(e,t)},record:function(e,t){n.recorder.record(e,t)},stopRecording:function(){n.recorder.stopRecording()},stopPlayBack:function(){n.recorder.stopPlayBack()},observeLevel:function(){n.recorder.observeLevel()},stopObservingLevel:function(){n.recorder.stopObservingLevel()},observeSamples:function(){n.recorder.observeSamples()},stopObservingSamples:function(){n.recorder.stopObservingSamples()},resize:function(e,t){n.recorder.width=e+"px",n.recorder.height=t+"px"},defaultSize:function(){n.resize(n.recorderOriginalWidth,n.recorderOriginalHeight)},show:function(){n.recorder.show()},hide:function(){n.recorder.hide()},duration:function(e){return n.recorder.duration(e||n.uploadFieldName)},getBase64:function(e){var t=n.recorder.getBase64(e);return"data:"+r+";base64,"+t},getBlob:function(e){var o=n.getBase64(e).split(",")[1];return t(o,r)},getCurrentTime:function(e){return n.recorder.getCurrentTime(e)},isMicrophoneAccessible:function(){return n.recorder.isMicrophoneAccessible()},updateForm:function(){var e=$(n.uploadFormId);n.recorder.update(e.serializeArray())},showPermissionWindow:function(e){n.resize(240,160);var t=function(){e&&e.permanent?n.recorder.permitPermanently():n.recorder.permit()};setTimeout(t,1)},configure:function(e,t,r,o){switch(e=parseInt(e||22),t=parseInt(t||100),r=parseInt(r||0),o=parseInt(o||4e3),e){case 44:case 22:case 11:case 8:case 5:break;default:throw"invalid rate "+e}if(0>t||t>100)throw"invalid gain "+t;if(0>r||r>100)throw"invalid silenceLevel "+r;if(-1>o)throw"invalid silenceTimeout "+o;n.recorder.configure(e,t,r,o)},setUseEchoSuppression:function(e){if("boolean"!=typeof e)throw"invalid value for setting echo suppression, val: "+e;n.recorder.setUseEchoSuppression(e)},setLoopBack:function(e){if("boolean"!=typeof e)throw"invalid value for setting loop back, val: "+e;n.recorder.setLoopBack(e)}},e.FWRecorder=n}(window),function(){"use strict";var e=function(e,t){if("function"!=typeof e)throw"The specified parameter must be a valid function";var n=e.toString();if(n.match(/\[native\s*code\]/i))throw"You cannot bind a native function to a worker";t=t||{},"object"!=typeof t&&console.warn("Params must be an object that is serializable with JSON.stringify, specified is: "+typeof t);var r=window.URL.createObjectURL(new Blob(["(",n,")(this,",JSON.stringify(t),")"],{type:"application/javascript"}));return r};Function.prototype.toWorker=function(t){var n=e(this,t);return new Worker(n)}}(),function(e){"use strict";var t=function(e){function t(e){d=e.sampleRate}function n(e){f.push(e[0]),u+=e[0].length}function r(t){var n=a(f,u),r=l(n),o=new Blob([r],{type:t});e.postMessage(o)}function o(){var t=[];t.push(a(f,u)),t.push(a(p,u)),e.postMessage(t)}function i(){u=0,f=[],p=[]}function a(e,t){for(var n=new Float32Array(t),r=0,o=0;o<e.length;o++)n.set(e[o],r),r+=e[o].length;return n}function c(e,t,n){for(var r=0;r<n.length;r++,t+=2){var o=Math.max(-1,Math.min(1,n[r]));e.setInt16(t,0>o?32768*o:32767*o,!0)}}function s(e,t,n){for(var r=0;r<n.length;r++)e.setUint8(t+r,n.charCodeAt(r))}function l(e){var t=new ArrayBuffer(44+2*e.length),n=new DataView(t);return s(n,0,"RIFF"),n.setUint32(4,32+2*e.length,!0),s(n,8,"WAVE"),s(n,12,"fmt "),n.setUint32(16,16,!0),n.setUint16(20,1,!0),n.setUint16(22,1,!0),n.setUint32(24,d,!0),n.setUint32(28,2*d,!0),n.setUint16(32,2,!0),n.setUint16(34,16,!0),s(n,36,"data"),n.setUint32(40,2*e.length,!0),c(n,44,e),n}var d,u=0,f=[],p=[];e.onmessage=function(e){switch(e.data.command){case"init":t(e.data.config);break;case"record":n(e.data.buffer);break;case"exportWAV":r(e.data.type);break;case"getBuffer":o();break;case"clear":i()}}},n=function(e,n){var r=n||{},o=r.bufferLen||4096;this.context=e.context,this.node=(this.context.createScriptProcessor||this.context.createJavaScriptNode).call(this.context,o,2,2);var i=t.toWorker();i.postMessage({command:"init",config:{sampleRate:this.context.sampleRate}});var a,c=!1;this.node.onaudioprocess=function(e){c&&i.postMessage({command:"record",buffer:[e.inputBuffer.getChannelData(0)]})},this.configure=function(e){for(var t in e)e.hasOwnProperty(t)&&(r[t]=e[t])},this.record=function(){c=!0},this.stop=function(){c=!1},this.clear=function(){i.postMessage({command:"clear"})},this.getBuffer=function(e){a=e||r.callback,i.postMessage({command:"getBuffer"})},this.exportWAV=function(e,t){if(a=e||r.callback,t=t||r.type||"audio/wav",!a)throw new Error("Callback not set");i.postMessage({command:"exportWAV",type:t})},i.onmessage=function(e){var t=e.data;a(t)},e.connect(this.node),this.node.connect(this.context.destination)};e.Recorder=n}(window),function(e){"use strict";var t=function(e,t){console.log("MP3 conversion worker started."),"undefined"==typeof lamejs&&importScripts(t.lameJsUrl);var n,r,o,i,a,c,s=1152,l=function(){c=[]},d=function(e){c.push(new Int8Array(e))},u=function(e){a=e||{},i=new lamejs,l()},f=function(e){r=i.WavHeader.readHeader(new DataView(e)),console.log("wave:",r),o=new Int16Array(e,r.dataOffset,r.dataLen/2),n=new i.Mp3Encoder(r.channels,r.sampleRate,a.bitRate||128);for(var t=o.length,c=0;t>=s;c+=s){var l=o.subarray(c,c+s),u=n.encodeBuffer(l);d(u),t-=s}},p=function(){var e=n.flush();d(e),self.postMessage({cmd:"end",buf:c}),console.log("done encoding"),l()};e.onmessage=function(e){switch(e.data.cmd){case"init":u(e.data.config);break;case"encode":f(e.data.rawInput);break;case"finish":p()}}},n=function(){var e=document.getElementsByTagName("script"),t=e[e.length-1].getAttribute("src"),n=t.substr(0,t.lastIndexOf("/")+1);if(n&&!n.match(/:\/\//)){var r=document.createElement("a");return r.href=n,r.href}return n}(),r=function(e){e=e||{},e.lameJsUrl=e.lameJsUrl||n+"/lame.min.js";var r=!1,o=t.toWorker(e);this.isBusy=function(){return r},this.convert=function(e){var t="conversion_"+Date.now(),n=t+":";console.log(n,"Starting conversion");var i,a,c={};switch(typeof arguments[1]){case"object":c=arguments[1];break;case"function":i=arguments[1];break;default:throw"parameter 2 is expected to be an object (config) or function (success callback)"}if("function"==typeof arguments[2]&&(i?a=arguments[2]:i=arguments[2]),"function"!=typeof arguments[3]||a||(a=arguments[3]),r)throw"Another conversion is in progress";var s=e.size,l=new FileReader,d=Date.now();l.onload=function(e){console.log(n,"Passed to BG process"),o.postMessage({cmd:"init",config:c}),o.postMessage({cmd:"encode",rawInput:e.target.result}),o.postMessage({cmd:"finish"}),o.onmessage=function(e){if("end"==e.data.cmd){console.log(n,"Done converting to Mp3");var t=new Blob(e.data.buf,{type:"audio/mp3"});console.log(n,"Conversion completed in: "+(Date.now()-d)/1e3+"s");var o=t.size;console.log(n+"Initial size: = "+s+", Final size = "+o+", Reduction: "+Number(100*(s-o)/s).toPrecision(4)+"%"),r=!1,i&&"function"==typeof i&&i(t)}}},r=!0,l.readAsArrayBuffer(e)}};e.MP3Converter=r}(window),function(e){"use strict";e.swfobject=function(){function e(){"complete"==b.readyState&&(b.parentNode.removeChild(b),t())}function t(){if(!x){if($.ie&&$.win){var e=v("span");try{var t=I.getElementsByTagName("body")[0].appendChild(e);t.parentNode.removeChild(t)}catch(n){return}}x=!0,O&&(clearInterval(O),O=null);for(var r=F.length,o=0;r>o;o++)F[o]()}}function n(e){x?e():F[F.length]=e}function r(e){if(typeof M.addEventListener!=A)M.addEventListener("load",e,!1);else if(typeof I.addEventListener!=A)I.addEventListener("load",e,!1);else if(typeof M.attachEvent!=A)g(M,"onload",e);else if("function"==typeof M.onload){var t=M.onload;M.onload=function(){t(),e()}}else M.onload=e}function o(){for(var e=L.length,t=0;e>t;t++){var n=L[t].id;if($.pv[0]>0){var r=p(n);r&&(L[t].width=r.getAttribute("width")?r.getAttribute("width"):"0",L[t].height=r.getAttribute("height")?r.getAttribute("height"):"0",m(L[t].swfVersion)?($.webkit&&$.webkit<312&&i(r),w(n,!0)):L[t].expressInstall&&!j&&m("6.0.65")&&($.win||$.mac)?a(L[t]):c(r))}else w(n,!0)}}function i(e){var t=e.getElementsByTagName(R)[0];if(t){var n=v("embed"),r=t.attributes;if(r)for(var o=r.length,i=0;o>i;i++)"DATA"==r[i].nodeName?n.setAttribute("src",r[i].nodeValue):n.setAttribute(r[i].nodeName,r[i].nodeValue);var a=t.childNodes;if(a)for(var c=a.length,s=0;c>s;s++)1==a[s].nodeType&&"PARAM"==a[s].nodeName&&n.setAttribute(a[s].getAttribute("name"),a[s].getAttribute("value"));e.parentNode.replaceChild(n,e)}}function a(e){j=!0;var t=p(e.id);if(t){if(e.altContentId){var n=p(e.altContentId);n&&(T=n,U=e.altContentId)}else T=s(t);!/%$/.test(e.width)&&parseInt(e.width,10)<310&&(e.width="310"),!/%$/.test(e.height)&&parseInt(e.height,10)<137&&(e.height="137"),I.title=I.title.slice(0,47)+" - Flash Player Installation";var r=$.ie&&$.win?"ActiveX":"PlugIn",o=I.title,i="MMredirectURL="+M.location+"&MMplayerType="+r+"&MMdoctitle="+o,a=e.id;if($.ie&&$.win&&4!=t.readyState){var c=v("div");a+="SWFObjectNew",c.setAttribute("id",a),t.parentNode.insertBefore(c,t),t.style.display="none";var d=function(){t.parentNode.removeChild(t)};g(M,"onload",d)}l({data:e.expressInstall,id:P,width:e.width,height:e.height},{flashvars:i},a)}}function c(e){if($.ie&&$.win&&4!=e.readyState){var t=v("div");e.parentNode.insertBefore(t,e),t.parentNode.replaceChild(s(e),t),e.style.display="none";var n=function(){e.parentNode.removeChild(e)};g(M,"onload",n)}else e.parentNode.replaceChild(s(e),e)}function s(e){var t=v("div");if($.win&&$.ie)t.innerHTML=e.innerHTML;else{var n=e.getElementsByTagName(R)[0];if(n){var r=n.childNodes;if(r)for(var o=r.length,i=0;o>i;i++)1==r[i].nodeType&&"PARAM"==r[i].nodeName||8==r[i].nodeType||t.appendChild(r[i].cloneNode(!0))}}return t}function l(e,t,n){var r,o=p(n);if(o)if(typeof e.id==A&&(e.id=n),$.ie&&$.win){var i="";for(var a in e)e[a]!=Object.prototype[a]&&("data"==a.toLowerCase()?t.movie=e[a]:"styleclass"==a.toLowerCase()?i+=' class="'+e[a]+'"':"classid"!=a.toLowerCase()&&(i+=" "+a+'="'+e[a]+'"'));var c="";for(var s in t)t[s]!=Object.prototype[s]&&(c+='<param name="'+s+'" value="'+t[s]+'" />');o.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+i+">"+c+"</object>",N[N.length]=e.id,r=p(e.id)}else if($.webkit&&$.webkit<312){var l=v("embed");l.setAttribute("type",S);for(var u in e)e[u]!=Object.prototype[u]&&("data"==u.toLowerCase()?l.setAttribute("src",e[u]):"styleclass"==u.toLowerCase()?l.setAttribute("class",e[u]):"classid"!=u.toLowerCase()&&l.setAttribute(u,e[u]));for(var f in t)t[f]!=Object.prototype[f]&&"movie"!=f.toLowerCase()&&l.setAttribute(f,t[f]);o.parentNode.replaceChild(l,o),r=l}else{var g=v(R);g.setAttribute("type",S);for(var m in e)e[m]!=Object.prototype[m]&&("styleclass"==m.toLowerCase()?g.setAttribute("class",e[m]):"classid"!=m.toLowerCase()&&g.setAttribute(m,e[m]));for(var h in t)t[h]!=Object.prototype[h]&&"movie"!=h.toLowerCase()&&d(g,h,t[h]);o.parentNode.replaceChild(g,o),r=g}return r}function d(e,t,n){var r=v("param");r.setAttribute("name",t),r.setAttribute("value",n),e.appendChild(r)}function u(e){var t=p(e);!t||"OBJECT"!=t.nodeName&&"EMBED"!=t.nodeName||($.ie&&$.win?4==t.readyState?f(e):M.attachEvent("onload",function(){f(e)}):t.parentNode.removeChild(t))}function f(e){var t=p(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function p(e){var t=null;try{t=I.getElementById(e)}catch(n){}return t}function v(e){return I.createElement(e)}function g(e,t,n){e.attachEvent(t,n),B[B.length]=[e,t,n]}function m(e){var t=$.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]?!0:!1}function h(e,t){if(!$.ie||!$.mac){var n=I.getElementsByTagName("head")[0],r=v("style");if(r.setAttribute("type","text/css"),r.setAttribute("media","screen"),$.ie&&$.win||typeof I.createTextNode==A||r.appendChild(I.createTextNode(e+" {"+t+"}")),n.appendChild(r),$.ie&&$.win&&typeof I.styleSheets!=A&&I.styleSheets.length>0){var o=I.styleSheets[I.styleSheets.length-1];typeof o.addRule==R&&o.addRule(e,t)}}}function w(e,t){var n=t?"visible":"hidden";x&&p(e)?p(e).style.visibility=n:h("#"+e,"visibility:"+n)}function y(e){var t=/[\\\"<>\.;]/,n=null!=t.exec(e);return n?encodeURIComponent(e):e}var b,A="undefined",R="object",C="Shockwave Flash",k="ShockwaveFlash.ShockwaveFlash",S="application/x-shockwave-flash",P="SWFObjectExprInst",M=window,I=document,E=navigator,F=[],L=[],N=[],B=[],O=null,T=null,U=null,x=!1,j=!1,$=function(){var e=typeof I.getElementById!=A&&typeof I.getElementsByTagName!=A&&typeof I.createElement!=A,t=[0,0,0],n=null;if(typeof E.plugins!=A&&typeof E.plugins[C]==R)n=E.plugins[C].description,!n||typeof E.mimeTypes!=A&&E.mimeTypes[S]&&!E.mimeTypes[S].enabledPlugin||(n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10),t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10),t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0);else if(typeof M.ActiveXObject!=A){var r=null,o=!1;try{r=new ActiveXObject(k+".7")}catch(i){try{r=new ActiveXObject(k+".6"),t=[6,0,21],r.AllowScriptAccess="always"}catch(i){6==t[0]&&(o=!0)}if(!o)try{r=new ActiveXObject(k)}catch(i){}}if(!o&&r)try{n=r.GetVariable("$version"),n&&(n=n.split(" ")[1].split(","),t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)])}catch(i){}}var a=E.userAgent.toLowerCase(),c=E.platform.toLowerCase(),s=/webkit/.test(a)?parseFloat(a.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,l=!1,d=c?/win/.test(c):/win/.test(a),u=c?/mac/.test(c):/mac/.test(a);return{w3cdom:e,pv:t,webkit:s,ie:l,win:d,mac:u}}();(function(){if($.w3cdom){if(n(o),$.ie&&$.win)try{I.write("<script id=__ie_ondomload defer=true src=//:></script>"),b=p("__ie_ondomload"),b&&g(b,"onreadystatechange",e)}catch(i){}$.webkit&&typeof I.readyState!=A&&(O=setInterval(function(){/loaded|complete/.test(I.readyState)&&t()},10)),typeof I.addEventListener!=A&&I.addEventListener("DOMContentLoaded",t,null),r(t)}})(),function(){$.ie&&$.win&&window.attachEvent("onunload",function(){for(var e=B.length,t=0;e>t;t++)B[t][0].detachEvent(B[t][1],B[t][2]);for(var n=N.length,r=0;n>r;r++)u(N[r]);for(var o in $)$[o]=null;$=null;for(var i in swfobject)swfobject[i]=null;swfobject=null})}();return{registerObject:function(e,t,n){if($.w3cdom&&e&&t){var r={};r.id=e,r.swfVersion=t,r.expressInstall=n?n:!1,L[L.length]=r,w(e,!1)}},getObjectById:function(e){var t=null;if($.w3cdom){var n=p(e);if(n){var r=n.getElementsByTagName(R)[0];!r||r&&typeof n.SetVariable!=A?t=n:typeof r.SetVariable!=A&&(t=r)}}return t},embedSWF:function(e,t,r,o,i,c,s,d,u){if($.w3cdom&&e&&t&&r&&o&&i)if(r+="",o+="",m(i)){w(t,!1);var f={};if(u&&typeof u===R)for(var p in u)u[p]!=Object.prototype[p]&&(f[p]=u[p]);f.data=e,f.width=r,f.height=o;var v={};if(d&&typeof d===R)for(var g in d)d[g]!=Object.prototype[g]&&(v[g]=d[g]);if(s&&typeof s===R)for(var h in s)s[h]!=Object.prototype[h]&&(typeof v.flashvars!=A?v.flashvars+="&"+h+"="+s[h]:v.flashvars=h+"="+s[h]);n(function(){l(f,v,t),f.id==t&&w(t,!0)})}else c&&!j&&m("6.0.65")&&($.win||$.mac)&&(j=!0,w(t,!1),n(function(){var e={};e.id=e.altContentId=t,e.width=r,e.height=o,e.expressInstall=c,a(e)}))},getFlashPlayerVersion:function(){return{major:$.pv[0],minor:$.pv[1],release:$.pv[2]}},hasFlashPlayerVersion:m,createSWF:function(e,t,n){return $.w3cdom?l(e,t,n):void 0},removeSWF:function(e){$.w3cdom&&u(e)},createCSS:function(e,t){$.w3cdom&&h(e,t)},addDomLoadEvent:n,addLoadEvent:r,getQueryParamValue:function(e){var t=I.location.search||I.location.hash;if(null==e)return y(t);if(t)for(var n=t.substring(1).split("&"),r=0;r<n.length;r++)if(n[r].substring(0,n[r].indexOf("="))==e)return y(n[r].substring(n[r].indexOf("=")+1));return""},expressInstallCallback:function(){if(j&&T){var e=p(P);e&&(e.parentNode.replaceChild(T,e),U&&(w(U,!0),$.ie&&$.win&&(T.style.display="block")),T=null,U=null,j=!1)}}}}()}(window);
  