(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{1358:function(t,e,n){"use strict";(function(t){n.d(e,"b",(function(){return M})),n.d(e,"c",(function(){return R})),n.d(e,"e",(function(){return A})),n.d(e,"d",(function(){return O})),n.d(e,"f",(function(){return N})),n.d(e,"a",(function(){return I}));var s=n(1359),i=n(553),o=n(396),r=n(1368),a=n(1388),l=n(1356),c=n(1552),h=n(1382),u=n(1553),p=n(1405),d=n(1383),m=n(411),f=n(2),g=n(1555),_=n(19),v=Object.defineProperty,b=Object.defineProperties,y=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,C=(t,e,n)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,k=(t,e)=>{for(var n in e||(e={}))x.call(e,n)&&C(t,n,e[n]);if(w)for(var n of w(e))S.call(e,n)&&C(t,n,e[n]);return t},E=(t,e)=>b(t,y(e)),P=(t,e,n)=>new Promise((s,i)=>{var o=t=>{try{a(n.next(t))}catch(t){i(t)}},r=t=>{try{a(n.throw(t))}catch(t){i(t)}},a=t=>t.done?s(t.value):Promise.resolve(t.value).then(o,r);a((n=n.apply(t,e)).next())});const T="undefined"==typeof window?null:window.URL||window.webkitURL||null;var M=(t=>(t.channelUpdate="ChannelUpdate",t.regionsNoteUpdate="regionsNoteUpdate",t.regionsMoveUpdate="regionsMoveUpdate",t.regionsStretchUpdate="regionsStretchUpdate",t.regionsColorUpdate="regionsColorUpdate",t.connectNewInstrument="connectNewInstrument",t.channelVolumeAutomationUpdate="channelVolumeAutomationUpdate",t.channelMuteStateChange="channelMuteStateChange",t.openPorject="openProject",t.audioFileUpdate="audioFileUpdate",t.increasePulsesPerPixel="increasePulsesPerPixel",t.decreasePulsesPerPixel="decreasePulsesPerPixel",t.waveformDataUpdate="waveformDataUpdate",t.projectBPMChanged="projectBPMChanged",t.startKeyBoardRecord="startKeyBoardRecord",t.stopKeyBoardRecord="stopKeyBoardRecord",t.keyBoardRecordStopped="keyBoardRecordStopped",t.openChannelEffectSetting="openChannelEffectSetting",t.removeChannelEffectNode="removeChannelEffectNode",t.initializeProjectName="initializeProjectName",t))(M||{}),R=(t=>(t[t.IDLE=0]="IDLE",t[t.PROGRESS=1]="PROGRESS",t[t.DONE=2]="DONE",t[t.ERROR=3]="ERROR",t))(R||{}),A=(t=>(t[t.rendering=0]="rendering",t[t.encoding=1]="encoding",t[t.finished=2]="finished",t[t.failed=3]="failed",t))(A||{}),O=(t=>(t.SimpleSynth="simpleSynth",t.MonoSynth="monoSynth",t.AmSynth="amSynth",t.FmSynth="fmSynth",t.DrumMachine="drumMachine",t.Sampler="samplerPiano",t.GeneralMidiSynth="generalMidiSynth",t))(O||{}),N=(t=>(t.BitCrusher="bitCrusher",t.Chebyshev="chebyshev",t.Filter="filter",t.PingPongDelay="pingPongDelay",t.PitchShift="pitchShift",t.Tremolo="tremolo",t))(N||{});function D(t,e,n){if(!T)return;const s=document.createElement("a");document.body.appendChild(s),s.style.display="none";const i=new window.Blob(e,{type:n===h.a.MP3?"audio/mpeg":"audio/wav"}),o=T.createObjectURL(i);s.href=o,s.download=n===h.a.MP3?t+".mp3":t+".wav",s.click(),T.revokeObjectURL(o)}function B(t,e,n="text/plain"){if(!T)return;let s;s=new Blob([e],{type:n});const i=document.createElementNS("http://www.w3.org/1999/xhtml","a");i.href=T.createObjectURL(s),i.download=t,function(t){const e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}(i)}class I extends i.EventEmitter{constructor(t,e,n){super(),this.tone=t,this.content=e,this.apiUtils=n,this.audioFiles=[],this.bufferCache={},this.projecInfo={content_id:-1,projectName:Object(f.e)("Untitled"),author:-1,description:"",preview:""},this.instrumentSampleCache={},this.audioMetaData={},this.waveformCache={},this.offlineInstrument={},this.offlineChanVolumeCtrl={},this.offlineMasterVolume=null,this.instruments={},this.chanVolumeCtrl={},this.chanSpecialEffects={},this.offlineChanSpecialEffects={},this.pulsesPerPixel=12,this.scheduledPlayer=[],this._endPos=0,this.savedRecord=[""],this.uplaodPendingList=[],this.preserveBlobForPublishing=!1,this.preservedBlobData=null,this.getCalculator=()=>new r.a(this.pulsesPerPixel,this.ctx.sampleRate,this.ctx.transport.bpm.value),this.getProjectData=()=>({channelList:this.channels,audioMetaData:this.audioMetaData,audioFiles:this.audioFiles,transportRange:[this._startPos,this._endPos],bpm:this.ctx.transport.bpm.value,projectName:this.projecInfo.projectName}),this.exportToDAWFile=()=>{const t={channelList:this.channels,audioMetaData:this.audioMetaData,audioFiles:this.audioFiles,transportRange:[this._startPos,this._endPos],bpm:this.ctx.transport.bpm.value,projectName:this.projecInfo.projectName};B((this.projecInfo.projectName||Object(f.e)("Untitled"))+".daw",JSON.stringify(t))},this.importFormDAWFile=t=>{var e,n;let i;if(i="string"==typeof t?JSON.parse(t):t,i.projectName&&(this.projecInfo.projectName=i.projectName),i.audioMetaData&&(this.audioMetaData=i.audioMetaData),i.audioFiles){this.audioFiles=i.audioFiles;for(let t=0;t{this.apiUtils.contentResolver.retrieve(t.url).then(e=>{if(e){const n=e.buffer;this.decodeAudioData(n).then(e=>{this.restoreMissingFile(e,t)}).catch(t=>{console.error(t)})}}).catch(()=>{console.error("retrive Error:",t.name,t.url)})})(e))}}if(i.channelList){const t=i.channelList;if(void 0!==t.length&&t.length>0){for(let t=0;t=20&&i.bpm<=200&&(this.ctx.transport.bpm.value=i.bpm,this.emit("projectBPMChanged")),this.emit("openProject"),this.emit("ChannelUpdate"),this.emit("audioFileUpdate"),this.emit("initializeProjectName",this.projecInfo.projectName),i},this._isUsingOfflineCxt=!1,this.exportToAudioFile=(t=h.a.MP3,e)=>{this.stop();const n=this.getCalculator(),s=n.fromPulses(this.arrangeStartPos).toSeconds(),i=n.fromPulses(this.arrangeEndPos).toSeconds(),o=i-s;this._isUsingOfflineCxt=!0,this._RenderingListener=e,this._RenderingListener&&this._RenderingListener(0),this.tone.Offline(({transport:t})=>{this.offlineMasterVolume=(new this.tone.Volume).toDestination();for(let t=0;tthis.arrangeEndPos))){const t=[];for(let s=0;sthis.arrangeEndPos)break;if(o>=0&&o{const i=new this.tone.Part((t,e)=>{n.triggerAttackRelease(e.note,e.duration,t,1)},t);i.loop=e.loopCount,i.loopEnd=r,i.start(s,void 0),i.stop(s+o)})(i)}}}}t.seconds=s,t.start(0,s),t.stop(i)},o).then(e=>{this._RenderingListener&&this._RenderingListener(1,0),this._isUsingOfflineCxt=!1;const n=e.get();if(n){const e=n.numberOfChannels,s=[];for(let t=0;t{console.error(t)})},this.play=()=>{const t=this.getCalculator();this.tone.setContext(this.ctx);const e=t.fromPulses(this.arrangeStartPos).toSeconds();for(let e=0;e=0&&o{const n=new this.tone.Part((e,n)=>{const s=a.instruments[t];try{null===s||s.disposed||s.triggerAttackRelease(n.note,n.duration,e,1)}catch(t){console.warn(t)}},e);n.loop=s.loopCount,n.loopEnd=r,n.start(i,void 0),n.stop(i+o)})(n.id)}}}this.chanVolumeCtrl[this.channels[e].data.id].mute=this.channels[e].data.mute}this.ctx.transport.loop=!0,this.ctx.transport.loopStart=t.fromPulses(this.arrangeStartPos).toSeconds(),this.ctx.transport.loopEnd=t.fromPulses(this.arrangeEndPos).toSeconds(),this.ctx.transport.seconds=Math.max(this.transportSeekToPos,e),this.ctx.transport.start()},this.stop=()=>{for(let t=0;t{const e=Object.keys(t),n=[];for(let s=0;s{this.content.retrieve(t[e[s]]).then(o=>{o&&o.buffer&&this.ctx.rawContext.decodeAudioData(o.buffer.slice(0),i=>{this.instrumentSampleCache[t[e[s]]]=i,n(i)},t=>{console.error("decodeAudioData error:",t),i(t)})}).catch(t=>{console.error(t),i(t)})}));return Promise.all(n)},this._exportWorker=Object(m.a)(1556,{cdnPath:e.cdnPath}).worker,this.channels=s.j.alloc();let i=null;"undefined"!=typeof AudioContext?i=new AudioContext:"undefined"!=typeof window&&(i=new window.webkitAudioContext),this.ctx=i?new this.tone.Context(i):new this.tone.Context,this.tone.setContext(this.ctx),Object(p.b)(this.ctx),this.masterVolume=new this.tone.Volume,this.masterVolume.toDestination(),this._endPos=4*this.ctx.transport.PPQ*10,this.aaDecoder=new g.a({ctx:this.ctx.rawContext}),this.aaEncoder=new g.b,this._exportWorker.addEventListener("message",t=>{const e=t.data;if(e[0]===h.b.ERROR)return console.error(e[1]),void(this._RenderingListener&&this._RenderingListener(3,e[1]));e[0]===h.b.PROGRESS?this._RenderingListener&&this._RenderingListener(1,e[1]):e[0]===h.b.DONE&&(e[1]===h.a.MP3?this.preserveBlobForPublishing?this.preservedBlobData=new Blob(e[2],{type:"audio/mpeg"}):D("audio",e[2],h.a.MP3):e[1]===h.a.WAV&&D("audio",[e[2]],h.a.WAV),this._RenderingListener&&this._RenderingListener(2))}),window.ctx=this.ctx}get isUsingOfflineCtx(){return this._isUsingOfflineCxt}_setUpVolumeAutomiation(t,e,n){if(0===e.length)throw new Error("automation curve should has at least one point");if(t.volume.cancelScheduledValues(0),1===e.length)t.volume.setValueAtTime(e[0].value,0);else{t.volume.setValueAtTime(e[1].value,0);for(let s=1;s{const e=s.findAudioFileById(r);e&&(e.url=t),_.a.info(Object(f.e)("resourceUploadSucced",{name:i}),1e3)},t=>{console.error(t),_.a.error(t.message)})}var i,o,r}getFirstRegionIdByFileId(t){for(let e=0;e{this._gumStream=t,this._streamInput=this.ctx.createMediaStreamSource(t),this._rec=new u.a(this._streamInput,{numChannels:1},this.content.cdnPath),this._rec.record()}).catch(t=>{throw new Error(t)})}pauseMicRecording(){this._rec.recording?this._rec.stop():this._rec.record()}stopMicRecording(){return this._rec.stop(),this._gumStream.getAudioTracks()[0].stop(),new Promise((t,e)=>{this._rec.exportMP3(e=>P(this,null,(function*(){const n=yield e.arrayBuffer();t(n)})))})}composoryToStopRecording(){this._rec&&this._rec.recording&&this._rec.stop()}decodeAudioData(t){return P(this,null,(function*(){let e;if(e="undefined"!=typeof window&&void 0!==window.webkitAudioContext?yield new Promise((e,n)=>{this.ctx.rawContext.decodeAudioData(t.slice(0),t=>{e(t)},t=>{console.error("decodeAudioData error:",t),n(t)})}):yield this.ctx.decodeAudioData(t.slice(0)),e)return e;throw new Error("Recorder Error: cannot decode exported MP3")}))}solo(t,e){for(let n=0;n{const e={};for(let t=0;t{a()}).catch(t=>{console.error(t)})}else if("monoSynth"===e.type){const s=e.data,i=this.parseOmniOscOpts(s.oscillator),o={portamento:s.portamento,oscillator:i,envelope:k({},s.envelope),filter:k({},s.filter),filterEnvelope:k({},s.filterEnvelope)};if(n){const e=new this.tone.PolySynth(this.tone.MonoSynth,o);this.offlineInstrument[t]=e,this.offlineInstrument[t].connect(this.offlineChanVolumeCtrl[t])}else{this.tone.setContext(this.ctx);const e=new this.tone.PolySynth(this.tone.MonoSynth,o);this.connectNewInstrument(t,e)}}else if("samplerPiano"===e.type){const s=Object.keys(a.c),i=e.data.samplePack.name,o=s.indexOf(i);if(o>=0){const e=a.c[s[o]],i=Object.keys(e.notes);let r=!0;for(let t=0;t{const s={};for(let t=0;t{l()}).catch(t=>{console.error(t)})}else console.error("instrument sample packe:",i,"does not exit")}else if("generalMidiSynth"===e.type){const s=e.data;if(n){const e=new d.a(this.offlineChanVolumeCtrl[t].context);e.setProgram(s.isPercussion,s.programId),this.offlineInstrument[t]=e,this.tone.connect(this.offlineInstrument[t].output,this.offlineChanVolumeCtrl[t])}else{this.tone.setContext(this.ctx);const e=new d.a(this.ctx);e.setProgram(s.isPercussion,s.programId),this.connectNewInstrument(t,e)}}}createChannelVolumeCtrl(t,e){this.tone.setContext(this.ctx),this.chanVolumeCtrl[t]&&!this.chanVolumeCtrl[t].disposed&&this.chanVolumeCtrl[t].dispose(),this.chanVolumeCtrl[t]=new this.tone.Volume,this.chanVolumeCtrl[t].connect(this.masterVolume),e?this.chanVolumeCtrl[t].volume.value=e[0].value:(console.warn("missing gainAutomation info"),this.chanVolumeCtrl[t].volume.value=0)}addInstrumentChannel(t,e,n){const i=s.k.alloc();i.type="InstrumentChannel",i.data=s.k.muData.InstrumentChannel.alloc(),i.data.name=t,i.data.mute=!1,i.data.regions=e,i.data.id=Object(o.v4)(),i.data.solo=!1,n?this.allocChannelInstrumentSchema(i.data,n.instrumentType,n.data):(i.data.instrument=s.p.alloc(),i.data.instrument.name="simpleSynth",i.data.instrument.config=s.K.alloc(),i.data.instrument.config.type="simpleSynth",i.data.instrument.config.data=s.Q.alloc(),i.data.instrument.config.data.oscillator.type="oscillator",i.data.instrument.config.data.oscillator.data=s.M.alloc()),i.data.gainAutomation=s.o.alloc(),i.data.gainAutomation.push(s.g.alloc()),i.data.gainAutomation[0].value=-10,this.channels.push(i),this.createChannelVolumeCtrl(i.data.id,i.data.gainAutomation),this.createInstrument(i.data.id,i.data.instrument.config,!1),this.emit("ChannelUpdate")}allocChannelInstrumentSchema(t,e,n){if(t.instrument=s.p.alloc(),t.instrument.name=e,t.instrument.config=s.K.alloc(),t.instrument.config.type=e,"simpleSynth"===e)t.instrument.config.data=s.Q.alloc(),t.instrument.config.data.oscillator.type="oscillator",t.instrument.config.data.oscillator.data=s.M.alloc();else if("monoSynth"===e)t.instrument.config.data=s.J.clone(c.a[0]);else if("fmSynth"===e)t.instrument.config.data=s.H.alloc(),t.instrument.config.data.oscillator.type="oscillator",t.instrument.config.data.oscillator.data=s.M.alloc();else if("amSynth"===e)t.instrument.config.data=s.C.alloc(),t.instrument.config.data.oscillator.type="oscillator",t.instrument.config.data.oscillator.data=s.M.alloc();else if("drumMachine"===e){const e=Object.keys(a.a);if("string"!=typeof n&&void 0!==n)throw new Error('Drumkit require a sound pack name, but get "'+JSON.stringify(n)+'" instead');let i=n;e.length>0&&(void 0!==i&&e.indexOf(i)>=0||(i=e[0])),t.instrument.config.data=s.D.alloc();const o=t.instrument.config.data;o.samplePack.name=i,o.samplePack.samples=[];let r=35;if(a.a[o.samplePack.name])for(let t=0;t0))return;void 0!==i&&e.indexOf(i)>=0||(i=e[0]),t.instrument.name=i,t.instrument.config.data=s.P.alloc(),t.instrument.config.data.samplePack.name=i}else if("generalMidiSynth"===e){if(null==n)throw new Error("Need more infomation to create GeneralMidiSynth");const e=n;t.instrument.config.data=s.I.alloc(),t.instrument.config.data.isPercussion=e.Percussion,t.instrument.config.data.programId=e.programId,e.Percussion?t.instrument.name="Percussion":t.instrument.name=d.a.getTimbreName(e.Percussion,e.programId)}}setChannelInstrument(t,e,n){this.allocChannelInstrumentSchema(t,e,n),this.createInstrument(t.id,t.instrument.config,!1)}createBitCrusher(t){let e;if(void 0===window.AudioWorklet)return window.alert('Your broswer is not support AudioWorklet that require by "bitCrusher", use Chrome or Firefox will give you a better experience'),e=new this.tone.Gain,e;try{e=new this.tone.BitCrusher(t)}catch(t){console.error(t),window.alert('Your broswer is not support AudioWorklet that require by "bitCrusher", use Chrome or Firefox will give you a better experience'),e=new this.tone.Gain}return e}createChebyshev(t){let e;try{e=new this.tone.Chebyshev(t)}catch(t){console.error(t),window.alert("Your broswer is not support this feature, use Chrome or Firefox will give you a better experience"),e=new this.tone.Gain}return e}createSpecialEffect(t,e,n=!1){if(this.chanSpecialEffects[t]||(this.chanSpecialEffects[t]=[]),this.offlineChanSpecialEffects[t]||(this.offlineChanSpecialEffects[t]=[]),"bitCrusher"===e.type)if(n){const n=this.createBitCrusher({bits:e.data.bits});this.offlineChanSpecialEffects[t].push(n)}else{this.tone.setContext(this.ctx);const n=this.createBitCrusher({bits:e.data.bits});this.chanSpecialEffects[t].push(n)}else if("chebyshev"===e.type)if(n){const n=this.createChebyshev({order:e.data.order});this.offlineChanSpecialEffects[t].push(n)}else{this.tone.setContext(this.ctx);const n=this.createChebyshev({order:e.data.order});this.chanSpecialEffects[t].push(n)}else if("filter"===e.type){const s=e.data,i=k({},s);if(n){const e=new this.tone.Filter(i);this.offlineChanSpecialEffects[t].push(e)}else{this.tone.setContext(this.ctx);const e=new this.tone.Filter(i);this.chanSpecialEffects[t].push(e)}}else if("pingPongDelay"===e.type){const s=e.data,i=k({},s);if(n){const e=new this.tone.PingPongDelay(i);this.offlineChanSpecialEffects[t].push(e)}else{this.tone.setContext(this.ctx);const e=new this.tone.PingPongDelay(i);this.chanSpecialEffects[t].push(e)}}else if("pitchShift"===e.type){const s=e.data,i=k({},s);if(n){const e=new this.tone.PitchShift(i);this.offlineChanSpecialEffects[t].push(e)}else{this.tone.setContext(this.ctx);const e=new this.tone.PitchShift(i);this.chanSpecialEffects[t].push(e)}}else if("tremolo"===e.type){const s=e.data,i={frequency:s.frequency,depth:s.depth,type:s.type};if(n){const e=new this.tone.Tremolo(i).start();this.offlineChanSpecialEffects[t].push(e)}else{this.tone.setContext(this.ctx);const e=new this.tone.Tremolo(i).start();this.chanSpecialEffects[t].push(e)}}if(n){const e=this.offlineChanSpecialEffects[t].length;1===e?(this.offlineChanVolumeCtrl[t].disconnect(),this.offlineChanVolumeCtrl[t].connect(this.offlineChanSpecialEffects[t][0]),this.offlineChanSpecialEffects[t][0].toDestination()):(this.offlineChanSpecialEffects[t][e-2].disconnect(),this.offlineChanSpecialEffects[t][e-2].connect(this.offlineChanSpecialEffects[t][e-1]),this.offlineChanSpecialEffects[t][e-1].toDestination())}else{const e=this.chanSpecialEffects[t].length;1===e?(this.chanVolumeCtrl[t].disconnect(),this.chanVolumeCtrl[t].connect(this.chanSpecialEffects[t][0]),this.chanSpecialEffects[t][0].toDestination()):(this.chanSpecialEffects[t][e-2].disconnect(),this.chanSpecialEffects[t][e-2].connect(this.chanSpecialEffects[t][e-1]),this.chanSpecialEffects[t][e-1].toDestination())}}allocSpecialEffectSchema(t,e){const n=s.z.alloc();return"bitCrusher"===e?(n.type=e,n.data=s.i.alloc()):"chebyshev"===e?(n.type=e,n.data=s.l.alloc()):"filter"===e?(n.type=e,n.data=s.F.alloc()):"pingPongDelay"===e?(n.type=e,n.data=s.v.alloc()):"pitchShift"===e?(n.type=e,n.data=s.w.alloc()):"tremolo"===e&&(n.type=e,n.data=s.A.alloc()),t.effects.push(n),n}addSpecialEffectToChannel(t,e){const n=this.allocSpecialEffectSchema(t,e);this.createSpecialEffect(t.id,n,!1)}removeSpecialEffectFromChannel(t,e){t.effects.splice(e,1);const n=this.chanSpecialEffects[t.id][e];n.disconnect(),n.dispose(),0===e?(this.chanVolumeCtrl[t.id].disconnect(),1===this.chanSpecialEffects[t.id].length?this.chanVolumeCtrl[t.id].toDestination():this.chanVolumeCtrl[t.id].connect(this.chanSpecialEffects[t.id][e+1])):(this.chanSpecialEffects[t.id][e-1].disconnect(),this.chanSpecialEffects[t.id].length-1===e?this.chanSpecialEffects[t.id][e-1].toDestination():this.chanSpecialEffects[t.id][e-1].connect(this.chanSpecialEffects[t.id][e+1])),this.chanSpecialEffects[t.id].splice(e,1),this.emit("removeChannelEffectNode",{channelId:t.id,effectIdx:e})}addNoteToRegionFromClip(t,e){const n=this.getCalculator(),i=s.s.alloc();i.id=Object(o.v4)(),i.loopCount=1,i.position=n.fromMilliseconds(1e3*e.position).toPulses(),i.timing.pulsesLength=n.fromMilliseconds(1e3*e.length).toPulses();for(let t=0;tt.position-e.position),this.addRegion(t,i)}addRegion(t,e){t.regions.push(e),this.emit("ChannelUpdate-"+t.id)}addNoteToRegion(t,e,n){if("[object Array]"===Object.prototype.toString.call(n))for(let t=0;t(t.sine="sine",t.square="square",t.sawtooth="sawtooth",t.triangle="triangle",t.custom="custom",t))(i||{});const o=new s.q({type:new s.a("triangle"),frequency:new s.g(440),detune:new s.g(0),phase:new s.g(0),partial:new s.b(new s.g,32)}),r=new s.q({carrierType:new s.a("triangle"),frequency:new s.g(440),detune:new s.g(0),phase:new s.g(0),partial:new s.b(new s.g,32),modulatortype:new s.a("square"),modulationIndex:new s.u(2),harmonicity:new s.g(1)}),a=new s.q({carrierType:new s.a("triangle"),frequency:new s.g(440),detune:new s.g(0),phase:new s.g(0),partial:new s.b(new s.g,32),modulatortype:new s.a("square"),harmonicity:new s.g(1)}),l=new s.q({width:new s.g(0),frequency:new s.g(440),detune:new s.g(0)}),c=new s.q({modulationFrequency:new s.g(1.6),detune:new s.g(0)}),h=new s.q({type:new s.a("sine"),partial:new s.b(new s.g,32),spread:new s.u(20),count:new s.u(3)});var u=(t=>(t.Oscillator="oscillator",t.FMOscillator="fm",t.AMOscillator="am",t.FatOscillator="fat",t.PulseOscillator="pulse",t.PWMOscillator="pwm",t))(u||{});const p=new s.v({oscillator:o,fm:r,am:a,fat:h,pulse:l,pwm:c});var d=(t=>(t.linear="linear",t.exponential="exponential",t.bounce="bounce",t.ripple="ripple",t.step="step",t.cosine="cosine",t.sine="sine",t))(d||{}),m=(t=>(t.linear="linear",t.exponential="exponential",t))(m||{});const f=new s.q({attack:new s.g(.1),decay:new s.g(.2),sustain:new s.g(.5),release:new s.g(1),attackCurve:new s.a("exponential"),decayCurve:new s.a("exponential"),releaseCurve:new s.a("exponential")}),g=new s.q({attack:new s.g(.1),decay:new s.g(.2),sustain:new s.g(.5),release:new s.g(1),attackCurve:new s.a("exponential"),decayCurve:new s.a("exponential"),releaseCurve:new s.a("exponential"),baseFrequency:new s.w(200),exponent:new s.u(1),octaves:new s.g(4)});var _=(t=>(t.lowpass="lowpass",t.highpass="highpass",t.bandpass="bandpass",t.lowshelf="lowshelf",t.highshelf="highshelf",t.peaking="peaking",t.notch="notch",t.allpass="allpass",t))(_||{});const v=new s.q({type:new s.a("lowpass"),rolloff:new s.i(-48),Q:new s.g(2.8),gain:new s.i(-3),frequency:new s.w(350)}),b=new s.q({polyphony:new s.u(8),portamento:new s.g(0),envelope:f,oscillator:p}),y=new s.q({polyphony:new s.u(8),portamento:new s.g(0),envelope:f,oscillator:p,filter:v,filterEnvelope:g}),w=new s.q({polyphony:new s.u(8),portamento:new s.g(0),harmonicity:new s.g(3),detune:new s.g(0),modulationIndex:new s.u(10),envelope:f,oscillator:p,modulation:o,modulationEnvelope:f}),x=new s.q({polyphony:new s.u(8),portamento:new s.g(0),harmonicity:new s.g(3),detune:new s.g(0),envelope:f,oscillator:p,modulation:o,modulationEnvelope:f}),S=(new s.q({attackNoise:new s.g(1),dampening:new s.w(4e3),release:new s.g(1),resonance:new s.g(.7)}),new s.q({name:new s.r(""),src:new s.r(""),note:new s.u(60)})),C=new s.q({name:new s.r(""),samples:new s.b(S,1/0)}),k=new s.q({samplePack:C,fadeIn:new s.g(0),fadeOut:new s.g(1)}),E=new s.q({samplePack:C,fadeIn:new s.g(.3),fadeOut:new s.g(1),revert:new s.c(!1)}),P=new s.q({isPercussion:new s.c(!1),programId:new s.w(0)}),T=new s.v({simpleSynth:b,monoSynth:y,fmSynth:w,amSynth:x,drumMachine:k,samplerPiano:E,generalMidiSynth:P}),M=new s.q({millisecondsLength:new s.t,millisecondsContentPosition:new s.t}),R=new s.q({type:new s.a("A"),id:new s.r(""),file:new s.r(""),loopCount:new s.w(1),position:new s.h(0),color:new s.r(""),reverse:new s.c(!1),stretch:new s.h(1),timing:M}),A=new s.q({id:new s.r(""),pitch:new s.u,length:new s.w(48),position:new s.h(0),velocity:new s.g(.75)}),O=new s.b(A,1/0),N=new s.q({pulsesLength:new s.w(0),pulsesContentPosition:new s.w(0)}),D=new s.q({type:new s.a("N"),id:new s.r(""),timing:N,notes:O,loopCount:new s.w(1),position:new s.h(0),color:new s.r("#B47157"),name:new s.a("Note Clip")}),B=new s.b(D,1/0),I=new s.q({value:new s.g(0),time:new s.g(0)}),F=new s.b(I,1/0),V=new s.q({name:new s.r(""),config:T}),j=new s.q({bits:new s.w(4),wet:new s.g(1)}),L=new s.q({frequency:new s.w(10),type:new s.a("sine"),depth:new s.g(.5),wet:new s.g(1)}),q=new s.q({order:new s.w(20),oversample:new s.a("none"),wet:new s.g(1)}),U=new s.q({delayTime:new s.g(0),feedback:new s.g(0),pitch:new s.w(0),wet:new s.g(1),windowSize:new s.g(.1)}),H=new s.q({wet:new s.g(1),delayTime:new s.g(.25),feedback:new s.g(.5)}),W=new s.v({bitCrusher:j,chebyshev:q,filter:v,pingPongDelay:H,pitchShift:U,tremolo:L}),Q=new s.b(W,1/0),X=new s.q({name:new s.r(""),id:new s.a(""),mute:new s.c(!1),solo:new s.c(!1),gainAutomation:F,effects:Q,instrument:V,regions:B}),z=new s.b(R,1/0),G=new s.q({name:new s.r(""),id:new s.a(""),mute:new s.c(!1),solo:new s.c(!1),gainAutomation:F,effects:Q,regions:new s.b(R,1/0)}),Y=new s.v({InstrumentChannel:X,AudioChannel:G}),K=new s.b(Y,1/0),Z=new s.q({id:new s.r(""),name:new s.r(""),size:new s.w(0),url:new s.r(""),userFile:new s.u}),J=(new s.q({channels:K}),{White:"#a9a9a9",Ocean:"#10b6c7",AoNi:"#516E41",SumiRe:"#66327C",KaraCha:"#B47157",Orange:"#FF6600",Black:"#303030",Red:"#702524",Blue:"#325472"})},1368:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));class s{constructor(t,e){this.pulses=t,this.calculator=e}toMilliseconds(){return this.calculator.toMilliseconds(this.pulses)}toSeconds(){return this.calculator.toSeconds(this.pulses)}toPulses(){return this.calculator.toPulses(this.pulses)}toFrames(t){return this.calculator.toFrames(this.pulses,t)}toPixels(){return this.calculator.toPixels(this.pulses)}toQuarters(){return this.calculator.toQuarters(this.pulses)}}class i{constructor(t=0,e=0,n=0,s=192){this.pulsesPerPixel=t,this.framesPerSecond=e,this.bpm=n,this.pulsesPerQuarterNote=s}fromMilliseconds(t){return new s(t*this.bpm*this.pulsesPerQuarterNote/6e4,this)}fromPulses(t){return new s(t,this)}fromFrames(t,e=this.framesPerSecond){return new s(t*this.bpm*this.pulsesPerQuarterNote/(60*e),this)}fromPixels(t){return new s(this.pulsesPerPixel*t,this)}fromQuarters(t){return new s(this.pulsesPerQuarterNote*t,this)}toMilliseconds(t){return 6e4*t/(this.bpm*this.pulsesPerQuarterNote)}toSeconds(t){return 60*t/(this.bpm*this.pulsesPerQuarterNote)}toPulses(t){return Math.round(t)}toFrames(t,e=this.framesPerSecond){return Math.round(60*t*e/(this.bpm*this.pulsesPerQuarterNote))}toPixels(t){return t/this.pulsesPerPixel}toQuarters(t){return t/this.pulsesPerQuarterNote}}},1381:function(t,e,n){t.exports={noteContainer:"_3Vw_drbMtlUKHvPL9kVbmp",active:"_23BkKu0IvMlT5UxlLrzRdw",whiteKey:"_1xHLrfonr_2NRfMfS6dwYw",blackKey:"_3pueZ3YQSKLG8Jf4oD-079",noteLabel:"_1vbURp6SErp_8lbXP3s5Fx",octaveContainer:"_3nT9Usnj-6gRRFyLkYklsB",whiteNotes:"_1q7ZZAppY4buNBMnXtEGPw",blackNotes:"_11vC4fsBKJ4_ycY0AYwIIS",whiteNote:"_1Prk4EChrQlZvOdz6Mh7FI",blackNote:"_2YtVj2EiKMxaVr5fgkvcvx",hide:"tUKPvRODNqaKdtzOLZTH8",keyboardContainer:"_3vNX8gsL2fZfQHwnhGevwm",scroll:"tonN259eqZy0oLxBDMV7_"}},1382:function(t,e,n){"use strict";n.d(e,"b",(function(){return s})),n.d(e,"a",(function(){return i}));var s=(t=>(t[t.DONE=1]="DONE",t[t.PROGRESS=2]="PROGRESS",t[t.ERROR=3]="ERROR",t))(s||{}),i=(t=>(t[t.MP3=1]="MP3",t[t.WAV=2]="WAV",t))(i||{})},1383:function(t,e,n){"use strict";n.d(e,"a",(function(){return a}));var s=n(553),i=n(1405),o=n(1356);const r=class extends s.EventEmitter{constructor(t){super(),this.name="GeneralMidiSynth",this.program=[],this.drummap=[],this.voicesCount=12,this.programFormula=[[{w:"sine",v:.4,d:.7,r:.1},{w:"triangle",v:3,d:.7,s:.1,g:1,a:.01,k:-1.2}],[{w:"triangle",v:.4,d:.7,r:.1},{w:"triangle",v:4,t:3,d:.4,s:.1,g:1,k:-1,a:.01}],[{w:"sine",d:.7,r:.1},{w:"triangle",v:4,f:2,d:.5,s:.5,g:1,k:-1}],[{w:"sine",d:.7,v:.2},{w:"triangle",v:4,t:3,f:2,d:.3,g:1,k:-1,a:.01,s:.5}],[{w:"sine",v:.35,d:.7},{w:"sine",v:3,t:7,f:1,d:1,s:1,g:1,k:-.7}],[{w:"sine",v:.35,d:.7},{w:"sine",v:8,t:7,f:1,d:.5,s:1,g:1,k:-.7}],[{w:"sawtooth",v:.34,d:2},{w:"sine",v:8,f:.1,d:2,s:1,r:2,g:1}],[{w:"triangle",v:.34,d:1.5},{w:"square",v:6,f:.1,d:1.5,s:.5,r:2,g:1}],[{w:"sine",d:.3,r:.3},{w:"sine",v:7,t:11,d:.03,g:1}],[{w:"sine",d:.3,r:.3},{w:"sine",v:11,t:6,d:.2,s:.4,g:1}],[{w:"sine",v:.2,d:.3,r:.3},{w:"sine",v:11,t:5,d:.1,s:.4,g:1}],[{w:"sine",v:.2,d:.6,r:.6},{w:"triangle",v:11,t:5,f:1,s:.5,g:1}],[{w:"sine",v:.3,d:.2,r:.2},{w:"sine",v:6,t:5,d:.02,g:1}],[{w:"sine",v:.3,d:.2,r:.2},{w:"sine",v:7,t:11,d:.03,g:1}],[{w:"sine",v:.2,d:1,r:1},{w:"sine",v:11,t:3.5,d:1,r:1,g:1}],[{w:"triangle",v:.2,d:.5,r:.2},{w:"sine",v:6,t:2.5,d:.2,s:.1,r:.2,g:1}],[{w:"w9999",v:.22,s:.9},{w:"w9999",v:.22,t:2,f:2,s:.9}],[{w:"w9999",v:.2,s:1},{w:"sine",v:11,t:6,f:2,s:.1,g:1,h:.006,r:.002,d:.002},{w:"w9999",v:.2,t:2,f:1,h:0,s:1}],[{w:"w9999",v:.2,d:.1,s:.9},{w:"w9999",v:.25,t:4,f:2,s:.5}],[{w:"w9999",v:.3,a:.04,s:.9},{w:"w9999",v:.2,t:8,f:2,a:.04,s:.9}],[{w:"sine",v:.2,a:.02,d:.05,s:1},{w:"sine",v:6,t:3,f:1,a:.02,d:.05,s:1,g:1}],[{w:"triangle",v:.2,a:.02,d:.05,s:.8},{w:"square",v:7,t:3,f:1,d:.05,s:1.5,g:1}],[{w:"square",v:.2,a:.02,d:.2,s:.5},{w:"square",v:1,d:.03,s:2,g:1}],[{w:"square",v:.2,a:.02,d:.1,s:.8},{w:"square",v:1,a:.3,d:.1,s:2,g:1}],[{w:"sine",v:.3,d:.5,f:1},{w:"triangle",v:5,t:3,f:-1,d:1,s:.1,g:1}],[{w:"sine",v:.4,d:.6,f:1},{w:"triangle",v:12,t:3,d:.6,s:.1,g:1,f:-1}],[{w:"triangle",v:.3,d:1,f:1},{w:"triangle",v:6,f:-1,d:.4,s:.5,g:1,t:3}],[{w:"sine",v:.3,d:1,f:-1},{w:"triangle",v:11,f:1,d:.4,s:.5,g:1,t:3}],[{w:"sine",v:.4,d:.1,r:.01},{w:"sine",v:7,g:1}],[{w:"triangle",v:.4,d:1,f:1},{w:"square",v:4,f:-1,d:1,s:.7,g:1}],[{w:"triangle",v:.35,d:1,f:1},{w:"square",v:7,f:-1,d:.3,s:.5,g:1}],[{w:"sine",v:.2,t:1.5,a:.005,h:.2,d:.6},{w:"sine",v:11,t:5,f:2,d:1,s:.5,g:1}],[{w:"sine",d:.3},{w:"sine",v:4,t:3,d:1,s:1,g:1}],[{w:"sine",d:.3},{w:"sine",v:4,t:3,d:1,s:1,g:1}],[{w:"w9999",d:.3,v:.7,s:.5},{w:"sawtooth",v:1.2,d:.02,s:.5,g:1,h:0,r:.02}],[{w:"sine",d:.3},{w:"sine",v:4,t:3,d:1,s:1,g:1}],[{w:"triangle",v:.3,t:2,d:1},{w:"triangle",v:15,t:2.5,d:.04,s:.1,g:1}],[{w:"triangle",v:.3,t:2,d:1},{w:"triangle",v:15,t:2.5,d:.04,s:.1,g:1}],[{w:"triangle",d:.7},{w:"square",v:.4,t:.5,f:1,d:.2,s:10,g:1}],[{w:"triangle",d:.7},{w:"square",v:.4,t:.5,f:1,d:.2,s:10,g:1}],[{w:"sawtooth",v:.4,a:.1,d:11},{w:"sine",v:5,d:11,s:.2,g:1}],[{w:"sawtooth",v:.4,a:.1,d:11},{w:"sine",v:5,d:11,s:.2,g:1}],[{w:"sawtooth",v:.4,a:.1,d:11},{w:"sine",v:5,t:.5,d:11,s:.2,g:1}],[{w:"sawtooth",v:.4,a:.1,d:11},{w:"sine",v:5,t:.5,d:11,s:.2,g:1}],[{w:"sine",v:.4,a:.1,d:11},{w:"sine",v:6,f:2.5,d:.05,s:1.1,g:1}],[{w:"sine",v:.3,d:.1,r:.1},{w:"square",v:4,t:3,d:1,s:.2,g:1}],[{w:"sine",v:.3,d:.5,r:.5},{w:"sine",v:7,t:2,f:2,d:1,r:1,g:1}],[{w:"triangle",v:.6,h:.03,d:.3,r:.3,t:.5},{w:"n0",v:8,t:1.5,d:.08,r:.08,g:1}],[{w:"sawtooth",v:.3,a:.03,s:.5},{w:"sawtooth",v:.2,t:2,f:2,d:1,s:2}],[{w:"sawtooth",v:.3,f:-2,a:.03,s:.5},{w:"sawtooth",v:.2,t:2,f:2,d:1,s:2}],[{w:"sawtooth",v:.2,a:.02,s:1},{w:"sawtooth",v:.2,t:2,f:2,a:1,d:1,s:1}],[{w:"sawtooth",v:.2,a:.02,s:1},{w:"sawtooth",v:.2,f:2,a:.02,d:1,s:1}],[{w:"triangle",v:.3,a:.03,s:1},{w:"sine",v:3,t:5,f:1,d:1,s:1,g:1}],[{w:"sine",v:.4,a:.03,s:.9},{w:"sine",v:1,t:2,f:3,d:.03,s:.2,g:1}],[{w:"triangle",v:.6,a:.05,s:.5},{w:"sine",v:1,f:.8,d:.2,s:.2,g:1}],[{w:"square",v:.15,a:.01,d:.2,r:.2,t:.5,h:.03},{w:"square",v:4,f:.5,d:.2,r:11,a:.01,g:1,h:.02},{w:"square",v:.15,t:4,f:1,a:.02,d:.15,r:.15,h:.03},{g:3,w:"square",v:4,f:-.5,a:.01,h:.02,d:.15,r:11}],[{w:"square",v:.2,a:.01,d:1,s:.6,r:.04},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.5,r:.08},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.04,d:1,s:.4,r:.08},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.15,a:.04,s:1},{w:"sine",v:2,d:.1,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.5,r:.08},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.6,r:.08},{w:"sine",v:1,f:.2,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.02,d:.5,s:.7,r:.08},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.5,r:.08},{w:"sine",v:1,d:.1,s:4,g:1}],[{w:"square",v:.2,a:.02,d:2,s:.6},{w:"sine",v:2,d:1,g:1}],[{w:"square",v:.2,a:.02,d:2,s:.6},{w:"sine",v:2,d:1,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.6},{w:"sine",v:2,d:1,g:1}],[{w:"square",v:.2,a:.02,d:1,s:.6},{w:"sine",v:2,d:1,g:1}],[{w:"sine",v:.4,a:.02,d:.7,s:.5},{w:"square",v:5,t:2,d:.2,s:.5,g:1}],[{w:"sine",v:.3,a:.05,d:.2,s:.8},{w:"sawtooth",v:6,f:.1,d:.1,s:.3,g:1}],[{w:"sine",v:.3,a:.03,d:.2,s:.4},{w:"square",v:7,f:.2,d:1,s:.1,g:1}],[{w:"square",v:.2,a:.05,d:.1,s:.8},{w:"square",v:4,d:.1,s:1.1,g:1}],[{w:"sine",a:.02,d:2},{w:"sine",v:6,t:2,d:.04,g:1}],[{w:"sine",v:.7,a:.03,d:.4,s:.4},{w:"sine",v:4,t:2,f:.2,d:.4,g:1}],[{w:"sine",v:.7,a:.02,d:.4,s:.6},{w:"sine",v:3,t:2,d:0,s:1,g:1}],[{w:"sine",v:.4,a:.06,d:.3,s:.3},{w:"sine",v:7,t:2,d:.2,s:.2,g:1}],[{w:"sine",a:.02,d:.3,s:.3},{w:"sawtooth",v:3,t:2,d:.3,g:1}],[{w:"sine",v:.4,a:.02,d:2,s:.1},{w:"sawtooth",v:8,t:2,f:1,d:.5,g:1}],[{w:"sine",v:.7,a:.03,d:.5,s:.3},{w:"sine",v:.003,t:0,f:4,d:.1,s:.002,g:1}],[{w:"sine",v:.7,a:.02,d:2},{w:"sine",v:1,t:2,f:1,d:.02,g:1}],[{w:"square",v:.3,d:1,s:.5},{w:"square",v:1,f:.2,d:1,s:.5,g:1}],[{w:"sawtooth",v:.3,d:2,s:.5},{w:"square",v:2,f:.1,s:.5,g:1}],[{w:"triangle",v:.5,a:.05,d:2,s:.6},{w:"sine",v:4,t:2,g:1}],[{w:"triangle",v:.3,a:.01,d:2,s:.3},{w:"sine",v:22,t:2,f:1,d:.03,s:.2,g:1}],[{w:"sawtooth",v:.3,d:1,s:.5},{w:"sine",v:11,t:11,a:.2,d:.05,s:.3,g:1}],[{w:"sine",v:.3,a:.06,d:1,s:.5},{w:"sine",v:7,f:1,d:1,s:.2,g:1}],[{w:"sawtooth",v:.3,a:.03,d:.7,s:.3,r:.2},{w:"sawtooth",v:.3,t:.75,d:.7,a:.1,s:.3,r:.2}],[{w:"triangle",v:.3,a:.01,d:.7,s:.5},{w:"square",v:5,t:.5,d:.7,s:.5,g:1}],[{w:"triangle",v:.3,a:.02,d:.3,s:.3,r:.3},{w:"square",v:3,t:4,f:1,a:.02,d:.1,s:1,g:1},{w:"triangle",v:.08,t:.5,a:.1,h:0,d:.1,s:.5,r:.1,b:0,c:0}],[{w:"sine",v:.3,a:.05,d:1,s:.7,r:.3},{w:"sine",v:2,f:1,d:.3,s:1,g:1}],[{w:"square",v:.3,a:.03,d:.5,s:.3,r:.1},{w:"square",v:4,f:1,a:.03,d:.1,g:1}],[{w:"triangle",v:.3,a:.08,d:1,s:.3,r:.1},{w:"square",v:2,f:1,d:.3,s:.3,g:1,t:4,a:.08}],[{w:"sine",v:.3,a:.05,d:1,s:.3,r:.1},{w:"sine",v:.1,t:2.001,f:1,d:1,s:50,g:1}],[{w:"triangle",v:.3,a:.03,d:.7,s:.3,r:.2},{w:"sine",v:12,t:7,f:1,d:.5,s:1.7,g:1}],[{w:"sine",v:.3,a:.05,d:1,s:.3,r:.1},{w:"sawtooth",v:22,t:6,d:.06,s:.3,g:1}],[{w:"triangle",v:.3,a:.05,d:11,r:.3},{w:"triangle",v:1,d:1,s:8,g:1}],[{w:"sawtooth",v:.3,d:4,s:.8,r:.1},{w:"square",v:1,t:2,f:8,a:1,d:1,s:1,r:.1,g:1}],[{w:"triangle",v:.3,d:1,s:.5,t:.8,a:.2,p:1.25,q:.2},{w:"sawtooth",v:.2,a:.2,d:.3,s:1,t:1.2,p:1.25,q:.2}],[{w:"sine",v:.3,d:1,s:.3},{w:"square",v:22,t:11,d:.5,s:.1,g:1}],[{w:"sawtooth",v:.3,a:.04,d:1,s:.8,r:.1},{w:"square",v:1,t:.5,d:1,s:2,g:1}],[{w:"triangle",v:.3,d:1,s:.3},{w:"sine",v:22,t:6,d:.6,s:.05,g:1}],[{w:"sine",v:.6,a:.1,d:.05,s:.4},{w:"sine",v:5,t:5,f:1,d:.05,s:.3,g:1}],[{w:"sine",a:.1,d:.05,s:.4,v:.8},{w:"sine",v:5,t:5,f:1,d:.05,s:.3,g:1}],[{w:"square",v:.3,a:.1,d:.1,s:.4},{w:"square",v:1,f:1,d:.3,s:.1,g:1}],[{w:"sawtooth",v:.3,d:.5,r:.5},{w:"sawtooth",v:11,t:5,d:.05,g:1}],[{w:"square",v:.3,d:.2,r:.2},{w:"square",v:7,t:3,d:.05,g:1}],[{w:"triangle",d:.2,r:.2},{w:"square",v:9,t:3,d:.1,r:.1,g:1}],[{w:"triangle",d:.3,r:.3},{w:"square",v:6,t:3,d:1,r:1,g:1}],[{w:"triangle",v:.4,d:.2,r:.2},{w:"square",v:22,t:12,d:.1,r:.1,g:1}],[{w:"sine",v:.25,a:.02,d:.05,s:.8},{w:"square",v:1,t:2,d:.03,s:11,g:1}],[{w:"sine",v:.3,a:.05,d:11},{w:"square",v:7,t:3,f:1,s:.7,g:1}],[{w:"square",v:.3,a:.05,d:.1,s:.8},{w:"square",v:4,d:.1,s:1.1,g:1}],[{w:"sine",v:.4,d:.3,r:.3},{w:"sine",v:7,t:9,d:.1,r:.1,g:1}],[{w:"sine",v:.7,d:.1,r:.1},{w:"sine",v:22,t:7,d:.05,g:1}],[{w:"sine",v:.6,d:.15,r:.15},{w:"square",v:11,t:3.2,d:.1,r:.1,g:1}],[{w:"sine",v:.8,d:.07,r:.07},{w:"square",v:11,t:7,r:.01,g:1}],[{w:"triangle",v:.7,t:.5,d:.2,r:.2,p:.95},{w:"n0",v:9,g:1,d:.2,r:.2}],[{w:"sine",v:.7,d:.1,r:.1,p:.9},{w:"square",v:14,t:2,d:.005,r:.005,g:1}],[{w:"square",d:.15,r:.15,p:.5},{w:"square",v:4,t:5,d:.001,r:.001,g:1}],[{w:"n1",v:.3,a:1,s:1,d:.15,r:0,t:.5}],[{w:"sine",t:12.5,d:0,r:0,p:.5,v:.3,h:.2,q:.5},{g:1,w:"sine",v:1,t:2,d:0,r:0,s:1},{g:1,w:"n0",v:.2,t:2,a:.6,h:0,d:.1,r:.1,b:0,c:0}],[{w:"n0",v:.2,a:.05,h:.02,d:.02,r:.02}],[{w:"n0",v:.4,a:1,d:1,t:.25}],[{w:"sine",v:.3,a:.1,d:1,s:.5},{w:"sine",v:4,t:0,f:1.5,d:1,s:1,r:.1,g:1},{g:1,w:"sine",v:4,t:0,f:2,a:.6,h:0,d:.1,s:1,r:.1,b:0,c:0}],[{w:"square",v:.3,t:.25,d:11,s:1},{w:"square",v:12,t:0,f:8,d:1,s:1,r:11,g:1}],[{w:"n0",v:.4,t:.5,a:1,d:11,s:1,r:.5},{w:"square",v:1,t:0,f:14,d:1,s:1,r:11,g:1}],[{w:"sine",t:0,f:1221,a:.2,d:1,r:.25,s:1},{g:1,w:"n0",v:3,t:.5,d:1,s:1,r:1}],[{w:"sine",d:.4,r:.4,p:.1,t:2.5,v:1},{w:"n0",v:12,t:2,d:1,r:1,g:1}]],this.drummapFormula=[[{w:"triangle",t:0,f:70,v:1,d:.05,h:.03,p:.9,q:.1},{w:"n0",g:1,t:6,v:17,r:.01,h:0,p:0}],[{w:"triangle",t:0,f:88,v:1,d:.05,h:.03,p:.5,q:.1},{w:"n0",g:1,t:5,v:42,r:.01,h:0,p:0}],[{w:"n0",f:222,p:0,t:0,r:.01,h:0}],[{w:"triangle",v:.3,f:180,d:.05,t:0,h:.03,p:.9,q:.1},{w:"n0",v:.6,t:0,f:70,h:.02,r:.01,p:0},{g:1,w:"square",v:2,t:0,f:360,r:.01,b:0,c:0}],[{w:"square",f:1150,v:.34,t:0,r:.03,h:.025,d:.03},{g:1,w:"n0",t:0,f:13,h:.025,d:.1,s:1,r:.1,v:1}],[{w:"triangle",f:200,v:1,d:.06,t:0,r:.06},{w:"n0",g:1,t:0,f:400,v:12,r:.02,d:.02}],[{w:"triangle",f:100,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.4,h:.015,d:.005,r:.005}],[{w:"n1",f:390,v:.25,r:.01,t:0}],[{w:"triangle",f:120,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.5,h:.015,d:.005,r:.005}],[{w:"n1",v:.25,f:390,r:.03,t:0,h:.005,d:.03}],[{w:"triangle",f:140,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.3,h:.015,d:.005,r:.005}],[{w:"n1",v:.25,f:390,t:0,d:.2,r:.2},{w:"n0",v:.3,t:0,c:0,f:440,h:.005,d:.05}],[{w:"triangle",f:155,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.3,h:.015,d:.005,r:.005}],[{w:"triangle",f:180,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.3,h:.015,d:.005,r:.005}],[{w:"n1",v:.3,f:1200,d:.2,r:.2,h:.05,t:0},{w:"n1",t:0,v:1,d:.1,r:.1,p:1.2,f:440}],[{w:"triangle",f:220,v:.9,d:.12,h:.02,p:.5,t:0,r:.12},{g:1,w:"n0",v:5,t:.3,h:.015,d:.005,r:.005}],[{w:"n1",f:500,v:.15,d:.4,r:.4,h:0,t:0},{w:"n0",v:.1,t:0,r:.01,f:440}],[{w:"n1",v:.3,f:800,d:.2,r:.2,h:.05,t:0},{w:"square",t:0,v:1,d:.1,r:.1,p:.1,f:220,g:1}],[{w:"sine",f:1651,v:.15,d:.2,r:.2,h:0,t:0},{w:"sawtooth",g:1,t:1.21,v:7.2,d:.1,r:11,h:1},{g:1,w:"n0",v:3.1,t:.152,d:.002,r:.002}],[{w:"n0",f:200,v:.2,d:.05,p:.9,t:0}],[{w:"n1",v:.3,f:1200,d:.2,r:.2,h:.05,t:0},{w:"n1",t:0,v:1,d:.1,r:.1,p:1.2,f:440}],[{w:"sine",f:800,v:.4,d:.06,t:0}],[{w:"n1",v:.3,f:555,d:.25,r:.25,h:.05,t:0},{w:"n1",t:0,v:1,d:.1,r:.1,f:440,a:.005,h:.02}],[{w:"sawtooth",f:776,v:.2,d:.3,t:0,r:.3},{g:1,w:"n0",v:2,t:0,f:776,a:.005,h:.02,d:.1,s:1,r:.1,c:0},{g:11,w:"sine",v:.1,t:0,f:22,d:.3,r:.3,b:0,c:0}],[{w:"n1",f:440,v:.15,d:.4,r:.4,h:0,t:0},{w:"n0",v:.4,t:0,r:.01,f:440}],[{w:"sine",f:200,d:.06,t:0}],[{w:"sine",f:150,d:.06,t:0}],[{w:"sine",f:300,t:0}],[{w:"sine",f:300,d:.06,t:0}],[{w:"sine",f:250,d:.06,t:0}],[{w:"square",f:300,v:.3,d:.06,p:.8,t:0}],[{w:"square",f:260,v:.3,d:.06,p:.8,t:0}],[{w:"sine",f:850,v:.5,d:.07,t:0}],[{w:"sine",f:790,v:.5,d:.07,t:0}],[{w:"n0",f:440,v:.3,a:.05,t:0}],[{w:"n0",f:440,v:.3,a:.05,t:0}],[{w:"triangle",f:1800,v:.4,p:.9,t:0,h:.03}],[{w:"triangle",f:1800,v:.3,p:.9,t:0,h:.13}],[{w:"n0",f:330,v:.3,a:.02,t:0,r:.01}],[{w:"n0",f:330,v:.3,a:.02,t:0,h:.04,r:.01}],[{w:"n0",f:440,v:.3,t:0}],[{w:"sine",f:800,t:0}],[{w:"sine",f:700,t:0}],[{w:"n0",f:330,v:.3,t:0}],[{w:"n0",f:330,v:.3,t:0,h:.1,r:.01,p:.7}],[{w:"sine",f:1720,v:.3,d:.02,t:0,r:.02},{w:"square",g:1,t:0,f:2876,v:6,d:.2,s:1,r:.2}],[{w:"sine",f:1720,v:.3,d:.25,t:0,r:.25},{w:"square",g:1,t:0,f:2876,v:6,d:.2,s:1,r:.2}]],this.wave={},this.releaseRatio=.3,this.programIdx=0,this.isPercussion=!1,this.notetab=[],this.disposed=!1,this.intervalID=-1,this.actx=t,this.output=t.createGain(),this.input=t.createGain(),this.wave.w9999=this._createWave("w9999"),this.initTimber(),this.actx.name&&"OfflineContext"==this.actx.name||this.actx.constructor&&("OfflineContext"==this.actx.constructor.name||"webkitOfflineAudioContext"==this.actx.constructor.name)||(this.intervalID=setInterval(()=>{for(let t=this.notetab.length-1;t>=0;--t){const e=this.notetab[t];this.actx.currentTime>e.e&&(this._pruneNote(e),this.notetab.splice(t,1))}},180))}allSoundOff(){for(let t=this.notetab.length-1;t>=0;t--){const e=this.notetab[t];this._pruneNote(e),this.notetab.splice(t,1)}}_limitVoices(){this.notetab.sort((t,e)=>t.finished!==e.finished?t.finished-e.finished:t.e!==e.e?e.e-t.e:e.t-t.t);for(let t=this.notetab.length-1;t>=0;t--){const e=this.notetab[t];if(this.actx.name&&"OfflineContext"==this.actx.name||this.actx.constructor&&("OfflineContext"==this.actx.constructor.name||"webkitOfflineAudioContext"==this.actx.constructor.name))return;(this.actx.currentTime>e.e||t>this.voicesCount)&&(this._pruneNote(e),this.notetab.splice(t,1))}}_note(t,e,n,s){const o=[],r=[],a=[],l=[],c=[],h=440*Math.pow(2,(e-69)/12);let u,p,d;this._limitVoices();for(let m=0;m10?(u=r[d.g-11].gain,p=1,l[m]=l[d.g-11]*d.t+d.f):void 0!==o[d.g-1].frequency?(u=o[d.g-1].frequency,p=l[d.g-1],l[m]=l[d.g-1]*d.t+d.f):(u=o[d.g-1].playbackRate,p=l[d.g-1]/440,l[m]=l[d.g-1]*d.t+d.f),d.w[0]){case"n":const e=this.actx.createBufferSource();e.buffer=Object(i.a)()[d.w],e.loop=!0,e.playbackRate.value=l[m]/440,o[m]=e,1!==d.p&&this._setParamTarget(o[m].playbackRate,l[m]/440*d.p,t,d.q);break;default:const n=this.actx.createOscillator();n.frequency.value=l[m],o[m]=n,1!==d.p&&this._setParamTarget(o[m].frequency,l[m]*d.p,t,d.q),"w"==d.w[0]?o[m].setPeriodicWave(this.wave[d.w]):o[m].type=d.w}r[m]=this.actx.createGain(),c[m]=d.r,o[m].connect(r[m]),r[m].connect(u),a[m]=p*d.v,d.k&&(a[m]*=Math.pow(2,(e-60)/12*d.k)),d.a?(r[m].gain.value=0,r[m].gain.setValueAtTime(0,t),r[m].gain.linearRampToValueAtTime(a[m],t+d.a)):r[m].gain.setValueAtTime(a[m],t);const f=t+d.a+d.h;this._setParamTarget(r[m].gain,d.s*a[m],f,d.d),o[m].start(t),this.isPercussion&&o[m].stop(t+s[0].d*this.releaseRatio)}this.isPercussion||this.notetab.push({t:t,e:99999,n:e,sourceNodes:o,gainNodes:r,t2:t+d.a,v:a,release:c,finished:0})}triggerAttackRelease(t,e,n,s){const i=Object(o.e)(t);i&&(this.noteOn(i,s,n),this.noteOff(i,n+e))}triggerAttack(t){const e=Object(o.e)(t);e&&this.noteOn(e,1,this.actx.currentTime)}triggerRelease(t){const e=Object(o.e)(t);e&&this.noteOff(e,this.actx.currentTime)}noteOn(t,e,n){0!=e?this.isPercussion?t>=35&&t<=81&&this._note(n,t,e,this.drummap[t-35].p):this._note(n,t,e,this.program[this.programIdx].p):this.noteOff(t,n)}noteOff(t,e){if(!this.isPercussion)for(let n=this.notetab.length-1;n>=0;n--){const s=this.notetab[n];e>=s.t&&s.n==t&&0==s.finished&&(s.finished=1,this._releaseNote(s,e))}}setProgram(t,e){this.isPercussion=t,this.programIdx=e}static getTimbreName(t,e){return!1===t?r.programNameList[e].name:r.drummapNamelist[e-35].name}getTimbreName(t,e){return!1===t?this.program[e].name:this.drummap[e-35].name}initTimber(){for(let t=0;t=35&&e<=81&&(this.drummap[e-35]={name:r.drummapNamelist[e-35].name,p:i(n)}),0==t&&e>=0&&e<=127&&(this.program[e]={name:r.programNameList[e].name,p:i(n)})}_pruneNote(t){for(let e=t.sourceNodes.length-1;e>=0;e--){let n=!1;void 0!==t.sourceNodes[e].frequency&&(n=!0),t.sourceNodes[e].disconnect(),n?t.sourceNodes[e].frequency.cancelScheduledValues(0):t.sourceNodes[e].playbackRate.cancelScheduledValues(0),t.sourceNodes[e].stop(0)}for(let e=t.gainNodes.length-1;e>=0;e--)t.gainNodes[e].disconnect(),t.gainNodes[e].gain.cancelScheduledValues(0)}_releaseNote(t,e){for(let n=t.gainNodes.length-1;n>=0;n--)t.gainNodes[n].gain.cancelScheduledValues(e),e==t.t2?t.gainNodes[n].gain.setValueAtTime(t.v[n],e):e1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=S(t,360),e=S(e,100),n=S(n,100),0===e)s=i=o=n;else{var a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;s=r(l,a,t+1/3),i=r(l,a,t),o=r(l,a,t-1/3)}return{r:255*s,g:255*i,b:255*o}}(s.h,c,u),p=!0,d="hsl"),s.hasOwnProperty("a")&&(l=s.a)),l=x(l),{ok:p,format:s.format||d,r:Math.min(255,Math.max(a.r,0)),g:Math.min(255,Math.max(a.g,0)),b:Math.min(255,Math.max(a.b,0)),a:l}}(i);this._originalInput=i,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=Math.round(100*this._a)/100,this._format=o.format||r.format,this._gradientType=o.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=r.ok}function i(t,e,n){t=S(t,255),e=S(e,255),n=S(n,255);var s,i,o=Math.max(t,e,n),r=Math.min(t,e,n),a=(o+r)/2;if(o==r)s=i=0;else{var l=o-r;switch(i=a>.5?l/(2-o-r):l/(o+r),o){case t:s=(e-n)/l+(e>1)+720)%360;--e;)i.h=(i.h+o)%360,r.push(s(i));return r}function b(t,e){e=e||6;for(var n=s(t).toHsv(),i=n.h,o=n.s,r=n.v,a=[],l=1/e;e--;)a.push(s({h:i,s:o,v:r})),r=(r+l)%1;return a}s.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,e,n,s=this.toRgb();return t=s.r/255,e=s.g/255,n=s.b/255,.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(t){return this._a=x(t),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var t=o(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=o(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),s=Math.round(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+s+"%)":"hsva("+e+", "+n+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var t=i(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=i(this._r,this._g,this._b),e=Math.round(360*t.h),n=Math.round(100*t.s),s=Math.round(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+s+"%)":"hsla("+e+", "+n+"%, "+s+"%, "+this._roundA+")"},toHex:function(t){return r(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,s,i){var o=[E(Math.round(t).toString(16)),E(Math.round(e).toString(16)),E(Math.round(n).toString(16)),E(T(s))];return i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*S(this._r,255))+"%",g:Math.round(100*S(this._g,255))+"%",b:Math.round(100*S(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*S(this._r,255))+"%, "+Math.round(100*S(this._g,255))+"%, "+Math.round(100*S(this._b,255))+"%)":"rgba("+Math.round(100*S(this._r,255))+"%, "+Math.round(100*S(this._g,255))+"%, "+Math.round(100*S(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(w[r(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+a(this._r,this._g,this._b,this._a),n=e,i=this._gradientType?"GradientType = 1, ":"";if(t){var o=s(t);n="#"+a(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,s=this._a<1&&this._a>=0;return e||!s||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return s(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(u,arguments)},brighten:function(){return this._applyModification(p,arguments)},darken:function(){return this._applyModification(d,arguments)},desaturate:function(){return this._applyModification(l,arguments)},saturate:function(){return this._applyModification(c,arguments)},greyscale:function(){return this._applyModification(h,arguments)},spin:function(){return this._applyModification(m,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(v,arguments)},complement:function(){return this._applyCombination(f,arguments)},monochromatic:function(){return this._applyCombination(b,arguments)},splitcomplement:function(){return this._applyCombination(_,arguments)},triad:function(){return this._applyCombination(g,[3])},tetrad:function(){return this._applyCombination(g,[4])}},s.fromRatio=function(e,n){if("object"==t(e)){var i={};for(var o in e)e.hasOwnProperty(o)&&(i[o]="a"===o?e[o]:P(e[o]));e=i}return s(e,n)},s.equals=function(t,e){return!(!t||!e)&&s(t).toRgbString()==s(e).toRgbString()},s.random=function(){return s.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},s.mix=function(t,e,n){n=0===n?0:n||50;var i=s(t).toRgb(),o=s(e).toRgb(),r=n/100;return s({r:(o.r-i.r)*r+i.r,g:(o.g-i.g)*r+i.g,b:(o.b-i.b)*r+i.b,a:(o.a-i.a)*r+i.a})},s.readability=function(t,e){var n=s(t),i=s(e);return(Math.max(n.getLuminance(),i.getLuminance())+.05)/(Math.min(n.getLuminance(),i.getLuminance())+.05)},s.isReadable=function(t,e,n){var i,o,r,a,l,c=s.readability(t,e);switch(o=!1,(r=n,a=((r=r||{level:"AA",size:"small"}).level||"AA").toUpperCase(),l=(r.size||"small").toLowerCase(),"AA"!==a&&"AAA"!==a&&(a="AA"),"small"!==l&&"large"!==l&&(l="small"),i={level:a,size:l}).level+i.size){case"AAsmall":case"AAAlarge":o=c>=4.5;break;case"AAlarge":o=c>=3;break;case"AAAsmall":o=c>=7}return o},s.mostReadable=function(t,e,n){var i,o,r,a,l=null,c=0;o=(n=n||{}).includeFallbackColors,r=n.level,a=n.size;for(var h=0;hc&&(c=i,l=s(e[h]));return s.isReadable(t,l,{level:r,size:a})||!o?l:(n.includeFallbackColors=!1,s.mostReadable(t,["#fff","#000"],n))};var y=s.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},w=s.hexNames=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}(y);function x(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function S(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var n=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function C(t){return Math.min(1,Math.max(0,t))}function k(t){return parseInt(t,16)}function E(t){return 1==t.length?"0"+t:""+t}function P(t){return t<=1&&(t=100*t+"%"),t}function T(t){return Math.round(255*parseFloat(t)).toString(16)}function M(t){return k(t)/255}var R,A,O,N=(A="[\\s|\\(]+("+(R="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+R+")[,|\\s]+("+R+")\\s*\\)?",O="[\\s|\\(]+("+R+")[,|\\s]+("+R+")[,|\\s]+("+R+")[,|\\s]+("+R+")\\s*\\)?",{CSS_UNIT:new RegExp(R),rgb:new RegExp("rgb"+A),rgba:new RegExp("rgba"+O),hsl:new RegExp("hsl"+A),hsla:new RegExp("hsla"+O),hsv:new RegExp("hsv"+A),hsva:new RegExp("hsva"+O),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});function D(t){return!!N.CSS_UNIT.exec(t)}return s}()},1385:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Header=e.keySignatureKeys=void 0;var s=n(1408),i=new WeakMap;e.keySignatureKeys=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"];var o=function(){function t(t){var n=this;if(this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name="",i.set(this,480),t){i.set(this,t.header.ticksPerBeat),t.tracks.forEach((function(t){t.forEach((function(t){t.meta&&("timeSignature"===t.type?n.timeSignatures.push({ticks:t.absoluteTime,timeSignature:[t.numerator,t.denominator]}):"setTempo"===t.type?n.tempos.push({bpm:6e7/t.microsecondsPerBeat,ticks:t.absoluteTime}):"keySignature"===t.type&&n.keySignatures.push({key:e.keySignatureKeys[t.key+7],scale:0===t.scale?"major":"minor",ticks:t.absoluteTime}))}))}));var s=0;t.tracks[0].forEach((function(t){s+=t.deltaTime,t.meta&&("trackName"===t.type?n.name=t.text:"text"!==t.type&&"cuePoint"!==t.type&&"marker"!==t.type&&"lyrics"!==t.type||n.meta.push({text:t.text,ticks:s,type:t.type}))})),this.update()}}return t.prototype.update=function(){var t=this,e=0,n=0;this.tempos.sort((function(t,e){return t.ticks-e.ticks})),this.tempos.forEach((function(s,i){var o=i>0?t.tempos[i-1].bpm:t.tempos[0].bpm,r=s.ticks/t.ppq-n,a=60/o*r;s.time=a+e,e=s.time,n+=r})),this.timeSignatures.sort((function(t,e){return t.ticks-e.ticks})),this.timeSignatures.forEach((function(e,n){var s=n>0?t.timeSignatures[n-1]:t.timeSignatures[0],i=(e.ticks-s.ticks)/t.ppq/s.timeSignature[0]/(s.timeSignature[1]/4);s.measures=s.measures||0,e.measures=i+s.measures}))},t.prototype.ticksToSeconds=function(t){var e=(0,s.search)(this.tempos,t);if(-1!==e){var n=this.tempos[e],i=n.time,o=(t-n.ticks)/this.ppq;return i+60/n.bpm*o}return.5*(t/this.ppq)},t.prototype.ticksToMeasures=function(t){var e=(0,s.search)(this.timeSignatures,t);if(-1!==e){var n=this.timeSignatures[e],i=(t-n.ticks)/this.ppq;return n.measures+i/(n.timeSignature[0]/n.timeSignature[1])/4}return t/this.ppq/4},Object.defineProperty(t.prototype,"ppq",{get:function(){return i.get(this)},enumerable:!1,configurable:!0}),t.prototype.secondsToTicks=function(t){var e=(0,s.search)(this.tempos,t,"time");if(-1!==e){var n=this.tempos[e],i=(t-n.time)/(60/n.bpm);return Math.round(n.ticks+i*this.ppq)}var o=t/.5;return Math.round(o*this.ppq)},t.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map((function(t){return{bpm:t.bpm,ticks:t.ticks}})),timeSignatures:this.timeSignatures}},t.prototype.fromJSON=function(t){this.name=t.name,this.tempos=t.tempos.map((function(t){return Object.assign({},t)})),this.timeSignatures=t.timeSignatures.map((function(t){return Object.assign({},t)})),this.keySignatures=t.keySignatures.map((function(t){return Object.assign({},t)})),this.meta=t.meta.map((function(t){return Object.assign({},t)})),i.set(this,t.ppq),this.update()},t.prototype.setTempo=function(t){this.tempos=[{bpm:t,ticks:0}],this.update()},t}();e.Header=o},1388:function(t,e,n){"use strict";n.d(e,"c",(function(){return a})),n.d(e,"b",(function(){return l})),n.d(e,"a",(function(){return c}));const s=JSON.parse('{"drumKits":{"bass":"QmSEoL9upG42nxb8JWEMDZkqQ4aocXe3Np5JaX4trZejaX.mp3","bass-drum":"Qmd6NueDE8d5NsSHisege9pxbEf3uLecSXrBxgWDecuoL9.mp3","brush":"QmYugobYqt8SNUxSbjNjfKGHVsC9aXB8kq441awV6uvuDH.mp3","clap":"QmYAymyGkq6zH94BgJgCPLP9serPh7RKnPJDG5C6zD36Xf.mp3","clave":"QmSA2v7sMwdgpGRVJSKm411oMgbiE7Lv27XFYFgun57WaJ.mp3","cowbell":"QmdN2pFi6Teh6RbokC6UnXZV3ZAwHUPzjfS4kPLADLcgiH.mp3","crash":"QmVtkx2PapsLn2DmCqBi4VdwfsMcNyWPAnNbsL59jSjv8g.mp3","floor-tom":"QmQfUMzZDGzgoHBahvkeN6ndqg1E7MHHSYKzkWJVYqj2Aa.mp3","high-tom":"QmYXXmd7pNFVqYhAVHfwBCp2au4X7N1fPRpnziH5Usbc8Y.mp3","hihat":"QmW4tEgoj3ZpYSXVAFuDUr3okrd7trx5xoD6fnoHs5Z7aC.mp3","hihat-cl":"QmPnujWr8jZeYLQaUX7xSNTLxK9WA6WtFAYRb1wxEePYTJ.mp3","hihat-closed":"QmaR28s6c3TYKyV7KuSMR13jXz1RvkZXJiTJYZFjEavDMN.mp3","hihat-jazz":"QmQ3faES4XkLXVE4tw5C7qD195aN5XSuBdudd2e2TNSDYQ.mp3","hihat-op":"QmU1epTBfkr4sx1bgJGuSAE5Pnsw4hGPPRRDCNYmeyqPZC.mp3","hihat-open":"QmZzeRdXCEjV3uUtyrkYXq7ddfZ6sFfnvbrBaQVqpuWoTX.mp3","kick":"QmTVhAjpBnp2fkshWxG7x4agHNNtw6sezHcVii8nidp4cm.mp3","kick-hit2":"QmcLenG3z8nenzvTVztboNN5raepyikxJNWWtyjoEGy677.mp3","kick-hit3":"QmYRcKeTtj8KYxUGHuiwCcZv6f9xyV61RTAdCGf5D8kmZh.mp3","low-tom":"QmQV1aBerLkqBvZS6wGphgTWK1doNXaKVvM9ZxcYpBH9mq.mp3","maracas":"QmSZ3HE7Zo2HXoc96xocx8huypZHxzGm7YJhva2ZJ1BMLz.mp3","medium-tom":"QmNX4WUR8Z22hm9Kbti9p2v7JbyfKAL76zJGyZYzT9bEcc.mp3","perc-1":"QmUT8M8b6Qx56FpQrHL4aiux2Zf7xKL42QWKWt7q4g3RDz.mp3","perc-2":"QmdpF1p4X5p1oeZtxwTyPkxwRzzQdFzZmpr1hDPgQ5W29B.mp3","perc-3":"QmVKgXs2arxD3CLucfuu1ToSUoQkmU4ksyAubQGhVbPZXd.mp3","perc-4":"Qmak27dbDYjRjuSNBehDAesWreyFSCxET1o9T4zGHnKx9D.mp3","rack-tom":"QmNX4WUR8Z22hm9Kbti9p2v7JbyfKAL76zJGyZYzT9bEcc.mp3","ride":"QmXoh6EPYHUkVWPj7HYrxwzNE1Q6R6UE56uLMedGNJ1FHy.mp3","snare":"QmQd33sK14FmkNcfK1HZ4nVuvhgxPt8dbhYvttdCNQnicp.mp3","snare-hit2":"QmSBGPSwwdaMidFhv6q9TwLN7o5Xs6PrW6MuzYuWYMYs8L.mp3","snare-hit3":"QmWkGdk1YtBEdMJQpL9uqV9hQRZYCdyHpREad7hbrqPoYk.mp3","snare-jazz":"QmbQ3kFTUaYDp14z2nud2zCuUD4Ao4ugBEHyDk8p665mxu.mp3"},"effects":{"acceleration":"QmSwteVxeNU9wo6ymgwgZuaHRP4WsRmNtW8SfqcukTEUYe.mp3","airhorn":"QmXNeXPiGGHKbY6ho9fBSbW3pJbf5ZH8d4fgsW6ATYxF8k.mp3","boo":"QmRwZyCAkWmFXgdzGZs4XVvQYxSghKeHtoGfj1xdnWa71t.mp3","boy_hurt":"QmYWbKcqgVSgo5gXVwb7QcsYsFVtUP1KzLWvQsFce6RGVh.mp3","break_block":"QmTaUJ7bmi2nCh8VeDxFZpx6kaSXNjuDBuRRCQZravJ1Za.mp3","bubbles":"QmVjPHRvHYSsXQLogo2fShAy42b9X2fGbL5jj9yP1FvaWT.mp3","death":"QmS7GbdxuGWoUpT1cramd1dCnmrMCCF9FbAwmCupqJJJov.mp3","dive":"QmemkF2gMae2SkXYxffhQVQoh6KgmHkTugrDEGWkMcVXKh.mp3","door_close":"QmbQWUYC6UQ9MemR5SMpkv5jPyQ4sBqdZXYHdGkQ9ibkm6.mp3","door_open":"QmeBquf5Pm85K17vkiYdNNq2gdn9qWzR21iiqcZqC2FmcR.mp3","double_jump":"QmeD93k5DuPDer1TGyxdm3AaDZbr2fFDm8eZHb44W1Caxj.mp3","drama":"QmbicxPot1SWDYNmbLyqu3QUeuWEeh6QUf4mpcKn6h5cw2.mp3","electric":"QmQK4arKsnmq3AbksocurGdFaxAQNSTRyqV1mU5y68XAUs.mp3","elephant":"QmZyhpzSMB9fxsSiP278q7qKCEQEgRRRbKZMkbMtL5KNiN.mp3","explode":"QmZ1FQxWDWvaLL7vnsLyvxCdwKoHLJJZvtpdeVN9v5Yc4z.mp3","footstep":"QmZpcdh2Mw2fW13mgcj3L8NjbSYmZGa26kVqSVb8xvkEoG.mp3","girl_hurt":"QmPGWu34kmGE2E6qUsM5w671hTSh8ikeTt9LizA9ZDNjwF.mp3","gunshot":"Qmdt8zng4wHSGNxshdFQGpDExffRtgftLqqSRgBgQH8WG8.mp3","hit":"QmXpmb2gUXfGJ9iSqwtWXZMJzp6L8kJqS4HpsJCh4gdhDG.mp3","jump":"QmYjQtVHnDJHdfGkVb31YAQxR5Yh6jeZmb4M33VYexKGX1.mp3","land":"QmTSfa9fptd4pzVv2QswVCbtYC7oSAu12NkoMmDYfugo7w.mp3","laugh":"QmUAbAcxUVxTH9TLFFBQkUZdzH9QceeJqpSCNZA6TWcmrV.mp3","place_block":"QmfUZkKKdgXR3gPDq5SmTNnJfeWg6xa2dXse4WBqDZFdLK.mp3","player_spawn":"QmXMgCjudjq7QwXDieQTMriL9sqmL2s6tspCoUaSZzHDSp.mp3","punch":"QmR1WTyca2aQ1hAMr8n82ULiYPDpjnKSR3Z5qECsFeCr4F.mp3","rain":"QmPK3sGJiddn6nBeBu28oDnb5ua8N8uhNrKrMNbVEnLXvA.mp3","reach_goal":"QmXpuMoAAf1QRJkh45WdKe7zAUDRqYoVBnxw8Wjy3wfzNZ.mp3","reach_record_point":"QmbhfMPCDg15nQgKrZm9f5enXhXcD9H7YMErVskFZVEabd.mp3","rooster":"QmPq3p35GgwD94m5n5YtmA9rfeGz7m3CamAQ3VrZkEZuT9.mp3","sad_trombone":"QmRRaq2MC5yTJYpktAa1dCVQmgNeXRrShnEpfg3pxG4Rcw.mp3","scream":"QmWc7ef1m9Tc3mCXvkmr3TTCcc7tHr4uj2y9AP9U68RNMz.mp3","send_chat":"QmWvY461DpP47bGR6MNVqE4UtcKXuDhKGLJPHS42HgtR4z.mp3","splash":"QmSAXXFwAFTnZCrw4qEWC9qjSuAvktHbCc8Xufarb9gwVh.mp3","swim":"Qmd5krXxH5UREqB4Qy4bhjLDmhVerCugSmK9VeRwsW3Xzt.mp3","sword1":"QmdbtQxdisg7DP9d5pgCEfkNFUzuNoq3XYLKB5rCHRba43.mp3","sword2":"QmVZ3rruiSyN15QRNNbWruiZLRpNgFCAVbvEUUCfGWjQUJ.mp3","time_start":"QmZtC4RzLcaKdqp7Rab6yrbiMuWuo8uZqNRhH6svaWGcpY.mp3","wolf":"QmeRsXcMUZLbLDySY5B7qqwkUWamkRvrTaQpK4ZqA5omro.mp3"},"fluteClean":{"A#4":"QmdwQZmH4bYGEz3zx6Rd7RzSAWPVS5vpuXaaXSP52K8fvK.mp3","A#5":"QmRZ5EsjWthGjYzS6DnLaLQUBSNexT5xaAsM8Q36rJxT1d.mp3","A#6":"QmNSLYxmnwQWd6epUZnwoTPycJAdsziv3aAX4pfrqhSBzf.mp3","C#4":"QmRkcUpJaoVkFkXyovA8jnxQ8NpisEBSnVJPDUN2EbnKd7.mp3","C#7":"QmavGcaKSaduU2T12B4edsx6FejRumsN4TeoRqJb84vUBu.mp3","C4":"Qmcu6jvPtAVDmD8rdrnaeTJKvNzqErsLRW8JyNR9ayv1WA.mp3","C5":"QmbpVb7oewmojXBu4cDnfUHP46XuhQc2tcFGYAqfRpfe18.mp3","C6":"QmTX7RNiDB4wZU6UbeFYRMBasXjajZ8r7LCRmFtGzEHF8e.mp3","C7":"QmXUccR3PpwDhS6DB3JhFcfC398PhqkVMdtMVZ33wCtuFK.mp3","D4":"Qma4hcVVqgsqWvSPhbkCGrUfrYzKfQr29hwGUAYo16tEzH.mp3","D5":"Qmct5TKcm5GmYePAu8yKvhBxSNRtYKNUjERh98Q1HLQ6CL.mp3","D6":"QmYv1YzQFDgy2GU6QSQkU18mkcmCyDMt4njRFQTpeE4tXH.mp3","D7":"QmVQk3tx8YdtBXuZ3kMyvH5EC5DeB7gUeUq8CdZvZdBnkX.mp3","E4":"QmVDKL2V9wLSmr81J2JziiASFcS9fWPssx4gQJKjaapCuu.mp3","E5":"QmcyKiEhGmYYgsC1jVb3GTB7aRH2MX6C8Vt3WMnohcv7CZ.mp3","E6":"QmUcQJiJSfsRa4T7ekFqxUpkXZFuC7GVsrbSkE4ZXd4CK2.mp3","F#4":"QmXan1q363pXCwf31VQ6UiFFUuJH3Z6BPLJ9WfEeNKJ2AJ.mp3","F#5":"QmaEMQmYe2pLacP9ELB1KDyetVZj7x4eBFMBk4R8LpRL7r.mp3","F#6":"QmRxgny9Bx3B75ZmypgnvahVvHfnBYux6F7qM9VRZVkY8L.mp3","G#4":"QmZYnb4QNu3w92szDggCYAUnA2ddaKUz8QyuNxeGQPk32A.mp3","G#5":"QmZd62FrQpPjr9ZqNVqsSSecu1K8FWpCxGhoiwVBTi8Yms.mp3","G#6":"QmZTyR89Hx1p2y4NBsXDVWTvR2iLsurXMn47yAv3m4Z2y8.mp3"},"salamander":{"A0":"Qmeud5cYxixdrQhKwCe6Ee3h3wQJ8rFudfFyapudZfapDg.mp3","A1":"QmPxFHuJdzdEpM9wpnZprV5X5rRfr1LvfpCKdyUq4hgjeS.mp3","A2":"QmQX2m5YhtpVz6Sd4uFJX8tShBT8R1RFsMnv52X77joyDm.mp3","A3":"QmXuDFTr2RAatzK1qHGGzteZhKDMy6PVJJs1ddSmCqLz3i.mp3","A4":"QmZXM2GPuGdgZ9ZZbYNxaJnsJ2s23umvdXcyLsyXfx9hdC.mp3","A5":"QmYzqK9YaETQSxAh2EAx97QiJNvuEp7c3beUTnbuwsssTj.mp3","A6":"QmabCUSiWHCv6oddXxkNYLFNiBBa3W3zjEvfqHrAqyW7Ty.mp3","A7":"QmWDoD2g3gvXfTb4fdBQVEA573spKc5kZQoCyseCyuQMSp.mp3","C1":"Qmbz1ar1WhqQ5obqPe3dQ24kcqPRSApDh41AEM52Pw4Bnc.mp3","C2":"QmVtVDftveocSLGeRcYiLrPf3g7mDZbbKgYmwB4NP1p94d.mp3","C3":"QmaxLmVJDcGteDReiFELdcS9im3Z9eNhZ2Dn9qwxDN5Ccg.mp3","C4":"QmVP3S9gzzCoYwfKtwH5rpZqN9mBpAV1at4N8JXQXJdcXF.mp3","C5":"QmRXWQUdWdfEMuDPzTN53DDmKvZX3ZUnLN5qXYS2HY6vnK.mp3","C6":"QmPEAQVPSamkiHpPTi4eqaGzSiFMWCfT3dmNLRu5WqRhxJ.mp3","C7":"QmVRg8R4HumA3ng2tLVNNW1U46uDxFvkqXE8DuwFwX8EoC.mp3","C8":"QmaW51fxc5aAPfiQV8LHGy6XjoTGhjJYQgzTdxUs31eDMD.mp3","Ds1":"QmQDzXghJqCixBrosLArYaedivm3Vhc6RbFH7rHKe6orv7.mp3","Ds2":"QmZBENDtDpQgytnufNCrpeew463VkMa7RyXnYZxJHFjuBA.mp3","Ds3":"QmTiZRzH5DbFeWcdusx372LHV32FUTXAwTfTFMUdQAPbPr.mp3","Ds4":"QmVDmcMpsP5h9Y7ZpgTkNn1QA3AojsThLUbwDJCJewiEW4.mp3","Ds5":"QmbDxYs1UxCoz8E98AfmJeXM6F6djJWTAQW3ixvWzKWk7V.mp3","Ds6":"QmeBX8DBEPfCKqLYktqVEYqvCUGjt7Dsjq7zVmaGQ4ByEH.mp3","Ds7":"QmcgbEFtFQSZ1c7VWioGmR5jCDjWskArdmcMGr8KQXWnV4.mp3","Fs1":"QmUadtEYcUjwZ2okYdow8VnKLH1Ukhw4QkrjDP1QuzAYdL.mp3","Fs2":"QmdE9VDsundWCiXUJbFr4AnqeSs5s2N5dTUBgEJAsXVEzi.mp3","Fs3":"QmYSRxZw6PfvdcbyYhjpiTsjwwfnPVkfQc1U33FwzSQgXD.mp3","Fs4":"QmUt8JPoJGHALwn4yGLg7RtLmFTyMpztQpHogMmSB5CCx3.mp3","Fs5":"QmeJXfxUrNaCmPr1fSUtnGwGPynn3psmEA4HQdPoc5fRFL.mp3","Fs6":"QmbdgVgmL2Y4XQvfRY1TFroEgwKz8cvmHSBnHMJAAzQVjZ.mp3","Fs7":"Qme5LHRZEPs5jGM4d7THxE1ACRNDhhEGBYBdzxQ7EiA6NJ.mp3","README":"QmNfeSP15wBWWue77KBZW4kRwAdKuibsoTJysoLTs6rHt9"},"spanishGuitar":{"A#1":"QmZotswRucR1VDJgJJDSbWSsmzh6xx8jxA4QWD5DYPfsPD.mp3","A#3":"QmSSx7zwDeX6Lhdo1VmfPxDLtdfUmgPWwRV5wH2anVX5tz.mp3","A#4":"QmU9aDQu2GRdSCabxBq5vAq9oivmFq1wmzkVwvryquvDNL.mp3","A#5":"QmYtEDmSDjsHzUjtYyiKCZNNd54z4iU7d7vePxiNypD8Gv.mp3","A1":"QmUHPyoE4vNVBqoscFdez9xM5QBWUrKWQyrhDM4mPBitu3.mp3","A2":"QmUBtjXBGCsJ4Xbh8b2uJqwcsaZMR6YZyUCQyyMC4a6NoD.mp3","A3":"QmX9kGJSHznFGYP8oRiXREfFZ7agna4CvKJf2DywdHWWJK.mp3","A4":"QmXukGMi2ewHRSMg1X1odNWgSvumnJNXiXATEvPQkMbL23.mp3","A5":"QmThQzuS5gUCTXJunbov6FELRwRDU2tBB6r1i2DWRivDEA.mp3","B1":"Qmf4yKdiecGAGWZkp3SGstW9jXEFPA5ZkC4FScUHJoiVr5.mp3","B2":"QmW712Ec1Lajn57eokudwCY51yX9n5rgCcxe5iWk155CtF.mp3","B3":"QmSGWhA2tKtEH7VhGwog8oDkYVPgvEcxY2txaXCb1F8gGm.mp3","B4":"QmcrJUCDh8EoZ8zTptNomsQeZRaKWmpZatGPzP9pcJhr4m.mp3","B5":"QmZDRNnxmAEp55YCnFnTdA7Zb99e9cB8HxdpqiDkwBQK3h.mp3","C#2":"QmfUbR1nTbiFztfUw86qSejwyE6xTr7Q44xmJyhxsUuQX6.mp3","C#4":"QmX8MWr9s7LHigPv9wvjU7HScQa567AfLenjFB9KW6Yjyx.mp3","C#5":"Qmf65jRaAKgmd81oavotpbymyBE1xXqNFAiEgvQ7nu2nAQ.mp3","C2":"QmUyR1ikWnXQSLLYh9Awmi1wtpRUR9igkezJViFJMD4AhJ.mp3","C3":"Qmf7bk8SE2FDbSSZ86FhZ5yiKCNs5GdpP4zTmK9e2T9mc5.mp3","C4":"QmSdNSGyqvpjMnpZnHjagZ8LB63a5PVZcyn4jQdDvce3Ty.mp3","C5":"QmPu7CFs9GsYY836t3ZuSGaonBWRYZ8FmWSYasyYifokL3.mp3","C6":"QmRwiVdC3WdYzqnHbK55x3gCNU1deKeLBezu6QwRaxdt6z.mp3","D#2":"QmQNSxBTqH3De54tSNeye4Zc57ravq39efmoNkaQfuVXCD.mp3","D#4":"QmUHXswzC7q19reehmRZRYDgH7jmmFUYxbBcJFqQkL5s7B.mp3","D#5":"QmWN9cehrm6JVtnnZftWu38gXqDo1e6XUcrggyVFRf5MZC.mp3","D2":"QmWyaF3gyw6mKtvBhiLuVVSZWwYqquj7P9h2wFidJCuZLy.mp3","D3":"QmcqY2f3DMDV2QeYsuf19ficdeB1ahVu3upBhrjksMyQ6L.mp3","D4":"QmS18Bqw5drRCRhurYvxNYtahKLRqqR5L6adtVTNfcjfz5.mp3","D5":"QmbymFPcnc7SmrMUpoxVYNb3KARcZCQHMmGipm7SG6Cr43.mp3","E2":"QmbFCYEGJ9zZh6gzq8fH6CbWr9QyRpRFAw3AZNY1k7M9pB.mp3","E3":"QmXJVjG5SrRPDyHtGH4PfF8B1JVUH4YpdtUq9cftEf2eUg.mp3","E4":"QmTZJxjkfiy2Cgi562cSnQ9KwQt2nVPGKDBGsthumtSwg7.mp3","E5":"QmcADe79nRX5R4EJ5iwQDLR6obf5dcj6bM35sGJJjdhcdE.mp3","F#3":"Qmb2V3Q3rAyiNzyHfLUC91BiS1ZsrW4Mtce3PMCgbsDCYh.mp3","F#4":"QmV1qfSoCN3E9MbyZNnDy67p4yw6SCyGF3MnE8tJrgof7U.mp3","F#5":"QmZcrUaqZUQcmRLBVuZHCnWpAot1AdKonQvYbNPVKiRtER.mp3","F2":"QmXjhysukJMmaZ55r2uVGtDz41PBSkWNvDmwD9986R5AEL.mp3","F3":"QmUXQRKzfLDh2QU5CFEvV1e4LSpu5vL2FMW33feq2Xxtza.mp3","F4":"QmdMymyJWA7FJiBxf25nzjMqjXi4DVeg1HTp66qFzUiiWb.mp3","F5":"QmWACKgeyPnioyLXsW6oDrMPVyVwast5ep2J1qWxCN6j2q.mp3","G#1":"Qme6DYDbDjvB4Y5XFzBhfkUyCFZeDWtmcmV4myku4Vb6Rn.mp3","G#3":"QmYT8hRLwkq3dY42ojpTaBfCPaJk6Yvs2uhkj27vKvUAEJ.mp3","G#5":"QmZReureEoU31okdN7aZy28PFwajjdverYihgk5euHqrmu.mp3","G1":"QmPcint3jEew7Qijh6V3BsEcSxZeJfDZgAyecCHEC1VepG.mp3","G2":"QmPrSn6x9oJxtXe1ZR8nQj9MNQiwRaU4ZMVL4HA3MG5Jqh.mp3","G3":"QmWV9V9bWBTTM8rChjDPunk4T5LUCghA4BD4qsSVQ8e1W8.mp3","G4":"Qmf2a9Ug18jQvAyzMVfGSgdbSj93JhyKvUtUy8J3ymcvaj.mp3","G5":"QmPapTmqMPaqDzeBgxmCo3UEUo1QqmTobggZpejqG2SjUP.mp3"},"steelStringGuitar":{"HV_40":"QmQPnBD7sBw1vC3RvcoGcbqHKNJdtxNgMeYA952LGHW8RH.mp3","HV_41":"QmbKLQ65ZsrXkopkQrBwuiUuwe9ziNm2a732SqACL6EsfD.mp3","HV_42":"QmPcD8N4KPdzE4gCwt41Aue2RSEnEdYxtsjSVtav5YbQXy.mp3","HV_43":"QmRh5kHPNQMDi61KjFGqgkDX1mTDo29yqvdUMQe16m8GcC.mp3","HV_44":"Qmd9akDTaMQJoujoZMwkvXXxojFQUs8yVkc5ucC5jatKRw.mp3","HV_45":"QmUCJV4mPsfAX4P5KweDRvyntRpocHj1HkBXKfLfi55fjn.mp3","HV_46":"QmUXY8V2KNnH33cayFVLgs1TXt7WZGvQTwhYGvkSyR3CYX.mp3","HV_47":"QmUBCuc9wreUaxMaP4ZXRDd9DxZu6Wji2zydzVBx1wQxS5.mp3","HV_48":"QmNqvbDPGW4dWkANkmfdizu2cxG4V9YqUPiwG5f5tW5Can.mp3","HV_49":"QmYW2xXvXRTwLpd5wdAtTUgbmXzKexwnVSQqrf7dvNCh68.mp3","HV_50":"QmUJhJkUNDvQaAFHRPaMFwwNv2ThEZKrhUa8vCo65yEXTo.mp3","HV_51":"QmQKUg3YadxfbgMBN634d6gk3eyJNaFT9kX1NMqsZPcC4u.mp3","HV_52":"QmaTdaRJXBdtME9PwrW7r2JPGRmvf7JC9pGCn1dzvM51nz.mp3","HV_53":"QmVm59onJcDbqvaWhi2hdBdErjRjUJWqoSwrkTLjkBTvtK.mp3","HV_55":"QmbsAWVvTvecRATRrVj26XSamgTehavoKPuz8EM1sJN1G5.mp3","HV_56":"QmT6NQCxrVhNuwBFZ1qA61rDLZV7MuuWW1Q27Lm3GRi9Yn.mp3","HV_57":"QmdjT3FAbX1fSjN2hmxjdQ38W1h7fhnAHTC4Dp8iiK3ido.mp3","HV_58":"QmQneoUSGWHdUEBacKSnDLxzbLkoFZoyKbLrHfQX7qRKQw.mp3","HV_59":"QmQu7rrX93pcvqv2jX59Jj8HouKnkgdVdqUvF2Dcz86Y8b.mp3","HV_60":"QmWzex1aGZWtjxeCiMSSEdpjS21TE7eqQfCZqdohECrmMB.mp3","HV_61":"QmPTSuPU75oZPSoHzPMMgaBxLF6zq1DWSDMHmBNWossnqz.mp3","HV_62":"QmbsRQpQnbFx6YFjahe3YnPTWMWtxDfF5nR7nsVewgZyY7.mp3","HV_63":"QmUgH63MuCTDG2WWG2PzduDEA1RyN6FAksS3ZnNijKqVnF.mp3","HV_64":"QmPZabrv3YJGPy5rzoXznj1rX37CFCXaTua7GHDdKLJ5BA.mp3","HV_65":"QmU9qLFHfggpvZAPkct7nZb7gx7Veucjz9SQ52F4QhVkP5.mp3","HV_66":"QmXAo8P2L5a5DMvCCkSwYxrNHACKDxZ3GU1QN9EAff5i7c.mp3","HV_67":"QmNawjutwdkFZVrc2scZ4NR2xbTDnvqceRFu7Lkw5zbxUr.mp3","HV_68":"QmQxVczBGRB78pPBWJ3YJzZzBSxLhLwx9E8CsroVFWbHUi.mp3","HV_69":"QmXvd1pVqkzKuBU6kZcxHiiH4i13LGGXQxVtENNwGPcXTp.mp3","HV_70":"QmckCAvYUCSqFsJ2YYwiLX2CmHxbjDB2iVtxFEPuwcVjJM.mp3","HV_71":"QmRwM3rh1iq8bZZDMKP2A7DE8fNqoy5NRq3EMQKZh1VmKM.mp3","HV_72":"QmZReoan1wcy945eLNkquzsmvzqoxdboW6x6rkLJoFDx9a.mp3","HV_73":"Qmau6HbbL9USZausADf54BAskpRpUPEqAdDwiN44XXJQk9.mp3","HV_74":"QmNTfYtrkj7qtL9utfbX9JcskMynhqr7Ex1XwfhZCLbcTE.mp3","HV_75":"QmciQGc2Qj52vUgH3w37SRp6gTV6BqH1J3iB2mpM1Sv7aM.mp3","HV_76":"Qma7iZ1VET8J4iUbTTzR7uSt3BmjjQkvKngae3RuvpHt6n.mp3","HV_77":"QmZXE5eVXcnTmgW4AF2VAqTsGFJs2swAmgbX8c6mpHdkSd.mp3","HV_78":"QmcL2SUubkMggfRgg448LSFjx5hg1kM55tCGy29dwonwFG.mp3","HV_79":"QmPAiXZE5wLny7z9PMJDmZx5FewMBJCSBxccV6XaCV7Uhn.mp3","HV_80":"QmYhrEbCqxSECkQoQjDSf1GwK9h41tYwPg1tGfVQyuFNcj.mp3","HV_82":"QmVaWamBytPWwdQean79NVpvBZn7RLerfRcV5hKnxGtCgM.mp3","HV_83":"QmR7BMDsEyQKRaYHdPTUnoLnGhQekrVgzG8jnyQo6wGYsJ.mp3","MV_54":"QmPSN8qcQC4vRuBeSmwe9AhNmrY5GPE7Us5QRjZfQP7kxR.mp3","MV_81":"QmQmChi2dai94CQzWZRGgg84kcZX6Lr6yynABquJoBurtY.mp3","MV_84":"QmR1Kr7VoxdennNW4sfMLQWxAa8hpQ3xvhBDNPpyrZBXCe.mp3"},"synthString":{"C2":"QmVhRmDUHiygSLSXP7YdhbfuQeBZG5RRoZm24ZpaxDXJGU.mp3","C3":"Qma7esgQCQjxAtubrumbmihW2avusrRsCVaST9Revmq6aS.mp3","C4":"QmT1oatEiQ9ZshpeFhQKeNBNFDWwpitE1naV3br631tSbT.mp3","C5":"QmaScMgvTAJdxPUUToGXGgBXuTQuAJsFQqNULYC6tW8oRr.mp3","C6":"Qmbq4Amh9HHaUqWMLyEWXzpkKyT3PwjxZ2r29D9dmQw1N2.mp3","C7":"QmYmdDreFUQ8AhZXTD8i4eKvyXwshE2FduBEhiUo7RBWMm.mp3","F#1":"QmaYry1d7d4ktMqrbNcspzyZX1bVoyb3P5GKngCed57mNx.mp3","F#2":"QmSFPgqpprsdQVXm7MeFRRTxRmMCPVZXK7ndFzHc7YExKx.mp3","F#3":"QmR3qR1vAc4KdiPcM7vYzmjk8eoXxzbSxoYRJqj7L93rU7.mp3","F#4":"Qmd9R44HvsH7WqpJVdDJV8hLxHSRcEhULNPKbKEimmgcxu.mp3","F#5":"QmTScwH3sHLKfdXjCVUym8voN1XkMRVpgpxgTogHbWB923.mp3","F#6":"QmevqLL3PbRrRNgapiJrSpRkrVegej8re7KnwwK6EyEafF.mp3"}}'),i={notes:{A1:s.spanishGuitar.A1,A2:s.spanishGuitar.A2,A3:s.spanishGuitar.A3,A4:s.spanishGuitar.A4,A5:s.spanishGuitar.A5,B1:s.spanishGuitar.B1,B2:s.spanishGuitar.B2,B3:s.spanishGuitar.B3,B4:s.spanishGuitar.B4,B5:s.spanishGuitar.B5,C2:s.spanishGuitar.C2,C3:s.spanishGuitar.C3,C4:s.spanishGuitar.C4,C5:s.spanishGuitar.C5,C6:s.spanishGuitar.C6,D2:s.spanishGuitar.D2,D3:s.spanishGuitar.D3,D4:s.spanishGuitar.D4,D5:s.spanishGuitar.D5,E2:s.spanishGuitar.E2,E3:s.spanishGuitar.E3,E4:s.spanishGuitar.E4,E5:s.spanishGuitar.E5,F2:s.spanishGuitar.F2,F3:s.spanishGuitar.F3,F4:s.spanishGuitar.F4,F5:s.spanishGuitar.F5,G1:s.spanishGuitar.G1,G2:s.spanishGuitar.G2,G3:s.spanishGuitar.G3,G4:s.spanishGuitar.G4,G5:s.spanishGuitar.G5},release:1},o={notes:{A0:s.salamander.A0,C1:s.salamander.C1,"D#1":s.salamander.Ds1,"F#1":s.salamander.Fs1,A1:s.salamander.A1,C2:s.salamander.C2,"D#2":s.salamander.Ds2,"F#2":s.salamander.Fs2,A2:s.salamander.A2,C3:s.salamander.C3,"D#3":s.salamander.Ds3,"F#3":s.salamander.Fs3,A3:s.salamander.A3,C4:s.salamander.C4,"D#4":s.salamander.Ds4,"F#4":s.salamander.Fs4,A4:s.salamander.A4,C5:s.salamander.C5,"D#5":s.salamander.Ds5,"F#5":s.salamander.Fs5,A5:s.salamander.A5,C6:s.salamander.C6,"D#6":s.salamander.Ds6,"F#6":s.salamander.Fs6,A6:s.salamander.A6,C7:s.salamander.C7,"D#7":s.salamander.Ds7,"F#7":s.salamander.Fs7,A7:s.salamander.A7,C8:s.salamander.C8},release:1},r={notes:{"A#4":s.fluteClean["A#4"],"A#5":s.fluteClean["A#5"],"A#6":s.fluteClean["A#6"],"C#4":s.fluteClean["C#4"],"C#7":s.fluteClean["C#7"],C4:s.fluteClean.C4,C5:s.fluteClean.C5,C6:s.fluteClean.C6,C7:s.fluteClean.C7,D4:s.fluteClean.D4,D5:s.fluteClean.D5,D6:s.fluteClean.D6,D7:s.fluteClean.D7,"F#4":s.fluteClean["F#4"],"F#5":s.fluteClean["F#5"],"F#6":s.fluteClean["F#6"],"G#4":s.fluteClean["G#4"],"G#5":s.fluteClean["G#5"],"G#6":s.fluteClean["G#6"]},release:1},a={salamander:o,spanishGuitar:i,steelStringGuitar:{notes:{E2:s.steelStringGuitar.HV_40,F2:s.steelStringGuitar.HV_41,"F#2":s.steelStringGuitar.HV_42,G2:s.steelStringGuitar.HV_43,"G#2":s.steelStringGuitar.HV_44,A2:s.steelStringGuitar.HV_45,"A#2":s.steelStringGuitar.HV_46,B2:s.steelStringGuitar.HV_47,C3:s.steelStringGuitar.HV_48,"C#3":s.steelStringGuitar.HV_49,D3:s.steelStringGuitar.HV_50,"D#3":s.steelStringGuitar.HV_51,E3:s.steelStringGuitar.HV_52,F3:s.steelStringGuitar.HV_53,"F#3":s.steelStringGuitar.MV_54,G3:s.steelStringGuitar.HV_55,"G#3":s.steelStringGuitar.HV_56,A3:s.steelStringGuitar.HV_57,"A#3":s.steelStringGuitar.HV_58,B3:s.steelStringGuitar.HV_59,C4:s.steelStringGuitar.HV_60,"C#4":s.steelStringGuitar.HV_61,D4:s.steelStringGuitar.HV_62,"D#4":s.steelStringGuitar.HV_63,E4:s.steelStringGuitar.HV_64,F4:s.steelStringGuitar.HV_65,"F#4":s.steelStringGuitar.HV_66,G4:s.steelStringGuitar.HV_67,"G#4":s.steelStringGuitar.HV_68,A4:s.steelStringGuitar.HV_69,"A#4":s.steelStringGuitar.HV_70,B4:s.steelStringGuitar.HV_71,C5:s.steelStringGuitar.HV_72,"C#5":s.steelStringGuitar.HV_73,D5:s.steelStringGuitar.HV_74,"D#5":s.steelStringGuitar.HV_75,E5:s.steelStringGuitar.HV_76,F5:s.steelStringGuitar.HV_77,"F#5":s.steelStringGuitar.HV_78,G5:s.steelStringGuitar.HV_79,"G#5":s.steelStringGuitar.HV_80,A5:s.steelStringGuitar.MV_81,"A#5":s.steelStringGuitar.HV_82,B5:s.steelStringGuitar.HV_83,C6:s.steelStringGuitar.MV_84},release:1},synthString:{notes:{C2:s.synthString.C2,C3:s.synthString.C3,C4:s.synthString.C4,C5:s.synthString.C5,C6:s.synthString.C6,C7:s.synthString.C7,"F#1":s.synthString["F#1"],"F#2":s.synthString["F#2"],"F#3":s.synthString["F#3"],"F#4":s.synthString["F#4"],"F#5":s.synthString["F#5"],"F#6":s.synthString["F#6"]},release:1},fluteClean:r},l={crash:s.drumKits.crash,"high-tom":s.drumKits["high-tom"],"hihat-cl":s.drumKits["hihat-cl"],"hihat-op":s.drumKits["hihat-op"],kick:s.drumKits.kick,"low-tom":s.drumKits["low-tom"],"medium-tom":s.drumKits["medium-tom"],snare:s.drumKits.snare,"floor-tom":s.drumKits["floor-tom"],"hihat-closed":s.drumKits["hihat-closed"],"hihat-open":s.drumKits["hihat-open"],"kick-hit2":s.drumKits["kick-hit2"],"rack-tom":s.drumKits["rack-tom"],ride:s.drumKits.ride,"snare-hit2":s.drumKits["snare-hit2"],bass:s.drumKits.bass,clap:s.drumKits.clap,clave:s.drumKits.clave,cowbell:s.drumKits.cowbell,hihat:s.drumKits.hihat,"kick-hit3":s.drumKits["kick-hit3"],maracas:s.drumKits.maracas,"snare-hit3":s.drumKits["snare-hit3"],"bass-drum":s.drumKits["bass-drum"],brush:s.drumKits.brush,"hihat-jazz":s.drumKits["hihat-jazz"],"perc-1":s.drumKits["perc-1"],"perc-2":s.drumKits["perc-2"],"perc-3":s.drumKits["perc-3"],"perc-4":s.drumKits["perc-4"],"snare-jazz":s.drumKits["snare-jazz"]},c={hit1:["crash","high-tom","hihat-cl","hihat-op","kick","low-tom","medium-tom","snare"],hit2:["crash","floor-tom","hihat-closed","hihat-open","kick-hit2","rack-tom","ride","snare-hit2"],hit3:["bass","clap","clave","cowbell","hihat","kick-hit3","maracas","snare-hit3"],jazz:["bass-drum","brush","hihat-jazz","perc-1","perc-2","perc-3","perc-4","snare-jazz"]}},1403:function(t,e,n){"undefined"!=typeof self&&self,t.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(s,i,function(e){return t[e]}.bind(null,i));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=16)}([function(t,e,n){!function(t,e,n,s){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=i(e),r=i(n),a=i(s),l=function(t,e,n){return{endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}},c=function(t,e,n){return{endTime:e,insertTime:n,type:"linearRampToValue",value:t}},h=function(t,e){return{startTime:e,type:"setValue",value:t}},u=function(t,e,n){return{duration:n,startTime:e,type:"setValueCurve",values:t}},p=function(t,e,n){var s=n.startTime,i=n.target,o=n.timeConstant;return i+(e-i)*Math.exp((s-t)/o)},d=function(t){return"exponentialRampToValue"===t.type},m=function(t){return"linearRampToValue"===t.type},f=function(t){return d(t)||m(t)},g=function(t){return"setValue"===t.type},_=function(t){return"setValueCurve"===t.type},v=function t(e,n,s,i){var o=e[n];return void 0===o?i:f(o)||g(o)?o.value:_(o)?o.values[o.values.length-1]:p(s,t(e,n-1,o.startTime,i),o)},b=function(t,e,n,s,i){return void 0===n?[s.insertTime,i]:f(n)?[n.endTime,n.value]:g(n)?[n.startTime,n.value]:_(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,v(t,e-1,n.startTime,i)]},y=function(t){return"cancelAndHold"===t.type},w=function(t){return"cancelScheduledValues"===t.type},x=function(t){return y(t)||w(t)?t.cancelTime:d(t)||m(t)?t.endTime:t.startTime},S=function(t,e,n,s){var i=s.endTime,o=s.value;return n===o?o:0=e:x(n)>=e})),s=this._automationEvents[n];if(-1!==n&&(this._automationEvents=this._automationEvents.slice(0,n)),y(t)){var i=this._automationEvents[this._automationEvents.length-1];if(void 0!==s&&f(s)){if(k(i))throw new Error("The internal list is malformed.");var o=_(i)?i.startTime+i.duration:x(i),r=_(i)?i.values[i.values.length-1]:i.value,a=d(s)?S(e,o,r,s):C(e,o,r,s),p=d(s)?l(a,e,this._currenTime):c(a,e,this._currenTime);this._automationEvents.push(p)}void 0!==i&&k(i)&&this._automationEvents.push(h(this.getValue(e),e)),void 0!==i&&_(i)&&i.startTime+i.duration>e&&(this._automationEvents[this._automationEvents.length-1]=u(new Float32Array([6,7]),i.startTime,e-i.startTime))}}else{var g=this._automationEvents.findIndex((function(t){return x(t)>e})),v=-1===g?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[g-1];if(void 0!==v&&_(v)&&x(v)+v.duration>e)return!1;var b=d(t)?l(t.value,t.endTime,this._currenTime):m(t)?c(t.value,e,this._currenTime):t;if(-1===g)this._automationEvents.push(b);else{if(_(t)&&e+t.duration>x(this._automationEvents[g]))return!1;this._automationEvents.splice(g,0,b)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return x(e)>t}));if(e>1){var n=this._automationEvents.slice(e-1),s=n[0];k(s)&&n.unshift(h(v(this._automationEvents,e-2,s.startTime,this._defaultValue),s.startTime)),this._automationEvents=n}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var e=this._automationEvents[this._automationEvents.length-1],n=this._automationEvents.findIndex((function(e){return x(e)>t})),s=this._automationEvents[n],i=x(e)<=t?e:this._automationEvents[n-1];if(void 0!==i&&k(i)&&(void 0===s||!f(s)||s.insertTime>t))return p(t,v(this._automationEvents,n-2,i.startTime,this._defaultValue),i);if(void 0!==i&&g(i)&&(void 0===s||!f(s)))return i.value;if(void 0!==i&&_(i)&&(void 0===s||!f(s)||i.startTime+i.duration>t))return tt.length)&&(e=t.length);for(var n=0,s=new Array(e);ng},_=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,v=(t,e)=>{const n=[];let s=t.replace(/^[\s]+/,""),i=s.match(_);for(;null!==i;){const t=i[1].slice(1,-1),o=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(o),s=s.slice(i[0].length).replace(/^[\s]+/,""),i=s.match(_)}return[n.join(";"),s]},b=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},y=t=>{if(!(t=>{try{new new Proxy(t,g)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},w=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},x=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[s]=n;return t.delete(s),s},S=(t,e,n,s)=>{const i=w(t,e),o=x(i,t=>t[0]===n&&t[1]===s);return 0===i.size&&t.delete(e),o},C=t=>w(p,t),k=t=>{if(r.has(t))throw new Error("The AudioNode is already stored.");r.add(t),C(t).forEach(t=>t(!0))},E=t=>"port"in t,P=t=>{if(!r.has(t))throw new Error("The AudioNode is not stored.");r.delete(t),C(t).forEach(t=>t(!1))},T=(t,e)=>{!E(t)&&e.every(t=>0===t.size)&&P(t)},M={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",fftSize:2048,maxDecibels:-30,minDecibels:-100,smoothingTimeConstant:.8},R=(t,e)=>t.context===e,A=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},O=()=>new DOMException("","IndexSizeError"),N=t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw O();throw t}})},D={numberOfChannels:1},B=-34028234663852886e22,I=-B,F=t=>r.has(t),V={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},j=t=>w(a,t),L=t=>w(c,t),q=(t,e)=>{const{activeInputs:n}=j(t);n.forEach(n=>n.forEach(([n])=>{e.includes(t)||q(n,[...e,t])}));const s=(t=>"playbackRate"in t)(t)?[t.playbackRate]:E(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t)(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of s){const n=L(t);void 0!==n&&n.activeInputs.forEach(([t])=>q(t,e))}F(t)&&P(t)},U=t=>{q(t.destination,[])},H=t=>"context"in t,W=t=>H(t[0]),Q=(t,e,n,s)=>{for(const e of t)if(n(e)){if(s)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},X=(t,e,[n,s],i)=>{Q(t,[e,n,s],t=>t[0]===e&&t[1]===n,i)},z=(t,[e,n,s],i)=>{const o=t.get(e);void 0===o?t.set(e,new Set([[n,s]])):Q(o,[n,s],t=>t[0]===n,i)},G=t=>"inputs"in t,Y=(t,e,n,s)=>{if(G(e)){const i=e.inputs[s];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,s),[e,n,s]},K=(t,e,n)=>{for(const s of t)if(s[0]===e&&s[1]===n)return t.delete(s),s;return null},Z=(t,e)=>{if(!C(t).delete(e))throw new Error("Missing the expected event listener.")},J=(t,e,n)=>{const s=w(t,e),i=x(s,t=>t[0]===n);return 0===s.size&&t.delete(e),i},$=(t,e,n,s)=>{G(e)?t.disconnect(e.inputs[s],n,0):t.disconnect(e,n,s)},tt=t=>w(l,t),et=t=>w(h,t),nt=t=>d.has(t),st=t=>!r.has(t),it=t=>new Promise(e=>{const n=t.createScriptProcessor(256,1,1),s=t.createGain(),i=t.createBuffer(1,2,44100),o=i.getChannelData(0);o[0]=1,o[1]=1;const r=t.createBufferSource();r.buffer=i,r.loop=!0,r.connect(n).connect(t.destination),r.connect(s),r.disconnect(s),n.onaudioprocess=s=>{const i=s.inputBuffer.getChannelData(0);Array.prototype.some.call(i,t=>1===t)?e(!0):e(!1),r.stop(),n.onaudioprocess=null,r.disconnect(n),n.disconnect(t.destination)},r.start()}),ot=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach((t,n)=>e(n,t))},rt=t=>"context"in t,at=(t,e,n,s,i)=>{const[o,r]=((t,e,n,s)=>{const{activeInputs:i,passiveInputs:o}=j(e),r=K(i[s],t,n);return null===r?[S(o,t,n,s)[2],!1]:[r[2],!0]})(t,n,s,i);if(null!==o&&(Z(t,o),!r||e||nt(t)||$(tt(t),tt(n),s,i)),F(n)){const{activeInputs:t}=j(n);T(n,t)}},lt=(t,e,n,s)=>{const[i,o]=((t,e,n)=>{const{activeInputs:s,passiveInputs:i}=L(e),o=K(s,t,n);return null===o?[J(i,t,n)[1],!1]:[o[2],!0]})(t,n,s);null!==i&&(Z(t,i),!o||e||nt(t)||tt(t).disconnect(et(n),s))};class ct{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach((n,s)=>t.call(e,n,s,this))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const ht={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function ut(t,e,n,s,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],s,i);else{const o=t.getChannelData(s);if(0===e[n].byteLength)e[n]=o.slice(i,i+128);else{const t=new Float32Array(o.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const pt=(t,e,n,s,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],s,i):0!==e[n].byteLength&&t.getChannelData(s).set(e[n],i)},dt=(t,e)=>{const n=[];for(let s=0;s{const a=null===e?128*Math.ceil(t.context.length/128):e.length,l=s.channelCount*s.numberOfInputs,c=i.reduce((t,e)=>t+e,0),h=0===c?null:n.createBuffer(c,a,n.sampleRate);if(void 0===o)throw new Error("Missing the processor constructor.");const u=j(t),p=await((t,e)=>{const n=w(f,t),s=tt(e);return w(n,s)})(n,t),d=dt(s.numberOfInputs,s.channelCount),m=dt(s.numberOfOutputs,i),g=Array.from(t.parameters.keys()).reduce((t,e)=>({...t,[e]:new Float32Array(128)}),{});for(let c=0;c0&&null!==e)for(let t=0;t{ut(e,g,t,l+n,c)});for(let t=0;t0===u.activeInputs[e].size?[]:t),e=r(c/n.sampleRate,n.sampleRate,()=>p.process(t,m,g));if(null!==h)for(let t=0,e=0;t{const s=e[n];if(void 0===s)throw t();return s},xt={attack:.003,channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",knee:30,ratio:12,release:.25,threshold:-24},St={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",gain:1},Ct=()=>new DOMException("","InvalidStateError"),kt=()=>new DOMException("","InvalidAccessError"),Et={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers"},Pt=(t,e,n,s,i,o,r,a,l,c,h)=>{const u=c.length;let p=a;for(let a=0;a{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,()=>{});return void 0!==n&&(n.catch(()=>{}),!0)}catch{}return!1},Rt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n]&&(t[n]=s)},At=(t,e)=>{Rt(t,e,"channelCount"),Rt(t,e,"channelCountMode"),Rt(t,e,"channelInterpretation")},Ot=t=>"function"==typeof t.getFloatTimeDomainData,Nt=(t,e,n)=>{const s=e[n];void 0!==s&&s!==t[n].value&&(t[n].value=s)},Dt=t=>{var e;t.start=(e=t.start,(n=0,s=0,i)=>{if("number"==typeof i&&i<0||s<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,s,i)})},Bt=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},It=(t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))),Ft=(t,e)=>{const n=t.createBiquadFilter();return At(n,e),Nt(n,e,"Q"),Nt(n,e,"detune"),Nt(n,e,"frequency"),Nt(n,e,"gain"),Rt(n,e,"type"),n},Vt=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return At(n,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Ct()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Ct()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Ct()}})})(n),n},jt=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),Lt=(t,e)=>{const n=t.createDelay(e.maxDelayTime);return At(n,e),Nt(n,e,"delayTime"),n},qt=(t,e)=>{const n=t.createGain();return At(n,e),Nt(n,e,"gain"),n};function Ut(t,e){const n=e[0]*e[0]+e[1]*e[1];return[(t[0]*e[0]+t[1]*e[1])/n,(t[1]*e[0]-t[0]*e[1])/n]}function Ht(t,e){let n=[0,0];for(let o=t.length-1;o>=0;o-=1)i=e,n=[(s=n)[0]*i[0]-s[1]*i[1],s[0]*i[1]+s[1]*i[0]],n[0]+=t[o];var s,i;return n}const Wt=(t,e,n,s)=>t.createScriptProcessor(e,n,s),Qt=()=>new DOMException("","NotSupportedError"),Xt={numberOfChannels:1},zt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",detune:0,frequency:440,periodicWave:void 0,type:"sine"},Gt={channelCount:2,channelCountMode:"clamped-max",channelInterpretation:"speakers",coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:1,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1},Yt={disableNormalization:!1},Kt={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",pan:0},Zt=()=>new DOMException("","UnknownError"),Jt={channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",curve:null,oversample:"none"},$t=t=>{if(null===t)return!1;const e=t.length;return e%2!=0?0!==t[Math.floor(e/2)]:t[e/2-1]+t[e/2]!==0},te=(t,e,n,s)=>{let i=Object.getPrototypeOf(t);for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:o,set:r}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(o),set:s(r)})},ee=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},ne=t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}},se=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},ie=()=>{try{new DOMException}catch{return!1}return!0},oe=()=>new Promise(t=>{const e=new ArrayBuffer(0),{port1:n,port2:s}=new MessageChannel;n.onmessage=({data:e})=>t(null!==e),s.postMessage(e,[e])}),re=(t,e)=>{const n=e.createGain();t.connect(n);const s=(i=t.disconnect,()=>{i.call(t,n),t.removeEventListener("ended",s)});var i;t.addEventListener("ended",s),jt(t,n),t.stop=(e=>{let s=!1;return(i=0)=>{if(s)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),s=!0}})(t.stop)},ae=(t,e)=>n=>{const s={value:t};return Object.defineProperties(n,{currentTarget:s,target:s}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},le=(ce=Q,(t,e,[n,s,i],o)=>{ce(t[s],[e,n,i],t=>t[0]===e&&t[1]===n,o)});var ce;const he=(t=>(e,n,[s,i,o],r)=>{const a=e.get(s);void 0===a?e.set(s,new Set([[i,n,o]])):t(a,[i,n,o],t=>t[0]===i&&t[1]===n,r)})(Q),ue=(t=>(e,n,s,i)=>t(e[i],t=>t[0]===n&&t[1]===s))(x),pe=new WeakMap,de=(t=>e=>{var n;return null!==(n=t.get(e))&&void 0!==n?n:0})(pe),me=(fe=new Map,ge=new WeakMap,(t,e)=>{const n=ge.get(t);if(void 0!==n)return n;const s=fe.get(t);if(void 0!==s)return s;try{const n=e();return n instanceof Promise?(fe.set(t,n),n.catch(()=>!1).then(e=>(fe.delete(t),ge.set(t,e),e))):(ge.set(t,n),n)}catch{return ge.set(t,!1),!1}});var fe,ge;const _e="undefined"==typeof window?null:window,ve=(be=me,ye=O,(t,e)=>{const n=t.createAnalyser();if(At(n,e),!(e.maxDecibels>e.minDecibels))throw ye();return Rt(n,e,"fftSize"),Rt(n,e,"maxDecibels"),Rt(n,e,"minDecibels"),Rt(n,e,"smoothingTimeConstant"),be(Ot,()=>Ot(n))||(t=>{t.getFloatTimeDomainData=e=>{const n=new Uint8Array(e.length);t.getByteTimeDomainData(n);const s=Math.max(n.length,t.fftSize);for(let t=0;t{const e=xe(t);if(null===e.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return e.renderer});var xe;const Se=((t,e,n)=>async(s,i,o,r)=>{const a=t(s),l=[...r,s];await Promise.all(a.activeInputs.map((t,r)=>Array.from(t).filter(([t])=>!l.includes(t)).map(async([t,a])=>{const c=e(t),h=await c.render(t,i,l),u=s.context.destination;n(t)||s===u&&n(s)||h.connect(o,a,r)})).reduce((t,e)=>[...t,...e],[]))})(j,we,nt),Ce=(ke=ve,Ee=tt,Pe=Se,()=>{const t=new WeakMap;return{render(e,n,s){const i=t.get(n);return void 0!==i?Promise.resolve(i):(async(e,n,s)=>{let i=Ee(e);if(!R(i,n)){const t={channelCount:i.channelCount,channelCountMode:i.channelCountMode,channelInterpretation:i.channelInterpretation,fftSize:i.fftSize,maxDecibels:i.maxDecibels,minDecibels:i.minDecibels,smoothingTimeConstant:i.smoothingTimeConstant};i=ke(n,t)}return t.set(n,i),await Pe(e,n,i,s),i})(e,n,s)}}});var ke,Ee,Pe;const Te=(Me=u,t=>{const e=Me.get(t);if(void 0===e)throw Ct();return e});var Me;const Re=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(_e),Ae=(Oe=Re,t=>null!==Oe&&t instanceof Oe);var Oe;const Ne=new WeakMap,De=(Be=ae,class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,e,n){if(null!==e){let s=this._listeners.get(e);void 0===s&&(s=Be(this,e),"function"==typeof e&&this._listeners.set(e,s)),this._nativeEventTarget.addEventListener(t,s,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const s=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===s?null:s,n)}});var Be;const Ie=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(_e),Fe=(Ve=Ie,t=>null!==Ve&&t instanceof Ve);var Ve;const je=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(_e),Le=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(_e),qe=((t,e,n,s,i,o,r,a,c,h,u,d,m,f,g)=>class extends h{constructor(e,s,i,o){super(i),this._context=e,this._nativeAudioNode=i;const r=u(e);d(r)&&!0!==n(it,()=>it(r))&&(t=>{const e=new Map;var n,s;t.connect=(n=t.connect.bind(t),(t,s=0,i=0)=>{const o=rt(t)?n(t,s,i):n(t,s),r=e.get(t);return void 0===r?e.set(t,[{input:i,output:s}]):r.every(t=>t.input!==i||t.output!==s)&&r.push({input:i,output:s}),o}),t.disconnect=(s=t.disconnect,(n,i,o)=>{if(s.apply(t),void 0===n)e.clear();else if("number"==typeof n)for(const[t,s]of e){const i=s.filter(t=>t.output!==n);0===i.length?e.delete(t):e.set(t,i)}else if(e.has(n))if(void 0===i)e.delete(n);else{const t=e.get(n);if(void 0!==t){const s=t.filter(t=>t.output!==i&&(t.input!==o||void 0===o));0===s.length?e.delete(n):e.set(n,s)}}for(const[n,s]of e)s.forEach(e=>{rt(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)})})})(i),l.set(this,i),p.set(this,new Set),"closed"!==e.state&&s&&k(this),t(this,o,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,n=0,a=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const l=u(this._context),h=g(l);if(m(t)||f(t))throw o();if(H(t)){const i=tt(t);try{const e=Y(this._nativeAudioNode,i,n,a),s=st(this);(h||s)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!s&&st(t)&&k(t)}catch(t){if(12===t.code)throw o();throw t}if(e(this,t,n,a,h)){const e=c([this],t);ot(e,s(h))}return t}const p=et(t);if("playbackRate"===p.name)throw r();try{this._nativeAudioNode.connect(p,n),(h||st(this))&&this._nativeAudioNode.disconnect(p,n)}catch(t){if(12===t.code)throw o();throw t}if(((t,e,n,s)=>{const{activeInputs:i,passiveInputs:o}=L(e),{outputs:r}=j(t),a=C(t),l=r=>{const a=tt(t),l=et(e);if(r){const e=J(o,t,n);X(i,t,e,!1),s||nt(t)||a.connect(l,n)}else{const e=((t,e,n)=>x(t,t=>t[0]===e&&t[1]===n))(i,t,n);z(o,e,!1),s||nt(t)||a.disconnect(l,n)}};return!!Q(r,[e,n],t=>t[0]===e&&t[1]===n,!0)&&(a.add(l),F(t)?X(i,t,[n,l],!0):z(o,[t,n,l],!0),!0)})(this,t,n,h)){const e=c([this],t);ot(e,s(h))}}disconnect(t,e,n){let s;const r=u(this._context),l=g(r);if(void 0===t)s=((t,e)=>{const n=j(t),s=[];for(const i of n.outputs)W(i)?at(t,e,...i):lt(t,e,...i),s.push(i[0]);return n.outputs.clear(),s})(this,l);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();s=((t,e,n)=>{const s=j(t),i=[];for(const o of s.outputs)o[1]===n&&(W(o)?at(t,e,...o):lt(t,e,...o),i.push(o[0]),s.outputs.delete(o));return i})(this,l,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(H(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(s=((t,e,n,s,i)=>{const o=j(t);return Array.from(o.outputs).filter(t=>!(t[0]!==n||void 0!==s&&t[1]!==s||void 0!==i&&t[2]!==i)).map(n=>(W(n)?at(t,e,...n):lt(t,e,...n),o.outputs.delete(n),n[0]))})(this,l,t,e,n),0===s.length)throw o()}for(const t of s){const e=c([this],t);ot(e,a)}}})((Ue=a,(t,e,n)=>{const s=[];for(let t=0;t(d,m,f,g,_)=>{const{activeInputs:v,passiveInputs:b}=o(m),{outputs:y}=o(d),w=a(d),x=o=>{const a=l(m),c=l(d);if(o){const e=S(b,d,f,g);t(v,d,e,!1),_||u(d)||n(c,a,f,g),p(m)&&k(m)}else{const t=s(v,d,f,g);e(b,g,t,!1),_||u(d)||i(c,a,f,g);const n=r(m);0===n?h(m)&&T(m,v):setTimeout(()=>{h(m)&&T(m,v)},1e3*n)}};return!!c(y,[m,f,g],t=>t[0]===m&&t[1]===f&&t[2]===g,!0)&&(w.add(x),h(d)?t(v,d,[f,g,x],!0):e(b,g,[d,f,x],!0),!0)})(le,he,Y,ue,$,j,de,C,tt,Q,F,nt,st),me,((t,e,n,s,i,o)=>r=>(a,l)=>{const c=t.get(a);if(void 0===c){if(!r&&o(a)){const t=s(a),{outputs:o}=n(a);for(const n of o)if(W(n)){const i=s(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,l)}else t.set(a,c+l)})(d,$,j,tt,et,F),O,kt,Qt,((t,e,n,s,i,o,r,a)=>(l,c)=>{const h=e.get(l);if(void 0===h)throw new Error("Missing the expected cycle count.");const u=o(l.context),p=a(u);if(h===c){if(e.delete(l),!p&&r(l)){const e=s(l),{outputs:o}=n(l);for(const n of o)if(W(n)){const i=s(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(l,h-c)})(Y,d,j,tt,et,Te,F,Ae),((t,e,n)=>function s(i,o){const r=H(o)?o:n(t,o);if((t=>"delayTime"in t)(r))return[];if(i[0]===r)return[i];if(i.includes(r))return[];const{outputs:a}=e(r);return Array.from(a).map(t=>s([...i,r],t[0])).reduce((t,e)=>t.concat(e),[])})(Ne,j,w),De,Te,Fe,je,Le,Ae);var Ue;const He=((t,e,n,s,i,o)=>class extends t{constructor(t,n){const r=i(t),a={...M,...n},l=s(r,a);super(t,!1,l,o(r)?e():null),this._nativeAnalyserNode=l}get fftSize(){return this._nativeAnalyserNode.fftSize}set fftSize(t){this._nativeAnalyserNode.fftSize=t}get frequencyBinCount(){return this._nativeAnalyserNode.frequencyBinCount}get maxDecibels(){return this._nativeAnalyserNode.maxDecibels}set maxDecibels(t){const e=this._nativeAnalyserNode.maxDecibels;if(this._nativeAnalyserNode.maxDecibels=t,!(t>this._nativeAnalyserNode.minDecibels))throw this._nativeAnalyserNode.maxDecibels=e,n()}get minDecibels(){return this._nativeAnalyserNode.minDecibels}set minDecibels(t){const e=this._nativeAnalyserNode.minDecibels;if(this._nativeAnalyserNode.minDecibels=t,!(this._nativeAnalyserNode.maxDecibels>t))throw this._nativeAnalyserNode.minDecibels=e,n()}get smoothingTimeConstant(){return this._nativeAnalyserNode.smoothingTimeConstant}set smoothingTimeConstant(t){this._nativeAnalyserNode.smoothingTimeConstant=t}getByteFrequencyData(t){this._nativeAnalyserNode.getByteFrequencyData(t)}getByteTimeDomainData(t){this._nativeAnalyserNode.getByteTimeDomainData(t)}getFloatFrequencyData(t){this._nativeAnalyserNode.getFloatFrequencyData(t)}getFloatTimeDomainData(t){this._nativeAnalyserNode.getFloatTimeDomainData(t)}})(qe,Ce,O,ve,Te,Ae),We=new WeakSet,Qe=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(_e),Xe=(ze=new Uint32Array(1),t=>(ze[0]=t,ze[0]));var ze;const Ge=((t,e)=>n=>{n.copyFromChannel=(s,i,o=0)=>{const r=t(o),a=t(i);if(a>=n.numberOfChannels)throw e();const l=n.length,c=n.getChannelData(a),h=s.length;for(let t=r<0?-r:0;t+r{const r=t(o),a=t(i);if(a>=n.numberOfChannels)throw e();const l=n.length,c=n.getChannelData(a),h=s.length;for(let t=r<0?-r:0;t+re=>{e.copyFromChannel=(n=>(s,i,o=0)=>{const r=t(o),a=t(i);if(r(s,i,o=0)=>{const r=t(o),a=t(i);if(r{let l=null;return class c{constructor(c){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:h,numberOfChannels:u,sampleRate:p}={...D,...c};null===l&&(l=new i(1,1,44100));const d=null!==s&&e(o,o)?new s({length:h,numberOfChannels:u,sampleRate:p}):l.createBuffer(u,h,p);if(0===d.numberOfChannels)throw n();return"function"!=typeof d.copyFromChannel?(r(d),N(d)):e(A,()=>A(d))||a(d),t.add(d),d}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===c.prototype||t.has(e)}}})(We,me,Qt,Qe,Re,(Ze=Qe,()=>{if(null===Ze)return!1;try{new Ze({length:1,sampleRate:44100})}catch{return!1}return!0}),Ge,Ye);var Ze;const Je=($e=qt,(t,e)=>{const n=$e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});e.connect(n).connect(t.destination);const s=()=>{e.removeEventListener("ended",s),e.disconnect(n),n.disconnect()};e.addEventListener("ended",s)});var $e;const tn=((t,e,n)=>async(s,i,o,r)=>{const a=e(s);await Promise.all(Array.from(a.activeInputs).map(async([e,s])=>{const a=t(e),l=await a.render(e,i,r);n(e)||l.connect(o,s)}))})(we,L,nt),en=(t=>(e,n,s,i)=>t(n,e,s,i))(tn),nn=((t,e,n,s,i,o,r,a,l,c,h)=>(l,u)=>{const p=l.createBufferSource();return At(p,u),Nt(p,u,"playbackRate"),Rt(p,u,"buffer"),Rt(p,u,"loop"),Rt(p,u,"loopEnd"),Rt(p,u,"loopStart"),e(n,()=>n(l))||(t=>{t.start=(e=>{let n=!1;return(s=0,i=0,o)=>{if(n)throw Ct();e.call(t,s,i,o),n=!0}})(t.start)})(p),e(s,()=>s(l))||(t=>{var e;t.start=(e=t.start,(n=0,s=0,i)=>{const o=t.buffer,r=null===o?s:Math.min(o.duration,s);null!==o&&r>o.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,r,i)})})(p),e(i,()=>i(l))||c(p,l),e(o,()=>o(l))||Dt(p),e(r,()=>r(l))||h(p,l),e(a,()=>a(l))||Bt(p),t(l,p),p})(Je,me,t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1},t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0},t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0},ee,ne,se,0,(sn=te,(t,e)=>{const n=e.createBuffer(1,1,44100);null===t.buffer&&(t.buffer=n),sn(t,"buffer",e=>()=>{const s=e.call(t);return s===n?null:s},e=>s=>e.call(t,null===s?n:s))}),re);var sn;const on=((t,e)=>(n,s,i,o)=>(t(s).replay(i),e(s,n,i,o)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(L),tn),rn=((t,e,n,s,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(l,c,h){const u=o.get(c);return void 0!==u?Promise.resolve(u):(async(l,c,h)=>{let u=n(l);const p=R(u,c);if(!p){const t={buffer:u.buffer,channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,loop:u.loop,loopEnd:u.loopEnd,loopStart:u.loopStart,playbackRate:u.playbackRate.value};u=e(c,t),null!==r&&u.start(...r),null!==a&&u.stop(a)}return o.set(c,u),p?await t(c,l.playbackRate,u.playbackRate,h):await s(c,l.playbackRate,u.playbackRate,h),await i(l,c,u,h),u})(l,c,h)}}})(en,nn,tt,on,Se),an=((t,e,n,s,i,r,a,l,c,h,u,p)=>(s,d,m,f=null,g=null)=>{const _=new o.AutomationEventList(m.defaultValue),v=d?(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:s}=n;e.exponentialRampToValueAtTime(s,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:s}=n;e.linearRampToValueAtTime(s,t)}else if("setTarget"===n.type){const{startTime:t,target:s,timeConstant:i}=n;e.setTargetAtTime(s,t,i)}else if("setValue"===n.type){const{startTime:t,value:s}=n;e.setValueAtTime(s,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:s,values:i}=n;e.setValueCurveAtTime(i,s,t)}}}}))(_):null,b={get defaultValue(){return m.defaultValue},get maxValue(){return null===f?m.maxValue:f},get minValue(){return null===g?m.minValue:g},get value(){return m.value},set value(t){m.value=t,b.setValueAtTime(t,s.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof m.cancelAndHoldAtTime)null===v&&_.flush(s.context.currentTime),_.add(i(t)),m.cancelAndHoldAtTime(t);else{const e=Array.from(_).pop();null===v&&_.flush(s.context.currentTime),_.add(i(t));const n=Array.from(_).pop();m.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?m.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?m.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?m.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&m.setValueCurveAtTime(n.values,n.startTime,n.duration))}return b},cancelScheduledValues:t=>(null===v&&_.flush(s.context.currentTime),_.add(r(t)),m.cancelScheduledValues(t),b),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;return null===v&&_.flush(s.context.currentTime),_.add(a(t,e)),m.exponentialRampToValueAtTime(t,e),b},linearRampToValueAtTime:(t,e)=>(null===v&&_.flush(s.context.currentTime),_.add(l(t,e)),m.linearRampToValueAtTime(t,e),b),setTargetAtTime:(t,e,n)=>(null===v&&_.flush(s.context.currentTime),_.add(c(t,e,n)),m.setTargetAtTime(t,e,n),b),setValueAtTime:(t,e)=>(null===v&&_.flush(s.context.currentTime),_.add(h(t,e)),m.setValueAtTime(t,e),b),setValueCurveAtTime(t,e,n){const i=t instanceof Float32Array?t:new Float32Array(t);if(null!==p&&"webkitAudioContext"===p.name){const t=e+n,o=s.context.sampleRate,r=Math.ceil(e*o),a=Math.floor(t*o),l=a-r,c=new Float32Array(l);for(let t=0;t{ln.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),Ne,h,0,o.createCancelAndHoldAutomationEvent,o.createCancelScheduledValuesAutomationEvent,o.createExponentialRampToValueAutomationEvent,o.createLinearRampToValueAutomationEvent,o.createSetTargetAutomationEvent,o.createSetValueAutomationEvent,o.createSetValueCurveAutomationEvent,Ie);var ln;const cn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,s){const a=o(t),l={...V,...s},c=i(a,l),h=r(a),u=h?e():null;super(t,!1,c,u),this._audioBufferSourceNodeRenderer=u,this._isBufferNullified=!1,this._isBufferSet=null!==l.buffer,this._nativeAudioBufferSourceNode=c,this._onended=null,this._playbackRate=n(this,h,c.playbackRate,I,B)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw s();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){k(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),F(this)&&P(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(qe,rn,an,Ct,nn,Te,Ae,ae),hn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,e){const n=o(t),s=r(n),l=i(n,e,s);super(t,!1,l,s?(t=>{let e=null;return{render:(n,s,i)=>(null===e&&(e=(async(e,n,s)=>{const i=n.destination;return await t(e,n,i,s),i})(n,s,i)),e)}})(a):null),this._isNodeOfNativeOfflineAudioContext=s,this._nativeAudioDestinationNode=l}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw s();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(qe,0,O,Ct,((t,e)=>(n,s,i)=>{const o=n.destination;if(o.channelCount!==s)try{o.channelCount=s}catch{}i&&"explicit"!==o.channelCountMode&&(o.channelCountMode="explicit"),0===o.maxChannelCount&&Object.defineProperty(o,"maxChannelCount",{value:s});const r=t(n,{channelCount:s,channelCountMode:o.channelCountMode,channelInterpretation:o.channelInterpretation,gain:1});return e(r,"channelCount",t=>()=>t.call(r),t=>e=>{t.call(r,e);try{o.channelCount=e}catch(t){if(e>o.maxChannelCount)throw t}}),e(r,"channelCountMode",t=>()=>t.call(r),t=>e=>{t.call(r,e),o.channelCountMode=e}),e(r,"channelInterpretation",t=>()=>t.call(r),t=>e=>{t.call(r,e),o.channelInterpretation=e}),Object.defineProperty(r,"maxChannelCount",{get:()=>o.maxChannelCount}),r.connect(o),r})(qt,te),Te,Ae,Se),un=((t,e,n,s,i)=>()=>{const o=new WeakMap;return{render(r,a,l){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a,l)=>{let c=n(r);const h=R(c,a);if(!h){const t={Q:c.Q.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,detune:c.detune.value,frequency:c.frequency.value,gain:c.gain.value,type:c.type};c=e(a,t)}return o.set(a,c),h?(await t(a,r.Q,c.Q,l),await t(a,r.detune,c.detune,l),await t(a,r.frequency,c.frequency,l),await t(a,r.gain,c.gain,l)):(await s(a,r.Q,c.Q,l),await s(a,r.detune,c.detune,l),await s(a,r.frequency,c.frequency,l),await s(a,r.gain,c.gain,l)),await i(r,a,c,l),c})(r,a,l)}}})(en,Ft,tt,on,Se),pn=(t=>(e,n)=>t.set(e,n))(pe),dn=(mn=qe,fn=an,gn=un,_n=kt,vn=Ft,bn=Te,yn=Ae,wn=pn,class extends mn{constructor(t,e){const n=bn(t),s={...ft,...e},i=vn(n,s),o=yn(n);super(t,!1,i,o?gn():null),this._Q=fn(this,o,i.Q,I,B),this._detune=fn(this,o,i.detune,1200*Math.log2(I),-1200*Math.log2(I)),this._frequency=fn(this,o,i.frequency,t.sampleRate/2,0),this._gain=fn(this,o,i.gain,40*Math.log10(I),B),this._nativeBiquadFilterNode=i,wn(this,1)}get detune(){return this._detune}get frequency(){return this._frequency}get gain(){return this._gain}get Q(){return this._Q}get type(){return this._nativeBiquadFilterNode.type}set type(t){this._nativeBiquadFilterNode.type=t}getFrequencyResponse(t,e,n){if(this._nativeBiquadFilterNode.getFrequencyResponse(t,e,n),t.length!==e.length||e.length!==n.length)throw _n()}});var mn,fn,gn,_n,vn,bn,yn,wn;const xn=((t,e)=>(n,s,i)=>{const o=new Set;var r,a;return n.connect=(r=n.connect,(i,a=0,l=0)=>{const c=0===o.size;if(e(i))return r.call(n,i,a,l),t(o,[i,a,l],t=>t[0]===i&&t[1]===a&&t[2]===l,!0),c&&s(),i;r.call(n,i,a),t(o,[i,a],t=>t[0]===i&&t[1]===a,!0),c&&s()}),n.disconnect=(a=n.disconnect,(t,s,r)=>{const l=o.size>0;if(void 0===t)a.apply(n),o.clear();else if("number"==typeof t){a.call(n,t);for(const e of o)e[1]===t&&o.delete(e)}else{e(t)?a.call(n,t,s,r):a.call(n,t,s);for(const e of o)e[0]!==t||void 0!==s&&e[1]!==s||void 0!==r&&e[2]!==r||o.delete(e)}const c=0===o.size;l&&c&&i()}),n})(Q,je),Sn=(Cn=Ct,kn=xn,(t,e)=>{e.channelCount=1,e.channelCountMode="explicit",Object.defineProperty(e,"channelCount",{get:()=>1,set:()=>{throw Cn()}}),Object.defineProperty(e,"channelCountMode",{get:()=>"explicit",set:()=>{throw Cn()}});const n=t.createBufferSource();kn(e,()=>{const t=e.numberOfInputs;for(let s=0;sn.disconnect(e))});var Cn,kn;const En=((t,e)=>(n,s)=>{const i=n.createChannelMerger(s.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),At(i,s),i})(Ie,Sn),Pn=((t,e,n,s,i)=>class extends t{constructor(t,o){const r=s(t),a={...gt,...o};super(t,!1,n(r,a),i(r)?e():null)}})(qe,((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o,r){const a=s.get(o);return void 0!==a?Promise.resolve(a):(async(i,o,r)=>{let a=e(i);if(!R(a,o)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfInputs:a.numberOfInputs};a=t(o,e)}return s.set(o,a),await n(i,o,a,r),a})(i,o,r)}}})(En,tt,Se),En,Te,Ae),Tn=((t,e,n,s,i,o)=>class extends t{constructor(t,o){const r=s(t),a=(t=>({...t,channelCount:t.numberOfOutputs}))({..._t,...o});super(t,!1,n(r,a),i(r)?e():null)}})(qe,((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o,r){const a=s.get(o);return void 0!==a?Promise.resolve(a):(async(i,o,r)=>{let a=e(i);if(!R(a,o)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,numberOfOutputs:a.numberOfOutputs};a=t(o,e)}return s.set(o,a),await n(i,o,a,r),a})(i,o,r)}}})(Vt,tt,Se),Vt,Te,Ae),Mn=((t,e,n,s)=>(i,{offset:o,...r})=>{const a=i.createBuffer(1,2,44100),l=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),c=n(i,{...r,gain:o}),h=a.getChannelData(0);h[0]=1,h[1]=1,l.buffer=a,l.loop=!0;const u={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){c.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){c.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){c.channelInterpretation=t},get context(){return c.context},get inputs(){return[]},get numberOfInputs(){return l.numberOfInputs},get numberOfOutputs(){return c.numberOfOutputs},get offset(){return c.gain},get onended(){return l.onended},set onended(t){l.onended=t},addEventListener:(...t)=>l.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>l.dispatchEvent(t[0]),removeEventListener:(...t)=>l.removeEventListener(t[0],t[1],t[2]),start(t=0){l.start.call(l,t)},stop(t=0){l.stop.call(l,t)}};return t(i,l),s(jt(u,c),()=>l.connect(c),()=>l.disconnect(c))})(Je,nn,qt,xn),Rn=((t,e,n,s,i)=>(o,r)=>{if(void 0===o.createConstantSource)return n(o,r);const a=o.createConstantSource();return At(a,r),Nt(a,r,"offset"),e(s,()=>s(o))||Dt(a),e(i,()=>i(o))||Bt(a),t(o,a),a})(Je,me,Mn,ee,se),An=((t,e,n,s,i,o,r)=>class extends t{constructor(t,r){const a=i(t),l={...vt,...r},c=s(a,l),h=o(a),u=h?n():null;super(t,!1,c,u),this._constantSourceNodeRenderer=u,this._nativeConstantSourceNode=c,this._offset=e(this,h,c.offset,I,B),this._onended=null}get offset(){return this._offset}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeConstantSourceNode.onended=e;const n=this._nativeConstantSourceNode.onended;this._onended=null!==n&&n===e?t:n}start(t=0){if(this._nativeConstantSourceNode.start(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.start=t),"closed"!==this.context.state){k(this);const t=()=>{this._nativeConstantSourceNode.removeEventListener("ended",t),F(this)&&P(this)};this._nativeConstantSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeConstantSourceNode.stop(t),null!==this._constantSourceNodeRenderer&&(this._constantSourceNodeRenderer.stop=t)}})(qe,an,((t,e,n,s,i)=>()=>{const o=new WeakMap;let r=null,a=null;return{set start(t){r=t},set stop(t){a=t},render(l,c,h){const u=o.get(c);return void 0!==u?Promise.resolve(u):(async(l,c,h)=>{let u=n(l);const p=R(u,c);if(!p){const t={channelCount:u.channelCount,channelCountMode:u.channelCountMode,channelInterpretation:u.channelInterpretation,offset:u.offset.value};u=e(c,t),null!==r&&u.start(r),null!==a&&u.stop(a)}return o.set(c,u),p?await t(c,l.offset,u.offset,h):await s(c,l.offset,u.offset,h),await i(l,c,u,h),u})(l,c,h)}}})(en,Rn,tt,on,Se),Rn,Te,Ae,ae),On=((t,e)=>(n,s)=>{const i=n.createConvolver();if(At(i,s),s.disableNormalization===i.normalize&&(i.normalize=!s.disableNormalization),Rt(i,s,"buffer"),s.channelCount>2)throw t();if(e(i,"channelCount",t=>()=>t.call(i),e=>n=>{if(n>2)throw t();return e.call(i,n)}),"max"===s.channelCountMode)throw t();return e(i,"channelCountMode",t=>()=>t.call(i),e=>n=>{if("max"===n)throw t();return e.call(i,n)}),i})(Qt,te),Nn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=s(t),l={...bt,...r},c=n(a,l);super(t,!1,c,i(a)?e():null),this._isBufferNullified=!1,this._nativeConvolverNode=c,null!==l.buffer&&o(this,l.buffer.duration)}get buffer(){return this._isBufferNullified?null:this._nativeConvolverNode.buffer}set buffer(t){if(this._nativeConvolverNode.buffer=t,null===t&&null!==this._nativeConvolverNode.buffer){const t=this._nativeConvolverNode.context;this._nativeConvolverNode.buffer=t.createBuffer(1,1,44100),this._isBufferNullified=!0,o(this,0)}else this._isBufferNullified=!1,o(this,null===this._nativeConvolverNode.buffer?0:this._nativeConvolverNode.buffer.duration)}get normalize(){return this._nativeConvolverNode.normalize}set normalize(t){this._nativeConvolverNode.normalize=t}})(qe,((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o,r){const a=s.get(o);return void 0!==a?Promise.resolve(a):(async(i,o,r)=>{let a=e(i);if(!R(a,o)){const e={buffer:a.buffer,channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,disableNormalization:!a.normalize};a=t(o,e)}return s.set(o,a),G(a)?await n(i,o,a.inputs[0],r):await n(i,o,a,r),a})(i,o,r)}}})(On,tt,Se),On,Te,Ae,pn),Dn=((t,e,n,s,i,o,r)=>class extends t{constructor(t,a){const l=i(t),c={...yt,...a},h=s(l,c),u=o(l);super(t,!1,h,u?n(c.maxDelayTime):null),this._delayTime=e(this,u,h.delayTime),r(this,c.maxDelayTime)}get delayTime(){return this._delayTime}})(qe,an,((t,e,n,s,i)=>o=>{const r=new WeakMap;return{render(a,l,c){const h=r.get(l);return void 0!==h?Promise.resolve(h):(async(a,l,c)=>{let h=n(a);const u=R(h,l);if(!u){const t={channelCount:h.channelCount,channelCountMode:h.channelCountMode,channelInterpretation:h.channelInterpretation,delayTime:h.delayTime.value,maxDelayTime:o};h=e(l,t)}return r.set(l,h),u?await t(l,a.delayTime,h.delayTime,c):await s(l,a.delayTime,h.delayTime,c),await i(a,l,h,c),h})(a,l,c)}}})(en,Lt,tt,on,Se),Lt,Te,Ae,pn),Bn=(In=Qt,(t,e)=>{const n=t.createDynamicsCompressor();if(At(n,e),e.channelCount>2)throw In();if("max"===e.channelCountMode)throw In();return Nt(n,e,"attack"),Nt(n,e,"knee"),Nt(n,e,"ratio"),Nt(n,e,"release"),Nt(n,e,"threshold"),n});var In;const Fn=((t,e,n,s,i,o,r,a)=>class extends t{constructor(t,i){const l=o(t),c={...xt,...i},h=s(l,c),u=r(l);super(t,!1,h,u?n():null),this._attack=e(this,u,h.attack),this._knee=e(this,u,h.knee),this._nativeDynamicsCompressorNode=h,this._ratio=e(this,u,h.ratio),this._release=e(this,u,h.release),this._threshold=e(this,u,h.threshold),a(this,.006)}get attack(){return this._attack}get channelCount(){return this._nativeDynamicsCompressorNode.channelCount}set channelCount(t){const e=this._nativeDynamicsCompressorNode.channelCount;if(this._nativeDynamicsCompressorNode.channelCount=t,t>2)throw this._nativeDynamicsCompressorNode.channelCount=e,i()}get channelCountMode(){return this._nativeDynamicsCompressorNode.channelCountMode}set channelCountMode(t){const e=this._nativeDynamicsCompressorNode.channelCountMode;if(this._nativeDynamicsCompressorNode.channelCountMode=t,"max"===t)throw this._nativeDynamicsCompressorNode.channelCountMode=e,i()}get knee(){return this._knee}get ratio(){return this._ratio}get reduction(){return"number"==typeof this._nativeDynamicsCompressorNode.reduction.value?this._nativeDynamicsCompressorNode.reduction.value:this._nativeDynamicsCompressorNode.reduction}get release(){return this._release}get threshold(){return this._threshold}})(qe,an,((t,e,n,s,i)=>()=>{const o=new WeakMap;return{render(r,a,l){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a,l)=>{let c=n(r);const h=R(c,a);if(!h){const t={attack:c.attack.value,channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,knee:c.knee.value,ratio:c.ratio.value,release:c.release.value,threshold:c.threshold.value};c=e(a,t)}return o.set(a,c),h?(await t(a,r.attack,c.attack,l),await t(a,r.knee,c.knee,l),await t(a,r.ratio,c.ratio,l),await t(a,r.release,c.release,l),await t(a,r.threshold,c.threshold,l)):(await s(a,r.attack,c.attack,l),await s(a,r.knee,c.knee,l),await s(a,r.ratio,c.ratio,l),await s(a,r.release,c.release,l),await s(a,r.threshold,c.threshold,l)),await i(r,a,c,l),c})(r,a,l)}}})(en,Bn,tt,on,Se),Bn,Qt,Te,Ae,pn),Vn=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=i(t),l={...St,...r},c=s(a,l),h=o(a);super(t,!1,c,h?n():null),this._gain=e(this,h,c.gain,I,B)}get gain(){return this._gain}})(qe,an,((t,e,n,s,i)=>()=>{const o=new WeakMap;return{render(r,a,l){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a,l)=>{let c=n(r);const h=R(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,gain:c.gain.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.gain,c.gain,l):await s(a,r.gain,c.gain,l),await i(r,a,c,l),c})(r,a,l)}}})(en,qt,tt,on,Se),qt,Te,Ae),jn=((t,e,n,s)=>(i,o,{channelCount:r,channelCountMode:a,channelInterpretation:l,feedback:c,feedforward:h})=>{const u=It(o,i.sampleRate),p=c instanceof Float64Array?c:new Float64Array(c),d=h instanceof Float64Array?h:new Float64Array(h),m=p.length,f=d.length,g=Math.min(m,f);if(0===m||m>20)throw s();if(0===p[0])throw e();if(0===f||f>20)throw s();if(0===d[0])throw e();if(1!==p[0]){for(let t=0;t{const e=t.inputBuffer,n=t.outputBuffer,s=e.numberOfChannels;for(let t=0;t_.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>_.dispatchEvent(t[0]),getFrequencyResponse(e,n,s){if(e.length!==n.length||n.length!==s.length)throw t();const i=e.length;for(let t=0;t_.removeEventListener(t[0],t[1],t[2])},_)})(kt,Ct,Wt,Qt),Ln=((t,e,n,s)=>i=>t(Mt,()=>Mt(i))?Promise.resolve(t(s,s)).then(t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()}):new Promise(t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()}))(me,qt,Wt,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),s=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise(t=>{n.oncomplete=()=>{s.disconnect(),t(0!==n.currentTime)},n.startRendering()})})(qt,Re)),qn=((t,e,n,s,i)=>(o,r)=>{const a=new WeakMap;let l=null;const c=async(c,h,u)=>{let p=null,d=e(c);const m=R(d,h);if(void 0===h.createIIRFilter?p=t(h,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}):m||(d=h.createIIRFilter(r,o)),a.set(h,null===p?d:p),null!==p){if(null===l){if(null===n)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new n(c.context.destination.channelCount,c.context.length,h.sampleRate);l=(async()=>(await s(c,t,t.destination,u),((t,e,n,s)=>{const i=n instanceof Float64Array?n:new Float64Array(n),o=s instanceof Float64Array?s:new Float64Array(s),r=i.length,a=o.length,l=Math.min(r,a);if(1!==i[0]){for(let t=0;tclass extends t{constructor(t,r){const a=s(t),l=i(a),c={...Et,...r},h=e(a,l?null:t.baseLatency,c);super(t,!1,h,l?n(c.feedback,c.feedforward):null),(t=>{var e;t.getFrequencyResponse=(e=t.getFrequencyResponse,(n,s,i)=>{if(n.length!==s.length||s.length!==i.length)throw kt();return e.call(t,n,s,i)})})(h),this._nativeIIRFilterNode=h,o(this,1)}getFrequencyResponse(t,e,n){return this._nativeIIRFilterNode.getFrequencyResponse(t,e,n)}})(qe,(Un=jn,(t,e,n)=>{if(void 0===t.createIIRFilter)return Un(t,e,n);const s=t.createIIRFilter(n.feedforward,n.feedback);return At(s,n),s}),qn,Te,Ae,pn),Wn=((t,e,n,s,i)=>(o,r)=>{const a=r.listener,{forwardX:l,forwardY:c,forwardZ:h,positionX:u,positionY:p,positionZ:d,upX:m,upY:f,upZ:g}=void 0===a.forwardX?(()=>{const l=e(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),c=i(r),h=s(r,256,9,0),u=(e,s)=>{const i=n(r,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:s});return i.connect(l,0,e),i.start(),Object.defineProperty(i.offset,"defaultValue",{get:()=>s}),t({context:o},c,i.offset,I,B)};let p=[0,0,-1,0,1,0],d=[0,0,0];return h.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0],t.getChannelData(3)[0],t.getChannelData(4)[0],t.getChannelData(5)[0]];e.some((t,e)=>t!==p[e])&&(a.setOrientation(...e),p=e);const n=[t.getChannelData(6)[0],t.getChannelData(7)[0],t.getChannelData(8)[0]];n.some((t,e)=>t!==d[e])&&(a.setPosition(...n),d=n)},l.connect(h),{forwardX:u(0,0),forwardY:u(1,0),forwardZ:u(2,-1),positionX:u(6,0),positionY:u(7,0),positionZ:u(8,0),upX:u(3,0),upY:u(4,1),upZ:u(5,0)}})():a;return{get forwardX(){return l},get forwardY(){return c},get forwardZ(){return h},get positionX(){return u},get positionY(){return p},get positionZ(){return d},get upX(){return m},get upY(){return f},get upZ(){return g}}})(an,En,Rn,Wt,Ae),Qn=new WeakMap,Xn=((t,e,n,s,i,o)=>class extends n{constructor(n,o){super(n),this._nativeContext=n,u.set(this,n),s(n)&&i.set(n,new Set),this._destination=new t(this,o),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?o(this,t):null;this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(hn,Wn,De,Ae,Qn,ae),zn=((t,e,n,s,i,o)=>(r,a)=>{const l=r.createOscillator();return At(l,a),Nt(l,a,"detune"),Nt(l,a,"frequency"),void 0!==a.periodicWave?l.setPeriodicWave(a.periodicWave):Rt(l,a,"type"),e(n,()=>n(r))||Dt(l),e(s,()=>s(r))||o(l,r),e(i,()=>i(r))||Bt(l),t(r,l),l})(Je,me,ee,ne,se,re),Gn=((t,e,n,s,i,o,r)=>class extends t{constructor(t,r){const a=i(t),l={...zt,...r},c=n(a,l),h=o(a),u=h?s():null,p=t.sampleRate/2;super(t,!1,c,u),this._detune=e(this,h,c.detune,153600,-153600),this._frequency=e(this,h,c.frequency,p,-p),this._nativeOscillatorNode=c,this._onended=null,this._oscillatorNodeRenderer=u,null!==this._oscillatorNodeRenderer&&void 0!==l.periodicWave&&(this._oscillatorNodeRenderer.periodicWave=l.periodicWave)}get detune(){return this._detune}get frequency(){return this._frequency}get onended(){return this._onended}set onended(t){const e="function"==typeof t?r(this,t):null;this._nativeOscillatorNode.onended=e;const n=this._nativeOscillatorNode.onended;this._onended=null!==n&&n===e?t:n}get type(){return this._nativeOscillatorNode.type}set type(t){this._nativeOscillatorNode.type=t,null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=null)}setPeriodicWave(t){this._nativeOscillatorNode.setPeriodicWave(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.periodicWave=t)}start(t=0){if(this._nativeOscillatorNode.start(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.start=t),"closed"!==this.context.state){k(this);const t=()=>{this._nativeOscillatorNode.removeEventListener("ended",t),F(this)&&P(this)};this._nativeOscillatorNode.addEventListener("ended",t)}}stop(t=0){this._nativeOscillatorNode.stop(t),null!==this._oscillatorNodeRenderer&&(this._oscillatorNodeRenderer.stop=t)}})(qe,an,zn,((t,e,n,s,i)=>()=>{const o=new WeakMap;let r=null,a=null,l=null;return{set periodicWave(t){r=t},set start(t){a=t},set stop(t){l=t},render(c,h,u){const p=o.get(h);return void 0!==p?Promise.resolve(p):(async(c,h,u)=>{let p=n(c);const d=R(p,h);if(!d){const t={channelCount:p.channelCount,channelCountMode:p.channelCountMode,channelInterpretation:p.channelInterpretation,detune:p.detune.value,frequency:p.frequency.value,periodicWave:null===r?void 0:r,type:p.type};p=e(h,t),null!==a&&p.start(a),null!==l&&p.stop(l)}return o.set(h,p),d?(await t(h,c.detune,p.detune,u),await t(h,c.frequency,p.frequency,u)):(await s(h,c.detune,p.detune,u),await s(h,c.frequency,p.frequency,u)),await i(c,h,p,u),p})(c,h,u)}}})(en,zn,tt,on,Se),Te,Ae,ae),Yn=(Kn=nn,(t,e)=>{const n=Kn(t,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),s=t.createBuffer(1,2,44100);return n.buffer=s,n.loop=!0,n.connect(e),n.start(),()=>{n.stop(),n.disconnect(e)}});var Kn;const Zn=((t,e,n,s,i)=>(o,{curve:r,oversample:a,...l})=>{const c=o.createWaveShaper(),h=o.createWaveShaper();At(c,l),At(h,l);const u=n(o,{...l,gain:1}),p=n(o,{...l,gain:-1}),d=n(o,{...l,gain:1}),m=n(o,{...l,gain:-1});let f=null,g=!1,_=null;const v={get bufferSize(){},get channelCount(){return c.channelCount},set channelCount(t){u.channelCount=t,p.channelCount=t,c.channelCount=t,d.channelCount=t,h.channelCount=t,m.channelCount=t},get channelCountMode(){return c.channelCountMode},set channelCountMode(t){u.channelCountMode=t,p.channelCountMode=t,c.channelCountMode=t,d.channelCountMode=t,h.channelCountMode=t,m.channelCountMode=t},get channelInterpretation(){return c.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t,p.channelInterpretation=t,c.channelInterpretation=t,d.channelInterpretation=t,h.channelInterpretation=t,m.channelInterpretation=t},get context(){return c.context},get curve(){return _},set curve(n){if(null!==n&&n.length<2)throw e();if(null===n)c.curve=n,h.curve=n;else{const t=n.length,e=new Float32Array(t+2-t%2),s=new Float32Array(t+2-t%2);e[0]=n[0],s[0]=-n[t-1];const i=Math.ceil((t+1)/2),o=(t+1)/2-1;for(let r=1;ru.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2])};return null!==r&&(v.curve=r instanceof Float32Array?r:new Float32Array(r)),a!==v.oversample&&(v.oversample=a),i(jt(v,d),()=>{u.connect(c).connect(d),u.connect(p).connect(h).connect(m).connect(d),g=!0,s(_)&&(f=t(o,u))},()=>{u.disconnect(c),c.disconnect(d),u.disconnect(p),p.disconnect(h),h.disconnect(m),m.disconnect(d),g=!1,null!==f&&(f(),f=null)})})(Yn,Ct,qt,$t,xn),Jn=((t,e,n,s,i,o,r)=>(a,l)=>{const c=a.createWaveShaper();if(null!==o&&"webkitAudioContext"===o.name)return n(a,l);At(c,l);const h=null===l.curve||l.curve instanceof Float32Array?l.curve:new Float32Array(l.curve);if(null!==h&&h.length<2)throw e();Rt(c,{curve:h},"curve"),Rt(c,l,"oversample");let u=null,p=!1;return r(c,"curve",t=>()=>t.call(c),e=>n=>(e.call(c,n),p&&(s(n)&&null===u?u=t(a,c):s(n)||null===u||(u(),u=null)),n)),i(c,()=>{p=!0,s(c.curve)&&(u=t(a,c))},()=>{p=!1,null!==u&&(u(),u=null)})})(Yn,Ct,Zn,$t,xn,Ie,te),$n=((t,e,n,s,i,o,r,a,l)=>(c,{coneInnerAngle:h,coneOuterAngle:u,coneOuterGain:p,distanceModel:d,maxDistance:m,orientationX:f,orientationY:g,orientationZ:_,panningModel:v,positionX:b,positionY:y,positionZ:w,refDistance:x,rolloffFactor:S,...C})=>{const k=c.createPanner();if(C.channelCount>2)throw r();if("max"===C.channelCountMode)throw r();At(k,C);const E={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},P=n(c,{...E,channelInterpretation:"speakers",numberOfInputs:6}),T=s(c,{...C,gain:1}),M=s(c,{...E,gain:1}),R=s(c,{...E,gain:0}),A=s(c,{...E,gain:0}),O=s(c,{...E,gain:0}),N=s(c,{...E,gain:0}),D=s(c,{...E,gain:0}),B=i(c,256,6,1),I=o(c,{...E,curve:new Float32Array([1,1]),oversample:"none"});let F=[f,g,_],V=[b,y,w];B.onaudioprocess=({inputBuffer:t})=>{const e=[t.getChannelData(0)[0],t.getChannelData(1)[0],t.getChannelData(2)[0]];e.some((t,e)=>t!==F[e])&&(k.setOrientation(...e),F=e);const n=[t.getChannelData(3)[0],t.getChannelData(4)[0],t.getChannelData(5)[0]];n.some((t,e)=>t!==V[e])&&(k.setPosition(...n),V=n)},Object.defineProperty(R.gain,"defaultValue",{get:()=>0}),Object.defineProperty(A.gain,"defaultValue",{get:()=>0}),Object.defineProperty(O.gain,"defaultValue",{get:()=>0}),Object.defineProperty(N.gain,"defaultValue",{get:()=>0}),Object.defineProperty(D.gain,"defaultValue",{get:()=>0});const j={get bufferSize(){},get channelCount(){return k.channelCount},set channelCount(t){if(t>2)throw r();T.channelCount=t,k.channelCount=t},get channelCountMode(){return k.channelCountMode},set channelCountMode(t){if("max"===t)throw r();T.channelCountMode=t,k.channelCountMode=t},get channelInterpretation(){return k.channelInterpretation},set channelInterpretation(t){T.channelInterpretation=t,k.channelInterpretation=t},get coneInnerAngle(){return k.coneInnerAngle},set coneInnerAngle(t){k.coneInnerAngle=t},get coneOuterAngle(){return k.coneOuterAngle},set coneOuterAngle(t){k.coneOuterAngle=t},get coneOuterGain(){return k.coneOuterGain},set coneOuterGain(t){if(t<0||t>1)throw e();k.coneOuterGain=t},get context(){return k.context},get distanceModel(){return k.distanceModel},set distanceModel(t){k.distanceModel=t},get inputs(){return[T]},get maxDistance(){return k.maxDistance},set maxDistance(t){if(t<0)throw new RangeError;k.maxDistance=t},get numberOfInputs(){return k.numberOfInputs},get numberOfOutputs(){return k.numberOfOutputs},get orientationX(){return M.gain},get orientationY(){return R.gain},get orientationZ(){return A.gain},get panningModel(){return k.panningModel},set panningModel(t){k.panningModel=t},get positionX(){return O.gain},get positionY(){return N.gain},get positionZ(){return D.gain},get refDistance(){return k.refDistance},set refDistance(t){if(t<0)throw new RangeError;k.refDistance=t},get rolloffFactor(){return k.rolloffFactor},set rolloffFactor(t){if(t<0)throw new RangeError;k.rolloffFactor=t},addEventListener:(...t)=>T.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>T.dispatchEvent(t[0]),removeEventListener:(...t)=>T.removeEventListener(t[0],t[1],t[2])};return h!==j.coneInnerAngle&&(j.coneInnerAngle=h),u!==j.coneOuterAngle&&(j.coneOuterAngle=u),p!==j.coneOuterGain&&(j.coneOuterGain=p),d!==j.distanceModel&&(j.distanceModel=d),m!==j.maxDistance&&(j.maxDistance=m),f!==j.orientationX.value&&(j.orientationX.value=f),g!==j.orientationY.value&&(j.orientationY.value=g),_!==j.orientationZ.value&&(j.orientationZ.value=_),v!==j.panningModel&&(j.panningModel=v),b!==j.positionX.value&&(j.positionX.value=b),y!==j.positionY.value&&(j.positionY.value=y),w!==j.positionZ.value&&(j.positionZ.value=w),x!==j.refDistance&&(j.refDistance=x),S!==j.rolloffFactor&&(j.rolloffFactor=S),1===F[0]&&0===F[1]&&0===F[2]||k.setOrientation(...F),0===V[0]&&0===V[1]&&0===V[2]||k.setPosition(...V),l(jt(j,k),()=>{T.connect(k),t(T,I,0,0),I.connect(M).connect(P,0,0),I.connect(R).connect(P,0,1),I.connect(A).connect(P,0,2),I.connect(O).connect(P,0,3),I.connect(N).connect(P,0,4),I.connect(D).connect(P,0,5),P.connect(B).connect(c.destination)},()=>{T.disconnect(k),a(T,I,0,0),I.disconnect(M),M.disconnect(P),I.disconnect(R),R.disconnect(P),I.disconnect(A),A.disconnect(P),I.disconnect(O),O.disconnect(P),I.disconnect(N),N.disconnect(P),I.disconnect(D),D.disconnect(P),P.disconnect(B),B.disconnect(c.destination)})})(Y,Ct,En,qt,Wt,Jn,Qt,$,xn),ts=(es=$n,(t,e)=>{const n=t.createPanner();return void 0===n.orientationX?es(t,e):(At(n,e),Nt(n,e,"orientationX"),Nt(n,e,"orientationY"),Nt(n,e,"orientationZ"),Nt(n,e,"positionX"),Nt(n,e,"positionY"),Nt(n,e,"positionZ"),Rt(n,e,"coneInnerAngle"),Rt(n,e,"coneOuterAngle"),Rt(n,e,"coneOuterGain"),Rt(n,e,"distanceModel"),Rt(n,e,"maxDistance"),Rt(n,e,"panningModel"),Rt(n,e,"refDistance"),Rt(n,e,"rolloffFactor"),n)});var es;const ns=((t,e,n,s,i,o,r)=>class extends t{constructor(t,a){const l=i(t),c={...Gt,...a},h=n(l,c),u=o(l);super(t,!1,h,u?s():null),this._nativePannerNode=h,this._orientationX=e(this,u,h.orientationX,I,B),this._orientationY=e(this,u,h.orientationY,I,B),this._orientationZ=e(this,u,h.orientationZ,I,B),this._positionX=e(this,u,h.positionX,I,B),this._positionY=e(this,u,h.positionY,I,B),this._positionZ=e(this,u,h.positionZ,I,B),r(this,1)}get coneInnerAngle(){return this._nativePannerNode.coneInnerAngle}set coneInnerAngle(t){this._nativePannerNode.coneInnerAngle=t}get coneOuterAngle(){return this._nativePannerNode.coneOuterAngle}set coneOuterAngle(t){this._nativePannerNode.coneOuterAngle=t}get coneOuterGain(){return this._nativePannerNode.coneOuterGain}set coneOuterGain(t){this._nativePannerNode.coneOuterGain=t}get distanceModel(){return this._nativePannerNode.distanceModel}set distanceModel(t){this._nativePannerNode.distanceModel=t}get maxDistance(){return this._nativePannerNode.maxDistance}set maxDistance(t){this._nativePannerNode.maxDistance=t}get orientationX(){return this._orientationX}get orientationY(){return this._orientationY}get orientationZ(){return this._orientationZ}get panningModel(){return this._nativePannerNode.panningModel}set panningModel(t){this._nativePannerNode.panningModel=t}get positionX(){return this._positionX}get positionY(){return this._positionY}get positionZ(){return this._positionZ}get refDistance(){return this._nativePannerNode.refDistance}set refDistance(t){this._nativePannerNode.refDistance=t}get rolloffFactor(){return this._nativePannerNode.rolloffFactor}set rolloffFactor(t){this._nativePannerNode.rolloffFactor=t}})(qe,an,ts,((t,e,n,s,i,o,r,a,l,c)=>()=>{const h=new WeakMap;let u=null;return{render(p,d,m){const f=h.get(d);return void 0!==f?Promise.resolve(f):(async(p,d,m)=>{let f=null,g=o(p);const _={channelCount:g.channelCount,channelCountMode:g.channelCountMode,channelInterpretation:g.channelInterpretation},v={..._,coneInnerAngle:g.coneInnerAngle,coneOuterAngle:g.coneOuterAngle,coneOuterGain:g.coneOuterGain,distanceModel:g.distanceModel,maxDistance:g.maxDistance,panningModel:g.panningModel,refDistance:g.refDistance,rolloffFactor:g.rolloffFactor},b=R(g,d);if("bufferSize"in g)f=s(d,{..._,gain:1});else if(!b){const t={...v,orientationX:g.orientationX.value,orientationY:g.orientationY.value,orientationZ:g.orientationZ.value,positionX:g.positionX.value,positionY:g.positionY.value,positionZ:g.positionZ.value};g=i(d,t)}if(h.set(d,null===f?g:f),null!==f){if(null===u){if(null===r)throw new Error("Missing the native OfflineAudioContext constructor.");const t=new r(6,p.context.length,d.sampleRate),s=e(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:6});s.connect(t.destination),u=(async()=>{const e=await Promise.all([p.orientationX,p.orientationY,p.orientationZ,p.positionX,p.positionY,p.positionZ].map(async(e,s)=>{const i=n(t,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:0===s?1:0});return await a(t,e,i.offset,m),i}));for(let t=0;t<6;t+=1)e[t].connect(s,0,t),e[t].start(0);return c(t)})()}const t=await u,o=s(d,{..._,gain:1});await l(p,d,o,m);const h=[];for(let e=0;et!==g[e])||n.some((t,e)=>t!==b[e])){g=t,b=n;const r=e/d.sampleRate;y.gain.setValueAtTime(0,r),y=s(d,{..._,gain:0}),w=i(d,{...v,orientationX:g[0],orientationY:g[1],orientationZ:g[2],positionX:b[0],positionY:b[1],positionZ:b[2]}),y.gain.setValueAtTime(1,r),o.connect(y).connect(w.inputs[0]),w.connect(f)}}return f}return b?(await t(d,p.orientationX,g.orientationX,m),await t(d,p.orientationY,g.orientationY,m),await t(d,p.orientationZ,g.orientationZ,m),await t(d,p.positionX,g.positionX,m),await t(d,p.positionY,g.positionY,m),await t(d,p.positionZ,g.positionZ,m)):(await a(d,p.orientationX,g.orientationX,m),await a(d,p.orientationY,g.orientationY,m),await a(d,p.orientationZ,g.orientationZ,m),await a(d,p.positionX,g.positionX,m),await a(d,p.positionY,g.positionY,m),await a(d,p.positionZ,g.positionZ,m)),G(g)?await l(p,d,g.inputs[0],m):await l(p,d,g,m),g})(p,d,m)}}})(en,En,Rn,qt,ts,tt,Re,on,Se,Ln),Te,Ae,pn),ss=((t,e,n,s)=>class s{constructor(s,i){const o=e(s),r=(t=>{const{imag:e,real:n}=t;return void 0===e?void 0===n?{...t,imag:[0,0],real:[0,0]}:{...t,imag:Array.from(n,()=>0),real:n}:void 0===n?{...t,imag:e,real:Array.from(e,()=>0)}:{...t,imag:e,real:n}})({...Yt,...i}),a=t(o,r);return n.add(a),a}static[Symbol.hasInstance](t){return null!==t&&"object"==typeof t&&Object.getPrototypeOf(t)===s.prototype||n.has(t)}})((t=>(e,{disableNormalization:n,imag:s,real:i})=>{const o=s instanceof Float32Array?s:new Float32Array(s),r=i instanceof Float32Array?i:new Float32Array(i),a=e.createPeriodicWave(r,o,{disableNormalization:n});if(Array.from(s).length<2)throw t();return a})(O),Te,new WeakSet),is=((t,e)=>(n,s)=>{const i=s.channelCountMode;if("clamped-max"===i)throw e();if(void 0===n.createStereoPanner)return t(n,s);const o=n.createStereoPanner();return At(o,s),Nt(o,s,"pan"),Object.defineProperty(o,"channelCountMode",{get:()=>i,set:t=>{if(t!==i)throw e()}}),o})(((t,e,n,s,i,o)=>{const r=new Float32Array([1,1]),a=Math.PI/2,l={channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete"},c={...l,oversample:"none"},h=(t,o,h,u,p)=>{if(1===o)return((t,e,i,o)=>{const h=new Float32Array(16385),u=new Float32Array(16385);for(let t=0;t<16385;t+=1){const e=t/16384*a;h[t]=Math.cos(e),u[t]=Math.sin(e)}const p=n(t,{...l,gain:0}),d=s(t,{...c,curve:h}),m=s(t,{...c,curve:r}),f=n(t,{...l,gain:0}),g=s(t,{...c,curve:u});return{connectGraph(){e.connect(p),e.connect(m.inputs[0]),e.connect(f),m.connect(i),i.connect(d.inputs[0]),i.connect(g.inputs[0]),d.connect(p.gain),g.connect(f.gain),p.connect(o,0,0),f.connect(o,0,1)},disconnectGraph(){e.disconnect(p),e.disconnect(m.inputs[0]),e.disconnect(f),m.disconnect(i),i.disconnect(d.inputs[0]),i.disconnect(g.inputs[0]),d.disconnect(p.gain),g.disconnect(f.gain),p.disconnect(o,0,0),f.disconnect(o,0,1)}}})(t,h,u,p);if(2===o)return((t,i,o,h)=>{const u=new Float32Array(16385),p=new Float32Array(16385),d=new Float32Array(16385),m=new Float32Array(16385),f=Math.floor(8192.5);for(let t=0;t<16385;t+=1)if(t>f){const e=(t-f)/(16384-f)*a;u[t]=Math.cos(e),p[t]=Math.sin(e),d[t]=0,m[t]=1}else{const e=t/(16384-f)*a;u[t]=1,p[t]=0,d[t]=Math.cos(e),m[t]=Math.sin(e)}const g=e(t,{channelCount:2,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:2}),_=n(t,{...l,gain:0}),v=s(t,{...c,curve:u}),b=n(t,{...l,gain:0}),y=s(t,{...c,curve:p}),w=s(t,{...c,curve:r}),x=n(t,{...l,gain:0}),S=s(t,{...c,curve:d}),C=n(t,{...l,gain:0}),k=s(t,{...c,curve:m});return{connectGraph(){i.connect(g),i.connect(w.inputs[0]),g.connect(_,0),g.connect(b,0),g.connect(x,1),g.connect(C,1),w.connect(o),o.connect(v.inputs[0]),o.connect(y.inputs[0]),o.connect(S.inputs[0]),o.connect(k.inputs[0]),v.connect(_.gain),y.connect(b.gain),S.connect(x.gain),k.connect(C.gain),_.connect(h,0,0),x.connect(h,0,0),b.connect(h,0,1),C.connect(h,0,1)},disconnectGraph(){i.disconnect(g),i.disconnect(w.inputs[0]),g.disconnect(_,0),g.disconnect(b,0),g.disconnect(x,1),g.disconnect(C,1),w.disconnect(o),o.disconnect(v.inputs[0]),o.disconnect(y.inputs[0]),o.disconnect(S.inputs[0]),o.disconnect(k.inputs[0]),v.disconnect(_.gain),y.disconnect(b.gain),S.disconnect(x.gain),k.disconnect(C.gain),_.disconnect(h,0,0),x.disconnect(h,0,0),b.disconnect(h,0,1),C.disconnect(h,0,1)}}})(t,h,u,p);throw i()};return(e,{channelCount:s,channelCountMode:r,pan:a,...l})=>{if("max"===r)throw i();const c=t(e,{...l,channelCount:1,channelCountMode:r,numberOfInputs:2}),u=n(e,{...l,channelCount:s,channelCountMode:r,gain:1}),p=n(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:a});let{connectGraph:d,disconnectGraph:m}=h(e,s,u,p,c);Object.defineProperty(p.gain,"defaultValue",{get:()=>0}),Object.defineProperty(p.gain,"minValue",{get:()=>-1});const f={get bufferSize(){},get channelCount(){return u.channelCount},set channelCount(t){u.channelCount!==t&&(g&&m(),({connectGraph:d,disconnectGraph:m}=h(e,t,u,p,c)),g&&d()),u.channelCount=t},get channelCountMode(){return u.channelCountMode},set channelCountMode(t){if("clamped-max"===t||"max"===t)throw i();u.channelCountMode=t},get channelInterpretation(){return u.channelInterpretation},set channelInterpretation(t){u.channelInterpretation=t},get context(){return u.context},get inputs(){return[u]},get numberOfInputs(){return u.numberOfInputs},get numberOfOutputs(){return u.numberOfOutputs},get pan(){return p.gain},addEventListener:(...t)=>u.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>u.dispatchEvent(t[0]),removeEventListener:(...t)=>u.removeEventListener(t[0],t[1],t[2])};let g=!1;return o(jt(f,c),()=>{d(),g=!0},()=>{m(),g=!1})}})(En,Vt,qt,Jn,Qt,xn),Qt),os=((t,e,n,s,i,o)=>class extends t{constructor(t,r){const a=i(t),l={...Kt,...r},c=n(a,l),h=o(a);super(t,!1,c,h?s():null),this._pan=e(this,h,c.pan)}get pan(){return this._pan}})(qe,an,is,((t,e,n,s,i)=>()=>{const o=new WeakMap;return{render(r,a,l){const c=o.get(a);return void 0!==c?Promise.resolve(c):(async(r,a,l)=>{let c=n(r);const h=R(c,a);if(!h){const t={channelCount:c.channelCount,channelCountMode:c.channelCountMode,channelInterpretation:c.channelInterpretation,pan:c.pan.value};c=e(a,t)}return o.set(a,c),h?await t(a,r.pan,c.pan,l):await s(a,r.pan,c.pan,l),G(c)?await i(r,a,c.inputs[0],l):await i(r,a,c,l),c})(r,a,l)}}})(en,is,tt,on,Se),Te,Ae),rs=((t,e,n)=>()=>{const s=new WeakMap;return{render(i,o,r){const a=s.get(o);return void 0!==a?Promise.resolve(a):(async(i,o,r)=>{let a=e(i);if(!R(a,o)){const e={channelCount:a.channelCount,channelCountMode:a.channelCountMode,channelInterpretation:a.channelInterpretation,curve:a.curve,oversample:a.oversample};a=t(o,e)}return s.set(o,a),G(a)?await n(i,o,a.inputs[0],r):await n(i,o,a,r),a})(i,o,r)}}})(Jn,tt,Se),as=((t,e,n,s,i,o,r)=>class extends t{constructor(t,e){const a=i(t),l={...Jt,...e},c=n(a,l);super(t,!0,c,o(a)?s():null),this._isCurveNullified=!1,this._nativeWaveShaperNode=c,r(this,1)}get curve(){return this._isCurveNullified?null:this._nativeWaveShaperNode.curve}set curve(t){if(null===t)this._isCurveNullified=!0,this._nativeWaveShaperNode.curve=new Float32Array([0,0]);else{if(t.length<2)throw e();this._isCurveNullified=!1,this._nativeWaveShaperNode.curve=t}}get oversample(){return this._nativeWaveShaperNode.oversample}set oversample(t){this._nativeWaveShaperNode.oversample=t}})(qe,Ct,Jn,rs,Te,Ae,pn),ls=(t=>null!==t&&t.isSecureContext)(_e),cs=(t=>(e,n,s)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return s()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(_e),hs=new WeakMap,us=((t,e)=>n=>{let s=t.get(n);if(void 0!==s)return s;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return s=new e(1,1,8e3),t.set(n,s),s})(hs,Re),ps=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(_e),ds=ls?((t,e,n,s,i,o,r,a,l,c,h,u)=>(p,d,f={credentials:"omit"})=>{const g=o(p),_=new URL(d,u.location.href).toString();if(void 0!==g.audioWorklet)return Promise.all([i(d),Promise.resolve(t(h,h))]).then(([t,e])=>{const[n,s]=v(t,_),i=e?s:s.replace(/\s+extends\s+AudioWorkletProcessor\s*{/," extends (class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}){"),o=new Blob([`${n};(registerProcessor=>{${i}\n})((n,p)=>registerProcessor(n,class extends p{${e?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${e?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}))`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(o);return g.audioWorklet.addModule(l,f).then(()=>{if(!a(g))return r(g).audioWorklet.addModule(l,f)}).finally(()=>URL.revokeObjectURL(l))});const w=c.get(p);if(void 0!==w&&w.has(d))return Promise.resolve();const x=l.get(p);if(void 0!==x){const t=x.get(d);if(void 0!==t)return t}const S=i(d).then(t=>{const[e,s]=v(t,_);return n(`${e};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${s}\n})})(window,'_AWGS')`)}).then(()=>{const t=u._AWGS.pop();if(void 0===t)throw new SyntaxError;s(g.currentTime,g.sampleRate,()=>t(class{},void 0,(t,n)=>{if(""===t.trim())throw e();const s=m.get(g);if(void 0!==s){if(s.has(t))throw e();y(n),b(n.parameterDescriptors),s.set(t,n)}else y(n),b(n.parameterDescriptors),m.set(g,new Map([[t,n]]))},g.sampleRate,void 0,void 0))});return void 0===x?l.set(p,new Map([[d,S]])):x.set(d,S),S.then(()=>{const t=c.get(p);void 0===t?c.set(p,new Set([d])):t.add(d)}).finally(()=>{const t=l.get(p);void 0!==t&&t.delete(d)}),S})(me,Qt,(t=>e=>new Promise((n,s)=>{if(null===t)return void s(new SyntaxError);const i=t.document.head;if(null===i)s(new SyntaxError);else{const o=t.document.createElement("script"),r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r),l=t.onerror,c=()=>{t.onerror=l,URL.revokeObjectURL(a)};t.onerror=(e,n,i,o,r)=>n===a||n===t.location.href&&1===i&&1===o?(c(),s(r),!1):null!==l?l(e,n,i,o,r):void 0,o.onerror=()=>{c(),s(new SyntaxError)},o.onload=()=>{c(),n()},o.src=a,o.type="module",i.appendChild(o)}}))(_e),cs,async t=>{try{const e=await fetch(t);if(e.ok)return e.text()}catch{}throw new DOMException("","AbortError")},Te,us,Ae,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),s=new e(1,128,8e3),i=URL.createObjectURL(n);let o=!1,r=!1;try{await s.audioWorklet.addModule(i);const e=new t(s,"a",{numberOfOutputs:0}),n=s.createOscillator();e.port.onmessage=()=>o=!0,e.onprocessorerror=()=>r=!0,n.connect(e),await s.startRendering()}catch{}finally{URL.revokeObjectURL(i)}return o&&!r})(ps,Re),_e):void 0,ms=((t,e)=>n=>t(n)||e(n))(Fe,Ae),fs=((t,e,n,s,i,o,r,a,l,c,h,u,p,d,m,f,g,_,v,b)=>class extends m{constructor(e,n){super(e,n),this._nativeContext=e,this._audioWorklet=void 0===t?void 0:{addModule:(e,n)=>t(this,e,n)}}get audioWorklet(){return this._audioWorklet}createAnalyser(){return new e(this)}createBiquadFilter(){return new i(this)}createBuffer(t,e,s){return new n({length:e,numberOfChannels:t,sampleRate:s})}createBufferSource(){return new s(this)}createChannelMerger(t=6){return new o(this,{numberOfInputs:t})}createChannelSplitter(t=6){return new r(this,{numberOfOutputs:t})}createConstantSource(){return new a(this)}createConvolver(){return new l(this)}createDelay(t=1){return new h(this,{maxDelayTime:t})}createDynamicsCompressor(){return new u(this)}createGain(){return new p(this)}createIIRFilter(t,e){return new d(this,{feedback:e,feedforward:t})}createOscillator(){return new f(this)}createPanner(){return new g(this)}createPeriodicWave(t,e,n={disableNormalization:!1}){return new _(this,{...n,imag:e,real:t})}createStereoPanner(){return new v(this)}createWaveShaper(){return new b(this)}decodeAudioData(t,e,n){return c(this._nativeContext,t).then(t=>("function"==typeof e&&e(t),t)).catch(t=>{throw"function"==typeof n&&n(t),t})}})(ds,He,Ke,cn,dn,Pn,Tn,An,Nn,((t,e,n,s,i,o,r,a,l,c,h)=>(n,s)=>{const u=r(n)?n:o(n);if(i.has(s)){const t=new DOMException("","DataCloneError");return Promise.reject(t)}try{i.add(s)}catch{}return e(l,()=>l(u))?u.decodeAudioData(s).then(n=>(e(a,()=>a(n))||h(n),t.add(n),n)):new Promise((e,n)=>{const i=()=>{try{(t=>{const{port1:e}=new MessageChannel;e.postMessage(t,[t])})(s)}catch{}},o=t=>{n(t),i()};try{u.decodeAudioData(s,n=>{"function"!=typeof n.copyFromChannel&&(c(n),N(n)),t.add(n),i(),e(n)},t=>{o(null===t?new DOMException("","EncodingError"):t)})}catch(t){o(t)}})})(We,me,0,0,new WeakSet,Te,ms,A,Mt,Ge,Ye),Dn,Fn,Vn,Hn,Xn,Gn,ns,ss,os,as),gs=((t,e,n,s)=>class extends t{constructor(t,e){const i=n(t),o=((t,e)=>t.createMediaElementSource(e.mediaElement))(i,e);if(s(i))throw TypeError();super(t,!0,o,null),this._nativeMediaElementAudioSourceNode=o}get mediaElement(){return this._nativeMediaElementAudioSourceNode.mediaElement}})(qe,0,Te,Ae),_s=((t,e,n,s)=>class extends t{constructor(t,e){const i=n(t);if(s(i))throw new TypeError;const o=((t,e)=>{const n=t.createMediaStreamDestination();return At(n,e),1===n.numberOfOutputs&&Object.defineProperty(n,"numberOfOutputs",{get:()=>0}),n})(i,{...Tt,...e});super(t,!1,o,null),this._nativeMediaStreamAudioDestinationNode=o}get stream(){return this._nativeMediaStreamAudioDestinationNode.stream}})(qe,0,Te,Ae),vs=((t,e,n,s)=>class extends t{constructor(t,e){const i=n(t),o=((t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort((t,e)=>t.ide.id?1:0);const s=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(s));return Object.defineProperty(i,"mediaStream",{value:e}),i})(i,e);if(s(i))throw new TypeError;super(t,!0,o,null),this._nativeMediaStreamAudioSourceNode=o}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(qe,0,Te,Ae),bs=((t,e,n)=>class extends t{constructor(t,s){const i=n(t);super(t,!0,e(i,s),null)}})(qe,((t,e)=>(n,{mediaStreamTrack:s})=>{if("function"==typeof n.createMediaStreamTrackSource)return n.createMediaStreamTrackSource(s);const i=new MediaStream([s]),o=n.createMediaStreamSource(i);if("audio"!==s.kind)throw t();if(e(n))throw new TypeError;return o})(Ct,Ae),Te),ys=((t,e,n,s,i,o,r,a,l)=>class extends t{constructor(t={}){if(null===l)throw new Error("Missing the native AudioContext constructor.");const e=new l(t);if(null===e)throw s();if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&e.sampleRate!==t.sampleRate)throw n();super(e,2);const{latencyHint:i}=t,{sampleRate:o}=e;if(this._baseLatency="number"==typeof e.baseLatency?e.baseLatency:"balanced"===i?512/o:"interactive"===i||void 0===i?256/o:"playback"===i?1024/o:128*Math.max(2,Math.min(128,Math.round(i*o/128)))/o,this._nativeAudioContext=e,"webkitAudioContext"===l.name?(this._nativeGainNode=e.createGain(),this._nativeOscillatorNode=e.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(e.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===e.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),e.removeEventListener("statechange",t)};e.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then(()=>{throw e()}):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then(()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),U(this)}))}createMediaElementSource(t){return new i(this,{mediaElement:t})}createMediaStreamDestination(){return new o(this)}createMediaStreamSource(t){return new r(this,{mediaStream:t})}createMediaStreamTrackSource(t){return new a(this,{mediaStreamTrack:t})}resume(){return"suspended"===this._state?new Promise((t,e)=>{const n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)}):this._nativeAudioContext.resume().catch(t=>{if(void 0===t||15===t.code)throw e();throw t})}suspend(){return this._nativeAudioContext.suspend().catch(t=>{if(void 0===t)throw e();throw t})}})(fs,Ct,Qt,Zt,gs,_s,vs,bs,Ie),ws=(xs=Qn,t=>{const e=xs.get(t);if(void 0===e)throw new Error("The context has no set of AudioWorkletNodes.");return e});var xs;const Ss=(Cs=ws,(t,e)=>{Cs(t).add(e)});var Cs;const ks=(t=>(e,n,s=0,i=0)=>{const o=e[s];if(void 0===o)throw t();return rt(n)?o.connect(n,0,i):o.connect(n,0)})(O),Es=(t=>(e,n)=>{t(e).delete(n)})(ws),Ps=(t=>(e,n,s,i=0)=>void 0===n?e.forEach(t=>t.disconnect()):"number"==typeof n?wt(t,e,n).disconnect():rt(n)?void 0===s?e.forEach(t=>t.disconnect(n)):void 0===i?wt(t,e,s).disconnect(n,0):wt(t,e,s).disconnect(n,0,i):void 0===s?e.forEach(t=>t.disconnect(n)):wt(t,e,s).disconnect(n,0))(O),Ts=new WeakMap,Ms=((t,e)=>n=>e(t,n))(Ts,w),Rs=((t,e,n,s,i,o,r,a,l,c,h,u,p)=>(d,m,g,_)=>{if(0===_.numberOfInputs&&0===_.numberOfOutputs)throw l();const v=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(v.some(t=>t<1))throw l();if(v.length!==_.numberOfOutputs)throw e();if("explicit"!==_.channelCountMode)throw l();const b=_.channelCount*_.numberOfInputs,y=v.reduce((t,e)=>t+e,0),w=void 0===g.parameterDescriptors?0:g.parameterDescriptors.length;if(b+w>6||y>6)throw l();const x=new MessageChannel,S=[],C=[];for(let t=0;t<_.numberOfInputs;t+=1)S.push(r(d,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),C.push(i(d,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const k=[];if(void 0!==g.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:s}of g.parameterDescriptors){const i=o(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==_.parameterData[s]?_.parameterData[s]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?I:e},minValue:{get:()=>void 0===n?B:n}}),k.push(i)}const E=s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,b+w)}),P=It(m,d.sampleRate),T=a(d,P,b+w,Math.max(1,y)),M=i(d,{channelCount:Math.max(1,y),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,y)}),R=[];for(let t=0;t<_.numberOfOutputs;t+=1)R.push(s(d,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:v[t]}));for(let t=0;t<_.numberOfInputs;t+=1){S[t].connect(C[t]);for(let e=0;e<_.channelCount;e+=1)C[t].connect(E,e,t*_.channelCount+e)}const A=new ct(void 0===g.parameterDescriptors?[]:g.parameterDescriptors.map(({name:t},e)=>{const n=k[e];return n.connect(E,0,b+e),n.start(0),[t,n.offset]}));E.connect(T);let O=_.channelInterpretation,N=null;const D=0===_.numberOfOutputs?[T]:R,F={get bufferSize(){return P},get channelCount(){return _.channelCount},set channelCount(t){throw n()},get channelCountMode(){return _.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return O},set channelInterpretation(t){for(const e of S)e.channelInterpretation=t;O=t},get context(){return T.context},get inputs(){return S},get numberOfInputs(){return _.numberOfInputs},get numberOfOutputs(){return _.numberOfOutputs},get onprocessorerror(){return N},set onprocessorerror(t){"function"==typeof N&&F.removeEventListener("processorerror",N),N="function"==typeof t?t:null,"function"==typeof N&&F.addEventListener("processorerror",N)},get parameters(){return A},get port(){return x.port2},addEventListener:(...t)=>T.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,D),disconnect:c.bind(null,D),dispatchEvent:(...t)=>T.dispatchEvent(t[0]),removeEventListener:(...t)=>T.removeEventListener(t[0],t[1],t[2])},V=new Map;var j,L;x.port1.addEventListener=(j=x.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=V.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{h(d.currentTime,d.sampleRate,()=>e(t))},V.set(e,t[1]))}}return j.call(x.port1,t[0],t[1],t[2])}),x.port1.removeEventListener=(L=x.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=V.get(t[1]);void 0!==e&&(V.delete(t[1]),t[1]=e)}return L.call(x.port1,t[0],t[1],t[2])});let q=null;Object.defineProperty(x.port1,"onmessage",{get:()=>q,set:t=>{"function"==typeof q&&x.port1.removeEventListener("message",q),q="function"==typeof t?t:null,"function"==typeof q&&(x.port1.addEventListener("message",q),x.port1.start())}}),g.prototype.port=x.port1;let U=null;((t,e,n,s)=>{let i=f.get(t);void 0===i&&(i=new WeakMap,f.set(t,i));const o=(async(t,e)=>new t(await(t=>new Promise((e,n)=>{const{port1:s,port2:i}=new MessageChannel;s.onmessage=({data:t})=>{s.close(),i.close(),e(t)},s.onmessageerror=({data:t})=>{s.close(),i.close(),n(t)},i.postMessage(t)}))(e)))(n,s);return i.set(e,o),o})(d,F,g,_).then(t=>U=t);const H=dt(_.numberOfInputs,_.channelCount),W=dt(_.numberOfOutputs,v),Q=void 0===g.parameterDescriptors?[]:g.parameterDescriptors.reduce((t,{name:e})=>({...t,[e]:new Float32Array(128)}),{});let X=!0;const z=()=>{_.numberOfOutputs>0&&T.disconnect(M);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=R[t];for(let s=0;s{if(null!==U){const n=u(F);for(let s=0;s{ut(t,Q,e,b+n,s)});for(let t=0;t<_.numberOfInputs;t+=1)for(let e=0;e{if(n[e].size>0)return G.set(e,P/128),t;const s=G.get(e);return void 0===s?[]:(t.every(t=>t.every(t=>0===t))&&(1===s?G.delete(e):G.set(e,s-1)),t)}),i=h(d.currentTime+s/d.sampleRate,d.sampleRate,()=>U.process(t,W,Q));X=i;for(let t=0,n=0;t<_.numberOfOutputs;t+=1){for(let i=0;iT.connect(K).connect(d.destination),J=()=>{T.disconnect(K),K.disconnect()};return Z(),p(F,()=>{if(X){J(),_.numberOfOutputs>0&&T.connect(M);for(let t=0,e=0;t<_.numberOfOutputs;t+=1){const n=R[t];for(let s=0;s{X&&(Z(),z()),Y=!1})})(ks,O,Ct,En,Vt,Rn,qt,Wt,Qt,Ps,cs,Ms,xn),As=((t,e,n,s,i)=>(o,r,a,l,c,h)=>{if(null!==a)try{const e=new a(o,l,h),s=new Map;let r=null;if(Object.defineProperties(e,{channelCount:{get:()=>h.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>r,set:t=>{"function"==typeof r&&e.removeEventListener("processorerror",r),r="function"==typeof t?t:null,"function"==typeof r&&e.addEventListener("processorerror",r)}}}),e.addEventListener=(p=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=s.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},s.set(e,t[1]))}}return p.call(e,"error",t[1],t[2]),p.call(e,...t)}),e.removeEventListener=(u=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=s.get(t[1]);void 0!==e&&(s.delete(t[1]),t[1]=e)}return u.call(e,"error",t[1],t[2]),u.call(e,t[0],t[1],t[2])}),0!==h.numberOfOutputs){const t=n(o,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return e.connect(t).connect(o.destination),i(e,()=>t.disconnect(),()=>t.connect(o.destination))}return e}catch(t){if(11===t.code)throw s();throw t}var u,p;if(void 0===c)throw s();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(h),e(o,r,c,h)})(Ct,Rs,qt,Qt,xn),Os=((t,e,n,s,i,o,r,a,l,c,h,u,p,d,m,f)=>(g,_,v)=>{const b=new WeakMap;let y=null;return{render(w,x,S){a(x,w);const C=b.get(x);return void 0!==C?Promise.resolve(C):(async(a,w,x)=>{let S=h(a),C=null;const k=R(S,w),E=Array.isArray(_.outputChannelCount)?_.outputChannelCount:Array.from(_.outputChannelCount);if(null===u){const t=E.reduce((t,e)=>t+e,0),n=i(w,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),o=[];for(let t=0;t{const l=new p(n,128*Math.ceil(a.context.length/128),w.sampleRate),c=[],h=[];for(let t=0;t<_.numberOfInputs;t+=1)c.push(r(l,{channelCount:_.channelCount,channelCountMode:_.channelCountMode,channelInterpretation:_.channelInterpretation,gain:1})),h.push(i(l,{channelCount:_.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:_.channelCount}));const u=await Promise.all(Array.from(a.parameters.values()).map(async t=>{const e=o(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await d(l,t,e.offset,x),e})),g=s(l,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<_.numberOfInputs;t+=1){c[t].connect(h[t]);for(let e=0;e<_.channelCount;e+=1)h[t].connect(g,e,t*_.channelCount+e)}for(const[e,n]of u.entries())n.connect(g,0,t+e),n.start(0);return g.connect(l.destination),await Promise.all(c.map(t=>m(a,l,t,x))),f(l)};y=mt(a,0===n?null:await l(),w,_,E,v,c)}const t=await y,e=n(w,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[l,h,u]=C;null!==t&&(e.buffer=t,e.start(0)),e.connect(l);for(let t=0,e=0;te=>t.get(e))(hs),Ds=(t=>(e,n)=>{t.set(e,n)})(Ts),Bs=ls?((t,e,n,s,i,o,r,a,l,c,h,u,p)=>class extends e{constructor(e,h,p){var d;const f=a(e),g=l(f),_=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},()=>1)}))({...ht,...p}),v=m.get(f),b=null==v?void 0:v.get(h),y=g||"closed"!==f.state?f:null!==(d=r(f))&&void 0!==d?d:f,w=i(y,g?null:e.baseLatency,c,h,b,_);super(e,!0,w,g?s(h,_,b):null);const x=[];w.parameters.forEach((t,e)=>{const s=n(this,g,t);x.push([e,s])}),this._nativeAudioWorkletNode=w,this._onprocessorerror=null,this._parameters=new ct(x),g&&t(f,this);const{activeInputs:S}=o(this);u(w,S)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?p(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(Ss,qe,an,Os,As,j,Ns,Te,Ae,ps,0,Ds,ae):void 0,Is=((t,e)=>(n,s,i)=>{if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");try{return new e(n,s,i)}catch(e){if("SyntaxError"===e.name)throw t();throw e}})(Qt,Re),Fs=((t,e,n,s,i,o,r,a)=>{const l=[];return(c,h)=>n(c).render(c,h,l).then(()=>Promise.all(Array.from(s(h)).map(t=>n(t).render(t,h,l)))).then(()=>i(h)).then(n=>("function"!=typeof n.copyFromChannel?(r(n),N(n)):e(o,()=>o(n))||a(n),t.add(n),n))})(We,me,we,ws,Ln,A,Ge,Ye),Vs=((t,e,n,s,i)=>class extends t{constructor(t,n,i){let o;if("number"==typeof t&&void 0!==n&&void 0!==i)o={length:n,numberOfChannels:t,sampleRate:i};else{if("object"!=typeof t)throw new Error("The given parameters are not valid.");o=t}const{length:r,numberOfChannels:a,sampleRate:l}={...Xt,...o},c=s(a,r,l);e(Mt,()=>Mt(c))||c.addEventListener("statechange",(()=>{let t=0;const e=n=>{"running"===this._state&&(t>0?(c.removeEventListener("statechange",e),n.stopImmediatePropagation(),this._waitForThePromiseToSettle(n)):t+=1)};return e})()),super(c,a),this._length=r,this._nativeOfflineAudioContext=c,this._state=null}get length(){return void 0===this._nativeOfflineAudioContext.length?this._length:this._nativeOfflineAudioContext.length}get state(){return null===this._state?this._nativeOfflineAudioContext.state:this._state}startRendering(){return"running"===this._state?Promise.reject(n()):(this._state="running",i(this.destination,this._nativeOfflineAudioContext).finally(()=>{this._state=null,U(this)}))}_waitForThePromiseToSettle(t){null===this._state?this._nativeOfflineAudioContext.dispatchEvent(t):setTimeout(()=>this._waitForThePromiseToSettle(t))}})(fs,me,Ct,Is,Fs),js=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(u,Fe),Ls=(qs=l,Us=je,t=>qs.has(t)||Us(t));var qs,Us;const Hs=(Ws=h,Qs=Le,t=>Ws.has(t)||Qs(t));var Ws,Qs;const Xs=((t,e)=>n=>{const s=t.get(n);return e(s)||e(n)})(u,Ae),zs=()=>(async(t,e,n,s,i,o,r,a,l,c,h,u,p,d,m,f)=>!!(t(e,e)&&t(n,n)&&t(i,i)&&t(o,o)&&t(a,a)&&t(l,l)&&t(c,c)&&t(h,h)&&t(u,u)&&t(p,p)&&t(d,d))&&(await Promise.all([t(s,s),t(r,r),t(m,m),t(f,f)])).every(t=>t))(me,(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createBuffer(1,1,44100);if(void 0===e.copyToChannel)return!0;const n=new Float32Array(2);try{e.copyFromChannel(n,0,0)}catch{return!1}return!0})(Re),(t=>()=>{if(null===t)return!1;if(void 0!==t.prototype&&void 0!==t.prototype.close)return!0;const e=new t,n=void 0!==e.close;try{e.close()}catch{}return n})(Ie),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);return new Promise(t=>{let n=!0;const s=s=>{n&&(n=!1,e.startRendering(),t(s instanceof TypeError))};let i;try{i=e.decodeAudioData(null,()=>{},s)}catch(t){s(t)}void 0!==i&&i.catch(s)})})(Re),(t=>()=>{if(null===t)return!1;let e;try{e=new t({latencyHint:"balanced"})}catch{return!1}return e.close(),!0})(Ie),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createGain(),n=e.connect(e)===e;return e.disconnect(e),n})(Re),((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(){this.port.postMessage(0)}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),s=new e(1,128,8e3),i=URL.createObjectURL(n);let o=!1;try{await s.audioWorklet.addModule(i);const e=new t(s,"a",{numberOfOutputs:0}),n=s.createOscillator();e.port.onmessage=()=>o=!0,n.connect(e),n.start(0),await s.startRendering(),o||await new Promise(t=>setTimeout(t,5))}catch{}finally{URL.revokeObjectURL(i)}return o})(ps,Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createChannelMerger();if("max"===e.channelCountMode)return!0;try{e.channelCount=2}catch{return!0}return!1})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100);return void 0===e.createConstantSource||e.createConstantSource().offset.maxValue!==Number.POSITIVE_INFINITY})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100),n=e.createConvolver();n.buffer=e.createBuffer(1,1,e.sampleRate);try{n.buffer=e.createBuffer(1,1,e.sampleRate)}catch{return!1}return!0})(Re),(t=>()=>{if(null===t)return!1;const e=new t(1,1,44100).createConvolver();try{e.channelCount=1}catch{return!1}return!0})(Re),ie,(t=>()=>null!==t&&t.hasOwnProperty("isSecureContext"))(_e),(t=>()=>{if(null===t)return!1;const e=new t;try{return e.createMediaStreamSource(new MediaStream),!1}catch(t){return!0}})(Ie),(t=>()=>{if(null===t)return Promise.resolve(!1);const e=new t(1,1,44100);if(void 0===e.createStereoPanner)return Promise.resolve(!0);if(void 0===e.createConstantSource)return Promise.resolve(!0);const n=e.createConstantSource(),s=e.createStereoPanner();return n.channelCount=1,n.offset.value=1,s.channelCount=1,n.start(),n.connect(s).connect(e.destination),e.startRendering().then(t=>1!==t.getChannelData(0)[0])})(Re),oe);function Gs(t,e){if(!t)throw new Error(e)}function Ys(t,e,n=1/0){if(!(e<=t&&t<=n))throw new RangeError(`Value must be within [${e}, ${n}], got: ${t}`)}function Ks(t){t.isOffline||"running"===t.state||ti('The AudioContext is "suspended". Invoke Tone.start() from a user action to start the audio.')}let Zs=console;function Js(t){Zs=t}function $s(...t){Zs.log(...t)}function ti(...t){Zs.warn(...t)}function ei(t){return void 0===t}function ni(t){return!ei(t)}function si(t){return"function"==typeof t}function ii(t){return"number"==typeof t}function oi(t){return"[object Object]"===Object.prototype.toString.call(t)&&t.constructor===Object}function ri(t){return"boolean"==typeof t}function ai(t){return Array.isArray(t)}function li(t){return"string"==typeof t}function ci(t){return li(t)&&/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i.test(t)}let hi=!0;function ui(t,e,n){let s;if(hi)try{s=new Vs(t,e,n)}catch(i){hi=!1,console.warn("create stdOfflineAudioContext failed",i),console.warn("will use native OfflineAudioContext"),s=new OfflineAudioContext(t,e,n)}else s=new OfflineAudioContext(t,e,n);return s}-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&(hi=!1);const pi="object"==typeof self?self:null,di=pi&&(pi.hasOwnProperty("AudioContext")||pi.hasOwnProperty("webkitAudioContext"));let mi=!0;function fi(t,e,n,s){var i,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,s);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r}function gi(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))}Object.create,Object.create;class _i{constructor(t,e,n){this._callback=t,this._type=e,this._updateInterval=n,this._createClock()}_createWorker(){const t=new Blob([`\n\t\t\t// the initial timeout time\n\t\t\tlet timeoutTime = ${(1e3*this._updateInterval).toFixed(1)};\n\t\t\t// onmessage callback\n\t\t\tself.onmessage = function(msg){\n\t\t\t\ttimeoutTime = parseInt(msg.data);\n\t\t\t};\n\t\t\t// the tick function which posts a message\n\t\t\t// and schedules a new tick\n\t\t\tfunction tick(){\n\t\t\t\tsetTimeout(tick, timeoutTime);\n\t\t\t\tself.postMessage('tick');\n\t\t\t}\n\t\t\t// call tick initially\n\t\t\ttick();\n\t\t\t`],{type:"text/javascript"}),e=URL.createObjectURL(t),n=new Worker(e);n.onmessage=this._callback.bind(this),this._worker=n}_createTimeout(){this._timeout=setTimeout(()=>{this._createTimeout(),this._callback()},1e3*this._updateInterval)}_createClock(){if("worker"===this._type)try{this._createWorker()}catch(t){this._type="timeout",this._createClock()}else"timeout"===this._type&&this._createTimeout()}_disposeClock(){this._timeout&&(clearTimeout(this._timeout),this._timeout=0),this._worker&&(this._worker.terminate(),this._worker.onmessage=null)}get updateInterval(){return this._updateInterval}set updateInterval(t){this._updateInterval=Math.max(t,128/44100),"worker"===this._type&&this._worker.postMessage(Math.max(1e3*t,1))}get type(){return this._type}set type(t){this._disposeClock(),this._type=t,this._createClock()}dispose(){this._disposeClock()}}function vi(t){return Hs(t)}function bi(t){return Ls(t)}function yi(t){return Xs(t)}function wi(t){return js(t)}function xi(t){return t instanceof AudioBuffer}function Si(t,e){return"value"===t||vi(e)||bi(e)||xi(e)}function Ci(t,...e){if(!e.length)return t;const n=e.shift();if(oi(t)&&oi(n))for(const e in n)Si(e,n[e])?t[e]=n[e]:oi(n[e])?(t[e]||Object.assign(t,{[e]:{}}),Ci(t[e],n[e])):Object.assign(t,{[e]:n[e]});return Ci(t,...e)}function ki(t,e,n=[],s){const i={},o=Array.from(e);if(oi(o[0])&&s&&!Reflect.has(o[0],s)&&(Object.keys(o[0]).some(e=>Reflect.has(t,e))||(Ci(i,{[s]:o[0]}),n.splice(n.indexOf(s),1),o.shift())),1===o.length&&oi(o[0]))Ci(i,o[0]);else for(let t=0;t{Reflect.has(t,e)&&delete t[e]}),t}const Ti="dev"; /** * Tone.js * @author Yotam Mann * @license http://opensource.org/licenses/MIT MIT License * @copyright 2014-2019 Yotam Mann */class Mi{constructor(){this.debug=!1,this._wasDisposed=!1}static getDefaults(){return{}}log(...t){(this.debug||pi&&this.toString()===pi.TONE_DEBUG_CLASS)&&$s(this,...t)}dispose(){return this._wasDisposed=!0,this}get disposed(){return this._wasDisposed}toString(){return this.name}}function Ri(t,e){return t>e+1e-6}function Ai(t,e){return Ri(t,e)||Ni(t,e)}function Oi(t,e){return t+1e-6this.memory){const t=this.length-this.memory;this._timeline.splice(0,t)}return this}remove(t){const e=this._timeline.indexOf(t);return-1!==e&&this._timeline.splice(e,1),this}get(t,e="time"){const n=this._search(t,e);return-1!==n?this._timeline[n]:null}peek(){return this._timeline[0]}shift(){return this._timeline.shift()}getAfter(t,e="time"){const n=this._search(t,e);return n+10&&this._timeline[e-1].time=0?this._timeline[n-1]:null}cancel(t){if(this._timeline.length>1){let e=this._search(t);if(e>=0)if(Ni(this._timeline[e].time,t)){for(let n=e;n>=0&&Ni(this._timeline[n].time,t);n--)e=n;this._timeline=this._timeline.slice(0,e)}else this._timeline=this._timeline.slice(0,e+1);else this._timeline=[]}else 1===this._timeline.length&&Ai(this._timeline[0].time,t)&&(this._timeline=[]);return this}cancelBefore(t){const e=this._search(t);return e>=0&&(this._timeline=this._timeline.slice(e+1)),this}previousEvent(t){const e=this._timeline.indexOf(t);return e>0?this._timeline[e-1]:null}_search(t,e="time"){if(0===this._timeline.length)return-1;let n=0;const s=this._timeline.length;let i=s;if(s>0&&this._timeline[s-1][e]<=t)return s-1;for(;n=0&&this._timeline[n].time>=t;)n--;return this._iterate(e,n+1),this}forEachAtTime(t,e){const n=this._search(t);if(-1!==n&&Ni(this._timeline[n].time,t)){let s=n;for(let e=n;e>=0&&Ni(this._timeline[e].time,t);e--)s=e;this._iterate(t=>{e(t)},s,n)}return this}dispose(){return super.dispose(),this._timeline=[],this}}const Ii=[];function Fi(t){Ii.push(t)}const Vi=[];function ji(t){Vi.push(t)}class Li extends Mi{constructor(){super(...arguments),this.name="Emitter"}on(t,e){return t.split(/\W+/).forEach(t=>{ei(this._events)&&(this._events={}),this._events.hasOwnProperty(t)||(this._events[t]=[]),this._events[t].push(e)}),this}once(t,e){const n=(...s)=>{e(...s),this.off(t,n)};return this.on(t,n),this}off(t,e){return t.split(/\W+/).forEach(n=>{if(ei(this._events)&&(this._events={}),this._events.hasOwnProperty(t))if(ei(e))this._events[t]=[];else{const n=this._events[t];for(let t=n.length-1;t>=0;t--)n[t]===e&&n.splice(t,1)}}),this}emit(t,...e){if(this._events&&this._events.hasOwnProperty(t)){const n=this._events[t].slice(0);for(let t=0,s=n.length;t{const n=Object.getOwnPropertyDescriptor(Li.prototype,e);Object.defineProperty(t.prototype,e,n)})}dispose(){return super.dispose(),this._events=void 0,this}}class qi extends Li{constructor(){super(...arguments),this._isOffline=!1}}class Ui extends qi{constructor(){super(),this.name="Context",this._constants=new Map,this._timeouts=new Bi,this._timeoutIds=0,this._initialized=!1,this._isOffline=!1,this._workletModules=new Map;const t=ki(Ui.getDefaults(),arguments,["context"]);t.context?this._context=t.context:(this._context=function(t){return new ys(t)}({latencyHint:t.latencyHint}),this._context._nativeAudioContext&&this._context._nativeAudioContext.createScriptProcessor&&(this._context.createScriptProcessor=this._context._nativeAudioContext.createScriptProcessor)),this._ticker=new _i(this.emit.bind(this,"tick"),t.clockSource,t.updateInterval),this.on("tick",this._timeoutLoop.bind(this)),this._context.onstatechange=()=>{this.emit("statechange",this.state)},this._setLatencyHint(t.latencyHint),this.lookAhead=t.lookAhead}get isOffline(){return this._isOffline}static getDefaults(){return{clockSource:"worker",latencyHint:"interactive",lookAhead:.1,updateInterval:.05}}initialize(){var t;return this._initialized||(t=this,Ii.forEach(e=>{e(t)}),this._initialized=!0),this}createAnalyser(){return this._context.createAnalyser()}createOscillator(){return this._context.createOscillator()}createBufferSource(){return this._context.createBufferSource()}createBiquadFilter(){return this._context.createBiquadFilter()}createBuffer(t,e,n){return this._context.createBuffer(t,e,n)}createChannelMerger(t){return this._context.createChannelMerger(t)}createChannelSplitter(t){return this._context.createChannelSplitter(t)}createConstantSource(){return this._context.createConstantSource()}createConvolver(){return this._context.createConvolver()}createDelay(t){return this._context.createDelay(t)}createDynamicsCompressor(){return this._context.createDynamicsCompressor()}createGain(){return this._context.createGain()}createIIRFilter(t,e){if(void 0===this._context.createIIRFilter)throw Error("createIIRFilter dose not support in your browser");return this._context.createIIRFilter(t,e)}createPanner(){return this._context.createPanner()}createPeriodicWave(t,e,n){return this._context.createPeriodicWave(t,e,n)}createStereoPanner(){return this._context.createStereoPanner()}createWaveShaper(){return this._context.createWaveShaper()}createScriptProcessor(){return void 0!==this._context._nativeAudioContext?this._context._nativeAudioContext.createScriptProcessor():this._context.createScriptProcessor()}createMediaStreamSource(t){return Gs(wi(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamSource(t)}createMediaElementSource(t){return Gs(wi(this._context),"Not available if OfflineAudioContext"),this._context.createMediaElementSource(t)}createMediaStreamDestination(){return Gs(wi(this._context),"Not available if OfflineAudioContext"),this._context.createMediaStreamDestination()}decodeAudioData(t){return this._context.decodeAudioData(t)}get currentTime(){return this._context.currentTime}get state(){return this._context.state}get sampleRate(){return this._context.sampleRate}get listener(){return this.initialize(),this._listener}set listener(t){Gs(!this._initialized,"The listener cannot be set after initialization."),this._listener=t}get transport(){return this.initialize(),this._transport}set transport(t){Gs(!this._initialized,"The transport cannot be set after initialization."),this._transport=t}get draw(){return this.initialize(),this._draw}set draw(t){Gs(!this._initialized,"Draw cannot be set after initialization."),this._draw=t}get destination(){return this.initialize(),this._destination}set destination(t){Gs(!this._initialized,"The destination cannot be set after initialization."),this._destination=t}createAudioWorkletNode(t,e){return function(t,e,n){let s;if(Gs(ni(Bs),"This node only works in a secure context (https or localhost)"),mi&&Bs)try{s=new Bs(t,e,n)}catch(i){mi=!1,console.warn("create stdAudioWorkletNode failed",i),console.warn("will use native AudioWorkletNode"),s=new AudioWorkletNode(t,e,n)}else s=new AudioWorkletNode(t,e,n);return s} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */(this.rawContext,t,e)}addAudioWorkletModule(t,e){return gi(this,void 0,void 0,(function*(){Gs(ni(this.rawContext.audioWorklet),"AudioWorkletNode is only available in a secure context (https or localhost)"),this._workletModules.has(e)||this._workletModules.set(e,this.rawContext.audioWorklet.addModule(t)),yield this._workletModules.get(e)}))}workletsAreReady(){return gi(this,void 0,void 0,(function*(){const t=[];this._workletModules.forEach(e=>t.push(e)),yield Promise.all(t)}))}get updateInterval(){return this._ticker.updateInterval}set updateInterval(t){this._ticker.updateInterval=t}get clockSource(){return this._ticker.type}set clockSource(t){this._ticker.type=t}get latencyHint(){return this._latencyHint}_setLatencyHint(t){let e=0;if(this._latencyHint=t,li(t))switch(t){case"interactive":e=.1;break;case"playback":e=.5;break;case"balanced":e=.25}this.lookAhead=e,this.updateInterval=e/2}get rawContext(){return this._context}now(){return this._context.currentTime+this.lookAhead}immediate(){return this._context.currentTime}resume(){return"suspended"===this._context.state&&wi(this._context)?this._context.resume():Promise.resolve()}close(){return gi(this,void 0,void 0,(function*(){var t;wi(this._context)&&(yield this._context.close()),this._initialized&&(t=this,Vi.forEach(e=>e(t)))}))}getConstant(t){if(this._constants.has(t))return this._constants.get(t);{const e=this._context.createBuffer(1,128,this._context.sampleRate),n=e.getChannelData(0);for(let e=0;ethis._constants[t].disconnect()),this}_timeoutLoop(){const t=this.now();let e=this._timeouts.peek();for(;this._timeouts.length&&e&&e.time<=t;)e.callback(),this._timeouts.shift(),e=this._timeouts.peek()}setTimeout(t,e){this._timeoutIds++;const n=this.now();return this._timeouts.add({callback:t,id:this._timeoutIds,time:n+e}),this._timeoutIds}clearTimeout(t){return this._timeouts.forEach(e=>{e.id===t&&this._timeouts.remove(e)}),this}clearInterval(t){return this.clearTimeout(t)}setInterval(t,e){const n=++this._timeoutIds,s=()=>{const i=this.now();this._timeouts.add({callback:()=>{t(),s()},id:n,time:i+e})};return s(),n}}function Hi(t,e){ai(e)?e.forEach(e=>Hi(t,e)):Object.defineProperty(t,e,{enumerable:!0,writable:!1})}function Wi(t,e){ai(e)?e.forEach(e=>Wi(t,e)):Object.defineProperty(t,e,{writable:!0})}const Qi=()=>{};class Xi extends Mi{constructor(){super(),this.name="ToneAudioBuffer",this.onload=Qi;const t=ki(Xi.getDefaults(),arguments,["url","onload","onerror"]);this.reverse=t.reverse,this.onload=t.onload,t.url&&xi(t.url)||t.url instanceof Xi?this.set(t.url):li(t.url)&&this.load(t.url).catch(t.onerror)}static getDefaults(){return{onerror:Qi,onload:Qi,reverse:!1}}get sampleRate(){return this._buffer?this._buffer.sampleRate:Ki().sampleRate}set(t){return t instanceof Xi?t.loaded?this._buffer=t.get():t.onload=()=>{this.set(t),this.onload(this)}:this._buffer=t,this._reversed&&this._reverse(),this}get(){return this._buffer}load(t){return gi(this,void 0,void 0,(function*(){const e=Xi.load(t).then(t=>{this.set(t),this.onload(this)});Xi.downloads.push(e);try{yield e}finally{const t=Xi.downloads.indexOf(e);Xi.downloads.splice(t,1)}return this}))}dispose(){return super.dispose(),this._buffer=void 0,this}fromArray(t){const e=ai(t)&&t[0].length>0,n=e?t.length:1,s=e?t[0].length:t.length,i=Ki(),o=i.createBuffer(n,s,i.sampleRate),r=e||1!==n?t:[t];for(let t=0;tt/e),this.fromArray(t)}return this}toArray(t){if(ii(t))return this.getChannelData(t);if(1===this.numberOfChannels)return this.toArray(0);{const t=[];for(let e=0;e0}get duration(){return this._buffer?this._buffer.duration:0}get length(){return this._buffer?this._buffer.length:0}get numberOfChannels(){return this._buffer?this._buffer.numberOfChannels:0}get reverse(){return this._reversed}set reverse(t){this._reversed!==t&&(this._reversed=t,this._reverse())}static fromArray(t){return(new Xi).fromArray(t)}static fromUrl(t){return gi(this,void 0,void 0,(function*(){const e=new Xi;return yield e.load(t)}))}static load(t){return gi(this,void 0,void 0,(function*(){const e=t.match(/\[([^\]\[]+\|.+)\]$/);if(e){const n=e[1].split("|");let s=n[0];for(const t of n)if(Xi.supportsType(t)){s=t;break}t=t.replace(e[0],s)}const n=""===Xi.baseUrl||Xi.baseUrl.endsWith("/")?Xi.baseUrl:Xi.baseUrl+"/",s=yield fetch(n+t);if(!s.ok)throw new Error("could not load url: "+t);const i=yield s.arrayBuffer();return yield Ki().decodeAudioData(i)}))}static supportsType(t){const e=t.split("."),n=e[e.length-1];return""!==document.createElement("audio").canPlayType("audio/"+n)}static loaded(){return gi(this,void 0,void 0,(function*(){for(yield Promise.resolve();Xi.downloads.length;)yield Xi.downloads[0]}))}}Xi.baseUrl="",Xi.downloads=[];class zi extends Ui{constructor(){super({clockSource:"offline",context:yi(arguments[0])?arguments[0]:ui(arguments[0],arguments[1]*arguments[2],arguments[2]),lookAhead:0,updateInterval:yi(arguments[0])?128/arguments[0].sampleRate:128/arguments[2]}),this.name="OfflineContext",this._currentTime=0,this._isOffline=!0,this._isOffline=!0,this._duration=yi(arguments[0])?arguments[0].length/arguments[0].sampleRate:arguments[1]}get isOffline(){return this._isOffline}now(){return this._currentTime}get currentTime(){return this._currentTime}_renderClock(t){return gi(this,void 0,void 0,(function*(){let e=0;for(;this._duration-this._currentTime>=0;){this.emit("tick"),this._currentTime+=128/this.sampleRate,e++;const n=Math.floor(this.sampleRate/128);t&&e%n==0&&(yield new Promise(t=>setTimeout(t,1)))}}))}render(t=!0){return gi(this,void 0,void 0,(function*(){yield this.workletsAreReady(),yield this._renderClock(t);const e=yield this._context.startRendering();return new Xi(e)}))}close(){return Promise.resolve()}}const Gi=new class extends qi{constructor(){super(...arguments),this.lookAhead=0,this.latencyHint=0,this.isOffline=!1}createAnalyser(){return{}}createOscillator(){return{}}createBufferSource(){return{}}createBiquadFilter(){return{}}createBuffer(t,e,n){return{}}createChannelMerger(t){return{}}createChannelSplitter(t){return{}}createConstantSource(){return{}}createConvolver(){return{}}createDelay(t){return{}}createDynamicsCompressor(){return{}}createGain(){return{}}createIIRFilter(t,e){return{}}createPanner(){return{}}createPeriodicWave(t,e,n){return{}}createStereoPanner(){return{}}createWaveShaper(){return{}}createScriptProcessor(){return{}}createMediaStreamSource(t){return{}}createMediaElementSource(t){return{}}createMediaStreamDestination(){return{}}decodeAudioData(t){return Promise.resolve({})}createAudioWorkletNode(t,e){return{}}get rawContext(){return{}}addAudioWorkletModule(t,e){return gi(this,void 0,void 0,(function*(){return Promise.resolve()}))}resume(){return Promise.resolve()}setTimeout(t,e){return 0}clearTimeout(t){return this}setInterval(t,e){return 0}clearInterval(t){return this}getConstant(t){return{}}get currentTime(){return 0}get state(){return{}}get sampleRate(){return 0}get listener(){return{}}get transport(){return{}}get draw(){return{}}set draw(t){}get destination(){return{}}set destination(t){}now(){return 0}immediate(){return 0}};let Yi=Gi;function Ki(){return Yi===Gi&&di&&Zi(new Ui),Yi}function Zi(t){Yi=wi(t)?new Ui(t):yi(t)?new zi(t):t}function Ji(){return Yi.resume()}function $i(t){return Math.pow(10,t/20)}function to(t){return Math.log(t)/Math.LN10*20}function eo(t){return Math.pow(2,t/12)}let no=440;function so(t){return Math.round(io(t))}function io(t){return 69+12*Math.log2(t/no)}function oo(t){return no*Math.pow(2,(t-69)/12)}class ro extends Mi{constructor(t,e,n){super(),this.defaultUnits="s",this._val=e,this._units=n,this.context=t,this._expressions=this._getExpressions()}_getExpressions(){return{hz:{method:t=>this._frequencyToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)hz$/i},i:{method:t=>this._ticksToUnits(parseInt(t,10)),regexp:/^(\d+)i$/i},m:{method:t=>this._beatsToUnits(parseInt(t,10)*this._getTimeSignature()),regexp:/^(\d+)m$/i},n:{method:(t,e)=>{const n=parseInt(t,10),s="."===e?1.5:1;return 1===n?this._beatsToUnits(this._getTimeSignature())*s:this._beatsToUnits(4/n)*s},regexp:/^(\d+)n(\.?)$/i},number:{method:t=>this._expressions[this.defaultUnits].method.call(this,t),regexp:/^(\d+(?:\.\d+)?)$/},s:{method:t=>this._secondsToUnits(parseFloat(t)),regexp:/^(\d+(?:\.\d+)?)s$/},samples:{method:t=>parseInt(t,10)/this.context.sampleRate,regexp:/^(\d+)samples$/},t:{method:t=>{const e=parseInt(t,10);return this._beatsToUnits(8/(3*Math.floor(e)))},regexp:/^(\d+)t$/i},tr:{method:(t,e,n)=>{let s=0;return t&&"0"!==t&&(s+=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s+=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s+=this._beatsToUnits(parseFloat(n)/4)),s},regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?$/}}}valueOf(){if(this._val instanceof ro&&this.fromType(this._val),ei(this._val))return this._noArg();if(li(this._val)&&ei(this._units)){for(const t in this._expressions)if(this._expressions[t].regexp.test(this._val.trim())){this._units=t;break}}else if(oi(this._val)){let t=0;for(const e in this._val)if(ni(this._val[e])){const n=this._val[e];t+=new this.constructor(this.context,e).valueOf()*n}return t}if(ni(this._units)){const t=this._expressions[this._units],e=this._val.toString().trim().match(t.regexp);return e?t.method.apply(this,e.slice(1)):t.method.call(this,this._val)}return li(this._val)?parseFloat(this._val):this._val}_frequencyToUnits(t){return 1/t}_beatsToUnits(t){return 60/this._getBpm()*t}_secondsToUnits(t){return t}_ticksToUnits(t){return t*this._beatsToUnits(1)/this._getPPQ()}_noArg(){return this._now()}_getBpm(){return this.context.transport.bpm.value}_getTimeSignature(){return this.context.transport.timeSignature}_getPPQ(){return this.context.transport.PPQ}fromType(t){switch(this._units=void 0,this.defaultUnits){case"s":this._val=t.toSeconds();break;case"i":this._val=t.toTicks();break;case"hz":this._val=t.toFrequency();break;case"midi":this._val=t.toMidi()}return this}toFrequency(){return 1/this.toSeconds()}toSamples(){return this.toSeconds()*this.context.sampleRate}toMilliseconds(){return 1e3*this.toSeconds()}}class ao extends ro{constructor(){super(...arguments),this.name="TimeClass"}_getExpressions(){return Object.assign(super._getExpressions(),{now:{method:t=>this._now()+new this.constructor(this.context,t).valueOf(),regexp:/^\+(.+)/},quantize:{method:t=>{const e=new ao(this.context,t).valueOf();return this._secondsToUnits(this.context.transport.nextSubdivision(e))},regexp:/^@(.+)/}})}quantize(t,e=1){const n=new this.constructor(this.context,t).valueOf(),s=this.valueOf();return s+(Math.round(s/n)*n-s)*e}toNotation(){const t=this.toSeconds(),e=["1m"];for(let t=1;t<9;t++){const n=Math.pow(2,t);e.push(n+"n."),e.push(n+"n"),e.push(n+"t")}e.push("0");let n=e[0],s=new ao(this.context,e[0]).toSeconds();return e.forEach(e=>{const i=new ao(this.context,e).toSeconds();Math.abs(i-t)3&&(s=parseFloat(parseFloat(i).toFixed(3))),[n,e,s].join(":")}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.round(e*this._getPPQ())}toSeconds(){return this.valueOf()}toMidi(){return so(this.toFrequency())}_now(){return this.context.now()}}function lo(t,e){return new ao(Ki(),t,e)}class co extends ao{constructor(){super(...arguments),this.name="Frequency",this.defaultUnits="hz"}static get A4(){return no}static set A4(t){!function(t){no=t}(t)}_getExpressions(){return Object.assign({},super._getExpressions(),{midi:{regexp:/^(\d+(?:\.\d+)?midi)/,method(t){return"midi"===this.defaultUnits?t:co.mtof(t)}},note:{regexp:/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,method(t,e){const n=ho[t.toLowerCase()]+12*(parseInt(e,10)+1);return"midi"===this.defaultUnits?n:co.mtof(n)}},tr:{regexp:/^(\d+(?:\.\d+)?):(\d+(?:\.\d+)?):?(\d+(?:\.\d+)?)?/,method(t,e,n){let s=1;return t&&"0"!==t&&(s*=this._beatsToUnits(this._getTimeSignature()*parseFloat(t))),e&&"0"!==e&&(s*=this._beatsToUnits(parseFloat(e))),n&&"0"!==n&&(s*=this._beatsToUnits(parseFloat(n)/4)),s}}})}transpose(t){return new co(this.context,this.valueOf()*eo(t))}harmonize(t){return t.map(t=>this.transpose(t))}toMidi(){return so(this.valueOf())}toNote(){const t=this.toFrequency(),e=Math.log2(t/co.A4);let n=Math.round(12*e)+57;const s=Math.floor(n/12);return s<0&&(n+=-12*s),uo[n%12]+s.toString()}toSeconds(){return 1/super.toSeconds()}toTicks(){const t=this._beatsToUnits(1),e=this.valueOf()/t;return Math.floor(e*this._getPPQ())}_noArg(){return 0}_frequencyToUnits(t){return t}_ticksToUnits(t){return 1/(60*t/(this._getBpm()*this._getPPQ()))}_beatsToUnits(t){return 1/super._beatsToUnits(t)}_secondsToUnits(t){return 1/t}static mtof(t){return oo(t)}static ftom(t){return so(t)}}const ho={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13},uo=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];function po(t,e){return new co(Ki(),t,e)}class mo extends ao{constructor(){super(...arguments),this.name="TransportTime"}_now(){return this.context.transport.seconds}}function fo(t,e){return new mo(Ki(),t,e)}class go extends Mi{constructor(){super();const t=ki(go.getDefaults(),arguments,["context"]);this.defaultContext?this.context=this.defaultContext:this.context=t.context}static getDefaults(){return{context:Ki()}}now(){return this.context.currentTime+this.context.lookAhead}immediate(){return this.context.currentTime}get sampleTime(){return 1/this.context.sampleRate}get blockTime(){return 128/this.context.sampleRate}toSeconds(t){return new ao(this.context,t).toSeconds()}toFrequency(t){return new co(this.context,t).toFrequency()}toTicks(t){return new mo(this.context,t).toTicks()}_getPartialProperties(t){const e=this.get();return Object.keys(e).forEach(n=>{ei(t[n])&&delete e[n]}),e}get(){const t=this.constructor.getDefaults();return Object.keys(t).forEach(e=>{if(Reflect.has(this,e)){const n=this[e];ni(n)&&ni(n.value)&&ni(n.setValueAtTime)?t[e]=n.value:n instanceof go?t[e]=n._getPartialProperties(t[e]):ai(n)||ii(n)||li(n)||ri(n)?t[e]=n:delete t[e]}}),t}set(t){return Object.keys(t).forEach(e=>{Reflect.has(this,e)&&ni(this[e])&&(this[e]&&ni(this[e].value)&&ni(this[e].setValueAtTime)?this[e].value!==t[e]&&(this[e].value=t[e]):this[e]instanceof go?this[e].set(t[e]):this[e]=t[e])}),this}}class _o extends Bi{constructor(t="stopped"){super(),this.name="StateTimeline",this._initial=t,this.setStateAtTime(this._initial,0)}getValueAtTime(t){const e=this.get(t);return null!==e?e.state:this._initial}setStateAtTime(t,e,n){return Ys(e,0),this.add(Object.assign({},n,{state:t,time:e})),this}getLastState(t,e){for(let n=this._search(e);n>=0;n--){const e=this._timeline[n];if(e.state===t)return e}}getNextState(t,e){const n=this._search(e);if(-1!==n)for(let e=n;ethis.getValueAtTime(t)}static getDefaults(){return Object.assign(go.getDefaults(),{convert:!0,units:"number"})}get value(){const t=this.now();return this.getValueAtTime(t)}set value(t){this.cancelScheduledValues(this.now()),this.setValueAtTime(t,this.now())}get minValue(){return ni(this._minValue)?this._minValue:"time"===this.units||"frequency"===this.units||"normalRange"===this.units||"positive"===this.units||"transportTime"===this.units||"ticks"===this.units||"bpm"===this.units||"hertz"===this.units||"samples"===this.units?0:"audioRange"===this.units?-1:"decibels"===this.units?-1/0:this._param.minValue}get maxValue(){return ni(this._maxValue)?this._maxValue:"normalRange"===this.units||"audioRange"===this.units?1:this._param.maxValue}_is(t,e){return this.units===e}_assertRange(t){return"undefined"==typeof window||void 0===window.webkitAudioContext||"gain"!==this._param.name&&"Q"!==this._param.name?(ni(this.maxValue)&&ni(this.minValue)&&Ys(t,this._fromType(this.minValue),this._fromType(this.maxValue)),t):t}_fromType(t){return this.convert&&!this.overridden?this._is(t,"time")?this.toSeconds(t):this._is(t,"decibels")?$i(t):this._is(t,"frequency")?this.toFrequency(t):t:this.overridden?0:t}_toType(t){return this.convert&&"decibels"===this.units?to(t):t}setValueAtTime(t,e){const n=this.toSeconds(e),s=this._fromType(t);return Gs(isFinite(s)&&isFinite(n),`Invalid argument(s) to setValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(s),this.log(this.units,"setValueAtTime",t,n),this._events.add({time:n,type:"setValueAtTime",value:s}),this._param.setValueAtTime(s,n),this}getValueAtTime(t){const e=Math.max(this.toSeconds(t),0),n=this._events.getAfter(e),s=this._events.get(e);let i=this._initialValue;if(null===s)i=this._initialValue;else if("setTargetAtTime"!==s.type||null!==n&&"setValueAtTime"!==n.type)if(null===n)i=s.value;else if("linearRampToValueAtTime"===n.type||"exponentialRampToValueAtTime"===n.type){let t=s.value;if("setTargetAtTime"===s.type){const e=this._events.getBefore(s.time);t=null===e?this._initialValue:e.value}i="linearRampToValueAtTime"===n.type?this._linearInterpolate(s.time,t,n.time,n.value,e):this._exponentialInterpolate(s.time,t,n.time,n.value,e)}else i=s.value;else{const t=this._events.getBefore(s.time);let n;n=null===t?this._initialValue:t.value,"setTargetAtTime"===s.type&&(i=this._exponentialApproach(s.time,n,s.value,s.constant,e))}return this._toType(i)}setRampPoint(t){t=this.toSeconds(t);let e=this.getValueAtTime(t);return this.cancelAndHoldAtTime(t),0===this._fromType(e)&&(e=this._toType(this._minOutput)),this.setValueAtTime(e,t),this}linearRampToValueAtTime(t,e){const n=this._fromType(t),s=this.toSeconds(e);return Gs(isFinite(n)&&isFinite(s),`Invalid argument(s) to linearRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._assertRange(n),this._events.add({time:s,type:"linearRampToValueAtTime",value:n}),this.log(this.units,"linearRampToValueAtTime",t,s),this._param.linearRampToValueAtTime(n,s),this}exponentialRampToValueAtTime(t,e){let n=this._fromType(t);n=Math.max(this._minOutput,n),this._assertRange(n);const s=this.toSeconds(e);return Gs(isFinite(n)&&isFinite(s),`Invalid argument(s) to exponentialRampToValueAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({time:s,type:"exponentialRampToValueAtTime",value:n}),this.log(this.units,"exponentialRampToValueAtTime",t,s),this._param.exponentialRampToValueAtTime(n,s),this}exponentialRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialRampToValueAtTime(t,n+this.toSeconds(e)),this}linearRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.linearRampToValueAtTime(t,n+this.toSeconds(e)),this}targetRampTo(t,e,n){return n=this.toSeconds(n),this.setRampPoint(n),this.exponentialApproachValueAtTime(t,n,e),this}exponentialApproachValueAtTime(t,e,n){e=this.toSeconds(e),n=this.toSeconds(n);const s=Math.log(n+1)/Math.log(200);return this.setTargetAtTime(t,e,s),this.cancelAndHoldAtTime(e+.9*n),this.linearRampToValueAtTime(t,e+n),this}setTargetAtTime(t,e,n){const s=this._fromType(t);Gs(isFinite(n)&&n>0,"timeConstant must be a number greater than 0");const i=this.toSeconds(e);return this._assertRange(s),Gs(isFinite(s)&&isFinite(i),`Invalid argument(s) to setTargetAtTime: ${JSON.stringify(t)}, ${JSON.stringify(e)}`),this._events.add({constant:n,time:i,type:"setTargetAtTime",value:s}),this.log(this.units,"setTargetAtTime",t,i,n),this._param.setTargetAtTime(s,i,n),this}setValueCurveAtTime(t,e,n,s=1){n=this.toSeconds(n),e=this.toSeconds(e);const i=this._fromType(t[0])*s;this.setValueAtTime(this._toType(i),e);const o=n/(t.length-1);for(let n=1;n{"cancelScheduledValues"===e.type?t.cancelScheduledValues(e.time):"setTargetAtTime"===e.type?t.setTargetAtTime(e.value,e.time,e.constant):t[e.type](e.value,e.time)}),this}setParam(t){Gs(this._swappable,"The Param must be assigned as 'swappable' in the constructor");const e=this.input;return e.disconnect(this._param),this.apply(t),this._param=t,e.connect(this._param),this}dispose(){return super.dispose(),this._events.dispose(),this}get defaultValue(){return this._toType(this._param.defaultValue)}_exponentialApproach(t,e,n,s,i){return n+(e-n)*Math.exp(-(i-t)/s)}_linearInterpolate(t,e,n,s,i){return e+(i-t)/(n-t)*(s-e)}_exponentialInterpolate(t,e,n,s,i){return e*Math.pow(s/e,(i-t)/(n-t))}}class bo extends go{constructor(){super(...arguments),this.name="ToneAudioNode",this._internalChannels=[]}get numberOfInputs(){return ni(this.input)?vi(this.input)||this.input instanceof vo?1:this.input.numberOfInputs:0}get numberOfOutputs(){return ni(this.output)?this.output.numberOfOutputs:0}_isAudioNode(t){return ni(t)&&(t instanceof bo||bi(t))}_getInternalNodes(){const t=this._internalChannels.slice(0);return this._isAudioNode(this.input)&&t.push(this.input),this._isAudioNode(this.output)&&this.input!==this.output&&t.push(this.output),t}_setChannelProperties(t){this._getInternalNodes().forEach(e=>{e.channelCount=t.channelCount,e.channelCountMode=t.channelCountMode,e.channelInterpretation=t.channelInterpretation})}_getChannelProperties(){const t=this._getInternalNodes();Gs(t.length>0,"ToneAudioNode does not have any internal nodes");const e=t[0];return{channelCount:e.channelCount,channelCountMode:e.channelCountMode,channelInterpretation:e.channelInterpretation}}get channelCount(){return this._getChannelProperties().channelCount}set channelCount(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCount:t}))}get channelCountMode(){return this._getChannelProperties().channelCountMode}set channelCountMode(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelCountMode:t}))}get channelInterpretation(){return this._getChannelProperties().channelInterpretation}set channelInterpretation(t){const e=this._getChannelProperties();this._setChannelProperties(Object.assign(e,{channelInterpretation:t}))}connect(t,e=0,n=0){return wo(this,t,e,n),this}toDestination(){return this.connect(this.context.destination),this}toMaster(){return ti("toMaster() has been renamed toDestination()"),this.toDestination()}disconnect(t,e=0,n=0){return xo(this,t,e,n),this}chain(...t){return yo(this,...t),this}fan(...t){return t.forEach(t=>this.connect(t)),this}dispose(){return super.dispose(),ni(this.input)&&(this.input instanceof bo?this.input.dispose():bi(this.input)&&this.input.disconnect()),ni(this.output)&&(this.output instanceof bo?this.output.dispose():bi(this.output)&&this.output.disconnect()),this._internalChannels=[],this}}function yo(...t){const e=t.shift();t.reduce((t,e)=>(t instanceof bo?t.connect(e):bi(t)&&wo(t,e),e),e)}function wo(t,e,n=0,s=0){for(Gs(ni(t),"Cannot connect from undefined node"),Gs(ni(e),"Cannot connect to undefined node"),(e instanceof bo||bi(e))&&Gs(e.numberOfInputs>0,"Cannot connect to node with no inputs"),Gs(t.numberOfOutputs>0,"Cannot connect from node with no outputs");e instanceof bo||e instanceof vo;)ni(e.input)&&(e=e.input);for(;t instanceof bo;)ni(t.output)&&(t=t.output);vi(e)?t.connect(e,n):t.connect(e,n,s)}function xo(t,e,n=0,s=0){if(ni(e))for(;e instanceof bo;)e=e.input;for(;!bi(t);)ni(t.output)&&(t=t.output);vi(e)?t.disconnect(e,n):bi(e)?t.disconnect(e,n,s):t.disconnect()}class So extends bo{constructor(){super(ki(So.getDefaults(),arguments,["gain","units"])),this.name="Gain",this._gainNode=this.context.createGain(),this.input=this._gainNode,this.output=this._gainNode;const t=ki(So.getDefaults(),arguments,["gain","units"]);this.gain=new vo({context:this.context,convert:t.convert,param:this._gainNode.gain,units:t.units,value:t.gain,minValue:t.minValue,maxValue:t.maxValue}),Hi(this,"gain")}static getDefaults(){return Object.assign(bo.getDefaults(),{convert:!0,gain:1,units:"gain"})}dispose(){return super.dispose(),this._gainNode.disconnect(),this.gain.dispose(),this}}class Co extends bo{constructor(t){super(t),this.onended=Qi,this._startTime=-1,this._stopTime=-1,this._timeout=-1,this.output=new So({context:this.context,gain:0}),this._gainNode=this.output,this.getStateAtTime=function(t){const e=this.toSeconds(t);return-1!==this._startTime&&e>=this._startTime&&(-1===this._stopTime||e<=this._stopTime)?"started":"stopped"},this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut,this._curve=t.curve,this.onended=t.onended}static getDefaults(){return Object.assign(bo.getDefaults(),{curve:"linear",fadeIn:0,fadeOut:0,onended:Qi})}_startGain(t,e=1){Gs(-1===this._startTime,"Source cannot be started more than once");const n=this.toSeconds(this._fadeIn);return this._startTime=t+n,this._startTime=Math.max(this._startTime,this.context.currentTime),n>0?(this._gainNode.gain.setValueAtTime(0,t),"linear"===this._curve?this._gainNode.gain.linearRampToValueAtTime(e,t+n):this._gainNode.gain.exponentialApproachValueAtTime(e,t,n)):this._gainNode.gain.setValueAtTime(e,t),this}stop(t){return this.log("stop",t),this._stopGain(this.toSeconds(t)),this}_stopGain(t){Gs(-1!==this._startTime,"'start' must be called before 'stop'"),this.cancelStop();const e=this.toSeconds(this._fadeOut);return this._stopTime=this.toSeconds(t)+e,this._stopTime=Math.max(this._stopTime,this.context.currentTime),e>0?"linear"===this._curve?this._gainNode.gain.linearRampTo(0,e,t):this._gainNode.gain.targetRampTo(0,e,t):(this._gainNode.gain.cancelAndHoldAtTime(t),this._gainNode.gain.setValueAtTime(0,t)),this.context.clearTimeout(this._timeout),this._timeout=this.context.setTimeout(()=>{const t="exponential"===this._curve?2*e:0;this._stopSource(this.now()+t),this._onended()},this._stopTime-this.context.currentTime),this}_onended(){if(this.onended!==Qi&&(this.onended(this),this.onended=Qi,!this.context.isOffline)){const t=()=>this.dispose();void 0!==window.requestIdleCallback?window.requestIdleCallback(t):setTimeout(t,1e3)}}get state(){return this.getStateAtTime(this.now())}cancelStop(){return this.log("cancelStop"),Gs(-1!==this._startTime,"Source is not started"),this._gainNode.gain.cancelScheduledValues(this._startTime+this.sampleTime),this.context.clearTimeout(this._timeout),this._stopTime=-1,this}dispose(){return super.dispose(),this._gainNode.disconnect(),this}}class ko extends Co{constructor(){super(ki(ko.getDefaults(),arguments,["offset"])),this.name="ToneConstantSource";const t=ki(ko.getDefaults(),arguments,["offset"]);try{this._source=this.context.createConstantSource(),wo(this._source,this._gainNode),this.offset=new vo({context:this.context,convert:t.convert,param:this._source.offset,units:t.units,value:t.offset,minValue:t.minValue,maxValue:t.maxValue})}catch(t){return void console.error("ToneConstantSource constructor:",t)}}static getDefaults(){return Object.assign(Co.getDefaults(),{convert:!0,offset:1,units:"number"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._source.start(e),this}_stopSource(t){try{this._source.stop(t)}catch(t){console.error("ToneConstantSource _stopSource error:",t)}}dispose(){if(super.dispose(),"started"===this.state)try{this.stop()}catch(t){console.error("ToneConstantSource dispose stop error:",t)}return this._source.disconnect(),this.offset.dispose(),this}}class Eo extends bo{constructor(){super(ki(Eo.getDefaults(),arguments,["value","units"])),this.name="Signal",this.override=!0;const t=ki(Eo.getDefaults(),arguments,["value","units"]);this.output=this._constantSource=new ko({context:this.context,convert:t.convert,offset:t.value,units:t.units,minValue:t.minValue,maxValue:t.maxValue}),this._constantSource.start(0),this.input=this._param=this._constantSource.offset}static getDefaults(){return Object.assign(bo.getDefaults(),{convert:!0,units:"number",value:0})}connect(t,e=0,n=0){return Po(this,t,e,n),this}dispose(){return super.dispose(),this._param.dispose(),this._constantSource.dispose(),this}setValueAtTime(t,e){return this._param.setValueAtTime(t,e),this}getValueAtTime(t){return this._param.getValueAtTime(t)}setRampPoint(t){return this._param.setRampPoint(t),this}linearRampToValueAtTime(t,e){return this._param.linearRampToValueAtTime(t,e),this}exponentialRampToValueAtTime(t,e){return this._param.exponentialRampToValueAtTime(t,e),this}exponentialRampTo(t,e,n){return this._param.exponentialRampTo(t,e,n),this}linearRampTo(t,e,n){return this._param.linearRampTo(t,e,n),this}targetRampTo(t,e,n){return this._param.targetRampTo(t,e,n),this}exponentialApproachValueAtTime(t,e,n){return this._param.exponentialApproachValueAtTime(t,e,n),this}setTargetAtTime(t,e,n){return this._param.setTargetAtTime(t,e,n),this}setValueCurveAtTime(t,e,n,s){return this._param.setValueCurveAtTime(t,e,n,s),this}cancelScheduledValues(t){return this._param.cancelScheduledValues(t),this}cancelAndHoldAtTime(t){return this._param.cancelAndHoldAtTime(t),this}rampTo(t,e,n){return this._param.rampTo(t,e,n),this}get value(){return this._param.value}set value(t){this._param.value=t}get convert(){return this._param.convert}set convert(t){this._param.convert=t}get units(){return this._param.units}get overridden(){return this._param.overridden}set overridden(t){this._param.overridden=t}get maxValue(){return this._param.maxValue}get minValue(){return this._param.minValue}apply(t){return this._param.apply(t),this}}function Po(t,e,n,s){(e instanceof vo||vi(e)||e instanceof Eo&&e.override)&&(e.cancelScheduledValues(0),e.setValueAtTime(0,0),e instanceof Eo&&(e.overridden=!0)),wo(t,e,n,s)}class To extends vo{constructor(){super(ki(To.getDefaults(),arguments,["value"])),this.name="TickParam",this._events=new Bi(1/0),this._multiplier=1;const t=ki(To.getDefaults(),arguments,["value"]);this._multiplier=t.multiplier,this._events.cancel(0),this._events.add({ticks:0,time:0,type:"setValueAtTime",value:this._fromType(t.value)}),this.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(vo.getDefaults(),{multiplier:1,units:"hertz",value:1})}setTargetAtTime(t,e,n){e=this.toSeconds(e),this.setRampPoint(e);const s=this._fromType(t),i=this._events.get(e),o=Math.round(Math.max(1/n,1));for(let t=0;t<=o;t++){const o=n*t+e,r=this._exponentialApproach(i.time,i.value,s,n,o);this.linearRampToValueAtTime(this._toType(r),o)}return this}setValueAtTime(t,e){const n=this.toSeconds(e);super.setValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),o=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(o,0),this}linearRampToValueAtTime(t,e){const n=this.toSeconds(e);super.linearRampToValueAtTime(t,e);const s=this._events.get(n),i=this._events.previousEvent(s),o=this._getTicksUntilEvent(i,n);return s.ticks=Math.max(o,0),this}exponentialRampToValueAtTime(t,e){e=this.toSeconds(e);const n=this._fromType(t),s=this._events.get(e),i=Math.round(Math.max(10*(e-s.time),1)),o=(e-s.time)/i;for(let t=0;t<=i;t++){const i=o*t+s.time,r=this._exponentialInterpolate(s.time,s.value,e,n,i);this.linearRampToValueAtTime(this._toType(r),i)}return this}_getTicksUntilEvent(t,e){if(null===t)t={ticks:0,time:0,type:"setValueAtTime",value:0};else if(ei(t.ticks)){const e=this._events.previousEvent(t);t.ticks=this._getTicksUntilEvent(e,t.time)}const n=this._fromType(this.getValueAtTime(t.time));let s=this._fromType(this.getValueAtTime(e));const i=this._events.get(e);return i&&i.time===e&&"setValueAtTime"===i.type&&(s=this._fromType(this.getValueAtTime(e-this.sampleTime))),.5*(e-t.time)*(n+s)+t.ticks}getTicksAtTime(t){const e=this.toSeconds(t),n=this._events.get(e);return Math.max(this._getTicksUntilEvent(n,e),0)}getDurationOfTicks(t,e){const n=this.toSeconds(e),s=this.getTicksAtTime(e);return this.getTimeOfTick(s+t)-n}getTimeOfTick(t){const e=this._events.get(t,"ticks"),n=this._events.getAfter(t,"ticks");if(e&&e.ticks===t)return e.time;if(e&&n&&"linearRampToValueAtTime"===n.type&&e.value!==n.value){const s=this._fromType(this.getValueAtTime(e.time)),i=(this._fromType(this.getValueAtTime(n.time))-s)/(n.time-e.time),o=Math.sqrt(Math.pow(s,2)-2*i*(e.ticks-t)),r=(-s+o)/i,a=(-s-o)/i;return(r>0?r:a)+e.time}return e?0===e.value?1/0:e.time+(t-e.ticks)/e.value:t/this._initialValue}ticksToTime(t,e){return this.getDurationOfTicks(t,e)}timeToTicks(t,e){const n=this.toSeconds(e),s=this.toSeconds(t),i=this.getTicksAtTime(n);return this.getTicksAtTime(n+s)-i}_fromType(t){return"bpm"===this.units&&this.multiplier?1/(60/t/this.multiplier):super._fromType(t)}_toType(t){return"bpm"===this.units&&this.multiplier?t/this.multiplier*60:super._toType(t)}get multiplier(){return this._multiplier}set multiplier(t){const e=this.value;this._multiplier=t,this.cancelScheduledValues(0),this.setValueAtTime(e,0)}}class Mo extends Eo{constructor(){super(ki(Mo.getDefaults(),arguments,["value"])),this.name="TickSignal";const t=ki(Mo.getDefaults(),arguments,["value"]);this.input=this._param=new To({context:this.context,convert:t.convert,multiplier:t.multiplier,param:this._constantSource.offset,units:t.units,value:t.value})}static getDefaults(){return Object.assign(Eo.getDefaults(),{multiplier:1,units:"hertz",value:1})}ticksToTime(t,e){return this._param.ticksToTime(t,e)}timeToTicks(t,e){return this._param.timeToTicks(t,e)}getTimeOfTick(t){return this._param.getTimeOfTick(t)}getDurationOfTicks(t,e){return this._param.getDurationOfTicks(t,e)}getTicksAtTime(t){return this._param.getTicksAtTime(t)}get multiplier(){return this._param.multiplier}set multiplier(t){this._param.multiplier=t}dispose(){return super.dispose(),this._param.dispose(),this}}class Ro extends go{constructor(){super(ki(Ro.getDefaults(),arguments,["frequency"])),this.name="TickSource",this._state=new _o,this._tickOffset=new Bi;const t=ki(Ro.getDefaults(),arguments,["frequency"]);this.frequency=new Mo({context:this.context,units:t.units,value:t.frequency}),Hi(this,"frequency"),this._state.setStateAtTime("stopped",0),this.setTicksAtTime(0,0)}static getDefaults(){return Object.assign({frequency:1,units:"hertz"},go.getDefaults())}get state(){return this.getStateAtTime(this.now())}start(t,e){const n=this.toSeconds(t);return"started"!==this._state.getValueAtTime(n)&&(this._state.setStateAtTime("started",n),ni(e)&&this.setTicksAtTime(e,n)),this}stop(t){const e=this.toSeconds(t);if("stopped"===this._state.getValueAtTime(e)){const t=this._state.get(e);t&&t.time>0&&(this._tickOffset.cancel(t.time),this._state.cancel(t.time))}return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this.setTicksAtTime(0,e),this}pause(t){const e=this.toSeconds(t);return"started"===this._state.getValueAtTime(e)&&this._state.setStateAtTime("paused",e),this}cancel(t){return t=this.toSeconds(t),this._state.cancel(t),this._tickOffset.cancel(t),this}getTicksAtTime(t){const e=this.toSeconds(t),n=this._state.getLastState("stopped",e),s={state:"paused",time:e};this._state.add(s);let i=n,o=0;return this._state.forEachBetween(n.time,e+this.sampleTime,t=>{let e=i.time;const n=this._tickOffset.get(t.time);n&&n.time>=i.time&&(o=n.ticks,e=n.time),"started"===i.state&&"started"!==t.state&&(o+=this.frequency.getTicksAtTime(t.time)-this.frequency.getTicksAtTime(e)),i=t}),this._state.remove(s),o}get ticks(){return this.getTicksAtTime(this.now())}set ticks(t){this.setTicksAtTime(t,this.now())}get seconds(){return this.getSecondsAtTime(this.now())}set seconds(t){const e=this.now(),n=this.frequency.timeToTicks(t,e);this.setTicksAtTime(n,e)}getSecondsAtTime(t){t=this.toSeconds(t);const e=this._state.getLastState("stopped",t),n={state:"paused",time:t};this._state.add(n);let s=e,i=0;return this._state.forEachBetween(e.time,t+this.sampleTime,t=>{let e=s.time;const n=this._tickOffset.get(t.time);n&&n.time>=s.time&&(i=n.seconds,e=n.time),"started"===s.state&&"started"!==t.state&&(i+=t.time-e),s=t}),this._state.remove(n),i}setTicksAtTime(t,e){return e=this.toSeconds(e),this._tickOffset.cancel(e),this._tickOffset.add({seconds:this.frequency.getDurationOfTicks(t,e),ticks:t,time:e}),this}getStateAtTime(t){return t=this.toSeconds(t),this._state.getValueAtTime(t)}getTimeOfTick(t,e=this.now()){const n=this._tickOffset.get(e),s=this._state.get(e),i=Math.max(n.time,s.time),o=this.frequency.getTicksAtTime(i)+t-n.ticks;return this.frequency.getTimeOfTick(o)}forEachTickBetween(t,e,n){let s=this._state.get(t);this._state.forEachBetween(t,e,e=>{s&&"started"===s.state&&"started"!==e.state&&this.forEachTickBetween(Math.max(s.time,t),e.time-this.sampleTime,n),s=e});let i=null;if(s&&"started"===s.state){const o=Math.max(s.time,t),r=this.frequency.getTicksAtTime(o),a=r-this.frequency.getTicksAtTime(s.time);let l=Math.ceil(a)-a;l=Ni(l,1)?0:l;let c=this.frequency.getTimeOfTick(r+l);for(;c{switch(t.state){case"started":const e=this._tickSource.getTicksAtTime(t.time);this.emit("start",t.time,e);break;case"stopped":0!==t.time&&this.emit("stop",t.time);break;case"paused":this.emit("pause",t.time)}}),this._tickSource.forEachTickBetween(t,e,(t,e)=>{this.callback(t,e)}))}getStateAtTime(t){const e=this.toSeconds(t);return this._state.getValueAtTime(e)}dispose(){return super.dispose(),this.context.off("tick",this._boundLoop),this._tickSource.dispose(),this._state.dispose(),this}}Li.mixin(Ao);class Oo extends bo{constructor(){super(ki(Oo.getDefaults(),arguments,["delayTime","maxDelay"])),this.name="Delay";const t=ki(Oo.getDefaults(),arguments,["delayTime","maxDelay"]),e=this.toSeconds(t.maxDelay);this._maxDelay=Math.max(e,this.toSeconds(t.delayTime)),this._delayNode=this.input=this.output=this.context.createDelay(e),this.delayTime=new vo({context:this.context,param:this._delayNode.delayTime,units:"time",value:t.delayTime,minValue:0,maxValue:this.maxDelay}),Hi(this,"delayTime")}static getDefaults(){return Object.assign(bo.getDefaults(),{delayTime:0,maxDelay:1})}get maxDelay(){return this._maxDelay}dispose(){return super.dispose(),this._delayNode.disconnect(),this.delayTime.dispose(),this}}function No(t,e,n=2,s=Ki().sampleRate){return gi(this,void 0,void 0,(function*(){const i=Ki(),o=new zi(n,e,s);Zi(o),yield t(o);const r=o.render();Zi(i);const a=yield r;return new Xi(a)}))}class Do extends Mi{constructor(){super(),this.name="ToneAudioBuffers",this._buffers=new Map,this._loadingCount=0;const t=ki(Do.getDefaults(),arguments,["urls","onload","baseUrl"],"urls");this.baseUrl=t.baseUrl,Object.keys(t.urls).forEach(e=>{this._loadingCount++;const n=t.urls[e];this.add(e,n,this._bufferLoaded.bind(this,t.onload),t.onerror)})}static getDefaults(){return{baseUrl:"",onerror:Qi,onload:Qi,urls:{}}}has(t){return this._buffers.has(t.toString())}get(t){return Gs(this.has(t),"ToneAudioBuffers has no buffer named: "+t),this._buffers.get(t.toString())}_bufferLoaded(t){this._loadingCount--,0===this._loadingCount&&t&&t()}get loaded(){return Array.from(this._buffers).every(([t,e])=>e.loaded)}add(t,e,n=Qi,s=Qi){return li(e)?this._buffers.set(t.toString(),new Xi(this.baseUrl+e,n,s)):this._buffers.set(t.toString(),new Xi(e,n,s)),this}dispose(){return super.dispose(),this._buffers.forEach(t=>t.dispose()),this._buffers.clear(),this}}class Bo extends co{constructor(){super(...arguments),this.name="MidiClass",this.defaultUnits="midi"}_frequencyToUnits(t){return so(super._frequencyToUnits(t))}_ticksToUnits(t){return so(super._ticksToUnits(t))}_beatsToUnits(t){return so(super._beatsToUnits(t))}_secondsToUnits(t){return so(super._secondsToUnits(t))}toMidi(){return this.valueOf()}toFrequency(){return oo(this.toMidi())}transpose(t){return new Bo(this.context,this.toMidi()+t)}}function Io(t,e){return new Bo(Ki(),t,e)}class Fo extends mo{constructor(){super(...arguments),this.name="Ticks",this.defaultUnits="i"}_now(){return this.context.transport.ticks}_beatsToUnits(t){return this._getPPQ()*t}_secondsToUnits(t){return Math.floor(t/(60/this._getBpm())*this._getPPQ())}_ticksToUnits(t){return t}toTicks(){return this.valueOf()}toSeconds(){return this.valueOf()/this._getPPQ()*(60/this._getBpm())}}function Vo(t,e){return new Fo(Ki(),t,e)}class jo extends go{constructor(){super(...arguments),this.name="Draw",this.expiration=.25,this.anticipation=.008,this._events=new Bi,this._boundDrawLoop=this._drawLoop.bind(this),this._animationFrame=-1}schedule(t,e){return this._events.add({callback:t,time:this.toSeconds(e)}),1===this._events.length&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop)),this}cancel(t){return this._events.cancel(this.toSeconds(t)),this}_drawLoop(){const t=this.context.currentTime;for(;this._events.length&&this._events.peek().time-this.anticipation<=t;){const e=this._events.shift();e&&t-e.time<=this.expiration&&e.callback()}this._events.length>0&&(this._animationFrame=requestAnimationFrame(this._boundDrawLoop))}dispose(){return super.dispose(),this._events.dispose(),cancelAnimationFrame(this._animationFrame),this}}Fi(t=>{t.draw=new jo({context:t})}),ji(t=>{t.draw.dispose()});class Lo extends Mi{constructor(){super(...arguments),this.name="IntervalTimeline",this._root=null,this._length=0}add(t){Gs(ni(t.time),"Events must have a time property"),Gs(ni(t.duration),"Events must have a duration parameter"),t.time=t.time.valueOf();let e=new qo(t.time,t.time+t.duration,t);for(null===this._root?this._root=e:this._root.insert(e),this._length++;null!==e;)e.updateHeight(),e.updateMax(),this._rebalance(e),e=e.parent;return this}remove(t){if(null!==this._root){const e=[];this._root.search(t.time,e);for(const n of e)if(n.event===t){this._removeNode(n),this._length--;break}}return this}get length(){return this._length}cancel(t){return this.forEachFrom(t,t=>this.remove(t)),this}_setRoot(t){this._root=t,null!==this._root&&(this._root.parent=null)}_replaceNodeInParent(t,e){null!==t.parent?(t.isLeftChild()?t.parent.left=e:t.parent.right=e,this._rebalance(t.parent)):this._setRoot(e)}_removeNode(t){if(null===t.left&&null===t.right)this._replaceNodeInParent(t,null);else if(null===t.right)this._replaceNodeInParent(t,t.left);else if(null===t.left)this._replaceNodeInParent(t,t.right);else{let e,n=null;if(t.getBalance()>0)if(null===t.left.right)e=t.left,e.right=t.right,n=e;else{for(e=t.left.right;null!==e.right;)e=e.right;e.parent&&(e.parent.right=e.left,n=e.parent,e.left=t.left,e.right=t.right)}else if(null===t.right.left)e=t.right,e.left=t.left,n=e;else{for(e=t.right.left;null!==e.left;)e=e.left;e.parent&&(e.parent.left=e.right,n=e.parent,e.left=t.left,e.right=t.right)}null!==t.parent?t.isLeftChild()?t.parent.left=e:t.parent.right=e:this._setRoot(e),n&&this._rebalance(n)}t.dispose()}_rotateLeft(t){const e=t.parent,n=t.isLeftChild(),s=t.right;s&&(t.right=s.left,s.left=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_rotateRight(t){const e=t.parent,n=t.isLeftChild(),s=t.left;s&&(t.left=s.right,s.right=t),null!==e?n?e.left=s:e.right=s:this._setRoot(s)}_rebalance(t){const e=t.getBalance();e>1&&t.left?t.left.getBalance()<0?this._rotateLeft(t.left):this._rotateRight(t):e<-1&&t.right&&(t.right.getBalance()>0?this._rotateRight(t.right):this._rotateLeft(t))}get(t){if(null!==this._root){const e=[];if(this._root.search(t,e),e.length>0){let t=e[0];for(let n=1;nt.low&&(t=e[n]);return t.event}}return null}forEach(t){if(null!==this._root){const e=[];this._root.traverse(t=>e.push(t)),e.forEach(e=>{e.event&&t(e.event)})}return this}forEachAtTime(t,e){if(null!==this._root){const n=[];this._root.search(t,n),n.forEach(t=>{t.event&&e(t.event)})}return this}forEachFrom(t,e){if(null!==this._root){const n=[];this._root.searchAfter(t,n),n.forEach(t=>{t.event&&e(t.event)})}return this}dispose(){return super.dispose(),null!==this._root&&this._root.traverse(t=>t.dispose()),this._root=null,this}}class qo{constructor(t,e,n){this._left=null,this._right=null,this.parent=null,this.height=0,this.event=n,this.low=t,this.high=e,this.max=this.high}insert(t){t.low<=this.low?null===this.left?this.left=t:this.left.insert(t):null===this.right?this.right=t:this.right.insert(t)}search(t,e){t>this.max||(null!==this.left&&this.left.search(t,e),this.low<=t&&this.high>t&&e.push(this),this.low>t||null!==this.right&&this.right.search(t,e))}searchAfter(t,e){this.low>=t&&(e.push(this),null!==this.left&&this.left.searchAfter(t,e)),null!==this.right&&this.right.searchAfter(t,e)}traverse(t){t(this),null!==this.left&&this.left.traverse(t),null!==this.right&&this.right.traverse(t)}updateHeight(){null!==this.left&&null!==this.right?this.height=Math.max(this.left.height,this.right.height)+1:null!==this.right?this.height=this.right.height+1:null!==this.left?this.height=this.left.height+1:this.height=0}updateMax(){this.max=this.high,null!==this.left&&(this.max=Math.max(this.max,this.left.max)),null!==this.right&&(this.max=Math.max(this.max,this.right.max))}getBalance(){let t=0;return null!==this.left&&null!==this.right?t=this.left.height-this.right.height:null!==this.left?t=this.left.height+1:null!==this.right&&(t=-(this.right.height+1)),t}isLeftChild(){return null!==this.parent&&this.parent.left===this}get left(){return this._left}set left(t){this._left=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}get right(){return this._right}set right(t){this._right=t,null!==t&&(t.parent=this),this.updateHeight(),this.updateMax()}dispose(){this.parent=null,this._left=null,this._right=null,this.event=null}}class Uo extends bo{constructor(){super(ki(Uo.getDefaults(),arguments,["volume"])),this.name="Volume";const t=ki(Uo.getDefaults(),arguments,["volume"]);this.input=this.output=new So({context:this.context,gain:t.volume,units:"decibels"}),this.volume=this.output.gain,Hi(this,"volume"),this._unmutedVolume=t.volume,this.mute=t.mute}static getDefaults(){return Object.assign(bo.getDefaults(),{mute:!1,volume:0})}get mute(){return this.volume.value===-1/0}set mute(t){!this.mute&&t?(this._unmutedVolume=this.volume.value,this.volume.value=-1/0):this.mute&&!t&&(this.volume.value=this._unmutedVolume)}dispose(){return super.dispose(),this.input.dispose(),this.volume.dispose(),this}}class Ho extends bo{constructor(){super(ki(Ho.getDefaults(),arguments)),this.name="Destination",this.input=new Uo({context:this.context}),this.output=new So({context:this.context}),this.volume=this.input.volume;const t=ki(Ho.getDefaults(),arguments);yo(this.input,this.output,this.context.rawContext.destination),this.mute=t.mute,this._internalChannels=[this.input,this.context.rawContext.destination,this.output]}static getDefaults(){return Object.assign(bo.getDefaults(),{mute:!1,volume:0})}get mute(){return this.input.mute}set mute(t){this.input.mute=t}chain(...t){return this.input.disconnect(),t.unshift(this.input),t.push(this.output),yo(...t),this}get maxChannelCount(){return this.context.rawContext.destination.maxChannelCount}dispose(){return super.dispose(),this.volume.dispose(),this}}Fi(t=>{t.destination=new Ho({context:t})}),ji(t=>{t.destination.dispose()});class Wo extends Mi{constructor(t){super(),this.name="TimelineValue",this._timeline=new Bi({memory:10}),this._initialValue=t}set(t,e){return this._timeline.add({value:t,time:e}),this}get(t){const e=this._timeline.get(t);return e?e.value:this._initialValue}}class Qo{constructor(t,e){this.id=Qo._eventId++;const n=Object.assign(Qo.getDefaults(),e);this.transport=t,this.callback=n.callback,this._once=n.once,this.time=n.time}static getDefaults(){return{callback:Qi,once:!1,time:0}}invoke(t){this.callback&&(this.callback(t),this._once&&this.transport.clear(this.id))}dispose(){return this.callback=void 0,this}}Qo._eventId=0;class Xo extends Qo{constructor(t,e){super(t,e),this._currentId=-1,this._nextId=-1,this._nextTick=this.time,this._boundRestart=this._restart.bind(this);const n=Object.assign(Xo.getDefaults(),e);this.duration=new Fo(t.context,n.duration).valueOf(),this._interval=new Fo(t.context,n.interval).valueOf(),this._nextTick=n.time,this.transport.on("start",this._boundRestart),this.transport.on("loopStart",this._boundRestart),this.context=this.transport.context,this._restart()}static getDefaults(){return Object.assign({},Qo.getDefaults(),{duration:1/0,interval:1,once:!1})}invoke(t){this._createEvents(t),super.invoke(t)}_createEvents(t){const e=this.transport.getTicksAtTime(t);e>=this.time&&e>=this._nextTick&&this._nextTick+this._intervalthis.time&&(this._nextTick=this.time+Math.ceil((e-this.time)/this._interval)*this._interval),this._currentId=this.transport.scheduleOnce(this.invoke.bind(this),new Fo(this.context,this._nextTick).toSeconds()),this._nextTick+=this._interval,this._nextId=this.transport.scheduleOnce(this.invoke.bind(this),new Fo(this.context,this._nextTick).toSeconds())}dispose(){return super.dispose(),this.transport.clear(this._currentId),this.transport.clear(this._nextId),this.transport.off("start",this._boundRestart),this.transport.off("loopStart",this._boundRestart),this}}class zo extends go{constructor(){super(ki(zo.getDefaults(),arguments)),this.name="Transport",this._loop=new Wo(!1),this._loopStart=0,this._loopEnd=0,this._scheduledEvents={},this._timeline=new Bi,this._repeatedEvents=new Lo,this._syncedSignals=[],this._swingAmount=0;const t=ki(zo.getDefaults(),arguments);this._ppq=t.ppq,this._clock=new Ao({callback:this._processTick.bind(this),context:this.context,frequency:0,units:"bpm"}),this._bindClockEvents(),this.bpm=this._clock.frequency,this._clock.frequency.multiplier=t.ppq,this.bpm.setValueAtTime(t.bpm,0),Hi(this,"bpm"),this._timeSignature=t.timeSignature,this._swingTicks=t.ppq/2}static getDefaults(){return Object.assign(go.getDefaults(),{bpm:120,loopEnd:"4m",loopStart:0,ppq:192,swing:0,swingSubdivision:"8n",timeSignature:4})}_processTick(t,e){if(this._loop.get(t)&&e>=this._loopEnd&&(this.emit("loopEnd",t),this._clock.setTicksAtTime(this._loopStart,t),e=this._loopStart,this.emit("loopStart",t,this._clock.getSecondsAtTime(t)),this.emit("loop",t)),this._swingAmount>0&&e%this._ppq!=0&&e%(2*this._swingTicks)!=0){const n=e%(2*this._swingTicks)/(2*this._swingTicks),s=Math.sin(n*Math.PI)*this._swingAmount;t+=new Fo(this.context,2*this._swingTicks/3).toSeconds()*s}this._timeline.forEachAtTime(e,e=>e.invoke(t))}schedule(t,e){const n=new Qo(this,{callback:t,time:new mo(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}scheduleRepeat(t,e,n,s=1/0){const i=new Xo(this,{callback:t,duration:new ao(this.context,s).toTicks(),interval:new ao(this.context,e).toTicks(),time:new mo(this.context,n).toTicks()});return this._addEvent(i,this._repeatedEvents)}scheduleOnce(t,e){const n=new Qo(this,{callback:t,once:!0,time:new mo(this.context,e).toTicks()});return this._addEvent(n,this._timeline)}clear(t){if(this._scheduledEvents.hasOwnProperty(t)){const e=this._scheduledEvents[t.toString()];e.timeline.remove(e.event),e.event.dispose(),delete this._scheduledEvents[t.toString()]}return this}_addEvent(t,e){return this._scheduledEvents[t.id.toString()]={event:t,timeline:e},e.add(t),t.id}cancel(t=0){const e=this.toTicks(t);return this._timeline.forEachFrom(e,t=>this.clear(t.id)),this._repeatedEvents.forEachFrom(e,t=>this.clear(t.id)),this}_bindClockEvents(){this._clock.on("start",(t,e)=>{e=new Fo(this.context,e).toSeconds(),this.emit("start",t,e)}),this._clock.on("stop",t=>{this.emit("stop",t)}),this._clock.on("pause",t=>{this.emit("pause",t)})}get state(){return this._clock.getStateAtTime(this.now())}start(t,e){let n;return ni(e)&&(n=this.toTicks(e)),this._clock.start(t,n),this}stop(t){return this._clock.stop(t),this}pause(t){return this._clock.pause(t),this}toggle(t){return t=this.toSeconds(t),"started"!==this._clock.getStateAtTime(t)?this.start(t):this.stop(t),this}get timeSignature(){return this._timeSignature}set timeSignature(t){ai(t)&&(t=t[0]/t[1]*4),this._timeSignature=t}get loopStart(){return new ao(this.context,this._loopStart,"i").toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t)}get loopEnd(){return new ao(this.context,this._loopEnd,"i").toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t)}get loop(){return this._loop.get(this.now())}set loop(t){this._loop.set(t,this.now())}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get swing(){return this._swingAmount}set swing(t){this._swingAmount=t}get swingSubdivision(){return new Fo(this.context,this._swingTicks).toNotation()}set swingSubdivision(t){this._swingTicks=this.toTicks(t)}get position(){const t=this.now(),e=this._clock.getTicksAtTime(t);return new Fo(this.context,e).toBarsBeatsSixteenths()}set position(t){const e=this.toTicks(t);this.ticks=e}get seconds(){return this._clock.seconds}set seconds(t){const e=this.now(),n=this._clock.frequency.timeToTicks(t,e);this.ticks=n}get progress(){if(this.loop){const t=this.now();return(this._clock.getTicksAtTime(t)-this._loopStart)/(this._loopEnd-this._loopStart)}return 0}get ticks(){return this._clock.ticks}set ticks(t){if(this._clock.ticks!==t){const e=this.now();if("started"===this.state){const n=this._clock.getTicksAtTime(e),s=e+this._clock.frequency.getDurationOfTicks(Math.ceil(n)-n,e);this.emit("stop",s),this._clock.setTicksAtTime(t,s),this.emit("start",s,this._clock.getSecondsAtTime(s))}else this._clock.setTicksAtTime(t,e)}}getTicksAtTime(t){return Math.round(this._clock.getTicksAtTime(t))}getSecondsAtTime(t){return this._clock.getSecondsAtTime(t)}get PPQ(){return this._clock.frequency.multiplier}set PPQ(t){this._clock.frequency.multiplier=t}nextSubdivision(t){if(t=this.toTicks(t),"started"!==this.state)return 0;{const e=this.now(),n=t-this.getTicksAtTime(e)%t;return this._clock.nextTickTime(n,e)}}syncSignal(t,e){if(!e){const n=this.now();if(0!==t.getValueAtTime(n)){const s=1/(60/this.bpm.getValueAtTime(n)/this.PPQ);e=t.getValueAtTime(n)/s}else e=0}const n=new So(e);return this.bpm.connect(n),n.connect(t._param),this._syncedSignals.push({initial:t.value,ratio:n,signal:t}),t.value=0,this}unsyncSignal(t){for(let e=this._syncedSignals.length-1;e>=0;e--){const n=this._syncedSignals[e];n.signal===t&&(n.ratio.dispose(),n.signal.value=n.initial,this._syncedSignals.splice(e,1))}return this}dispose(){return super.dispose(),this._clock.dispose(),Wi(this,"bpm"),this._timeline.dispose(),this._repeatedEvents.dispose(),this}}Li.mixin(zo),Fi(t=>{t.transport=new zo({context:t})}),ji(t=>{t.transport.dispose()});class Go extends bo{constructor(t){super(t),this.input=void 0,this._state=new _o("stopped"),this._synced=!1,this._scheduled=[],this._syncedStart=Qi,this._syncedStop=Qi,this._state.memory=100,this._state.increasing=!0,this._volume=this.output=new Uo({context:this.context,mute:t.mute,volume:t.volume}),this.volume=this._volume.volume,Hi(this,"volume"),this.onstop=t.onstop}static getDefaults(){return Object.assign(bo.getDefaults(),{mute:!1,onstop:Qi,volume:0})}get state(){return this._synced?"started"===this.context.transport.state?this._state.getValueAtTime(this.context.transport.seconds):"stopped":this._state.getValueAtTime(this.now())}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}_clampToCurrentTime(t){return this._synced?t:Math.max(t,this.context.currentTime)}start(t,e,n){let s=ei(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(s=this._clampToCurrentTime(s),this._synced||"started"!==this._state.getValueAtTime(s))if(this.log("start",s),this._state.setStateAtTime("started",s),this._synced){const t=this._state.get(s);t&&(t.offset=this.toSeconds(Ei(e,0)),t.duration=n?this.toSeconds(n):void 0);const i=this.context.transport.schedule(t=>{this._start(t,e,n)},s);this._scheduled.push(i),"started"===this.context.transport.state&&this.context.transport.getSecondsAtTime(this.immediate())>s&&this._syncedStart(this.now(),this.context.transport.seconds)}else Ks(this.context),this._start(s,e,n);else Gs(Ri(s,this._state.get(s).time),"Start time must be strictly greater than previous start time"),this._state.cancel(s),this._state.setStateAtTime("started",s),this.log("restart",s),this.restart(s,e,n);return this}stop(t){let e=ei(t)&&this._synced?this.context.transport.seconds:this.toSeconds(t);if(e=this._clampToCurrentTime(e),"started"===this._state.getValueAtTime(e)||ni(this._state.getNextState("started",e))){if(this.log("stop",e),this._synced){const t=this.context.transport.schedule(this._stop.bind(this),e);this._scheduled.push(t)}else this._stop(e);this._state.cancel(e),this._state.setStateAtTime("stopped",e)}return this}restart(t,e,n){return t=this.toSeconds(t),"started"===this._state.getValueAtTime(t)&&(this._state.cancel(t),this._restart(t,e,n)),this}sync(){return this._synced||(this._synced=!0,this._syncedStart=(t,e)=>{if(e>0){const n=this._state.get(e);if(n&&"started"===n.state&&n.time!==e){const s=e-this.toSeconds(n.time);let i;n.duration&&(i=this.toSeconds(n.duration)-s),this._start(t,this.toSeconds(n.offset)+s,i)}}},this._syncedStop=t=>{const e=this.context.transport.getSecondsAtTime(Math.max(t-this.sampleTime,0));"started"===this._state.getValueAtTime(e)&&this._stop(t)},this.context.transport.on("start",this._syncedStart),this.context.transport.on("loopStart",this._syncedStart),this.context.transport.on("stop",this._syncedStop),this.context.transport.on("pause",this._syncedStop),this.context.transport.on("loopEnd",this._syncedStop)),this}unsync(){return this._synced&&(this.context.transport.off("stop",this._syncedStop),this.context.transport.off("pause",this._syncedStop),this.context.transport.off("loopEnd",this._syncedStop),this.context.transport.off("start",this._syncedStart),this.context.transport.off("loopStart",this._syncedStart)),this._synced=!1,this._scheduled.forEach(t=>this.context.transport.clear(t)),this._scheduled=[],this._state.cancel(0),this._stop(0),this}dispose(){return super.dispose(),this.onstop=Qi,this.unsync(),this._volume.dispose(),this._state.dispose(),this}}class Yo extends Co{constructor(){super(ki(Yo.getDefaults(),arguments,["url","onload"])),this.name="ToneBufferSource",this._source=this.context.createBufferSource(),this._internalChannels=[this._source],this._sourceStarted=!1,this._sourceStopped=!1;const t=ki(Yo.getDefaults(),arguments,["url","onload"]);wo(this._source,this._gainNode),this._source.onended=()=>this._stopSource(),this.playbackRate=new vo({context:this.context,param:this._source.playbackRate,units:"positive",value:t.playbackRate}),this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this._buffer=new Xi(t.url,t.onload,t.onerror),this._internalChannels.push(this._source)}static getDefaults(){return Object.assign(Co.getDefaults(),{url:new Xi,loop:!1,loopEnd:0,loopStart:0,onload:Qi,onerror:Qi,playbackRate:1})}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t}get curve(){return this._curve}set curve(t){this._curve=t}start(t,e,n,s=1){Gs(this.buffer.loaded,"buffer is either not set or not loaded");const i=this.toSeconds(t);this._startGain(i,s),e=this.loop?Ei(e,this.loopStart):Ei(e,0);let o=Math.max(this.toSeconds(e),0);if(this.loop){const t=this.toSeconds(this.loopEnd)||this.buffer.duration,e=this.toSeconds(this.loopStart),n=t-e;Ai(o,t)&&(o=(o-e)%n+e),Ni(o,this.buffer.duration)&&(o=0)}if(this._source.buffer=this.buffer.get(),this._source.loopEnd=this.toSeconds(this.loopEnd)||this.buffer.duration,Oi(o,this.buffer.duration)&&(this._sourceStarted=!0,this._source.start(i,o)),ni(n)){let t=this.toSeconds(n);t=Math.max(t,0),this.stop(i+t)}return this}_stopSource(t){if(!this._sourceStopped&&this._sourceStarted){this._sourceStopped=!0;try{this._source.stop(this.toSeconds(t))}catch(t){console.error("ToneBufferSource _stopSource error",t)}this._onended()}}get loopStart(){return this._source.loopStart}set loopStart(t){this._source.loopStart=this.toSeconds(t)}get loopEnd(){return this._source.loopEnd}set loopEnd(t){this._source.loopEnd=this.toSeconds(t)}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._source.loop}set loop(t){this._source.loop=t,this._sourceStarted&&this.cancelStop()}dispose(){return super.dispose(),this._source.onended=null,this._source.disconnect(),this._buffer.dispose(),this.playbackRate.dispose(),this}}class Ko extends Go{constructor(){super(ki(Ko.getDefaults(),arguments,["type"])),this.name="Noise",this._source=null;const t=ki(Ko.getDefaults(),arguments,["type"]);this._playbackRate=t.playbackRate,this.type=t.type,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Go.getDefaults(),{fadeIn:0,fadeOut:0,playbackRate:1,type:"white"})}get type(){return this._type}set type(t){if(Gs(t in Jo,"Noise: invalid type: "+t),this._type!==t&&(this._type=t,"started"===this.state)){const t=this.now();this._stop(t),this._start(t)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._source&&(this._source.playbackRate.value=t)}_start(t){const e=Jo[this._type];this._source=new Yo({url:e,context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,loop:!0,onended:()=>this.onstop(this),playbackRate:this._playbackRate}).connect(this.output),this._source.start(this.toSeconds(t),Math.random()*(e.duration-.001))}_stop(t){this._source&&(this._source.stop(this.toSeconds(t)),this._source=null)}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._source&&(this._source.fadeIn=this._fadeIn)}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._source&&(this._source.fadeOut=this._fadeOut)}_restart(t){this._stop(t),this._start(t)}dispose(){return super.dispose(),this._source&&this._source.disconnect(),this}}const Zo={brown:null,pink:null,white:null},Jo={get brown(){if(!Zo.brown){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);t[e]=n;let s=0;for(let t=0;t<220500;t++){const e=2*Math.random()-1;n[t]=(s+.02*e)/1.02,s=n[t],n[t]*=3.5}}Zo.brown=(new Xi).fromArray(t)}return Zo.brown},get pink(){if(!Zo.pink){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);let s,i,o,r,a,l,c;t[e]=n,s=i=o=r=a=l=c=0;for(let t=0;t<220500;t++){const e=2*Math.random()-1;s=.99886*s+.0555179*e,i=.99332*i+.0750759*e,o=.969*o+.153852*e,r=.8665*r+.3104856*e,a=.55*a+.5329522*e,l=-.7616*l-.016898*e,n[t]=s+i+o+r+a+l+c+.5362*e,n[t]*=.11,c=.115926*e}}Zo.pink=(new Xi).fromArray(t)}return Zo.pink},get white(){if(!Zo.white){const t=[];for(let e=0;e<2;e++){const n=new Float32Array(220500);t[e]=n;for(let t=0;t<220500;t++)n[t]=2*Math.random()-1}Zo.white=(new Xi).fromArray(t)}return Zo.white}};class $o extends bo{constructor(){super(ki($o.getDefaults(),arguments,["volume"])),this.name="UserMedia";const t=ki($o.getDefaults(),arguments,["volume"]);this._volume=this.output=new Uo({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Hi(this,"volume"),this.mute=t.mute}static getDefaults(){return Object.assign(bo.getDefaults(),{mute:!1,volume:0})}open(t){return gi(this,void 0,void 0,(function*(){Gs($o.supported,"UserMedia is not supported"),"started"===this.state&&this.close();const e=yield $o.enumerateDevices();ii(t)?this._device=e[t]:(this._device=e.find(e=>e.label===t||e.deviceId===t),!this._device&&e.length>0&&(this._device=e[0]),Gs(ni(this._device),"No matching device "+t));const n={audio:{echoCancellation:!1,sampleRate:this.context.sampleRate,noiseSuppression:!1,mozNoiseSuppression:!1}};this._device&&(n.audio.deviceId=this._device.deviceId);const s=yield navigator.mediaDevices.getUserMedia(n);if(!this._stream){this._stream=s;const t=this.context.createMediaStreamSource(s);wo(t,this.output),this._mediaStream=t}return this}))}close(){return this._stream&&this._mediaStream&&(this._stream.getAudioTracks().forEach(t=>{t.stop()}),this._stream=void 0,this._mediaStream.disconnect(),this._mediaStream=void 0),this._device=void 0,this}static enumerateDevices(){return gi(this,void 0,void 0,(function*(){return(yield navigator.mediaDevices.enumerateDevices()).filter(t=>"audioinput"===t.kind)}))}get state(){return this._stream&&this._stream.active?"started":"stopped"}get deviceId(){return this._device?this._device.deviceId:void 0}get groupId(){return this._device?this._device.groupId:void 0}get label(){return this._device?this._device.label:void 0}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this.close(),this._volume.dispose(),this.volume.dispose(),this}static get supported(){return ni(navigator.mediaDevices)&&ni(navigator.mediaDevices.getUserMedia)}}function tr(t,e){return gi(this,void 0,void 0,(function*(){const n=e/t.context.sampleRate,s=new zi(1,n,t.context.sampleRate);return new t.constructor(Object.assign(t.get(),{frequency:2/n,detune:0,context:s})).toDestination().start(0),(yield s.render()).getChannelData(0)}))}class er extends Co{constructor(){super(ki(er.getDefaults(),arguments,["frequency","type"])),this.name="ToneOscillatorNode",this._oscillator=this.context.createOscillator(),this._internalChannels=[this._oscillator];const t=ki(er.getDefaults(),arguments,["frequency","type"]);wo(this._oscillator,this._gainNode),this.type=t.type,this.frequency=new vo({context:this.context,param:this._oscillator.frequency,units:"frequency",value:t.frequency}),this.detune=new vo({context:this.context,param:this._oscillator.detune,units:"cents",value:t.detune}),Hi(this,["frequency","detune"])}static getDefaults(){return Object.assign(Co.getDefaults(),{detune:0,frequency:440,type:"sine"})}start(t){const e=this.toSeconds(t);return this.log("start",e),this._startGain(e),this._oscillator.start(e),this}_stopSource(t){try{this._oscillator.stop(t)}catch(t){console.warn("ToneOscillatorNode: _oscillator already stopped")}}setPeriodicWave(t){return this._oscillator.setPeriodicWave(t),this}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t}dispose(){return super.dispose(),"started"===this.state&&this.stop(),this._oscillator.disconnect(),this.frequency.dispose(),this.detune.dispose(),this}}class nr extends Go{constructor(){super(ki(nr.getDefaults(),arguments,["frequency","type"])),this.name="Oscillator",this._oscillator=null;const t=ki(nr.getDefaults(),arguments,["frequency","type"]);this.frequency=new Eo({context:this.context,units:"frequency",value:t.frequency}),Hi(this,"frequency"),this.detune=new Eo({context:this.context,units:"cents",value:t.detune}),Hi(this,"detune"),this._partials=t.partials,this._partialCount=t.partialCount,this._type=t.type,t.partialCount&&"custom"!==t.type&&(this._type=this.baseType+t.partialCount.toString()),this.phase=t.phase}static getDefaults(){return Object.assign(Go.getDefaults(),{detune:0,frequency:440,partialCount:0,partials:[],phase:0,type:"sine"})}_start(t){const e=this.toSeconds(t),n=new er({context:this.context,onended:()=>this.onstop(this)});this._oscillator=n,this._wave?this._oscillator.setPeriodicWave(this._wave):this._oscillator.type=this._type,this._oscillator.connect(this.output),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.start(e)}_stop(t){const e=this.toSeconds(t);this._oscillator&&this._oscillator.stop(e)}_restart(t){const e=this.toSeconds(t);return this.log("restart",e),this._oscillator&&this._oscillator.cancelStop(),this._state.cancel(e),this}syncFrequency(){return this.context.transport.syncSignal(this.frequency),this}unsyncFrequency(){return this.context.transport.unsyncSignal(this.frequency),this}_getCachedPeriodicWave(){if("custom"===this._type)return nr._periodicWaveCache.find(t=>{return t.phase===this._phase&&(e=t.partials,n=this._partials,e.length===n.length&&e.every((t,e)=>n[e]===t));var e,n});{const t=nr._periodicWaveCache.find(t=>t.type===this._type&&t.phase===this._phase);return this._partialCount=t?t.partialCount:this._partialCount,t}}get type(){return this._type}set type(t){this._type=t;const e=-1!==["sine","square","sawtooth","triangle"].indexOf(t);if(0===this._phase&&e)this._wave=void 0,this._partialCount=0,null!==this._oscillator&&(this._oscillator.type=t);else{const e=this._getCachedPeriodicWave();if(ni(e)){const{partials:t,wave:n}=e;this._wave=n,this._partials=t,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave)}else{const[e,n]=this._getRealImaginary(t,this._phase),s=this.context.createPeriodicWave(e,n);this._wave=s,null!==this._oscillator&&this._oscillator.setPeriodicWave(this._wave),nr._periodicWaveCache.push({imag:n,partialCount:this._partialCount,partials:this._partials,phase:this._phase,real:e,type:this._type,wave:this._wave}),nr._periodicWaveCache.length>100&&nr._periodicWaveCache.shift()}}}get baseType(){return this._type.replace(this.partialCount.toString(),"")}set baseType(t){this.partialCount&&"custom"!==this._type&&"custom"!==t?this.type=t+this.partialCount:this.type=t}get partialCount(){return this._partialCount}set partialCount(t){Ys(t,0);let e=this._type;const n=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(this._type);if(n&&(e=n[1]),"custom"!==this._type)this.type=0===t?e:e+t.toString();else{const e=new Float32Array(t);this._partials.forEach((t,n)=>e[n]=t),this._partials=Array.from(e),this.type=this._type}}_getRealImaginary(t,e){let n=2048;const s=new Float32Array(n),i=new Float32Array(n);let o=1;if("custom"===t){if(o=this._partials.length+1,this._partialCount=this._partials.length,n=o,0===this._partials.length)return[s,i]}else{const e=/^(sine|triangle|square|sawtooth)(\d+)$/.exec(t);e?(o=parseInt(e[2],10)+1,this._partialCount=parseInt(e[2],10),t=e[1],o=Math.max(o,2),n=o):this._partialCount=0,this._partials=[]}for(let r=1;r>1&1?-1:1):0,this._partials[r-1]=a;break;case"custom":a=this._partials[r-1];break;default:throw new TypeError("Oscillator: invalid type: "+t)}0!==a?(s[r]=-a*Math.sin(e*r),i[r]=a*Math.cos(e*r)):(s[r]=0,i[r]=0)}return[s,i]}_inverseFFT(t,e,n){let s=0;const i=t.length;for(let o=0;oe.includes(t)),"oversampling must be either 'none', '2x', or '4x'"),this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.disconnect(),this}}class or extends sr{constructor(){super(...arguments),this.name="AudioToGain",this._norm=new ir({context:this.context,mapping:t=>(t+1)/2}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class rr extends Eo{constructor(){super(Object.assign(ki(rr.getDefaults(),arguments,["value"]))),this.name="Multiply",this.override=!1;const t=ki(rr.getDefaults(),arguments,["value"]);this._mult=this.input=this.output=new So({context:this.context,minValue:t.minValue,maxValue:t.maxValue}),this.factor=this._param=this._mult.gain,this.factor.setValueAtTime(t.value,0)}static getDefaults(){return Object.assign(Eo.getDefaults(),{value:0})}dispose(){return super.dispose(),this._mult.dispose(),this}}class ar extends Go{constructor(){super(ki(ar.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="AMOscillator",this._modulationScale=new or({context:this.context}),this._modulationNode=new So({context:this.context});const t=ki(ar.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new nr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.frequency=this._carrier.frequency,this.detune=this._carrier.detune,this._modulator=new nr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new rr({context:this.context,units:"positive",value:t.harmonicity}),this.frequency.chain(this.harmonicity,this._modulator.frequency),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output),Hi(this,["frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(nr.getDefaults(),{harmonicity:1,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){this._modulator.restart(t),this._carrier.restart(t)}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this._modulationScale.dispose(),this}}class lr extends Go{constructor(){super(ki(lr.getDefaults(),arguments,["frequency","type","modulationType"])),this.name="FMOscillator",this._modulationNode=new So({context:this.context,gain:0});const t=ki(lr.getDefaults(),arguments,["frequency","type","modulationType"]);this._carrier=new nr({context:this.context,detune:t.detune,frequency:0,onstop:()=>this.onstop(this),phase:t.phase,type:t.type}),this.detune=this._carrier.detune,this.frequency=new Eo({context:this.context,units:"frequency",value:t.frequency}),this._modulator=new nr({context:this.context,phase:t.phase,type:t.modulationType}),this.harmonicity=new rr({context:this.context,units:"positive",value:t.harmonicity}),this.modulationIndex=new rr({context:this.context,units:"positive",value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output),this.detune.connect(this._modulator.detune),Hi(this,["modulationIndex","frequency","detune","harmonicity"])}static getDefaults(){return Object.assign(nr.getDefaults(),{harmonicity:1,modulationIndex:2,modulationType:"square"})}_start(t){this._modulator.start(t),this._carrier.start(t)}_stop(t){this._modulator.stop(t),this._carrier.stop(t)}_restart(t){return this._modulator.restart(t),this._carrier.restart(t),this}get type(){return this._carrier.type}set type(t){this._carrier.type=t}get baseType(){return this._carrier.baseType}set baseType(t){this._carrier.baseType=t}get partialCount(){return this._carrier.partialCount}set partialCount(t){this._carrier.partialCount=t}get modulationType(){return this._modulator.type}set modulationType(t){this._modulator.type=t}get phase(){return this._carrier.phase}set phase(t){this._carrier.phase=t,this._modulator.phase=t}get partials(){return this._carrier.partials}set partials(t){this._carrier.partials=t}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.harmonicity.dispose(),this._carrier.dispose(),this._modulator.dispose(),this._modulationNode.dispose(),this.modulationIndex.dispose(),this}}class cr extends Go{constructor(){super(ki(cr.getDefaults(),arguments,["frequency","width"])),this.name="PulseOscillator",this._widthGate=new So({context:this.context,gain:0}),this._thresh=new ir({context:this.context,mapping:t=>t<=0?-1:1});const t=ki(cr.getDefaults(),arguments,["frequency","width"]);this.width=new Eo({context:this.context,units:"audioRange",value:t.width}),this._triangle=new nr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase,type:"triangle"}),this.frequency=this._triangle.frequency,this.detune=this._triangle.detune,this._triangle.chain(this._thresh,this.output),this.width.chain(this._widthGate,this._thresh),Hi(this,["width","frequency","detune"])}static getDefaults(){return Object.assign(Go.getDefaults(),{detune:0,frequency:440,phase:0,type:"pulse",width:.2})}_start(t){t=this.toSeconds(t),this._triangle.start(t),this._widthGate.gain.setValueAtTime(1,t)}_stop(t){t=this.toSeconds(t),this._triangle.stop(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(0,t)}_restart(t){this._triangle.restart(t),this._widthGate.gain.cancelScheduledValues(t),this._widthGate.gain.setValueAtTime(1,t)}get phase(){return this._triangle.phase}set phase(t){this._triangle.phase=t}get type(){return"pulse"}get baseType(){return"pulse"}get partials(){return[]}get partialCount(){return 0}set carrierType(t){this._triangle.type=t}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this._triangle.dispose(),this.width.dispose(),this._widthGate.dispose(),this._thresh.dispose(),this}}class hr extends Go{constructor(){super(ki(hr.getDefaults(),arguments,["frequency","type","spread"])),this.name="FatOscillator",this._oscillators=[];const t=ki(hr.getDefaults(),arguments,["frequency","type","spread"]);this.frequency=new Eo({context:this.context,units:"frequency",value:t.frequency}),this.detune=new Eo({context:this.context,units:"cents",value:t.detune}),this._spread=t.spread,this._type=t.type,this._phase=t.phase,this._partials=t.partials,this._partialCount=t.partialCount,this.count=t.count,Hi(this,["frequency","detune"])}static getDefaults(){return Object.assign(nr.getDefaults(),{count:3,spread:20,type:"sawtooth"})}_start(t){t=this.toSeconds(t),this._forEach(e=>e.start(t))}_stop(t){t=this.toSeconds(t),this._forEach(e=>e.stop(t))}_restart(t){this._forEach(e=>e.restart(t))}_forEach(t){for(let e=0;ee.type=t)}get spread(){return this._spread}set spread(t){if(this._spread=t,this._oscillators.length>1){const e=-t/2,n=t/(this._oscillators.length-1);this._forEach((t,s)=>t.detune.value=e+n*s)}}get count(){return this._oscillators.length}set count(t){if(Ys(t,1),this._oscillators.length!==t){this._forEach(t=>t.dispose()),this._oscillators=[];for(let e=0;ethis.onstop(this):Qi});"custom"===this.type&&(n.partials=this._partials),this.frequency.connect(n.frequency),this.detune.connect(n.detune),n.detune.overridden=!1,n.connect(this.output),this._oscillators[e]=n}this.spread=this._spread,"started"===this.state&&this._forEach(t=>t.start())}}get phase(){return this._phase}set phase(t){this._phase=t,this._forEach((t,e)=>t.phase=this._phase+e/this.count*360)}get baseType(){return this._oscillators[0].baseType}set baseType(t){this._forEach(e=>e.baseType=t),this._type=this._oscillators[0].type}get partials(){return this._oscillators[0].partials}set partials(t){this._partials=t,this._partialCount=this._partials.length,t.length&&(this._type="custom",this._forEach(e=>e.partials=t))}get partialCount(){return this._oscillators[0].partialCount}set partialCount(t){this._partialCount=t,this._forEach(e=>e.partialCount=t),this._type=this._oscillators[0].type}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this.frequency.dispose(),this.detune.dispose(),this._forEach(t=>t.dispose()),this}}class ur extends Go{constructor(){super(ki(ur.getDefaults(),arguments,["frequency","modulationFrequency"])),this.name="PWMOscillator",this.sourceType="pwm",this._scale=new rr({context:this.context,value:2});const t=ki(ur.getDefaults(),arguments,["frequency","modulationFrequency"]);this._pulse=new cr({context:this.context,frequency:t.modulationFrequency}),this._pulse.carrierType="sine",this.modulationFrequency=this._pulse.frequency,this._modulator=new nr({context:this.context,detune:t.detune,frequency:t.frequency,onstop:()=>this.onstop(this),phase:t.phase}),this.frequency=this._modulator.frequency,this.detune=this._modulator.detune,this._modulator.chain(this._scale,this._pulse.width),this._pulse.connect(this.output),Hi(this,["modulationFrequency","frequency","detune"])}static getDefaults(){return Object.assign(Go.getDefaults(),{detune:0,frequency:440,modulationFrequency:.4,phase:0,type:"pwm"})}_start(t){t=this.toSeconds(t),this._modulator.start(t),this._pulse.start(t)}_stop(t){t=this.toSeconds(t),this._modulator.stop(t),this._pulse.stop(t)}_restart(t){this._modulator.restart(t),this._pulse.restart(t)}get type(){return"pwm"}get baseType(){return"pwm"}get partials(){return[]}get partialCount(){return 0}get phase(){return this._modulator.phase}set phase(t){this._modulator.phase=t}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this._pulse.dispose(),this._scale.dispose(),this._modulator.dispose(),this}}const pr={am:ar,fat:hr,fm:lr,oscillator:nr,pulse:cr,pwm:ur};class dr extends Go{constructor(){super(ki(dr.getDefaults(),arguments,["frequency","type"])),this.name="OmniOscillator";const t=ki(dr.getDefaults(),arguments,["frequency","type"]);this.frequency=new Eo({context:this.context,units:"frequency",value:t.frequency}),this.detune=new Eo({context:this.context,units:"cents",value:t.detune}),Hi(this,["frequency","detune"]),this.set(t)}static getDefaults(){return Object.assign(nr.getDefaults(),lr.getDefaults(),ar.getDefaults(),hr.getDefaults(),cr.getDefaults(),ur.getDefaults())}_start(t){this._oscillator.start(t)}_stop(t){this._oscillator.stop(t)}_restart(t){return this._oscillator.restart(t),this}get type(){let t="";return["am","fm","fat"].some(t=>this._sourceType===t)&&(t=this._sourceType),t+this._oscillator.type}set type(t){"fm"===t.substr(0,2)?(this._createNewOscillator("fm"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"am"===t.substr(0,2)?(this._createNewOscillator("am"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(2)):"fat"===t.substr(0,3)?(this._createNewOscillator("fat"),this._oscillator=this._oscillator,this._oscillator.type=t.substr(3)):"pwm"===t?(this._createNewOscillator("pwm"),this._oscillator=this._oscillator):"pulse"===t?this._createNewOscillator("pulse"):(this._createNewOscillator("oscillator"),this._oscillator=this._oscillator,this._oscillator.type=t)}get partials(){return this._oscillator.partials}set partials(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partials=t)}get partialCount(){return this._oscillator.partialCount}set partialCount(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||(this._oscillator.partialCount=t)}set(t){return Reflect.has(t,"type")&&t.type&&(this.type=t.type),super.set(t),this}_createNewOscillator(t){if(t!==this._sourceType){this._sourceType=t;const e=pr[t],n=this.now();if(this._oscillator){const t=this._oscillator;t.stop(n),this.context.setTimeout(()=>t.dispose(),this.blockTime)}this._oscillator=new e({context:this.context}),this.frequency.connect(this._oscillator.frequency),this.detune.connect(this._oscillator.detune),this._oscillator.connect(this.output),this._oscillator.onstop=()=>this.onstop(this),"started"===this.state&&this._oscillator.start(n)}}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t}get sourceType(){return this._sourceType}set sourceType(t){let e="sine";"pwm"!==this._oscillator.type&&"pulse"!==this._oscillator.type&&(e=this._oscillator.type),"fm"===t?this.type="fm"+e:"am"===t?this.type="am"+e:"fat"===t?this.type="fat"+e:"oscillator"===t?this.type=e:"pulse"===t?this.type="pulse":"pwm"===t&&(this.type="pwm")}_getOscType(t,e){return t instanceof pr[e]}get baseType(){return this._oscillator.baseType}set baseType(t){this._getOscType(this._oscillator,"pulse")||this._getOscType(this._oscillator,"pwm")||"pulse"===t||"pwm"===t||(this._oscillator.baseType=t)}get width(){return this._getOscType(this._oscillator,"pulse")?this._oscillator.width:void 0}get count(){return this._getOscType(this._oscillator,"fat")?this._oscillator.count:void 0}set count(t){this._getOscType(this._oscillator,"fat")&&ii(t)&&(this._oscillator.count=t)}get spread(){return this._getOscType(this._oscillator,"fat")?this._oscillator.spread:void 0}set spread(t){this._getOscType(this._oscillator,"fat")&&ii(t)&&(this._oscillator.spread=t)}get modulationType(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.modulationType:void 0}set modulationType(t){(this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am"))&&li(t)&&(this._oscillator.modulationType=t)}get modulationIndex(){return this._getOscType(this._oscillator,"fm")?this._oscillator.modulationIndex:void 0}get harmonicity(){return this._getOscType(this._oscillator,"fm")||this._getOscType(this._oscillator,"am")?this._oscillator.harmonicity:void 0}get modulationFrequency(){return this._getOscType(this._oscillator,"pwm")?this._oscillator.modulationFrequency:void 0}asArray(t=1024){return gi(this,void 0,void 0,(function*(){return tr(this,t)}))}dispose(){return super.dispose(),this.detune.dispose(),this.frequency.dispose(),this._oscillator.dispose(),this}}class mr extends Eo{constructor(){super(Object.assign(ki(mr.getDefaults(),arguments,["value"]))),this.override=!1,this.name="Add",this._sum=new So({context:this.context}),this.input=this._sum,this.output=this._sum,this.addend=this._param,yo(this._constantSource,this._sum)}static getDefaults(){return Object.assign(Eo.getDefaults(),{value:0})}dispose(){return super.dispose(),this._sum.dispose(),this}}class fr extends sr{constructor(){super(Object.assign(ki(fr.getDefaults(),arguments,["min","max"]))),this.name="Scale";const t=ki(fr.getDefaults(),arguments,["min","max"]);this._mult=this.input=new rr({context:this.context,value:t.max-t.min}),this._add=this.output=new mr({context:this.context,value:t.min}),this._min=t.min,this._max=t.max,this.input.connect(this.output)}static getDefaults(){return Object.assign(sr.getDefaults(),{max:1,min:0})}get min(){return this._min}set min(t){this._min=t,this._setRange()}get max(){return this._max}set max(t){this._max=t,this._setRange()}_setRange(){this._add.value=this._min,this._mult.value=this._max-this._min}dispose(){return super.dispose(),this._add.dispose(),this._mult.dispose(),this}}class gr extends sr{constructor(){super(Object.assign(ki(gr.getDefaults(),arguments))),this.name="Zero",this._gain=new So({context:this.context}),this.output=this._gain,this.input=void 0,wo(this.context.getConstant(0),this._gain)}dispose(){return super.dispose(),xo(this.context.getConstant(0),this._gain),this}}class _r extends bo{constructor(){super(ki(_r.getDefaults(),arguments,["frequency","min","max"])),this.name="LFO",this._stoppedValue=0,this._units="number",this.convert=!0,this._fromType=vo.prototype._fromType,this._toType=vo.prototype._toType,this._is=vo.prototype._is,this._clampValue=vo.prototype._clampValue;const t=ki(_r.getDefaults(),arguments,["frequency","min","max"]);this._oscillator=new nr({context:this.context,frequency:t.frequency,type:t.type}),this.frequency=this._oscillator.frequency,this._amplitudeGain=new So({context:this.context,gain:t.amplitude,units:"normalRange"}),this.amplitude=this._amplitudeGain.gain,this._stoppedSignal=new Eo({context:this.context,units:"audioRange",value:0}),this._zeros=new gr({context:this.context}),this._a2g=new or({context:this.context}),this._scaler=this.output=new fr({context:this.context,max:t.max,min:t.min}),this.units=t.units,this.min=t.min,this.max=t.max,this._oscillator.chain(this._amplitudeGain,this._a2g,this._scaler),this._zeros.connect(this._a2g),this._stoppedSignal.connect(this._a2g),Hi(this,["amplitude","frequency"]),this.phase=t.phase}static getDefaults(){return Object.assign(bo.getDefaults(),{amplitude:1,frequency:"4n",max:1,min:0,phase:0,type:"sine",units:"number"})}start(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(0,t),this._oscillator.start(t),this}stop(t){return t=this.toSeconds(t),this._stoppedSignal.setValueAtTime(this._stoppedValue,t),this._oscillator.stop(t),this}sync(){return this._oscillator.sync(),this._oscillator.syncFrequency(),this}unsync(){return this._oscillator.unsync(),this._oscillator.unsyncFrequency(),this}get min(){return this._toType(this._scaler.min)}set min(t){t=this._fromType(t),this._scaler.min=t}get max(){return this._toType(this._scaler.max)}set max(t){t=this._fromType(t),this._scaler.max=t}get type(){return this._oscillator.type}set type(t){this._oscillator.type=t,this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get phase(){return this._oscillator.phase}set phase(t){this._oscillator.phase=t,this._stoppedValue=this._oscillator.getInitialValue(),this._stoppedSignal.value=this._stoppedValue}get units(){return this._units}set units(t){const e=this.min,n=this.max;this._units=t,this.min=e,this.max=n}get state(){return this._oscillator.state}connect(t,e,n){return(t instanceof vo||t instanceof Eo)&&(this.convert=t.convert,this.units=t.units),Po(this,t,e,n),this}dispose(){return super.dispose(),this._oscillator.dispose(),this._stoppedSignal.dispose(),this._zeros.dispose(),this._scaler.dispose(),this._a2g.dispose(),this._amplitudeGain.dispose(),this.amplitude.dispose(),this}}function vr(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){Ys(s,t,e),n.set(this,s)}})}}function br(t,e=1/0){const n=new WeakMap;return function(s,i){Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,get:function(){return n.get(this)},set:function(s){Ys(this.toSeconds(s),t,e),n.set(this,s)}})}}class yr extends Go{constructor(){super(ki(yr.getDefaults(),arguments,["url","onload"])),this.name="Player",this._activeSources=new Set;const t=ki(yr.getDefaults(),arguments,["url","onload"]);this._buffer=new Xi({onload:this._onload.bind(this,t.onload),onerror:t.onerror,reverse:t.reverse,url:t.url}),this.autostart=t.autostart,this._loop=t.loop,this._loopStart=t.loopStart,this._loopEnd=t.loopEnd,this._playbackRate=t.playbackRate,this.fadeIn=t.fadeIn,this.fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Go.getDefaults(),{autostart:!1,fadeIn:0,fadeOut:0,loop:!1,loopEnd:0,loopStart:0,onload:Qi,onerror:Qi,playbackRate:1,reverse:!1})}load(t){return gi(this,void 0,void 0,(function*(){return yield this._buffer.load(t),this._onload(),this}))}_onload(t=Qi){t(),this.autostart&&this.start()}_onSourceEnd(t){this.onstop(this),this._activeSources.delete(t),0!==this._activeSources.size||this._synced||"started"!==this._state.getValueAtTime(this.now())||(this._state.cancel(this.now()),this._state.setStateAtTime("stopped",this.now()))}start(t,e,n){return super.start(t,e,n),this}_start(t,e,n){e=this._loop?Ei(e,this._loopStart):Ei(e,0);const s=this.toSeconds(e),i=n;n=Ei(n,Math.max(this._buffer.duration-s,0));let o=this.toSeconds(n);o/=this._playbackRate,t=this.toSeconds(t);const r=new Yo({url:this._buffer,context:this.context,fadeIn:this.fadeIn,fadeOut:this.fadeOut,loop:this._loop,loopEnd:this._loopEnd,loopStart:this._loopStart,onended:this._onSourceEnd.bind(this),playbackRate:this._playbackRate}).connect(this.output);this._loop||this._synced||(this._state.cancel(t+o),this._state.setStateAtTime("stopped",t+o,{implicitEnd:!0})),this._activeSources.add(r),this._loop&&ei(i)?r.start(t,s):r.start(t,s,o-this.toSeconds(this.fadeOut))}_stop(t){const e=this.toSeconds(t);this._activeSources.forEach(t=>t.stop(e))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){this._stop(t),this._start(t,e,n)}seek(t,e){const n=this.toSeconds(e);if("started"===this._state.getValueAtTime(n)){const e=this.toSeconds(t);this._stop(n),this._start(n,e)}return this}setLoopPoints(t,e){return this.loopStart=t,this.loopEnd=e,this}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this.buffer.loaded&&Ys(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopStart=t})}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this.buffer.loaded&&Ys(this.toSeconds(t),0,this.buffer.duration),this._activeSources.forEach(e=>{e.loopEnd=t})}get buffer(){return this._buffer}set buffer(t){this._buffer.set(t)}get loop(){return this._loop}set loop(t){if(this._loop!==t&&(this._loop=t,this._activeSources.forEach(e=>{e.loop=t}),t)){const t=this._state.getNextState("stopped",this.now());t&&this._state.cancel(t.time)}}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t;const e=this.now(),n=this._state.getNextState("stopped",e);n&&n.implicitEnd&&(this._state.cancel(n.time),this._activeSources.forEach(t=>t.cancelStop())),this._activeSources.forEach(n=>{n.playbackRate.setValueAtTime(t,e)})}get reverse(){return this._buffer.reverse}set reverse(t){this._buffer.reverse=t}get loaded(){return this._buffer.loaded}dispose(){return super.dispose(),this._activeSources.forEach(t=>t.dispose()),this._activeSources.clear(),this._buffer.dispose(),this}}fi([br(0)],yr.prototype,"fadeIn",void 0),fi([br(0)],yr.prototype,"fadeOut",void 0);class wr extends bo{constructor(){super(ki(wr.getDefaults(),arguments,["urls","onload"],"urls")),this.name="Players",this.input=void 0,this._players=new Map;const t=ki(wr.getDefaults(),arguments,["urls","onload"],"urls");this._volume=this.output=new Uo({context:this.context,volume:t.volume}),this.volume=this._volume.volume,Hi(this,"volume"),this._buffers=new Do({urls:t.urls,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.mute=t.mute,this._fadeIn=t.fadeIn,this._fadeOut=t.fadeOut}static getDefaults(){return Object.assign(Go.getDefaults(),{baseUrl:"",fadeIn:0,fadeOut:0,mute:!1,onload:Qi,onerror:Qi,urls:{},volume:0})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}get fadeIn(){return this._fadeIn}set fadeIn(t){this._fadeIn=t,this._players.forEach(e=>{e.fadeIn=t})}get fadeOut(){return this._fadeOut}set fadeOut(t){this._fadeOut=t,this._players.forEach(e=>{e.fadeOut=t})}get state(){return Array.from(this._players).some(([t,e])=>"started"===e.state)?"started":"stopped"}has(t){return this._buffers.has(t)}player(t){if(Gs(this.has(t),`No Player with the name ${t} exists on this object`),!this._players.has(t)){const e=new yr({context:this.context,fadeIn:this._fadeIn,fadeOut:this._fadeOut,url:this._buffers.get(t)}).connect(this.output);this._players.set(t,e)}return this._players.get(t)}get loaded(){return this._buffers.loaded}add(t,e,n){return Gs(!this._buffers.has(t),"A buffer with that name already exists on this object"),this._buffers.add(t,e,n),this}stopAll(t){return this._players.forEach(e=>e.stop(t)),this}dispose(){return super.dispose(),this._volume.dispose(),this.volume.dispose(),this._players.forEach(t=>t.dispose()),this._buffers.dispose(),this}}class xr extends Go{constructor(){super(ki(xr.getDefaults(),arguments,["url","onload"])),this.name="GrainPlayer",this._loopStart=0,this._loopEnd=0,this._activeSources=[];const t=ki(xr.getDefaults(),arguments,["url","onload"]);this.buffer=new Xi({onload:t.onload,onerror:t.onerror,reverse:t.reverse,url:t.url}),this._clock=new Ao({context:this.context,callback:this._tick.bind(this),frequency:1/t.grainSize}),this._playbackRate=t.playbackRate,this._grainSize=t.grainSize,this._overlap=t.overlap,this.detune=t.detune,this.overlap=t.overlap,this.loop=t.loop,this.playbackRate=t.playbackRate,this.grainSize=t.grainSize,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.reverse=t.reverse,this._clock.on("stop",this._onstop.bind(this))}static getDefaults(){return Object.assign(Go.getDefaults(),{onload:Qi,onerror:Qi,overlap:.1,grainSize:.2,playbackRate:1,detune:0,loop:!1,loopStart:0,loopEnd:0,reverse:!1})}_start(t,e,n){e=Ei(e,0),e=this.toSeconds(e),t=this.toSeconds(t);const s=1/this._clock.frequency.getValueAtTime(t);this._clock.start(t,e/s),n&&this.stop(t+this.toSeconds(n))}restart(t,e,n){return super.restart(t,e,n),this}_restart(t,e,n){this._stop(t),this._start(t,e,n)}_stop(t){this._clock.stop(t)}_onstop(t){this._activeSources.forEach(e=>{e.fadeOut=0,e.stop(t)}),this.onstop(this)}_tick(t){const e=this._clock.getTicksAtTime(t),n=e*this._grainSize;if(this.log("offset",n),!this.loop&&n>this.buffer.duration)return void this.stop(t);const s=n{const t=this._activeSources.indexOf(i);-1!==t&&this._activeSources.splice(t,1)}}get playbackRate(){return this._playbackRate}set playbackRate(t){Ys(t,.001),this._playbackRate=t,this.grainSize=this._grainSize}get loopStart(){return this._loopStart}set loopStart(t){this.buffer.loaded&&Ys(this.toSeconds(t),0,this.buffer.duration),this._loopStart=this.toSeconds(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this.buffer.loaded&&Ys(this.toSeconds(t),0,this.buffer.duration),this._loopEnd=this.toSeconds(t)}get reverse(){return this.buffer.reverse}set reverse(t){this.buffer.reverse=t}get grainSize(){return this._grainSize}set grainSize(t){this._grainSize=this.toSeconds(t),this._clock.frequency.setValueAtTime(this._playbackRate/this._grainSize,this.now())}get overlap(){return this._overlap}set overlap(t){const e=this.toSeconds(t);Ys(e,0),this._overlap=e}get loaded(){return this.buffer.loaded}dispose(){return super.dispose(),this.buffer.dispose(),this._clock.dispose(),this._activeSources.forEach(t=>t.dispose()),this}}class Sr extends sr{constructor(){super(...arguments),this.name="Abs",this._abs=new ir({context:this.context,mapping:t=>Math.abs(t)<.001?0:Math.abs(t)}),this.input=this._abs,this.output=this._abs}dispose(){return super.dispose(),this._abs.dispose(),this}}class Cr extends sr{constructor(){super(...arguments),this.name="GainToAudio",this._norm=new ir({context:this.context,mapping:t=>2*Math.abs(t)-1}),this.input=this._norm,this.output=this._norm}dispose(){return super.dispose(),this._norm.dispose(),this}}class kr extends sr{constructor(){super(...arguments),this.name="Negate",this._multiply=new rr({context:this.context,value:-1}),this.input=this._multiply,this.output=this._multiply}dispose(){return super.dispose(),this._multiply.dispose(),this}}class Er extends Eo{constructor(){super(Object.assign(ki(Er.getDefaults(),arguments,["value"]))),this.override=!1,this.name="Subtract",this._sum=new So({context:this.context}),this.input=this._sum,this.output=this._sum,this._neg=new kr({context:this.context}),this.subtrahend=this._param,yo(this._constantSource,this._neg,this._sum)}static getDefaults(){return Object.assign(Eo.getDefaults(),{value:0})}dispose(){return super.dispose(),this._neg.dispose(),this._sum.dispose(),this}}class Pr extends sr{constructor(){super(Object.assign(ki(Pr.getDefaults(),arguments))),this.name="GreaterThanZero",this._thresh=this.output=new ir({context:this.context,length:127,mapping:t=>t<=0?0:1}),this._scale=this.input=new rr({context:this.context,value:1e4}),this._scale.connect(this._thresh)}dispose(){return super.dispose(),this._scale.dispose(),this._thresh.dispose(),this}}class Tr extends Eo{constructor(){super(Object.assign(ki(Tr.getDefaults(),arguments,["value"]))),this.name="GreaterThan",this.override=!1;const t=ki(Tr.getDefaults(),arguments,["value"]);this._subtract=this.input=new Er({context:this.context,value:t.value}),this._gtz=this.output=new Pr({context:this.context}),this.comparator=this._param=this._subtract.subtrahend,Hi(this,"comparator"),this._subtract.connect(this._gtz)}static getDefaults(){return Object.assign(Eo.getDefaults(),{value:0})}dispose(){return super.dispose(),this._gtz.dispose(),this._subtract.dispose(),this.comparator.dispose(),this}}class Mr extends sr{constructor(){super(Object.assign(ki(Mr.getDefaults(),arguments,["value"]))),this.name="Pow";const t=ki(Mr.getDefaults(),arguments,["value"]);this._exponentScaler=this.input=this.output=new ir({context:this.context,mapping:this._expFunc(t.value),length:8192}),this._exponent=t.value}static getDefaults(){return Object.assign(sr.getDefaults(),{value:1})}_expFunc(t){return e=>Math.pow(Math.abs(e),t)}get value(){return this._exponent}set value(t){this._exponent=t,this._exponentScaler.setMap(this._expFunc(this._exponent))}dispose(){return super.dispose(),this._exponentScaler.dispose(),this}}class Rr extends fr{constructor(){super(Object.assign(ki(Rr.getDefaults(),arguments,["min","max","exponent"]))),this.name="ScaleExp";const t=ki(Rr.getDefaults(),arguments,["min","max","exponent"]);this.input=this._exp=new Mr({context:this.context,value:t.exponent}),this._exp.connect(this._mult)}static getDefaults(){return Object.assign(fr.getDefaults(),{exponent:1})}get exponent(){return this._exp.value}set exponent(t){this._exp.value=t}dispose(){return super.dispose(),this._exp.dispose(),this}}class Ar extends Eo{constructor(){super(ki(Eo.getDefaults(),arguments,["value","units"])),this.name="SyncedSignal",this.override=!1;const t=ki(Eo.getDefaults(),arguments,["value","units"]);this._lastVal=t.value,this._synced=this.context.transport.scheduleRepeat(this._onTick.bind(this),"1i"),this._syncedCallback=this._anchorValue.bind(this),this.context.transport.on("start",this._syncedCallback),this.context.transport.on("pause",this._syncedCallback),this.context.transport.on("stop",this._syncedCallback),this._constantSource.disconnect(),this._constantSource.stop(0),this._constantSource=this.output=new ko({context:this.context,offset:t.value,units:t.units}).start(0),this.setValueAtTime(t.value,0)}_onTick(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal!==e&&(this._lastVal=e,this._constantSource.offset.setValueAtTime(e,t))}_anchorValue(t){const e=super.getValueAtTime(this.context.transport.seconds);this._lastVal=e,this._constantSource.offset.cancelAndHoldAtTime(t),this._constantSource.offset.setValueAtTime(e,t)}getValueAtTime(t){const e=new mo(this.context,t).toSeconds();return super.getValueAtTime(e)}setValueAtTime(t,e){const n=new mo(this.context,e).toSeconds();return super.setValueAtTime(t,n),this}linearRampToValueAtTime(t,e){const n=new mo(this.context,e).toSeconds();return super.linearRampToValueAtTime(t,n),this}exponentialRampToValueAtTime(t,e){const n=new mo(this.context,e).toSeconds();return super.exponentialRampToValueAtTime(t,n),this}setTargetAtTime(t,e,n){const s=new mo(this.context,e).toSeconds();return super.setTargetAtTime(t,s,n),this}cancelScheduledValues(t){const e=new mo(this.context,t).toSeconds();return super.cancelScheduledValues(e),this}setValueCurveAtTime(t,e,n,s){const i=new mo(this.context,e).toSeconds();return n=this.toSeconds(n),super.setValueCurveAtTime(t,i,n,s),this}cancelAndHoldAtTime(t){const e=new mo(this.context,t).toSeconds();return super.cancelAndHoldAtTime(e),this}setRampPoint(t){const e=new mo(this.context,t).toSeconds();return super.setRampPoint(e),this}exponentialRampTo(t,e,n){const s=new mo(this.context,n).toSeconds();return super.exponentialRampTo(t,e,s),this}linearRampTo(t,e,n){const s=new mo(this.context,n).toSeconds();return super.linearRampTo(t,e,s),this}targetRampTo(t,e,n){const s=new mo(this.context,n).toSeconds();return super.targetRampTo(t,e,s),this}dispose(){return super.dispose(),this.context.transport.clear(this._synced),this.context.transport.off("start",this._syncedCallback),this.context.transport.off("pause",this._syncedCallback),this.context.transport.off("stop",this._syncedCallback),this._constantSource.dispose(),this}}class Or extends bo{constructor(){super(ki(Or.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="Envelope",this._sig=new Eo({context:this.context,value:0}),this.output=this._sig,this.input=void 0;const t=ki(Or.getDefaults(),arguments,["attack","decay","sustain","release"]);this.attack=t.attack,this.decay=t.decay,this.sustain=t.sustain,this.release=t.release,this.attackCurve=t.attackCurve,this.releaseCurve=t.releaseCurve,this.decayCurve=t.decayCurve}static getDefaults(){return Object.assign(bo.getDefaults(),{attack:.01,attackCurve:"linear",decay:.1,decayCurve:"exponential",release:1,releaseCurve:"exponential",sustain:.5})}get value(){return this.getValueAtTime(this.now())}_getCurve(t,e){if(li(t))return t;{let n;for(n in Nr)if(Nr[n][e]===t)return n;return t}}_setCurve(t,e,n){if(li(n)&&Reflect.has(Nr,n)){const s=Nr[n];oi(s)?"_decayCurve"!==t&&(this[t]=s[e]):this[t]=s}else{if(!ai(n)||"_decayCurve"===t)throw new Error("Envelope: invalid curve: "+n);this[t]=n}}get attackCurve(){return this._getCurve(this._attackCurve,"In")}set attackCurve(t){this._setCurve("_attackCurve","In",t)}get releaseCurve(){return this._getCurve(this._releaseCurve,"Out")}set releaseCurve(t){this._setCurve("_releaseCurve","Out",t)}get decayCurve(){return this._decayCurve}set decayCurve(t){Gs(["linear","exponential"].some(e=>e===t),"Invalid envelope curve: "+t),this._decayCurve=t}triggerAttack(t,e=1){this.log("triggerAttack",t,e),t=this.toSeconds(t);let n=this.toSeconds(this.attack);const s=this.toSeconds(this.decay),i=this.getValueAtTime(t);if(i>0&&(n=(1-i)/(1/n)),n0){const n=this.toSeconds(this.release);n{let t,e;const n=[];for(t=0;t<128;t++)n[t]=Math.sin(t/127*(Math.PI/2));const s=[];for(t=0;t<127;t++){e=t/127;const n=Math.sin(e*(2*Math.PI)*6.4-Math.PI/2)+1;s[t]=n/10+.83*e}s[127]=1;const i=[];for(t=0;t<128;t++)i[t]=Math.ceil(t/127*5)/5;const o=[];for(t=0;t<128;t++)e=t/127,o[t]=.5*(1-Math.cos(Math.PI*e));const r=[];for(t=0;t<128;t++){e=t/127;const n=4*Math.pow(e,3)+.2,s=Math.cos(n*Math.PI*2*e);r[t]=Math.abs(s*(1-e))}function a(t){const e=new Array(t.length);for(let n=0;n{const s=t[e],i=this.context.transport.schedule(s=>{t[e]=s,n.apply(this,t)},s);this._scheduledEvents.push(i)}}unsync(){return this._scheduledEvents.forEach(t=>this.context.transport.clear(t)),this._scheduledEvents=[],this._synced&&(this._synced=!1,this.triggerAttack=this._original_triggerAttack,this.triggerRelease=this._original_triggerRelease),this}triggerAttackRelease(t,e,n,s){const i=this.toSeconds(n),o=this.toSeconds(e);return this.triggerAttack(t,i,s),this.triggerRelease(i+o),this}dispose(){return super.dispose(),this._volume.dispose(),this.unsync(),this._scheduledEvents=[],this}}class Br extends Dr{constructor(){super(ki(Br.getDefaults(),arguments));const t=ki(Br.getDefaults(),arguments);this.portamento=t.portamento,this.onsilence=t.onsilence}static getDefaults(){return Object.assign(Dr.getDefaults(),{detune:0,onsilence:Qi,portamento:0})}triggerAttack(t,e,n=1){this.log("triggerAttack",t,e,n);const s=this.toSeconds(e);return this._triggerEnvelopeAttack(s,n),this.setNote(t,s),this}triggerRelease(t){this.log("triggerRelease",t);const e=this.toSeconds(t);return this._triggerEnvelopeRelease(e),this}setNote(t,e){const n=this.toSeconds(e),s=t instanceof co?t.toFrequency():t;if(this.portamento>0&&this.getLevelAtTime(n)>.05){const t=this.toSeconds(this.portamento);this.frequency.exponentialRampTo(s,t,n)}else this.frequency.setValueAtTime(s,n);return this}}fi([br(0)],Br.prototype,"portamento",void 0);class Ir extends Or{constructor(){super(ki(Ir.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="AmplitudeEnvelope",this._gainNode=new So({context:this.context,gain:0}),this.output=this._gainNode,this.input=this._gainNode,this._sig.connect(this._gainNode.gain),this.output=this._gainNode,this.input=this._gainNode}dispose(){return super.dispose(),this._gainNode.dispose(),this}}class Fr extends Br{constructor(){super(ki(Fr.getDefaults(),arguments)),this.name="Synth";const t=ki(Fr.getDefaults(),arguments);this.oscillator=new dr(Object.assign({context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)},t.oscillator)),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.envelope=new Ir(Object.assign({context:this.context},t.envelope)),this.oscillator.chain(this.envelope,this.output),Hi(this,["oscillator","frequency","detune","envelope"])}static getDefaults(){return Object.assign(Br.getDefaults(),{envelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.3}),oscillator:Object.assign(Pi(dr.getDefaults(),[...Object.keys(Go.getDefaults()),"frequency","detune"]),{type:"triangle"})})}_triggerEnvelopeAttack(t,e){if(this.envelope.triggerAttack(t,e),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this}}class Vr extends Br{constructor(){super(ki(Vr.getDefaults(),arguments)),this.name="ModulationSynth";const t=ki(Vr.getDefaults(),arguments);this._carrier=new Fr({context:this.context,oscillator:t.oscillator,envelope:t.envelope,onsilence:()=>this.onsilence(this),volume:-10}),this._modulator=new Fr({context:this.context,oscillator:t.modulation,envelope:t.modulationEnvelope,volume:-10}),this.oscillator=this._carrier.oscillator,this.envelope=this._carrier.envelope,this.modulation=this._modulator.oscillator,this.modulationEnvelope=this._modulator.envelope,this.frequency=new Eo({context:this.context,units:"frequency"}),this.detune=new Eo({context:this.context,value:t.detune,units:"cents"}),this.harmonicity=new rr({context:this.context,value:t.harmonicity,minValue:0}),this._modulationNode=new So({context:this.context,gain:0}),Hi(this,["frequency","harmonicity","oscillator","envelope","modulation","modulationEnvelope","detune"])}static getDefaults(){return Object.assign(Br.getDefaults(),{harmonicity:3,oscillator:Object.assign(Pi(dr.getDefaults(),[...Object.keys(Go.getDefaults()),"frequency","detune"]),{type:"sine"}),envelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{attack:.01,decay:.01,sustain:1,release:.5}),modulation:Object.assign(Pi(dr.getDefaults(),[...Object.keys(Go.getDefaults()),"frequency","detune"]),{type:"square"}),modulationEnvelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{attack:.5,decay:0,sustain:1,release:.5})})}_triggerEnvelopeAttack(t,e){this._carrier._triggerEnvelopeAttack(t,e),this._modulator._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this._carrier._triggerEnvelopeRelease(t),this._modulator._triggerEnvelopeRelease(t),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this._carrier.dispose(),this._modulator.dispose(),this.frequency.dispose(),this.detune.dispose(),this.harmonicity.dispose(),this._modulationNode.dispose(),this}}class jr extends Vr{constructor(){super(ki(jr.getDefaults(),arguments)),this.name="AMSynth",this._modulationScale=new or({context:this.context}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.chain(this._modulationScale,this._modulationNode.gain),this._carrier.chain(this._modulationNode,this.output)}dispose(){return super.dispose(),this._modulationScale.dispose(),this}}class Lr extends bo{constructor(){super(ki(Lr.getDefaults(),arguments,["frequency","type"])),this.name="BiquadFilter";const t=ki(Lr.getDefaults(),arguments,["frequency","type"]);this._filter=this.context.createBiquadFilter(),this.input=this.output=this._filter,this.Q=new vo({context:this.context,units:"number",value:t.Q,param:this._filter.Q}),this.frequency=new vo({context:this.context,units:"frequency",value:t.frequency,param:this._filter.frequency}),this.detune=new vo({context:this.context,units:"cents",value:t.detune,param:this._filter.detune}),this.gain=new vo({context:this.context,units:"gain",value:t.gain,param:this._filter.gain}),this.type=t.type}static getDefaults(){return Object.assign(bo.getDefaults(),{Q:1,type:"lowpass",frequency:350,detune:0,gain:0})}get type(){return this._filter.type}set type(t){Gs(-1!==["lowpass","highpass","bandpass","lowshelf","highshelf","notch","allpass","peaking"].indexOf(t),"Invalid filter type: "+t),this._filter.type=t}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let n=0;ne.type=t)}get rolloff(){return this._rolloff}set rolloff(t){const e=ii(t)?t:parseInt(t,10),n=[-12,-24,-48,-96];let s=n.indexOf(e);Gs(-1!==s,"rolloff can only be "+n.join(", ")),s+=1,this._rolloff=e,this.input.disconnect(),this._filters.forEach(t=>t.disconnect()),this._filters=new Array(s);for(let t=0;t1);return this._filters.forEach(()=>{e.getFrequencyResponse(t).forEach((t,e)=>n[e]*=t)}),e.dispose(),n}dispose(){return super.dispose(),this._filters.forEach(t=>{t.dispose()}),Wi(this,["detune","frequency","gain","Q"]),this.frequency.dispose(),this.Q.dispose(),this.detune.dispose(),this.gain.dispose(),this}}class Ur extends Or{constructor(){super(ki(Ur.getDefaults(),arguments,["attack","decay","sustain","release"])),this.name="FrequencyEnvelope";const t=ki(Ur.getDefaults(),arguments,["attack","decay","sustain","release"]);this._octaves=t.octaves,this._baseFrequency=this.toFrequency(t.baseFrequency),this._exponent=this.input=new Mr({context:this.context,value:t.exponent}),this._scale=this.output=new fr({context:this.context,min:this._baseFrequency,max:this._baseFrequency*Math.pow(2,this._octaves)}),this._sig.chain(this._exponent,this._scale)}static getDefaults(){return Object.assign(Or.getDefaults(),{baseFrequency:200,exponent:1,octaves:4})}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){const e=this.toFrequency(t);Ys(e,0),this._baseFrequency=e,this._scale.min=this._baseFrequency,this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._scale.max=this._baseFrequency*Math.pow(2,t)}get exponent(){return this._exponent.value}set exponent(t){this._exponent.value=t}dispose(){return super.dispose(),this._exponent.dispose(),this._scale.dispose(),this}}class Hr extends Br{constructor(){super(ki(Hr.getDefaults(),arguments)),this.name="MonoSynth";const t=ki(Hr.getDefaults(),arguments);this.oscillator=new dr(Object.assign(t.oscillator,{context:this.context,detune:t.detune,onstop:()=>this.onsilence(this)})),this.frequency=this.oscillator.frequency,this.detune=this.oscillator.detune,this.filter=new qr(Object.assign(t.filter,{context:this.context})),this.filterEnvelope=new Ur(Object.assign(t.filterEnvelope,{context:this.context})),this.envelope=new Ir(Object.assign(t.envelope,{context:this.context})),this.oscillator.chain(this.filter,this.envelope,this.output),this.filterEnvelope.connect(this.filter.frequency),Hi(this,["oscillator","frequency","detune","filter","filterEnvelope","envelope"])}static getDefaults(){return Object.assign(Br.getDefaults(),{envelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{attack:.005,decay:.1,release:1,sustain:.9}),filter:Object.assign(Pi(qr.getDefaults(),Object.keys(bo.getDefaults())),{Q:1,rolloff:-12,type:"lowpass"}),filterEnvelope:Object.assign(Pi(Ur.getDefaults(),Object.keys(bo.getDefaults())),{attack:.6,baseFrequency:200,decay:.2,exponent:2,octaves:3,release:2,sustain:.5}),oscillator:Object.assign(Pi(dr.getDefaults(),Object.keys(Go.getDefaults())),{type:"sawtooth"})})}_triggerEnvelopeAttack(t,e=1){if(this.envelope.triggerAttack(t,e),this.filterEnvelope.triggerAttack(t),this.oscillator.start(t),0===this.envelope.sustain){const e=this.toSeconds(this.envelope.attack),n=this.toSeconds(this.envelope.decay);this.oscillator.stop(t+e+n)}}_triggerEnvelopeRelease(t){this.envelope.triggerRelease(t),this.filterEnvelope.triggerRelease(t),this.oscillator.stop(t+this.toSeconds(this.envelope.release))}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}dispose(){return super.dispose(),this.oscillator.dispose(),this.envelope.dispose(),this.filterEnvelope.dispose(),this.filter.dispose(),this}}class Wr extends Br{constructor(){super(ki(Wr.getDefaults(),arguments)),this.name="DuoSynth";const t=ki(Wr.getDefaults(),arguments);this.voice0=new Hr(Object.assign(t.voice0,{context:this.context,onsilence:()=>this.onsilence(this)})),this.voice1=new Hr(Object.assign(t.voice1,{context:this.context})),this.harmonicity=new rr({context:this.context,units:"positive",value:t.harmonicity}),this._vibrato=new _r({frequency:t.vibratoRate,context:this.context,min:-50,max:50}),this._vibrato.start(),this.vibratoRate=this._vibrato.frequency,this._vibratoGain=new So({context:this.context,units:"normalRange",gain:t.vibratoAmount}),this.vibratoAmount=this._vibratoGain.gain,this.frequency=new Eo({context:this.context,units:"frequency",value:440}),this.detune=new Eo({context:this.context,units:"cents",value:t.detune}),this.frequency.connect(this.voice0.frequency),this.frequency.chain(this.harmonicity,this.voice1.frequency),this._vibrato.connect(this._vibratoGain),this._vibratoGain.fan(this.voice0.detune,this.voice1.detune),this.detune.fan(this.voice0.detune,this.voice1.detune),this.voice0.connect(this.output),this.voice1.connect(this.output),Hi(this,["voice0","voice1","frequency","vibratoAmount","vibratoRate"])}getLevelAtTime(t){return t=this.toSeconds(t),this.voice0.envelope.getValueAtTime(t)+this.voice1.envelope.getValueAtTime(t)}static getDefaults(){return Ci(Br.getDefaults(),{vibratoAmount:.5,vibratoRate:5,harmonicity:1.5,voice0:Ci(Pi(Hr.getDefaults(),Object.keys(Br.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}}),voice1:Ci(Pi(Hr.getDefaults(),Object.keys(Br.getDefaults())),{filterEnvelope:{attack:.01,decay:0,sustain:1,release:.5},envelope:{attack:.01,decay:0,sustain:1,release:.5}})})}_triggerEnvelopeAttack(t,e){this.voice0._triggerEnvelopeAttack(t,e),this.voice1._triggerEnvelopeAttack(t,e)}_triggerEnvelopeRelease(t){return this.voice0._triggerEnvelopeRelease(t),this.voice1._triggerEnvelopeRelease(t),this}dispose(){return super.dispose(),this.voice0.dispose(),this.voice1.dispose(),this.frequency.dispose(),this.detune.dispose(),this._vibrato.dispose(),this.vibratoRate.dispose(),this._vibratoGain.dispose(),this.harmonicity.dispose(),this}}class Qr extends Vr{constructor(){super(ki(Qr.getDefaults(),arguments)),this.name="FMSynth";const t=ki(Qr.getDefaults(),arguments);this.modulationIndex=new rr({context:this.context,value:t.modulationIndex}),this.frequency.connect(this._carrier.frequency),this.frequency.chain(this.harmonicity,this._modulator.frequency),this.frequency.chain(this.modulationIndex,this._modulationNode),this.detune.fan(this._carrier.detune,this._modulator.detune),this._modulator.connect(this._modulationNode.gain),this._modulationNode.connect(this._carrier.frequency),this._carrier.connect(this.output)}static getDefaults(){return Object.assign(Vr.getDefaults(),{modulationIndex:10})}dispose(){return super.dispose(),this.modulationIndex.dispose(),this}}const Xr=[1,1.483,1.932,2.546,2.63,3.897];class zr extends Br{constructor(){super(ki(zr.getDefaults(),arguments)),this.name="MetalSynth",this._oscillators=[],this._freqMultipliers=[];const t=ki(zr.getDefaults(),arguments);this.detune=new Eo({context:this.context,units:"cents",value:t.detune}),this.frequency=new Eo({context:this.context,units:"frequency"}),this._amplitude=new So({context:this.context,gain:0}).connect(this.output),this._highpass=new qr({Q:0,context:this.context,type:"highpass"}).connect(this._amplitude);for(let e=0;ethis.onsilence(this):Qi,type:"square"});n.connect(this._highpass),this._oscillators[e]=n;const s=new rr({context:this.context,value:Xr[e]});this._freqMultipliers[e]=s,this.frequency.chain(s,n.frequency),this.detune.connect(n.detune)}this._filterFreqScaler=new fr({context:this.context,max:7e3,min:this.toFrequency(t.resonance)}),this.envelope=new Or({attack:t.envelope.attack,attackCurve:"linear",context:this.context,decay:t.envelope.decay,release:t.envelope.release,sustain:0}),this.envelope.chain(this._filterFreqScaler,this._highpass.frequency),this.envelope.connect(this._amplitude.gain),this._octaves=t.octaves,this.octaves=t.octaves}static getDefaults(){return Ci(Br.getDefaults(),{envelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{attack:.001,decay:1.4,release:.2}),harmonicity:5.1,modulationIndex:32,octaves:1.5,resonance:4e3})}_triggerEnvelopeAttack(t,e=1){return this.envelope.triggerAttack(t,e),this._oscillators.forEach(e=>e.start(t)),0===this.envelope.sustain&&this._oscillators.forEach(e=>{e.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay))}),this}_triggerEnvelopeRelease(t){return this.envelope.triggerRelease(t),this._oscillators.forEach(e=>e.stop(t+this.toSeconds(this.envelope.release))),this}getLevelAtTime(t){return t=this.toSeconds(t),this.envelope.getValueAtTime(t)}get modulationIndex(){return this._oscillators[0].modulationIndex.value}set modulationIndex(t){this._oscillators.forEach(e=>e.modulationIndex.value=t)}get harmonicity(){return this._oscillators[0].harmonicity.value}set harmonicity(t){this._oscillators.forEach(e=>e.harmonicity.value=t)}get resonance(){return this._filterFreqScaler.min}set resonance(t){this._filterFreqScaler.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._filterFreqScaler.max=this._filterFreqScaler.min*Math.pow(2,t)}dispose(){return super.dispose(),this._oscillators.forEach(t=>t.dispose()),this._freqMultipliers.forEach(t=>t.dispose()),this.frequency.dispose(),this.detune.dispose(),this._filterFreqScaler.dispose(),this._amplitude.dispose(),this.envelope.dispose(),this._highpass.dispose(),this}}class Gr extends Fr{constructor(){super(ki(Gr.getDefaults(),arguments)),this.name="MembraneSynth",this.portamento=0;const t=ki(Gr.getDefaults(),arguments);this.pitchDecay=t.pitchDecay,this.octaves=t.octaves,Hi(this,["oscillator","envelope"])}static getDefaults(){return Ci(Br.getDefaults(),Fr.getDefaults(),{envelope:{attack:.001,attackCurve:"exponential",decay:.4,release:1.4,sustain:.01},octaves:10,oscillator:{type:"sine"},pitchDecay:.05})}setNote(t,e){const n=this.toSeconds(e),s=this.toFrequency(t instanceof co?t.toFrequency():t),i=s*this.octaves;return this.oscillator.frequency.setValueAtTime(i,n),this.oscillator.frequency.exponentialRampToValueAtTime(s,n+this.toSeconds(this.pitchDecay)),this}dispose(){return super.dispose(),this}}fi([vr(0)],Gr.prototype,"octaves",void 0),fi([br(0)],Gr.prototype,"pitchDecay",void 0);class Yr extends Dr{constructor(){super(ki(Yr.getDefaults(),arguments)),this.name="NoiseSynth";const t=ki(Yr.getDefaults(),arguments);this.noise=new Ko(Object.assign({context:this.context},t.noise)),this.envelope=new Ir(Object.assign({context:this.context},t.envelope)),this.noise.chain(this.envelope,this.output)}static getDefaults(){return Object.assign(Dr.getDefaults(),{envelope:Object.assign(Pi(Or.getDefaults(),Object.keys(bo.getDefaults())),{decay:.1,sustain:0}),noise:Object.assign(Pi(Ko.getDefaults(),Object.keys(Go.getDefaults())),{type:"white"})})}triggerAttack(t,e=1){return t=this.toSeconds(t),this.envelope.triggerAttack(t,e),this.noise.start(t),0===this.envelope.sustain&&this.noise.stop(t+this.toSeconds(this.envelope.attack)+this.toSeconds(this.envelope.decay)),this}triggerRelease(t){return t=this.toSeconds(t),this.envelope.triggerRelease(t),this.noise.stop(t+this.toSeconds(this.envelope.release)),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",0),this._syncMethod("triggerRelease",0)),this}triggerAttackRelease(t,e,n=1){return e=this.toSeconds(e),t=this.toSeconds(t),this.triggerAttack(e,n),this.triggerRelease(e+t),this}dispose(){return super.dispose(),this.noise.dispose(),this.envelope.dispose(),this}}const Kr=new Set;function Zr(t){Kr.add(t)}function Jr(t,e){const n=`registerProcessor("${t}", ${e})`;Kr.add(n)}class $r extends bo{constructor(t){super(t),this.name="ToneAudioWorklet",this.workletOptions={},this.onprocessorerror=Qi;const e=URL.createObjectURL(new Blob([Array.from(Kr).join("\n")],{type:"text/javascript"})),n=this._audioWorkletName();this._dummyGain=this.context.createGain(),this._dummyParam=this._dummyGain.gain,this.context.addAudioWorkletModule(e,n).then(()=>{this.disposed||(this._worklet=this.context.createAudioWorkletNode(n,this.workletOptions),this._worklet.onprocessorerror=this.onprocessorerror.bind(this),this.onReady(this._worklet))}).catch(t=>{throw console.error(t),new Error(t)})}dispose(){return super.dispose(),this._dummyGain.disconnect(),this._worklet&&(this._worklet.port.postMessage("dispose"),this._worklet.disconnect()),this}}Zr('\n\t/**\n\t * The base AudioWorkletProcessor for use in Tone.js. Works with the [[ToneAudioWorklet]]. \n\t */\n\tclass ToneAudioWorkletProcessor extends AudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\t\n\t\t\tsuper(options);\n\t\t\t/**\n\t\t\t * If the processor was disposed or not. Keep alive until it\'s disposed.\n\t\t\t */\n\t\t\tthis.disposed = false;\n\t\t \t/** \n\t\t\t * The number of samples in the processing block\n\t\t\t */\n\t\t\tthis.blockSize = 128;\n\t\t\t/**\n\t\t\t * the sample rate\n\t\t\t */\n\t\t\tthis.sampleRate = sampleRate;\n\n\t\t\tthis.port.onmessage = (event) => {\n\t\t\t\t// when it receives a dispose \n\t\t\t\tif (event.data === "dispose") {\n\t\t\t\t\tthis.disposed = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t}\n'),Zr("\n\t/**\n\t * Abstract class for a single input/output processor. \n\t * has a 'generate' function which processes one sample at a time\n\t */\n\tclass SingleIOProcessor extends ToneAudioWorkletProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(Object.assign(options, {\n\t\t\t\tnumberOfInputs: 1,\n\t\t\t\tnumberOfOutputs: 1\n\t\t\t}));\n\t\t\t/**\n\t\t\t * Holds the name of the parameter and a single value of that\n\t\t\t * parameter at the current sample\n\t\t\t * @type { [name: string]: number }\n\t\t\t */\n\t\t\tthis.params = {}\n\t\t}\n\n\t\t/**\n\t\t * Generate an output sample from the input sample and parameters\n\t\t * @abstract\n\t\t * @param input number\n\t\t * @param channel number\n\t\t * @param parameters { [name: string]: number }\n\t\t * @returns number\n\t\t */\n\t\tgenerate(){}\n\n\t\t/**\n\t\t * Update the private params object with the \n\t\t * values of the parameters at the given index\n\t\t * @param parameters { [name: string]: Float32Array },\n\t\t * @param index number\n\t\t */\n\t\tupdateParams(parameters, index) {\n\t\t\tfor (const paramName in parameters) {\n\t\t\t\tconst param = parameters[paramName];\n\t\t\t\tif (param.length > 1) {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][index];\n\t\t\t\t} else {\n\t\t\t\t\tthis.params[paramName] = parameters[paramName][0];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Process a single frame of the audio\n\t\t * @param inputs Float32Array[][]\n\t\t * @param outputs Float32Array[][]\n\t\t */\n\t\tprocess(inputs, outputs, parameters) {\n\t\t\tconst input = inputs[0];\n\t\t\tconst output = outputs[0];\n\t\t\t// get the parameter values\n\t\t\tconst channelCount = Math.max(input && input.length || 0, output.length);\n\t\t\tfor (let sample = 0; sample < this.blockSize; sample++) {\n\t\t\t\tthis.updateParams(parameters, sample);\n\t\t\t\tfor (let channel = 0; channel < channelCount; channel++) {\n\t\t\t\t\tconst inputSample = input && input.length ? input[channel][sample] : 0;\n\t\t\t\t\toutput[channel][sample] = this.generate(inputSample, channel, this.params);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn !this.disposed;\n\t\t}\n\t};\n"),Zr("\n\t/**\n\t * A multichannel buffer for use within an AudioWorkletProcessor as a delay line\n\t */\n\tclass DelayLine {\n\t\t\n\t\tconstructor(size, channels) {\n\t\t\tthis.buffer = [];\n\t\t\tthis.writeHead = []\n\t\t\tthis.size = size;\n\n\t\t\t// create the empty channels\n\t\t\tfor (let i = 0; i < channels; i++) {\n\t\t\t\tthis.buffer[i] = new Float32Array(this.size);\n\t\t\t\tthis.writeHead[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * Push a value onto the end\n\t\t * @param channel number\n\t\t * @param value number\n\t\t */\n\t\tpush(channel, value) {\n\t\t\tthis.writeHead[channel] += 1;\n\t\t\tif (this.writeHead[channel] > this.size) {\n\t\t\t\tthis.writeHead[channel] = 0;\n\t\t\t}\n\t\t\tthis.buffer[channel][this.writeHead[channel]] = value;\n\t\t}\n\n\t\t/**\n\t\t * Get the recorded value of the channel given the delay\n\t\t * @param channel number\n\t\t * @param delay number delay samples\n\t\t */\n\t\tget(channel, delay) {\n\t\t\tlet readHead = this.writeHead[channel] - Math.floor(delay);\n\t\t\tif (readHead < 0) {\n\t\t\t\treadHead += this.size;\n\t\t\t}\n\t\t\treturn this.buffer[channel][readHead];\n\t\t}\n\t}\n"),Jr("feedback-comb-filter",'\n\tclass FeedbackCombFilterWorklet extends SingleIOProcessor {\n\n\t\tconstructor(options) {\n\t\t\tsuper(options);\n\t\t\tthis.delayLine = new DelayLine(this.sampleRate, options.channelCount || 2);\n\t\t}\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: "delayTime",\n\t\t\t\tdefaultValue: 0.1,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 1,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}, {\n\t\t\t\tname: "feedback",\n\t\t\t\tdefaultValue: 0.5,\n\t\t\t\tminValue: 0,\n\t\t\t\tmaxValue: 0.9999,\n\t\t\t\tautomationRate: "k-rate"\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, channel, parameters) {\n\t\t\tconst delayedSample = this.delayLine.get(channel, parameters.delayTime * this.sampleRate);\n\t\t\tthis.delayLine.push(channel, input + delayedSample * parameters.feedback);\n\t\t\treturn delayedSample;\n\t\t}\n\t}\n');class ta extends $r{constructor(){super(ki(ta.getDefaults(),arguments,["delayTime","resonance"])),this.name="FeedbackCombFilter";const t=ki(ta.getDefaults(),arguments,["delayTime","resonance"]);this.input=new So({context:this.context}),this.output=new So({context:this.context}),this.delayTime=new vo({context:this.context,value:t.delayTime,units:"time",minValue:0,maxValue:1,param:this._dummyParam,swappable:!0}),this.resonance=new vo({context:this.context,value:t.resonance,units:"normalRange",param:this._dummyParam,swappable:!0}),Hi(this,["resonance","delayTime"])}_audioWorkletName(){return"feedback-comb-filter"}static getDefaults(){return Object.assign(bo.getDefaults(),{delayTime:.1,resonance:.5})}onReady(t){yo(this.input,t,this.output);const e=t.parameters.get("delayTime");this.delayTime.setParam(e);const n=t.parameters.get("feedback");this.resonance.setParam(n)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.delayTime.dispose(),this.resonance.dispose(),this}}class ea extends bo{constructor(){super(ki(ea.getDefaults(),arguments,["frequency","type"])),this.name="OnePoleFilter";const t=ki(ea.getDefaults(),arguments,["frequency","type"]);this._frequency=t.frequency,this._type=t.type,this.input=new So({context:this.context}),this.output=new So({context:this.context}),this._createFilter()}static getDefaults(){return Object.assign(bo.getDefaults(),{frequency:880,type:"lowpass"})}_createFilter(){const t=this._filter,e=this.toFrequency(this._frequency),n=1/(2*Math.PI*e);if("lowpass"===this._type){const t=1/(n*this.context.sampleRate),e=t-1;this._filter=this.context.createIIRFilter([t,0],[1,e])}else{const t=1/(n*this.context.sampleRate)-1;this._filter=this.context.createIIRFilter([1,-1],[1,t])}this.input.chain(this._filter,this.output),t&&this.context.setTimeout(()=>{this.disposed||(this.input.disconnect(t),t.disconnect())},this.blockTime)}get frequency(){return this._frequency}set frequency(t){this._frequency=t,this._createFilter()}get type(){return this._type}set type(t){this._type=t,this._createFilter()}getFrequencyResponse(t=128){const e=new Float32Array(t);for(let n=0;ne.voice===t);this._activeVoices.splice(e,1)}_getNextAvailableVoice(){if(this._availableVoices.length)return this._availableVoices.shift();if(this._voices.lengthMath.ceil(this._averageActiveVoices+1)){const t=this._availableVoices.shift(),e=this._voices.indexOf(t);this._voices.splice(e,1),this.context.isOffline||t.dispose()}}_triggerAttack(t,e,n){t.forEach(t=>{const s=new Bo(this.context,t).toMidi(),i=this._getNextAvailableVoice();i&&(i.triggerAttack(t,e,n),this._activeVoices.push({midi:s,voice:i,released:!1}),this.log("triggerAttack",t,e))})}_triggerRelease(t,e){t.forEach(t=>{const n=new Bo(this.context,t).toMidi(),s=this._activeVoices.find(({midi:t,released:e})=>t===n&&!e);s&&(s.voice.triggerRelease(e),s.released=!0,this.log("triggerRelease",t,e))})}_scheduleEvent(t,e,n,s){Gs(!this.disposed,"Synth was already disposed"),n<=this.now()?"attack"===t?this._triggerAttack(e,n,s):this._triggerRelease(e,n):this.context.setTimeout(()=>{this._scheduleEvent(t,e,n,s)},n-this.now())}triggerAttack(t,e,n){Array.isArray(t)||(t=[t]);const s=this.toSeconds(e);return this._scheduleEvent("attack",t,s,n),this}triggerRelease(t,e){Array.isArray(t)||(t=[t]);const n=this.toSeconds(e);return this._scheduleEvent("release",t,n),this}triggerAttackRelease(t,e,n,s){const i=this.toSeconds(n);if(this.triggerAttack(t,i,s),ai(e)){Gs(ai(t),"If the duration is an array, the notes must also be an array"),t=t;for(let n=0;n0,"The duration must be greater than 0"),this.triggerRelease(t[n],i+o)}}else{const n=this.toSeconds(e);Gs(n>0,"The duration must be greater than 0"),this.triggerRelease(t,i+n)}return this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}set(t){const e=Pi(t,["onsilence","context"]);return this.options=Ci(this.options,e),this._voices.forEach(t=>t.set(e)),this._dummyVoice.set(e),this}get(){return this._dummyVoice.get()}releaseAll(t){const e=this.toSeconds(t);return this._activeVoices.forEach(({voice:t})=>{t.triggerRelease(e)}),this}dispose(){return super.dispose(),this._dummyVoice.dispose(),this._voices.forEach(t=>t.dispose()),this._activeVoices=[],this._availableVoices=[],this.context.clearInterval(this._gcTimeout),this}}class oa extends Dr{constructor(){super(ki(oa.getDefaults(),arguments,["urls","onload","baseUrl"],"urls")),this.name="Sampler",this._activeSources=new Map;const t=ki(oa.getDefaults(),arguments,["urls","onload","baseUrl"],"urls"),e={};Object.keys(t.urls).forEach(n=>{const s=parseInt(n,10);if(Gs(ci(n)||ii(s)&&isFinite(s),"url key is neither a note or midi pitch: "+n),ci(n)){const s=new co(this.context,n).toMidi();e[s]=t.urls[n]}else ii(s)&&isFinite(s)&&(e[s]=t.urls[s])}),this._buffers=new Do({urls:e,onload:t.onload,baseUrl:t.baseUrl,onerror:t.onerror}),this.attack=t.attack,this.release=t.release,this.curve=t.curve,this._buffers.loaded&&Promise.resolve().then(t.onload)}static getDefaults(){return Object.assign(Dr.getDefaults(),{attack:0,baseUrl:"",curve:"exponential",onload:Qi,onerror:Qi,release:.1,urls:{}})}_findClosest(t){let e=0;for(;e<96;){if(this._buffers.has(t+e))return-e;if(this._buffers.has(t-e))return e;e++}throw new Error("No available buffers for note: "+t)}triggerAttack(t,e,n=1){return this.log("triggerAttack",t,e,n),Array.isArray(t)||(t=[t]),t.forEach(t=>{const s=io(new co(this.context,t).toFrequency()),i=Math.round(s),o=s-i,r=this._findClosest(i),a=i-r,l=this._buffers.get(a),c=eo(r+o),h=new Yo({url:l,context:this.context,curve:this.curve,fadeIn:this.attack,fadeOut:this.release,playbackRate:c}).connect(this.output);h.start(e,0,l.duration/c,n),ai(this._activeSources.get(i))||this._activeSources.set(i,[]),this._activeSources.get(i).push(h),h.onended=()=>{if(this._activeSources&&this._activeSources.has(i)){const t=this._activeSources.get(i),e=t.indexOf(h);-1!==e&&t.splice(e,1)}}}),this}triggerRelease(t,e){return this.log("triggerRelease",t,e),Array.isArray(t)||(t=[t]),t.forEach(t=>{const n=new co(this.context,t).toMidi();if(this._activeSources.has(n)&&this._activeSources.get(n).length){const t=this._activeSources.get(n);e=this.toSeconds(e),t.forEach(t=>{t.stop(e)}),this._activeSources.set(n,[])}}),this}releaseAll(t){const e=this.toSeconds(t);return this._activeSources.forEach(t=>{for(;t.length;)t.shift().stop(e)}),this}sync(){return this._syncState()&&(this._syncMethod("triggerAttack",1),this._syncMethod("triggerRelease",1)),this}triggerAttackRelease(t,e,n,s=1){const i=this.toSeconds(n);return this.triggerAttack(t,i,s),ai(e)?(Gs(ai(t),"notes must be an array when duration is array"),t.forEach((t,n)=>{const s=e[Math.min(n,e.length-1)];this.triggerRelease(t,i+this.toSeconds(s))})):this.triggerRelease(t,i+this.toSeconds(e)),this}add(t,e,n){if(Gs(ci(t)||isFinite(t),"note must be a pitch or midi: "+t),ci(t)){const s=new co(this.context,t).toMidi();this._buffers.add(s,e,n)}else this._buffers.add(t,e,n);return this}get loaded(){return this._buffers.loaded}dispose(){return super.dispose(),this._buffers.dispose(),this._activeSources.forEach(t=>{t.forEach(t=>t.dispose())}),this._activeSources.clear(),this}}fi([br(0)],oa.prototype,"attack",void 0),fi([br(0)],oa.prototype,"release",void 0);class ra extends go{constructor(){super(ki(ra.getDefaults(),arguments,["callback","value"])),this.name="ToneEvent",this._state=new _o("stopped"),this._startOffset=0;const t=ki(ra.getDefaults(),arguments,["callback","value"]);this._loop=t.loop,this.callback=t.callback,this.value=t.value,this._loopStart=this.toTicks(t.loopStart),this._loopEnd=this.toTicks(t.loopEnd),this._playbackRate=t.playbackRate,this._probability=t.probability,this._humanize=t.humanize,this.mute=t.mute,this._playbackRate=t.playbackRate,this._state.increasing=!0,this._rescheduleEvents()}static getDefaults(){return Object.assign(go.getDefaults(),{callback:Qi,humanize:!1,loop:!1,loopEnd:"1m",loopStart:0,mute:!1,playbackRate:1,probability:1,value:null})}_rescheduleEvents(t=-1){this._state.forEachFrom(t,t=>{let e;if("started"===t.state){-1!==t.id&&this.context.transport.clear(t.id);const n=t.time+Math.round(this.startOffset/this._playbackRate);if(!0===this._loop||ii(this._loop)&&this._loop>1){e=1/0,ii(this._loop)&&(e=this._loop*this._getLoopDuration());const s=this._state.getAfter(n);null!==s&&(e=Math.min(e,s.time-n)),e!==1/0&&(this._state.setStateAtTime("stopped",n+e+1,{id:-1}),e=new Fo(this.context,e));const i=new Fo(this.context,this._getLoopDuration());t.id=this.context.transport.scheduleRepeat(this._tick.bind(this),i,new Fo(this.context,n),e)}else t.id=this.context.transport.schedule(this._tick.bind(this),new Fo(this.context,n))}})}get state(){return this._state.getValueAtTime(this.context.transport.ticks)}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t}get probability(){return this._probability}set probability(t){this._probability=t}get humanize(){return this._humanize}set humanize(t){this._humanize=t}start(t){const e=this.toTicks(t);return"stopped"===this._state.getValueAtTime(e)&&(this._state.add({id:-1,state:"started",time:e}),this._rescheduleEvents(e)),this}stop(t){this.cancel(t);const e=this.toTicks(t);if("started"===this._state.getValueAtTime(e)){this._state.setStateAtTime("stopped",e,{id:-1});const t=this._state.getBefore(e);let n=e;null!==t&&(n=t.time),this._rescheduleEvents(n)}return this}cancel(t){t=Ei(t,-1/0);const e=this.toTicks(t);return this._state.forEachFrom(e,t=>{this.context.transport.clear(t.id)}),this._state.cancel(e),this}_tick(t){const e=this.context.transport.getTicksAtTime(t);if(!this.mute&&"started"===this._state.getValueAtTime(e)){if(this.probability<1&&Math.random()>this.probability)return;if(this.humanize){let e=.02;ri(this.humanize)||(e=this.toSeconds(this.humanize)),t+=(2*Math.random()-1)*e}this.callback(t,this.value)}}_getLoopDuration(){return Math.round((this._loopEnd-this._loopStart)/this._playbackRate)}get loop(){return this._loop}set loop(t){this._loop=t,this._rescheduleEvents()}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._rescheduleEvents()}get loopEnd(){return new Fo(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._rescheduleEvents()}get loopStart(){return new Fo(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._rescheduleEvents()}get progress(){if(this._loop){const t=this.context.transport.ticks,e=this._state.get(t);if(null!==e&&"started"===e.state){const n=this._getLoopDuration();return(t-e.time)%n/n}return 0}return 0}dispose(){return super.dispose(),this.cancel(),this._state.dispose(),this}}class aa extends go{constructor(){super(ki(aa.getDefaults(),arguments,["callback","interval"])),this.name="Loop";const t=ki(aa.getDefaults(),arguments,["callback","interval"]);this._event=new ra({context:this.context,callback:this._tick.bind(this),loop:!0,loopEnd:t.interval,playbackRate:t.playbackRate,probability:t.probability}),this.callback=t.callback,this.iterations=t.iterations}static getDefaults(){return Object.assign(go.getDefaults(),{interval:"4n",callback:Qi,playbackRate:1,iterations:1/0,probability:1,mute:!1,humanize:!1})}start(t){return this._event.start(t),this}stop(t){return this._event.stop(t),this}cancel(t){return this._event.cancel(t),this}_tick(t){this.callback(t)}get state(){return this._event.state}get progress(){return this._event.progress}get interval(){return this._event.loopEnd}set interval(t){this._event.loopEnd=t}get playbackRate(){return this._event.playbackRate}set playbackRate(t){this._event.playbackRate=t}get humanize(){return this._event.humanize}set humanize(t){this._event.humanize=t}get probability(){return this._event.probability}set probability(t){this._event.probability=t}get mute(){return this._event.mute}set mute(t){this._event.mute=t}get iterations(){return!0===this._event.loop?1/0:this._event.loop}set iterations(t){this._event.loop=t===1/0||t}dispose(){return super.dispose(),this._event.dispose(),this}}class la extends ra{constructor(){super(ki(la.getDefaults(),arguments,["callback","events"])),this.name="Part",this._state=new _o("stopped"),this._events=new Set;const t=ki(la.getDefaults(),arguments,["callback","events"]);this._state.increasing=!0,t.events.forEach(t=>{ai(t)?this.add(t[0],t[1]):this.add(t)})}static getDefaults(){return Object.assign(ra.getDefaults(),{events:[]})}start(t,e){const n=this.toTicks(t);if("started"!==this._state.getValueAtTime(n)){e=Ei(e,this._loop?this._loopStart:0),e=this._loop?Ei(e,this._loopStart):Ei(e,0);const t=this.toTicks(e);this._state.add({id:-1,offset:t,state:"started",time:n}),this._forEach(e=>{this._startNote(e,n,t)})}return this}_startNote(t,e,n){e-=n,this._loop?t.startOffset>=this._loopStart&&t.startOffset=n&&(t.loop=!1,t.start(new Fo(this.context,e))):t.startOffset>=n&&t.start(new Fo(this.context,e))}get startOffset(){return this._startOffset}set startOffset(t){this._startOffset=t,this._forEach(t=>{t.startOffset+=this._startOffset})}stop(t){const e=this.toTicks(t);return this._state.cancel(e),this._state.setStateAtTime("stopped",e),this._forEach(e=>{e.stop(t)}),this}at(t,e){const n=new mo(this.context,t).toTicks(),s=new Fo(this.context,1).toSeconds(),i=this._events.values();let o=i.next();for(;!o.done;){const t=o.value;if(Math.abs(n-t.startOffset){"started"===e.state?this._startNote(t,e.time,e.offset):t.stop(new Fo(this.context,e.time))})}remove(t,e){return oi(t)&&t.hasOwnProperty("time")&&(t=(e=t).time),t=this.toTicks(t),this._events.forEach(n=>{n.startOffset===t&&(ei(e)||ni(e)&&n.value===e)&&(this._events.delete(n),n.dispose())}),this}clear(){return this._forEach(t=>t.dispose()),this._events.clear(),this}cancel(t){return this._forEach(e=>e.cancel(t)),this._state.cancel(this.toTicks(t)),this}_forEach(t){return this._events&&this._events.forEach(e=>{e instanceof la?e._forEach(t):t(e)}),this}_setAll(t,e){this._forEach(n=>{n[t]=e})}_tick(t,e){this.mute||this.callback(t,e)}_testLoopBoundries(t){this._loop&&(t.startOffset=this._loopEnd)?t.cancel(0):"stopped"===t.state&&this._restartEvent(t)}get probability(){return this._probability}set probability(t){this._probability=t,this._setAll("probability",t)}get humanize(){return this._humanize}set humanize(t){this._humanize=t,this._setAll("humanize",t)}get loop(){return this._loop}set loop(t){this._loop=t,this._forEach(e=>{e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.loop=t,this._testLoopBoundries(e)})}get loopEnd(){return new Fo(this.context,this._loopEnd).toSeconds()}set loopEnd(t){this._loopEnd=this.toTicks(t),this._loop&&this._forEach(e=>{e.loopEnd=t,this._testLoopBoundries(e)})}get loopStart(){return new Fo(this.context,this._loopStart).toSeconds()}set loopStart(t){this._loopStart=this.toTicks(t),this._loop&&this._forEach(t=>{t.loopStart=this.loopStart,this._testLoopBoundries(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this._setAll("playbackRate",t)}get length(){return this._events.size}dispose(){return super.dispose(),this.clear(),this}}function*ca(t){let e=0;for(;e=0;)e=pa(e,t),yield t[e],e--}function*ua(t,e){for(;;)yield*e(t)}function pa(t,e){return Di(t,0,e.length-1)}function*da(t,e){let n=e?0:t.length-1;for(;;)n=pa(n,t),yield t[n],e?(n++,n>=t.length-1&&(e=!1)):(n--,n<=0&&(e=!0))}function*ma(t){let e=0,n=0;for(;e=0;)e=pa(e,t),yield t[e],n++,e+=n%2?-2:1}function*ga(t){const e=[];for(let n=0;n0;){const n=pa(e.splice(Math.floor(e.length*Math.random()),1)[0],t);yield t[n]}}function*_a(t,e="up",n=0){switch(Gs(t.length>0,"The array must have more than one value in it"),e){case"up":yield*ua(t,ca);case"down":yield*ua(t,ha);case"upDown":yield*da(t,!0);case"downUp":yield*da(t,!1);case"alternateUp":yield*ua(t,ma);case"alternateDown":yield*ua(t,fa);case"random":yield*function*(t){for(;;){const e=Math.floor(Math.random()*t.length);yield t[e]}}(t);case"randomOnce":yield*ua(t,ga);case"randomWalk":yield*function*(t){let e=Math.floor(Math.random()*t.length);for(;;)0===e?e++:e===t.length-1||Math.random()<.5?e--:e++,yield t[e]}(t)}}class va extends aa{constructor(){super(ki(va.getDefaults(),arguments,["callback","values","pattern"])),this.name="Pattern";const t=ki(va.getDefaults(),arguments,["callback","values","pattern"]);this.callback=t.callback,this._values=t.values,this._pattern=_a(t.values,t.pattern),this._type=t.pattern}static getDefaults(){return Object.assign(aa.getDefaults(),{pattern:"up",values:[],callback:Qi})}_tick(t){const e=this._pattern.next();this._value=e.value,this.callback(t,this._value)}get values(){return this._values}set values(t){this._values=t,this.pattern=this._type}get value(){return this._value}get pattern(){return this._type}set pattern(t){this._type=t,this._pattern=_a(this._values,this._type)}}class ba extends ra{constructor(){super(ki(ba.getDefaults(),arguments,["callback","events","subdivision"])),this.name="Sequence",this._part=new la({callback:this._seqCallback.bind(this),context:this.context}),this._events=[],this._eventsArray=[];const t=ki(ba.getDefaults(),arguments,["callback","events","subdivision"]);this._subdivision=this.toTicks(t.subdivision),this.events=t.events,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.playbackRate=t.playbackRate,this.probability=t.probability,this.humanize=t.humanize,this.mute=t.mute,this.playbackRate=t.playbackRate}static getDefaults(){return Object.assign(Pi(ra.getDefaults(),["value"]),{events:[],loop:!0,loopEnd:0,loopStart:0,subdivision:"8n"})}_seqCallback(t,e){null!==e&&this.callback(t,e)}get events(){return this._events}set events(t){this.clear(),this._eventsArray=t,this._events=this._createSequence(this._eventsArray),this._eventsUpdated()}start(t,e){return this._part.start(t,e?this._indexTime(e):e),this}stop(t){return this._part.stop(t),this}get subdivision(){return new Fo(this.context,this._subdivision).toSeconds()}_createSequence(t){return new Proxy(t,{get:(t,e)=>t[e],set:(t,e,n)=>(li(e)&&isFinite(parseInt(e,10))&&ai(n)?t[e]=this._createSequence(n):t[e]=n,this._eventsUpdated(),!0)})}_eventsUpdated(){this._part.clear(),this._rescheduleSequence(this._eventsArray,this._subdivision,this.startOffset),this.loopEnd=this.loopEnd}_rescheduleSequence(t,e,n){t.forEach((t,s)=>{const i=s*e+n;if(ai(t))this._rescheduleSequence(t,e/t.length,i);else{const e=new Fo(this.context,i,"i").toSeconds();this._part.add(e,t)}})}_indexTime(t){return new Fo(this.context,t*this._subdivision+this.startOffset).toSeconds()}clear(){return this._part.clear(),this}dispose(){return super.dispose(),this._part.dispose(),this}get loop(){return this._part.loop}set loop(t){this._part.loop=t}get loopStart(){return this._loopStart}set loopStart(t){this._loopStart=t,this._part.loopStart=this._indexTime(t)}get loopEnd(){return this._loopEnd}set loopEnd(t){this._loopEnd=t,this._part.loopEnd=0===t?this._indexTime(this._eventsArray.length):this._indexTime(t)}get startOffset(){return this._part.startOffset}set startOffset(t){this._part.startOffset=t}get playbackRate(){return this._part.playbackRate}set playbackRate(t){this._part.playbackRate=t}get probability(){return this._part.probability}set probability(t){this._part.probability=t}get progress(){return this._part.progress}get humanize(){return this._part.humanize}set humanize(t){this._part.humanize=t}get length(){return this._part.length}}class ya extends bo{constructor(){super(Object.assign(ki(ya.getDefaults(),arguments,["fade"]))),this.name="CrossFade",this._panner=this.context.createStereoPanner(),this._split=this.context.createChannelSplitter(2),this._g2a=new Cr({context:this.context}),this.a=new So({context:this.context,gain:0}),this.b=new So({context:this.context,gain:0}),this.output=new So({context:this.context}),this._internalChannels=[this.a,this.b];const t=ki(ya.getDefaults(),arguments,["fade"]);this.fade=new Eo({context:this.context,units:"normalRange",value:t.fade}),Hi(this,"fade"),this.context.getConstant(1).connect(this._panner),this._panner.connect(this._split),wo(this._split,this.a.gain,0),wo(this._split,this.b.gain,1),this.fade.chain(this._g2a,this._panner.pan),this.a.connect(this.output),this.b.connect(this.output)}static getDefaults(){return Object.assign(bo.getDefaults(),{fade:.5})}dispose(){return super.dispose(),this.a.dispose(),this.b.dispose(),this.output.dispose(),this.fade.dispose(),this._g2a.dispose(),this._panner.disconnect(),this._split.disconnect(),this}}class wa extends bo{constructor(t){super(t),this.name="Effect",this._dryWet=new ya({context:this.context}),this.wet=this._dryWet.fade,this.effectSend=new So({context:this.context}),this.effectReturn=new So({context:this.context}),this.input=new So({context:this.context}),this.output=this._dryWet,this.input.fan(this._dryWet.a,this.effectSend),this.effectReturn.connect(this._dryWet.b),this.wet.setValueAtTime(t.wet,0),this._internalChannels=[this.effectReturn,this.effectSend],Hi(this,"wet")}static getDefaults(){return Object.assign(bo.getDefaults(),{wet:1})}connectEffect(t){return this._internalChannels.push(t),this.effectSend.chain(t,this.effectReturn),this}dispose(){return super.dispose(),this._dryWet.dispose(),this.effectSend.dispose(),this.effectReturn.dispose(),this.wet.dispose(),this}}class xa extends wa{constructor(t){super(t),this.name="LFOEffect",this._lfo=new _r({context:this.context,frequency:t.frequency,amplitude:t.depth}),this.depth=this._lfo.amplitude,this.frequency=this._lfo.frequency,this.type=t.type,Hi(this,["frequency","depth"])}static getDefaults(){return Object.assign(wa.getDefaults(),{frequency:1,type:"sine",depth:1})}start(t){return this._lfo.start(t),this}stop(t){return this._lfo.stop(t),this}sync(){return this._lfo.sync(),this}unsync(){return this._lfo.unsync(),this}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class Sa extends xa{constructor(){super(ki(Sa.getDefaults(),arguments,["frequency","baseFrequency","octaves"])),this.name="AutoFilter";const t=ki(Sa.getDefaults(),arguments,["frequency","baseFrequency","octaves"]);this.filter=new qr(Object.assign(t.filter,{context:this.context})),this.connectEffect(this.filter),this._lfo.connect(this.filter.frequency),this.octaves=t.octaves,this.baseFrequency=t.baseFrequency}static getDefaults(){return Object.assign(xa.getDefaults(),{baseFrequency:200,octaves:2.6,filter:{type:"lowpass",rolloff:-12,Q:1}})}get baseFrequency(){return this._lfo.min}set baseFrequency(t){this._lfo.min=this.toFrequency(t),this.octaves=this._octaves}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._lfo.max=this._lfo.min*Math.pow(2,t)}dispose(){return super.dispose(),this.filter.dispose(),this}}class Ca extends bo{constructor(){super(Object.assign(ki(Ca.getDefaults(),arguments,["pan"]))),this.name="Panner",this._panner=this.context.createStereoPanner(),this.input=this._panner,this.output=this._panner;const t=ki(Ca.getDefaults(),arguments,["pan"]);this.pan=new vo({context:this.context,param:this._panner.pan,value:t.pan,minValue:-1,maxValue:1}),Hi(this,"pan")}static getDefaults(){return Object.assign(bo.getDefaults(),{pan:0,channelCount:1})}dispose(){return super.dispose(),this._panner.disconnect(),this.pan.dispose(),this}}class ka extends xa{constructor(){super(ki(ka.getDefaults(),arguments,["frequency"])),this.name="AutoPanner";const t=ki(ka.getDefaults(),arguments,["frequency"]);this._panner=new Ca({context:this.context,channelCount:t.channelCount}),this.connectEffect(this._panner),this._lfo.connect(this._panner.pan),this._lfo.min=-1,this._lfo.max=1}static getDefaults(){return Object.assign(xa.getDefaults(),{channelCount:1})}dispose(){return super.dispose(),this._panner.dispose(),this}}class Ea extends bo{constructor(){super(ki(Ea.getDefaults(),arguments,["smoothing"])),this.name="Follower";const t=ki(Ea.getDefaults(),arguments,["smoothing"]);this._abs=this.input=new Sr({context:this.context}),this._lowpass=this.output=new ea({context:this.context,frequency:1/this.toSeconds(t.smoothing),type:"lowpass"}),this._abs.connect(this._lowpass),this._smoothing=t.smoothing}static getDefaults(){return Object.assign(bo.getDefaults(),{smoothing:.05})}get smoothing(){return this._smoothing}set smoothing(t){this._smoothing=t,this._lowpass.frequency=1/this.toSeconds(this.smoothing)}dispose(){return super.dispose(),this._abs.dispose(),this._lowpass.dispose(),this}}class Pa extends wa{constructor(){super(ki(Pa.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"])),this.name="AutoWah";const t=ki(Pa.getDefaults(),arguments,["baseFrequency","octaves","sensitivity"]);this._follower=new Ea({context:this.context,smoothing:t.follower}),this._sweepRange=new Rr({context:this.context,min:0,max:1,exponent:.5}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this._inputBoost=new So({context:this.context}),this._bandpass=new qr({context:this.context,rolloff:-48,frequency:0,Q:t.Q}),this._peaking=new qr({context:this.context,type:"peaking"}),this._peaking.gain.value=t.gain,this.gain=this._peaking.gain,this.Q=this._bandpass.Q,this.effectSend.chain(this._inputBoost,this._follower,this._sweepRange),this._sweepRange.connect(this._bandpass.frequency),this._sweepRange.connect(this._peaking.frequency),this.effectSend.chain(this._bandpass,this._peaking,this.effectReturn),this._setSweepRange(),this.sensitivity=t.sensitivity,Hi(this,["gain","Q"])}static getDefaults(){return Object.assign(wa.getDefaults(),{baseFrequency:100,octaves:6,sensitivity:0,Q:2,gain:2,follower:.2})}get octaves(){return this._octaves}set octaves(t){this._octaves=t,this._setSweepRange()}get follower(){return this._follower.smoothing}set follower(t){this._follower.smoothing=t}get baseFrequency(){return this._baseFrequency}set baseFrequency(t){this._baseFrequency=this.toFrequency(t),this._setSweepRange()}get sensitivity(){return to(1/this._inputBoost.gain.value)}set sensitivity(t){this._inputBoost.gain.value=1/$i(t)}_setSweepRange(){this._sweepRange.min=this._baseFrequency,this._sweepRange.max=Math.min(this._baseFrequency*Math.pow(2,this._octaves),this.context.sampleRate/2)}dispose(){return super.dispose(),this._follower.dispose(),this._sweepRange.dispose(),this._bandpass.dispose(),this._peaking.dispose(),this._inputBoost.dispose(),this}}Jr("bit-crusher","\n\tclass BitCrusherWorklet extends SingleIOProcessor {\n\n\t\tstatic get parameterDescriptors() {\n\t\t\treturn [{\n\t\t\t\tname: \"bits\",\n\t\t\t\tdefaultValue: 12,\n\t\t\t\tminValue: 1,\n\t\t\t\tmaxValue: 16,\n\t\t\t\tautomationRate: 'k-rate'\n\t\t\t}];\n\t\t}\n\n\t\tgenerate(input, _channel, parameters) {\n\t\t\tconst step = Math.pow(0.5, parameters.bits - 1);\n\t\t\tconst val = step * Math.floor(input / step + 0.5);\n\t\t\treturn val;\n\t\t}\n\t}\n");class Ta extends wa{constructor(){super(ki(Ta.getDefaults(),arguments,["bits"])),this.name="BitCrusher";const t=ki(Ta.getDefaults(),arguments,["bits"]);this._bitCrusherWorklet=new Ma({context:this.context,bits:t.bits}),this.connectEffect(this._bitCrusherWorklet),this.bits=this._bitCrusherWorklet.bits}static getDefaults(){return Object.assign(wa.getDefaults(),{bits:4})}dispose(){return super.dispose(),this._bitCrusherWorklet.dispose(),this}}class Ma extends $r{constructor(){super(ki(Ma.getDefaults(),arguments)),this.name="BitCrusherWorklet";const t=ki(Ma.getDefaults(),arguments);this.input=new So({context:this.context}),this.output=new So({context:this.context}),this.bits=new vo({context:this.context,value:t.bits,units:"positive",minValue:1,maxValue:16,param:this._dummyParam,swappable:!0})}static getDefaults(){return Object.assign($r.getDefaults(),{bits:12})}_audioWorkletName(){return"bit-crusher"}onReady(t){yo(this.input,t,this.output);const e=t.parameters.get("bits");this.bits.setParam(e)}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.bits.dispose(),this}}class Ra extends wa{constructor(){super(ki(Ra.getDefaults(),arguments,["order"])),this.name="Chebyshev";const t=ki(Ra.getDefaults(),arguments,["order"]);this._shaper=new ir({context:this.context,length:4096}),this._order=t.order,this.connectEffect(this._shaper),this.order=t.order,this.oversample=t.oversample}static getDefaults(){return Object.assign(wa.getDefaults(),{order:1,oversample:"none"})}_getCoefficient(t,e,n){return n.has(e)||(0===e?n.set(e,0):1===e?n.set(e,t):n.set(e,2*t*this._getCoefficient(t,e-1,n)-this._getCoefficient(t,e-2,n))),n.get(e)}get order(){return this._order}set order(t){this._order=t,this._shaper.setMap(e=>this._getCoefficient(e,t,new Map))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Aa extends bo{constructor(){super(ki(Aa.getDefaults(),arguments,["channels"])),this.name="Split";const t=ki(Aa.getDefaults(),arguments,["channels"]);this._splitter=this.input=this.output=this.context.createChannelSplitter(t.channels),this._internalChannels=[this._splitter]}static getDefaults(){return Object.assign(bo.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._splitter.disconnect(),this}}class Oa extends bo{constructor(){super(ki(Oa.getDefaults(),arguments,["channels"])),this.name="Merge";const t=ki(Oa.getDefaults(),arguments,["channels"]);this._merger=this.output=this.input=this.context.createChannelMerger(t.channels)}static getDefaults(){return Object.assign(bo.getDefaults(),{channels:2})}dispose(){return super.dispose(),this._merger.disconnect(),this}}class Na extends bo{constructor(t){super(t),this.name="StereoEffect",this.input=new So({context:this.context}),this.input.channelCount=2,this.input.channelCountMode="explicit",this._dryWet=this.output=new ya({context:this.context,fade:t.wet}),this.wet=this._dryWet.fade,this._split=new Aa({context:this.context,channels:2}),this._merge=new Oa({context:this.context,channels:2}),this.input.connect(this._split),this.input.connect(this._dryWet.a),this._merge.connect(this._dryWet.b),Hi(this,["wet"])}connectEffectLeft(...t){this._split.connect(t[0],0,0),yo(...t),wo(t[t.length-1],this._merge,0,0)}connectEffectRight(...t){this._split.connect(t[0],1,0),yo(...t),wo(t[t.length-1],this._merge,0,1)}static getDefaults(){return Object.assign(bo.getDefaults(),{wet:1})}dispose(){return super.dispose(),this._dryWet.dispose(),this._split.dispose(),this._merge.dispose(),this}}class Da extends Na{constructor(t){super(t),this.feedback=new Eo({context:this.context,value:t.feedback,units:"normalRange"}),this._feedbackL=new So({context:this.context}),this._feedbackR=new So({context:this.context}),this._feedbackSplit=new Aa({context:this.context,channels:2}),this._feedbackMerge=new Oa({context:this.context,channels:2}),this._merge.connect(this._feedbackSplit),this._feedbackMerge.connect(this._split),this._feedbackSplit.connect(this._feedbackL,0,0),this._feedbackL.connect(this._feedbackMerge,0,0),this._feedbackSplit.connect(this._feedbackR,1,0),this._feedbackR.connect(this._feedbackMerge,0,1),this.feedback.fan(this._feedbackL.gain,this._feedbackR.gain),Hi(this,["feedback"])}static getDefaults(){return Object.assign(Na.getDefaults(),{feedback:.5})}dispose(){return super.dispose(),this.feedback.dispose(),this._feedbackL.dispose(),this._feedbackR.dispose(),this._feedbackSplit.dispose(),this._feedbackMerge.dispose(),this}}class Ba extends Da{constructor(){super(ki(Ba.getDefaults(),arguments,["frequency","delayTime","depth"])),this.name="Chorus";const t=ki(Ba.getDefaults(),arguments,["frequency","delayTime","depth"]);this._depth=t.depth,this._delayTime=t.delayTime/1e3,this._lfoL=new _r({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new _r({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._delayNodeL=new Oo({context:this.context}),this._delayNodeR=new Oo({context:this.context}),this.frequency=this._lfoL.frequency,Hi(this,["frequency"]),this._lfoL.frequency.connect(this._lfoR.frequency),this.connectEffectLeft(this._delayNodeL),this.connectEffectRight(this._delayNodeR),this._lfoL.connect(this._delayNodeL.delayTime),this._lfoR.connect(this._delayNodeR.delayTime),this.depth=this._depth,this.type=t.type,this.spread=t.spread}static getDefaults(){return Object.assign(Da.getDefaults(),{frequency:1.5,delayTime:3.5,depth:.7,type:"sine",spread:180,feedback:0,wet:.5})}get depth(){return this._depth}set depth(t){this._depth=t;const e=this._delayTime*t;this._lfoL.min=Math.max(this._delayTime-e,0),this._lfoL.max=this._delayTime+e,this._lfoR.min=Math.max(this._delayTime-e,0),this._lfoR.max=this._delayTime+e}get delayTime(){return 1e3*this._delayTime}set delayTime(t){this._delayTime=t/1e3,this.depth=this._depth}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._delayNodeL.dispose(),this._delayNodeR.dispose(),this.frequency.dispose(),this}}class Ia extends wa{constructor(){super(ki(Ia.getDefaults(),arguments,["distortion"])),this.name="Distortion";const t=ki(Ia.getDefaults(),arguments,["distortion"]);this._shaper=new ir({context:this.context,length:4096}),this._distortion=t.distortion,this.connectEffect(this._shaper),this.distortion=t.distortion,this.oversample=t.oversample}static getDefaults(){return Object.assign(wa.getDefaults(),{distortion:.4,oversample:"none"})}get distortion(){return this._distortion}set distortion(t){this._distortion=t;const e=100*t,n=Math.PI/180;this._shaper.setMap(t=>Math.abs(t)<.001?0:(3+e)*t*20*n/(Math.PI+e*Math.abs(t)))}get oversample(){return this._shaper.oversample}set oversample(t){this._shaper.oversample=t}dispose(){return super.dispose(),this._shaper.dispose(),this}}class Fa extends wa{constructor(t){super(t),this.name="FeedbackEffect",this._feedbackGain=new So({context:this.context,gain:t.feedback,units:"normalRange"}),this.feedback=this._feedbackGain.gain,Hi(this,"feedback"),this.effectReturn.chain(this._feedbackGain,this.effectSend)}static getDefaults(){return Object.assign(wa.getDefaults(),{feedback:.125})}dispose(){return super.dispose(),this._feedbackGain.dispose(),this.feedback.dispose(),this}}class Va extends Fa{constructor(){super(ki(Va.getDefaults(),arguments,["delayTime","feedback"])),this.name="FeedbackDelay";const t=ki(Va.getDefaults(),arguments,["delayTime","feedback"]);this._delayNode=new Oo({context:this.context,delayTime:t.delayTime,maxDelay:t.maxDelay}),this.delayTime=this._delayNode.delayTime,this.connectEffect(this._delayNode),Hi(this,"delayTime")}static getDefaults(){return Object.assign(Fa.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._delayNode.dispose(),this.delayTime.dispose(),this}}class ja extends bo{constructor(t){super(t),this.name="PhaseShiftAllpass",this.input=new So({context:this.context}),this.output=new So({context:this.context}),this.offset90=new So({context:this.context}),this._bank0=this._createAllPassFilterBank([.6923878,.9360654322959,.988229522686,.9987488452737]),this._bank1=this._createAllPassFilterBank([.4021921162426,.856171088242,.9722909545651,.9952884791278]),this._oneSampleDelay=this.context.createIIRFilter([0,1],[1,0]),yo(this.input,...this._bank0,this._oneSampleDelay,this.output),yo(this.input,...this._bank1,this.offset90)}_createAllPassFilterBank(t){return t.map(t=>{const e=[[t*t,0,-1],[1,0,-t*t]];return this.context.createIIRFilter(e[0],e[1])})}dispose(){return super.dispose(),this.input.dispose(),this.output.dispose(),this.offset90.dispose(),this._bank0.forEach(t=>t.disconnect()),this._bank1.forEach(t=>t.disconnect()),this._oneSampleDelay.disconnect(),this}}class La extends wa{constructor(){super(ki(La.getDefaults(),arguments,["frequency"])),this.name="FrequencyShifter";const t=ki(La.getDefaults(),arguments,["frequency"]);this.frequency=new Eo({context:this.context,units:"frequency",value:t.frequency,minValue:-this.context.sampleRate/2,maxValue:this.context.sampleRate/2}),this._sine=new er({context:this.context,type:"sine"}),this._cosine=new nr({context:this.context,phase:-90,type:"sine"}),this._sineMultiply=new rr({context:this.context}),this._cosineMultiply=new rr({context:this.context}),this._negate=new kr({context:this.context}),this._add=new mr({context:this.context}),this._phaseShifter=new ja({context:this.context}),this.effectSend.connect(this._phaseShifter),this.frequency.fan(this._sine.frequency,this._cosine.frequency),this._phaseShifter.offset90.connect(this._cosineMultiply),this._cosine.connect(this._cosineMultiply.factor),this._phaseShifter.connect(this._sineMultiply),this._sine.connect(this._sineMultiply.factor),this._sineMultiply.connect(this._negate),this._cosineMultiply.connect(this._add),this._negate.connect(this._add.addend),this._add.connect(this.effectReturn);const e=this.immediate();this._sine.start(e),this._cosine.start(e)}static getDefaults(){return Object.assign(wa.getDefaults(),{frequency:0})}dispose(){return super.dispose(),this.frequency.dispose(),this._add.dispose(),this._cosine.dispose(),this._cosineMultiply.dispose(),this._negate.dispose(),this._phaseShifter.dispose(),this._sine.dispose(),this._sineMultiply.dispose(),this}}const qa=[1557/44100,1617/44100,1491/44100,1422/44100,1277/44100,1356/44100,1188/44100,1116/44100],Ua=[225,556,441,341];class Ha extends Na{constructor(){super(ki(Ha.getDefaults(),arguments,["roomSize","dampening"])),this.name="Freeverb",this._combFilters=[],this._allpassFiltersL=[],this._allpassFiltersR=[];const t=ki(Ha.getDefaults(),arguments,["roomSize","dampening"]);this.roomSize=new Eo({context:this.context,value:t.roomSize,units:"normalRange"}),this._allpassFiltersL=Ua.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._allpassFiltersR=Ua.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._combFilters=qa.map((e,n)=>{const s=new na({context:this.context,dampening:t.dampening,delayTime:e});return ne.dampening=t)}dispose(){return super.dispose(),this._allpassFiltersL.forEach(t=>t.disconnect()),this._allpassFiltersR.forEach(t=>t.disconnect()),this._combFilters.forEach(t=>t.dispose()),this.roomSize.dispose(),this}}const Wa=[.06748,.06404,.08212,.09004],Qa=[.773,.802,.753,.733],Xa=[347,113,37];class za extends Na{constructor(){super(ki(za.getDefaults(),arguments,["roomSize"])),this.name="JCReverb",this._allpassFilters=[],this._feedbackCombFilters=[];const t=ki(za.getDefaults(),arguments,["roomSize"]);this.roomSize=new Eo({context:this.context,value:t.roomSize,units:"normalRange"}),this._scaleRoomSize=new fr({context:this.context,min:-.733,max:.197}),this._allpassFilters=Xa.map(t=>{const e=this.context.createBiquadFilter();return e.type="allpass",e.frequency.value=t,e}),this._feedbackCombFilters=Wa.map((t,e)=>{const n=new ta({context:this.context,delayTime:t});return this._scaleRoomSize.connect(n.resonance),n.resonance.value=Qa[e],et.disconnect()),this._feedbackCombFilters.forEach(t=>t.dispose()),this.roomSize.dispose(),this._scaleRoomSize.dispose(),this}}class Ga extends Da{constructor(t){super(t),this._feedbackL.disconnect(),this._feedbackL.connect(this._feedbackMerge,0,1),this._feedbackR.disconnect(),this._feedbackR.connect(this._feedbackMerge,0,0),Hi(this,["feedback"])}}class Ya extends Ga{constructor(){super(ki(Ya.getDefaults(),arguments,["delayTime","feedback"])),this.name="PingPongDelay";const t=ki(Ya.getDefaults(),arguments,["delayTime","feedback"]);this._leftDelay=new Oo({context:this.context,maxDelay:t.maxDelay}),this._rightDelay=new Oo({context:this.context,maxDelay:t.maxDelay}),this._rightPreDelay=new Oo({context:this.context,maxDelay:t.maxDelay}),this.delayTime=new Eo({context:this.context,units:"time",value:t.delayTime}),this.connectEffectLeft(this._leftDelay),this.connectEffectRight(this._rightPreDelay,this._rightDelay),this.delayTime.fan(this._leftDelay.delayTime,this._rightDelay.delayTime,this._rightPreDelay.delayTime),this._feedbackL.disconnect(),this._feedbackL.connect(this._rightDelay),Hi(this,["delayTime"])}static getDefaults(){return Object.assign(Ga.getDefaults(),{delayTime:.25,maxDelay:1})}dispose(){return super.dispose(),this._leftDelay.dispose(),this._rightDelay.dispose(),this._rightPreDelay.dispose(),this.delayTime.dispose(),this}}class Ka extends Fa{constructor(){super(ki(Ka.getDefaults(),arguments,["pitch"])),this.name="PitchShift";const t=ki(Ka.getDefaults(),arguments,["pitch"]);this._frequency=new Eo({context:this.context}),this._delayA=new Oo({maxDelay:1,context:this.context}),this._lfoA=new _r({context:this.context,min:0,max:.1,type:"sawtooth"}).connect(this._delayA.delayTime),this._delayB=new Oo({maxDelay:1,context:this.context}),this._lfoB=new _r({context:this.context,min:0,max:.1,type:"sawtooth",phase:180}).connect(this._delayB.delayTime),this._crossFade=new ya({context:this.context}),this._crossFadeLFO=new _r({context:this.context,min:0,max:1,type:"triangle",phase:90}).connect(this._crossFade.fade),this._feedbackDelay=new Oo({delayTime:t.delayTime,context:this.context}),this.delayTime=this._feedbackDelay.delayTime,Hi(this,"delayTime"),this._pitch=t.pitch,this._windowSize=t.windowSize,this._delayA.connect(this._crossFade.a),this._delayB.connect(this._crossFade.b),this._frequency.fan(this._lfoA.frequency,this._lfoB.frequency,this._crossFadeLFO.frequency),this.effectSend.fan(this._delayA,this._delayB),this._crossFade.chain(this._feedbackDelay,this.effectReturn);const e=this.now();this._lfoA.start(e),this._lfoB.start(e),this._crossFadeLFO.start(e),this.windowSize=this._windowSize}static getDefaults(){return Object.assign(Fa.getDefaults(),{pitch:0,windowSize:.1,delayTime:0,feedback:0})}get pitch(){return this._pitch}set pitch(t){this._pitch=t;let e=0;t<0?(this._lfoA.min=0,this._lfoA.max=this._windowSize,this._lfoB.min=0,this._lfoB.max=this._windowSize,e=eo(t-1)+1):(this._lfoA.min=this._windowSize,this._lfoA.max=0,this._lfoB.min=this._windowSize,this._lfoB.max=0,e=eo(t)-1),this._frequency.value=e*(1.2/this._windowSize)}get windowSize(){return this._windowSize}set windowSize(t){this._windowSize=this.toSeconds(t),this.pitch=this._pitch}dispose(){return super.dispose(),this._frequency.dispose(),this._delayA.dispose(),this._delayB.dispose(),this._lfoA.dispose(),this._lfoB.dispose(),this._crossFade.dispose(),this._crossFadeLFO.dispose(),this._feedbackDelay.dispose(),this}}class Za extends Na{constructor(){super(ki(Za.getDefaults(),arguments,["frequency","octaves","baseFrequency"])),this.name="Phaser";const t=ki(Za.getDefaults(),arguments,["frequency","octaves","baseFrequency"]);this._lfoL=new _r({context:this.context,frequency:t.frequency,min:0,max:1}),this._lfoR=new _r({context:this.context,frequency:t.frequency,min:0,max:1,phase:180}),this._baseFrequency=this.toFrequency(t.baseFrequency),this._octaves=t.octaves,this.Q=new Eo({context:this.context,value:t.Q,units:"positive"}),this._filtersL=this._makeFilters(t.stages,this._lfoL),this._filtersR=this._makeFilters(t.stages,this._lfoR),this.frequency=this._lfoL.frequency,this.frequency.value=t.frequency,this.connectEffectLeft(...this._filtersL),this.connectEffectRight(...this._filtersR),this._lfoL.frequency.connect(this._lfoR.frequency),this.baseFrequency=t.baseFrequency,this.octaves=t.octaves,this._lfoL.start(),this._lfoR.start(),Hi(this,["frequency","Q"])}static getDefaults(){return Object.assign(Na.getDefaults(),{frequency:.5,octaves:3,stages:10,Q:10,baseFrequency:350})}_makeFilters(t,e){const n=[];for(let s=0;st.disconnect()),this._filtersR.forEach(t=>t.disconnect()),this.frequency.dispose(),this}}class Ja extends wa{constructor(){super(ki(Ja.getDefaults(),arguments,["decay"])),this.name="Reverb",this._convolver=this.context.createConvolver(),this.ready=Promise.resolve();const t=ki(Ja.getDefaults(),arguments,["decay"]);this._decay=t.decay,this._preDelay=t.preDelay,this.generate(),this.connectEffect(this._convolver)}static getDefaults(){return Object.assign(wa.getDefaults(),{decay:1.5,preDelay:.01})}get decay(){return this._decay}set decay(t){Ys(t=this.toSeconds(t),.001),this._decay=t,this.generate()}get preDelay(){return this._preDelay}set preDelay(t){Ys(t=this.toSeconds(t),0),this._preDelay=t,this.generate()}generate(){return gi(this,void 0,void 0,(function*(){const t=this.ready,e=new zi(2,this._decay+this._preDelay,this.context.sampleRate),n=new Ko({context:e}),s=new Ko({context:e}),i=new Oa({context:e});n.connect(i,0,0),s.connect(i,0,1);const o=new So({context:e}).toDestination();i.connect(o),n.start(0),s.start(0),o.gain.setValueAtTime(0,0),o.gain.setValueAtTime(1,this._preDelay),o.gain.exponentialApproachValueAtTime(0,this._preDelay,this.decay);const r=e.render();return this.ready=r.then(Qi),yield t,this._convolver.buffer=(yield r).get(),this}))}dispose(){return super.dispose(),this._convolver.disconnect(),this}}class $a extends bo{constructor(){super(ki($a.getDefaults(),arguments)),this.name="MidSideSplit",this._split=this.input=new Aa({channels:2,context:this.context}),this._midAdd=new mr({context:this.context}),this.mid=new rr({context:this.context,value:Math.SQRT1_2}),this._sideSubtract=new Er({context:this.context}),this.side=new rr({context:this.context,value:Math.SQRT1_2}),this._split.connect(this._midAdd,0),this._split.connect(this._midAdd.addend,1),this._split.connect(this._sideSubtract,0),this._split.connect(this._sideSubtract.subtrahend,1),this._midAdd.connect(this.mid),this._sideSubtract.connect(this.side)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midAdd.dispose(),this._sideSubtract.dispose(),this._split.dispose(),this}}class tl extends bo{constructor(){super(ki(tl.getDefaults(),arguments)),this.name="MidSideMerge",this.mid=new So({context:this.context}),this.side=new So({context:this.context}),this._left=new mr({context:this.context}),this._leftMult=new rr({context:this.context,value:Math.SQRT1_2}),this._right=new Er({context:this.context}),this._rightMult=new rr({context:this.context,value:Math.SQRT1_2}),this._merge=this.output=new Oa({context:this.context}),this.mid.fan(this._left),this.side.connect(this._left.addend),this.mid.connect(this._right),this.side.connect(this._right.subtrahend),this._left.connect(this._leftMult),this._right.connect(this._rightMult),this._leftMult.connect(this._merge,0,0),this._rightMult.connect(this._merge,0,1)}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._leftMult.dispose(),this._rightMult.dispose(),this._left.dispose(),this._right.dispose(),this}}class el extends wa{constructor(t){super(t),this.name="MidSideEffect",this._midSideMerge=new tl({context:this.context}),this._midSideSplit=new $a({context:this.context}),this._midSend=this._midSideSplit.mid,this._sideSend=this._midSideSplit.side,this._midReturn=this._midSideMerge.mid,this._sideReturn=this._midSideMerge.side,this.effectSend.connect(this._midSideSplit),this._midSideMerge.connect(this.effectReturn)}connectEffectMid(...t){this._midSend.chain(...t,this._midReturn)}connectEffectSide(...t){this._sideSend.chain(...t,this._sideReturn)}dispose(){return super.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this._midSend.dispose(),this._sideSend.dispose(),this._midReturn.dispose(),this._sideReturn.dispose(),this}}class nl extends el{constructor(){super(ki(nl.getDefaults(),arguments,["width"])),this.name="StereoWidener";const t=ki(nl.getDefaults(),arguments,["width"]);this.width=new Eo({context:this.context,value:t.width,units:"normalRange"}),Hi(this,["width"]),this._twoTimesWidthMid=new rr({context:this.context,value:2}),this._twoTimesWidthSide=new rr({context:this.context,value:2}),this._midMult=new rr({context:this.context}),this._twoTimesWidthMid.connect(this._midMult.factor),this.connectEffectMid(this._midMult),this._oneMinusWidth=new Er({context:this.context}),this._oneMinusWidth.connect(this._twoTimesWidthMid),wo(this.context.getConstant(1),this._oneMinusWidth),this.width.connect(this._oneMinusWidth.subtrahend),this._sideMult=new rr({context:this.context}),this.width.connect(this._twoTimesWidthSide),this._twoTimesWidthSide.connect(this._sideMult.factor),this.connectEffectSide(this._sideMult)}static getDefaults(){return Object.assign(el.getDefaults(),{width:.5})}dispose(){return super.dispose(),this.width.dispose(),this._midMult.dispose(),this._sideMult.dispose(),this._twoTimesWidthMid.dispose(),this._twoTimesWidthSide.dispose(),this._oneMinusWidth.dispose(),this}}class sl extends Na{constructor(){super(ki(sl.getDefaults(),arguments,["frequency","depth"])),this.name="Tremolo";const t=ki(sl.getDefaults(),arguments,["frequency","depth"]);this._lfoL=new _r({context:this.context,type:t.type,min:1,max:0}),this._lfoR=new _r({context:this.context,type:t.type,min:1,max:0}),this._amplitudeL=new So({context:this.context}),this._amplitudeR=new So({context:this.context}),this.frequency=new Eo({context:this.context,value:t.frequency,units:"frequency"}),this.depth=new Eo({context:this.context,value:t.depth,units:"normalRange"}),Hi(this,["frequency","depth"]),this.connectEffectLeft(this._amplitudeL),this.connectEffectRight(this._amplitudeR),this._lfoL.connect(this._amplitudeL.gain),this._lfoR.connect(this._amplitudeR.gain),this.frequency.fan(this._lfoL.frequency,this._lfoR.frequency),this.depth.fan(this._lfoR.amplitude,this._lfoL.amplitude),this.spread=t.spread}static getDefaults(){return Object.assign(Na.getDefaults(),{frequency:10,type:"sine",depth:.5,spread:180})}start(t){return this._lfoL.start(t),this._lfoR.start(t),this}stop(t){return this._lfoL.stop(t),this._lfoR.stop(t),this}sync(){return this._lfoL.sync(),this._lfoR.sync(),this.context.transport.syncSignal(this.frequency),this}unsync(){return this._lfoL.unsync(),this._lfoR.unsync(),this.context.transport.unsyncSignal(this.frequency),this}get type(){return this._lfoL.type}set type(t){this._lfoL.type=t,this._lfoR.type=t}get spread(){return this._lfoR.phase-this._lfoL.phase}set spread(t){this._lfoL.phase=90-t/2,this._lfoR.phase=t/2+90}dispose(){return super.dispose(),this._lfoL.dispose(),this._lfoR.dispose(),this._amplitudeL.dispose(),this._amplitudeR.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class il extends wa{constructor(){super(ki(il.getDefaults(),arguments,["frequency","depth"])),this.name="Vibrato";const t=ki(il.getDefaults(),arguments,["frequency","depth"]);this._delayNode=new Oo({context:this.context,delayTime:0,maxDelay:t.maxDelay}),this._lfo=new _r({context:this.context,type:t.type,min:0,max:t.maxDelay,frequency:t.frequency,phase:-90}).start().connect(this._delayNode.delayTime),this.frequency=this._lfo.frequency,this.depth=this._lfo.amplitude,this.depth.value=t.depth,Hi(this,["frequency","depth"]),this.effectSend.chain(this._delayNode,this.effectReturn)}static getDefaults(){return Object.assign(wa.getDefaults(),{maxDelay:.005,frequency:5,depth:.1,type:"sine"})}get type(){return this._lfo.type}set type(t){this._lfo.type=t}dispose(){return super.dispose(),this._delayNode.dispose(),this._lfo.dispose(),this.frequency.dispose(),this.depth.dispose(),this}}class ol extends bo{constructor(){super(ki(ol.getDefaults(),arguments,["type","size"])),this.name="Analyser",this._analysers=[],this._buffers=[];const t=ki(ol.getDefaults(),arguments,["type","size"]);this.input=this.output=this._gain=new So({context:this.context}),this._split=new Aa({context:this.context,channels:t.channels}),this.input.connect(this._split),Ys(t.channels,1);for(let e=0;e{const n=this._buffers[e];"fft"===this._type?t.getFloatFrequencyData(n):"waveform"===this._type&&t.getFloatTimeDomainData(n)}),1===this.channels?this._buffers[0]:this._buffers}get size(){return this._analysers[0].frequencyBinCount}set size(t){this._analysers.forEach((e,n)=>{e.fftSize=2*t,this._buffers[n]=new Float32Array(t)})}get channels(){return this._analysers.length}get type(){return this._type}set type(t){Gs("waveform"===t||"fft"===t,"Analyser: invalid type: "+t),this._type=t}get smoothing(){return this._analysers[0].smoothingTimeConstant}set smoothing(t){this._analysers.forEach(e=>e.smoothingTimeConstant=t)}dispose(){return super.dispose(),this._analysers.forEach(t=>t.disconnect()),this._split.dispose(),this._gain.dispose(),this}}class rl extends bo{constructor(){super(ki(rl.getDefaults(),arguments)),this.name="MeterBase",this.input=this.output=this._analyser=new ol({context:this.context,size:256,type:"waveform"})}dispose(){return super.dispose(),this._analyser.dispose(),this}}class al extends rl{constructor(){super(ki(al.getDefaults(),arguments,["smoothing"])),this.name="Meter",this._rms=0;const t=ki(al.getDefaults(),arguments,["smoothing"]);this.input=this.output=this._analyser=new ol({context:this.context,size:256,type:"waveform",channels:t.channels}),this.smoothing=t.smoothing,this.normalRange=t.normalRange}static getDefaults(){return Object.assign(rl.getDefaults(),{smoothing:.8,normalRange:!1,channels:1})}getLevel(){return ti("'getLevel' has been changed to 'getValue'"),this.getValue()}getValue(){const t=this._analyser.getValue(),e=(1===this.channels?[t]:t).map(t=>{const e=t.reduce((t,e)=>t+e*e,0),n=Math.sqrt(e/t.length);return this._rms=Math.max(n,this._rms*this.smoothing),this.normalRange?this._rms:to(this._rms)});return 1===this.channels?e[0]:e}get channels(){return this._analyser.channels}dispose(){return super.dispose(),this._analyser.dispose(),this}}class ll extends rl{constructor(){super(ki(ll.getDefaults(),arguments,["size"])),this.name="FFT";const t=ki(ll.getDefaults(),arguments,["size"]);this.normalRange=t.normalRange,this._analyser.type="fft",this.size=t.size}static getDefaults(){return Object.assign(bo.getDefaults(),{normalRange:!1,size:1024,smoothing:.8})}getValue(){return this._analyser.getValue().map(t=>this.normalRange?$i(t):t)}get size(){return this._analyser.size}set size(t){this._analyser.size=t}get smoothing(){return this._analyser.smoothing}set smoothing(t){this._analyser.smoothing=t}getFrequencyOfIndex(t){return Gs(0<=t&&tt._updateSolo())}get muted(){return 0===this.input.gain.value}_addSolo(){ul._soloed.has(this.context)||ul._soloed.set(this.context,new Set),ul._soloed.get(this.context).add(this)}_removeSolo(){ul._soloed.has(this.context)&&ul._soloed.get(this.context).delete(this)}_isSoloed(){return ul._soloed.has(this.context)&&ul._soloed.get(this.context).has(this)}_noSolos(){return!ul._soloed.has(this.context)||ul._soloed.has(this.context)&&0===ul._soloed.get(this.context).size}_updateSolo(){this._isSoloed()||this._noSolos()?this.input.gain.value=1:this.input.gain.value=0}dispose(){return super.dispose(),ul._allSolos.get(this.context).delete(this),this._removeSolo(),this}}ul._allSolos=new Map,ul._soloed=new Map;class pl extends bo{constructor(){super(ki(pl.getDefaults(),arguments,["pan","volume"])),this.name="PanVol";const t=ki(pl.getDefaults(),arguments,["pan","volume"]);this._panner=this.input=new Ca({context:this.context,pan:t.pan,channelCount:t.channelCount}),this.pan=this._panner.pan,this._volume=this.output=new Uo({context:this.context,volume:t.volume}),this.volume=this._volume.volume,this._panner.connect(this._volume),this.mute=t.mute,Hi(this,["pan","volume"])}static getDefaults(){return Object.assign(bo.getDefaults(),{mute:!1,pan:0,volume:0,channelCount:1})}get mute(){return this._volume.mute}set mute(t){this._volume.mute=t}dispose(){return super.dispose(),this._panner.dispose(),this.pan.dispose(),this._volume.dispose(),this.volume.dispose(),this}}class dl extends bo{constructor(){super(ki(dl.getDefaults(),arguments,["volume","pan"])),this.name="Channel";const t=ki(dl.getDefaults(),arguments,["volume","pan"]);this._solo=this.input=new ul({solo:t.solo,context:this.context}),this._panVol=this.output=new pl({context:this.context,pan:t.pan,volume:t.volume,mute:t.mute,channelCount:t.channelCount}),this.pan=this._panVol.pan,this.volume=this._panVol.volume,this._solo.connect(this._panVol),Hi(this,["pan","volume"])}static getDefaults(){return Object.assign(bo.getDefaults(),{pan:0,volume:0,mute:!1,solo:!1,channelCount:1})}get solo(){return this._solo.solo}set solo(t){this._solo.solo=t}get muted(){return this._solo.muted||this.mute}get mute(){return this._panVol.mute}set mute(t){this._panVol.mute=t}_getBus(t){return dl.buses.has(t)||dl.buses.set(t,new So({context:this.context})),dl.buses.get(t)}send(t,e=0){const n=this._getBus(t),s=new So({context:this.context,units:"decibels",gain:e});return this.connect(s),s.connect(n),s}receive(t){return this._getBus(t).connect(this),this}dispose(){return super.dispose(),this._panVol.dispose(),this.pan.dispose(),this.volume.dispose(),this._solo.dispose(),this}}dl.buses=new Map;class ml extends bo{constructor(){super(ki(ml.getDefaults(),arguments)),this.name="Mono",this.input=new So({context:this.context}),this._merge=this.output=new Oa({channels:2,context:this.context}),this.input.connect(this._merge,0,0),this.input.connect(this._merge,0,1)}dispose(){return super.dispose(),this._merge.dispose(),this.input.dispose(),this}}class fl extends bo{constructor(){super(ki(fl.getDefaults(),arguments,["lowFrequency","highFrequency"])),this.name="MultibandSplit",this.input=new So({context:this.context}),this.output=void 0,this.low=new qr({context:this.context,frequency:0,type:"lowpass"}),this._lowMidFilter=new qr({context:this.context,frequency:0,type:"highpass"}),this.mid=new qr({context:this.context,frequency:0,type:"lowpass"}),this.high=new qr({context:this.context,frequency:0,type:"highpass"}),this._internalChannels=[this.low,this.mid,this.high];const t=ki(fl.getDefaults(),arguments,["lowFrequency","highFrequency"]);this.lowFrequency=new Eo({context:this.context,units:"frequency",value:t.lowFrequency}),this.highFrequency=new Eo({context:this.context,units:"frequency",value:t.highFrequency}),this.Q=new Eo({context:this.context,units:"positive",value:t.Q}),this.input.fan(this.low,this.high),this.input.chain(this._lowMidFilter,this.mid),this.lowFrequency.fan(this.low.frequency,this._lowMidFilter.frequency),this.highFrequency.fan(this.mid.frequency,this.high.frequency),this.Q.connect(this.low.Q),this.Q.connect(this._lowMidFilter.Q),this.Q.connect(this.mid.Q),this.Q.connect(this.high.Q),Hi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(bo.getDefaults(),{Q:1,highFrequency:2500,lowFrequency:400})}dispose(){return super.dispose(),Wi(this,["high","mid","low","highFrequency","lowFrequency"]),this.low.dispose(),this._lowMidFilter.dispose(),this.mid.dispose(),this.high.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this.Q.dispose(),this}}class gl extends bo{constructor(){super(...arguments),this.name="Listener",this.positionX=new vo({context:this.context,param:this.context.rawContext.listener.positionX}),this.positionY=new vo({context:this.context,param:this.context.rawContext.listener.positionY}),this.positionZ=new vo({context:this.context,param:this.context.rawContext.listener.positionZ}),this.forwardX=new vo({context:this.context,param:this.context.rawContext.listener.forwardX}),this.forwardY=new vo({context:this.context,param:this.context.rawContext.listener.forwardY}),this.forwardZ=new vo({context:this.context,param:this.context.rawContext.listener.forwardZ}),this.upX=new vo({context:this.context,param:this.context.rawContext.listener.upX}),this.upY=new vo({context:this.context,param:this.context.rawContext.listener.upY}),this.upZ=new vo({context:this.context,param:this.context.rawContext.listener.upZ})}static getDefaults(){return Object.assign(bo.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this.forwardX.dispose(),this.forwardY.dispose(),this.forwardZ.dispose(),this.upX.dispose(),this.upY.dispose(),this.upZ.dispose(),this}}class _l extends bo{constructor(t){super(),this.context=t,this.name="PolyfillListener",this._orientation=[0,0,0,0,0,0],this._position=[0,0,0],this.setPosition=(t,e,n)=>{this.context.rawContext.listener.setPosition(t,e,n),this._position=[t,e,n]}}get positionX(){return this._position[0]}set positionX(t){this.setPosition(t,this._position[1],this._position[2])}get positionY(){return this._position[1]}set positionY(t){this.setPosition(this._position[0],t,this._position[2])}get positionZ(){return this._position[2]}set positionZ(t){this.setPosition(this._position[0],this._position[1],t)}get forwardX(){return this._orientation[0]}set forwardX(t){this._orientation[0]=t,this.setOrientation.apply(this,this._orientation)}get forwardY(){return this._orientation[1]}set forwardY(t){this._orientation[1]=t,this.setOrientation.apply(this,this._orientation)}get forwardZ(){return this._orientation[2]}set forwardZ(t){this._orientation[2]=t,this.setOrientation.apply(this,this._orientation)}get upX(){return this._orientation[3]}set upX(t){this._orientation[3]=t,this.setOrientation.apply(this,this._orientation)}get upY(){return this._orientation[4]}set upY(t){this._orientation[4]=t,this.setOrientation.apply(this,this._orientation)}get upZ(){return this._orientation[5]}set upZ(t){this._orientation[5]=t,this.setOrientation.apply(this,this._orientation)}setOrientation(t,e,n,s,i,o){this.context.rawContext.listener.setOrientation(t,e,n,s,i,o),this._orientation=[t,e,n,s,i,o]}static getDefaults(){return Object.assign(bo.getDefaults(),{positionX:0,positionY:0,positionZ:0,forwardX:0,forwardY:0,forwardZ:-1,upX:0,upY:1,upZ:0})}dispose(){return super.dispose(),this._orientation=null,this._position=null,this}}Fi(t=>{t.rawContext.listener.forwardX?t.listener=new gl({context:t}):t.listener=new _l(t)}),ji(t=>{t.listener.dispose()});class vl extends bo{constructor(){super(ki(vl.getDefaults(),arguments,["positionX","positionY","positionZ"])),this.name="Panner3D";const t=ki(vl.getDefaults(),arguments,["positionX","positionY","positionZ"]);this._panner=this.input=this.output=this.context.createPanner(),this.panningModel=t.panningModel,this.maxDistance=t.maxDistance,this.distanceModel=t.distanceModel,this.coneOuterGain=t.coneOuterGain,this.coneOuterAngle=t.coneOuterAngle,this.coneInnerAngle=t.coneInnerAngle,this.refDistance=t.refDistance,this.rolloffFactor=t.rolloffFactor,this.positionX=new vo({context:this.context,param:this._panner.positionX,value:t.positionX}),this.positionY=new vo({context:this.context,param:this._panner.positionY,value:t.positionY}),this.positionZ=new vo({context:this.context,param:this._panner.positionZ,value:t.positionZ}),this.orientationX=new vo({context:this.context,param:this._panner.orientationX,value:t.orientationX}),this.orientationY=new vo({context:this.context,param:this._panner.orientationY,value:t.orientationY}),this.orientationZ=new vo({context:this.context,param:this._panner.orientationZ,value:t.orientationZ})}static getDefaults(){return Object.assign(bo.getDefaults(),{coneInnerAngle:360,coneOuterAngle:360,coneOuterGain:0,distanceModel:"inverse",maxDistance:1e4,orientationX:0,orientationY:0,orientationZ:0,panningModel:"equalpower",positionX:0,positionY:0,positionZ:0,refDistance:1,rolloffFactor:1})}setPosition(t,e,n){return this.positionX.value=t,this.positionY.value=e,this.positionZ.value=n,this}setOrientation(t,e,n){return this.orientationX.value=t,this.orientationY.value=e,this.orientationZ.value=n,this}get panningModel(){return this._panner.panningModel}set panningModel(t){this._panner.panningModel=t}get refDistance(){return this._panner.refDistance}set refDistance(t){this._panner.refDistance=t}get rolloffFactor(){return this._panner.rolloffFactor}set rolloffFactor(t){this._panner.rolloffFactor=t}get distanceModel(){return this._panner.distanceModel}set distanceModel(t){this._panner.distanceModel=t}get coneInnerAngle(){return this._panner.coneInnerAngle}set coneInnerAngle(t){this._panner.coneInnerAngle=t}get coneOuterAngle(){return this._panner.coneOuterAngle}set coneOuterAngle(t){this._panner.coneOuterAngle=t}get coneOuterGain(){return this._panner.coneOuterGain}set coneOuterGain(t){this._panner.coneOuterGain=t}get maxDistance(){return this._panner.maxDistance}set maxDistance(t){this._panner.maxDistance=t}dispose(){return super.dispose(),this._panner.disconnect(),this.orientationX.dispose(),this.orientationY.dispose(),this.orientationZ.dispose(),this.positionX.dispose(),this.positionY.dispose(),this.positionZ.dispose(),this}}class bl extends bo{constructor(){super(ki(bl.getDefaults(),arguments)),this.name="Recorder";const t=ki(bl.getDefaults(),arguments);this.input=new So({context:this.context}),Gs(bl.supported,"Media Recorder API is not available"),this._stream=this.context.createMediaStreamDestination(),this.input.connect(this._stream),this._recorder=new MediaRecorder(this._stream.stream,{mimeType:t.mimeType})}static getDefaults(){return bo.getDefaults()}get mimeType(){return this._recorder.mimeType}static get supported(){return null!==pi&&Reflect.has(pi,"MediaRecorder")}get state(){return"inactive"===this._recorder.state?"stopped":"paused"===this._recorder.state?"paused":"started"}start(){return gi(this,void 0,void 0,(function*(){Gs("started"!==this.state,"Recorder is already started");const t=new Promise(t=>{const e=()=>{this._recorder.removeEventListener("start",e,!1),t(!0)};this._recorder.addEventListener("start",e,!1)});return this._recorder.start(),yield t}))}stop(){return gi(this,void 0,void 0,(function*(){Gs("stopped"!==this.state,"Recorder is not started");const t=new Promise(t=>{const e=n=>{this._recorder.removeEventListener("dataavailable",e,!1),t(n.data)};this._recorder.addEventListener("dataavailable",e,!1)});return this._recorder.stop(),yield t}))}pause(){return Gs("started"===this.state,"Recorder must be started"),this._recorder.pause(),this}dispose(){return super.dispose(),this.input.dispose(),this._stream.disconnect(),this}}class yl extends bo{constructor(){super(ki(yl.getDefaults(),arguments,["threshold","ratio"])),this.name="Compressor",this._compressor=this.context.createDynamicsCompressor(),this.input=this._compressor,this.output=this._compressor;const t=ki(yl.getDefaults(),arguments,["threshold","ratio"]);this.threshold=new vo({minValue:this._compressor.threshold.minValue,maxValue:this._compressor.threshold.maxValue,context:this.context,convert:!1,param:this._compressor.threshold,units:"decibels",value:t.threshold}),this.attack=new vo({minValue:this._compressor.attack.minValue,maxValue:this._compressor.attack.maxValue,context:this.context,param:this._compressor.attack,units:"time",value:t.attack}),this.release=new vo({minValue:this._compressor.release.minValue,maxValue:this._compressor.release.maxValue,context:this.context,param:this._compressor.release,units:"time",value:t.release}),this.knee=new vo({minValue:this._compressor.knee.minValue,maxValue:this._compressor.knee.maxValue,context:this.context,convert:!1,param:this._compressor.knee,units:"decibels",value:t.knee}),this.ratio=new vo({minValue:this._compressor.ratio.minValue,maxValue:this._compressor.ratio.maxValue,context:this.context,convert:!1,param:this._compressor.ratio,units:"positive",value:t.ratio}),Hi(this,["knee","release","attack","ratio","threshold"])}static getDefaults(){return Object.assign(bo.getDefaults(),{attack:.003,knee:30,ratio:12,release:.25,threshold:-24})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.disconnect(),this.attack.dispose(),this.release.dispose(),this.threshold.dispose(),this.ratio.dispose(),this.knee.dispose(),this}}class wl extends bo{constructor(){super(Object.assign(ki(wl.getDefaults(),arguments,["threshold","smoothing"]))),this.name="Gate";const t=ki(wl.getDefaults(),arguments,["threshold","smoothing"]);this._follower=new Ea({context:this.context,smoothing:t.smoothing}),this._gt=new Tr({context:this.context,value:$i(t.threshold)}),this.input=new So({context:this.context}),this._gate=this.output=new So({context:this.context}),this.input.connect(this._gate),this.input.chain(this._follower,this._gt,this._gate.gain)}static getDefaults(){return Object.assign(bo.getDefaults(),{smoothing:.1,threshold:-40})}get threshold(){return to(this._gt.value)}set threshold(t){this._gt.value=$i(t)}get smoothing(){return this._follower.smoothing}set smoothing(t){this._follower.smoothing=t}dispose(){return super.dispose(),this.input.dispose(),this._follower.dispose(),this._gt.dispose(),this._gate.dispose(),this}}class xl extends bo{constructor(){super(Object.assign(ki(xl.getDefaults(),arguments,["threshold"]))),this.name="Limiter";const t=ki(xl.getDefaults(),arguments,["threshold"]);this._compressor=this.input=this.output=new yl({context:this.context,ratio:20,attack:.003,release:.01,threshold:t.threshold}),this.threshold=this._compressor.threshold,Hi(this,"threshold")}static getDefaults(){return Object.assign(bo.getDefaults(),{threshold:-12})}get reduction(){return this._compressor.reduction}dispose(){return super.dispose(),this._compressor.dispose(),this.threshold.dispose(),this}}class Sl extends bo{constructor(){super(Object.assign(ki(Sl.getDefaults(),arguments))),this.name="MidSideCompressor";const t=ki(Sl.getDefaults(),arguments);this._midSideSplit=this.input=new $a({context:this.context}),this._midSideMerge=this.output=new tl({context:this.context}),this.mid=new yl(Object.assign(t.mid,{context:this.context})),this.side=new yl(Object.assign(t.side,{context:this.context})),this._midSideSplit.mid.chain(this.mid,this._midSideMerge.mid),this._midSideSplit.side.chain(this.side,this._midSideMerge.side),Hi(this,["mid","side"])}static getDefaults(){return Object.assign(bo.getDefaults(),{mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},side:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10}})}dispose(){return super.dispose(),this.mid.dispose(),this.side.dispose(),this._midSideSplit.dispose(),this._midSideMerge.dispose(),this}}class Cl extends bo{constructor(){super(Object.assign(ki(Cl.getDefaults(),arguments))),this.name="MultibandCompressor";const t=ki(Cl.getDefaults(),arguments);this._splitter=this.input=new fl({context:this.context,lowFrequency:t.lowFrequency,highFrequency:t.highFrequency}),this.lowFrequency=this._splitter.lowFrequency,this.highFrequency=this._splitter.highFrequency,this.output=new So({context:this.context}),this.low=new yl(Object.assign(t.low,{context:this.context})),this.mid=new yl(Object.assign(t.mid,{context:this.context})),this.high=new yl(Object.assign(t.high,{context:this.context})),this._splitter.low.chain(this.low,this.output),this._splitter.mid.chain(this.mid,this.output),this._splitter.high.chain(this.high,this.output),Hi(this,["high","mid","low","highFrequency","lowFrequency"])}static getDefaults(){return Object.assign(bo.getDefaults(),{lowFrequency:250,highFrequency:2e3,low:{ratio:6,threshold:-30,release:.25,attack:.03,knee:10},mid:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16},high:{ratio:3,threshold:-24,release:.03,attack:.02,knee:16}})}dispose(){return super.dispose(),this._splitter.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.output.dispose(),this}}class kl extends bo{constructor(){super(ki(kl.getDefaults(),arguments,["low","mid","high"])),this.name="EQ3",this.output=new So({context:this.context}),this._internalChannels=[];const t=ki(kl.getDefaults(),arguments,["low","mid","high"]);this.input=this._multibandSplit=new fl({context:this.context,highFrequency:t.highFrequency,lowFrequency:t.lowFrequency}),this._lowGain=new So({context:this.context,gain:t.low,units:"decibels"}),this._midGain=new So({context:this.context,gain:t.mid,units:"decibels"}),this._highGain=new So({context:this.context,gain:t.high,units:"decibels"}),this.low=this._lowGain.gain,this.mid=this._midGain.gain,this.high=this._highGain.gain,this.Q=this._multibandSplit.Q,this.lowFrequency=this._multibandSplit.lowFrequency,this.highFrequency=this._multibandSplit.highFrequency,this._multibandSplit.low.chain(this._lowGain,this.output),this._multibandSplit.mid.chain(this._midGain,this.output),this._multibandSplit.high.chain(this._highGain,this.output),Hi(this,["low","mid","high","lowFrequency","highFrequency"]),this._internalChannels=[this._multibandSplit]}static getDefaults(){return Object.assign(bo.getDefaults(),{high:0,highFrequency:2500,low:0,lowFrequency:400,mid:0})}dispose(){return super.dispose(),Wi(this,["low","mid","high","lowFrequency","highFrequency"]),this._multibandSplit.dispose(),this.lowFrequency.dispose(),this.highFrequency.dispose(),this._lowGain.dispose(),this._midGain.dispose(),this._highGain.dispose(),this.low.dispose(),this.mid.dispose(),this.high.dispose(),this.Q.dispose(),this}}class El extends bo{constructor(){super(ki(El.getDefaults(),arguments,["url","onload"])),this.name="Convolver",this._convolver=this.context.createConvolver();const t=ki(El.getDefaults(),arguments,["url","onload"]);this._buffer=new Xi(t.url,e=>{this.buffer=e,t.onload()}),this.input=new So({context:this.context}),this.output=new So({context:this.context}),this._buffer.loaded&&(this.buffer=this._buffer),this.normalize=t.normalize,this.input.chain(this._convolver,this.output)}static getDefaults(){return Object.assign(bo.getDefaults(),{normalize:!0,onload:Qi})}load(t){return gi(this,void 0,void 0,(function*(){this.buffer=yield this._buffer.load(t)}))}get buffer(){return this._buffer.length?this._buffer:null}set buffer(t){t&&this._buffer.set(t),this._convolver.buffer&&(this.input.disconnect(),this._convolver.disconnect(),this._convolver=this.context.createConvolver(),this.input.chain(this._convolver,this.output));const e=this._buffer.get();this._convolver.buffer=e||null}get normalize(){return this._convolver.normalize}set normalize(t){this._convolver.normalize=t}dispose(){return super.dispose(),this._buffer.dispose(),this._convolver.disconnect(),this}}function Pl(){return Ki().now()}function Tl(){return Ki().immediate()}function Ml(){return Ki().transport}function Rl(){return Ki().destination}function Al(){return Ki().listener}function Ol(){return Ki().draw}function Nl(){return Xi.loaded()}n(2),n(3),n(4),n(5).polyfill(),n(7).polyfill();const Dl=Xi,Bl=Do,Il=Yo}])},1404:function(t,e,n){(function(e){t.exports=function(){function t(t){return new Int8Array(t)}function e(t){return new Int16Array(t)}function n(t){return new Int32Array(t)}function s(t){return new Float32Array(t)}function i(t){return new Float64Array(t)}function o(t){if(1==t.length)return s(t[0]);var e=t[0];t=t.slice(1);for(var n=[],i=0;ie&&(n=-1,e=0);90||(t.quant_comp=c.quant_comp),0!=n?t.quant_comp_short=c.quant_comp_s:Math.abs(t.quant_comp_short- -1)>0||(t.quant_comp_short=c.quant_comp_s),0!=c.expY&&(t.experimentalY=0!=c.expY),0!=n?t.internal_flags.nsPsy.attackthre=c.st_lrm:Math.abs(t.internal_flags.nsPsy.attackthre- -1)>0||(t.internal_flags.nsPsy.attackthre=c.st_lrm),0!=n?t.internal_flags.nsPsy.attackthre_s=c.st_s:Math.abs(t.internal_flags.nsPsy.attackthre_s- -1)>0||(t.internal_flags.nsPsy.attackthre_s=c.st_s),0!=n?t.maskingadjust=c.masking_adj:Math.abs(t.maskingadjust-0)>0||(t.maskingadjust=c.masking_adj),0!=n?t.maskingadjust_short=c.masking_adj_short:Math.abs(t.maskingadjust_short-0)>0||(t.maskingadjust_short=c.masking_adj_short),0!=n?t.ATHlower=-c.ath_lower/10:Math.abs(10*-t.ATHlower-0)>0||(t.ATHlower=-c.ath_lower/10),0!=n?t.ATHcurve=c.ath_curve:Math.abs(t.ATHcurve- -1)>0||(t.ATHcurve=c.ath_curve),0!=n?t.athaa_sensitivity=c.ath_sensitivity:Math.abs(t.athaa_sensitivity- -1)>0||(t.athaa_sensitivity=c.ath_sensitivity),c.interch>0&&(0!=n?t.interChRatio=c.interch:Math.abs(t.interChRatio- -1)>0||(t.interChRatio=c.interch)),c.safejoint>0&&(t.exp_nspsytune=t.exp_nspsytune|c.safejoint),c.sfb21mod>0&&(t.exp_nspsytune=t.exp_nspsytune|c.sfb21mod<<20),0!=n?t.msfix=c.msfix:Math.abs(t.msfix- -1)>0||(t.msfix=c.msfix),0==n&&(t.VBR_q=e,t.VBR_q_frac=r)}var r=[new e(8,9,9,0,0,6.6,145,0,.95,0,-30,11,.0012,1),new e(16,9,9,0,0,6.6,145,0,.95,0,-25,11,.001,1),new e(24,9,9,0,0,6.6,145,0,.95,0,-20,11,.001,1),new e(32,9,9,0,0,6.6,145,0,.95,0,-15,11,.001,1),new e(40,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new e(48,9,9,0,0,6.6,145,0,.95,0,-10,11,9e-4,1),new e(56,9,9,0,0,6.6,145,0,.95,0,-6,11,8e-4,1),new e(64,9,9,0,0,6.6,145,0,.95,0,-2,11,8e-4,1),new e(80,9,9,0,0,6.6,145,0,.95,0,0,8,7e-4,1),new e(96,9,9,0,2.5,6.6,145,0,.95,0,1,5.5,6e-4,1),new e(112,9,9,0,2.25,6.6,145,0,.95,0,2,4.5,5e-4,1),new e(128,9,9,0,1.95,6.4,140,0,.95,0,3,4,2e-4,1),new e(160,9,9,1,1.79,6,135,0,.95,-2,5,3.5,0,1),new e(192,9,9,1,1.49,5.6,125,0,.97,-4,7,3,0,0),new e(224,9,9,1,1.25,5.2,125,0,.98,-6,9,2,0,0),new e(256,9,9,1,.97,5.2,125,0,1,-8,10,1,0,0),new e(320,9,9,1,.9,5.2,125,0,1,-10,12,0,0,0)];function a(t,e,s){var i=e,o=n.nearestBitrateFullIndex(e);if(t.VBR=m.vbr_abr,t.VBR_mean_bitrate_kbps=i,t.VBR_mean_bitrate_kbps=Math.min(t.VBR_mean_bitrate_kbps,320),t.VBR_mean_bitrate_kbps=Math.max(t.VBR_mean_bitrate_kbps,8),t.brate=t.VBR_mean_bitrate_kbps,t.VBR_mean_bitrate_kbps>320&&(t.disable_reservoir=!0),r[o].safejoint>0&&(t.exp_nspsytune=2|t.exp_nspsytune),r[o].sfscale>0&&(t.internal_flags.noise_shaping=2),Math.abs(r[o].nsbass)>0){var a=int(4*r[o].nsbass);a<0&&(a+=64),t.exp_nspsytune=t.exp_nspsytune|a<<2}return 0!=s?t.quant_comp=r[o].quant_comp:Math.abs(t.quant_comp- -1)>0||(t.quant_comp=r[o].quant_comp),0!=s?t.quant_comp_short=r[o].quant_comp_s:Math.abs(t.quant_comp_short- -1)>0||(t.quant_comp_short=r[o].quant_comp_s),0!=s?t.msfix=r[o].nsmsfix:Math.abs(t.msfix- -1)>0||(t.msfix=r[o].nsmsfix),0!=s?t.internal_flags.nsPsy.attackthre=r[o].st_lrm:Math.abs(t.internal_flags.nsPsy.attackthre- -1)>0||(t.internal_flags.nsPsy.attackthre=r[o].st_lrm),0!=s?t.internal_flags.nsPsy.attackthre_s=r[o].st_s:Math.abs(t.internal_flags.nsPsy.attackthre_s- -1)>0||(t.internal_flags.nsPsy.attackthre_s=r[o].st_s),0!=s?t.scale=r[o].scale:Math.abs(t.scale- -1)>0||(t.scale=r[o].scale),0!=s?t.maskingadjust=r[o].masking_adj:Math.abs(t.maskingadjust-0)>0||(t.maskingadjust=r[o].masking_adj),r[o].masking_adj>0?0!=s?t.maskingadjust_short=.9*r[o].masking_adj:Math.abs(t.maskingadjust_short-0)>0||(t.maskingadjust_short=.9*r[o].masking_adj):0!=s?t.maskingadjust_short=1.1*r[o].masking_adj:Math.abs(t.maskingadjust_short-0)>0||(t.maskingadjust_short=1.1*r[o].masking_adj),0!=s?t.ATHlower=-r[o].ath_lower/10:Math.abs(10*-t.ATHlower-0)>0||(t.ATHlower=-r[o].ath_lower/10),0!=s?t.ATHcurve=r[o].ath_curve:Math.abs(t.ATHcurve- -1)>0||(t.ATHcurve=r[o].ath_curve),0!=s?t.interChRatio=r[o].interch:Math.abs(t.interChRatio- -1)>0||(t.interChRatio=r[o].interch),e}this.apply_preset=function(t,e,n){switch(e){case G.R3MIX:e=G.V3,t.VBR=m.vbr_mtrh;break;case G.MEDIUM:e=G.V4,t.VBR=m.vbr_rh;break;case G.MEDIUM_FAST:e=G.V4,t.VBR=m.vbr_mtrh;break;case G.STANDARD:e=G.V2,t.VBR=m.vbr_rh;break;case G.STANDARD_FAST:e=G.V2,t.VBR=m.vbr_mtrh;break;case G.EXTREME:e=G.V0,t.VBR=m.vbr_rh;break;case G.EXTREME_FAST:e=G.V0,t.VBR=m.vbr_mtrh;break;case G.INSANE:return e=320,t.preset=e,a(t,e,n),t.VBR=m.vbr_off,e}switch(t.preset=e,e){case G.V9:return o(t,9,n),e;case G.V8:return o(t,8,n),e;case G.V7:return o(t,7,n),e;case G.V6:return o(t,6,n),e;case G.V5:return o(t,5,n),e;case G.V4:return o(t,4,n),e;case G.V3:return o(t,3,n),e;case G.V2:return o(t,2,n),e;case G.V1:return o(t,1,n),e;case G.V0:return o(t,0,n),e}return 8<=e&&e<=320?a(t,e,n):(t.preset=0,e)}}function v(){v.YULE_ORDER,v.MAX_SAMP_FREQ;var t=v.RMS_WINDOW_TIME_NUMERATOR,e=v.RMS_WINDOW_TIME_DENOMINATOR,n=(v.MAX_SAMPLES_PER_WINDOW,[[.038575994352,-3.84664617118067,-.02160367184185,7.81501653005538,-.00123395316851,-11.34170355132042,-9291677959e-14,13.05504219327545,-.01655260341619,-12.28759895145294,.02161526843274,9.4829380631979,-.02074045215285,-5.87257861775999,.00594298065125,2.75465861874613,.00306428023191,-.86984376593551,.00012025322027,.13919314567432,.00288463683916],[.0541865640643,-3.47845948550071,-.02911007808948,6.36317777566148,-.00848709379851,-8.54751527471874,-.00851165645469,9.4769360780128,-.00834990904936,-8.81498681370155,.02245293253339,6.85401540936998,-.02596338512915,-4.39470996079559,.01624864962975,2.19611684890774,-.00240879051584,-.75104302451432,.00674613682247,.13149317958808,-.00187763777362],[.15457299681924,-2.37898834973084,-.09331049056315,2.84868151156327,-.06247880153653,-2.64577170229825,.02163541888798,2.23697657451713,-.05588393329856,-1.67148153367602,.04781476674921,1.00595954808547,.00222312597743,-.45953458054983,.03174092540049,.16378164858596,-.01390589421898,-.05032077717131,.00651420667831,.0234789740702,-.00881362733839],[.30296907319327,-1.61273165137247,-.22613988682123,1.0797749225997,-.08587323730772,-.2565625775407,.03282930172664,-.1627671912044,-.00915702933434,-.22638893773906,-.02364141202522,.39120800788284,-.00584456039913,-.22138138954925,.06276101321749,.04500235387352,-828086748e-14,.02005851806501,.00205861885564,.00302439095741,-.02950134983287],[.33642304856132,-1.49858979367799,-.2557224142557,.87350271418188,-.11828570177555,.12205022308084,.11921148675203,-.80774944671438,-.07834489609479,.47854794562326,-.0046997791438,-.12453458140019,-.0058950022444,-.04067510197014,.05724228140351,.08333755284107,.00832043980773,-.04237348025746,-.0163538138454,.02977207319925,-.0176017656815],[.4491525660845,-.62820619233671,-.14351757464547,.29661783706366,-.22784394429749,-.372563729424,-.01419140100551,.00213767857124,.04078262797139,-.42029820170918,-.12398163381748,.22199650564824,.04097565135648,.00613424350682,.10478503600251,.06747620744683,-.01863887810927,.05784820375801,-.03193428438915,.03222754072173,.00541907748707],[.56619470757641,-1.04800335126349,-.75464456939302,.29156311971249,.1624213774223,-.26806001042947,.16744243493672,.00819999645858,-.18901604199609,.45054734505008,.3093178284183,-.33032403314006,-.27562961986224,.0673936833311,.00647310677246,-.04784254229033,.08647503780351,.01639907836189,-.0378898455484,.01807364323573,-.00588215443421],[.58100494960553,-.51035327095184,-.53174909058578,-.31863563325245,-.14289799034253,-.20256413484477,.17520704835522,.1472815413433,.02377945217615,.38952639978999,.15558449135573,-.23313271880868,-.25344790059353,-.05246019024463,.01628462406333,-.02505961724053,.06920467763959,.02442357316099,-.03721611395801,.01818801111503,-.00749618797172],[.53648789255105,-.2504987195602,-.42163034350696,-.43193942311114,-.00275953611929,-.03424681017675,.04267842219415,-.04678328784242,-.10214864179676,.26408300200955,.14590772289388,.15113130533216,-.02459864859345,-.17556493366449,-.11202315195388,-.18823009262115,-.04060034127,.05477720428674,.0478866554818,.0470440968812,-.02217936801134]]),s=[[.98621192462708,-1.97223372919527,-1.97242384925416,.97261396931306,.98621192462708],[.98500175787242,-1.96977855582618,-1.97000351574484,.9702284756635,.98500175787242],[.97938932735214,-1.95835380975398,-1.95877865470428,.95920349965459,.97938932735214],[.97531843204928,-1.95002759149878,-1.95063686409857,.95124613669835,.97531843204928],[.97316523498161,-1.94561023566527,-1.94633046996323,.94705070426118,.97316523498161],[.96454515552826,-1.92783286977036,-1.92909031105652,.93034775234268,.96454515552826],[.96009142950541,-1.91858953033784,-1.92018285901082,.92177618768381,.96009142950541],[.95856916599601,-1.9154210807478,-1.91713833199203,.91885558323625,.95856916599601],[.94597685600279,-1.88903307939452,-1.89195371200558,.89487434461664,.94597685600279]];function i(t,e,n,s,i,o){for(;0!=i--;)n[s]=1e-10+t[e+0]*o[0]-n[s-1]*o[1]+t[e-1]*o[2]-n[s-2]*o[3]+t[e-2]*o[4]-n[s-3]*o[5]+t[e-3]*o[6]-n[s-4]*o[7]+t[e-4]*o[8]-n[s-5]*o[9]+t[e-5]*o[10]-n[s-6]*o[11]+t[e-6]*o[12]-n[s-7]*o[13]+t[e-7]*o[14]-n[s-8]*o[15]+t[e-8]*o[16]-n[s-9]*o[17]+t[e-9]*o[18]-n[s-10]*o[19]+t[e-10]*o[20],++s,++e}function o(t,e,n,s,i,o){for(;0!=i--;)n[s]=t[e+0]*o[0]-n[s-1]*o[1]+t[e-1]*o[2]-n[s-2]*o[3]+t[e-2]*o[4],++s,++e}function r(t){return t*t}this.InitGainAnalysis=function(n,s){return function(n,s){for(var i=0;i0;){b=_>t.sampleWindow-t.totsamp?t.sampleWindow-t.totsamp:_,yMAX_ORDER-y&&(b=MAX_ORDER-y)):(d=a+y,m=e,f=c+y,g=l),i(m,d,t.lstepbuf,t.lstep+t.totsamp,b,n[t.reqindex]),i(g,f,t.rstepbuf,t.rstep+t.totsamp,b,n[t.reqindex]),o(t.lstepbuf,t.lstep+t.totsamp,t.loutbuf,t.lout+t.totsamp,b,s[t.reqindex]),o(t.rstepbuf,t.rstep+t.totsamp,t.routbuf,t.rout+t.totsamp,b,s[t.reqindex]),d=t.lout+t.totsamp,m=t.loutbuf,f=t.rout+t.totsamp,g=t.routbuf;for(var w=b%8;0!=w--;)t.lsum+=r(m[d++]),t.rsum+=r(g[f++]);for(w=b/8;0!=w--;)t.lsum+=r(m[d+0])+r(m[d+1])+r(m[d+2])+r(m[d+3])+r(m[d+4])+r(m[d+5])+r(m[d+6])+r(m[d+7]),d+=8,t.rsum+=r(g[f+0])+r(g[f+1])+r(g[f+2])+r(g[f+3])+r(g[f+4])+r(g[f+5])+r(g[f+6])+r(g[f+7]),f+=8;if(_-=b,y+=b,t.totsamp+=b,t.totsamp==t.sampleWindow){var x=10*v.STEPS_per_dB*Math.log10((t.lsum+t.rsum)/t.totsamp*.5+1e-37),S=x<=0?0:0|x;S>=t.A.length&&(S=t.A.length-1),t.A[S]++,t.lsum=t.rsum=0,h.arraycopy(t.loutbuf,t.totsamp,t.loutbuf,0,MAX_ORDER),h.arraycopy(t.routbuf,t.totsamp,t.routbuf,0,MAX_ORDER),h.arraycopy(t.lstepbuf,t.totsamp,t.lstepbuf,0,MAX_ORDER),h.arraycopy(t.rstepbuf,t.totsamp,t.rstepbuf,0,MAX_ORDER),t.totsamp=0}if(t.totsamp>t.sampleWindow)return GAIN_ANALYSIS_ERROR}return u0&&!((i-=t[n])<=0););return 64.82-n/v.STEPS_per_dB}(t.A,t.A.length),n=0;n>=1;0!=t--;)i[o++]=r>n[s++]?0:1,i[o++]=r>n[s++]?0:1}function o(e,n,s,i,o,r){var a=(e>>=1)%2;for(e>>=1;0!=e--;){var l,c,h,u,p,d,m,f;l=s[i++]*n,c=s[i++]*n,p=0|l,h=s[i++]*n,d=0|c,u=s[i++]*n,m=0|h,l+=t.adj43[p],f=0|u,c+=t.adj43[d],o[r++]=0|l,h+=t.adj43[m],o[r++]=0|c,u+=t.adj43[f],o[r++]=0|h,o[r++]=0|u}0!=a&&(p=0|(l=s[i++]*n),d=0|(c=s[i++]*n),l+=t.adj43[p],c+=t.adj43[d],o[r++]=0|l,o[r++]=0|c)}var r=[1,2,5,7,7,10,10,13,13,13,13,13,13,13,13];function a(t,e,n,s){var i=function(t,e,n){var s=0,i=0;do{var o=t[e++],r=t[e++];s>=16)>o&&(a=o,s++),i.bits+=a,s}(t,e,n,r[i-1],s);case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:return function(t,e,n,s,i){var o=0,r=0,a=0,l=C.ht[s].xlen,c=C.ht[s].hlen,h=C.ht[s+1].hlen,u=C.ht[s+2].hlen;do{var p=t[e+0]*l+t[e+1];e+=2,o+=c[p],r+=h[p],a+=u[p]}while(er&&(o=r,d++),o>a&&(o=a,d=s+2),i.bits+=o,d}(t,e,n,r[i-1],s);default:if(i>N.IXMAX_VAL)return s.bits=N.LARGE_BITS,-1;var o,a;for(i-=15,o=24;o<32&&!(C.ht[o].linmax>=i);o++);for(a=o-8;a<24&&!(C.ht[a].linmax>=i);a++);return function(t,e,n,s,i,o){var r,a=65536*C.ht[s].xlen+C.ht[i].xlen,l=0;do{var c=t[e++],h=t[e++];0!=c&&(c>14&&(c=15,l+=a),c*=16),0!=h&&(h>14&&(h=15,l+=a),c+=h),l+=C.largetbl[c]}while(e>=16)>r&&(l=r,s=i),o.bits+=l,s}(t,e,n,a,o,s)}}function l(t,n,s,i,o,r,l,c){for(var h=n.big_values,u=2;u=h)break;var d=o[u-2]+n.count1bits;if(s.part2_3_length<=d)break;var m=new e(d),f=a(i,p,h,m);d=m.bits,s.part2_3_length<=d||(s.assign(n),s.part2_3_length=d,s.region0_count=r[u-2],s.region1_count=u-2-r[u-2],s.table_select[0]=l[u-2],s.table_select[1]=c[u-2],s.table_select[2]=f)}}this.noquant_count_bits=function(t,n,s){var i=n.l3_enc,o=Math.min(576,n.max_nonzero_coeff+2>>1<<1);for(null!=s&&(s.sfb_count1=0);o>1&&0==(i[o-1]|i[o-2]);o-=2);n.count1=o;for(var r=0,l=0;o>3;o-=4){var c;if((2147483647&(i[o-1]|i[o-2]|i[o-3]|i[o-4]))>1)break;c=2*(2*(2*i[o-4]+i[o-3])+i[o-2])+i[o-1],r+=C.t32l[c],l+=C.t33l[c]}var h=r;if(n.count1table_select=0,r>l&&(h=l,n.count1table_select=1),n.count1bits=h,n.big_values=o,0==o)return h;if(n.block_type==L.SHORT_TYPE)(r=3*t.scalefac_band.s[3])>n.big_values&&(r=n.big_values),l=n.big_values;else if(n.block_type==L.NORM_TYPE){if(r=n.region0_count=t.bv_scf[o-2],l=n.region1_count=t.bv_scf[o-1],l=t.scalefac_band.l[r+l+2],r=t.scalefac_band.l[r+1],l(l=o)&&(r=l);if(r=Math.min(r,o),l=Math.min(l,o),0l)return N.LARGE_BITS;if(function(e,n,s,r,a){var l,h,u,p=0,d=0,m=0,f=0,g=n,_=0,v=g,b=0,y=e,w=0;for(u=null!=a&&r.global_gain==a.global_gain,h=r.block_type==L.SHORT_TYPE?38:21,l=0;l<=h;l++){var x=-1;if((u||r.block_type==L.NORM_TYPE)&&(x=r.global_gain-(r.scalefac[l]+(0!=r.preflag?t.pretab[l]:0)<r.max_nonzero_coeff)S=r.max_nonzero_coeff-p+1,c.fill(n,r.max_nonzero_coeff,576,0),(C=S)<0&&(C=0),l=h+1;if(0==d&&0==m&&(v=g,b=_,y=e,w=f),null!=a&&a.sfb_count1>0&&l>=a.sfb_count1&&a.step[l]>0&&x>=a.step[l]?(0!=d&&(o(d,s,y,w,v,b),d=0,v=g,b=_,y=e,w=f),m+=C):(0!=m&&(i(m,s,y,w,v,b),m=0,v=g,b=_,y=e,w=f),d+=C),C<=0){0!=m&&(i(m,s,y,w,v,b),m=0),0!=d&&(o(d,s,y,w,v,b),d=0);break}}l<=h&&(_+=r.width[l],f+=r.width[l],p+=r.width[l])}0!=d&&(o(d,s,y,w,v,b),d=0),0!=m&&(i(m,s,y,w,v,b),m=0)}(n,a,t.IPOW20(s.global_gain),s,r),0!=(2&e.substep_shaping))for(var h=0,u=s.global_gain+s.scalefac_scale,p=.634521682242439/t.IPOW20(u),d=0;d=p?a[m]:0}return this.noquant_count_bits(e,s,r)},this.best_huffman_divide=function(t,s){var i=new B,o=s.l3_enc,r=n(23),c=n(23),h=n(23),u=n(23);if(s.block_type!=L.SHORT_TYPE||1!=t.mode_gr){i.assign(s),s.block_type==L.NORM_TYPE&&(!function(t,n,s,i,o,r,l){for(var c=n.big_values,h=0;h<=22;h++)i[h]=N.LARGE_BITS;for(h=0;h<16;h++){var u=t.scalefac_band.l[h+1];if(u>=c)break;var p=0,d=new e(p),m=a(s,0,u,d);p=d.bits;for(var f=0;f<8;f++){var g=t.scalefac_band.l[h+f+2];if(g>=c)break;var _=p,v=a(s,u,g,d=new e(_));_=d.bits,i[h+f]>_&&(i[h+f]=_,o[h+f]=h,r[h+f]=m,l[h+f]=v)}}}(t,s,o,r,c,h,u),l(t,i,s,o,r,c,h,u));var p=i.big_values;if(!(0==p||(o[p-2]|o[p-1])>1||(p=s.count1+2)>576)){i.assign(s),i.count1=p;for(var d=0,m=0;p>i.big_values;p-=4){var f=2*(2*(2*o[p-4]+o[p-3])+o[p-2])+o[p-1];d+=C.t32l[f],m+=C.t33l[f]}if(i.big_values=p,i.count1table_select=0,d>m&&(d=m,i.count1table_select=1),i.count1bits=d,i.block_type==L.NORM_TYPE)l(t,i,s,o,r,c,h,u);else{if(i.part2_3_length=d,(d=t.scalefac_band.l[8])>p&&(d=p),d>0){var g=new e(i.part2_3_length);i.table_select[0]=a(o,0,d,g),i.part2_3_length=g.bits}if(p>d){g=new e(i.part2_3_length);i.table_select[1]=a(o,d,p,g),i.part2_3_length=g.bits}s.part2_3_length>i.part2_3_length&&s.assign(i)}}}};var u=[1,1,1,1,8,2,2,2,4,4,4,8,8,8,16,16],p=[1,2,4,8,1,2,4,8,2,4,8,2,4,8,4,8],d=[0,0,0,0,3,1,1,1,2,2,2,3,3,3,4,4],m=[0,1,2,3,0,1,2,3,1,2,3,1,2,3,2,3];b.slen1_tab=d,b.slen2_tab=m,this.best_scalefac_store=function(e,n,s,i){var o,r,a,l,c=i.tt[n][s],h=0;for(a=0,o=0;o0&&(g|=c.scalefac[o]);if(0==(1&g)&&0!=g){for(o=0;o0&&(c.scalefac[o]>>=1);c.scalefac_scale=h=1}}if(0==c.preflag&&c.block_type!=L.SHORT_TYPE&&2==e.mode_gr){for(o=11;o0&&(c.scalefac[o]-=t.pretab[o]);c.preflag=h=1}}for(r=0;r<4;r++)i.scfsi[s][r]=0;for(2==e.mode_gr&&1==n&&i.tt[0][s].block_type!=L.SHORT_TYPE&&i.tt[1][s].block_type!=L.SHORT_TYPE&&(!function(t,e){for(var n,s=e.tt[1][t],i=e.tt[0][t],o=0;o=0);n++);if(n==C.scfsi_band[o+1]){for(n=C.scfsi_band[o];nh&&(s.part2_length=h,s.scalefac_compress=o)}}(s,i),h=0),o=0;oi[n]&&(e.part2_length=i[n],e.scalefac_compress=n);return e.part2_length==N.LARGE_BITS};var v=[[15,15,7,7],[15,15,7,0],[7,3,0,0],[15,31,31,0],[7,7,7,0],[3,3,0,0]];this.scale_bitcount_lsf=function(e,s){var i,o,r,a,l,c,u,p,d=n(4),m=s.scalefac;for(i=0!=s.preflag?2:0,u=0;u<4;u++)d[u]=0;if(s.block_type==L.SHORT_TYPE){o=1;var f=t.nr_of_sfb_block[i][o];for(p=0,r=0;r<4;r++)for(a=f[r]/3,u=0;ud[r]&&(d[r]=m[3*p+l])}else{o=0;f=t.nr_of_sfb_block[i][o];for(p=0,r=0;r<4;r++)for(a=f[r],u=0;ud[r]&&(d[r]=m[p])}for(c=!1,r=0;r<4;r++)d[r]>v[i][r]&&(c=!0);if(!c){var g,_,b,w;for(s.sfb_partition_table=t.nr_of_sfb_block[i][o],r=0;r<4;r++)s.slen[r]=y[d[r]];switch(g=s.slen[0],_=s.slen[1],b=s.slen[2],w=s.slen[3],i){case 0:s.scalefac_compress=(5*g+_<<4)+(b<<2)+w;break;case 1:s.scalefac_compress=400+(5*g+_<<2)+b;break;case 2:s.scalefac_compress=500+3*g+_;break;default:h.err.printf("intensity stereo not implemented yet\n")}}if(!c)for(s.part2_length=0,r=0;r<4;r++)s.part2_length+=s.slen[r]*s.sfb_partition_table[r];return c};var y=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];this.huffman_init=function(t){for(var e=2;e<=576;e+=2){for(var n,i=0;t.scalefac_band.l[++i]e;)n--;for(n<0&&(n=s[i][0]),t.bv_scf[e-2]=n,n=s[i][1];t.scalefac_band.l[n+t.bv_scf[e-2]+2]>e;)n--;n<0&&(n=s[i][1]),t.bv_scf[e-1]=n}}}function y(){var t;this.setModules=function(e){t=e},this.ResvFrameBegin=function(e,n){var s,i=e.internal_flags,o=i.l3_side,r=t.getframebits(e);n.bits=(r-8*i.sideinfo_len)/i.mode_gr;var a=2048*i.mode_gr-8;e.brate>320?s=8*int(1e3*e.brate/(e.out_samplerate/1152)/8+.5):(s=11520,e.strict_ISO&&(s=8*int(32e4/(e.out_samplerate/1152)/8+.5))),i.ResvMax=s-r,i.ResvMax>a&&(i.ResvMax=a),(i.ResvMax<0||e.disable_reservoir)&&(i.ResvMax=0);var l=n.bits*i.mode_gr+Math.min(i.ResvSize,i.ResvMax);return l>s&&(l=s),o.resvDrain_pre=0,null!=i.pinfo&&(i.pinfo.mean_bits=n.bits/2,i.pinfo.resvsize=i.ResvSize),l},this.ResvMaxBits=function(t,e,n,s){var i,o=t.internal_flags,r=o.ResvSize,a=o.ResvMax;0!=s&&(r+=e),0!=(1&o.substep_shaping)&&(a*=.9),n.bits=e,10*r>9*a?(i=r-9*a/10,n.bits+=i,o.substep_shaping|=128):(i=0,o.substep_shaping&=127,t.disable_reservoir||0!=(1&o.substep_shaping)||(n.bits-=.1*e));var l=r<6*o.ResvMax/10?r:6*o.ResvMax/10;return(l-=i)<0&&(l=0),l},this.ResvAdjust=function(t,e){t.ResvSize-=e.part2_3_length+e.part2_length},this.ResvFrameEnd=function(t,e){var n,s=t.l3_side;t.ResvSize+=e*t.mode_gr;var i=0;s.resvDrain_post=0,s.resvDrain_pre=0,0!=(n=t.ResvSize%8)&&(i+=n),(n=t.ResvSize-i-t.ResvMax)>0&&(i+=n);var o=Math.min(8*s.main_data_begin,i)/8;s.resvDrain_pre+=8*o,i-=8*o,t.ResvSize-=8*o,s.main_data_begin-=o,s.resvDrain_post+=i,t.ResvSize-=i}}function w(){var e=this,s=null,i=null,r=null,a=null;this.setModules=function(t,e,n,o){s=t,i=e,r=n,a=o};var l=null,u=0,p=0,d=0;function m(t){h.arraycopy(t.header[t.w_ptr].buf,0,l,p,t.sideinfo_len),p+=t.sideinfo_len,u+=8*t.sideinfo_len,t.w_ptr=t.w_ptr+1&Q.MAX_HEADER_BUF-1}function f(t,e,n){for(;n>0;){var s;0==d&&(d=8,p++,t.header[t.w_ptr].write_timing==u&&m(t),l[p]=0),n-=s=Math.min(n,d),d-=s,l[p]|=e>>n<0;){var s;0==d&&(d=8,p++,l[p]=0),n-=s=Math.min(n,d),d-=s,l[p]|=e>>n<=8&&(f(s,76,8),e-=8),e>=8&&(f(s,65,8),e-=8),e>=8&&(f(s,77,8),e-=8),e>=8&&(f(s,69,8),e-=8),e>=32){var i=r.getLameShortVersion();if(e>=32)for(n=0;n=8;++n)e-=8,f(s,i.charAt(n),8)}for(;e>=1;e-=1)f(s,s.ancillary_flag,1),s.ancillary_flag^=t.disable_reservoir?0:1}function y(t,e,n){for(var s=t.header[t.h_ptr].ptr;n>0;){var i=Math.min(n,8-(7&s));n-=i,t.header[t.h_ptr].buf[s>>3]|=e>>n<<8-(7&s)-i,s+=i}t.header[t.h_ptr].ptr=s}function w(t,e){t<<=8;for(var n=0;n<8;n++)0!=(65536&((e<<=1)^(t<<=1)))&&(e^=32773);return e}function x(t,e){var n,s=C.ht[e.count1table_select+32],i=0,o=e.big_values,r=e.big_values;for(n=(e.count1-e.big_values)/4;n>0;--n){var a=0,l=0;0!=e.l3_enc[o+0]&&(l+=8,e.xr[r+0]<0&&a++),0!=e.l3_enc[o+1]&&(l+=4,a*=2,e.xr[r+1]<0&&a++),0!=e.l3_enc[o+2]&&(l+=2,a*=2,e.xr[r+2]<0&&a++),0!=e.l3_enc[o+3]&&(l++,a*=2,e.xr[r+3]<0&&a++),o+=4,r+=4,f(t,a+s.table[l],s.hlen[l]),i+=s.hlen[l]}return i}function S(t,e,n,s,i){var o=C.ht[e],r=0;if(0==e)return r;for(var a=n;a15){if(d>14)p|=d-15<<1,c=h,d=15;if(m>14)p<<=h,p|=m-15,c+=h,m=15;u=16}0!=m&&(p<<=1,i.xr[a+1]<0&&p++,l--),d=d*u+m,c-=l,l+=o.hlen[d],f(t,o.table[d],l),f(t,p,c),r+=l+c}return r}function k(t,e){var n=3*t.scalefac_band.s[3];n>e.big_values&&(n=e.big_values);var s=S(t,e.table_select[0],0,n,e);return s+=S(t,e.table_select[1],n,e.big_values,e)}function E(t,e){var n,s,i,o;n=e.big_values;var r=e.region0_count+1;return i=t.scalefac_band.l[r],r+=e.region1_count+1,i>n&&(i=n),(o=t.scalefac_band.l[r])>n&&(o=n),s=S(t,e.table_select[0],0,i,e),s+=S(t,e.table_select[1],i,o,e),s+=S(t,e.table_select[2],o,n,e)}function P(){this.total=0}function T(t,n){var s,i,o,r,a,l=t.internal_flags;return a=l.w_ptr,-1==(r=l.h_ptr-1)&&(r=Q.MAX_HEADER_BUF-1),s=l.header[r].write_timing-u,n.total=s,s>=0&&(i=1+r-a,r>8),e[5]=byte(255&n)},this.flush_bitstream=function(t){var e,n,i=t.internal_flags,o=i.h_ptr-1;if(-1==o&&(o=Q.MAX_HEADER_BUF-1),e=i.l3_side,!((n=T(t,new P))<0)){if(_(t,n),i.ResvSize=0,e.main_data_begin=0,i.findReplayGain){var r=s.GetTitleGain(i.rgdata);i.RadioGain=0|Math.floor(10*r+.5)}i.findPeakSample&&(i.noclipGainChange=0|Math.ceil(20*Math.log10(i.PeakSample/32767)*10),i.noclipGainChange>0&&(EQ(t.scale,1)||EQ(t.scale,0))?i.noclipScale=Math.floor(32767/i.PeakSample*100)/100:i.noclipScale=-1)}},this.add_dummy_byte=function(t,e,n){for(var s,i=t.internal_flags;n-- >0;)for(g(0,e,8),s=0;s ResvSize"),8*e.main_data_begin!=n.ResvSize&&(h.err.printf("bit reservoir error: \nl3_side.main_data_begin: %d \nResvoir size: %d \nresv drain (post) %d \nresv drain (pre) %d \nheader and sideinfo: %d \ndata bits: %d \ntotal bits: %d (remainder: %d) \nbitsperframe: %d \n",8*e.main_data_begin,n.ResvSize,e.resvDrain_post,e.resvDrain_pre,8*n.sideinfo_len,i-e.resvDrain_post-8*n.sideinfo_len,i,i%8,s),h.err.println("This is a fatal error. It has several possible causes:"),h.err.println("90%% LAME compiled with buggy version of gcc using advanced optimizations"),h.err.println(" 9%% Your system is overclocked"),h.err.println(" 1%% bug in LAME encoding library"),n.ResvSize=8*e.main_data_begin),u>1e9){var o;for(o=0;oc)return-1;if(h.arraycopy(l,0,e,r,m),p=-1,d=0,0!=u){var f=n(1);if(f[0]=t.nMusicCRC,a.updateMusicCRC(f,e,r,m),t.nMusicCRC=f[0],m>0&&(t.VBR_seek_table.nBytesWritten+=m),t.decode_on_the_fly)for(var g,_=o([2,1152]),b=m,y=-1;0!=y;)if(y=i.hip_decode1_unclipped(t.hip,e,r,b,_[0],_[1]),b=0,-1==y&&(y=0),y>0){if(t.findPeakSample){for(g=0;gt.PeakSample?t.PeakSample=_[0][g]:-_[0][g]>t.PeakSample&&(t.PeakSample=-_[0][g]);if(t.channels_out>1)for(g=0;gt.PeakSample?t.PeakSample=_[1][g]:-_[1][g]>t.PeakSample&&(t.PeakSample=-_[1][g])}if(t.findReplayGain&&s.AnalyzeSamples(t.rgdata,_[0],0,_[1],0,y,t.channels_out)==v.GAIN_ANALYSIS_ERROR)return-6}}return m},this.init_bit_stream_w=function(e){l=t(G.LAME_MAXMP3BUFFER),e.h_ptr=e.w_ptr=0,e.header[e.h_ptr].write_timing=0,p=-1,d=0,u=0}}function x(){var e,n,s;this.setModules=function(t,i,o){e=t,n=i,s=o};var i=x.NUMTOCENTRIES,o=x.MAXFRAMESIZE,r=i+4+4+4+4+4+9+1+1+8+1+1+3+1+1+2+4+2+2,a=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];function l(t,e){var n=255&t[e+0];return n<<=8,n|=255&t[e+1],n<<=8,n|=255&t[e+2],n<<=8,n|=255&t[e+3]}function u(t,e,n){t[e+0]=255&n>>24,t[e+1]=255&n>>16,t[e+2]=255&n>>8,t[e+3]=255&n}function d(t,e,n){t[e+0]=255&n>>8,t[e+1]=255&n}function f(t,e,n){return 255&(t<>8^a[255&(e^t)]}this.addVbrFrame=function(t){var e=t.internal_flags,n=C.bitrate_table[t.version][e.bitrate_index];!function(t,e){if(t.nVbrNumFrames++,t.sum+=e,t.seen++,!(t.seen>3&1,o=t[n+2]>>2&3,r=t[n+3]>>6&3,a=t[n+2]>>4&15;if(a=C.bitrate_table[s][a],t[n+1]>>4==14?e.samprate=C.samplerate_table[2][o]:e.samprate=C.samplerate_table[s][o],!function(t,e){return new String(t,e,"Xing".length(),null).equals("Xing")||new String(t,e,"Info".length(),null).equals("Info")}(t,n+=0!=s?3!=r?36:21:3!=r?21:13))return null;n+=4,e.hId=s;var c=e.flags=l(t,n);if(n+=4,0!=(1&c)&&(e.frames=l(t,n),n+=4),0!=(2&c)&&(e.bytes=l(t,n),n+=4),0!=(4&c)){if(null!=e.toc)for(var h=0;h>4;var p=(15&t[n+1])<<8;return(u<0||u>3e3)&&(u=-1),((p+=255&t[n+2])<0||p>3e3)&&(p=-1),e.encDelay=u,e.encPadding=p,e},this.InitVbrTag=function(e){var s,i=e.internal_flags;s=1==e.version?128:e.out_samplerate<16e3?32:64,e.VBR==m.vbr_off&&(s=e.brate);var a=72e3*(e.version+1)*s/e.out_samplerate,l=i.sideinfo_len+r;if(i.VBR_seek_table.TotalFrameSize=a,ao)e.bWriteVbrTag=!1;else{i.VBR_seek_table.nVbrNumFrames=0,i.VBR_seek_table.nBytesWritten=0,i.VBR_seek_table.sum=0,i.VBR_seek_table.seen=0,i.VBR_seek_table.want=1,i.VBR_seek_table.pos=0,null==i.VBR_seek_table.bag&&(i.VBR_seek_table.bag=new int[400],i.VBR_seek_table.size=400);var c=t(o);g(e,c);for(var h=i.VBR_seek_table.TotalFrameSize,u=0;ut.pos-1&&(o=t.pos-1);var r=0|256*t.bag[o]/t.sum;r>255&&(r=255),e[n]=255&r}}(r.VBR_seek_table,a);var f=r.sideinfo_len;e.error_protection&&(f-=2),e.VBR==m.vbr_off?(o[f++]=255&"Info".charAt(0),o[f++]=255&"Info".charAt(1),o[f++]=255&"Info".charAt(2),o[f++]=255&"Info".charAt(3)):(o[f++]=255&"Xing".charAt(0),o[f++]=255&"Xing".charAt(1),o[f++]=255&"Xing".charAt(2),o[f++]=255&"Xing".charAt(3)),u(o,f,15),u(o,f+=4,r.VBR_seek_table.nVbrNumFrames),f+=4;var v=r.VBR_seek_table.nBytesWritten+r.VBR_seek_table.TotalFrameSize;u(o,f,0|v),f+=4,h.arraycopy(a,0,o,f,a.length),f+=a.length,e.error_protection&&n.CRC_writeheader(r,o);var b=0;for(l=0;l255?255:t.lowpassfreq/100+.5),S=0,C=0,k=t.internal_flags.noise_shaping,E=0,P=0,T=0,M=0!=(1&t.exp_nspsytune),R=0!=(2&t.exp_nspsytune),A=!1,O=!1,N=t.internal_flags.nogap_total,D=t.internal_flags.nogap_current,B=t.ATHtype;switch(t.VBR){case vbr_abr:h=t.VBR_mean_bitrate_kbps;break;case vbr_off:h=t.brate;break;default:h=t.VBR_min_bitrate_kbps}switch(r=0+(t.VBR.ordinal()510&&(m.RadioGain=510),m.RadioGain<-510&&(m.RadioGain=-510),C=8192,C|=3072,m.RadioGain>=0?C|=m.RadioGain:(C|=512,C|=-m.RadioGain)),m.findPeakSample&&(S=Math.abs(0|m.PeakSample/32767*Math.pow(2,23)+.5)),-1!=N&&(D>0&&(O=!0),D48e3?3:1,(t.short_blocks==p.short_block_forced||t.short_blocks==p.short_block_dispensed||-1==t.lowpassfreq&&-1==t.highpassfreq||t.scale_leftt.scale_right||t.disable_reservoir&&t.brate<320||t.noATH||t.ATHonly||0==B||t.in_samplerate<=32e3)&&(P=1),a=k+(E<<2)+(P<<5)+(T<<6),l=m.nMusicCRC,u(n,i+f,b),f+=4;for(var I=0;I<9;I++)n[i+f+I]=255&y.charAt(I);n[i+(f+=9)]=255&r,n[i+ ++f]=255&x,u(n,i+ ++f,S),d(n,i+(f+=4),C),d(n,i+(f+=2),0),n[i+(f+=2)]=255&c,n[i+ ++f]=h>=255?255:255&h,n[i+ ++f]=255&g>>4,n[i+f+1]=255&(g<<4)+(v>>8),n[i+f+2]=255&v,n[i+(f+=3)]=255&a,f++,n[i+f++]=0,d(n,i+f,t.preset),u(n,i+(f+=2),e),d(n,i+(f+=4),l),f+=2;for(var F=0;Fi.length?-1:(r<1||n.write(i,0,r),0)}}function S(t,e,n,s){this.xlen=t,this.linmax=e,this.table=n,this.hlen=s}d.MAX_VALUE=34028235e31,m.vbr_off=new m(0),m.vbr_mt=new m(1),m.vbr_rh=new m(2),m.vbr_abr=new m(3),m.vbr_mtrh=new m(4),m.vbr_default=m.vbr_mtrh,f.STEREO=new f(0),f.JOINT_STEREO=new f(1),f.DUAL_CHANNEL=new f(2),f.MONO=new f(3),f.NOT_SET=new f(4),v.STEPS_per_dB=100,v.MAX_dB=120,v.GAIN_NOT_ENOUGH_SAMPLES=-24601,v.GAIN_ANALYSIS_ERROR=0,v.GAIN_ANALYSIS_OK=1,v.INIT_GAIN_ANALYSIS_ERROR=0,v.INIT_GAIN_ANALYSIS_OK=1,v.YULE_ORDER=10,v.MAX_ORDER=v.YULE_ORDER,v.MAX_SAMP_FREQ=48e3,v.RMS_WINDOW_TIME_NUMERATOR=1,v.RMS_WINDOW_TIME_DENOMINATOR=20,v.MAX_SAMPLES_PER_WINDOW=v.MAX_SAMP_FREQ*v.RMS_WINDOW_TIME_NUMERATOR/v.RMS_WINDOW_TIME_DENOMINATOR+1,w.EQ=function(t,e){return Math.abs(t)>Math.abs(e)?Math.abs(t-e)<=1e-6*Math.abs(t):Math.abs(t-e)<=1e-6*Math.abs(e)},w.NEQ=function(t,e){return!w.EQ(t,e)},x.NUMTOCENTRIES=100,x.MAXFRAMESIZE=2880;var C={};function k(t){this.bits=t}function E(){this.setModules=function(t,e){t,e}}function P(){this.over_noise=0,this.tot_noise=0,this.max_noise=0,this.over_count=0,this.over_SSD=0,this.bits=0}function T(){this.class_id=0,this.num_samples=0,this.num_channels=0,this.in_samplerate=0,this.out_samplerate=0,this.scale=0,this.scale_left=0,this.scale_right=0,this.analysis=!1,this.bWriteVbrTag=!1,this.decode_only=!1,this.quality=0,this.mode=f.STEREO,this.force_ms=!1,this.free_format=!1,this.findReplayGain=!1,this.decode_on_the_fly=!1,this.write_id3tag_automatic=!1,this.brate=0,this.compression_ratio=0,this.copyright=0,this.original=0,this.extension=0,this.emphasis=0,this.error_protection=0,this.strict_ISO=!1,this.disable_reservoir=!1,this.quant_comp=0,this.quant_comp_short=0,this.experimentalY=!1,this.experimentalZ=0,this.exp_nspsytune=0,this.preset=0,this.VBR=null,this.VBR_q_frac=0,this.VBR_q=0,this.VBR_mean_bitrate_kbps=0,this.VBR_min_bitrate_kbps=0,this.VBR_max_bitrate_kbps=0,this.VBR_hard_min=0,this.lowpassfreq=0,this.highpassfreq=0,this.lowpasswidth=0,this.highpasswidth=0,this.maskingadjust=0,this.maskingadjust_short=0,this.ATHonly=!1,this.ATHshort=!1,this.noATH=!1,this.ATHtype=0,this.ATHcurve=0,this.ATHlower=0,this.athaa_type=0,this.athaa_loudapprox=0,this.athaa_sensitivity=0,this.short_blocks=null,this.useTemporal=!1,this.interChRatio=0,this.msfix=0,this.tune=!1,this.tune_value_a=0,this.version=0,this.encoder_delay=0,this.encoder_padding=0,this.framesize=0,this.frameNum=0,this.lame_allocated_gfp=0,this.internal_flags=null}function M(){this.linprebuf=s(2*v.MAX_ORDER),this.linpre=0,this.lstepbuf=s(v.MAX_SAMPLES_PER_WINDOW+v.MAX_ORDER),this.lstep=0,this.loutbuf=s(v.MAX_SAMPLES_PER_WINDOW+v.MAX_ORDER),this.lout=0,this.rinprebuf=s(2*v.MAX_ORDER),this.rinpre=0,this.rstepbuf=s(v.MAX_SAMPLES_PER_WINDOW+v.MAX_ORDER),this.rstep=0,this.routbuf=s(v.MAX_SAMPLES_PER_WINDOW+v.MAX_ORDER),this.rout=0,this.sampleWindow=0,this.totsamp=0,this.lsum=0,this.rsum=0,this.freqindex=0,this.first=0,this.A=n(0|v.STEPS_per_dB*v.MAX_dB),this.B=n(0|v.STEPS_per_dB*v.MAX_dB)}function R(){this.useAdjust=0,this.aaSensitivityP=0,this.adjust=0,this.adjustLimit=0,this.decay=0,this.floor=0,this.l=s(L.SBMAX_l),this.s=s(L.SBMAX_s),this.psfb21=s(L.PSFB21),this.psfb12=s(L.PSFB12),this.cb_l=s(L.CBANDS),this.cb_s=s(L.CBANDS),this.eql_w=s(L.BLKSIZE/2)}function A(t){var e=t;this.quantize=e,this.iteration_loop=function(t,e,i,o){var r,a=t.internal_flags,l=s(I.SFBMAX),c=s(576),h=n(2),u=0,p=a.l3_side,d=new k(u);this.quantize.rv.ResvFrameBegin(t,d),u=d.bits;for(var m=0;m>2&63)>=32&&(n-=64),l=Math.pow(10,n/4/10),(n=e.exp_nspsytune>>8&63)>=32&&(n-=64),u=Math.pow(10,n/4/10),(n=e.exp_nspsytune>>14&63)>=32&&(n-=64),m=Math.pow(10,n/4/10),(n=e.exp_nspsytune>>20&63)>=32&&(n-=64),_=m*Math.pow(10,n/4/10),n=0;nQ.MAX_BITS_PER_GRANULE&&(f=Q.MAX_BITS_PER_GRANULE),l=0,c=0;c3*o/4&&(p[c]=3*o/4),p[c]<0&&(p[c]=0),p[c]+i[c]>Q.MAX_BITS_PER_CHANNEL&&(p[c]=Math.max(0,Q.MAX_BITS_PER_CHANNEL-i[c])),l+=p[c];if(l>m)for(c=0;cQ.MAX_BITS_PER_GRANULE){for(c=0;c.5&&(i=.5);var o=0|.5*i*(t[0]+t[1]);o>Q.MAX_BITS_PER_CHANNEL-t[0]&&(o=Q.MAX_BITS_PER_CHANNEL-t[0]),o<0&&(o=0),t[1]>=125&&(t[1]-o>125?(t[0]s&&(t[0]=s*t[0]/o,t[1]=s*t[1]/o)},this.athAdjust=function(t,e,n){var s=90.30873362,i=u.FAST_LOG10_X(e,10),o=t*t,r=0;return i-=n,o>1e-20&&(r=1+u.FAST_LOG10_X(o,10/s)),r<0&&(r=0),i*=r,i+=n+s-94.82444863,Math.pow(10,.1*i)},this.calc_xmin=function(t,e,n,s){var i,o=0,r=t.internal_flags,a=0,l=0,c=r.ATH,h=n.xr,u=t.VBR==m.vbr_mtrh?1:0,p=r.masking_lower;for(t.VBR!=m.vbr_mtrh&&t.VBR!=m.vbr_mt||(p=1),i=0;i>1,E=0;do{E+=T=h[a]*h[a],S+=T0);if(E>y&&l++,i==L.SBPSY_l)S<(k=y*r.nsPsy.longfact[i])&&(S=k);if(0!=u&&(y=S),!t.ATHonly)if((C=e.en.l[i])>0)k=E*e.thm.l[i]*p/C,0!=u&&(k*=r.nsPsy.longfact[i]),y>1;x=b/_,S=2220446049250313e-31;do{var T,M;E+=T=h[a]*h[a],S+=T0);if(E>b&&l++,g==L.SBPSY_s)S<(k=b*r.nsPsy.shortfact[g])&&(S=k);if(y=0!=u?S:b,!t.ATHonly&&!t.ATHshort)if((C=e.en.s[g][v])>0)k=E*e.thm.s[g][v]*p/C,0!=u&&(k*=r.nsPsy.shortfact[g]),ys[o-3+1]&&(s[o-3+1]+=(s[o-3]-s[o-3+1])*r.decay),s[o-3+1]>s[o-3+2]&&(s[o-3+2]+=(s[o-3+1]-s[o-3+2])*r.decay))}return l},this.calc_noise_core=function(t,e,n,i){var o=0,r=e.s,a=t.l3_enc;if(r>t.count1)for(;0!=n--;){c=t.xr[r],r++,o+=c*c,c=t.xr[r],r++,o+=c*c}else if(r>t.big_values){var l=s(2);for(l[0]=0,l[1]=i;0!=n--;){c=Math.abs(t.xr[r])-l[a[r]],r++,o+=c*c,c=Math.abs(t.xr[r])-l[a[r]],r++,o+=c*c}}else for(;0!=n--;){var c;c=Math.abs(t.xr[r])-p[a[r]]*i,r++,o+=c*c,c=Math.abs(t.xr[r])-p[a[r]]*i,r++,o+=c*c}return e.s=r,o},this.calc_noise=function(t,e,n,s,i){var o,r,a=0,h=0,p=0,d=0,m=0,f=-20,g=0,v=t.scalefac,b=0;for(s.over_SSD=0,o=0;o>1,g+t.width[o]>t.max_nonzero_coeff)r=(S=t.max_nonzero_coeff-g+1)>0?S>>1:0;var k=new _(g);x=this.calc_noise_core(t,k,r,C),g=k.s,null!=i&&(i.step[o]=w,i.noise[o]=x),x=n[a++]=x/e[h++],x=u.FAST_LOG10(Math.max(x,1e-20)),null!=i&&(i.noise_log[o]=x)}if(null!=i&&(i.global_gain=t.global_gain),m+=x,x>0)y=Math.max(0|10*x+.5,1),s.over_SSD+=y*y,p++,d+=x;f=Math.max(f,x)}return s.over_count=p,s.tot_noise=m,s.over_noise=d,s.max_noise=f,p},this.set_pinfo=function(t,e,n,i,o){var r,a,c,h,u,p=t.internal_flags,d=0==e.scalefac_scale?.5:1,m=e.scalefac,f=s(I.SFBMAX),g=s(I.SFBMAX),_=new P;calc_xmin(t,n,e,f),calc_noise(e,f,g,_,null);var v=0;for(a=e.sfb_lmax,e.block_type!=L.SHORT_TYPE&&0==e.mixed_block_flag&&(a=22),r=0;r0&&!t.ATHonly?h/=n.en.l[r]:h=0,p.pinfo.thr[i][o][r]=u*Math.max(h*n.thm.l[r],p.ATH.l[r]),p.pinfo.LAMEsfb[i][o][r]=0,0!=e.preflag&&r>=11&&(p.pinfo.LAMEsfb[i][o][r]=-d*l[r]),r0?h/=n.en.s[r][x]:h=0,(t.ATHonly||t.ATHshort)&&(h=0),p.pinfo.thr_s[i][o][3*r+x]=u*Math.max(h*n.thm.s[r][x],p.ATH.s[r]),p.pinfo.LAMEsfb_s[i][o][3*r+x]=-2*e.subblock_gain[x],r0?(o=n.over_SSD<=e.over_SSD,n.over_SSD==e.over_SSD&&(o=n.bits.2||n.max_noise<=0&&e.max_noise<0&&e.max_noise>n.max_noise-.2&&n.tot_noise0&&e.max_noise>n.max_noise-.2&&n.tot_noise0&&e.max_noise>-.05&&e.max_noise>n.max_noise-.1&&n.tot_noise+n.over_noise0&&e.max_noise>-.1&&e.max_noise>n.max_noise-.15&&n.tot_noise+n.over_noise+n.over_noise1?a=Math.pow(a,.5):a*=.95;break;case 0:default:a>1?a=1:a*=.95}var h=0;for(l=0;le.xrpow_max&&(e.xrpow_max=s[h+u]);if(2==r.noise_shaping_amp)return}}}(t,e,s,o,r);var h=a(e);return!h&&(!(h=2==l.mode_gr?i.scale_bitcount(e):i.scale_bitcount_lsf(l,e))||(l.noise_shaping>1&&(c.fill(l.pseudohalf,0),0==e.scalefac_scale?(!function(t,e){for(var s=0,i=0;it.xrpow_max&&(t.xrpow_max=e[s+a])}t.scalefac[i]=r>>1}t.preflag=0,t.scalefac_scale=1}(e,o),h=!1):e.block_type==L.SHORT_TYPE&&l.subblock_gain>0&&(h=function(t,e,s){var i,o=e.scalefac;for(i=0;i=16)return!0;for(var r=0;r<3;r++){var a=0,l=0;for(i=e.sfb_lmax+r;i=7)return!0;e.subblock_gain[r]++;var c=t.scalefac_band.l[e.sfb_lmax];for(i=e.sfb_lmax+r;i>e.scalefac_scale)>=0)o[i]=u,c+=3*h;else{o[i]=0;var p=210+(u<e.xrpow_max&&(e.xrpow_max=s[c+d]);c+=h*(3-r-1)}}var m=n.IPOW20(202);c+=e.width[i]*(r+1);for(d=-e.width[i];d<0;d++)s[c+d]*=m,s[c+d]>e.xrpow_max&&(e.xrpow_max=s[c+d])}}return!1}(l,e,o)||a(e))),h||(h=2==l.mode_gr?i.scale_bitcount(e):i.scale_bitcount_lsf(l,e)),!h))}this.setModules=function(s,r,a,l){t=s,e=r,this.rv=r,n=a,this.qupvt=a,i=l,o.setModules(n,i)},this.ms_convert=function(t,e){for(var n=0;n<576;++n){var s=t.tt[e][0].xr[n],i=t.tt[e][1].xr[n];t.tt[e][0].xr[n]=(s+i)*(.5*u.SQRT2),t.tt[e][1].xr[n]=(s-i)*(.5*u.SQRT2)}},this.init_xrpow=function(t,e,n){var s=0,i=0|e.max_nonzero_coeff;if(e.xrpow_max=0,c.fill(n,i,576,0),(s=function(t,e,n,s){s=0;for(var i=0;i<=n;++i){var o=Math.abs(t.xr[i]);s+=o,e[i]=Math.sqrt(o*Math.sqrt(o)),e[i]>t.xrpow_max&&(t.xrpow_max=e[i])}return s}(e,n,i,s))>1e-20){var o=0;0!=(2&t.substep_shaping)&&(o=1);for(var r=0;r=0&&!o;r--){var a=t.scalefac_band.psfb21[r],l=t.scalefac_band.psfb21[r+1],c=n.athAdjust(s.adjust,s.psfb21[r],s.floor);t.nsPsy.longfact[21]>1e-12&&(c*=t.nsPsy.longfact[21]);for(var h=l-1;h>=a;h--){if(!(Math.abs(i[h])=0&&!o;r--){l=(a=3*t.scalefac_band.s[12]+(t.scalefac_band.s[13]-t.scalefac_band.s[12])*u+(t.scalefac_band.psfb12[r]-t.scalefac_band.psfb12[0]))+(t.scalefac_band.psfb12[r+1]-t.scalefac_band.psfb12[r]);var p=n.athAdjust(s.adjust,s.psfb12[r],s.floor);t.nsPsy.shortfact[12]>1e-12&&(p*=t.nsPsy.shortfact[12]);for(h=l-1;h>=a;h--){if(!(Math.abs(i[h])=1||(c.sort(r,l-g,g),w.EQ(r[l-1],0)))){p=(1-a[u])*o[u],d=0,f=0;do{var _;for(m=1;f+m0)}}while(++un?(u==r.BINSEARCH_DOWN&&(c=!0),c&&(l/=2),u=r.BINSEARCH_UP,p=l):(u==r.BINSEARCH_UP&&(c=!0),c&&(l/=2),u=r.BINSEARCH_DOWN,p=-l),e.global_gain+=p,e.global_gain<0&&(e.global_gain=0,c=!0),e.global_gain>255&&(e.global_gain=255,c=!0)}for(;a>n&&e.global_gain<255;)e.global_gain++,a=i.count_bits(t,o,e,null);t.CurrentStep[s]=h-e.global_gain>=4?4:2,t.OldValue[s]=e.global_gain,e.part2_3_length=a}(d,e,u,c,a),0==d.noise_shaping)return 100;n.calc_noise(e,o,_,v,b),v.bits=e.part2_3_length,f.assign(e);var C=0;for(h.arraycopy(a,0,g,0,576);!w;){do{var k,E=new P,T=255;if(k=0!=(2&d.substep_shaping)?20:3,d.sfb21_extra){if(_[f.sfbmax]>1)break;if(f.block_type==L.SHORT_TYPE&&(_[f.sfbmax+1]>1||_[f.sfbmax+2]>1))break}if(!p(t,f,_,a,x))break;0!=f.scalefac_scale&&(T=254);var M=u-f.part2_length;if(M<=0)break;for(;(f.part2_3_length=i.count_bits(d,a,f,b))>M&&f.global_gain<=T;)f.global_gain++;if(f.global_gain>T)break;if(0==v.over_count){for(;(f.part2_3_length=i.count_bits(d,a,f,b))>y&&f.global_gain<=T;)f.global_gain++;if(f.global_gain>T)break}if(n.calc_noise(f,o,_,E,b),E.bits=f.part2_3_length,0!=(l(e.block_type!=L.SHORT_TYPE?t.quant_comp:t.quant_comp_short,v,E,f,_)?1:0))y=e.part2_3_length,v=E,e.assign(f),C=0,h.arraycopy(a,0,g,0,576);else if(0==d.full_outer_loop){if(++C>k&&0==v.over_count)break;if(3==d.noise_shaping_amp&&x&&C>30)break;if(3==d.noise_shaping_amp&&x&&f.global_gain-S>15)break}}while(f.global_gain+f.scalefac_scale<255);3==d.noise_shaping_amp?x?w=!0:(f.assign(e),h.arraycopy(g,0,a,0,576),C=0,S=f.global_gain,x=!0):w=!0}return t.VBR==m.vbr_rh||t.VBR==m.vbr_mtrh?h.arraycopy(g,0,a,0,576):0!=(1&d.substep_shaping)&&trancate_smallspectrums(d,e,o,a),v.over_count},this.iteration_finish_one=function(t,n,s){var o=t.l3_side,r=o.tt[n][s];i.best_scalefac_store(t,n,s,o),1==t.use_best_huffman&&i.best_huffman_divide(t,r),e.ResvAdjust(t,r)},this.VBR_encode_granule=function(t,e,n,i,o,r,a){var l,u=t.internal_flags,p=new B,d=s(576),m=a,f=a+1,g=(a+r)/2,_=0,v=u.sfb21_extra;c.fill(p.l3_enc,0);do{u.sfb21_extra=!(g>m-42)&&v,outer_loop(t,e,n,i,o,g)<=0?(_=1,f=e.part2_3_length,p.assign(e),h.arraycopy(i,0,d,0,576),l=(a=f-32)-r,g=(a+r)/2):(l=a-(r=g+32),g=(a+r)/2,0!=_&&(_=2,e.assign(p),h.arraycopy(d,0,i,0,576)))}while(l>12);u.sfb21_extra=v,2==_&&h.arraycopy(p.l3_enc,0,e.l3_enc,0,576)},this.get_framebits=function(n,s){var i=n.internal_flags;i.bitrate_index=i.VBR_min_bitrate;var o=t.getframebits(n);i.bitrate_index=1,o=t.getframebits(n);for(var r=1;r<=i.VBR_max_bitrate;r++){i.bitrate_index=r;var a=new k(o);s[r]=e.ResvFrameBegin(n,a),o=a.bits}},this.VBR_old_prepare=function(t,s,i,o,r,a,l,c,h){var u,p=t.internal_flags,d=0,m=1,f=0;p.bitrate_index=p.VBR_max_bitrate;var g=e.ResvFrameBegin(t,new k(0))/p.mode_gr;get_framebits(t,a);for(var _=0;_a[p.VBR_max_bitrate]&&(c[_][b]*=a[p.VBR_max_bitrate],c[_][b]/=f),l[_][b]>c[_][b]&&(l[_][b]=c[_][b]);return m},this.bitpressure_strategy=function(t,e,n,s){for(var i=0;il&&(a[m][f]*=l,a[m][f]/=p);return h},this.calc_target_bits=function(s,i,o,r,a,l){var c,h,u,p,d=s.internal_flags,m=d.l3_side,f=0;d.bitrate_index=d.VBR_max_bitrate;var g=new k(f);for(l[0]=e.ResvFrameBegin(s,g),f=g.bits,d.bitrate_index=1,f=t.getframebits(s)-8*d.sideinfo_len,a[0]=f/(d.mode_gr*d.channels_out),f=s.VBR_mean_bitrate_kbps*s.framesize*1e3,0!=(1&d.substep_shaping)&&(f*=1.09),f/=s.out_samplerate,f-=8*d.sideinfo_len,f/=d.mode_gr*d.channels_out,(c=.93+.07*(11-s.compression_ratio)/5.5)<.9&&(c=.9),c>1&&(c=1),h=0;h700){var v=int((i[h][u]-700)/1.4),b=m.tt[h][u];r[h][u]=int(c*f),b.block_type==L.SHORT_TYPE&&v3*f/2?v=3*f/2:v<0&&(v=0),r[h][u]+=v}r[h][u]>Q.MAX_BITS_PER_CHANNEL&&(r[h][u]=Q.MAX_BITS_PER_CHANNEL),_+=r[h][u]}if(_>Q.MAX_BITS_PER_GRANULE)for(u=0;uQ.MAX_BITS_PER_CHANNEL&&(r[h][u]=Q.MAX_BITS_PER_CHANNEL),p+=r[h][u];if(p>l[0])for(h=0;h=0;--X){var tt,et;tt=U[H+X]*o[20+X]+U[H+-1-X]*r[28+X],et=U[H+X]*r[28+X]-U[H+-1-X]*o[20+X],U[H+-1-X]=tt,U[H+X]=et}}}if(B=d,I=286,1==t.mode_gr)for(var nt=0;nt<18;nt++)h.arraycopy(t.sb_sample[F][1][nt],0,t.sb_sample[F][0][nt],0,32)}}}function L(){var t=L.FFTOFFSET,e=L.MPG_MD_MS_LR,i=null;this.psy=null;var r=null,a=null,c=null;this.setModules=function(t,e,n,s){i=t,this.psy=e,r=e,a=s,c=n};var u=new j;this.lame_encode_mp3_frame=function(p,d,g,_,v,b){var y,w=l([2,2]);w[0][0]=new V,w[0][1]=new V,w[1][0]=new V,w[1][1]=new V;var x,S=l([2,2]);S[0][0]=new V,S[0][1]=new V,S[1][0]=new V,S[1][1]=new V;var C,k,E,P=[null,null],T=p.internal_flags,M=o([2,4]),R=[.5,.5],A=[[0,0],[0,0]],O=[[0,0],[0,0]];if(P[0]=d,P[1]=g,0==T.lame_encode_frame_init&&function(t,e){var n,i,o=t.internal_flags;if(0==o.lame_encode_frame_init){var r,a,l=s(2014),c=s(2014);for(o.lame_encode_frame_init=1,r=0,a=0;r<286+576*(1+o.mode_gr);++r)r<576*o.mode_gr?(l[r]=0,2==o.channels_out&&(c[r]=0)):(l[r]=e[0][a],2==o.channels_out&&(c[r]=e[1][a]),++a);for(i=0;i0&&(R[E]=M[E][3]/R[E])),k=0;k.03125)t.ATH.adjust>=1?t.ATH.adjust=1:t.ATH.adjust=s?(t.ATH.adjust*=.075*s+.925,t.ATH.adjust=s?t.ATH.adjust=s:t.ATH.adjust>1,f=(m=i<<1)+(d=i),i=m<<1,r=(o=e)+g;do{S=t[o+0]-t[o+d],x=t[o+0]+t[o+d],P=t[o+m]-t[o+f],k=t[o+m]+t[o+f],t[o+m]=x-k,t[o+0]=x+k,t[o+f]=S-P,t[o+d]=S+P,S=t[r+0]-t[r+d],x=t[r+0]+t[r+d],P=u.SQRT2*t[r+f],k=u.SQRT2*t[r+m],t[r+m]=x-k,t[r+0]=x+k,t[r+f]=S-P,t[r+d]=S+P,r+=i,o+=i}while(o=0);i(n[l],c,L.BLKSIZE_s/2)}},this.fft_long=function(e,n,s,r,a){var l=L.BLKSIZE/8-1,c=L.BLKSIZE/2;do{var h,u,p,d,m,f=255&o[l];u=(h=t[f]*r[s][a+f])-(m=t[f+512]*r[s][a+f+512]),h+=m,d=(p=t[f+256]*r[s][a+f+256])-(m=t[f+768]*r[s][a+f+768]),p+=m,n[(c-=4)+0]=h+p,n[c+2]=h-p,n[c+1]=u+d,n[c+3]=u-d,u=(h=t[f+1]*r[s][a+f+1])-(m=t[f+513]*r[s][a+f+513]),h+=m,d=(p=t[f+257]*r[s][a+f+257])-(m=t[f+769]*r[s][a+f+769]),p+=m,n[c+L.BLKSIZE/2+0]=h+p,n[c+L.BLKSIZE/2+2]=h-p,n[c+L.BLKSIZE/2+1]=u+d,n[c+L.BLKSIZE/2+3]=u-d}while(--l>=0);i(n,c,L.BLKSIZE/2)},this.init_fft=function(n){for(var s=0;s=0;--f){var g=i[o+0][f],_=i[o+1][f];i[o+0][f]=(g+_)*u.SQRT2*.5,i[o+1][f]=(g-_)*u.SQRT2*.5}for(var v=2;v>=0;--v)for(f=L.BLKSIZE_s-1;f>=0;--f){g=a[l+0][v][f],_=a[l+1][v][f];a[l+0][v][f]=(g+_)*u.SQRT2*.5,a[l+1][v][f]=(g-_)*u.SQRT2*.5}}n[0]=i[o+0][0],n[0]*=n[0];for(f=L.BLKSIZE/2-1;f>=0;--f){var b=i[o+0][L.BLKSIZE/2-f],y=i[o+0][L.BLKSIZE/2+f];n[L.BLKSIZE/2-f]=.5*(b*b+y*y)}for(v=2;v>=0;--v){s[v][0]=a[l+0][v][0],s[v][0]*=s[v][0];for(f=L.BLKSIZE_s/2-1;f>=0;--f){b=a[l+0][v][L.BLKSIZE_s/2-f],y=a[l+0][v][L.BLKSIZE_s/2+f];s[v][L.BLKSIZE_s/2-f]=.5*(b*b+y*y)}}var w=0;for(f=11;ft){if(!(e=e*h)return t+e;r=t/e}if(t+=e,s+3<=6){if(r>=l)return t;var a=0|u.FAST_LOG10_X(r,16);return t*b[a]}var c,p;a=0|u.FAST_LOG10_X(r,16);return e=0!=o?i.ATH.cb_s[n]*i.ATH.adjust:i.ATH.cb_l[n]*i.ATH.adjust,te?(c=1,a<=13&&(c=y[a]),p=u.FAST_LOG10_X(t/e,10/15),t*((v[a]-c)*p+c)):a>13?t:t*y[a]:t*v[a]}var x=[1.7782755904,1.35879*1.35879,1.38454*1.38454,1.39497*1.39497,1.40548*1.40548,1.3537*1.3537,1.6999465924,1.22321*1.22321,1.3169398564,1];function S(t,e,n){var s;if(t<0&&(t=0),e<0&&(e=0),t<=0)return e;if(e<=0)return t;if(s=e>t?e/t:t/e,-2<=n&&n<=2){if(s>=l)return t+e;var i=0|u.FAST_LOG10_X(s,16);return(t+e)*x[i]}return s=h){++o;break}var p=t.PSY.bo_s_weight[o],d=1-p;a=p*e[r],l=p*n[r],t.en[s].s[o][i]+=a,t.thm[s].s[o][i]+=l,a=d*e[r],l=d*n[r]}for(;o=c){++i;break}var u=t.PSY.bo_l_weight[i],p=1-u;r=u*e[o],a=u*n[o],t.en[s].l[i]+=r,t.thm[s].l[i]+=a,r=p*e[o],a=p*n[o]}for(;i=1?t:n<=0?e:e>0?Math.pow(t/e,n)*e:0}var T=[11.8,13.6,17.2,32,46.5,51.3,57.5,67.1,71.5,84.6,97.6,130];function M(t,n){for(var s=309.07,i=0;i0){var a=r*n,l=t.en.s[i][o];l>a&&(s+=l>1e10*a?T[i]*(10*e):T[i]*u.FAST_LOG10(l/a))}}return s}var R=[6.8,5.8,5.8,6.4,6.5,9.9,12.1,14.4,15,18.9,21.6,26.9,34.2,40.2,46.8,56.5,60.7,73.9,85.7,93.4,126.1];function A(t,n){for(var s=281.0575,i=0;i0){var r=o*n,a=t.en.l[i];a>r&&(s+=a>1e10*r?R[i]*(10*e):R[i]*u.FAST_LOG10(a/r))}}return s}function O(t,e,n,s,i){var o,r;for(o=r=0;o0?((a=e[o])i&&(l=i),s[o]=l):s[o]=0;for(o=1;o0)(a=e[o-1])i&&(l=i),s[o]=l;else s[o]=0}(r=n[o-1]+n[o])>0?((a=e[o-1])i&&(l=i),s[o]=l):s[o]=0}var D=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function B(e,n,s,i,o,r,a,l){var c=e.internal_flags;if(i<2)t.fft_long(c,a[l],i,n,s);else if(2==i)for(var h=L.BLKSIZE-1;h>=0;--h){var p=a[l+0][h],d=a[l+1][h];a[l+0][h]=(p+d)*u.SQRT2*.5,a[l+1][h]=(p-d)*u.SQRT2*.5}r[0]=a[l+0][0],r[0]*=r[0];for(h=L.BLKSIZE/2-1;h>=0;--h){var m=a[l+0][L.BLKSIZE/2-h],f=a[l+0][L.BLKSIZE/2+h];r[L.BLKSIZE/2-h]=.5*(m*m+f*f)}var g=0;for(h=11;h=0;--h){var p=a[l+0][o][h],d=a[l+1][o][h];a[l+0][o][h]=(p+d)*u.SQRT2*.5,a[l+1][o][h]=(p-d)*u.SQRT2*.5}r[o][0]=a[l+0][o][0],r[o][0]*=r[o][0];for(h=L.BLKSIZE_s/2-1;h>=0;--h){var m=a[l+0][o][L.BLKSIZE_s/2-h],f=a[l+0][o][L.BLKSIZE_s/2+h];r[o][L.BLKSIZE_s/2-h]=.5*(m*m+f*f)}}function F(t,e,n,s){var i=t.internal_flags;2==t.athaa_loudapprox&&n<2&&(i.loudness_sq[e][n]=i.loudness_sq_save[n],i.loudness_sq_save[n]=r(s,i))}this.L3psycho_anal_ns=function(t,e,i,r,l,h,u,d,g,v){var b,y,x,S,T,R,B,I,F,V,j=t.internal_flags,q=o([2,L.BLKSIZE]),U=o([2,3,L.BLKSIZE_s]),H=s(L.CBANDS+1),W=s(L.CBANDS+1),Q=s(L.CBANDS+2),X=n(2),z=n(2),G=o([2,576]),Y=n(L.CBANDS+2),K=n(L.CBANDS+2);for(c.fill(K,0),b=j.channels_out,t.mode==f.JOINT_STEREO&&(b=4),F=t.VBR==m.vbr_off?0==j.ResvMax?0:j.ResvSize/j.ResvMax*.5:t.VBR==m.vbr_rh||t.VBR==m.vbr_mtrh||t.VBR==m.vbr_mt?.6:1,y=0;y2&&(h[r][y].en.assign(j.en[y+2]),h[r][y].thm.assign(j.thm[y+2]))}for(y=0;ynt[S+3-2]?gt/=nt[S+3-2]:gt=nt[S+3-2]>10*gt?nt[S+3-2]/(10*gt):0,it[S+3]=gt}if(t.analysis){var _t=it[0];for(S=1;S<12;S++)_tet&&(lt[S/3]=S%3+1);for(S=1;S<4;S++){(st[S-1]>st[S]?st[S-1]/st[S]:st[S]/st[S-1])<1.7&&(lt[S]=0,1==S&&(lt[0]=0))}for(0!=lt[0]&&0!=j.nsPsy.lastAttacks[y]&&(lt[0]=0),3!=j.nsPsy.lastAttacks[y]&<[0]+lt[1]+lt[2]+lt[3]==0||(ot=0,0!=lt[1]&&0!=lt[0]&&(lt[1]=0),0!=lt[2]&&0!=lt[1]&&(lt[2]=0),0!=lt[3]&&0!=lt[2]&&(lt[3]=0)),y<2?z[y]=ot:0==ot&&(z[0]=z[1]=0),g[y]=j.tot_ener[y],a(t,ct,ht,q,1&y,U,1&y,r,y,e,i),O(j,ct,H,rt,at),N(j,rt,at,Y),I=0;I<3;I++){var vt,bt;for(E(t,ht,W,Q,y,I),C(j,W,Q,y,I),B=0;B=2||1==lt[I+1]){var yt=0!=I?I-1:2;gt=P(j.thm[y].s[B][yt],bt,.6*F);bt=Math.min(bt,gt)}if(1==lt[I]){yt=0!=I?I-1:2,gt=P(j.thm[y].s[B][yt],bt,.3*F);bt=Math.min(bt,gt)}else if(0!=I&&3==lt[I-1]||0==I&&3==j.nsPsy.lastAttacks[y]){yt=2!=I?I+1:0,gt=P(j.thm[y].s[B][yt],bt,.3*F);bt=Math.min(bt,gt)}vt=nt[3*I+3]+nt[3*I+4]+nt[3*I+5],6*nt[3*I+5]0&&function(t,e){var n=t.internal_flags;if(n.channels_out>1){for(var s=0;s1.58*t.thm[1].l[e]||t.thm[1].l[e]>1.58*t.thm[0].l[e])){var n=t.mld_l[e]*t.en[3].l[e],s=Math.max(t.thm[2].l[e],Math.min(t.thm[3].l[e],n));n=t.mld_l[e]*t.en[2].l[e];var i=Math.max(t.thm[3].l[e],Math.min(t.thm[2].l[e],n));t.thm[2].l[e]=s,t.thm[3].l[e]=i}for(e=0;e1.58*t.thm[1].s[e][o]||t.thm[1].s[e][o]>1.58*t.thm[0].s[e][o])){n=t.mld_s[e]*t.en[3].s[e][o],s=Math.max(t.thm[2].s[e][o],Math.min(t.thm[3].s[e][o],n));n=t.mld_s[e]*t.en[2].s[e][o];i=Math.max(t.thm[3].s[e][o],Math.min(t.thm[2].s[e][o],n));t.thm[2].s[e][o]=s,t.thm[3].s[e][o]=i}}(j),V=t.msfix,Math.abs(V)>0&&function(t,e,n){var s=e,i=Math.pow(10,n);e*=2,s*=2;for(var o=0;o1?(Ct=d,Pt=-2,kt=L.NORM_TYPE,v[0]!=L.SHORT_TYPE&&v[1]!=L.SHORT_TYPE||(kt=L.SHORT_TYPE),Et=h[r][y-2]):(Ct=u,Pt=0,kt=v[y],Et=l[r][y]),kt==L.SHORT_TYPE?Ct[Pt+y]=M(Et,j.masking_lower):Ct[Pt+y]=A(Et,j.masking_lower),t.analysis&&(j.pinfo.pe[r][y]=Ct[Pt+y])}return 0};var V=[-1730326e-23,-.01703172,-1349528e-23,.0418072,-673278e-22,-.0876324,-30835e-21,.1863476,-1104424e-22,-.627638];function j(t,e,n){if(0==n)for(var s=0;s0?((a=e[o])i&&(l=i),s[o]=l):s[o]=0,o=1;o0)(a=e[o-1])i&&(l=i),s[o]=l;else s[o]=0}(r=n[o-1]+n[o])>0?((a=e[o-1])i&&(l=i),s[o]=l):s[o]=0}(h,u,p,d),l=c=0;cw&&(i[c]=w),h.masking_lower>1&&(i[c]*=h.masking_lower),i[c]>n[c]&&(i[c]=n[c]),h.masking_lower<1&&(i[c]*=h.masking_lower)}for(;c0?Math.min(d,y):Math.min(d,.3*i[a])}else{var w=16*t.nb_2[r][a],x=2*t.nb_1[r][a];w<=0&&(w=d),x<=0&&(x=d),y=t.blocktype_old[1&r]==L.NORM_TYPE?Math.min(x,w):x,o[a]=Math.min(d,y)}t.nb_2[r][a]=t.nb_1[r][a],t.nb_1[r][a]=d,p=l[a],p*=t.minval_l[a],p*=m,o[a]>p&&(o[a]=p),t.masking_lower>1&&(o[a]*=t.masking_lower),o[a]>i[a]&&(o[a]=i[a]),t.masking_lower<1&&(o[a]*=t.masking_lower)}for(;a0?Math.pow(10,i):1,u=0;u0){var y,w,x=s[u]*h;if(y=Math.min(Math.max(m,x),Math.max(f,x)),(w=(g=Math.max(l,x))+(_=Math.max(a,x)))>0&&y*cp&&(l=p),a>d&&(a=d),e[2][u]=l,e[3][u]=a}}function Q(t,e){var n;return(n=t>=0?27*-t:t*e)<=-72?0:Math.exp(.2302585093*n)}function z(t){var e,n,s=0;for(s=0;Q(s,t)>1e-20;s-=1);for(i=s,o=0;Math.abs(o-i)>1e-12;)Q(s=(o+i)/2,t)>0?o=s:i=s;e=i;var i,o;s=0;for(s=0;Q(s,t)>1e-20;s+=1);for(i=0,o=s;Math.abs(o-i)>1e-12;)Q(s=(o+i)/2,t)>0?i=s:o=s;n=o;var r,a=0,l=1e3;for(r=0;r<=l;++r){a+=Q(s=e+r*(n-e)/l,t)}return 1001/(a*(n-e))}function G(t){return t<0&&(t=0),t*=.001,13*Math.atan(.76*t)+3.5*Math.atan(t*t/56.25)}function Y(t,e,i,o,r,a,l,c,h,u,p,d){var m,f=s(L.CBANDS+1),g=c/(d>15?1152:384),_=n(L.HBLKSIZE);c/=h;var v=0,b=0;for(m=0;mh/2){v=h/2,++m;break}}f[m]=c*v;for(var w=0;wh/2&&(S=h/2),i[w]=(_[x]+_[S])/2,e[w]=_[S];var P=g*k;l[w]=(P-f[e[w]])/(f[e[w]+1]-f[e[w]]),l[w]<0?l[w]=0:l[w]>1&&(l[w]=1),E=G(c*u[w]*p),E=Math.min(E,15.5)/15.5,a[w]=Math.pow(10,1.25*(1-Math.cos(Math.PI*E))-2.5)}v=0;for(var T=0;T=0?3:1.5)>=.5&&h<=2.5?8*((d=h-.5)*d-2*d):0,((p=15.811389+7.5*(h+=.474)-17.5*Math.sqrt(1+h*h))<=-60?0:(h=Math.exp(.2302585093*(u+p)),h/=.6609193))*i[l]);m[g][l]=_*r[g]}else for(l=0;l0);l++);for(t[g][0]=l,l=e-1;l>0&&!(m[g][l]>0);l--);t[g][1]=l,f+=t[g][1]-t[g][0]+1}var y=s(f),w=0;for(g=0;g2&&(a[i][_].en.assign(d.en[_+2]),a[i][_].thm.assign(d.thm[_+2]))}for(_=0;_0;++b,--x){var R=p[0][b],A=p[1][b];p[0][b]=R+A,p[1][b]=R-A}for(b=0;b<3;b++)C[b]=d.nsPsy.last_en_subshort[_][b+6],S[b]=C[b]/d.nsPsy.last_en_subshort[_][b+4],k[0]+=C[b];for(b=0;b<9;b++){for(var O=P+64,N=1;PC[b+3-2]?N/=C[b+3-2]:N=C[b+3-2]>10*N?C[b+3-2]/(10*N):0,S[b+3]=N}for(b=0;b<3;++b){var D=C[3*b+3]+C[3*b+4]+C[3*b+5],B=1;6*C[3*b+5]T&&(h[_][b/3]=b%3+1);for(b=1;b<4;b++){var F=k[b-1],j=k[b];Math.max(F,j)<4e4&&F<1.7*j&&j<1.7*F&&(1==b&&h[_][0]<=h[_][b]&&(h[_][0]=0),h[_][b]=0)}h[_][0]<=d.nsPsy.lastAttacks[_]&&(h[_][0]=0),3!=d.nsPsy.lastAttacks[_]&&h[_][0]+h[_][1]+h[_][2]+h[_][3]==0||(M=0,0!=h[_][1]&&0!=h[_][0]&&(h[_][1]=0),0!=h[_][2]&&0!=h[_][1]&&(h[_][2]=0),0!=h[_][3]&&0!=h[_][2]&&(h[_][3]=0)),_<2?u[_]=M:0==M&&(u[0]=u[1]=0),l[_]=d.tot_ener[_]}}(t,e,i,r,a,l,u,x,S,E),function(t,e){var n=t.internal_flags;t.short_blocks!=p.short_block_coupled||0!=e[0]&&0!=e[1]||(e[0]=e[1]=0);for(var s=0;s=2||1==S[R][O+1]){var z=0!=O?O-1:2,G=P(m.thm[R].s[D][z],X,.36);X=Math.min(X,G)}else if(1==S[R][O]){z=0!=O?O-1:2,G=P(m.thm[R].s[D][z],X,.18);X=Math.min(X,G)}else if(0!=O&&3==S[R][O-1]||0==O&&3==m.nsPsy.lastAttacks[R]){z=2!=O?O+1:0,G=P(m.thm[R].s[D][z],X,.18);X=Math.min(X,G)}X*=x[R][O],Q[O]=X}for(O=0;O<3;O++)m.thm[R].s[D][O]=Q[O]}}for(R=0;R1?(Y=h,K=-2,Z=L.NORM_TYPE,d[0]!=L.SHORT_TYPE&&d[1]!=L.SHORT_TYPE||(Z=L.SHORT_TYPE),J=l[r][R-2]):(Y=c,K=0,Z=d[R],J=a[r][R]),Z==L.SHORT_TYPE?Y[K+R]=M(J,m.masking_lower):Y[K+R]=A(J,m.masking_lower),t.analysis&&(m.pinfo.pe[r][R]=Y[K+R])}return 0},this.psymodel_init=function(n){var i,o=n.internal_flags,r=!0,a=13,c=0,u=0,p=-8.25,f=-4.5,_=s(L.CBANDS),v=s(L.CBANDS),b=s(L.CBANDS),y=n.out_samplerate;switch(n.experimentalZ){default:case 0:r=!0;break;case 1:r=n.VBR!=m.vbr_mtrh&&n.VBR!=m.vbr_mt;break;case 2:r=!1;break;case 3:a=8,c=-1.75,u=-.0125,p=-8.25,f=-2.25}for(o.ms_ener_ratio_old=.25,o.blocktype_old[0]=o.blocktype_old[1]=L.NORM_TYPE,i=0;i<4;++i){for(var w=0;w=a&&(S=u*(_[i]-a)/(24-a)+c*(24-_[i])/(24-a)),b[i]=Math.pow(10,S/10),o.numlines_l[i]>0?o.rnumlines_l[i]=1/o.numlines_l[i]:o.rnumlines_l[i]=0}o.s3_ll=K(o.s3ind,o.npart_l,_,v,b,r);var C;w=0;for(i=0;i(T*=o.numlines_l[i])&&(P=T)}o.ATH.cb_l[i]=P,(P=20*_[i]/10-20)>6&&(P=100),P<-15&&(P=-15),P-=8,o.minval_l[i]=Math.pow(10,P/10)*o.numlines_l[i]}for(o.npart_s=Y(o.numlines_s,o.bo_s,o.bm_s,_,v,o.mld_s,o.PSY.bo_s_weight,y,L.BLKSIZE_s,o.scalefac_band.s,L.BLKSIZE_s/384,L.SBMAX_s),w=0,i=0;i=a&&(S=f*(_[i]-a)/(24-a)+p*(24-_[i])/(24-a)),b[i]=Math.pow(10,S/10),P=d.MAX_VALUE;for(k=0;k(T*=o.numlines_s[i])&&(P=T)}o.ATH.cb_s[i]=P,P=7*_[i]/12-7,_[i]>12&&(P*=1+3.1*Math.log(1+P)),_[i]<12&&(P*=1+2.3*Math.log(1-P)),P<-15&&(P=-15),P-=8,o.minval_s[i]=Math.pow(10,P/10)*o.numlines_s[i]}o.s3_ss=K(o.s3ind_s,o.npart_s,_,v,b,r),l=Math.pow(10,9/16),h=Math.pow(10,1.5),g=Math.pow(10,1.5),t.init_fft(o),o.decay=Math.exp(-1*e/(.01*y/192)),C=3.5,0!=(2&n.exp_nspsytune)&&(C=1),Math.abs(n.msfix)>0&&(C=n.msfix),n.msfix=C;for(var M=0;Mo.npart_l-1&&(o.s3ind[M][1]=o.npart_l-1);var R=576*o.mode_gr/y;if(o.ATH.decay=Math.pow(10,-1.2*R),o.ATH.adjust=.01,o.ATH.adjustLimit=1,-1!=n.ATHtype){var A=n.out_samplerate/L.BLKSIZE,O=0;for(E=0,i=0;i=0;)o.ATH.eql_w[i]*=O}for(M=w=0;M1?0:t<=0?1:Math.cos(Math.PI/2*t)}function S(t,e){switch(t){case 44100:return e.version=1,0;case 48e3:return e.version=1,1;case 32e3:return e.version=1,2;case 22050:return e.version=0,0;case 24e3:return e.version=0,1;case 16e3:return e.version=0,2;case 11025:return e.version=0,0;case 12e3:return e.version=0,1;case 8e3:return e.version=0,2;default:return e.version=0,-1}}function k(t,e,n){n<16e3&&(e=2);for(var s=C.bitrate_table[e][1],i=2;i<=14;i++)C.bitrate_table[e][i]>0&&Math.abs(C.bitrate_table[e][i]-t)0&&C.bitrate_table[e][s]==t)return s;return-1}function P(e,n){var s=[new y(8,2e3),new y(16,3700),new y(24,3900),new y(32,5500),new y(40,7e3),new y(48,7500),new y(56,1e4),new y(64,11e3),new y(80,13500),new y(96,15100),new y(112,15600),new y(128,17e3),new y(160,17500),new y(192,18600),new y(224,19400),new y(256,19700),new y(320,20500)],i=t.nearestBitrateFullIndex(n);e.lowerlimit=s[i].lowpass}function O(t){var e=L.BLKSIZE+t.framesize-L.FFTOFFSET;return e=Math.max(e,512+t.framesize-32)}function N(e,n,s,i,o,r){var a=t.enc.lame_encode_mp3_frame(e,n,s,i,o,r);return e.frameNum++,a}function D(){this.n_in=0,this.n_out=0}function B(){this.num_used=0}function I(t,e,n){var s=Math.PI*e;(t/=n)<0&&(t=0),t>1&&(t=1);var i=t-.5,o=.42-.5*Math.cos(2*t*Math.PI)+.08*Math.cos(4*t*Math.PI);return Math.abs(i)<1e-9?s/Math.PI:o*Math.sin(n*s*i)/(Math.PI*n*i)}function F(t,e,n,i,o,r,a,l,c){var h,u,p=t.internal_flags,d=0,m=t.out_samplerate/function t(e,n){return 0!=n?t(n,e%n):e}(t.out_samplerate,t.in_samplerate);m>Q.BPC&&(m=Q.BPC);var f=Math.abs(p.resample_ratio-Math.floor(.5+p.resample_ratio))<1e-4?1:0,g=1/p.resample_ratio;g>1&&(g=1);var _=31;0==_%2&&--_;var v=(_+=f)+1;if(0==p.fill_buffer_resample_init){for(p.inbuf_old[0]=s(v),p.inbuf_old[1]=s(v),h=0;h<=2*m;++h)p.blackfilt[h]=s(v);for(p.itime[0]=0,p.itime[1]=0,d=0;d<=2*m;d++){var b=0,y=(d-m)/(2*m);for(h=0;h<=_;h++)b+=p.blackfilt[d][h]=I(h-y,g,_);for(h=0;h<=_;h++)p.blackfilt[d][h]/=b}p.fill_buffer_resample_init=1}var w=p.inbuf_old[c];for(u=0;u=a)break;y=x-p.itime[c]-(d+_%2*.5);S=0|Math.floor(2*y*m+m+.5);var C=0;for(h=0;h<=_;++h){var k=h+d-_/2;C+=(k<0?w[v+k]:o[r+k])*p.blackfilt[S][h]}e[n+u]=C}if(l.num_used=Math.min(a,_+d-_/2),p.itime[c]+=l.num_used-u*p.resample_ratio,l.num_used>=v)for(h=0;h1.0001)for(var a=0;at-s?n:i},this.lame_init_params=function(t){var s,a,y,T=t.internal_flags;if(T.Class_ID=0,null==T.ATH&&(T.ATH=new R),null==T.PSY&&(T.PSY=new _),null==T.rgdata&&(T.rgdata=new M),T.channels_in=t.num_channels,1==T.channels_in&&(t.mode=f.MONO),T.channels_out=t.mode==f.MONO?1:2,T.mode_ext=L.MPG_MD_MS_LR,t.mode==f.MONO&&(t.force_ms=!1),t.VBR==m.vbr_off&&128!=t.VBR_mean_bitrate_kbps&&0==t.brate&&(t.brate=t.VBR_mean_bitrate_kbps),t.VBR==m.vbr_off||t.VBR==m.vbr_mtrh||t.VBR==m.vbr_mt||(t.free_format=!1),t.VBR==m.vbr_off&&0==t.brate&&w.EQ(t.compression_ratio,0)&&(t.compression_ratio=11.025),t.VBR==m.vbr_off&&t.compression_ratio>0&&(0==t.out_samplerate&&(t.out_samplerate=map2MP3Frequency(int(.97*t.in_samplerate))),t.brate=0|16*t.out_samplerate*T.channels_out/(1e3*t.compression_ratio),T.samplerate_index=S(t.out_samplerate,t),t.free_format||(t.brate=k(t.brate,t.version,t.out_samplerate))),0!=t.out_samplerate&&(t.out_samplerate<16e3?(t.VBR_mean_bitrate_kbps=Math.max(t.VBR_mean_bitrate_kbps,8),t.VBR_mean_bitrate_kbps=Math.min(t.VBR_mean_bitrate_kbps,64)):t.out_samplerate<32e3?(t.VBR_mean_bitrate_kbps=Math.max(t.VBR_mean_bitrate_kbps,8),t.VBR_mean_bitrate_kbps=Math.min(t.VBR_mean_bitrate_kbps,160)):(t.VBR_mean_bitrate_kbps=Math.max(t.VBR_mean_bitrate_kbps,32),t.VBR_mean_bitrate_kbps=Math.min(t.VBR_mean_bitrate_kbps,320))),0==t.lowpassfreq){var O=16e3;switch(t.VBR){case m.vbr_off:P(N=new b,t.brate),O=N.lowerlimit;break;case m.vbr_abr:var N;P(N=new b,t.VBR_mean_bitrate_kbps),O=N.lowerlimit;break;case m.vbr_rh:var D=[19500,19e3,18600,18e3,17500,16e3,15600,14900,12500,1e4,3950];if(0<=t.VBR_q&&t.VBR_q<=9){var B=D[t.VBR_q],I=D[t.VBR_q+1],F=t.VBR_q_frac;O=linear_int(B,I,F)}else O=19500;break;default:D=[19500,19e3,18500,18e3,17500,16500,15500,14500,12500,9500,3950];if(0<=t.VBR_q&&t.VBR_q<=9){B=D[t.VBR_q],I=D[t.VBR_q+1],F=t.VBR_q_frac;O=linear_int(B,I,F)}else O=19500}t.mode!=f.MONO||t.VBR!=m.vbr_off&&t.VBR!=m.vbr_abr||(O*=1.5),t.lowpassfreq=0|O}if(0==t.out_samplerate&&(2*t.lowpassfreq>t.in_samplerate&&(t.lowpassfreq=t.in_samplerate/2),t.out_samplerate=(s=0|t.lowpassfreq,a=t.in_samplerate,y=44100,a>=48e3?y=48e3:a>=44100?y=44100:a>=32e3?y=32e3:a>=24e3?y=24e3:a>=22050?y=22050:a>=16e3?y=16e3:a>=12e3?y=12e3:a>=11025?y=11025:a>=8e3&&(y=8e3),-1==s?y:(s<=15960&&(y=44100),s<=15250&&(y=32e3),s<=11220&&(y=24e3),s<=9970&&(y=22050),s<=7230&&(y=16e3),s<=5420&&(y=12e3),s<=4510&&(y=11025),s<=3970&&(y=8e3),a44100?48e3:a>32e3?44100:a>24e3?32e3:a>22050?24e3:a>16e3?22050:a>12e3?16e3:a>11025?12e3:a>8e3?11025:8e3:y))),t.lowpassfreq=Math.min(20500,t.lowpassfreq),t.lowpassfreq=Math.min(t.out_samplerate/2,t.lowpassfreq),t.VBR==m.vbr_off&&(t.compression_ratio=16*t.out_samplerate*T.channels_out/(1e3*t.brate)),t.VBR==m.vbr_abr&&(t.compression_ratio=16*t.out_samplerate*T.channels_out/(1e3*t.VBR_mean_bitrate_kbps)),t.bWriteVbrTag||(t.findReplayGain=!1,t.decode_on_the_fly=!1,T.findPeakSample=!1),T.findReplayGain=t.findReplayGain,T.decode_on_the_fly=t.decode_on_the_fly,T.decode_on_the_fly&&(T.findPeakSample=!0),T.findReplayGain&&e.InitGainAnalysis(T.rgdata,t.out_samplerate)==v.INIT_GAIN_ANALYSIS_ERROR)return t.internal_flags=null,-6;switch(T.decode_on_the_fly&&!t.decode_only&&(null!=T.hip&&d.hip_decode_exit(T.hip),T.hip=d.hip_decode_init()),T.mode_gr=t.out_samplerate<=24e3?1:2,t.framesize=576*T.mode_gr,t.encoder_delay=L.ENCDELAY,T.resample_ratio=t.in_samplerate/t.out_samplerate,t.VBR){case m.vbr_mt:case m.vbr_rh:case m.vbr_mtrh:t.compression_ratio=[5.7,6.5,7.3,8.2,10,11.9,13,14,15,16.5][t.VBR_q];break;case m.vbr_abr:t.compression_ratio=16*t.out_samplerate*T.channels_out/(1e3*t.VBR_mean_bitrate_kbps);break;default:t.compression_ratio=16*t.out_samplerate*T.channels_out/(1e3*t.brate)}if(t.mode==f.NOT_SET&&(t.mode=f.JOINT_STEREO),t.highpassfreq>0?(T.highpass1=2*t.highpassfreq,t.highpasswidth>=0?T.highpass2=2*(t.highpassfreq+t.highpasswidth):T.highpass2=2*t.highpassfreq,T.highpass1/=t.out_samplerate,T.highpass2/=t.out_samplerate):(T.highpass1=0,T.highpass2=0),t.lowpassfreq>0?(T.lowpass2=2*t.lowpassfreq,t.lowpasswidth>=0?(T.lowpass1=2*(t.lowpassfreq-t.lowpasswidth),T.lowpass1<0&&(T.lowpass1=0)):T.lowpass1=2*t.lowpassfreq,T.lowpass1/=t.out_samplerate,T.lowpass2/=t.out_samplerate):(T.lowpass1=0,T.lowpass2=0),function(t){var e=t.internal_flags,n=32,s=-1;if(e.lowpass1>0){for(var i=999,o=0;o<=31;o++){(c=o/31)>=e.lowpass2&&(n=Math.min(n,o)),e.lowpass10&&e.highpass2<.75/31*.9&&(e.highpass1=0,e.highpass2=0,h.err.println("Warning: highpass filter disabled. highpass frequency too small\n")),e.highpass2>0){var r=-1;for(o=0;o<=31;o++){(c=o/31)<=e.highpass1&&(s=Math.max(s,o)),e.highpass1e.highpass1?x((e.highpass2-c)/(e.highpass2-e.highpass1+1e-20)):1,l=e.lowpass2>e.lowpass1?x((c-e.lowpass1)/(e.lowpass2-e.lowpass1+1e-20)):1,e.amp_filter[o]=a*l}}(t),T.samplerate_index=S(t.out_samplerate,t),T.samplerate_index<0)return t.internal_flags=null,-1;if(t.VBR==m.vbr_off){if(t.free_format)T.bitrate_index=0;else if(t.brate=k(t.brate,t.version,t.out_samplerate),T.bitrate_index=E(t.brate,t.version,t.out_samplerate),T.bitrate_index<=0)return t.internal_flags=null,-1}else T.bitrate_index=1;t.analysis&&(t.bWriteVbrTag=!1),null!=T.pinfo&&(t.bWriteVbrTag=!1),n.init_bit_stream_w(T);for(var V,j=T.samplerate_index+3*t.version+6*(t.out_samplerate<16e3?1:0),q=0;q5&&(t.quality=5),T.PSY.mask_adjust=t.maskingadjust,T.PSY.mask_adjust_short=t.maskingadjust_short,t.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=t.out_samplerate>44e3,T.iteration_loop=new VBRNewIterationLoop(l);break;case m.vbr_rh:i.apply_preset(t,500-10*t.VBR_q,0),T.PSY.mask_adjust=t.maskingadjust,T.PSY.mask_adjust_short=t.maskingadjust_short,t.experimentalY?T.sfb21_extra=!1:T.sfb21_extra=t.out_samplerate>44e3,t.quality>6&&(t.quality=6),t.quality<0&&(t.quality=LAME_DEFAULT_QUALITY),T.iteration_loop=new VBROldIterationLoop(l);break;default:var W;T.sfb21_extra=!1,t.quality<0&&(t.quality=LAME_DEFAULT_QUALITY),(W=t.VBR)==m.vbr_off&&(t.VBR_mean_bitrate_kbps=t.brate),i.apply_preset(t,t.VBR_mean_bitrate_kbps,0),t.VBR=W,T.PSY.mask_adjust=t.maskingadjust,T.PSY.mask_adjust_short=t.maskingadjust_short,W==m.vbr_off?T.iteration_loop=new A(l):T.iteration_loop=new ABRIterationLoop(l)}if(t.VBR!=m.vbr_off){if(T.VBR_min_bitrate=1,T.VBR_max_bitrate=14,t.out_samplerate<16e3&&(T.VBR_max_bitrate=8),0!=t.VBR_min_bitrate_kbps&&(t.VBR_min_bitrate_kbps=k(t.VBR_min_bitrate_kbps,t.version,t.out_samplerate),T.VBR_min_bitrate=E(t.VBR_min_bitrate_kbps,t.version,t.out_samplerate),T.VBR_min_bitrate<0))return-1;if(0!=t.VBR_max_bitrate_kbps&&(t.VBR_max_bitrate_kbps=k(t.VBR_max_bitrate_kbps,t.version,t.out_samplerate),T.VBR_max_bitrate=E(t.VBR_max_bitrate_kbps,t.version,t.out_samplerate),T.VBR_max_bitrate<0))return-1;t.VBR_min_bitrate_kbps=C.bitrate_table[t.version][T.VBR_min_bitrate],t.VBR_max_bitrate_kbps=C.bitrate_table[t.version][T.VBR_max_bitrate],t.VBR_mean_bitrate_kbps=Math.min(C.bitrate_table[t.version][T.VBR_max_bitrate],t.VBR_mean_bitrate_kbps),t.VBR_mean_bitrate_kbps=Math.max(C.bitrate_table[t.version][T.VBR_min_bitrate],t.VBR_mean_bitrate_kbps)}return t.tune&&(T.PSY.mask_adjust+=t.tune_value_a,T.PSY.mask_adjust_short+=t.tune_value_a),function(t){var e=t.internal_flags;switch(t.quality){default:case 9:e.psymodel=0,e.noise_shaping=0,e.noise_shaping_amp=0,e.noise_shaping_stop=0,e.use_best_huffman=0,e.full_outer_loop=0;break;case 8:t.quality=7;case 7:e.psymodel=1,e.noise_shaping=0,e.noise_shaping_amp=0,e.noise_shaping_stop=0,e.use_best_huffman=0,e.full_outer_loop=0;break;case 6:case 5:e.psymodel=1,0==e.noise_shaping&&(e.noise_shaping=1),e.noise_shaping_amp=0,e.noise_shaping_stop=0,-1==e.subblock_gain&&(e.subblock_gain=1),e.use_best_huffman=0,e.full_outer_loop=0;break;case 4:e.psymodel=1,0==e.noise_shaping&&(e.noise_shaping=1),e.noise_shaping_amp=0,e.noise_shaping_stop=0,-1==e.subblock_gain&&(e.subblock_gain=1),e.use_best_huffman=1,e.full_outer_loop=0;break;case 3:e.psymodel=1,0==e.noise_shaping&&(e.noise_shaping=1),e.noise_shaping_amp=1,e.noise_shaping_stop=1,-1==e.subblock_gain&&(e.subblock_gain=1),e.use_best_huffman=1,e.full_outer_loop=0;break;case 2:e.psymodel=1,0==e.noise_shaping&&(e.noise_shaping=1),0==e.substep_shaping&&(e.substep_shaping=2),e.noise_shaping_amp=1,e.noise_shaping_stop=1,-1==e.subblock_gain&&(e.subblock_gain=1),e.use_best_huffman=1,e.full_outer_loop=0;break;case 1:case 0:e.psymodel=1,0==e.noise_shaping&&(e.noise_shaping=1),0==e.substep_shaping&&(e.substep_shaping=2),e.noise_shaping_amp=2,e.noise_shaping_stop=1,-1==e.subblock_gain&&(e.subblock_gain=1),e.use_best_huffman=1,e.full_outer_loop=0}}(t),t.athaa_type<0?T.ATH.useAdjust=3:T.ATH.useAdjust=t.athaa_type,T.ATH.aaSensitivityP=Math.pow(10,t.athaa_sensitivity/-10),null==t.short_blocks&&(t.short_blocks=p.short_block_allowed),t.short_blocks!=p.short_block_allowed||t.mode!=f.JOINT_STEREO&&t.mode!=f.STEREO||(t.short_blocks=p.short_block_coupled),t.quant_comp<0&&(t.quant_comp=1),t.quant_comp_short<0&&(t.quant_comp_short=0),t.msfix<0&&(t.msfix=0),t.exp_nspsytune=1|t.exp_nspsytune,t.internal_flags.nsPsy.attackthre<0&&(t.internal_flags.nsPsy.attackthre=z.NSATTACKTHRE),t.internal_flags.nsPsy.attackthre_s<0&&(t.internal_flags.nsPsy.attackthre_s=z.NSATTACKTHRE_S),t.scale<0&&(t.scale=1),t.ATHtype<0&&(t.ATHtype=4),t.ATHcurve<0&&(t.ATHcurve=4),t.athaa_loudapprox<0&&(t.athaa_loudapprox=2),t.interChRatio<0&&(t.interChRatio=0),null==t.useTemporal&&(t.useTemporal=!0),T.slot_lag=T.frac_SpF=0,t.VBR==m.vbr_off&&(T.slot_lag=T.frac_SpF=72e3*(t.version+1)*t.brate%t.out_samplerate|0),o.iteration_init(t),g.psymodel_init(t),0},this.lame_encode_flush=function(t,e,s,i){var o,r,l,c,h=t.internal_flags,p=a([2,1152]),d=0,m=h.mf_samples_to_encode-L.POSTDELAY,f=O(t);if(h.mf_samples_to_encode<1)return 0;for(o=0,t.in_samplerate!=t.out_samplerate&&(m+=16*t.out_samplerate/t.in_samplerate),(l=t.framesize-m%t.framesize)<576&&(l+=t.framesize),t.encoder_padding=l,c=(m+l)/t.framesize;c>0&&d>=0;){var g=f-h.mf_size,_=t.frameNum;g*=t.in_samplerate,(g/=t.out_samplerate)>1152&&(g=1152),g<1&&(g=1),r=i-o,0==i&&(r=0),s+=d=this.lame_encode_buffer(t,p[0],p[1],g,e,s,r),o+=d,c-=_!=t.frameNum?1:0}if(h.mf_samples_to_encode=0,d<0)return d;if(r=i-o,0==i&&(r=0),n.flush_bitstream(t),(d=n.copy_buffer(h,e,s,r,1))<0)return d;if(s+=d,r=i-(o+=d),0==i&&(r=0),t.write_id3tag_automatic){if(u.id3tag_write_v1(t),(d=n.copy_buffer(h,e,s,r,0))<0)return d;o+=d}return o},this.lame_encode_buffer=function(t,i,o,r,a,l,c){var h=t.internal_flags,u=[null,null];if(4294479419!=h.Class_ID)return-3;if(0==r)return 0;!function(t,e){(null==t.in_buffer_0||t.in_buffer_nsamples1&&(u[1][p]=o[p]);return function(t,s,i,o,r,a,l){var c,h,u,p,d,m=t.internal_flags,f=0,g=[null,null],_=[null,null];if(4294479419!=m.Class_ID)return-3;if(0==o)return 0;if((d=n.copy_buffer(m,r,a,l,0))<0)return d;if(a+=d,f+=d,_[0]=s,_[1]=i,w.NEQ(t.scale,0)&&w.NEQ(t.scale,1))for(h=0;h0;){var y,x,S=[null,null];S[0]=_[0],S[1]=_[1];var C=new D;if(V(t,g,S,b,o,C),y=C.n_in,x=C.n_out,m.findReplayGain&&!m.decode_on_the_fly&&e.AnalyzeSamples(m.rgdata,g[0],m.mf_size,g[1],m.mf_size,x,m.channels_out)==v.GAIN_ANALYSIS_ERROR)return-6;if(o-=y,b+=y,m.channels_out,m.mf_size+=x,m.mf_samples_to_encode<1&&(m.mf_samples_to_encode=L.ENCDELAY+L.POSTDELAY),m.mf_samples_to_encode+=x,m.mf_size>=p){var k=l-f;if(0==l&&(k=0),(c=N(t,g[0],g[1],r,a,k))<0)return c;for(a+=c,f+=c,m.mf_size-=t.framesize,m.mf_samples_to_encode-=t.framesize,u=0;uP&&(P=n.length,M=t(T=0|1.25*P+7200));var o=i.lame_encode_buffer(E,n,s,n.length,M,0,T);return new Int8Array(M.subarray(0,o))},this.flush=function(){var t=i.lame_encode_flush(E,M,0,T);return new Int8Array(M.subarray(0,t))}}function tt(){this.dataOffset=0,this.dataLen=0,this.channels=0,this.sampleRate=0}function et(t){return t.charCodeAt(0)<<24|t.charCodeAt(1)<<16|t.charCodeAt(2)<<8|t.charCodeAt(3)}I.SFBMAX=3*L.SBMAX_s,L.ENCDELAY=576,L.POSTDELAY=1152,L.MDCTDELAY=48,L.FFTOFFSET=224+L.MDCTDELAY,L.DECDELAY=528,L.SBLIMIT=32,L.CBANDS=64,L.SBPSY_l=21,L.SBPSY_s=12,L.SBMAX_l=22,L.SBMAX_s=13,L.PSFB21=6,L.PSFB12=6,L.BLKSIZE=1024,L.HBLKSIZE=L.BLKSIZE/2+1,L.BLKSIZE_s=256,L.HBLKSIZE_s=L.BLKSIZE_s/2+1,L.NORM_TYPE=0,L.START_TYPE=1,L.SHORT_TYPE=2,L.STOP_TYPE=3,L.MPG_MD_LR_LR=0,L.MPG_MD_LR_I=1,L.MPG_MD_MS_LR=2,L.MPG_MD_MS_I=3,L.fircoef=[-.1039435,-.1892065,5*-.0432472,-.155915,3898045e-23,.0467745*5,.50455,.756825,.187098*5],Q.MFSIZE=3456+L.ENCDELAY-L.MDCTDELAY,Q.MAX_HEADER_BUF=256,Q.MAX_BITS_PER_CHANNEL=4095,Q.MAX_BITS_PER_GRANULE=7680,Q.BPC=320,tt.RIFF=et("RIFF"),tt.WAVE=et("WAVE"),tt.fmt_=et("fmt "),tt.data=et("data"),tt.readHeader=function(t){var e=new tt,n=t.getUint32(0,!1);if(tt.RIFF==n){t.getUint32(4,!0);if(tt.WAVE==t.getUint32(8,!1)&&tt.fmt_==t.getUint32(12,!1)){var s=t.getUint32(16,!0),i=20;switch(s){case 16:case 18:e.channels=t.getUint16(i+2,!0),e.sampleRate=t.getUint32(i+4,!0);break;default:throw"extended fmt chunk not implemented"}i+=s;for(var o=tt.data,r=0;o!=n&&(n=t.getUint32(i,!1),r=t.getUint32(i+4,!0),o!=n);)i+=r+8;return e.dataLen=r,e.dataOffset=i+8,e}}},I.SFBMAX=3*L.SBMAX_s,this.Mp3Encoder=$,this.WavHeader=tt}}).call(this,n(257).Buffer)},1405:function(t,e,n){"use strict";let s,i;n.d(e,"b",(function(){return r})),n.d(e,"a",(function(){return a}));let o=!1;function r(t){if(!o){const e=.5*t.sampleRate|0;s=t.createBuffer(2,e,t.sampleRate),i={},i.n0=t.createBuffer(1,e,t.sampleRate),i.n1=t.createBuffer(1,e,t.sampleRate);const n=s.getChannelData(0),r=s.getChannelData(1),a=i.n0.getChannelData(0),l=i.n1.getChannelData(0);for(let t=0;t>2]|=t[o]<>6,l[i++]=128|63&s):s<55296||s>=57344?(l[i++]=224|s>>12,l[i++]=128|s>>6&63,l[i++]=128|63&s):(s=65536+((1023&s)<<10|1023&t.charCodeAt(++o)),l[i++]=240|s>>18,l[i++]=128|s>>12&63,l[i++]=128|s>>6&63,l[i++]=128|63&s);else for(i=this.start;o>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(a[i>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=64?(this.start=i-64,this.hash(),this.hashed=!0):this.start=i}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Md5.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,e=this.lastByteIndex;t[e>>2]|=EXTRA[3&e],e>=56&&(this.hashed||this.hash(),t[0]=t[16],t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.bytes<<3,t[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Md5.prototype.hash=function(){var t,e,n,s,i,o,r=this.blocks;this.first?e=((e=((t=((t=r[0]-680876937)<<7|t>>>25)-271733879<<0)^(n=((n=(-271733879^(s=((s=(-1732584194^2004318071&t)+r[1]-117830708)<<12|s>>>20)+t<<0)&(-271733879^t))+r[2]-1126478375)<<17|n>>>15)+s<<0)&(s^t))+r[3]-1316259209)<<22|e>>>10)+n<<0:(t=this.h0,e=this.h1,n=this.h2,e=((e+=((t=((t+=((s=this.h3)^e&(n^s))+r[0]-680876936)<<7|t>>>25)+e<<0)^(n=((n+=(e^(s=((s+=(n^t&(e^n))+r[1]-389564586)<<12|s>>>20)+t<<0)&(t^e))+r[2]+606105819)<<17|n>>>15)+s<<0)&(s^t))+r[3]-1044525330)<<22|e>>>10)+n<<0),e=((e+=((t=((t+=(s^e&(n^s))+r[4]-176418897)<<7|t>>>25)+e<<0)^(n=((n+=(e^(s=((s+=(n^t&(e^n))+r[5]+1200080426)<<12|s>>>20)+t<<0)&(t^e))+r[6]-1473231341)<<17|n>>>15)+s<<0)&(s^t))+r[7]-45705983)<<22|e>>>10)+n<<0,e=((e+=((t=((t+=(s^e&(n^s))+r[8]+1770035416)<<7|t>>>25)+e<<0)^(n=((n+=(e^(s=((s+=(n^t&(e^n))+r[9]-1958414417)<<12|s>>>20)+t<<0)&(t^e))+r[10]-42063)<<17|n>>>15)+s<<0)&(s^t))+r[11]-1990404162)<<22|e>>>10)+n<<0,e=((e+=((t=((t+=(s^e&(n^s))+r[12]+1804603682)<<7|t>>>25)+e<<0)^(n=((n+=(e^(s=((s+=(n^t&(e^n))+r[13]-40341101)<<12|s>>>20)+t<<0)&(t^e))+r[14]-1502002290)<<17|n>>>15)+s<<0)&(s^t))+r[15]+1236535329)<<22|e>>>10)+n<<0,e=((e+=((s=((s+=(e^n&((t=((t+=(n^s&(e^n))+r[1]-165796510)<<5|t>>>27)+e<<0)^e))+r[6]-1069501632)<<9|s>>>23)+t<<0)^t&((n=((n+=(t^e&(s^t))+r[11]+643717713)<<14|n>>>18)+s<<0)^s))+r[0]-373897302)<<20|e>>>12)+n<<0,e=((e+=((s=((s+=(e^n&((t=((t+=(n^s&(e^n))+r[5]-701558691)<<5|t>>>27)+e<<0)^e))+r[10]+38016083)<<9|s>>>23)+t<<0)^t&((n=((n+=(t^e&(s^t))+r[15]-660478335)<<14|n>>>18)+s<<0)^s))+r[4]-405537848)<<20|e>>>12)+n<<0,e=((e+=((s=((s+=(e^n&((t=((t+=(n^s&(e^n))+r[9]+568446438)<<5|t>>>27)+e<<0)^e))+r[14]-1019803690)<<9|s>>>23)+t<<0)^t&((n=((n+=(t^e&(s^t))+r[3]-187363961)<<14|n>>>18)+s<<0)^s))+r[8]+1163531501)<<20|e>>>12)+n<<0,e=((e+=((s=((s+=(e^n&((t=((t+=(n^s&(e^n))+r[13]-1444681467)<<5|t>>>27)+e<<0)^e))+r[2]-51403784)<<9|s>>>23)+t<<0)^t&((n=((n+=(t^e&(s^t))+r[7]+1735328473)<<14|n>>>18)+s<<0)^s))+r[12]-1926607734)<<20|e>>>12)+n<<0,e=((e+=((o=(s=((s+=((i=e^n)^(t=((t+=(i^s)+r[5]-378558)<<4|t>>>28)+e<<0))+r[8]-2022574463)<<11|s>>>21)+t<<0)^t)^(n=((n+=(o^e)+r[11]+1839030562)<<16|n>>>16)+s<<0))+r[14]-35309556)<<23|e>>>9)+n<<0,e=((e+=((o=(s=((s+=((i=e^n)^(t=((t+=(i^s)+r[1]-1530992060)<<4|t>>>28)+e<<0))+r[4]+1272893353)<<11|s>>>21)+t<<0)^t)^(n=((n+=(o^e)+r[7]-155497632)<<16|n>>>16)+s<<0))+r[10]-1094730640)<<23|e>>>9)+n<<0,e=((e+=((o=(s=((s+=((i=e^n)^(t=((t+=(i^s)+r[13]+681279174)<<4|t>>>28)+e<<0))+r[0]-358537222)<<11|s>>>21)+t<<0)^t)^(n=((n+=(o^e)+r[3]-722521979)<<16|n>>>16)+s<<0))+r[6]+76029189)<<23|e>>>9)+n<<0,e=((e+=((o=(s=((s+=((i=e^n)^(t=((t+=(i^s)+r[9]-640364487)<<4|t>>>28)+e<<0))+r[12]-421815835)<<11|s>>>21)+t<<0)^t)^(n=((n+=(o^e)+r[15]+530742520)<<16|n>>>16)+s<<0))+r[2]-995338651)<<23|e>>>9)+n<<0,e=((e+=((s=((s+=(e^((t=((t+=(n^(e|~s))+r[0]-198630844)<<6|t>>>26)+e<<0)|~n))+r[7]+1126891415)<<10|s>>>22)+t<<0)^((n=((n+=(t^(s|~e))+r[14]-1416354905)<<15|n>>>17)+s<<0)|~t))+r[5]-57434055)<<21|e>>>11)+n<<0,e=((e+=((s=((s+=(e^((t=((t+=(n^(e|~s))+r[12]+1700485571)<<6|t>>>26)+e<<0)|~n))+r[3]-1894986606)<<10|s>>>22)+t<<0)^((n=((n+=(t^(s|~e))+r[10]-1051523)<<15|n>>>17)+s<<0)|~t))+r[1]-2054922799)<<21|e>>>11)+n<<0,e=((e+=((s=((s+=(e^((t=((t+=(n^(e|~s))+r[8]+1873313359)<<6|t>>>26)+e<<0)|~n))+r[15]-30611744)<<10|s>>>22)+t<<0)^((n=((n+=(t^(s|~e))+r[6]-1560198380)<<15|n>>>17)+s<<0)|~t))+r[13]+1309151649)<<21|e>>>11)+n<<0,e=((e+=((s=((s+=(e^((t=((t+=(n^(e|~s))+r[4]-145523070)<<6|t>>>26)+e<<0)|~n))+r[11]-1120210379)<<10|s>>>22)+t<<0)^((n=((n+=(t^(s|~e))+r[2]+718787259)<<15|n>>>17)+s<<0)|~t))+r[9]-343485551)<<21|e>>>11)+n<<0,this.first?(this.h0=t+1732584193<<0,this.h1=e-271733879<<0,this.h2=n-1732584194<<0,this.h3=s+271733878<<0,this.first=!1):(this.h0=this.h0+t<<0,this.h1=this.h1+e<<0,this.h2=this.h2+n<<0,this.h3=this.h3+s<<0)},Md5.prototype.hex=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,s=this.h3;return HEX_CHARS[t>>4&15]+HEX_CHARS[15&t]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[15&e]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[15&n]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[15&s]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]},Md5.prototype.toString=Md5.prototype.hex,Md5.prototype.digest=function(){this.finalize();var t=this.h0,e=this.h1,n=this.h2,s=this.h3;return[255&t,t>>8&255,t>>16&255,t>>24&255,255&e,e>>8&255,e>>16&255,e>>24&255,255&n,n>>8&255,n>>16&255,n>>24&255,255&s,s>>8&255,s>>16&255,s>>24&255]},Md5.prototype.array=Md5.prototype.digest,Md5.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(16),e=new Uint32Array(t);return e[0]=this.h0,e[1]=this.h1,e[2]=this.h2,e[3]=this.h3,t},Md5.prototype.buffer=Md5.prototype.arrayBuffer,Md5.prototype.base64=function(){for(var t,e,n,s="",i=this.array(),o=0;o<15;)t=i[o++],e=i[o++],n=i[o++],s+=BASE64_ENCODE_CHAR[t>>>2]+BASE64_ENCODE_CHAR[63&(t<<4|e>>>4)]+BASE64_ENCODE_CHAR[63&(e<<2|n>>>6)]+BASE64_ENCODE_CHAR[63&n];return t=i[o],s+=BASE64_ENCODE_CHAR[t>>>2]+BASE64_ENCODE_CHAR[t<<4&63]+"=="};var exports=createMethod();COMMON_JS?module.exports=exports:(root.md5=exports,AMD&&(__WEBPACK_AMD_DEFINE_RESULT__=function(){return exports}.call(exports,__webpack_require__,exports,module),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)))}()}).call(this,__webpack_require__(227),__webpack_require__(187))},1407:function(t,e,n){e.parseMidi=n(1569),e.writeMidi=n(1570)},1408:function(t,e,n){"use strict";function s(t,e,n){void 0===n&&(n="ticks");var s=0,i=t.length,o=i;if(i>0&&t[i-1][n]<=e)return i-1;for(;se)return r;a[n]>e?o=r:a[n]=t.absoluteTime}));if(-1!==e){var n=r.splice(e,1)[0];h.addNote({durationTicks:n.absoluteTime-t.absoluteTime,midi:t.noteNumber,noteOffVelocity:n.velocity/127,ticks:t.absoluteTime,velocity:t.velocity/127})}},h=this;i.length;)l();t.filter((function(t){return"controller"===t.type})).forEach((function(t){n.addCC({number:t.controllerType,ticks:t.absoluteTime,value:t.value/127})})),t.filter((function(t){return"pitchBend"===t.type})).forEach((function(t){n.addPitchBend({ticks:t.absoluteTime,value:t.value/Math.pow(2,13)})}));var u=t.find((function(t){return"endOfTrack"===t.type}));this.endOfTrackTicks=void 0!==u?u.absoluteTime:void 0}}return t.prototype.addNote=function(t){var e=c.get(this),n=new l.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},e);return Object.assign(n,t),(0,s.insert)(this.notes,n,"ticks"),this},t.prototype.addCC=function(t){var e=c.get(this),n=new i.ControlChange({controllerType:t.number},e);return delete t.number,Object.assign(n,t),Array.isArray(this.controlChanges[n.number])||(this.controlChanges[n.number]=[]),(0,s.insert)(this.controlChanges[n.number],n,"ticks"),this},t.prototype.addPitchBend=function(t){var e=c.get(this),n=new r.PitchBend({},e);return Object.assign(n,t),(0,s.insert)(this.pitchBends,n,"ticks"),this},Object.defineProperty(t.prototype,"duration",{get:function(){if(!this.notes.length)return 0;for(var t=this.notes[this.notes.length-1].time+this.notes[this.notes.length-1].duration,e=0;e=t._state.keys.length?t._state.keys=t._state.keys.map((function(t){return t.isActive=!0,t})):(t._state.keys=t._state.keys.map((function(t){return t.isActive=!1,t})),t["_"+t._state.priority]()),t._state.buffer=[],t._state.keys.forEach((function(e){e.isActive&&t._state.buffer.push(e)}))):t._state.buffer=[]},_last:function(){for(var t=this._state.keys.length-this._state.polyphony;t{const e=i.callbacks[t.data.command].pop();"function"==typeof e&&e(t.data.data)})}record(){this.recording=!0}stop(){this.recording=!1}clear(){this.worker.postMessage({command:"clear"})}getBuffer(t){if(!(t=t||this.config.callback))throw new Error("Callback not set");this.callbacks.getBuffer.push(t),this.worker.postMessage({command:"getBuffer"})}exportMP3(t){if(!t)throw new Error("Callback not set");this.callbacks.exportMP3.push(t),this.worker.postMessage({command:"exportMP3"})}exportWAV(t,e){if(e=e||this.config.mimeType,!(t=t||this.config.callback))throw new Error("Callback not set");this.callbacks.exportWAV.push(t),this.worker.postMessage({command:"exportWAV",type:e})}static forceDownload(t,e){const n=(window.URL||window.webkitURL).createObjectURL(t),s=window.document.createElement("a");s.href=n,s.download=e||"output.wav";const i=document.createEvent("Event");i.initEvent("click",!0,!0),s.dispatchEvent(i)}}},1554:function(t,e,n){"use strict";n.r(e);var s=n(1404),i=n.n(s);e.default=function(){let t=0,e=[],n=0,s=0;function o(){for(let t=0;t0&&h.push(n.buffer)}const d=c.flush();d&&d.length>0&&h.push(d.buffer);const m=new Blob(h,{type:"audio/mpeg"});self.postMessage({command:"exportMP3",data:m})}();break;case"getBuffer":!function(){const n=[];for(let i=0;i0&&s.push(r.buffer),self.postMessage([i.b.PROGRESS,h+g*e/t])}const _=n.flush();_&&_.length>0&&s.push(_.buffer),self.postMessage([i.b.DONE,i.a.MP3,s])}else if(n==i.a.WAV){const t=o.length,e=o[0].length,n=t*e,r=2.1*n;let u=0;const p=2e4;let d;try{d=new Float32Array(n)}catch(t){return void self.postMessage([i.b.ERROR,"Not enough memory to create the file. Try shortening your overall audio length."])}for(let n=0;n1&&(h=1),h*=h<0?32768:32767,w.call(_,y,h,!0),u+=1,u%p==0&&self.postMessage([i.b.PROGRESS,u/r])}self.postMessage([i.b.PROGRESS,1]),self.postMessage([i.b.DONE,i.a.WAV,g])}}else self.postMessage([i.b.ERROR,"MP3 export does not support "+o.length+" channels."])}))}},1557:function(t,e,n){t.exports={pageContainer:"X82IqoWvNmm2dc3ojNp7H",container:"_1ecHzLlccJR8GVBnl0qAKO",closeBtn:"_37CJSmc59qnWgEEc0LIfjf",instrumentBtn:"PO-0ecDqHfmy4WPrfXuT9",InstrumentPanel:"_3KSA3_OH055zFJKMQigmiC",buttonText:"_260TPVTRWJfjuQfeQVQZNV"}},1558:function(t,e,n){t.exports={paddingStuff:"kQEbpWw49P7gi9_aF0OR_",barNumber:"_2EhBuFiCTjlu-TBSJqmEiF",last:"_1sqSQ7W3gPiOn_A9JX__LS"}},1559:function(t,e,n){t.exports={zoomSlider:"_1I-y1Aw-Y4qHmxUfbIAT8z",shiftLeft:"_13y_T47yy-nnUNJaPlsQ6j",decrease:"_1GeBt2VxkX6r85t-echG_F",increase:"JLuBENMfZBcUHLNoTgVry",sliderContainer:"ZdxG_629ZEW17ecMapXIF",slider:"cJgQMup1abR8uH7sX0e6a",sliderInput:"_25cz6phMcIfv6bg-4w4WOv",shade:"_2-xg2v7h_-Zdsp5mAu73bz"}},1560:function(t,e,n){t.exports={pageContainer:"_2u6SJ51rP8Pe_jvuQk-Yj5",titleBar:"_2fOMxaONxJACOo-2ycrSfE",closeBtn:"_10qTwNnRrJ5uG4PP4cPUGo",container:"_2aeFdGlJDmD8i-oVZ5_9qy",progressbar:"_2z4twMvBAB7nO8SAI6aj_s",progressbarWrapper:"_32k3ctXVVZmm6zhokOvhA",toolbar:"_3Jkq5hKyAuFc01jl-8w0R0",tools:"_1rGv--ZCqoZTWQTNW96zHe",tool:"_3jFuqffIVA4Ya-BSEdVDOT",icon:"coOMC5v-mG8MsNx6Pfitt",Pointer:"_1_V-8kRpkmxnYPhTu3wx3q",Pen:"u5y1V3Q1g-5OfLPTrWJJx",Play:"_3mT4QW0ZuPs6NHU72UItLP",Stop:"_1FQoLYNipZcHUL-uWOv1_U",currentTool:"ewUk4bVEva_ziul6DNSpe",right:"_2RjprBBpXVKsLoMGrAMtMz",previousStep:"_3XoR9Svd4fuXsq178hfXYW",subsequentStep:"_3otBEKNMniw6iAdnuGjr8X",copyPaste:"_1lo9vaOzpASGkm4U4rfbWu",hide:"_31kByND5b7rXDP8MukewHR",placeholder:"_11rIJtnGbnXBrnaTYqwoSy",selector:"_24G-yVyefRL6PcdGYV1H1b",selectValue:"_1idIBV--sq0RSqHUCwJ7uV",selectList:"v96IMM9Kca8t0mKLau0zS",listItem:"_1Tbre3v7q3MU2MGW4OnqEe",open:"_1LiBmQr4JcCprVYImpddtz",tooltip:"r0xb9PRNNCjsyjbOm3H4f",wrapper:"_6u7l5IIJSf0UB7mMBTX46",containerScroll:"_3GJcazmFWKN8GJRZly4qb7",keyPadContainer:"dCjUxpVaPF887dsf0x9uB",keysWrapper:"_D74YSNYOkrcYfQlhrYWq",key:"ravSoyjHx97cD0Z-E1GsV",label:"_3P0mRghmfKJ5p1eBIN-uiF",super:"_3_2SOXuxn2p3FBs0j5cLCV",active:"_2PJx9BgfindTZYpwH5ZnPB",noteClipEdit:"_1hOKh7YANQwOKnr05Lc8b3",rulerWrapper:"_11neDigUs7eHjmxyK39Ylf",grid:"_2CbRHzIuFq7ByEXo3akuUt",noteWrapper:"bhHUiyw01nmJ9enQUw3-C",note:"_3_kO1B5TZrzD9s88fz09Ky",selected:"_9W4Bw-ciyghqbVuTOXf0b",noteStretch:"_2JER6gM5BFwi-6M6rGI1pT",clipboard:"_1TdDV6uM5PeAAEQbfmkkf5",selectionRect:"nwbLYtxQ_SAf738n3md7F",contextMenuMask:"_3p9t-saRwIuDSnGowS0Qo5",ContextMenu:"_3uESLjbaZvqjZEwtO2Vh8b",dropdown:"bpsTKAoeIp5h3HJGluFjS",itemTooltip:"qZ-pdKJB4Ij_rLzqAc-GA",tooltipWrapper:"_13o7sWqxeJ8JJGZqqKrgxL",item:"_5hvo0rJwVaTWKtwdp4Hvd",separator:"_2T3szihycW_4lJwTUVN_XN",zoomSliderWrapper:"_NqQOG-kax670nbKFEccu"}},1561:function(t,e,n){t.exports={sliderWrapper:"_1mNa9XOLIWxN1yx80d8f5x",volumeSlider:"_1-VsbcD7qrTuhNAISeF3E8",fieldName:"s3DQMdjszEorb0Na5QVSD",volumeLable:"_1JuLZ0mAbeUuY-2xwLtVz5"}},1562:function(t,e,n){t.exports={menu:"_1qBtRlmsaAYJZoH_RWHgwj",menuTop:"_3kF5pNEhzaWwFT0GCOvhdZ",icon:"_2bmjMKlLB_IOCku7vfAZ2Z",channelName:"iHQm2V1z_IkyPXUFfeaPG",audioChannel:"_2Ue7ww1Nzbe_yesaM3unth",dropdownBtnLabel:"_2LUXAfkeBsChUm8gowof5V",withDropDowm:"_155mJzjpBqB4kz9A2_aoeM",dropdownBtn:"SqUPq8dkFkwFwb0EtZjQ0",active:"_26X5adbVBvvRklWSf3OC7k",instrumentDropdownBtn:"_8FsQpu80JWo10aRyHzS4N",dropdownBtnIcon:"_2d3JsO2nWzM1wvlErWqbmg",modeBtns:"_3_RkdJyNqQBvIbhBcpxkY7",modeBtnTooltip:"kavhz7MMFeYf_r5SY2dqx",tooltipWrapper:"_2iG5495u-yJtqU-ikxUCrl",keyboard:"_1dyAUnFJZLg7Cc-DOkIQIH",waveform:"_1cyTzNp1VCS4_Yb6iQjUmT",keysButton:"_2J7d9rKRh_Uv3C7p7tqZJ_",modeBtn:"zu2U0jvSqkYSILUc92cXP",solo:"_2LcC3iyocJRE-sxsvioqf",mute:"o00VFJ8iWIJTeiIGVVPEc",menuMiddle:"_1svlfsyVZtkuiuLPx9pObP",automationBtn:"_3O3VqmMhAD07iml2UZKA1n",effects:"_3Eofhqd84pMcEfYd-n7E80",showEffectList:"biQBQ4NXii7mE3jcKq0Wj",effectsBtn:"_1Hi1GUQh9jk-Zl2lHghTQI",effectsList:"bT9uecQ-yvpa_Pig0czvj",effectsAdd:"HcK9XRfruhNkT0znrk-sA",addButton:"_1stqeaxQ0_aIkgeOUrDXZP",effectsItem:"_2GBuZj-86_SjWZ34bF0gSq",itemLable:"_1EYdoOD_PmZ_7ae4OOKboE",deleteBtn:"_2TNm-q7qFoOKSf8xSJ4maX",allEffectsDropdown:"_239FRR3gK26Q8cDcpGa-l7",dropdown:"_166KEq9r5_rtS49NjXm1hY",itemTooltip:"YqWCfwb6bIgfrfVZi-icM",item:"_2q7fZ9fSytk6pNPf5vgkno",separator:"_1YvHtp0I66cLHEDxRtl-ux"}},1563:function(t,e,n){t.exports={region:"_5soQQ64taAhfi0Foxg-f-",selected:"_2U7xtWcWnu9_PDhX5cfLJ2",regionBar:"m9y7FzlbGIz_-8IQASqRR",loopDrager:"_3CkInh9_WXvukhF1GP0moj",icon:"_2Z7wT9UFlvALdlgQ2JJzOA",regionCanvas:"_2UUBMcTxVDqtr1a-hqk0sm",regionLoopPart:"_1ZAzb21B9ZF7Ei0Hewjt9c",looped:"yWtZkBqnOp0rjTX6nEEo2",missingFileError:"qY68gu3kKQcWo15Fb7DQS",downloadingFileWarning:"_7RXPLm96_B7iyP7CxB4ze","bg-scrolling-reverse":"_2KvOVWYuBu8VZv1eECwoPP",scissorsPointer:"_3WLjNK3msDYnrY1yPpXeBY"}},1564:function(t,e,n){t.exports={region:"_1Cjgb09sa5cvXKRr6CcRbS",selected:"_3NM4FtaGwZPzFYuBld1VrA",regionBar:"mtFxw2W7-43wDqpXGxbub",loopDrager:"_1G4RMXJLOM3CfeTp5cKAi",icon:"_3iwo61HkgeL9-v6ce39UUh",regionCanvas:"_1XTVCNSk0f_X9sMpzKmmSe",regionLoopPart:"Ie2P_5CrwuKK0NP7D6L6I",looped:"_3HRqLBwdMyjQ58IPV-c2Cu",scissorsPointer:"_2iq5dhBKPWUjVP96gRV8dL"}},1565:function(t,e,n){t.exports={channelAutomation:"_2J-wVzeIgIsQHmL771GME",automationLine:"NGr5hizuSClYhJhGle3v4",contextMenuMask:"_3C_Id_IwZQJJUnNnJF8F2C",automationContextMenu:"_2J4myPasdfT8QevS5zrHjS",dropdown:"_34hv7522SPbIKkl-pl9slR",itemTooltip:"_2yk1fXp0nVs7aAS1L3H-E-",tooltipWrapper:"_1lZn57NQzbCRs4FFEgxC6U",item:"_3Ged_cyAWeVxtfwCi1dkD4",separator:"xc7Cs9TSmcIojeYcsKchf"}},1566:function(t,e,n){t.exports={channelWrapper:"PYw4ig7U6sRMEBa4fCxn1",channel:"TzQ6musfH0ptGqoiK9PFa",channelRegion:"_2mdMFGOQHDvDsQ5nXhDfx1"}},1567:function(t,e,n){t.exports={rulerWrapper:"vQ0BQG99-intnBMb7TcK",rulerNumbers:"_25g6RyGdicnnNYGT9jAIoJ",transportRegion:"ZQxYU4Tr94IKPgEK357ZV",loopingHandleLeft:"pc9rl1Vi4DZnPc-KReqQP",loopingHandleRight:"NEJ2PKBSUCxk8QyzBmVv6",barNumber:"_1rPBXE2ouQk-nJNnQbvt_y",ruler:"_2qyWPvfI5OkwckKXXdxX7k"}},1568:function(t,e,n){"use strict";var s=this&&this.__awaiter||function(t,e,n,s){return new(n||(n=Promise))((function(i,o){function r(t){try{l(s.next(t))}catch(t){o(t)}}function a(t){try{l(s.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}l((s=s.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,s,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,s&&(i=2&o[0]?s.return:o[0]?s.throw||((i=s.return)&&i.call(s),0):s.next)&&!(i=i.call(s,o[1])).done)return i;switch(s=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,s=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]>4;switch(t.channel=15&s,l){case 8:return t.type="noteOff",t.noteNumber=a,t.velocity=n.readUInt8(),t;case 9:var c=n.readUInt8();return t.type=0===c?"noteOff":"noteOn",t.noteNumber=a,t.velocity=c,0===c&&(t.byte9=!0),t;case 10:return t.type="noteAftertouch",t.noteNumber=a,t.amount=n.readUInt8(),t;case 11:return t.type="controller",t.controllerType=a,t.value=n.readUInt8(),t;case 12:return t.type="programChange",t.programNumber=a,t;case 13:return t.type="channelAftertouch",t.amount=a,t;case 14:return t.type="pitchBend",t.value=a+(n.readUInt8()<<7)-8192,t;default:throw"Unrecognised MIDI event type: "+l}}}}function s(t){this.buffer=t,this.bufferLen=this.buffer.length,this.pos=0}s.prototype.eof=function(){return this.pos>=this.bufferLen},s.prototype.readUInt8=function(){var t=this.buffer[this.pos];return this.pos+=1,t},s.prototype.readInt8=function(){var t=this.readUInt8();return 128&t?t-256:t},s.prototype.readUInt16=function(){return(this.readUInt8()<<8)+this.readUInt8()},s.prototype.readInt16=function(){var t=this.readUInt16();return 32768&t?t-65536:t},s.prototype.readUInt24=function(){return(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},s.prototype.readInt24=function(){var t=this.readUInt24();return 8388608&t?t-16777216:t},s.prototype.readUInt32=function(){return(this.readUInt8()<<24)+(this.readUInt8()<<16)+(this.readUInt8()<<8)+this.readUInt8()},s.prototype.readBytes=function(t){var e=this.buffer.slice(this.pos,this.pos+t);return this.pos+=t,e},s.prototype.readString=function(t){var e=this.readBytes(t);return String.fromCharCode.apply(null,e)},s.prototype.readVarInt=function(){for(var t=0;!this.eof();){var e=this.readUInt8();if(!(128&e))return t+e;t+=127&e,t<<=7}return t},s.prototype.readChunk=function(){var t=this.readString(4),e=this.readUInt32();return{id:t,length:e,data:this.readBytes(e)}},t.exports=function(t){var e=new s(t),i=e.readChunk();if("MThd"!=i.id)throw"Bad MIDI file. Expected 'MHdr', got: '"+i.id+"'";for(var o=function(t){var e=new s(t),n=e.readUInt16(),i=e.readUInt16(),o={format:n,numTracks:i},r=e.readUInt16();32768&r?(o.framesPerSecond=256-(r>>8),o.ticksPerFrame=255&r):o.ticksPerBeat=r;return o}(i.data),r=[],a=0;!e.eof()&&a>7&127;t.writeUInt8(p),t.writeUInt8(d);break;default:throw"Unrecognized event type: "+i}return l}function i(){this.buffer=[]}i.prototype.writeUInt8=function(t){this.buffer.push(255&t)},i.prototype.writeInt8=i.prototype.writeUInt8,i.prototype.writeUInt16=function(t){var e=t>>8&255,n=255&t;this.writeUInt8(e),this.writeUInt8(n)},i.prototype.writeInt16=i.prototype.writeUInt16,i.prototype.writeUInt24=function(t){var e=t>>16&255,n=t>>8&255,s=255&t;this.writeUInt8(e),this.writeUInt8(n),this.writeUInt8(s)},i.prototype.writeInt24=i.prototype.writeUInt24,i.prototype.writeUInt32=function(t){var e=t>>24&255,n=t>>16&255,s=t>>8&255,i=255&t;this.writeUInt8(e),this.writeUInt8(n),this.writeUInt8(s),this.writeUInt8(i)},i.prototype.writeInt32=i.prototype.writeUInt32,i.prototype.writeBytes=function(t){this.buffer=this.buffer.concat(Array.prototype.slice.call(t,0))},i.prototype.writeString=function(t){var e,n=t.length,s=[];for(e=0;e>=7;e;){var s=127&e|128;n.push(s),e>>=7}this.writeBytes(n.reverse())}},i.prototype.writeChunk=function(t,e){this.writeString(t),this.writeUInt32(e.length),this.writeBytes(e)},t.exports=function(t,e){if("object"!=typeof t)throw"Invalid MIDI data";e=e||{};var s,o=t.header||{},r=t.tracks||[],a=r.length,l=new i;for(function(t,e,n){var s=null==e.format?1:e.format,o=128;e.timeDivision?o=e.timeDivision:e.ticksPerFrame&&e.framesPerSecond?o=-(255&e.framesPerSecond)<<8|255&e.ticksPerFrame:e.ticksPerBeat&&(o=32767&e.ticksPerBeat);var r=new i;r.writeUInt16(s),r.writeUInt16(n),r.writeUInt16(o),t.writeChunk("MThd",r.buffer)}(l,o,a),s=0;s{this.setState({isActive:!0})},this.handleNoteOff=()=>{this.setState({isActive:!1})},this._onMouseUp=()=>{this.props.keyOnCount()>0&&this.props.noteKeyUp(),document.removeEventListener("mouseup",this._onMouseUp)},this._bindMouseUp=()=>{document.addEventListener("mouseup",this._onMouseUp)},this.state={isActive:!1}}UNSAFE_componentWillReceiveProps(t){return t.note!==this.props.note}componentDidMount(){0!==this.props.note&&(this.props.piano.on(this.props.note+"-on",this.handleNoteOn),this.props.piano.on(this.props.note+"-off",this.handleNoteOff))}componentWillUnmount(){0!==this.props.note&&(this.props.piano.off(this.props.note+"-on",this.handleNoteOn),this.props.piano.off(this.props.note+"-off",this.handleNoteOff))}mouseover(t){t.buttons&&this.props.keyOnCount()>0&&(this._isCurrentNoteOn=!0,this.props.setNoteState(this.props.note,!0))}touchStart(t){const e=t.touches[0].identifier;this.props.bindTouchIdWithNote(this.props.note,e),this.props.setNoteState(this.props.note,!0)}render(){const t=this.props.note,e=this.state.isActive;return s.createElement("div",{className:[a.noteContainer,0===this.props.note?a.hide:""].join(" "),style:this.props.style},0!==this.props.note?s.createElement("button",{"data-note":this.props.note,className:[e?a.active:"",this.props.whiteKey?a.whiteKey:a.blackKey].join(" "),onMouseOver:this.mouseover.bind(this),onMouseLeave:()=>{this._isCurrentNoteOn&&(this._isCurrentNoteOn=!1,this.props.setNoteState(t,!1))},onMouseDown:()=>{this._isCurrentNoteOn=!0,this.props.noteKeyDown(),this.props.setNoteState(t,!0),this._bindMouseUp()},onMouseUp:()=>{this._isCurrentNoteOn=!1,this.props.noteKeyUp(),this.props.setNoteState(t,!1)},onTouchStart:t=>{this.touchStart(t)},onTouchEnd:()=>{this.props.setNoteState(t,!1)}},this.props.showNote?s.createElement("div",{className:a.noteLabel,style:{writingMode:"vertical-rl",textOrientation:"mixed"}},Object(r.d)(this.props.note)):""):"")}}const c=n(1381);class h extends s.Component{constructor(t){super(t)}UNSAFE_componentWillReceiveProps(t){return t.octave!==this.props.octave}render(){const t=12*this.props.octave,e=[0,2,4,5,7,9,11].map(e=>e+t),n=[0,1,3,0,6,8,10,0].map(e=>e?e+t:0);return s.createElement("div",{className:c.octaveContainer},s.createElement("div",{className:c.whiteNotes},e.map((t,e)=>s.createElement("div",{className:c.whiteNote,key:e},s.createElement(l,{setNoteState:this.props.setNoteState,bindTouchIdWithNote:this.props.bindTouchIdWithNote,piano:this.props.piano,showNote:!0,note:t,whiteKey:!0,keyOnCount:this.props.keyOnCount,noteKeyDown:this.props.noteKeyDown,noteKeyUp:this.props.noteKeyUp})))),s.createElement("div",{className:c.blackNotes},n.map((t,e)=>s.createElement("div",{className:c.blackNote,key:e},s.createElement(l,{setNoteState:this.props.setNoteState,bindTouchIdWithNote:this.props.bindTouchIdWithNote,piano:this.props.piano,showNote:!1,note:t,whiteKey:!1,keyOnCount:this.props.keyOnCount,noteKeyDown:this.props.noteKeyDown,noteKeyUp:this.props.noteKeyUp})))))}}const u=n(1545),p=n(1381);class d extends s.Component{constructor(t){super(t),this._keyboardContainerRef=s.createRef(),this.onKeyDown=t=>{90===t.keyCode||t.keyCode},this.onKeyboardDown=t=>{this.props.setNoteState(t.note,!0)},this.onKeyboardUp=t=>{this.props.setNoteState(t.note,!1)},this._keyOnCount=0,this.keyOnCount=()=>this._keyOnCount,this.noteKeyDown=()=>{this._keyOnCount++},this.noteKeyUp=()=>{this._keyOnCount--},this.state={initialNote:60},this._computerKeyboard=new u({polyphony:1/0})}UNSAFE_componentWillReceiveProps(t){return t.rootoctave!==this.props.rootoctave||t.octaves!==this.props.octaves}componentDidMount(){this._computerKeyboard.down(this.onKeyboardDown),this._computerKeyboard.up(this.onKeyboardUp),this.props.fixedKeySize&&this._keyboardContainerRef.current&&this._keyboardContainerRef.current.scrollTo(7*this.props.fixedKeySize*3,0)}componentWillUnmount(){this._computerKeyboard.removeDownListener(this.onKeyboardDown),this._computerKeyboard.removeUpListener(this.onKeyboardDown),delete this.onKeyboardDown,delete this.onKeyboardUp}render(){const t=[];for(let e=this.props.rootoctave;es.createElement(h,{setNoteState:this.props.setNoteState,piano:this.props.piano,bindTouchIdWithNote:this.props.bindTouchIdWithNote,octave:t,key:e,keyOnCount:this.keyOnCount,noteKeyDown:this.noteKeyDown,noteKeyUp:this.noteKeyUp}))))}}var m=n(553);class f extends m.EventEmitter{constructor(t,e){super(),this.tone=t,this.instrument=e,this.activeNotes={},this.noteAndTouchId={},this.touchedNote={},this._startRecordTime=-1,this.keysState={},this.list=[],this.activeNotes[0]=!1;for(let t=12;t<=107;t++)this.activeNotes[t]=!1,this.keysState[t]=-1}get isRecording(){return-1!==this._startRecordTime}startRecording(){const t=this.tone.getContext();t.transport.start(),this._startRecordTime=t.transport.seconds,this.list=[]}stopRecording(){const t=this.tone.getContext(),e=t.transport.seconds-this._startRecordTime,n=this._startRecordTime;return t.transport.stop(),this._startRecordTime=-1,{position:n,length:e,notes:this.list}}triggerAttackRelease(t,e,n,s){this.instrument?this.instrument.triggerAttackRelease(t,e,n,s):console.warn("piano's instrument has not been set yet")}handleNoteActiveStateChange(t,e){if(this.activeNotes[t]!==e){if(!0===e){if(this.instrument&&(this.instrument.triggerAttack(Object(r.d)(t)),-1!==this._startRecordTime)){const e=this.tone.getContext();this.keysState[t]=e.transport.seconds-this._startRecordTime}}else if(this.instrument&&("PluckSynth"===this.instrument.name?this.instrument.triggerRelease():this.instrument.triggerRelease(Object(r.d)(t)),-1!==this._startRecordTime)){const e=this.tone.getContext().transport.seconds-this._startRecordTime-this.keysState[t];this.list.push({note:t,position:this.keysState[t],length:e}),this.keysState[t]=-1}this.activeNotes[t]=e}}setInstrument(t){this.instrument=t}bindTouchIdWithNote(t,e){this.noteAndTouchId[t]=e,this.touchedNote[e]=t}findNodeByTouchId(t){for(const e in this.noteAndTouchId)if(this.noteAndTouchId[e]===t)return Number(e);return null}}var g=n(1358);const _=n(1557);class v extends s.Component{constructor(t){super(t),this.containerBoundbox={left:250,top:150,mouseDownX:0,mouseDownY:0},this.preNoteStates={},this._onChannelInstrumentChange=()=>{const t=this.props.arrangement.instruments[this.props.channel.id];t&&this.piano.setInstrument(t)},this._startRecord=()=>{this.piano.startRecording()},this._stopRecord=()=>{const t=this.piano.stopRecording();this.props.arrangement.addNoteToRegionFromClip(this.props.channel,t),this.props.arrangement.emit(g.b.keyBoardRecordStopped)},this.ontouchmove=t=>{let e=!1;Array.from(t.changedTouches).forEach(t=>{const n=document.elementFromPoint(t.clientX,t.clientY),s=this.piano.touchedNote[t.identifier];if(n&&n.hasAttribute("data-note")){const i=Number(n.getAttribute("data-note"));void 0!==s&&s!==i?(this.piano.handleNoteActiveStateChange(s,!1),this.piano.noteAndTouchId[s]=-1,this.piano.handleNoteActiveStateChange(i,!0),this.piano.noteAndTouchId[i]=t.identifier,e=!0):void 0===s&&0!==i&&(this.piano.handleNoteActiveStateChange(i,!0),this.piano.noteAndTouchId[i]=t.identifier,e=!0),this.piano.touchedNote[t.identifier]=i}}),e&&(this.emitNoteStateChangeEvent(),this.preNoteStates=Object.assign({},this.piano.activeNotes))},this.ontouchend=t=>{let e=!1;Array.from(t.changedTouches).forEach(t=>{const n=this.piano.touchedNote[t.identifier];n&&this.piano.activeNotes[n]&&(this.piano.handleNoteActiveStateChange(n,!1),this.piano.noteAndTouchId[n]=-1,e=!0)}),this.piano.touchedNote={},e&&(this.emitNoteStateChangeEvent(),this.preNoteStates=Object.assign({},this.piano.activeNotes))},this._onmousemove=t=>{const e=t.clientX-this.containerBoundbox.mouseDownX,n=t.clientY-this.containerBoundbox.mouseDownY;this.pageContainerRef.current&&(this.pageContainerRef.current.style.transform=`translate(${e+this.containerBoundbox.left}px, ${n+this.containerBoundbox.top}px)`),t.stopPropagation()},this._onmouseup=t=>{const e=t.clientX-this.containerBoundbox.mouseDownX,n=t.clientY-this.containerBoundbox.mouseDownY;this.setState({left:e+this.containerBoundbox.left,top:n+this.containerBoundbox.top}),document.removeEventListener("mousemove",this._onmousemove),document.removeEventListener("mouseup",this._onmouseup),t.stopPropagation()},this.continerRef=s.createRef(),this.pageContainerRef=s.createRef(),this.resize=this.resize.bind(this);const e=this.props.arrangement.instruments[this.props.channel.id];this.piano=new f(this.props.tone,null!==e?e:void 0),this.state={octaves:8,rootNote:1,showInstrumentPanel:!1,instrumentName:null!==e?e.name:"unknow instrument",left:this.containerBoundbox.left,top:this.containerBoundbox.top},this.preNoteStates=Object.assign({},this.piano.activeNotes)}componentDidMount(){this.props.arrangement.addListener(`${g.b.connectNewInstrument}-${this.props.channel.id}`,this._onChannelInstrumentChange),this.props.arrangement.addListener(g.b.startKeyBoardRecord,this._startRecord),this.props.arrangement.addListener(g.b.stopKeyBoardRecord,this._stopRecord)}componentWillUnmount(){this.props.arrangement.removeListener(`${g.b.connectNewInstrument}-${this.props.channel.id}`,this._onChannelInstrumentChange),this.props.arrangement.removeListener(g.b.startKeyBoardRecord,this._startRecord),this.props.arrangement.removeListener(g.b.stopKeyBoardRecord,this._stopRecord)}resize(){if(this.continerRef.current){const t=this.continerRef.current.clientWidth,e=Object(r.a)(Math.floor(t/120)-1,1,8),n=Math.ceil(6-Object(r.f)(e,1,8,1,5));this.setState({octaves:e,rootNote:n})}}emitNoteStateChangeEvent(){for(const t in this.piano.activeNotes)this.preNoteStates[t]!==this.piano.activeNotes[t]&&(this.piano.activeNotes[t]?this.piano.emit(t+"-on"):this.piano.emit(t+"-off"))}setNoteState(t,e){this.preNoteStates[t]!==e&&(this.piano.handleNoteActiveStateChange(t,e),this.emitNoteStateChangeEvent(),this.preNoteStates=Object.assign({},this.piano.activeNotes))}_bindMouseEvent(){document.addEventListener("mousemove",this._onmousemove),document.addEventListener("mouseup",this._onmouseup)}render(){return s.createElement("div",{className:_.pageContainer,ref:this.pageContainerRef,style:{transform:`translate(${this.state.left}px, ${this.state.top}px)`}},s.createElement("header",{onMouseDown:t=>{this.containerBoundbox.left=this.state.left,this.containerBoundbox.top=this.state.top,this.containerBoundbox.mouseDownX=t.clientX,this.containerBoundbox.mouseDownY=t.clientY,this._bindMouseEvent(),t.stopPropagation()}},s.createElement("div",{className:_.closeBtn,onClick:t=>{t.stopPropagation(),this.piano.isRecording&&this._stopRecord(),this.props.closePanel()}},"Close")),s.createElement("div",{ref:this.continerRef,className:_.container,onTouchMove:this.ontouchmove,onTouchEnd:this.ontouchend},s.createElement(d,{setNoteState:this.setNoteState.bind(this),piano:this.piano,bindTouchIdWithNote:this.piano.bindTouchIdWithNote.bind(this),octaves:this.state.octaves,rootoctave:this.state.rootNote,fixedKeySize:20})),s.createElement("div",{className:_.tracker},s.createElement("div",{className:_.track})))}}var b=n(396),y=n(1359),w=n(1368);const x=n(1558);function S(t){const e=t.uniteNoteLen;return i.a.createElement("div",{style:{width:"100%",height:"24px",backgroundPositionX:t.positionX+"px",backgroundSize:`24px 24px,\n ${4*e}px 48px,\n ${e/2}px ${e/2}px,\n ${e}px ${e}px`,backgroundImage:`linear-gradient( to bottom, #467277, #467277 12px, transparent 12px ),\n linear-gradient( to right, black 1px, transparent 1px, transparent ${4*e}px),\n linear-gradient( to right, #00000047 1px, transparent 1px, transparent ${e/2}px),\n linear-gradient( to right, #54535380 1px, transparent 1px, transparent ${e}px)`}},i.a.createElement("div",{className:x.numbersWrapper,style:{height:"12px",width:"100%"}},function(){const e=t.getCalculator(),n=e.fromPulses(t.region.timing.pulsesLength+e.fromQuarters(8).toPulses()).toPixels(),s=e.fromQuarters(4).toPulses(),o=e.fromQuarters(4).toPixels(),r=o-e.fromPulses(t.region.position%s).toPixels(),a=[];r!==o&&a.push(i.a.createElement("div",{key:0,className:x.paddingStuff,style:{width:r+"px"}}));const l=Math.floor(n/o),c=Math.ceil(t.region.position/s)+1;for(let t=0;tthis.props.onPulsePerPixelIncrease()}),s.createElement("div",{className:k.sliderContainer},s.createElement("div",{className:k.slider},s.createElement("input",{className:k.sliderInput,type:"range",min:this.props.steps[0],max:this.props.steps[this.props.steps.length-1],value:t,onChange:e=>{const n=Number(e.target.value);if(n>t){let e=n-t;for(;e--;)this.props.onPulsePerPixelDecrease()}else if(nthis.props.onPulsePerPixelDecrease()}))}}class P{constructor(){this.stack_A=[],this.stack_B=[]}push(t){for(this.stack_A.push(t);this.stack_B.length;)y.s.free(this.stack_B[this.stack_B.length-1]),this.stack_B.pop()}prevState(){if(this.stack_A.length>0){const t=this.stack_A.pop();this.stack_B.push(t)}return this.stack_A.length>0?this.stack_A[this.stack_A.length-1]:null}nextState(){if(this.stack_B.length>0){const t=this.stack_B.pop();this.stack_A.push(t)}return this.stack_A.length>0?this.stack_A[this.stack_A.length-1]:null}cleanUp(){for(;this.stack_A.length;)y.s.free(this.stack_A[this.stack_A.length-1]),this.stack_A.pop();for(;this.stack_B.length;)y.s.free(this.stack_B[this.stack_B.length-1]),this.stack_B.pop()}}var T=Object.defineProperty,M=Object.defineProperties,R=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable,D=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;const B=n(1560);class I extends s.Component{constructor(t){super(t),this.progressBarRef=s.createRef(),this.gridRef=s.createRef(),this.rulerRef=s.createRef(),this.rectSelection=s.createRef(),this.keysStateCopy={},this.dragStartPulse=1/0,this.dragStartPitch=1/0,this.reqAnimatHandler=null,this.rulerPosY=0,this.dragOperation=0,this.backUpNotes=[],this.noteRefTable={},this.focusNoteId="",this.selectionRectConfig={x:0,y:0,width:0,height:0},this.contextMenuPos=[0,0],this.stateHistoryStore=new P,this.notesClipboard=[],this.clipboardBackUp=[],this.noteClipboardRefTable={},this.getCalculator=()=>new w.a(this.state.pulsesPerPixel,this.props.arrangement.ctx.sampleRate,this.props.arrangement.ctx.transport.bpm.value),this.partPlayer=null,this.startTime=1/0,this.updateCounter=()=>{this.setState({notesUpdateCounter:this.state.notesUpdateCounter+1})},this.updateProgressBar=()=>{if(this.state.playing){const t=this.getCalculator(),e=t.fromPulses(this.props.region.timing.pulsesLength).toSeconds(),n=(this.props.tone.now()-this.startTime)%e;if(n>=0&&n<=e){const e=t.fromMilliseconds(1e3*n).toPixels();this.progressBarRef.current&&(this.progressBarRef.current.style.transform=`translate(${e}px, 0)`)}}if(this.continerRef.current){const t=this.continerRef.current;this.rulerPosY=Math.min(t.scrollTop,t.scrollHeight-t.clientHeight),this.rulerRef.current&&(this.rulerRef.current.style.transform=`translateY(${this.rulerPosY}px)`)}this.reqAnimatHandler=window.requestAnimationFrame(this.updateProgressBar)},this.onKeydown=t=>{t.preventDefault(),t.stopPropagation(),91===t.keyCode||8===t.keyCode&&this.deleteSelectNote(),t.preventDefault()},this.onMouseMove=t=>{if(0===this.dragOperation&&this.state.showSelectionRect){const e=this.computeSelectionRect(t);this.selectionRectConfig=e,this.upadeRectSelection()}},this.onMouseUp=t=>{if(this.state.showSelectionRect){const e=!t.shiftKey,n=[],s=this.gridRef.current;if(s){const t=s.getBoundingClientRect();let i=Math.floor((t.bottom-t.top-this.selectionRectConfig.y)/this.state.noteHeight)+12,o=Math.floor((t.bottom-t.top-this.selectionRectConfig.y-this.selectionRectConfig.height)/this.state.noteHeight)+12;i>o&&([i,o]=[o,i]);let r=this.selectionRectConfig.x,a=this.selectionRectConfig.x+this.selectionRectConfig.width;r>a&&([r,a]=[a,r]);const l=this.props.region;for(let t=0;t=r&&e.pitch<=o&&e.pitch>=i&&n.push(e.id)}if(e)this.setState({selectedNotes:n});else{for(let t=0;t{for(let e=0;e{for(let e=0;e{const n=this.props.region.timing.pulsesContentPosition;if(1===this.dragOperation){const s=this.getCalculator(),i=this.backUpNotes;for(let o=0;othis.state.rightThreshold)continue;const o=(a.pitch-12)*-this.state.noteHeight-1;t.style.transform=`translate(${e}px, ${o}px)`,t.style.height=this.state.noteHeight-1+"px",t.style.width=i-e-1+"px"}}}}else if(2===this.dragOperation){const t=this.getCalculator(),s=this.backUpNotes;for(let i=0;ithis.state.rightThreshold)continue;e.style.height=this.state.noteHeight-1+"px",e.style.width=i-s-1+"px"}}}}},this.noteMouseMoveListener=t=>{const e=this.getNoteById(this.focusNoteId);if(e&&this.noteRefTable[this.focusNoteId]&&this.noteRefTable[this.focusNoteId].current){const n=this.noteRefTable[this.focusNoteId].current,s=this.getPulseByClientX(t.clientX,n,e),i=this.getPitchByClientY(t.clientY),o=s-this.dragStartPulse,r=null!==i&&i!==1/0?i-this.dragStartPitch:0;this.updateEditingNotes(r,o)}},this.noteMouseUpListener=t=>{this.dragOperation=0,this.props.region.notes.sort((t,e)=>t.position-e.position),this.stateHistoryStore.push(y.s.clone(this.props.region)),this.props.arrangement.emit(`${g.b.regionsNoteUpdate}-${this.props.region.id}`),this.setState({notesUpdateCounter:this.state.notesUpdateCounter+1}),document.removeEventListener("mousemove",this.noteMouseMoveListener),document.removeEventListener("mouseup",this.noteMouseUpListener)},this.updateClipboardNotes=(t,e)=>{const n=this.props.region.timing.pulsesContentPosition;if(1===this.dragOperation){const s=this.getCalculator();for(let i=0;ithis.state.rightThreshold)continue;const a=(r.pitch-12)*-this.state.noteHeight-1;t.style.transform=`translate(${e}px, ${a}px)`,t.style.height=this.state.noteHeight-1+"px",t.style.width=i-e-1+"px"}}}}},this.clipboardMouseMoveListener=t=>{const e=this.getClipboardNoteById(this.focusNoteId);if(e&&this.noteClipboardRefTable[this.focusNoteId]&&this.noteClipboardRefTable[this.focusNoteId].current){const n=this.noteClipboardRefTable[this.focusNoteId].current,s=this.getPulseByClientX(t.clientX,n,e),i=this.getPitchByClientY(t.clientY),o=s-this.dragStartPulse,r=null!==i&&i!==1/0?i-this.dragStartPitch:0;this.updateClipboardNotes(r,o)}},this.clipboardMouseUpListener=t=>{this.dragOperation=0,document.removeEventListener("mousemove",this.clipboardMouseMoveListener),document.removeEventListener("mouseup",this.clipboardMouseUpListener)},this.continerRef=s.createRef(),this.instrument=this.props.arrangement.instruments[this.props.channel.id];const e={};for(let t=12;t<108;t++)e[t]=!1,this.keysStateCopy[t]=!1;const n=this.props.arrangement.ctx.transport.PPQ/4/32;this.state={uniteNoteLen:32,noteHeight:14,pulsesPerPixel:n,snapPixels:8,currentTool:1,selectedNotes:[],notesUpdateCounter:1,keysState:e,showSelectionRect:!1,playing:!1,penSize:16,openPenSizeSelector:!1,leftThreshold:0,rightThreshold:.9*window.innerWidth*2,showContextMenu:!1,copyPasteStep:0},this.props.arrangement.ctx.transport.stop()}shouldComponentUpdate(t,e){return t.channel.id!==this.props.channel.id||t.region.id!==this.props.region.id||(e.uniteNoteLen!==this.state.uniteNoteLen||e.noteHeight!==this.state.noteHeight||e.pulsesPerPixel!==this.state.pulsesPerPixel||e.snapPixels!==this.state.snapPixels||e.currentTool!==this.state.currentTool||e.selectedNotes!==this.state.selectedNotes||e.keysState!==this.state.keysState||e.showSelectionRect!==this.state.showSelectionRect||e.notesUpdateCounter!==this.state.notesUpdateCounter||e.playing!==this.state.playing||e.penSize!==this.state.penSize||e.openPenSizeSelector!==this.state.openPenSizeSelector||e.leftThreshold!==this.state.leftThreshold||e.rightThreshold!==this.state.rightThreshold||e.showContextMenu!==this.state.showContextMenu||e.copyPasteStep!==this.state.copyPasteStep)}toggle(){const t=this.props.tone;if(!0!==this.state.playing){const e=this.getCalculator(),n=[];for(let t=0;t=0&&s.position+this.props.region.timing.pulsesContentPosition{this.instrument.triggerAttackRelease(e.note,e.duration,t,1)},n),this.partPlayer.loopEnd=e.fromPulses(this.props.region.timing.pulsesLength).toSeconds(),this.partPlayer.loop=!0,this.setState({playing:!0},()=>{const e=t.now();this.startTime=e,this.props.arrangement.ctx.transport.start(),this.partPlayer&&this.partPlayer.start()})}else this.setState({playing:!1},()=>{null!==this.partPlayer&&(this.partPlayer.stop(),this.partPlayer.dispose(),this.partPlayer=null),this.props.arrangement.ctx.transport.stop(),this.props.arrangement.ctx.transport.cancel(0)})}computePositionInChannelFromPulse(t,e){const n=this.getCalculator(),s=this.props.region,i=t+s.timing.pulsesContentPosition+s.position,o=n.fromPixels(1).toPulses(),r=n.fromFrames(7938e4).toPulses();if(0===t)return Math.max(s.position,Math.min(r,i));const a=n.fromQuarters(1).toPulses()/4,l=Math.round(Math.floor(i/a)*a);return lo*e?Math.min(Math.max(i,s.position),r):Math.min(l,r)}endOfRegion(){let t=0;for(let e=0;e{this.keysStateCopy[l.pitch]=!1,this.setState({keysState:this.keysStateCopy})},e.fromPulses(l.length).toMilliseconds())}s.notes.sort((t,e)=>t.position-e.position),this.stateHistoryStore.push(y.s.clone(s))}computeSelectionRect(t){var e;const n=this.getCalculator(),s=this.selectionRectConfig,i=n.fromQuarters(4).toPulses(),o=this.endOfRegion(),r=(null==(e=this.gridRef.current)?void 0:e.offsetWidth)||0,a=Math.max(this.props.region.timing.pulsesLength+i,n.fromPixels(r).toPulses(),o),l=this.gridRef.current;if(l&&s){const e=l.scrollHeight,i=l.getBoundingClientRect();return((t,e)=>M(t,R(e)))(((t,e)=>{for(var n in e||(e={}))O.call(e,n)&&D(t,n,e[n]);if(A)for(var n of A(e))N.call(e,n)&&D(t,n,e[n]);return t})({},s),{width:Math.min(n.fromPixels(t.clientX-i.left).toPulses(),a)-s.x,height:Math.min(t.clientY-i.top,e)-s.y})}return s}deleteSelectNote(){for(let t=0;t=0?e.x:e.x+e.width).toPixels()+"px",s=(e.height>=0?e.y:e.y+e.height)+"px",i=t.fromPulses(Math.abs(e.width)).toPixels()+"px",o=Math.abs(e.height)+"px";this.rectSelection.current.style.left=n,this.rectSelection.current.style.top=s,this.rectSelection.current.style.width=i,this.rectSelection.current.style.height=o}}componentWillUnmount(){window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),document.removeEventListener("keydown",this.onKeydown),this.props.arrangement.removeListener(g.b.regionsNoteUpdate+"-"+this.props.region.id,this.updateCounter),null!==this.reqAnimatHandler&&window.cancelAnimationFrame(this.reqAnimatHandler),this.state.playing&&(null!==this.partPlayer&&(this.partPlayer.stop(),this.partPlayer.dispose(),this.partPlayer=null),this.props.arrangement.ctx.transport.stop(),this.props.arrangement.ctx.transport.cancel(0)),this.props.region.notes.sort((t,e)=>t.position-e.position),this.stateHistoryStore.cleanUp()}bindNoteMouseListeners(){document.addEventListener("mousemove",this.noteMouseMoveListener),document.addEventListener("mouseup",this.noteMouseUpListener)}bindClipboardMouseListeners(){document.addEventListener("mousemove",this.clipboardMouseMoveListener),document.addEventListener("mouseup",this.clipboardMouseUpListener)}getPitchByClientY(t){const e=this.state.noteHeight,n=this.gridRef.current;if(n){const s=n.getBoundingClientRect();return Math.floor((s.bottom-t)/e)+12}return null}getPulseByClientX(t,e,n){const s=this.getCalculator(),i=this.state.pulsesPerPixel,o=this.props.region.timing.pulsesContentPosition;Math.round(s.fromPulses(n.position+o).toPixels());const r=t-e.getBoundingClientRect().left;return n.position+i*r}computeAdjustedTiming(t,e,n,s,i){const o=this.props.region.timing.pulsesLength,r=t.fromQuarters(1/16).toPulses(),a=n.position+r,l=o,c=n.length;let h=this.computeAlignedPos(t,e,n.position+c+s,i);h=hl?l:h;const u=h-n.position-c;return Math.max(c+u,r)}noteStretch(t,e,n,s,i){return this.computeAdjustedTiming(t,e,n,s,i)}computeAlignedPos(t,e,n,s,i=0){const o=t.fromPixels(1).toPulses(),r=this.props.region.timing.pulsesLength+t.fromQuarters(8).toPulses();if(0===e)return Math.max(i,Math.min(n,r));let a=t.fromPixels(e).toPulses();a/=s||1;const l=Math.round(Math.round(n/a)*a);return lo*e?Math.min(Math.max(n,i),r):Math.min(l,r)}computeShiftedPos(t,e,n,s,i,o){const r=this.props.region.timing.pulsesLength+t.fromQuarters(8).toPulses();let a=e[0];for(let t=0;te[t].position&&(a=e[t]);const l=a?a.position:s.position,c=Math.max(s.position-l,0),h=r-s.length,u=this.computeAlignedPos(t,n,l+i,o),p=s.position+(u-l);return ph?{position:h}:{position:p}}isSuperKey(t){const e=t%12;return 1===e||3===e||6===e||8===e||10===e}renderKeys(){const t=[];for(let e=107,n=0;e>=12;e--,n++){const i=this.isSuperKey(e);t[n]=s.createElement("span",{key:e,className:[B.key,i?B.super:"",this.state.keysState[e]?B.active:""].join(" ")},i?"":s.createElement("span",{className:B.label},Object(r.d)(e)))}return t}backUpSelectedNotes(){for(let t=0;t{if(0!==t.button)return;const e=Number(t.clientX),n=Number(t.clientY);t.target===t.currentTarget&&(this.backUpClipboard(),this.focusNoteId=o.id,this.dragStartPulse=this.getPulseByClientX(e,t.currentTarget,o),this.dragStartPitch=this.getPitchByClientY(n)||1/0,this.dragOperation=1,this.bindClipboardMouseListeners()),t.stopPropagation(),t.preventDefault()},style:{transform:`translate(${a}px, ${c}px)`,height:this.state.noteHeight-1+"px",width:l-a-1+"px"}},s.createElement("div",{style:{pointerEvents:"none"},className:[B.note,B.clipboard].join(" ")})))}return n}renderNotes(){const t=this.getCalculator(),e=this.props.region.timing.pulsesContentPosition,n=[];this.noteRefTable={};for(let i=0;ithis.state.rightThreshold)continue;const h=(o.pitch-12)*-this.state.noteHeight-1,u=s.createRef();this.noteRefTable[o.id]=u,n.push(s.createElement("div",{key:o.id,id:o.id,className:B.noteWrapper,ref:this.noteRefTable[o.id],onClick:()=>{this.instrument.triggerAttackRelease(Object(r.d)(o.pitch),t.fromPulses(o.length).toSeconds(),this.props.tone.now(),1)},onContextMenu:t=>{if(this.gridRef.current){const e=this.gridRef.current.getBoundingClientRect(),n=t.clientX-e.left+32,s=t.clientY-e.top+24;this.contextMenuPos[0]=n,this.contextMenuPos[1]=s,0===this.state.selectedNotes.length?this.setState({selectedNotes:[o.id],showContextMenu:!0}):this.setState({showContextMenu:!0})}t.stopPropagation(),t.preventDefault()},onMouseDown:t=>{if(0!==t.button)return;const e=Number(t.clientX),n=Number(t.clientY);t.target===t.currentTarget?1===this.state.currentTool&&(a?this.backUpSelectedNotes():(this.backUpNotes=[y.u.clone(o)],this.setState({selectedNotes:[o.id]})),this.focusNoteId=o.id,this.dragStartPulse=this.getPulseByClientX(e,t.currentTarget,o),this.dragStartPitch=this.getPitchByClientY(n)||1/0,this.dragOperation=1,this.bindNoteMouseListeners()):0!==this.state.currentTool&&1!==this.state.currentTool||(0===this.state.currentTool&&this.state.showContextMenu&&this.setState({showContextMenu:!1}),a?this.backUpSelectedNotes():(this.backUpNotes=[y.u.clone(o)],this.setState({selectedNotes:[o.id]})),this.focusNoteId=o.id,this.dragStartPulse=this.getPulseByClientX(e,t.currentTarget,o),this.dragOperation=2,this.bindNoteMouseListeners()),t.stopPropagation(),t.preventDefault()},style:{transform:`translate(${l}px, ${h}px)`,height:this.state.noteHeight-1+"px",width:c-l-1+"px"}},s.createElement("div",{style:{pointerEvents:"none",backgroundColor:this.props.region.color},className:[B.note,a?B.selected:""].join(" ")},s.createElement("div",{className:B.noteStretch,style:{pointerEvents:"all"}}))))}return n}renderPenSizeButton(){return s.createElement("div",{className:[B.tool,B.selector].join(" ")},s.createElement("div",{className:B.selectValue,onClick:()=>{this.setState({openPenSizeSelector:!this.state.openPenSizeSelector})}},"1/",this.state.penSize," ",Object(C.e)("n")),s.createElement("div",{className:[B.selectList,this.state.openPenSizeSelector?B.open:""].join(" ")},[1,2,4,6,8,12,16,24,32,64].map((t,e)=>s.createElement("div",{className:B.listItem,key:e,onClick:()=>{this.setState({penSize:t,openPenSizeSelector:!1})}},"1/",t))))}render(){const{uniteNoteLen:t,noteHeight:e,pulsesPerPixel:n}=this.state,i=this.getCalculator(),o=i.fromQuarters(4).toPulses(),r=i.fromQuarters(4).toPixels()-i.fromPulses(this.props.region.position%o).toPixels();return s.createElement("div",{className:B.pageContainer},s.createElement("header",{className:B.titleBar},s.createElement("button",{className:B.closeBtn,onClick:()=>{this.props.close()}},s.createElement("i",{className:B.icon}),Object(C.e)("Close")),s.createElement("h3",null,"Note Clip Editor - ",this.props.channel.instrument.config.type)),s.createElement("div",{className:B.container},s.createElement("div",{className:B.toolBar},s.createElement("div",{className:B.tools},s.createElement("div",{className:[B.tool,B.Pointer,1===this.state.currentTool?B.currentTool:""].join(" "),onClick:()=>{this.setState({currentTool:1})}},s.createElement("div",{className:B.icon})),s.createElement("div",{className:[B.tool,B.Pen,0===this.state.currentTool?B.currentTool:""].join(" "),onClick:()=>{this.setState({currentTool:0})}},s.createElement("div",{className:B.icon})),this.renderPenSizeButton(),s.createElement("div",{className:[B.tool,B.previousStep].join(" "),onClick:()=>{const t=this.stateHistoryStore.prevState();t&&(y.s.assign(this.props.region,t),this.forceUpdate())}},s.createElement("div",{className:B.icon})),s.createElement("div",{className:[B.tool,B.subsequentStep].join(" "),onClick:()=>{const t=this.stateHistoryStore.nextState();t&&(y.s.assign(this.props.region,t),this.forceUpdate())}},s.createElement("div",{className:B.icon})),s.createElement("div",{className:[B.tool,B.copyPaste,0===this.state.selectedNotes.length&&0===this.state.copyPasteStep?B.hide:"",1===this.state.copyPasteStep?B.paste:""].join(" "),onClick:()=>{0===this.state.copyPasteStep?(this.copySelectedNotes(),this.setState({selectedNotes:[],copyPasteStep:1})):this.pasteClipboard()}},s.createElement("div",null,1===this.state.copyPasteStep?Object(C.e)("PasteNotes"):Object(C.e)("CopyNotes"))),s.createElement("div",{className:[B.tool,B.copyPaste,1===this.state.copyPasteStep?B.finished:B.hide].join(" "),onClick:()=>{this.clearClipboard()}},s.createElement("div",null,Object(C.e)("Finish"))),s.createElement("div",{className:B.placeholder}),s.createElement("div",{className:[B.tool,this.state.playing?B.Stop:B.Play,B.right].join(" "),onClick:()=>{this.toggle()}},s.createElement("div",{className:B.icon})))),s.createElement("div",{className:B.containerScroll,ref:this.continerRef,onScroll:t=>{const e=t.currentTarget,n=Math.max(0,e.scrollLeft-.9*window.innerWidth*.6),s=e.scrollLeft+.9*window.innerWidth*1.6;this.setState({leftThreshold:n,rightThreshold:s})}},s.createElement("div",{className:B.progressbarWrapper},s.createElement("div",{className:B.progressbar,ref:this.progressBarRef})),s.createElement("div",{className:B.keyPadContainer,style:{width:i.fromPulses(this.props.region.timing.pulsesLength).toPixels()+t+"px"}},s.createElement("div",{className:B.keysWrapper},this.renderKeys())),s.createElement("div",{className:B.noteClipEdit,style:{width:i.fromPulses(this.props.region.timing.pulsesLength+i.fromQuarters(8).toPulses()).toPixels()+"px",minWidth:"100%"},ref:this.gridRef},s.createElement("div",{className:B.rulerWrapper,ref:this.rulerRef,style:{height:"24px",top:"-24px",transform:`translateY(${this.rulerPosY}px)`}},s.createElement(S,{positionX:r,region:this.props.region,getCalculator:this.getCalculator,uniteNoteLen:this.state.uniteNoteLen})),s.createElement("div",{className:B.grid,style:{backgroundPositionX:(t-this.props.region.position%(this.props.arrangement.ctx.transport.PPQ/4)/n)%t+"px",backgroundSize:`${e}px ${e}px,\n ${4*t}px ${4*t}px,\n ${t}px ${t}px,\n 168px 168px, 168px 168px`},onContextMenu:t=>{t.preventDefault(),t.stopPropagation()},onDoubleClick:t=>{this.gridRef.current&&1===this.state.currentTool&&t.target===t.currentTarget&&this.addNoteAction(t)},onMouseDown:t=>{if(0!==t.button)return;const e=this.gridRef.current;if(e)if(0===this.state.currentTool)t.target===t.currentTarget&&this.addNoteAction(t);else if(1===this.state.currentTool&&t.target===t.currentTarget){const n=e.getBoundingClientRect(),s=t.clientX-n.left,o=i.fromPixels(s).toPulses();this.selectionRectConfig={x:o,y:t.clientY-n.top,width:0,height:0},this.setState({showSelectionRect:!0}),this.upadeRectSelection()}}},s.createElement("div",{style:{width:`calc(100% - ${i.fromPulses(this.props.region.timing.pulsesLength).toPixels()}px)`,height:"100%",transform:`translate(${i.fromPulses(this.props.region.timing.pulsesLength).toPixels()}px, 0px)`,pointerEvents:"none",background:"#00000085"}}),s.createElement("div",{ref:this.rectSelection,className:B.selectionRect,style:{display:this.state.showSelectionRect?"initial":"none"}}),this.state.notesUpdateCounter&&this.renderNotes(),1===this.state.copyPasteStep&&this.renderClipboard())),this.state.showContextMenu?s.createElement("div",{className:B.contextMenuMask,onClick:()=>{this.setState({showContextMenu:!1})}}):null,this.state.showContextMenu?s.createElement("div",{className:B.ContextMenu,style:{transform:`translate(${this.contextMenuPos[0]}px, ${this.contextMenuPos[1]}px)`}},s.createElement("div",{className:B.dropdown},s.createElement("div",{className:[B.itemTooltip,B.tooltipWrapper].join(" ")},s.createElement("div",{className:B.item,onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onClick:()=>{this.deleteSelectNote(),this.setState({showContextMenu:!1})}},Object(C.e)("Delete"))))):null),s.createElement("div",{className:B.zoomSliderWrapper},s.createElement(E,{onPulsePerPixelDecrease:()=>{if(this.state.pulsesPerPixel>1.5){const t=this.state.pulsesPerPixel/2,e=2*this.state.uniteNoteLen;this.setState({pulsesPerPixel:t,uniteNoteLen:e,snapPixels:e/4})}},onPulsePerPixelIncrease:()=>{if(this.state.pulsesPerPixel<6){const t=2*this.state.pulsesPerPixel,e=this.state.uniteNoteLen/2;this.setState({pulsesPerPixel:t,uniteNoteLen:e,snapPixels:e/4})}},steps:[0,1,2],maxPulsesPerPixel:6,minPulsesPerPixel:1.5,pulsesPerPixel:this.state.pulsesPerPixel,rightPanelOpen:!1}))))}}var F=n(1406),V=n(0),j=Object.defineProperty,L=Object.defineProperties,q=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,Q=(t,e,n)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,X=(t,e)=>{for(var n in e||(e={}))H.call(e,n)&&Q(t,n,e[n]);if(U)for(var n of U(e))W.call(e,n)&&Q(t,n,e[n]);return t},z=(t,e)=>L(t,q(e));const G=38,Y=130,K=1,Z=48,J=(Math.pow(10,.3),15),$=new V.q({width:new V.h}),tt=new V.q({zoom:new V.h}),et=new V.q({leftThreshold:new V.h,rightThreshold:new V.h}),nt=new V.q({renderOffset:new V.h,renderWidth:new V.h,pulsesPerPixel:new V.w,leftThreshold:new V.h,rightThreshold:new V.h}),st=new V.v({INIT:$,ZOOM_VERTICAL:tt,RENDERTHRESHOLDS:et,RENDERAREA:nt});function it(t,e,n){return{left:0===t?0:t+e/2*(1-n),right:t+e-(3-n)*e/6}}function ot(t,e,n,s){const{left:i,right:o}=it(t.renderOffset,t.renderWidth,s);if(e>=i&&e<=o&&t.renderWidth>0)return{renderOffset:t.renderOffset,renderWidth:t.renderWidth,leftThreshold:i,rightThreshold:o};const r=((e<=n?1:Math.round(e/n))-1)*n,a=3*n,l=it(r,a,s);return{renderOffset:r,renderWidth:a,leftThreshold:l.left,rightThreshold:l.right}}function rt(t,e){if(!t)return{verticalScale:106,width:0,pulsesPerPixel:12,renderOffset:0,renderWidth:0,devicePixelRatio:window.devicePixelRatio,leftThreshold:0,rightThreshold:0};switch(null==e?void 0:e.type){case"INIT":const n=e.data,s=ot(t,0,n.width,.8);return X(X(X({},t),n),s);case"RENDERAREA":const i=e.data;return z(X({},t),{renderOffset:i.renderOffset,renderWidth:i.renderWidth,pulsesPerPixel:i.pulsesPerPixel||t.pulsesPerPixel,leftThreshold:i.leftThreshold,rightThreshold:i.rightThreshold});case"RENDERTHRESHOLDS":const o=e.data;return z(X({},t),{leftThreshold:o.leftThreshold,rightThreshold:o.rightThreshold});case"ZOOM_VERTICAL":const r=e.data;return z(X({},t),{verticalScale:r.zoom*(Y-G)+G})}return t}var at=Object.defineProperty,lt=Object.getOwnPropertySymbols,ct=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,ut=(t,e,n)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;function pt(t,e,n,s){let i=Math.max(0,t-n),o=Math.min(t+e-n,s-n);o<=i&&([i,o]=[o,i]);const r=o-i;return{start:i,end:o,width:r,inView:s>=t&&n<=t+e,quantizedWidth:256*Math.ceil(r/256),transform:`translate(${i}px, 20px)`}}function dt(t,e,n,s,i=0){const o=t.fromPixels(1).toPulses(),r=t.fromFrames(3969e4).toPulses();if(0===e)return Math.max(i,Math.min(n,r));let a=t.fromQuarters(4).toPulses();if(!s&&e){s=1;for(let t=0;t<2&&a/(4*s)>o*e;++t)s*=4}a/=s||1;const l=Math.round(Math.round(n/a)*a);return lo*e?Math.min(Math.max(n,i),r):Math.min(l,r)}function mt(t,e,n,s,i,o){const r=t.fromFrames(3969e4,44100).toPulses(),a=t.fromQuarters(1/32).toPulses(),l=n.position+a;let c=r;const h=((t,e)=>{for(var n in e||(e={}))ct.call(e,n)&&ut(t,n,e[n]);if(lt)for(var n of lt(e))ht.call(e,n)&&ut(t,n,e[n]);return t})({},n.timing);let u=0,p=0;void 0!==h.pulsesContentPosition?(u=h.pulsesContentPosition,p=h.pulsesLength):(u=t.fromMilliseconds(h.millisecondsContentPosition).toPulses(),p=t.fromMilliseconds(h.millisecondsLength).toPulses()),i&&0!==i&&(c=n.position+u+i,c>r&&(c=r));let d=dt(t,e,n.position+p+s,o);d=dc?c:d;const m=d-n.position-p,f=Math.max(p+m,a);return void 0!==h.pulsesLength?h.pulsesLength=f:h.millisecondsLength=t.fromPulses(f).toMilliseconds(),h}var ft=(t=>(t[t.pointer=0]="pointer",t[t.scissors=1]="scissors",t[t.timeStretch=2]="timeStretch",t[t.pitchStretch=3]="pitchStretch",t))(ft||{}),gt=(t=>(t[t.StretchLeft=0]="StretchLeft",t[t.StretchRight=1]="StretchRight",t[t.LoopCount=2]="LoopCount",t[t.Move=3]="Move",t))(gt||{});const _t=n(1561);function vt(t){const[e,n]=Object(s.useState)(t.volumeNode.volume.value);return i.a.createElement("div",{className:_t.sliderWrapper},i.a.createElement("div",{className:_t.fieldName},Object(C.e)("Volume"),":"),i.a.createElement("div",{className:_t.volumeLable},Math.round(e),Object(C.e)("dB")),i.a.createElement("input",{className:_t.volumeSlider,onMouseDown:t=>{t.stopPropagation()},value:e,onChange:e=>{if(t.automationOverride)return;const s=Number(e.target.value);t.onVolumeChange(s)&&(n(s),t.volumeNode.volume.setValueAtTime(s,t.volumeNode.volume.toSeconds()))},min:-50,max:6,type:"range"}))}const bt=n(1562);function yt(t){const[e,n]=Object(s.useState)(t.channel.data.mute),[o,r]=Object(s.useState)(t.channel.data.solo),[a,l]=Object(s.useState)(!1),[c,h]=Object(s.useState)(!1),[u,p]=Object(s.useState)(1);function d(){e!==t.channel.data.mute&&n(t.channel.data.mute),o!==t.channel.data.solo&&r(t.channel.data.solo)}function m(){c&&h(!1)}Object(s.useEffect)(()=>(t.arrangement.addListener(g.b.channelMuteStateChange,d),document.addEventListener("click",m),function(){t.arrangement.removeListener(g.b.channelMuteStateChange,d),document.removeEventListener("click",m)}));const f="InstrumentChannel"===t.channel.type;return i.a.createElement("div",{className:bt.menu,style:{height:t.verticalScale+"px"},onContextMenu:e=>{t.openChannelContextMenu(e,t.channel.data.id),e.stopPropagation(),e.preventDefault()}},i.a.createElement("div",{className:bt.menuTop},f?i.a.createElement("div",{className:bt.modeBtns,onClick:()=>{t.keyboardBtnClick&&t.keyboardBtnClick()}},i.a.createElement("div",{className:[bt.tooltipWrapper,bt.modeBtnTooltip,bt.keyboard].join(" ")},i.a.createElement("button",{className:bt.keysButton},i.a.createElement("div",{className:bt.icon})))):i.a.createElement("div",{className:bt.modeBtns},i.a.createElement("div",{className:[bt.tooltipWrapper,bt.modeBtnTooltip,bt.waveform].join(" ")},i.a.createElement("div",{className:bt.icon}))),i.a.createElement("div",{className:bt.tooltipWrapper},i.a.createElement("div",{className:[bt.channelName,f?bt.instrumentChannel:bt.audioChannel].join(" ")},f?i.a.createElement("div",{className:bt.withDropDowm},i.a.createElement("button",{className:[bt.dropdownBtn,bt.active,bt.instrumentDropdownBtn].join(" "),onClick:e=>{t.instrumentBtnClick&&t.instrumentBtnClick(e)}},i.a.createElement("span",{style:{pointerEvents:"none"},className:bt.dropdownBtnLabel},t.channel.data.instrument.config.type!==g.d.Sampler?Object(C.e)(t.channel.data.instrument.name):t.channel.data.instrument.name),i.a.createElement("span",{style:{pointerEvents:"none"},className:bt.dropdownBtnIcon}))):i.a.createElement("span",{style:{pointerEvents:"none"},className:bt.dropdownBtnLabel},t.channel.data.name))),i.a.createElement("div",{className:bt.modeBtns},i.a.createElement("div",{className:[bt.tooltipWrapper,bt.modeBtnTooltip].join(" ")},i.a.createElement("button",{className:[bt.modeBtn,bt.solo,!0===o&&!1===e?bt.active:""].join(" "),onClick:()=>{t.arrangement.solo(t.channel.data.id,!o)}},i.a.createElement("div",{className:bt.icon}))),i.a.createElement("div",{className:[bt.tooltipWrapper,bt.modeBtnTooltip].join(" ")},i.a.createElement("button",{className:[bt.modeBtn,bt.mute,e?bt.active:""].join(" "),onClick:()=>{t.arrangement.mute(t.channel.data.id,!e)}},i.a.createElement("div",{className:bt.icon}))))),i.a.createElement("div",{className:bt.menuMiddle},i.a.createElement(vt,{automationOverride:t.channel.data.gainAutomation.length>1,onVolumeChange:e=>(t.channel.data.gainAutomation[0].value=e,t.onVolumeUpdate(),!0),volumeNode:t.volumeNode})),i.a.createElement("div",{className:bt.menuBottom},i.a.createElement("div",{className:[bt.tooltipWrapper].join(" ")},i.a.createElement("div",{className:[bt.effects,a?bt.showEffectList:""].join(" ")},i.a.createElement("button",{className:bt.effectsBtn,onClick:()=>{l(!a),a&&h(!1)}},t.channel.data.effects.length>0?`Effect (${t.channel.data.effects.length})`:"Effect"),a?function(){const e=[{name:"bitCrusher",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.BitCrusher)}},{name:"chebyshev",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.Chebyshev)}},{name:"filter",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.Filter)}},{name:"pingPongDelay",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.PingPongDelay)}},{name:"pitchShift",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.PitchShift)}},{name:"tremolo",fn:()=>{t.arrangement.addSpecialEffectToChannel(t.channel.data,g.f.Tremolo)}}];return i.a.createElement("ul",{className:bt.effectsList,onContextMenu:t=>{t.stopPropagation(),t.preventDefault()}},t.channel.data.effects.map((e,n)=>i.a.createElement("li",{className:bt.effectsItem,key:n},i.a.createElement("div",{className:bt.itemLable,onClick:()=>{t.arrangement.emit(g.b.openChannelEffectSetting,{channelId:t.channel.data.id,effectIdx:n})}},i.a.createElement("span",null,e.type)),i.a.createElement("button",{className:bt.deleteBtn,onClick:()=>{t.arrangement.removeSpecialEffectFromChannel(t.channel.data,n),p(u+1)}},"X"))),i.a.createElement("li",{className:bt.effectsAdd},i.a.createElement("button",{className:bt.addButton,onClick:()=>{h(!c)}},i.a.createElement("div",null,"+"),c?i.a.createElement("div",{className:bt.allEffectsDropdown},i.a.createElement("div",{className:bt.dropdown},i.a.createElement("div",{className:[bt.tooltipWrapper,bt.itemTooltip].join(" ")},i.a.createElement("div",{className:bt.item,style:{color:"#cfcfcf"}},"Done")),i.a.createElement("div",{className:[bt.item,bt.separator].join(" ")}),e.map((t,e)=>i.a.createElement("div",{key:e,className:[bt.tooltipWrapper,bt.itemTooltip].join(" ")},i.a.createElement("div",{className:bt.item,onClick:()=>{t.fn()}},t.name))))):null)))}():null)),i.a.createElement("div",{className:[bt.tooltipWrapper].join(" ")},i.a.createElement("button",{className:bt.automationBtn,onClick:()=>t.toggleAutomation()},Object(C.e)("Gain")))))}var wt=n(1384),xt=n.n(wt);const St=n(1563);class Ct extends s.Component{constructor(t){super(t),this.mainRef=s.createRef(),this.dragOperation=gt.StretchLeft,this.dragStartPulse=0,this.dragStartY=0,this.dragging=!1,this.dragStartLoopCount=1,this.allUpdate=()=>{this.setState({canvasUpdateCounter:this.state.canvasUpdateCounter+1}),this.forceUpdate()},this.updateColor=()=>{this.setState({color:this.props.region.color})},this.select=()=>{this.props.selected,this.props.setSelectedRegions([this.props.region.id])},this.handleMouseUp=t=>{this.dragging?t.stopPropagation():ft.scissors===this.props.tool||this.dragging||t.shiftKey||this.select()},this.onMouseDown=t=>{let e=t.nativeEvent.offsetX,n=t.nativeEvent.offsetY;const s=t.nativeEvent.target,{width:i,height:o,regionWidth:r}=this.getDimensions();s&&s.id==this.props.region.id+"-loop"&&(e+=r,n+=20),this.props.recording||(this.isCollapsed()?this.startMove(t):e>=r-10&&(e=o-10?(this.select(),this.startStretchRight(t)):e>=i-10&&n<=10?(this.select(),this.startLoopcountChange(t)):e<=10&&n>=o-10?(this.select(),this.startStretchLeft(t)):(this.select(),this.startMove(t))),t.preventDefault(),t.stopPropagation()},this.isCollapsed=()=>this.props.height<60,this.getActualCanvasHeight=()=>this.props.height-1-(this.isCollapsed()?0:20),this.updateScissorsPosition=t=>{ft.scissors===this.props.tool&&this.setState({pointerPosition:this.getScissorsPosition(t.clientX)||0})},this.getPulseByClientX=t=>{const e=this.props.pulsesPerPixel,n=this.props.region,s=this.mainRef.current;if(s){const i=t-s.getBoundingClientRect().left;return n.position+e*i}return 0},this.getScissorsPosition=t=>{const e=this.props.region;let n=this.getPulseByClientX(t);const s=this.getCalculator();n=dt(s,this.props.snapPixels,n,0);const i=s.fromQuarters(1/32).toPulses(),o=e.position+i,r=s.fromMilliseconds(e.timing.millisecondsLength).toPulses(),a=e.position+r-i,l=Math.max(Math.min(n,a),o);return l>=o&&l<=a?l:null},this.getPixelsByPulse=t=>{const{pulsesPerPixel:e,region:n}=this.props;return Math.round((t-n.position)/e)},this.bindMouseListeners=t=>{t.preventDefault(),document.addEventListener("mousemove",this.mouseMoveListener),document.addEventListener("mouseup",this.mouseUpListener)},this.correctY=t=>{const e=this.mainRef.current&&this.mainRef.current.parentElement;return t-(e?e.getBoundingClientRect().bottom:0)},this.mouseMoveListener=t=>{const e=this.dragStartPulse,n=this.getPulseByClientX(t.clientX);Math.abs(e-n)&&(this.dragging=!0),this.dragHandler(t.clientX,this.correctY(t.clientY),!0,t.shiftKey)},this.mouseUpListener=t=>{this.dragHandler(t.clientX,this.correctY(t.clientY),!1,t.shiftKey),document.removeEventListener("mousemove",this.mouseMoveListener),document.removeEventListener("mouseup",this.mouseUpListener),document.body.style.cursor="auto",this.dragging=!1,this.dragStartPulse=0,t.stopPropagation()},this.startStretchLeft=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.StretchLeft,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startStretchRight=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.StretchRight,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startLoopcountChange=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.LoopCount,this.dragStartLoopCount=this.props.region.loopCount,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startMove=t=>{if(2!==t.button){this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragStartY=this.correctY(t.clientY),this.dragOperation=gt.Move;const[e,n]=this.props.getChannelOrder(this.props.channel);this.channelOrder=e,this.totalChannel=n,this.bindMouseListeners(t)}else this.select()},this.onStretchLeft=(t,e)=>{this.props.regionsStretchLeft(t)},this.onStretchRight=(t,e)=>{this.props.regionsStretchRight(t)},this.onLoopCountChange=(t,e)=>{if(0!=t){const e=this.getCalculator().fromMilliseconds(this.props.region.timing.millisecondsLength).toPulses(),n=e*this.dragStartLoopCount+t;this.props.region.loopCount=Math.max(n/e,1),this.setState({canvasUpdateCounter:this.state.canvasUpdateCounter+1}),this.forceUpdate()}},this.onMove=(t,e,n)=>{e=Math.max(e,-this.channelOrder),e=Math.min(e,this.totalChannel-this.channelOrder-1);let s=!0;this.props.arrangement.channels[this.channelOrder+e].type!==this.props.channel.type&&(s=!1),n?(this.mainRef.current&&s&&(this.mainRef.current.style.top=e*this.props.height+"px"),(t||e)&&this.props.regionsMove(t,s?e:0,n)):(t||e)&&this.props.regionsMove(t,s?e:0,n)},this.dragHandler=(t,e,n,s)=>{const i=this.props.arrangement.audioMetaData[this.props.region.id].waveformKey;let o=null;this.props.arrangement.waveformCache[i]&&this.props.arrangement.waveformCache[i].data&&(o=this.props.arrangement.waveformCache[i].data);const r=this.dragOperation,a=this.dragStartPulse;let l=this.getPulseByClientX(t);const c=this.getCalculator().fromPulses(l-a).toPixels(),h=e-this.dragStartY,u=null!==o;s&>.Move===r&&(Math.abs(c)>Math.abs(h)||(l=a)),gt.StretchLeft===r&&u?this.onStretchLeft(l-a,n):gt.StretchRight===r&&u?this.onStretchRight(l-a,n):gt.LoopCount===r&&u?this.onLoopCountChange(l-a,n):h>=0?this.onMove(l-a,Math.floor(h/this.props.height),n):this.onMove(l-a,Math.ceil(h/this.props.height),n)},this.onClick=t=>{t.stopPropagation();const e=this.getCalculator().fromMilliseconds(this.props.region.timing.millisecondsLength).toPulses();if(ft.scissors===this.props.tool&&e){const e=this.getScissorsPosition(t.clientX);null!==e&&this.props.splitRegion(this.props.channel.data,this.props.region,e-this.props.region.position)}},this.state={pointerPosition:0,canvasUpdateCounter:0,color:this.props.region.color},this.getCalculator=()=>new w.a(this.props.pulsesPerPixel,this.props.arrangement.ctx.sampleRate,this.props.arrangement.ctx.transport.bpm.value),this.forceUpdate=this.forceUpdate.bind(this);const[e,n]=this.props.getChannelOrder(this.props.channel);this.channelOrder=e,this.totalChannel=n}componentDidMount(){this.props.arrangement.addListener(`${g.b.regionsMoveUpdate}-${this.props.region.id}`,this.forceUpdate),this.props.arrangement.addListener(`${g.b.regionsStretchUpdate}-${this.props.region.id}`,this.allUpdate),this.props.arrangement.addListener(`${g.b.regionsColorUpdate}-${this.props.region.id}`,this.updateColor),this.props.arrangement.addListener(g.b.waveformDataUpdate,this.allUpdate)}componentWillUnmount(){this.props.arrangement.removeListener(`${g.b.regionsMoveUpdate}-${this.props.region.id}`,this.forceUpdate),this.props.arrangement.removeListener(`${g.b.regionsStretchUpdate}-${this.props.region.id}`,this.allUpdate),this.props.arrangement.removeListener(`${g.b.regionsColorUpdate}-${this.props.region.id}`,this.updateColor),this.props.arrangement.removeListener(g.b.waveformDataUpdate,this.allUpdate)}getCSSPercentage(t,e){return 100*Math.round(1e7*t/e)/1e7+"%"}getDimensions(){const t=this.getCalculator(),e=t.fromMilliseconds(this.props.region.timing.millisecondsLength).toPulses();return{height:this.props.height,width:t.fromPulses(e*this.props.region.loopCount).toPixels(),regionWidth:t.fromPulses(e).toPixels(),regionLength:e,outerWidth:t.fromFrames(3969e4).toPixels()}}render(){const{height:t,width:e,regionWidth:n,regionLength:i,outerWidth:o}=this.getDimensions(),r=this.props.region.position/this.props.pulsesPerPixel,a=this.state.color,l=xt.a(a).lighten(30).toRgbString(),c=xt.a(a).lighten(25).toRgbString(),h=xt.a(a).lighten(-10).toRgbString(),u=xt.a(a).lighten(-5).toRgbString(),p=xt.a(a).lighten(15).toRgbString(),d=this.props.arrangement.audioMetaData[this.props.region.id].waveformKey,m=Number(d.split("|")[2]),f=Number(d.split("|")[4]);let _=null;this.props.arrangement.waveformCache[d]&&this.props.arrangement.waveformCache[d].data&&(_=this.props.arrangement.waveformCache[d].data);const v=this.props.arrangement.bufferCache[this.props.file.id];return s.createElement("div",{style:{background:this.props.selected?"#ffffff80":`radial-gradient(circle, ${l} 55%, ${c} 100%)`,height:t-1+"px",width:e<1?"1px":this.getCSSPercentage(e,o),color:this.props.selected?h:l,left:this.getCSSPercentage(r,o),bottom:t*this.props.verticalMove+"px"},ref:this.mainRef,onContextMenu:t=>{this.props.onContextMenu&&this.props.onContextMenu(t)},onMouseMove:t=>{this.props.tool===ft.scissors&&this.updateScissorsPosition(t)},onMouseDown:this.onMouseDown,onMouseUp:this.handleMouseUp,onClick:this.onClick,className:[St.region,this.props.selected?St.selected:"",this.props.region.loopCount>1?St.looped:"",this.props.recording?St.recording:""].join(" ")},s.createElement("div",{className:St.regionBar,id:this.props.region.id,style:{background:this.props.selected?p:`radial-gradient(circle, ${u} 55%, ${h} 100%)`}},s.createElement("i",{className:St.icon}),s.createElement("div",{className:St.title},this.props.file.name)),"AudioChannel"===this.props.channel.type&&null!==_?s.createElement(kt,{updateCounter:this.state.canvasUpdateCounter,waveformData:_,waveformStretchRate:m||1,waveformPulsesPerPixel:f||this.props.pulsesPerPixel,stretchRate:this.props.region.stretch,regionLength:i,height:this.props.height-20,pulsesPerPixel:this.props.pulsesPerPixel,regionStart:this.props.region.position/this.props.pulsesPerPixel,regionEnd:(this.props.region.position+i*this.props.region.loopCount)/this.props.pulsesPerPixel,contentPosition:this.getCalculator().fromMilliseconds(this.props.region.timing.millisecondsContentPosition).toPulses(),color:h,renderWidth:this.props.renderWidth,renderOffset:this.props.renderOffset}):v.status===g.c.ERROR?s.createElement("div",{className:St.missingFileError},s.createElement("div",null,Object(C.e)("Error")),s.createElement("div",null,Object(C.e)("FileMissing"))):v.status===g.c.PROGRESS?s.createElement("div",{className:St.downloadingFileWarning},s.createElement("div",null,Object(C.e)("Downloading"))):null,this.props.region.loopCount>1?s.createElement("div",{className:St.regionLoopPart,id:this.props.region.id+"-loop",style:{pointerEvents:"none",backgroundSize:this.getCSSPercentage(n,e-n),left:this.getCSSPercentage(n,e)}}):"",this.props.tool===ft.scissors?s.createElement("div",{className:St.scissorsPointer,style:{left:this.getPixelsByPulse(this.state.pointerPosition)+"px"}}):"")}}class kt extends s.Component{constructor(t){super(t),this.canvasRef=s.createRef()}drawWaveform(t){const e=this.canvasRef.current;if(e){const n=e.getContext("2d"),{renderOffset:s,renderWidth:i,regionStart:o,regionEnd:r}=t,a=pt(s,i,o,r);if(a.inView&&n){if(a.end<=a.start)return;e.style.transform=a.transform;let s=!1;e.width!==a.quantizedWidth&&(s=!0,e.style.width=a.quantizedWidth+"px",e.width=a.quantizedWidth),e.height!==t.height&&(s=!0,e.style.height=t.height+"px",e.height=t.height);const i=t.stretchRate/t.waveformStretchRate*(t.pulsesPerPixel/t.waveformPulsesPerPixel);s?(n.translate(.5,t.height/2),n.scale(.5/i,t.height/256),n.lineWidth=2):(n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,e.width,e.height),n.translate(.5,t.height/2),n.scale(.5/i,t.height/256));const o=i*t.regionLength/t.pulsesPerPixel,r=Math.round(i*t.contentPosition/t.pulsesPerPixel);n.strokeStyle=t.color,n.fillStyle=t.color;const l=a.start*i,c=a.end*i;n.beginPath();const h=i>=2?i>>0:1;for(let e=l;e>0);let i=2*(e-l),a=t.waveformData[s+1],u=t.waveformData[s];if(a>=-.5&&u<=.5){const s=i;for(;e>0);if(t.waveformData[n+1]<-.5||t.waveformData[n]>.5){e-=h;break}i=2*(e-l)}s===i?(n.moveTo(i,-.5),n.lineTo(i,.5)):(n.stroke(),n.lineWidth=1,n.beginPath(),n.moveTo(s-.5,0),n.lineTo(i+.5,0),n.stroke(),n.lineWidth=2,n.beginPath())}else a>-.5&&(a=-.5),u<.5&&(u=.5),n.moveTo(i,a),n.lineTo(i,u)}n.stroke()}}}componentDidMount(){this.drawWaveform(this.props)}UNSAFE_componentWillReceiveProps(t){return(this.props.updateCounter!==t.updateCounter||this.props.color!==t.color||t.renderOffset!==this.props.renderOffset||t.renderWidth!==this.props.renderWidth||t.regionStart!==this.props.regionStart||t.regionEnd!==this.props.regionEnd||t.regionLength!==this.props.regionLength)&&(this.drawWaveform(t),!0)}render(){return s.createElement("canvas",{style:{height:this.props.height+"px"},className:St.regionCanvas,ref:this.canvasRef})}}const Et=n(1564);class Pt extends s.Component{constructor(t){super(t),this.mainRef=s.createRef(),this.dragOperation=gt.StretchLeft,this.dragStartPulse=0,this.dragStartY=0,this.dragging=!1,this.dragStartLoopCount=1,this.allUpdate=()=>{this.setState({canvasUpdateCounter:this.state.canvasUpdateCounter+1}),this.forceUpdate()},this.canvasUpdate=()=>{this.setState({canvasUpdateCounter:this.state.canvasUpdateCounter+1})},this.updateColor=()=>{this.setState({color:this.props.region.color})},this.onDoubleClick=t=>{t.stopPropagation(),this.props.openNoteClipEditorWindow(this.props.region.id)},this.select=()=>{this.props.selected||this.props.setSelectedRegions([this.props.region.id])},this.handleMouseUp=t=>{this.dragging?t.stopPropagation():ft.scissors===this.props.tool||this.dragging||this.select()},this.onMouseDown=t=>{let e=t.nativeEvent.offsetX,n=t.nativeEvent.offsetY;const s=t.nativeEvent.target,{width:i,height:o,regionWidth:r}=this.getDimensions();s&&s.id==this.props.region.id+"-loop"&&(e+=r,n+=20),this.props.recording||(this.isCollapsed()?this.startMove(t):e>=r-10&&(e=o-10?(this.select(),this.startStretchRight(t)):e>=i-10&&n<=10?(this.select(),this.startLoopcountChange(t)):e<=10&&n>=o-10?(this.select(),this.startStretchLeft(t)):(this.select(),this.startMove(t))),t.preventDefault(),t.stopPropagation()},this.isCollapsed=()=>this.props.height<60,this.updateScissorsPosition=t=>{ft.scissors===this.props.tool&&this.setState({pointerPosition:this.getScissorsPosition(t.clientX)||0})},this.getPulseByClientX=t=>{const e=this.props.pulsesPerPixel,n=this.props.region,s=this.mainRef.current;if(s){const i=t-s.getBoundingClientRect().left;return n.position+e*i}return 0},this.getScissorsPosition=t=>{const e=this.props.region;let n=this.getPulseByClientX(t);const s=this.getCalculator();n=dt(s,this.props.snapPixels,n,0);const i=s.fromQuarters(1/32).toPulses(),o=e.position+i,r=e.timing.pulsesLength,a=e.position+r-i,l=Math.max(Math.min(n,a),o);return l>=o&&l<=a?l:null},this.getPixelsByPulse=t=>{const{pulsesPerPixel:e,region:n}=this.props;return Math.round((t-n.position)/e)},this.bindMouseListeners=t=>{t.preventDefault(),document.addEventListener("mousemove",this.mouseMoveListener),document.addEventListener("mouseup",this.mouseUpListener)},this.correctY=t=>{const e=this.mainRef.current&&this.mainRef.current.parentElement;return t-(e?e.getBoundingClientRect().bottom:0)},this.mouseMoveListener=t=>{const e=this.dragStartPulse,n=this.getPulseByClientX(t.clientX);Math.abs(e-n)&&(this.dragging=!0),this.dragHandler(t.clientX,this.correctY(t.clientY),!0,t.shiftKey)},this.mouseUpListener=t=>{this.dragHandler(t.clientX,this.correctY(t.clientY),!1,t.shiftKey),document.removeEventListener("mousemove",this.mouseMoveListener),document.removeEventListener("mouseup",this.mouseUpListener),document.body.style.cursor="auto",this.dragging=!1,this.dragStartPulse=0,t.stopPropagation()},this.startStretchLeft=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.StretchLeft,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startStretchRight=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.StretchRight,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startLoopcountChange=t=>{t.stopPropagation(),this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragOperation=gt.LoopCount,this.dragStartLoopCount=this.props.region.loopCount,document.body.style.cursor=getComputedStyle(t.currentTarget).cursor,this.bindMouseListeners(t)},this.startMove=t=>{if(2!==t.button){this.dragStartPulse=this.getPulseByClientX(t.clientX),this.dragStartY=this.correctY(t.clientY),this.dragOperation=gt.Move;const[e,n]=this.props.getChannelOrder(this.props.channel);this.channelOrder=e,this.totalChannel=n,this.bindMouseListeners(t)}else this.select()},this.onStretchLeft=(t,e)=>{this.props.regionsStretchLeft(t)},this.onStretchRight=(t,e)=>{this.props.regionsStretchRight(t)},this.onLoopCountChange=(t,e)=>{if(0!=t){const e=this.props.region.timing.pulsesLength,n=e*this.dragStartLoopCount+t;this.props.region.loopCount=Math.max(n/e,1),this.setState({canvasUpdateCounter:this.state.canvasUpdateCounter+1}),this.forceUpdate()}},this.onMove=(t,e,n)=>{e=Math.max(e,-this.channelOrder),e=Math.min(e,this.totalChannel-this.channelOrder-1);let s=!0;this.props.arrangement.channels[this.channelOrder+e].type!==this.props.channel.type&&(s=!1),n?(this.mainRef.current&&s&&(this.mainRef.current.style.top=e*this.props.height+"px"),(t||e)&&this.props.regionsMove(t,s?e:0,n)):(t||e)&&this.props.regionsMove(t,s?e:0,n)},this.dragHandler=(t,e,n,s)=>{const i=this.dragOperation,o=this.dragStartPulse;let r=this.getPulseByClientX(t);const a=this.getCalculator().fromPulses(r-o).toPixels(),l=e-this.dragStartY,c="N"===this.props.region.type;s&>.Move===i&&(Math.abs(a)>Math.abs(l)||(r=o)),gt.StretchLeft===i&&c?this.onStretchLeft(r-o,n):gt.StretchRight===i&&c?this.onStretchRight(r-o,n):gt.LoopCount===i&&c?this.onLoopCountChange(r-o,n):l>=0?this.onMove(r-o,Math.floor(l/this.props.height),n):this.onMove(r-o,Math.ceil(l/this.props.height),n)},this.onClick=t=>{t.stopPropagation();const e=this.props.region.timing.pulsesLength;if(ft.scissors===this.props.tool&&e){const e=this.getScissorsPosition(t.clientX);null!==e&&this.props.splitRegion(this.props.channel.data,this.props.region,e-this.props.region.position)}},this.state={pointerPosition:0,canvasUpdateCounter:0,color:this.props.region.color},this.getCalculator=()=>new w.a(this.props.pulsesPerPixel,this.props.arrangement.ctx.sampleRate,this.props.arrangement.ctx.transport.bpm.value),this.forceUpdate=this.forceUpdate.bind(this);const[e,n]=this.props.getChannelOrder(this.props.channel);this.channelOrder=e,this.totalChannel=n}componentDidMount(){this.props.arrangement.addListener(`${g.b.regionsMoveUpdate}-${this.props.region.id}`,this.forceUpdate),this.props.arrangement.addListener(`${g.b.regionsStretchUpdate}-${this.props.region.id}`,this.allUpdate),this.props.arrangement.addListener(g.b.regionsNoteUpdate+"-"+this.props.region.id,this.canvasUpdate),this.props.arrangement.addListener(`${g.b.regionsColorUpdate}-${this.props.region.id}`,this.updateColor)}componentWillUnmount(){this.props.arrangement.removeListener(`${g.b.regionsMoveUpdate}-${this.props.region.id}`,this.forceUpdate),this.props.arrangement.removeListener(`${g.b.regionsStretchUpdate}-${this.props.region.id}`,this.allUpdate),this.props.arrangement.removeListener(g.b.regionsNoteUpdate+"-"+this.props.region.id,this.canvasUpdate),this.props.arrangement.removeListener(`${g.b.regionsColorUpdate}-${this.props.region.id}`,this.updateColor)}getDimensions(){const t=this.getCalculator(),e=this.props.region.timing.pulsesLength;return{height:this.props.height,width:t.fromPulses(e*this.props.region.loopCount).toPixels(),regionWidth:t.fromPulses(e).toPixels(),regionLength:e,outerWidth:t.fromFrames(3969e4).toPixels()}}getCSSPercentage(t,e){return 100*Math.round(1e7*t/e)/1e7+"%"}render(){const{height:t,width:e,regionWidth:n,regionLength:i,outerWidth:o}=this.getDimensions(),r=this.props.region.position/this.props.pulsesPerPixel,a=this.state.color,l=xt.a(a).lighten(30).toRgbString(),c=xt.a(a).lighten(25).toRgbString(),h=xt.a(a).lighten(-10).toRgbString(),u=xt.a(a).lighten(-5).toRgbString(),p=xt.a(a).lighten(15).toRgbString();return s.createElement("div",{style:{background:this.props.selected?"#ffffff80":`radial-gradient(circle, ${l} 55%, ${c} 100%)`,height:t-1+"px",width:e<1?"1px":this.getCSSPercentage(e,o),color:this.props.selected?h:l,left:this.getCSSPercentage(r,o),bottom:t*this.props.verticalMove+"px"},ref:this.mainRef,onContextMenu:t=>{this.props.onContextMenu&&this.props.onContextMenu(t)},onMouseMove:t=>{this.props.tool===ft.scissors&&this.updateScissorsPosition(t)},onMouseDown:this.onMouseDown,onMouseUp:this.handleMouseUp,onClick:this.onClick,onDoubleClick:this.onDoubleClick,className:[Et.region,this.props.selected?Et.selected:"",this.props.region.loopCount>1?Et.looped:"",this.props.recording?Et.recording:""].join(" ")},s.createElement("div",{className:Et.regionBar,id:this.props.region.id,style:{background:this.props.selected?p:`radial-gradient(circle, ${u} 55%, ${h} 100%)`}},s.createElement("i",{className:Et.icon}),s.createElement("div",{className:Et.title},this.props.region.name)),"N"===this.props.region.type?s.createElement(Tt,{updateCounter:this.state.canvasUpdateCounter,arrangement:this.props.arrangement,region:this.props.region,regionLength:i,renderOffset:this.props.renderOffset,renderWidth:this.props.renderWidth,height:this.props.height-20,pulsesPerPixel:this.props.pulsesPerPixel,regionStart:this.props.region.position/this.props.pulsesPerPixel,regionEnd:(this.props.region.position+i*this.props.region.loopCount)/this.props.pulsesPerPixel,color:h,contentLength:i,contentPosition:this.props.region.timing.pulsesContentPosition}):"",this.props.region.loopCount>1?s.createElement("div",{className:Et.regionLoopPart,id:this.props.region.id+"-loop",style:{pointerEvents:"none",backgroundSize:this.getCSSPercentage(n,e-n),left:this.getCSSPercentage(n,e)}}):"",this.props.tool===ft.scissors?s.createElement("div",{className:Et.scissorsPointer,style:{left:this.getPixelsByPulse(this.state.pointerPosition)+"px"}}):"")}}class Tt extends s.Component{constructor(t){super(t),this.canvasRef=s.createRef()}componentDidMount(){this.drawNotes(this.props)}UNSAFE_componentWillReceiveProps(t){return(this.props.updateCounter!==t.updateCounter||this.props.color!==t.color||t.renderOffset!==this.props.renderOffset||t.renderWidth!==this.props.renderWidth||t.regionStart!==this.props.regionStart||t.regionEnd!==this.props.regionEnd)&&(this.drawNotes(t),!0)}drawNotes(t){const e=this.canvasRef.current;if(e){const n=e.getContext("2d"),{renderOffset:s,renderWidth:i,regionStart:o,regionEnd:r}=t,a=pt(s,i,o,r);if(a.inView&&n){if(a.end<=a.start)return;e.style.transform=a.transform,e.width!==a.quantizedWidth&&(e.style.width=a.quantizedWidth+"px",e.width=a.quantizedWidth),e.height!==t.height&&(e.style.height=t.height+"px",e.height=t.height),n.clearRect(0,0,e.width,e.height);let s=107,i=12;const o=12,r=[];for(let e=0;e=0&&n.positiont.contentPosition&&n.pitch>=12&&n.pitch<=107&&(r.push(n),n.pitch>i&&(i=n.pitch),n.pitch>0==i/o>>0?(s=o*Math.floor(s/o),i=s+o-1):(s=Math.max(0,s-Math.ceil((o-l)/2)),i=s+o-1)),n.strokeStyle=t.color;const c=t.height/(i-s+1),h=Math.max(1,c-.5),u=c/2;h!==n.lineWidth&&(n.lineWidth=h);const p=t.contentLength/t.pulsesPerPixel;n.beginPath();for(let e=Math.floor(a.start/p)*p;ee+4)break;{const e=t.verticalScale-Object(r.f)(s[o].value,-50,6,0,t.verticalScale);if(Math.abs(e-n)<4)return o}}}return!1}function v(e){const s=t.getCalculator();if(n){const i=e.clientX-n.left,o=e.clientY-n.top,l=s.fromPixels(i).toPulses(),c=t.channel.data.gainAutomation;if(a.current>0){let e,n;if(a.current!==c.length-1?(e=c[a.current-1].time,n=c[a.current+1].time):(e=c[a.current-1].time,n=s.fromFrames(3969e4).toPulses()),l>n||l(t.arrangement.addListener(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`,m),function(){t.arrangement.removeListener(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`,m)})),i.a.createElement("div",{className:Mt.channelAutomation,ref:e,onDoubleClick:t=>{t.stopPropagation()},onContextMenu:t=>{const e=t.currentTarget.getBoundingClientRect(),n=t.clientX-e.left,s=t.clientY-e.top,i=_(n,s);!1!==i&&i>0&&(a.current=i,u([n,s]),c(!0)),t.stopPropagation(),t.preventDefault()},onMouseDown:e=>{if(0!==e.button)return;const s=t.getCalculator(),i=e.currentTarget.getBoundingClientRect(),o=e.clientX-i.left,l=e.clientY-i.top,c=_(o,l);if(!1!==c)a.current=c,n=i,document.addEventListener("mousemove",v),document.addEventListener("mouseup",b);else{!function(e,n){const s=t.channel.data.gainAutomation;if(1===s.length){const i=y.g.alloc();return i.time=n,i.value=e,s.push(i),void t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`)}let i=0;for(;in);)i++;const o=y.g.alloc();o.time=n,o.value=e,s.splice(i,0,o),t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`)}(Object(r.f)(t.verticalScale-l,0,t.verticalScale,-50,6),s.fromPixels(o).toPulses())}e.stopPropagation()},onClick:()=>{l&&c(!1)},style:{height:t.verticalScale+"px",width:o+"px"}},i.a.createElement("svg",{style:{width:"100%",height:"100%"}},i.a.createElement("defs",null,i.a.createElement("marker",{id:"lineJoint",markerWidth:"4",markerHeight:"4",refX:"2",refY:"2"},i.a.createElement("rect",{width:"4",height:"4",fill:"orange"}))),i.a.createElement("path",{strokeWidth:"2",className:Mt.automationLine,style:{markerMid:"url(#lineJoint)"},d:p})),l?i.a.createElement("div",{className:Mt.contextMenuMask,onMouseDown:t=>{t.stopPropagation()},onClick:()=>{c(!1)}}):null,l?i.a.createElement("div",{className:Mt.automationContextMenu,style:{transform:`translate(${h[0]}px, ${h[1]}px)`}},i.a.createElement("div",{className:Mt.dropdown},i.a.createElement("div",{className:[Mt.itemTooltip,Mt.tooltipWrapper].join(" ")},i.a.createElement("div",{className:Mt.item,onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onClick:()=>{t.channel.data.gainAutomation.splice(a.current,1),a.current=-1,t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`),c(!1)}},Object(C.e)("DeletePoint"))),i.a.createElement("div",{className:[Mt.item,Mt.separator].join(" ")}),i.a.createElement("div",{className:[Mt.itemTooltip,Mt.tooltipWrapper].join(" ")},i.a.createElement("div",{className:Mt.item,onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onClick:()=>{t.channel.data.gainAutomation.splice(1),t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`),c(!1)}},Object(C.e)("DeleteAllPoints"))))):null)}const At=n(1566);function Ot(t){const e=[];for(let n=0;n(t.arrangement.addListener(`${g.b.channelUpdate}-${t.channel.data.id}`,h),function(){t.arrangement.removeListener(`${g.b.channelUpdate}-${t.channel.data.id}`,h)})),"InstrumentChannel"===t.channel.type?i.a.createElement("div",{key:t.channel.data.id,className:At.channelWrapper},i.a.createElement("div",{className:At.channel},i.a.createElement(yt,{arrangement:t.arrangement,volumeNode:t.arrangement.chanVolumeCtrl[t.channel.data.id],channel:t.channel,verticalScale:t.verticalScale,openChannelContextMenu:t.openChannelContextMenu,instrumentBtnClick:t.instrumentBtnClick,keyboardBtnClick:t.keyboardBtnClick,toggleAutomation:()=>{l(!a)},onVolumeUpdate:()=>{t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`)}}),i.a.createElement("div",{className:At.channelRegion,style:{height:t.verticalScale+"px",width:n+"px"},onMouseDown:()=>{0===c.current&&(c.current=1)},onMouseMove:()=>{1===c.current&&(c.current=0)},onMouseUp:e=>{1===c.current&&(c.current=0,t.deSelect(),e.stopPropagation())},onDoubleClick:n=>{const s=n.target.getBoundingClientRect(),i=n.clientX-s.left,o=t.arrangement.ctx.transport.timeSignature,r=t.arrangement.ctx.transport.PPQ*o,a=e.fromPulses(r).toPixels(),l=y.s.alloc();l.color=t.RegionColor.Ocean,l.id=Object(b.v4)(),l.loopCount=1,l.position=Math.floor(i/a)*r,l.timing.pulsesLength=r,t.arrangement.addRegion(t.channel.data,l)}},o.map(e=>{const n=t.arrangement.getRegionById(e);if(n){const e=t.selectedRegionsId.includes(n.id);return i.a.createElement(Pt,{key:n.id,onContextMenu:e=>{t.onRegionContextMenu(e,t.index)},arrangement:t.arrangement,channel:t.channel,tone:t.arrangement.tone,tool:t.currentTool,region:n,pulsesPerPixel:t.pulsesPerPixel,renderWidth:t.renderWidth,renderOffset:t.renderOffset,regionsStretchLeft:t.regionsStretchLeft,regionsStretchRight:t.regionsStretchRight,snapPixels:t.snapPixels,height:t.verticalScale,recording:!1,selected:e,setActiveSelection:()=>{},verticalMove:0,setRegions:t=>{},openNoteClipEditorWindow:e=>{t.openNoteClipEditorWindow&&t.openNoteClipEditorWindow(e)},regionsMove:(e,s,i)=>{if(t.regionsMove(e,1),!i&&0!==s){const e=t.index,i=t.index+s;t.arrangement.moveRegionToChannel(n.id,e,i)}},setSelectedRegions:t.setSelectedRegions,splitRegion:t.splitRegion,getChannelOrder:u})}return null}),a?i.a.createElement(Rt,{channel:t.channel,verticalScale:t.verticalScale,getCalculator:t.getCalculator,arrangement:t.arrangement}):null))):i.a.createElement("div",{key:t.channel.data.id,className:At.channelWrapper},i.a.createElement("div",{className:At.channel},i.a.createElement(yt,{arrangement:t.arrangement,volumeNode:t.arrangement.chanVolumeCtrl[t.channel.data.id],channel:t.channel,verticalScale:t.verticalScale,openChannelContextMenu:t.openChannelContextMenu,toggleAutomation:()=>{l(!a)},onVolumeUpdate:()=>{t.arrangement.emit(`${g.b.channelVolumeAutomationUpdate}-${t.channel.data.id}`)}}),i.a.createElement("div",{className:At.channelRegion,onMouseDown:()=>{0===c.current&&(c.current=1)},onMouseMove:()=>{1===c.current&&(c.current=0)},onMouseUp:e=>{1===c.current&&(c.current=0,t.deSelect(),e.stopPropagation())},style:{height:t.verticalScale+"px",width:n+"px"}},o.map(e=>{const n=t.arrangement.getRegionById(e);if(n){const e=t.arrangement.findAudioFileById(n.file),s=t.selectedRegionsId.includes(n.id);return i.a.createElement(Ct,{key:n.id,onContextMenu:e=>{t.onRegionContextMenu(e,t.index)},arrangement:t.arrangement,tone:t.arrangement.tone,channel:t.channel,region:n,tool:t.currentTool,pulsesPerPixel:t.pulsesPerPixel,file:e,renderOffset:t.renderOffset,renderWidth:t.renderWidth,regionsStretchLeft:t.regionsStretchLeft,regionsStretchRight:t.regionsStretchRight,snapPixels:t.snapPixels,waveformPulses:0,height:t.verticalScale,recording:!1,selected:s,verticalMove:0,regionsMove:(e,s,i)=>{if(t.regionsMove(e,1),!i&&0!==s){const e=t.index,i=t.index+s;t.arrangement.moveRegionToChannel(n.id,e,i)}},setSelectedRegions:t.setSelectedRegions,splitRegion:t.splitRegion,getChannelOrder:u})}return null}),a?i.a.createElement(Rt,{channel:t.channel,verticalScale:t.verticalScale,getCalculator:t.getCalculator,arrangement:t.arrangement}):null)))}const Dt=n(1567);class Bt extends s.Component{constructor(t){super(t),this._focusEnd=0,this._mouseDownPos=0,this.updateState=()=>{this.setState({startTime:this.props.arrangement.arrangeStartPos,endTime:this.props.arrangement.arrangeEndPos})},this.increaseCounter=()=>{this.setState({updateCounter:this.state.updateCounter+1})},this.onHandlerMouseMove=t=>{const e=this.props.getCalculator(),n=e.fromQuarters(.25).toPixels(),s=t.clientX-this._mouseDownPos;let i=e.fromPixels(s).toPulses();0===this._focusEnd?(i=dt(e,n,i+this.props.arrangement.arrangeStartPos,1),this.setState({startTime:Math.max(0,Math.min(i,this.state.endTime))})):(i=dt(e,n,i+this.props.arrangement.arrangeEndPos,1),this.setState({endTime:Math.max(this.state.startTime,Math.min(i,e.fromFrames(3969e4).toPulses()))}))},this.onHandlerTouchMove=t=>{},this.onHandlerMouseUp=()=>{this.props.arrangement.arrangeStartPos=this.state.startTime,this.props.arrangement.arrangeEndPos=this.state.endTime,document.removeEventListener("mousemove",this.onHandlerMouseMove),document.removeEventListener("mouseup",this.onHandlerMouseUp),document.removeEventListener("touchmove",this.onHandlerTouchMove),document.removeEventListener("touchend",this.onHandlerMouseUp)},this.bindHandlerMouseEvent=()=>{document.addEventListener("mousemove",this.onHandlerMouseMove),document.addEventListener("mouseup",this.onHandlerMouseUp),document.addEventListener("touchmove",this.onHandlerTouchMove),document.addEventListener("touchend",this.onHandlerMouseUp)},this.onLoopRegionMouseMove=t=>{const e=this.props.getCalculator(),n=e.fromQuarters(.25).toPixels(),s=t.clientX-this._mouseDownPos;let i=e.fromPixels(s).toPulses();i=dt(e,n,i+this.props.arrangement.arrangeStartPos,1);const o=Math.max(0,i);this.setState({startTime:o,endTime:Math.min(o+this._loopLen,e.fromFrames(3969e4).toPulses())})},this.onLoopRegionMouseUp=()=>{this.props.arrangement.arrangeStartPos=this.state.startTime,this.props.arrangement.arrangeEndPos=this.state.endTime,document.removeEventListener("mousemove",this.onLoopRegionMouseMove),document.removeEventListener("mouseup",this.onLoopRegionMouseUp)},this.bindLoopRegionMouseEvent=()=>{document.addEventListener("mousemove",this.onLoopRegionMouseMove),document.addEventListener("mouseup",this.onLoopRegionMouseUp)},this.state={startTime:this.props.arrangement.arrangeStartPos,endTime:this.props.arrangement.arrangeEndPos,updateCounter:0},this._loopLen=this.state.endTime-this.state.startTime}shouldComponentUpdate(t,e){return this.state.startTime!==e.startTime||this.state.endTime!==e.endTime||this.state.updateCounter!==e.updateCounter}componentDidMount(){this.props.arrangement.addListener(g.b.openPorject,this.updateState),this.props.arrangement.addListener(g.b.decreasePulsesPerPixel,this.increaseCounter),this.props.arrangement.addListener(g.b.increasePulsesPerPixel,this.increaseCounter)}componentWillUnmount(){this.props.arrangement.removeListener(g.b.openPorject,this.updateState)}render(){const t=this.props.getCalculator(),e=t.fromFrames(3969e4).toPixels(),n=t.fromQuarters(4).toPixels(),i=Math.floor(e/n),{startTime:o,endTime:r}=this.state;return s.createElement("div",{className:Dt.rulerWrapper,style:{width:t.fromFrames(3969e4).toPixels()+"px"},onClick:t=>{const e=t.currentTarget.getBoundingClientRect(),n=t.clientX-e.left,s=this.props.getCalculator().fromPixels(n).toSeconds();this.props.onSeekPosChange(s)}},s.createElement("div",{className:Dt.rulerNumbers},s.createElement(It,{pixelsPerBar:n,totalBarCount:i,getCalculator:this.props.getCalculator,onChange:(t,e)=>{this.setState({startTime:t,endTime:e})},onChangeFinished:()=>{this.props.arrangement.arrangeStartPos=this.state.startTime,this.props.arrangement.arrangeEndPos=this.state.endTime}}),s.createElement("div",{className:Dt.transportRegion,style:{left:t.fromPulses(o).toPixels()+"px",width:t.fromPulses(r-o).toPixels()+"px"},onMouseDown:t=>{this._mouseDownPos=t.clientX,this._loopLen=this.state.endTime-this.state.startTime,this.bindLoopRegionMouseEvent(),t.stopPropagation()}},s.createElement("div",{className:Dt.loopingHandleLeft,style:{left:"-6px"},onTouchStart:t=>{this._focusEnd=0,this._mouseDownPos=t.touches[0].clientX,this.bindHandlerMouseEvent(),t.stopPropagation()},onMouseDown:t=>{this._focusEnd=0,this._mouseDownPos=t.clientX,this.bindHandlerMouseEvent(),t.stopPropagation()}}),s.createElement("div",{className:Dt.loopingHandleRight,style:{right:"-6px"},onTouchStart:t=>{this._focusEnd=1,this._mouseDownPos=t.touches[0].clientX,this.bindHandlerMouseEvent(),t.stopPropagation()},onMouseDown:t=>{this._focusEnd=1,this._mouseDownPos=t.clientX,this.bindHandlerMouseEvent(),t.stopPropagation()}}))),s.createElement("div",{className:Dt.ruler}))}}class It extends s.Component{constructor(t){super(t),this._ref=s.createRef(),this.startX=0,this.computeLoopRegion=t=>{const e=this.props.getCalculator(),n=e.fromFrames(3969e4).toPulses(),s=this._ref.current;if(s){const i=s.getBoundingClientRect();return Math.min(e.fromPixels(t.clientX-i.left).toPulses(),n)-this.startX}return null},this.onLoopRegionMouseMove=t=>{const e=this.computeLoopRegion(t);if(e){const t=e>=0?this.startX:this.startX+e,n=Math.abs(e);this.props.onChange(t,t+n)}},this.onLoopRegionMouseUp=t=>{document.removeEventListener("mousemove",this.onLoopRegionMouseMove),document.removeEventListener("mouseup",this.onLoopRegionMouseUp)},this.bindBarNumberMouseEvent=()=>{document.addEventListener("mousemove",this.onLoopRegionMouseMove),document.addEventListener("mouseup",this.onLoopRegionMouseUp)}}shouldComponentUpdate(t){return t.pixelsPerBar!==this.props.pixelsPerBar||t.totalBarCount!==this.props.totalBarCount}render(){const t=[];for(let e=0;e{if(t.stopPropagation(),this._ref.current){const e=this._ref.current.getBoundingClientRect(),n=t.clientX-e.left,s=this.props.getCalculator().fromPixels(n).toPulses();this.startX=s,this.props.onChange(s,s+1),this.bindBarNumberMouseEvent()}}},t.map((t,e)=>s.createElement("div",{className:Dt.barNumber,key:e,style:{width:this.props.pixelsPerBar+"px"}},t)))}}var Ft=n(1568),Vt=n(1383);const jt=n(1578);class Lt extends s.Component{constructor(t){super(t),this.steps=[0,1,2,3,4,5]}shouldComponentUpdate(){return!0}componentDidMount(){}componentWillUnmount(){}render(){let t=this.steps[0];for(let e=0;ethis.props.onPulsePerPixelIncrease()}),s.createElement("div",{className:jt.sliderContainer},s.createElement("div",{className:jt.slider},s.createElement("input",{className:jt.sliderInput,type:"range",min:this.steps[0],max:this.steps[this.steps.length-1],value:t,onChange:e=>{const n=Number(e.target.value);if(n>t){let e=n-t;for(;e--;)this.props.onPulsePerPixelDecrease()}else if(nthis.props.onPulsePerPixelDecrease()}))))}}const qt=n(1579);class Ut extends s.Component{constructor(t){super(t),this.state={value:this.props.initValue,displayValue:String(this.props.initValue)},this._value=this.props.initValue}UNSAFE_componentWillReceiveProps(t){t.initValue!==this.props.initValue&&(this.setState({value:t.initValue,displayValue:void 0!==t.toFixed?t.initValue.toFixed(t.toFixed):String(t.initValue)}),this._value=t.initValue)}shouldComponentUpdate(t,e){return t.initValue!==this.props.initValue||t.maxValue!==this.props.maxValue||t.minValue!==this.props.minValue||(e.value!==this.state.value||e.displayValue!==this.state.displayValue)}updateState(){this.setState({value:this.props.initValue,displayValue:String(this.props.initValue)})}_checkValue(){const{minValue:t,maxValue:e}=this.props;let n=Number(this.state.displayValue);"number"==typeof n&&"NaN"!=n.toString()?(n=Math.floor(n),ne&&(n=e),this._value=n,this.setState({value:this._value,displayValue:void 0!==this.props.toFixed?this.state.value.toFixed(this.props.toFixed):this._value.toString()}),this.props.onChange(this._value)):void 0!==this.props.toFixed?this.setState({displayValue:this.state.value.toFixed(this.props.toFixed)}):this.setState({displayValue:this.state.value.toString()})}_onInputChange(t){this.setState({displayValue:t.target.value})}render(){return s.createElement("div",{className:qt.numberInput},s.createElement("div",{className:qt.inputWrap,style:this.props.style},s.createElement("input",{type:"text",value:this.state.displayValue,onBlur:t=>{this._checkValue()},onKeyPress:t=>{13==t.charCode&&this._checkValue()},onChange:t=>{this._onInputChange(t)}})))}}var Ht=Object.defineProperty,Wt=Object.defineProperties,Qt=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,Yt=(t,e,n)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Kt=(t,e)=>{for(var n in e||(e={}))zt.call(e,n)&&Yt(t,n,e[n]);if(Xt)for(var n of Xt(e))Gt.call(e,n)&&Yt(t,n,e[n]);return t},Zt=(t,e,n)=>new Promise((s,i)=>{var o=t=>{try{a(n.next(t))}catch(t){i(t)}},r=t=>{try{a(n.throw(t))}catch(t){i(t)}},a=t=>t.done?s(t.value):Promise.resolve(t.value).then(o,r);a((n=n.apply(t,e)).next())});const Jt=n(1580);const $t=["aui","wav","mp3","ogg","mid","flac","m4a","midi"];class te extends s.Component{constructor(t){super(t),this.focusedChannel=-1,this.registedUploadFile={},this.backupRegions=[],this.reqAnimatHandler=null,this.progressBarRef=s.createRef(),this.channelArea=s.createRef(),this.rectSelection=s.createRef(),this.appendSelectMode=!1,this.selectionRectStage=0,this._contextMenuChannelId="",this.selectionRectConfig={x:0,y:0,width:0,height:0},this.regionsStretchRight=t=>{const e=this.getCalculator(),n=e.fromQuarters(.25).toPixels();for(let s=0;s{const e=this.getCalculator(),n=e.fromQuarters(.25).toPixels();for(let s=0;s0){for(let t=0;t{const o=this.computeAdjustedTimingAndPos(t,e,n,s,0,i),r=o.timing,a=n.timing.pulsesLength/r.pulsesLength;r.pulsesContentPosition=n.timing.pulsesContentPosition/a;const l=t.fromQuarters(1/32).toPulses(),c=[];for(let t=0;t{const o=mt(t,e,n,s,void 0,i),r=n.timing.pulsesLength/o.pulsesLength;o.pulsesContentPosition=n.timing.pulsesContentPosition/r;const a=t.fromQuarters(1/32).toPulses(),l=[];for(let t=0;t{const r=mt(t,e,n,s,void 0,o),a=t.fromMilliseconds(n.timing.millisecondsLength).toPulses()/t.fromMilliseconds(r.millisecondsLength).toPulses(),l=n.stretch*a;return r.millisecondsContentPosition/=a,{stretchRate:l,stretchMode:i,timing:r}},this.regionsMove=(t,e)=>{const n=this.getCalculator(),s=n.fromQuarters(.25).toPixels(),i=this.backupRegions;for(let o=0;o{const s=this.getCalculator();this.props.arrangement.splitRegion(t,e,n,s)},this.getCalculator=()=>new w.a(this.state.pulsesPerPixel,this.props.arrangement.ctx.sampleRate,this.props.arrangement.ctx.transport.bpm.value),this.channelUpdate=()=>{this.setState({channelUpdate:this.state.channelUpdate+1})},this.onPulsesPerPixelDecrese=()=>{this.state.pulsesPerPixel/2>=K&&this.setState({pulsesPerPixel:this.state.pulsesPerPixel/2},()=>{this.props.arrangement.pulsesPerPixel=this.state.pulsesPerPixel})},this.onPulsesPerPixelIncrese=()=>{2*this.state.pulsesPerPixel<=Z&&this.setState({pulsesPerPixel:2*this.state.pulsesPerPixel},()=>{this.props.arrangement.pulsesPerPixel=this.state.pulsesPerPixel})},this.onKeyBoardRecordStop=()=>{this.setState({recording:!1})},this.onBPMChanged=()=>{this.setState({bpm:this.props.arrangement.ctx.transport.bpm.value}),this.updateWaveformData()},this.onKeyDown=t=>{"Shift"===t.key&&(this.appendSelectMode=!0)},this.onKeyUp=t=>{this.appendSelectMode=!1},this.openNoteClipEditorWindow=t=>{const e=this.props.arrangement.channels;for(let n=0;nt.includes(".")?(t.split(".").pop()||"").toLowerCase():null,this.selectRectMouseMoveListener=t=>{const e=this.computeSelectionRect(t);if(this.rectSelection.current&&this.channelArea.current){const t=this.getCalculator().fromPulses(e.width>=0?e.x:e.x+e.width).toPixels()+"px",n=(e.height>=0?e.y:e.y+e.height)+"px",s=this.getCalculator().fromPulses(Math.abs(e.width)).toPixels()+"px",i=Math.abs(e.height)+"px";this.rectSelection.current.style.left=t,this.rectSelection.current.style.top=n,this.rectSelection.current.style.width=s,this.rectSelection.current.style.height=i}this.selectionRectConfig=e,this.selectionRectStage=2},this.selectRectMouseUpListener=t=>{if(this.state.showSelectionRect&&2===this.selectionRectStage){const t=[],e=this.selectionRectConfig;let n=e.y,s=e.y+e.height;e.height<0&&(n=e.y+e.height,s=e.y);const i=Math.floor(n/this.state.verticalScale),o=Math.ceil(s/this.state.verticalScale),r=this.getCalculator().fromPixels(this.state.channelMenuWith).toPulses();let a=e.x-r,l=e.x+e.width-r;a>l&&([a,l]=[l,a]);const c=this.props.arrangement.channels;for(let e=i;e=a&&t.push(s.id)}else{const s=c[e].data.regions[n],i=s.loopCount*s.timing.pulsesLength;s.position<=l&&s.position+i>=a&&t.push(s.id)}this.setState({selectedRegionsId:t,showSelectionRect:!1},()=>{this.backupSelectedRegions()}),this.selectionRectConfig={x:0,y:0,width:0,height:0},this.rectSelection.current&&(this.rectSelection.current.style.left="0",this.rectSelection.current.style.top="0",this.rectSelection.current.style.width="0",this.rectSelection.current.style.height="0")}else this.setState({selectedRegionsId:[]},()=>this.backupRegions=[]);this.selectionRectStage=0,document.removeEventListener("mousemove",this.selectRectMouseMoveListener),document.removeEventListener("mouseup",this.selectRectMouseUpListener),t.stopPropagation(),t.preventDefault()},this.onRegionContextMenu=(t,e)=>{t.target&&(this.setState({showDropdownWrapper:3,dropDownPosition:[t.clientX,t.clientY]}),this.focusedChannel=e),t.preventDefault(),t.stopPropagation()},this.setSelectedRegions=t=>{if(this.appendSelectMode){const e=[...this.state.selectedRegionsId];for(let n=0;nthis.backupSelectedRegions())}else this.setState({selectedRegionsId:[...t]},()=>this.backupSelectedRegions())},this.channelInstrumentBtnClick=(t,e)=>{if(t.target){const n=t.target.getBoundingClientRect();this.setState({showDropdownWrapper:1,dropDownPosition:[n.left,n.top]}),this.focusedChannel=e}},this.renderChannels=()=>{const t=this.getCalculator().fromQuarters(.25).toPixels(),e=[];for(let n=this.props.arrangement.channels.length-1;n>=0;n--){const i=this.props.arrangement.channels[n];e.push(s.createElement(Nt,{key:i.data.id,arrangement:this.props.arrangement,channel:i,index:n,verticalScale:this.state.verticalScale,currentTool:this.state.currentTool,pulsesPerPixel:this.state.pulsesPerPixel,selectedRegionsId:this.state.selectedRegionsId,renderOffset:this.state.renderOffset,renderWidth:this.state.renderWidth,snapPixels:t,RegionColor:y.x,getCalculator:this.getCalculator,deSelect:()=>{this.appendSelectMode||this.setState({selectedRegionsId:[]},()=>this.backupRegions=[])},onRegionContextMenu:this.onRegionContextMenu,regionsMove:this.regionsMove,setSelectedRegions:this.setSelectedRegions,splitRegion:this.splitRegion,regionsStretchLeft:this.regionsStretchLeft,regionsStretchRight:this.regionsStretchRight,instrumentBtnClick:"AudioChannel"===i.type?void 0:t=>this.channelInstrumentBtnClick(t,n),keyboardBtnClick:"AudioChannel"===i.type?void 0:()=>{this.state.recording||this.props.openKeyborad(i.data)},openNoteClipEditorWindow:"AudioChannel"===i.type?void 0:this.openNoteClipEditorWindow,openChannelContextMenu:(t,e)=>{t.target&&(this.setState({showDropdownWrapper:4,dropDownPosition:[t.clientX,t.clientY]}),this._contextMenuChannelId=e)}}))}return e},this.changeSelectedRegionColor=t=>{for(let e=0;ec)&&(u=t)}const p=u-n.position,d=Math.max(a-p,r);return void 0!==h.pulsesLength?(h.pulsesLength=d,h.pulsesContentPosition=l-p):(h.millisecondsLength=t.fromPulses(d).toMilliseconds(),h.millisecondsContentPosition=t.fromPulses(l-p).toMilliseconds()),{position:u,timing:h}}audioRegionStretchLeft(t,e,n,s,i,o){const r=this.computeAdjustedTimingAndPos(t,e,n,s,0,o),{timing:a,position:l}=r,c=t.fromMilliseconds(n.timing.millisecondsLength).toPulses()/t.fromMilliseconds(a.millisecondsLength).toPulses(),h=n.stretch*c;return a.millisecondsContentPosition=n.timing.millisecondsContentPosition/c,{position:l,stretchRate:h,stretchMode:i,timing:a}}computeShiftedPos(t,e,n,s,i,o){const r=this.getCalculator().fromFrames(3969e4).toPulses();let a=e[0];for(let t=0;te[t].position&&(a=e[t]);const l=a?a.position:s.position,c=Math.max(s.position-l,0),h=r-this.getPulseFromTiming(s.timing,t),u=dt(t,n,l+i,o),p=s.position+(u-l);return ph?{position:h}:{position:p}}getPulseFromTiming(t,e){return void 0!==t.pulsesLength?t.pulsesLength:e.fromMilliseconds(t.millisecondsLength).toPulses()}componentDidMount(){this.props.arrangement.addListener(g.b.channelUpdate,this.channelUpdate),this.props.arrangement.addListener(g.b.decreasePulsesPerPixel,this.onPulsesPerPixelDecrese),this.props.arrangement.addListener(g.b.increasePulsesPerPixel,this.onPulsesPerPixelIncrese),this.props.arrangement.addListener(g.b.keyBoardRecordStopped,this.onKeyBoardRecordStop),this.props.arrangement.addListener(g.b.projectBPMChanged,this.onBPMChanged),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp)}componentWillUnmount(){this.props.arrangement.removeListener(g.b.channelUpdate,this.channelUpdate),this.props.arrangement.removeListener(g.b.decreasePulsesPerPixel,this.onPulsesPerPixelDecrese),this.props.arrangement.removeListener(g.b.increasePulsesPerPixel,this.onPulsesPerPixelIncrese),this.props.arrangement.removeListener(g.b.keyBoardRecordStopped,this.onKeyBoardRecordStop),this.props.arrangement.removeListener(g.b.projectBPMChanged,this.onBPMChanged),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp)}updateWaveformData(){var t;const e=this.getCalculator(),n=Object.keys(this.props.arrangement.waveformCache);for(let s=0;s0){const i=e.tracks[t].notes,o=y.r.alloc(),r=y.s.alloc();r.color=y.x.Ocean,r.id=Object(b.v4)(),r.loopCount=1,r.position=0,r.timing.pulsesLength=s.fromQuarters(e.tracks[t].durationTicks/n).toPulses(),o.push(r);for(let t=0;tt.position-e.position);const a=e.tracks[t].instrument.number,l=e.tracks[t].instrument.percussion;this.props.arrangement.addInstrumentChannel(e.tracks[t].name||"instrument",o,{instrumentType:g.d.GeneralMidiSynth,data:{Percussion:l,programId:a}})}}else{const n=F.update(t).hex();let s;if(void 0===this.registedUploadFile[n]){s=y.c.alloc(),s.name=e.name,s.id=n,s.userFile=0,s.size=t.byteLength,this.registedUploadFile[n]={uploaded:!1,buffer:t,name:e.name,id:n};const i=this.props.arrangement.getAudioFileInfo(s.id),o=yield this.props.arrangement.decodeAudioData(t.slice(0));i.audioBuffer=o,i.status=g.c.DONE,this.props.arrangement.audioFiles.push(s),this.props.arrangement.addToUploadPendingList(e.name,t,n),this.props.arrangement.emit(g.b.audioFileUpdate)}this.audioFileToAudioRegion(n)}}catch(t){console.error(t)}}}))}updateProgressBar(){const t=this.props.arrangement.ctx.transport.seconds,e=this.getCalculator().fromMilliseconds(1e3*t).toPixels();this.progressBarRef&&this.progressBarRef.current&&(this.progressBarRef.current.style.transform=`translateX(${e}px)`),this.reqAnimatHandler=window.requestAnimationFrame(this.updateProgressBar)}computeSelectionRect(t){const e=this.selectionRectConfig,n=this.getCalculator().fromFrames(3969e4).toPulses(),s=this.channelArea.current;if(s&&e){const r=s.scrollHeight,a=s.getBoundingClientRect();return i=Kt({},e),o={width:Math.min(this.getCalculator().fromPixels(t.clientX-a.left).toPulses(),n)-e.x,height:Math.min(t.clientY-a.top,r)-e.y},Wt(i,Qt(o))}var i,o;return e}bindRectSelectionMouseEvent(){document.addEventListener("mousemove",this.selectRectMouseMoveListener),document.addEventListener("mouseup",this.selectRectMouseUpListener)}renderArrangementContextMenu(){let t;return s.createElement("div",{style:{transform:`translate(${this.state.dropDownPosition[0]}px, ${this.state.dropDownPosition[1]}px)`},className:[Jt.dropdownWrapper,2===this.state.showDropdownWrapper?Jt.open:""].join(" ")},s.createElement("div",{className:Jt.dropdown},s.createElement("div",{className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:()=>{t.accept=".mp3,.m4a,.wav,.ogg,.opus",t.click()}},Object(C.e)("ImportAudioFile"))),s.createElement("div",{className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:()=>{t.accept=".midi,.mid",t.click()}},Object(C.e)("ImportMidiFile")))),s.createElement("input",{type:"file",style:{width:0,height:0,display:"none"},ref:e=>{t=e},onChange:e=>{this.handleAudioFileImport(t.files).catch(t=>console.error(t)),this.setState({showDropdownWrapper:0})}}))}renderRegionMenu(){const t=[];for(const e in y.x)t.push({label:e,value:y.x[e]});return s.createElement("div",{style:{transform:`translate(${this.state.dropDownPosition[0]}px, ${this.state.dropDownPosition[1]}px)`},className:[Jt.dropdownWrapper,3===this.state.showDropdownWrapper?Jt.open:""].join(" ")},s.createElement("div",{className:Jt.dropdown},t.map((t,e)=>s.createElement("div",{key:e,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:()=>{this.changeSelectedRegionColor(t.value),this.setState({showDropdownWrapper:0})}},s.createElement("span",{className:Jt.checkContainer},s.createElement("i",{style:{background:t.value,width:"13px",height:"13px",display:"block"}})),t.label))),s.createElement("div",{className:[Jt.item,Jt.separator].join(" ")}),s.createElement("div",{className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:()=>{this.props.arrangement.deleteRegionByIds(this.state.selectedRegionsId),this.setState({selectedRegionsId:[],showDropdownWrapper:0},()=>{this.backupRegions=[]})}},Object(C.e)("Delete"))),s.createElement("div",{className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:()=>{this.props.arrangement.copyRegionByIds(this.state.selectedRegionsId),this.setState({selectedRegionsId:[],showDropdownWrapper:0},()=>{this.backupRegions=[]})}},Object(C.e)("Copy")))))}renderSelectInstrumentMenu(){const t=(t,e)=>{this.props.arrangement.setChannelInstrument(this.props.arrangement.channels[this.focusedChannel].data,t,e),this.setState({showDropdownWrapper:0})},e=[{value:"",label:Object(C.e)("InstrumentSetting"),fn:()=>{this.props.openInstrumentSettingPanel(this.props.arrangement.channels[this.focusedChannel].data),this.setState({showDropdownWrapper:0})}},null],n=["Piano","ChromaticPerc","Organ","Guitar","Bass","Strings","Ensamble","Brass","Reed","Pipe","SynthLead","SynthPad","FX","Ethnic","Percussive","SE"];for(const s in g.d){const i={value:g.d[s],label:Object(C.e)(s),fn:()=>{t(g.d[s])}};if(g.d[s]===g.d.GeneralMidiSynth){i.child=[],i.fn=()=>{};const e={percussion:!0,label:Object(C.e)("Percussion"),fn:()=>{t(g.d[s],{Percussion:!0,programId:0})}};i.child.push(e),i.child.push(null);for(let e=0;e{t(g.d[s],{Percussion:!1,programId:n})}});i.child.push(o)}}e.push(i)}const i=this.props.arrangement.channels[this.focusedChannel].data;let o=this.state.dropDownPosition[1];o+230+15>window.innerHeight&&(o=window.innerHeight-230-15);const r=o+230+434-32;let a=-10;r>window.innerHeight&&(a=window.innerHeight-r-10);let l=-10;return(-10!==a||r+a+204-32>window.innerHeight)&&(l=-171),s.createElement("div",{style:{transform:`translate(${this.state.dropDownPosition[0]}px, ${o}px)`},className:[Jt.dropdownWrapper,1===this.state.showDropdownWrapper?Jt.open:""].join(" ")},s.createElement("div",{className:Jt.dropdown},e.map((t,e)=>{if(null!==t){if(t.child&&0!==t.child.length){if(t.value===g.d.GeneralMidiSynth){let n=!1;return i.instrument.config.type===t.value&&(n=!0),s.createElement("div",{key:e,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:[Jt.item,Jt.menuLV1].join(" ")},s.createElement("span",{className:Jt.checkContainer},n?s.createElement("i",{className:Jt.checkIcon}):null),t.label,s.createElement("div",{className:Jt.childHinter}),s.createElement("div",{className:Jt.menuLV1Child,style:{top:a+"px"}},t.child.map((e,o)=>{if(null!==e){if(e.percussion)return s.createElement("div",{key:"1-"+o,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:e.fn},s.createElement("span",{className:Jt.checkContainer},1==n&&!0===i.instrument.config.data.isPercussion?s.createElement("i",{className:Jt.checkIcon}):null),e.label));{const r=i.instrument.config.data;return s.createElement("div",{key:"1-"+o,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:[Jt.item,Jt.menuLV2].join(" ")},s.createElement("span",{className:Jt.checkContainer},1==n&&!1===r.isPercussion&&r.programId>=e.range[0]&&r.programId<=e.range[1]?s.createElement("i",{className:Jt.checkIcon}):null),e.label,s.createElement("div",{className:Jt.childHinter}),s.createElement("div",{className:Jt.menuLV2Child,style:{top:(o>t.child.length/2?l:-10)+"px"}},e.child.map((t,e)=>s.createElement("div",{key:"2-"+e,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:[Jt.item].join(" "),onClick:t.fn},s.createElement("span",{className:Jt.checkContainer},1==n&&!1===r.isPercussion&&r.programId==t.value?s.createElement("i",{className:Jt.checkIcon}):null),t.label))))))}}return s.createElement("div",{key:"1-"+o,className:[Jt.item,Jt.separator].join(" ")})}))))}return s.createElement("div",null)}return s.createElement("div",{key:e,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:t.fn},s.createElement("span",{className:Jt.checkContainer},i.instrument.config.type===t.value?s.createElement("i",{className:Jt.checkIcon}):null),t.label))}return s.createElement("div",{key:e,className:[Jt.item,Jt.separator].join(" ")})})))}renderChannelMenu(){const t=[{label:Object(C.e)("Delete"),fn:()=>{""!==this._contextMenuChannelId&&(this.props.arrangement.deleteChannelById(this._contextMenuChannelId),this.setState({showDropdownWrapper:0}),this._contextMenuChannelId="")}}];return s.createElement("div",{style:{transform:`translate(${this.state.dropDownPosition[0]}px, ${this.state.dropDownPosition[1]}px)`},className:[Jt.dropdownWrapper,4===this.state.showDropdownWrapper?Jt.open:""].join(" ")},s.createElement("div",{className:Jt.dropdown},t.map((t,e)=>null!==t?s.createElement("div",{key:e,className:[Jt.tooltipWrapper,Jt.itemTooltip].join(" ")},s.createElement("div",{className:Jt.item,onClick:t.fn},s.createElement("span",{className:Jt.checkContainer}),t.label)):s.createElement("div",{key:e,className:[Jt.item,Jt.separator].join(" ")}))))}renderSelectionRect(){return s.createElement("div",{className:Jt.selectionRect,ref:this.rectSelection})}handleAreaScroll(t){const e={width:this.state.width,pulsesPerPixel:this.state.pulsesPerPixel,renderOffset:this.state.renderOffset,renderWidth:this.state.renderWidth},n=ot(e,t,e.width,.8);n.renderOffset===e.renderOffset&&n.renderWidth===e.renderWidth&&this.setState({leftThreshold:n.leftThreshold,rightThreshold:n.rightThreshold});const s=this.getCalculator().fromFrames(3969e4).toPixels();n.renderOffset<=s&&(n.renderOffset+n.renderWidth>s&&(n.renderOffset=s-n.renderWidth),this.setState({renderWidth:n.renderWidth,renderOffset:n.renderOffset,leftThreshold:n.leftThreshold,rightThreshold:n.rightThreshold}))}render(){const t=this.props.arrangement.ctx.transport.timeSignature,e=this.props.arrangement.ctx.transport.PPQ*t,n=this.getCalculator().fromPulses(e).toPixels(),i=this.getCalculator().fromQuarters(.25).toPixels(),o=this.state.verticalScale;return s.createElement("div",{style:{width:"100%",height:"100%"}},s.createElement("div",null,s.createElement("div",{className:Jt.arrangementToolBar},s.createElement("div",{className:Jt.ToolBarItem},s.createElement("div",{className:Jt.toolsSelect},s.createElement("button",{className:[Jt.item,Jt.Pointer,this.state.currentTool===ft.pointer?Jt.actived:""].join(" "),onClick:()=>{this.setState({currentTool:ft.pointer})}},s.createElement("div",{className:Jt.icon})),s.createElement("button",{className:[Jt.item,Jt.Scissor,this.state.currentTool===ft.scissors?Jt.actived:""].join(" "),onClick:()=>{this.setState({currentTool:ft.scissors})}},s.createElement("div",{className:Jt.icon})),s.createElement("button",{className:[Jt.item,Jt.Stretch,this.state.currentTool===ft.pitchStretch?Jt.actived:""].join(" "),onClick:()=>{this.setState({currentTool:ft.pitchStretch})}},s.createElement("div",{className:Jt.icon})))),s.createElement("div",{className:Jt.ToolBarItem},s.createElement("div",{className:Jt.TransportBar},s.createElement("div",{className:Jt.tooltipWrapper},s.createElement("div",{className:[Jt.TransportBtn,Jt.Rewind].join(" "),onClick:()=>{this.props.arrangement.transportSeekToPos=0,this.props.arrangement.stop(),this.setState({playing:"started"===this.props.arrangement.ctx.transport.state}),this.updateProgressBar()}},s.createElement("div",{className:Jt.icon}))),s.createElement("div",{className:Jt.tooltipWrapper},s.createElement("div",{className:[Jt.TransportBtn,this.state.playing?Jt.Pause:Jt.Play].join(" "),onClick:()=>{if(this.state.playing){const t=this.props.arrangement.ctx.transport.seconds;this.props.arrangement.stop(),this.props.arrangement.transportSeekToPos=t,this.updateProgressBar(),this.setState({playing:"started"===this.props.arrangement.ctx.transport.state}),null!==this.reqAnimatHandler&&window.cancelAnimationFrame(this.reqAnimatHandler)}else this.props.arrangement.ctx.resume().then(()=>{this.props.arrangement.play(),this.setState({playing:"started"===this.props.arrangement.ctx.transport.state}),this.updateProgressBar()}).catch(t=>{console.error(t)})}},s.createElement("div",{className:Jt.icon}))),s.createElement("div",{className:Jt.tooltipWrapper},this.props.pianoKeyboardOpen?s.createElement("div",{className:[Jt.TransportBtn,this.state.recording?Jt.StopRecord:Jt.StartRecord].join(" "),onClick:()=>Zt(this,null,(function*(){if(this.state.recording)this.props.arrangement.emit(g.b.stopKeyBoardRecord);else{try{this.props.arrangement.emit(g.b.startKeyBoardRecord)}catch(t){return void console.error(t)}this.setState({recording:!0})}}))},s.createElement("div",{className:Jt.icon}),s.createElement("div",{className:Jt.Keyboard})):s.createElement("div",{className:[Jt.TransportBtn,this.state.recording?Jt.StopRecord:Jt.StartRecord].join(" "),onClick:()=>Zt(this,null,(function*(){if(this.state.recording){const t=yield this.props.arrangement.stopMicRecording();this.setState({recording:!1});const e=F.update(t).hex(),n=y.c.alloc();n.name=Object(C.e)("RecordingAudio"),n.id=e,n.userFile=1,n.size=t.byteLength,this.registedUploadFile[e]={uploaded:!1,buffer:new ArrayBuffer(0),name:n.name,id:e},this.props.arrangement.addToUploadPendingList(n.name,t,e);const s=yield this.props.arrangement.decodeAudioData(t),i=this.props.arrangement.getAudioFileInfo(n.id);i.audioBuffer=s,i.status=g.c.DONE,this.props.arrangement.audioFiles.push(n),this.audioFileToAudioRegion(e)}else{try{this.props.arrangement.startMicRecording()}catch(t){return void console.error(t)}this.setState({recording:!0})}}))},s.createElement("div",{className:Jt.icon}),s.createElement("div",{className:Jt.Mic}))),s.createElement("div",{className:[Jt.tooltipWrapper,Jt.bpmWrapper].join(" ")},s.createElement("span",{className:Jt.bpmLabel},"bpm:"),s.createElement(Ut,{initValue:this.state.bpm,maxValue:200,minValue:20,toFixed:0,onChange:t=>{const e=Math.round(t);e&&e<=200&&e>=20&&(this.props.arrangement.ctx.transport.bpm.value=e,this.setState({bpm:this.props.arrangement.ctx.transport.bpm.value},()=>{this.updateWaveformData()}))}})))))),s.createElement("div",{className:Jt.arrangementView},s.createElement("div",null,s.createElement("div",{className:Jt.addChannel},s.createElement("div",{className:[Jt.toggle,Jt.tooltipWrapper].join(" ")},s.createElement("button",{style:{outline:"none"},className:[Jt.toggle].join(" "),onClick:()=>{this.setState({showAddChannelDropUp:!this.state.showAddChannelDropUp})}},s.createElement("span",{className:Jt.toogleLabel},Object(C.e)("AddChannel")))),s.createElement("ul",{className:[Jt.addChannelDropUp,this.state.showAddChannelDropUp?Jt.open:""].join(" ")},s.createElement("div",{className:Jt.tooltipWrapper},s.createElement("li",{className:[Jt.dropupItem,Jt.addAudioChannelBtn].join(" "),onClick:()=>{this.props.arrangement.addAudioChannel(),this.setState({showAddChannelDropUp:!1})}},s.createElement("i",{className:Jt.icon}),s.createElement("span",{className:Jt.label},Object(C.e)("AudioChannel")))),s.createElement("div",{className:Jt.tooltipWrapper},s.createElement("li",{className:[Jt.dropupItem,Jt.addInstrumentChannelBtn].join(" "),onClick:()=>{this.props.arrangement.addInstrumentChannel("instrument",y.r.alloc()),this.setState({showAddChannelDropUp:!1})}},s.createElement("i",{className:Jt.icon}),s.createElement("span",{className:Jt.label},Object(C.e)("InstrumentChannel")))))),s.createElement("div",{className:Jt.menuPaddingStuff,style:{width:this.state.channelMenuWith+"px"}})),s.createElement("div",{className:Jt.arrangementContainer},s.createElement("div",{style:{width:"100%",paddingBottom:"24px",paddingRight:this.props.rightPanelOpen?"310px":"30px"}},s.createElement("div",{className:Jt.arrangementWrapper,onContextMenu:t=>{this.setState({showDropdownWrapper:2,dropDownPosition:[t.clientX,t.clientY]}),t.preventDefault()},onScroll:t=>{const e=t.currentTarget;if(e){const t=e.scrollLeft;(tthis.state.rightThreshold)&&this.handleAreaScroll(t)}}},s.createElement(Bt,{arrangement:this.props.arrangement,onTransportRangeChange:()=>{},getCalculator:this.getCalculator,onSeekPosChange:t=>{this.props.arrangement.transportSeekToPos=t,this.updateProgressBar()}}),s.createElement("div",{className:Jt.channelArea,ref:this.channelArea,onMouseDown:t=>{if(this.channelArea.current){const e=this.channelArea.current.getBoundingClientRect(),n=t.clientX-e.left,s=this.getCalculator().fromPixels(n).toPulses();this.setState({showSelectionRect:!0}),this.selectionRectConfig={x:s,y:t.clientY-e.top,width:0,height:0},this.selectionRectStage=1,this.bindRectSelectionMouseEvent()}}},s.createElement("div",{style:{height:Math.max(this.props.arrangement.channels.length*this.state.verticalScale+300,window.innerHeight-130)+"px",width:this.getCalculator().fromFrames(3969e4).toPixels()+"px",backgroundSize:`${o}px ${o}px,\n ${n}px ${n}px,\n ${i}px ${i}px,\n ${n}px ${n}px`},className:Jt.channelsAreaBackground}),this.state.channelUpdate?this.renderChannels():null,s.createElement("div",{ref:this.progressBarRef,className:Jt.progressBar}),this.renderSelectionRect())))),0!==this.state.showDropdownWrapper?s.createElement("div",{className:Jt.dropdownBackBG,onClick:()=>{this.setState({showDropdownWrapper:0}),this._contextMenuChannelId=""}}):"",1===this.state.showDropdownWrapper?this.renderSelectInstrumentMenu():"",2===this.state.showDropdownWrapper?this.renderArrangementContextMenu():"",3===this.state.showDropdownWrapper?this.renderRegionMenu():"",4===this.state.showDropdownWrapper?this.renderChannelMenu():""),s.createElement(Lt,{onPulsePerPixelDecrease:()=>{this.props.arrangement.emit(g.b.decreasePulsesPerPixel)},onPulsePerPixelIncrease:()=>{this.props.arrangement.emit(g.b.increasePulsesPerPixel)},pulsesPerPixel:this.state.pulsesPerPixel,rightPanelOpen:this.props.rightPanelOpen}))}}var ee=n(1388),ne=Object.defineProperty,se=Object.defineProperties,ie=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable,le=(t,e,n)=>e in t?ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;const ce=n(1581);class he extends s.Component{constructor(t){super(t),this.progressBarRef=s.createRef(),this.gridRef=s.createRef(),this.rulerRef=s.createRef(),this.rectSelection=s.createRef(),this.reqAnimatHandler=null,this.rulerPosY=0,this.dragOperation=0,this.backUpNotes=[],this.noteRefTable={},this.dragStartPulse=1/0,this.dragStartPitch=1/0,this.focusNoteId="",this.keysStateCopy={},this.samplePackList=Object.keys(ee.a),this.selectionRectConfig={x:0,y:0,width:0,height:0},this.contextMenuPos=[0,0],this.secondColor="",this.getCalculator=()=>new w.a(this.state.pulsesPerPixel,this.props.arrangement.ctx.sampleRate,this.props.arrangement.ctx.transport.bpm.value),this.partPlayer=null,this.startTime=1/0,this.triggerNote=(t,e)=>{const n=this.getCalculator();this.props.arrangement.instruments[this.props.channel.id].triggerAttackRelease(Object(r.d)(t),n.fromPulses(length).toSeconds(),this.props.tone.now(),1),this.keysStateCopy[t]=!0,this.setState({keysState:this.keysStateCopy,updateCounter:this.state.updateCounter+1},()=>{}),setTimeout(()=>{this.keysStateCopy[t]=!1,this.setState({keysState:this.keysStateCopy,updateCounter:this.state.updateCounter+1},()=>{})},n.fromPulses(e).toMilliseconds())},this.updateCounter=()=>{this.setState({notesUpdateCounter:this.state.notesUpdateCounter+1})},this.updateProgressBar=()=>{if(this.state.playing){const t=this.getCalculator(),e=t.fromPulses(this.props.region.timing.pulsesLength).toSeconds(),n=(this.props.tone.now()-this.startTime)%e;if(n>=0&&n<=e){const e=t.fromMilliseconds(1e3*n).toPixels();this.progressBarRef.current&&(this.progressBarRef.current.style.transform=`translate(${e}px, 0)`)}}if(this.continerRef.current){const t=this.continerRef.current;this.rulerPosY=Math.min(t.scrollTop,t.scrollHeight-t.clientHeight),this.rulerRef.current&&(this.rulerRef.current.style.transform=`translateY(${this.rulerPosY}px)`)}this.reqAnimatHandler=window.requestAnimationFrame(this.updateProgressBar)},this.onKeydown=t=>{t.preventDefault(),t.stopPropagation(),91===t.keyCode||8===t.keyCode&&this.deleteSelectNote(),t.preventDefault()},this.onMouseMove=t=>{if(0===this.dragOperation){const e=this.computeSelectionRect(t);this.selectionRectConfig=e,this.upadeRectSelection()}},this.onMouseUp=t=>{const e=this.props.channel.instrument.config.type===g.d.GeneralMidiSynth;if(this.state.showSelectionRect){const n=!t.shiftKey,s=[];if(this.gridRef.current){let t=Math.floor(this.selectionRectConfig.y/this.state.noteHeight),i=Math.floor((this.selectionRectConfig.y+this.selectionRectConfig.height)/this.state.noteHeight);t>i&&([t,i]=[i,t]);const o=[];if(e)for(let e=t;e<=i;e++)o.push(e+35);else{const e=this.props.channel.instrument.config.data;for(let n=t;na&&([r,a]=[a,r]);const l=this.props.region;for(let t=0;t=r&&o.includes(e.pitch)&&s.push(e.id)}if(n)this.setState({selectedNotes:s});else{for(let t=0;t{for(let e=0;e{const e=this.getNoteById(this.focusNoteId);if(e&&this.noteRefTable[this.focusNoteId]&&this.noteRefTable[this.focusNoteId].current){const n=this.noteRefTable[this.focusNoteId].current,s=this.getPulseByClientX(t.clientX,n,e)-this.dragStartPulse;if(1===this.dragOperation){const t=this.getCalculator(),e=this.backUpNotes;for(let n=0;n{this.dragOperation=0,this.props.region.notes.sort((t,e)=>t.position-e.position),document.removeEventListener("mousemove",this.noteMouseMoveListener),document.removeEventListener("mouseup",this.noteMouseUpListener)},this.getPitchRange=()=>{const t=this.props.channel.instrument;if(t.config.type===g.d.DrumMachine){const t=this.props.channel.instrument.config.data;let e=35,n=81;for(let s=0;s=i&&n.pitch<=s&&n.position+this.props.region.timing.pulsesContentPosition>=0&&n.position+this.props.region.timing.pulsesContentPosition{a.triggerAttackRelease(e.note,e.duration,t,1)},o),this.partPlayer.loop=!0,this.partPlayer.loopEnd=t.fromPulses(this.props.region.timing.pulsesLength).toSeconds(),this.setState({playing:!0},()=>{const t=e.now();this.startTime=t,n.ctx.transport.start(),this.partPlayer&&this.partPlayer.start()})}else this.setState({playing:!1},()=>{null!==this.partPlayer&&(this.partPlayer.stop(),this.partPlayer.dispose(),this.partPlayer=null),n.ctx.transport.stop(),n.ctx.transport.cancel(0)})}computePositionInChannelFromPulse(t,e){const n=this.getCalculator(),s=this.props.region,i=t+s.timing.pulsesContentPosition+s.position,o=n.fromPixels(1).toPulses(),r=n.fromFrames(7938e4).toPulses();if(0===t)return Math.max(s.position,Math.min(r,i));const a=n.fromQuarters(1).toPulses()/4,l=Math.round(Math.floor(i/a)*a);return lo*e?Math.min(Math.max(i,s.position),r):Math.min(l,r)}endOfRegion(){let t=0;for(let e=0;e=0&&(u=!0,c.pitch=h+35);else{const t=this.props.channel.instrument.config.data;h<=t.samplePack.samples.length&&h>=0&&(u=!0,c.pitch=t.samplePack.samples[h].note)}if(u)if(c.velocity=.75,c.position=this.computePositionInRegionFromPulse(l,null),this.props.arrangement.addNoteToRegion(this.props.channel,s,c),this.state.playing){if(null!==this.partPlayer){const t=e.fromPulses(c.position+this.props.region.timing.pulsesContentPosition).toSeconds(),n=e.fromPulses(c.length).toSeconds(),s=Object(r.d)(c.pitch);this.partPlayer.add(t,{duration:n,note:s})}}else this.triggerNote(c.pitch,c.length)}s.notes.sort((t,e)=>t.position-e.position)}computeSelectionRect(t){var e;const n=this.getCalculator(),s=this.selectionRectConfig,i=n.fromQuarters(4).toPulses(),o=this.endOfRegion(),r=(null==(e=this.gridRef.current)?void 0:e.offsetWidth)||0,a=Math.max(this.props.region.timing.pulsesLength+i,n.fromPixels(r).toPulses(),o),l=this.gridRef.current;if(l&&s){const e=l.scrollHeight,i=l.getBoundingClientRect();return((t,e)=>se(t,ie(e)))(((t,e)=>{for(var n in e||(e={}))re.call(e,n)&&le(t,n,e[n]);if(oe)for(var n of oe(e))ae.call(e,n)&&le(t,n,e[n]);return t})({},s),{width:Math.min(n.fromPixels(t.clientX-i.left).toPulses(),a)-s.x,height:Math.min(t.clientY-i.top,e)-s.y})}return s}deleteSelectNote(){for(let t=0;t=0?e.x:e.x+e.width).toPixels()+"px",s=(e.height>=0?e.y:e.y+e.height)+"px",i=t.fromPulses(Math.abs(e.width)).toPixels()+"px",o=Math.abs(e.height)+"px";this.rectSelection.current.style.left=n,this.rectSelection.current.style.top=s,this.rectSelection.current.style.width=i,this.rectSelection.current.style.height=o}}bindNoteMouseListeners(){document.addEventListener("mousemove",this.noteMouseMoveListener),document.addEventListener("mouseup",this.noteMouseUpListener)}getPulseByClientX(t,e,n){const s=this.state.pulsesPerPixel,i=this.props.region.timing.pulsesContentPosition;Math.round(this.getCalculator().fromPulses(n.position+i).toPixels());const o=t-e.getBoundingClientRect().left;return n.position+s*o}computeAdjustedTiming(t,e,n,s,i){const o=this.props.region.timing.pulsesLength,r=t.fromQuarters(1/16).toPulses(),a=n.position+r,l=o,c=n.length;let h=this.computeAlignedPos(t,e,n.position+c+s,i);h=hl?l:h;const u=h-n.position-c;return Math.max(c+u,r)}noteStretch(t,e,n,s,i){return this.computeAdjustedTiming(t,e,n,s,i)}computeAlignedPos(t,e,n,s,i=0){const o=t.fromPixels(1).toPulses(),r=this.props.region.timing.pulsesLength+this.getCalculator().fromQuarters(8).toPulses();if(0===e)return Math.max(i,Math.min(n,r));let a=t.fromPixels(e).toPulses();a/=s||1;const l=Math.round(Math.round(n/a)*a);return lo*e?Math.min(Math.max(n,i),r):Math.min(l,r)}computeShiftedPos(t,e,n,s,i,o){const r=this.props.region.timing.pulsesLength+this.getCalculator().fromQuarters(8).toPulses();let a=e[0];for(let t=0;te[t].position&&(a=e[t]);const l=a?a.position:s.position,c=Math.max(s.position-l,0),h=r-s.length,u=this.computeAlignedPos(t,n,l+i,o),p=s.position+(u-l);return ph?{position:h}:{position:p}}backUpSelectedNotes(){this.backUpNotes=[];for(let t=0;t=o&&this.props.region.notes[r].pitch<=i){const i=this.props.region.notes[r],a=this.state.selectedNotes.includes(i.id),l=Math.round(t.fromPulses(i.position+e).toPixels()),c=Math.round(t.fromPulses(i.position+e+i.length).toPixels());let h=0;h=(i.pitch-o)*this.state.noteHeight;const u=s.createRef();this.noteRefTable[i.id]=u,n[r]=s.createElement("div",{key:i.id,id:i.id,className:[ce.noteWrapper,ce.reverse].join(" "),ref:this.noteRefTable[i.id],onClick:()=>{this.triggerNote(i.pitch,i.length)},onContextMenu:t=>{if(this.gridRef.current){const e=this.gridRef.current.getBoundingClientRect(),n=t.clientX-e.left+100,s=t.clientY-e.top+24;this.contextMenuPos[0]=n,this.contextMenuPos[1]=s,this.setState({showContextMenu:!0})}t.stopPropagation(),t.preventDefault()},onMouseDown:t=>{t.stopPropagation();const e=Number(t.clientX);t.target===t.currentTarget?1===this.state.currentTool&&(a?this.backUpSelectedNotes():(this.backUpNotes=[y.u.clone(i)],this.setState({selectedNotes:[i.id]})),this.focusNoteId=i.id,this.dragStartPulse=this.getPulseByClientX(e,t.currentTarget,i),this.dragOperation=1,this.bindNoteMouseListeners()):0!==this.state.currentTool&&1!==this.state.currentTool||(a?this.backUpSelectedNotes():(this.backUpNotes=[y.u.clone(i)],this.setState({selectedNotes:[i.id]})),this.focusNoteId=i.id,this.dragStartPulse=this.getPulseByClientX(e,t.currentTarget,i),this.dragOperation=2,this.bindNoteMouseListeners())},style:{transform:`translate(${l+1}px, ${h}px)`,height:this.state.noteHeight-2+"px",width:c-l-2+"px"}},s.createElement("div",{style:{pointerEvents:"none",background:`radial-gradient(circle,${this.secondColor}, ${this.props.region.color})`},className:[ce.note,a?ce.selected:""].join(" ")},s.createElement("div",{className:ce.noteStretch,style:{pointerEvents:"all"}})))}return n}renderPercussions(){const t=this.getCalculator(),e=[];if(this.props.channel.instrument.config.type===g.d.DrumMachine){const n=this.props.channel.instrument.config.data;for(let i=0;i{this.triggerNote(o.note,t.fromQuarters(.25).toPulses())}},s.createElement("div",{className:ce.percussion},s.createElement("span",null,o.name))))}}else{const n=Vt.a.drummapNamelist;for(let i=0;i{this.triggerNote(i+35,t.fromQuarters(.25).toPulses())}},s.createElement("div",{className:ce.percussion},s.createElement("span",null,o.name))))}}return e}render(){const{uniteNoteLen:t,noteHeight:e,pulsesPerPixel:n}=this.state,i=this.getCalculator(),o=i.fromQuarters(4).toPulses(),r=i.fromQuarters(4).toPixels()-i.fromPulses(this.props.region.position%o).toPixels(),[a,l]=this.getPitchRange(),c=this.props.channel.instrument.config.data;return s.createElement("div",{className:ce.pageContainer},s.createElement("header",{className:ce.titleBar},s.createElement("button",{className:ce.closeBtn,onClick:()=>{this.props.close()}},s.createElement("i",{className:ce.icon}),"Close"),s.createElement("h3",null,"Note Clip Editor - ",this.props.channel.instrument.config.type)),s.createElement("div",{className:ce.container},s.createElement("div",{className:ce.toolBar},s.createElement("div",{className:ce.tools},s.createElement("div",{className:[ce.tool,ce.Pointer,1===this.state.currentTool?ce.currentTool:""].join(" "),onClick:()=>{this.setState({currentTool:1})}},s.createElement("div",{className:ce.icon})),s.createElement("div",{className:[ce.tool,ce.Pen,0===this.state.currentTool?ce.currentTool:""].join(" "),onClick:()=>{this.setState({currentTool:0})}},s.createElement("div",{className:ce.icon})),s.createElement("select",{className:[ce.tool,ce.samplePackSelector].join(" "),value:c.samplePack.name,onChange:t=>{t.target.value!==c.samplePack.name&&(this.props.arrangement.setChannelInstrument(this.props.channel,g.d.DrumMachine,t.target.value),this.setState({updateCounter:this.state.updateCounter+1}))}},this.samplePackList.map((t,e)=>s.createElement("option",{key:e,value:t},t))),s.createElement("div",{className:ce.placeholder}),s.createElement("div",{className:[ce.tooltip,ce.wrapper].join(" ")}),s.createElement("div",{className:[ce.tool,this.state.playing?ce.Stop:ce.Play,ce.right].join(" "),onClick:()=>{this.toggle()}},s.createElement("div",{className:ce.icon})))),s.createElement("div",{className:ce.containerScroll,ref:this.continerRef},s.createElement("div",{className:ce.progressbarWrapper},s.createElement("div",{className:ce.progressbar,ref:this.progressBarRef})),s.createElement("div",{className:ce.percussionContainer,style:{width:i.fromPulses(this.props.region.timing.pulsesLength).toPixels()+t+"px"}},s.createElement("div",{className:ce.percussionWrapper},this.renderPercussions())),s.createElement("div",{className:ce.noteClipEdit,style:{height:(a-l+1)*this.state.noteHeight+"px",width:i.fromPulses(this.props.region.timing.pulsesLength+i.fromQuarters(8).toPulses()).toPixels()+"px",minWidth:"100%"},ref:this.gridRef},s.createElement("div",{className:ce.rulerWrapper,ref:this.rulerRef,style:{height:"24px",top:"-24px",transform:`translateY(${this.rulerPosY}px)`}},s.createElement(S,{positionX:r,region:this.props.region,getCalculator:this.getCalculator,uniteNoteLen:this.state.uniteNoteLen})),s.createElement("div",{className:ce.grid,style:{backgroundPositionX:(t-this.props.region.position%(this.props.arrangement.ctx.transport.PPQ/4)/n)%t+"px",backgroundSize:`${e}px ${e}px,\n ${4*t}px ${4*t}px,\n ${t}px ${t}px,\n 576px 576px`},onContextMenu:t=>{t.preventDefault(),t.stopPropagation()},onDoubleClick:t=>{this.gridRef.current&&1===this.state.currentTool&&t.target===t.currentTarget&&this.addNoteAction(t)},onMouseDown:t=>{const e=this.gridRef.current;if(e)if(0===this.state.currentTool)t.target===t.currentTarget&&this.addNoteAction(t);else if(1===this.state.currentTool&&t.target===t.currentTarget){const n=e.getBoundingClientRect(),s=t.clientX-n.left,o=i.fromPixels(s).toPulses();this.selectionRectConfig={x:o,y:t.clientY-n.top,width:0,height:0},this.setState({showSelectionRect:!0}),this.upadeRectSelection()}}},s.createElement("div",{style:{width:`calc(100% - ${i.fromPulses(this.props.region.timing.pulsesLength).toPixels()}px)`,height:"100%",transform:`translate(${i.fromPulses(this.props.region.timing.pulsesLength).toPixels()}px, 0px)`,pointerEvents:"none",background:"#00000085"}}),s.createElement("div",{ref:this.rectSelection,className:ce.selectionRect,style:{display:this.state.showSelectionRect?"initial":"none"}}),this.state.notesUpdateCounter&&this.renderNotes())),this.state.showContextMenu?s.createElement("div",{className:ce.contextMenuMask,onClick:()=>{this.setState({showContextMenu:!1})}}):null,this.state.showContextMenu?s.createElement("div",{className:ce.ContextMenu,style:{transform:`translate(${this.contextMenuPos[0]}px, ${this.contextMenuPos[1]}px)`}},s.createElement("div",{className:ce.dropdown},s.createElement("div",{className:[ce.itemTooltip,ce.tooltipWrapper].join(" ")},s.createElement("div",{className:ce.item,onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onClick:()=>{this.deleteSelectNote(),this.setState({showContextMenu:!1})}},Object(C.e)("Delete"))))):null),s.createElement("div",{className:ce.zoomSliderWrapper},s.createElement(E,{onPulsePerPixelDecrease:()=>{if(this.state.pulsesPerPixel>1){const t=this.state.pulsesPerPixel/2,e=2*this.state.uniteNoteLen;this.setState({pulsesPerPixel:t,uniteNoteLen:e,snapPixels:e/4})}},onPulsePerPixelIncrease:()=>{if(this.state.pulsesPerPixel<4){const t=2*this.state.pulsesPerPixel,e=this.state.uniteNoteLen/2;this.setState({pulsesPerPixel:t,uniteNoteLen:e,snapPixels:e/4})}},steps:[0,1,2],maxPulsesPerPixel:4,minPulsesPerPixel:1,pulsesPerPixel:this.state.pulsesPerPixel,rightPanelOpen:!1}))))}}const ue=n(1582);class pe extends s.Component{constructor(t){super(t),this._renderHeaderView=()=>this.state.collapsed?this.props.renderHeaderView?this.props.renderHeaderView():null:this.props.renderHeaderViewAtExpened&&this.props.renderHeaderView?this.props.renderHeaderView():null,this.state={collapsed:!1}}render(){return s.createElement("div",{style:{display:"block",width:"100%"}},s.createElement("div",{className:[ue.container,this.state.collapsed?ue.closed:"",this.props.square?ue.square:""].join(" "),style:this.props.containerStyle},s.createElement("button",{className:ue.collapseBtn,onClick:()=>{this.setState({collapsed:!this.state.collapsed})}},this.state.collapsed?s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},s.createElement("path",{d:"M10 17l5-5-5-5v10z"}),s.createElement("path",{fill:"none",d:"M0 24V0h24v24H0z"})):s.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24"},s.createElement("path",{d:"M7 10l5 5 5-5z"}),s.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}))),s.createElement("h2",{className:ue.label},this.props.label),this._renderHeaderView(),s.createElement("div",{className:ue.childrenContainer,style:this.props.childContainerStyle},this.props.children)))}}const de=n(1583);class me extends s.Component{constructor(t){super(t),this.state={exp:void 0!==this.props.exp?this.props.exp:1,step:void 0!==this.props.step?this.props.step:1,value:void 0!==this.props.value?this.props.value:50,focused:!1}}UNSAFE_componentWillReceiveProps(t){return t.value!==this.props.value}_logValue(t){const e=Math.pow(t,this.state.exp),n=Math.pow(1,this.state.exp),s=Math.pow(101,this.state.exp);let i=Object(r.f)(e,n,s,this.props.min,this.props.max);i=this.props.integer?Math.round(i):1===this.state.exp?Number(i.toFixed(1)):Number(i.toFixed(2)),this.setState({value:i},()=>{this.state.value!==this.props.value&&this.props.onChange(this.state.value)})}_exp(t,e){return Math.sign(t)*Math.pow(Math.abs(t),e)}_beautifyVal(){const t=Math.abs(this.props.min-this.props.max);return t>10||this.props.integer?this.state.value.toFixed(0):t>1&&1===this.state.exp?this.state.value.toFixed(1):this.state.value.toFixed(2)}_getStep(){const t=Math.abs(this.props.min-this.props.max);return t>10||this.props.integer?1:t>1&&1===this.props.exp?.1:.01}_logPosition(){const t=Object(r.f)(this.state.value,this.props.min,this.props.max,Math.pow(1,this.state.exp),Math.pow(101,this.state.exp));return Math.pow(t,1/this.state.exp)}_numberInput(t){let e=Object(r.a)(parseFloat(t.target.value),this.props.min,this.props.max);e=this.props.integer?Math.round(e):1===this.state.exp?Number(e.toFixed(1)):Number(e.toFixed(2)),this.setState({value:e},()=>{this.state.value!==this.props.value&&this.props.onChange(this.state.value)})}render(){const t=Object(r.a)(this._logPosition(),0,100);let e=t-1,n=0;return void 0!==this.props.anchor&&0===this.props.anchor&&(n=50-Math.max(50-e,0),e=Math.abs(50-e)),s.createElement("div",{className:de.dawSliderContainer,style:this.props.style},s.createElement("label",{hidden:this.props.bare},this.props.label),s.createElement("span",{hidden:this.props.bare,className:de.units},this.props.units),s.createElement("input",{className:de.input,hidden:this.props.bare,type:"number",onChange:t=>{this._numberInput(t)},min:this.props.min,max:this.props.max,step:this._getStep(),value:this._beautifyVal()}),s.createElement("div",{className:de.slider},s.createElement("input",{className:de.input,name:"value",type:"range",onChange:t=>{this._logValue(parseFloat(t.target.value))},min:"1",max:"101",step:Math.pow(this.state.step,1/this.state.exp),onFocus:()=>{this.setState({focused:!0})},onBlur:()=>{this.setState({focused:!1})},value:t}),s.createElement("div",{className:[de.line,void 0!==this.props.anchor?0===this.props.anchor?de.center:de.left:""].join(" ")},s.createElement("div",{className:de.anchor,style:{width:e.toString()+"%",left:n.toString()+"%"}}),s.createElement("div",{className:[de.circle,this.state.focused?de.focused:""].join(" "),style:{left:`calc(${(t-1).toString()}% - ${(12*(t-1)/100).toString()}px)`}}))))}}class fe extends s.Component{constructor(t){super(t),this.state={value:void 0!==this.props.value?this.props.value:50,focused:!1}}UNSAFE_componentWillReceiveProps(t){return t.value!==this.props.value}_beautifyVal(t){const e=void 0===t?this.state.value:t,n=Object(r.a)(e,this.props.min,this.props.max);return 0===this.props.toFixed?Math.round(n):1===this.props.toFixed?Number(n.toFixed(1)):Number(n.toFixed(2))}_numberInput(t){let e=Object(r.a)(parseFloat(t.target.value),this.props.min,this.props.max);e=0===this.props.toFixed?Math.round(e):1===this.props.toFixed?Number(e.toFixed(1)):Number(e.toFixed(2)),this.setState({value:e},()=>{this.state.value!==this.props.value&&this.props.onChange(this.state.value)})}render(){let t=(this.state.value-this.props.min)/(this.props.max-this.props.min)*100,e=0;return void 0!==this.props.anchor&&0===this.props.anchor&&(e=50-Math.max(50-t,0),t=Math.abs(50-t)),s.createElement("div",{className:de.dawSliderContainer,style:this.props.style},s.createElement("label",{hidden:this.props.bare},this.props.label),s.createElement("span",{hidden:this.props.bare,className:de.units},this.props.units),s.createElement("input",{className:de.input,hidden:this.props.bare,type:"number",onChange:t=>{this._numberInput(t)},min:this.props.min,max:this.props.max,step:1/Math.pow(10,this.props.toFixed),value:this._beautifyVal()}),s.createElement("div",{className:de.slider},s.createElement("input",{className:de.input,name:"value",type:"range",onChange:t=>{const e=this._beautifyVal(parseFloat(t.target.value));this.setState({value:e},()=>{this.state.value!==this.props.value&&this.props.onChange(this.state.value)})},min:this.props.min,max:this.props.max,step:1/Math.pow(10,this.props.toFixed),onFocus:()=>{this.setState({focused:!0})},onBlur:()=>{this.setState({focused:!1})},value:this.state.value}),s.createElement("div",{className:[de.line,void 0!==this.props.anchor?0===this.props.anchor?de.center:de.left:""].join(" ")},s.createElement("div",{className:de.anchor,style:{width:t.toString()+"%",left:e.toString()+"%"}}),s.createElement("div",{className:[de.circle,this.state.focused?de.focused:""].join(" "),style:{left:`calc(${t.toString()}% - ${(20*t/100).toString()}px)`}}))))}}const ge=n(1584);class _e extends s.Component{constructor(t){super(t)}render(){return s.createElement("div",{className:ge.attributeContainer,style:this.props.style},s.createElement("label",{className:ge.attributeLabel},this.props.label),s.createElement("div",{className:ge.selectContainer},this.props.children))}}const ve=n(1585);class be extends s.Component{constructor(t){super(t),this.buffer=new Float32Array(50),this.min=-1.1,this.max=1.1,this.color="blue",this.canvasRef=s.createRef(),void 0!==this.props.color&&(this.color=this.props.color)}UNSAFE_componentWillReceiveProps(t){t.oscillator===this.props.oscillator&&t.updateCounter===this.props.updateCounter||this.visualize(t.oscillator).catch(t=>console.error(t))}componentDidMount(){this.visualize(this.props.oscillator).catch(t=>console.error(t))}visualize(t){return e=this,n=null,s=function*(){const e=this.props.tone,n=t.get(),s=yield e.Offline(()=>{let s;s="OmniOscillator"===t.name?new e.OmniOscillator(n):new e.Oscillator(n),s.frequency.value=200,s.detune.value=0,s.volume.value=0,s.toDestination().start(0).stop(.005)},.005);this.buffer=s.toArray(0),this.update()},new Promise((t,i)=>{var o=t=>{try{a(s.next(t))}catch(t){i(t)}},r=t=>{try{a(s.throw(t))}catch(t){i(t)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,r);a((s=s.apply(e,n)).next())});var e,n,s}update(){if(this.canvasRef.current){const t=this.canvasRef.current.getContext("2d");if(!t)return;const e=2*this.canvasRef.current.clientWidth,n=2*this.canvasRef.current.clientHeight;this.canvasRef.current.width=e,this.canvasRef.current.height=n,t.clearRect(0,0,e,n);const s=4;t.lineWidth=s,t.beginPath(),this.buffer.forEach((i,o)=>{const a=Object(r.f)(o,0,this.buffer.length,s,e-s),l=n-s-Object(r.f)(i,this.min,this.max,0,n-s);0===o?t.moveTo(a,l):t.lineTo(a,l)}),t.lineCap="round",t.strokeStyle=this.color,t.stroke()}}render(){return s.createElement("div",{className:ve.wrapper,style:this.props.containerStyle},s.createElement("canvas",{className:ve.oscillatorCanvas,ref:this.canvasRef}))}}const ye=n(1586);class we extends s.Component{constructor(t){super(t),this.state={updateCounter:0}}UNSAFE_componentWillReceiveProps(t){return!(this.props.oscillator===t.oscillator)}shouldComponentUpdate(t,e){return e.updateCounter!==this.state.updateCounter}renderBasicOscTypeOptions(){return s.createElement(s.Fragment,null,s.createElement("option",{value:y.h.sine},Object(C.e)(y.h.sine)),s.createElement("option",{value:y.h.square},Object(C.e)(y.h.square)),s.createElement("option",{value:y.h.sawtooth},Object(C.e)(y.h.sawtooth)),s.createElement("option",{value:y.h.triangle},Object(C.e)(y.h.triangle)))}renderBasicOscillatorControl(){return s.createElement("div",null,s.createElement(_e,{label:Object(C.e)("Type"),style:{paddingTop:"15px"}},s.createElement("select",{value:this.props.oscillator.type,onChange:t=>{this.props.onBasicTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement("div",{style:{height:"10px"}}),s.createElement("br",null))}renderFMOscillatorControl(){var t,e;return s.createElement("div",null,s.createElement(_e,{label:Object(C.e)("CarrierType"),style:{paddingTop:"15px"}},s.createElement("select",{value:this.props.oscillator.baseType,onChange:t=>{this.props.onBasicTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement("div",{style:{height:"10px"}}),s.createElement("br",null),s.createElement(_e,{label:Object(C.e)("ModulatorType")},s.createElement("select",{value:this.props.oscillator.modulationType,onChange:t=>{this.props.onModulatorTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement(me,{min:.1,max:20,integer:!0,exp:1.5,units:"",value:(null==(t=this.props.oscillator.modulationIndex)?void 0:t.value)||0,label:Object(C.e)("ModulationIndex"),onChange:t=>{this.props.onModulationIndexChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{min:.25,max:5,exp:1,units:"",value:(null==(e=this.props.oscillator.harmonicity)?void 0:e.value)||0,label:Object(C.e)("Harmonicity"),onChange:t=>{this.props.onHarmonicityChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}renderAMOscillatorControl(){var t;return s.createElement("div",null,s.createElement(_e,{label:Object(C.e)("CarrierType"),style:{paddingTop:"15px"}},s.createElement("select",{value:this.props.oscillator.baseType,onChange:t=>{this.props.onBasicTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement("div",{style:{height:"10px"}}),s.createElement("br",null),s.createElement(_e,{label:Object(C.e)("ModulatorType")},s.createElement("select",{value:this.props.oscillator.modulationType,onChange:t=>{this.props.onModulatorTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement(me,{min:.25,max:5,step:.1,units:"",value:(null==(t=this.props.oscillator.harmonicity)?void 0:t.value)||0,label:Object(C.e)("Harmonicity"),onChange:t=>{this.props.onHarmonicityChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}renderPulseOscillatorControl(){var t;return s.createElement("div",null,s.createElement(me,{style:{paddingTop:"15px"},min:0,max:1,exp:2,units:"",value:(null==(t=this.props.oscillator.width)?void 0:t.value)||0,label:Object(C.e)("width"),onChange:t=>{this.props.onPulseWidthChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}renderPWMOscillatorControl(){var t;return s.createElement("div",null,s.createElement(me,{style:{paddingTop:"15px"},min:.1,max:10,exp:1,units:Object(C.e)("hz"),value:(null==(t=this.props.oscillator.modulationFrequency)?void 0:t.value)||0,label:Object(C.e)("ModulationFrequency"),onChange:t=>{this.props.onPWMFreqChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}renderFatOscillatorControl(){return s.createElement("div",null,s.createElement(_e,{label:Object(C.e)("Type"),style:{paddingTop:"15px"}},s.createElement("select",{value:this.props.oscillator.baseType,onChange:t=>{this.props.onBasicTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderBasicOscTypeOptions())),s.createElement(me,{style:{paddingTop:"15px"},min:2,max:100,exp:1,units:Object(C.e)("cent"),value:this.props.oscillator.spread,label:Object(C.e)("Spread"),onChange:t=>{this.props.onFatSpreadChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{style:{paddingTop:"15px"},min:1,max:10,integer:!0,units:"",value:this.props.oscillator.count,label:Object(C.e)("Count"),onChange:t=>{this.props.onFatCountChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}render(){return s.createElement(pe,{label:this.props.label||Object(C.e)("Oscillator"),square:!0,renderHeaderViewAtExpened:!0,renderHeaderView:()=>s.createElement("div",null,s.createElement("div",{className:ye.miniOscillatorViz},s.createElement(be,{tone:this.props.tone,oscillator:this.props.oscillator,updateCounter:this.state.updateCounter,color:"black"})),s.createElement(_e,{label:"",style:{position:"absolute",top:"9px",right:"78px"}},s.createElement("select",{style:{padding:"0 8px 0 8px",maxWidth:"130px"},value:this.props.oscillator.sourceType,onChange:t=>{this.props.onSourceTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.y.Oscillator},Object(C.e)(y.y.Oscillator)),s.createElement("option",{value:y.y.FMOscillator},Object(C.e)(y.y.FMOscillator)),s.createElement("option",{value:y.y.AMOscillator},Object(C.e)(y.y.AMOscillator)),s.createElement("option",{value:y.y.FatOscillator},Object(C.e)(y.y.FatOscillator)),s.createElement("option",{value:y.y.PulseOscillator},Object(C.e)(y.y.PulseOscillator)),s.createElement("option",{value:y.y.PWMOscillator},Object(C.e)(y.y.PWMOscillator)))))},this.props.oscillator.sourceType===y.y.Oscillator?this.renderBasicOscillatorControl():"",this.props.oscillator.sourceType===y.y.FMOscillator?this.renderFMOscillatorControl():"",this.props.oscillator.sourceType===y.y.AMOscillator?this.renderAMOscillatorControl():"",this.props.oscillator.sourceType===y.y.PulseOscillator?this.renderPulseOscillatorControl():"",this.props.oscillator.sourceType===y.y.PWMOscillator?this.renderPWMOscillatorControl():"",this.props.oscillator.sourceType===y.y.FatOscillator?this.renderFatOscillatorControl():"")}}var xe=n(232),Se=Object.defineProperty,Ce=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Pe=(t,e,n)=>e in t?Se(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;const Te=n(1587);class Me extends s.Component{constructor(t){super(t),this.buffer=new Float32Array(50),this.color="#26ce2d",this.min=0,this.max=1.1,this.receivePropsTime=1/0,this.reqAnimatHandler=null,this.previousState=null,this.update=t=>{const e=t.attack+t.decay+t.release;this.props.tone.Offline(()=>{const e=(new o.Envelope).toDestination();e.toDestination(),e.set(t),e.triggerAttack(1e-4),e.triggerRelease(t.attack+t.decay+.001+1e-4)},e+.001+2e-4).then(t=>{if(this.buffer=t.toArray(0),this.canvasRef.current){const t=this.canvasRef.current.getContext("2d");if(!t)return;const e=2*this.canvasRef.current.clientWidth,n=2*this.canvasRef.current.clientHeight;this.canvasRef.current.width=e,this.canvasRef.current.height=n,t.clearRect(0,0,e,n);const s=this.props.lineWidth||4;t.lineWidth=s,t.beginPath(),this.buffer.forEach((i,o)=>{const a=Object(r.f)(o,0,this.buffer.length,s,e-s);if(a%1>.1)return;const l=Object(r.f)(this.max-i,this.min,this.max,0,n-s);0===o?t.moveTo(a,l):t.lineTo(a,l)}),t.lineCap="round",t.strokeStyle=this.props.color||this.color,t.stroke()}}).catch(t=>{console.error(t)})},this.canvasRef=s.createRef(),this.updateVisualize=this.updateVisualize.bind(this),this.update=Object(xe.b)(this.update,100)}UNSAFE_componentWillReceiveProps(t){return(t.envelope!==this.props.envelope||t.updateCounter!==this.props.updateCounter)&&(this.receivePropsTime==1/0&&(this.receivePropsTime=Date.now(),this.updateVisualize()),!0)}updateVisualize(){Date.now()-this.receivePropsTime>1e3?null!==this.reqAnimatHandler&&(window.cancelAnimationFrame(this.reqAnimatHandler),this.previousState=null,this.receivePropsTime=1/0):(this.visualize(this.props.envelope),this.reqAnimatHandler=window.requestAnimationFrame(this.updateVisualize))}componentDidMount(){this.visualize(this.props.envelope)}visualize(t){if(null!==this.previousState&&this.previousState.attack===t.attack&&this.previousState.decay===t.decay&&this.previousState.sustain===t.sustain&&this.previousState.release===t.release&&this.previousState.attackCurve===t.attackCurve&&this.previousState.decayCurve===t.decayCurve&&this.previousState.releaseCurve===t.releaseCurve)return;const e=((t,e)=>{for(var n in e||(e={}))ke.call(e,n)&&Pe(t,n,e[n]);if(Ce)for(var n of Ce(e))Ee.call(e,n)&&Pe(t,n,e[n]);return t})({},t.get());e.attack=e.attack.valueOf()/10,e.decay=e.decay.valueOf()/10,e.release=e.release.valueOf()/10,this.update(e),this.previousState={attack:t.attack,decay:t.decay,sustain:t.sustain,release:t.release,attackCurve:t.attackCurve,decayCurve:t.decayCurve,releaseCurve:t.releaseCurve}}render(){return s.createElement("div",{className:Te.wrapper,style:this.props.containerStyle},s.createElement("canvas",{className:Te.envelopeCanvas,ref:this.canvasRef}))}}const Re=n(1588);class Ae extends s.Component{constructor(t){super(t),this.state={updateCounter:0}}shouldComponentUpdate(t,e){return t.envelope.attack!==this.props.envelope.attack||t.envelope.decay!==this.props.envelope.decay||t.envelope.sustain!==this.props.envelope.sustain||t.envelope.release!==this.props.envelope.release||t.envelope.attackCurve!==this.props.envelope.attackCurve||t.envelope.decayCurve!==this.props.envelope.decayCurve||t.envelope.releaseCurve!==this.props.envelope.releaseCurve||t.label!==this.props.label||e.updateCounter!==this.state.updateCounter}renderCurveOptions(){return s.createElement(s.Fragment,null,s.createElement("option",{value:y.a.exponential},Object(C.e)(y.a.exponential)),s.createElement("option",{value:y.a.linear},Object(C.e)(y.a.linear)),s.createElement("option",{value:y.a.bounce},Object(C.e)(y.a.bounce)),s.createElement("option",{value:y.a.ripple},Object(C.e)(y.a.ripple)),s.createElement("option",{value:y.a.step},Object(C.e)(y.a.step)),s.createElement("option",{value:y.a.cosine},Object(C.e)(y.a.cosine)),s.createElement("option",{value:y.a.sine},Object(C.e)(y.a.sine)))}render(){return s.createElement(pe,{label:this.props.label||Object(C.e)("Envelope"),square:!0,renderHeaderViewAtExpened:!1,renderHeaderView:()=>s.createElement("div",{className:Re.miniEnvelopeViz},s.createElement(Me,{tone:this.props.tone,envelope:this.props.envelope,lineWidth:3,updateCounter:this.state.updateCounter,color:"black"}))},s.createElement("div",{className:Re.mainEnvelopeVizWrapper},s.createElement(Me,{tone:this.props.tone,envelope:this.props.envelope,updateCounter:this.state.updateCounter,color:this.props.color})),s.createElement(me,{min:.01,max:2,exp:2,units:"s",value:this.props.envelope.attack||0,label:Object(C.e)("Attack"),onChange:t=>{this.props.envelope.attack=t,this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("AttackCurve")},s.createElement("select",{value:this.props.envelope.attackCurve,onChange:t=>{this.props.onAttackCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderCurveOptions())),s.createElement(me,{min:.01,max:2,exp:2,units:Object(C.e)("s"),value:this.props.envelope.decay||0,label:Object(C.e)("Decay"),onChange:t=>{this.props.envelope.decay=t,this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("DecayCurve")},s.createElement("select",{value:this.props.envelope.decayCurve,onChange:t=>{this.props.onDecayCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.m.linear},Object(C.e)(y.m.linear)),s.createElement("option",{value:y.m.exponential},Object(C.e)(y.m.exponential)))),s.createElement(me,{min:.01,max:1,exp:2,units:Object(C.e)("s"),value:this.props.envelope.sustain,label:Object(C.e)("Sustain"),onChange:t=>{this.props.onSustainChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{min:.01,max:4,exp:2,units:Object(C.e)("s"),value:this.props.envelope.release||0,label:Object(C.e)("Release"),onChange:t=>{this.props.onReleaseChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("ReleaseCurve")},s.createElement("select",{value:this.props.envelope.releaseCurve,onChange:t=>{this.props.onReleaseCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderCurveOptions())))}}const Oe=n(1589);class Ne extends s.Component{constructor(t){super(t),this.buffer=new Float32Array(1),this.color="#26ce2d",this.min=0,this.max=2.5,this.receivePropsTime=1/0,this.reqAnimatHandler=null,this.previousState=null,this.updateVisualize=()=>{Date.now()-this.receivePropsTime>1e3?null!==this.reqAnimatHandler&&(window.cancelAnimationFrame(this.reqAnimatHandler),this.previousState=null,this.receivePropsTime=1/0):(this.visualize(this.props.filter),this.reqAnimatHandler=window.requestAnimationFrame(this.updateVisualize))},this.update=t=>{if(this.buffer=t.getFrequencyResponse().map(t=>Math.pow(t,.5)),this.canvasRef.current){const t=this.canvasRef.current.getContext("2d");if(!t)return;const e=2*this.canvasRef.current.clientWidth,n=2*this.canvasRef.current.clientHeight;this.canvasRef.current.width=e,this.canvasRef.current.height=n,t.clearRect(0,0,e,n),t.fillStyle="rgba(255, 255, 255, 0.3)",t.fillRect(0,.6*n,e,3),t.fill();const s=this.props.lineWidth||4;t.lineWidth=s,t.beginPath();for(let i=0;i{this.props.onTypeChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.n.lowpass},y.n.lowpass),s.createElement("option",{value:y.n.highpass},y.n.highpass),s.createElement("option",{value:y.n.bandpass},y.n.bandpass),s.createElement("option",{value:y.n.lowshelf},y.n.lowshelf),s.createElement("option",{value:y.n.highshelf},y.n.highshelf),s.createElement("option",{value:y.n.peaking},y.n.peaking),s.createElement("option",{value:y.n.notch},y.n.notch))),s.createElement(_e,{label:Object(C.e)("Rolloff"),style:{marginTop:"10px"}},s.createElement("select",{value:this.props.filter.rolloff.valueOf(),onChange:t=>{this.props.onRolloffChange(Number(t.target.value)),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:-12},-12),s.createElement("option",{value:-24},-24),s.createElement("option",{value:-48},-48),s.createElement("option",{value:-96},-96))),s.createElement(me,{min:0,max:10,units:"",value:this.props.filter.Q.value,label:Object(C.e)("Q"),onChange:t=>{this.props.onQChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{min:-20,max:3,units:Object(C.e)("dB"),value:this.props.filter.gain.value,label:Object(C.e)("Gain"),onChange:t=>{this.props.onGainChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}render(){return void 0!==this.props.inDrawer&&!1===this.props.inDrawer?this.renderContent():s.createElement(pe,{label:this.props.label||Object(C.e)("Envelope"),square:!0,renderHeaderViewAtExpened:!1,renderHeaderView:()=>s.createElement("div",{className:De.miniFilterViz},s.createElement(Ne,{tone:this.props.tone,filter:this.props.filter,lineWidth:3,updateCounter:this.state.updateCounter,color:"black"}))},this.renderContent())}}const Ie=n(1591);class Fe extends s.Component{constructor(t){super(t),this.state={updateCounter:0}}shouldComponentUpdate(t,e){return t.envelope.attack!==this.props.envelope.attack||t.envelope.decay!==this.props.envelope.decay||t.envelope.sustain!==this.props.envelope.sustain||t.envelope.release!==this.props.envelope.release||t.envelope.attackCurve!==this.props.envelope.attackCurve||t.envelope.decayCurve!==this.props.envelope.decayCurve||t.envelope.releaseCurve!==this.props.envelope.releaseCurve||t.label!==this.props.label||e.updateCounter!==this.state.updateCounter}renderAttackReleaseCurve(){return s.createElement(s.Fragment,null,s.createElement("option",{value:y.a.exponential},Object(C.e)(y.a.exponential)),s.createElement("option",{value:y.a.linear},Object(C.e)(y.a.linear)),s.createElement("option",{value:y.a.bounce},Object(C.e)(y.a.bounce)),s.createElement("option",{value:y.a.ripple},Object(C.e)(y.a.ripple)),s.createElement("option",{value:y.a.step},Object(C.e)(y.a.step)),s.createElement("option",{value:y.a.cosine},Object(C.e)(y.a.cosine)),s.createElement("option",{value:y.a.sine},Object(C.e)(y.a.sine)))}render(){return s.createElement(pe,{label:this.props.label||Object(C.e)("Envelope"),square:!0,renderHeaderViewAtExpened:!1,renderHeaderView:()=>s.createElement("div",{className:Ie.miniEnvelopeViz},s.createElement(Me,{tone:this.props.tone,envelope:this.props.envelope,lineWidth:3,updateCounter:this.state.updateCounter,color:"black"}))},s.createElement("div",{className:Ie.mainEnvelopeVizWrapper},s.createElement(Me,{tone:this.props.tone,envelope:this.props.envelope,updateCounter:this.state.updateCounter,color:this.props.color})),s.createElement(me,{min:.01,max:2,exp:2,units:Object(C.e)("s"),value:this.props.envelope.attack||0,label:Object(C.e)("Attack"),onChange:t=>{this.props.envelope.attack=t,this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("AttackCurve")},s.createElement("select",{value:this.props.envelope.attackCurve,onChange:t=>{this.props.onAttackCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderAttackReleaseCurve())),s.createElement(me,{min:.01,max:2,exp:2,units:Object(C.e)("s"),value:this.props.envelope.decay||0,label:Object(C.e)("Decay"),onChange:t=>{this.props.envelope.decay=t,this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("DecayCurve")},s.createElement("select",{value:this.props.envelope.decayCurve,onChange:t=>{this.props.onDecayCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.m.linear},Object(C.e)(y.m.linear)),s.createElement("option",{value:y.m.exponential},Object(C.e)(y.m.exponential)))),s.createElement(me,{min:.01,max:2,exp:2,units:Object(C.e)("s"),value:this.props.envelope.sustain,label:Object(C.e)("Sustain"),onChange:t=>{this.props.onSustainChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{min:.01,max:4,exp:2,units:Object(C.e)("s"),value:this.props.envelope.release||0,label:Object(C.e)("Release"),onChange:t=>{this.props.onReleaseChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(_e,{label:Object(C.e)("ReleaseCurve")},s.createElement("select",{value:this.props.envelope.releaseCurve,onChange:t=>{this.props.onReleaseCurveChange(t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},this.renderAttackReleaseCurve())),s.createElement(me,{min:20,max:2e4,exp:2,units:Object(C.e)("hz"),value:this.props.envelope.baseFrequency.valueOf()||400,label:Object(C.e)("baseFrequency"),onChange:t=>{this.props.onBaseFreqChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}),s.createElement(me,{min:0,max:16,units:"",value:this.props.envelope.octaves||4,label:Object(C.e)("Octaves"),onChange:t=>{this.props.onOctavesChange(t),this.setState({updateCounter:this.state.updateCounter+1})}}))}}var Ve=Object.defineProperty,je=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable,Ue=(t,e,n)=>e in t?Ve(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;const He=n(1592);class We extends s.Component{constructor(t){super(t),this._onChannelInstrumentChange=()=>{this.setState({updateCounter:this.state.updateCounter+1})},this._onSourceTypeChange=(t,e,n)=>{if(!this.props.arrangement.isUsingOfflineCtx&&t!==e.oscillator.type){const s=this._reAllocOmniOscillatorSchema(t);if(s)if(y.L.free(e.oscillator),e.oscillator=s[0],"oscillator"===e.oscillator.type){const t=e.oscillator.data.type;n.set({oscillator:{type:t}})}else if("pulse"===e.oscillator.type||"pwm"===e.oscillator.type)n.set({oscillator:{type:e.oscillator.type}});else if("am"===e.oscillator.type||"fm"===e.oscillator.type){const t=e.oscillator.type+e.oscillator.data.carrierType;n.set({oscillator:{type:t}})}else{const t=e.oscillator.type+e.oscillator.data.type;n.set({oscillator:{type:t}})}}},this._onBaseTypeChange=(t,e,n)=>{if(this.props.arrangement.isUsingOfflineCtx)return;let s=!1,i="";if("oscillator"===e.oscillator.type?(e.oscillator.data.type=t,s=!0):"fm"===e.oscillator.type?(e.oscillator.data.carrierType=t,i="fm",s=!0):"am"===e.oscillator.type?(e.oscillator.data.carrierType=t,i="am",s=!0):"fat"===e.oscillator.type&&(e.oscillator.data.type=t,i="fat",s=!0),s){const e=i+t;n.set({oscillator:{type:e}})}},this._onModulatorTypeChange=(t,e,n)=>{if(this.props.arrangement.isUsingOfflineCtx)return;let s=!1;("fm"===e.oscillator.type||"am"===e.oscillator.type)&&(e.oscillator.data.modulatortype=t,s=!0),s&&n.set({oscillator:{modulationType:t}})},this._onModulationIndexChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||"fm"===e.oscillator.type&&(e.oscillator.data.modulationIndex=t,n.set({oscillator:{modulationIndex:t}}))},this._onHarmonicityChange=(t,e,n)=>{if(this.props.arrangement.isUsingOfflineCtx)return;let s=!1;("fm"===e.oscillator.type||"am"===e.oscillator.type)&&(e.oscillator.data.harmonicity=t,s=!0),s&&n.set({oscillator:{harmonicity:t}})},this._onPWMFreqChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||"pwm"===e.oscillator.type&&(e.oscillator.data.modulationFrequency=t,n.set({oscillator:{modulationFrequency:t}}))},this._onPulseWidthChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||"pulse"===e.oscillator.type&&(e.oscillator.data.width=t,n.set({oscillator:{width:t}}))},this._onFatSpreadChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||"fat"===e.oscillator.type&&(e.oscillator.data.spread=t,n.set({oscillator:{spread:t}}))},this._onFatCountChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||"fat"===e.oscillator.type&&(e.oscillator.data.count=t,n.set({oscillator:{count:t}}))},this._onAttackChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.attack=t,n.set({envelope:{attack:t}}))},this._onReleaseChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.release=t,n.set({envelope:{release:t}}))},this._onDecayChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.decay=t,n.set({envelope:{decay:t}}))},this._onSustainChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.sustain=t,n.set({envelope:{sustain:t}}))},this._onAttackCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.attackCurve=t,n.set({envelope:{attackCurve:t}}))},this._onReleaseCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.releaseCurve=t,n.set({envelope:{releaseCurve:t}}))},this._onDecayCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.envelope.decayCurve=t,n.set({envelope:{decayCurve:t}}))},this._onSynthHarmonicityChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.harmonicity=t,n.set({harmonicity:t}))},this._onSynthModulationIndexChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationIndex=t,n.set({modulationIndex:t}))},this._onModulationBaseTypeChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulation.type=t,n.set({modulation:{type:t}}))},this._onModulatorAttackChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.attack=t,n.set({modulationEnvelope:{attack:t}}))},this._onModulatorReleaseChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.release=t,n.set({modulationEnvelope:{release:t}}))},this._onModulatorDecayChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.decay=t,n.set({modulationEnvelope:{decay:t}}))},this._onModulatorSustainChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.sustain=t,n.set({modulationEnvelope:{sustain:t}}))},this._onModulatorAttackCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.attackCurve=t,n.set({modulationEnvelope:{attackCurve:t}}))},this._onModulatorReleaseCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.releaseCurve=t,n.set({modulationEnvelope:{releaseCurve:t}}))},this._onModulatorDecayCurveChange=(t,e,n)=>{this.props.arrangement.isUsingOfflineCtx||(e.modulationEnvelope.decayCurve=t,n.set({modulationEnvelope:{decayCurve:t}}))},this.state={updateCounter:0}}shouldComponentUpdate(t,e){return t.channel.id!==this.props.channel.id||e.updateCounter!==this.state.updateCounter}componentDidMount(){this.props.arrangement.addListener(`${g.b.connectNewInstrument}-${this.props.channel.id}`,this._onChannelInstrumentChange)}componentWillUnmount(){this.props.arrangement.removeListener(`${g.b.connectNewInstrument}-${this.props.channel.id}`,this._onChannelInstrumentChange)}_reAllocOmniOscillatorSchema(t){if(t===y.y.Oscillator){const t=y.L.alloc();return t.type="oscillator",t.data=y.M.alloc(),[t,t.data.type]}if(t===y.y.FMOscillator){const t=y.L.alloc();return t.type="fm",t.data=y.G.alloc(),[t,t.type+t.data.carrierType]}if(t===y.y.AMOscillator){const t=y.L.alloc();return t.type="am",t.data=y.B.alloc(),[t,t.type+t.data.carrierType]}if(t===y.y.PulseOscillator){const t=y.L.alloc();return t.type="pulse",t.data=y.N.alloc(),[t,t.type]}if(t===y.y.PWMOscillator){const t=y.L.alloc();return t.type="pwm",t.data=y.O.alloc(),[t,t.type]}if(t===y.y.FatOscillator){const t=y.L.alloc();return t.type="fat",t.data=y.E.alloc(),[t,t.type+t.data.type]}return null}renderSimpleSynthSetting(){const t=this.props.channel.id,e=this.props.channel.instrument.config.data,n=this.props.arrangement.instruments[t],i=n._dummyVoice;return s.createElement("div",{style:{height:"100%"}},s.createElement(we,{tone:this.props.tone,oscillator:i.oscillator,onSourceTypeChange:t=>{this._onSourceTypeChange(t,e,n)},onBasicTypeChange:t=>{this._onBaseTypeChange(t,e,n)},onModulatorTypeChange:t=>{this._onModulatorTypeChange(t,e,n)},onModulationIndexChange:t=>{this._onModulationIndexChange(t,e,n)},onHarmonicityChange:t=>{this._onHarmonicityChange(t,e,n)},onPWMFreqChange:t=>{this._onPWMFreqChange(t,e,n)},onPulseWidthChange:t=>{this._onPulseWidthChange(t,e,n)},onFatSpreadChange:t=>{this._onFatSpreadChange(t,e,n)},onFatCountChange:t=>{this._onFatCountChange(t,e,n)}}),s.createElement(Ae,{tone:this.props.tone,envelope:i.envelope,onAttackChange:t=>{this._onAttackChange(t,e,n)},onReleaseChange:t=>{this._onReleaseChange(t,e,n)},onDecayChange:t=>{this._onDecayChange(t,e,n)},onSustainChange:t=>{this._onSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onDecayCurveChange(t,e,n)}}))}renderModulationOsc(t,e,n,i){return s.createElement(pe,{label:t,square:!0,renderHeaderViewAtExpened:!0,renderHeaderView:()=>s.createElement("div",{className:He.miniOscillatorViz},s.createElement(be,{tone:this.props.tone,oscillator:e,updateCounter:this.state.updateCounter,color:"black"}))},s.createElement("div",null,s.createElement(_e,{label:Object(C.e)("Type"),style:{paddingTop:"15px"}},s.createElement("select",{value:e.baseType,onChange:t=>{this._onModulationBaseTypeChange(t.target.value,n,i),this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.h.sine},Object(C.e)(y.h.sine)),s.createElement("option",{value:y.h.square},Object(C.e)(y.h.square)),s.createElement("option",{value:y.h.sawtooth},Object(C.e)(y.h.sawtooth)),s.createElement("option",{value:y.h.triangle},Object(C.e)(y.h.triangle)))),s.createElement("div",{style:{height:"10px"}}),s.createElement("br",null)))}renderFMSynthSetting(){const t=this.props.channel.id,e=this.props.channel.instrument.config.data,n=this.props.arrangement.instruments[t],i=n._dummyVoice;return s.createElement("div",{style:{height:"100%"}},s.createElement(pe,{label:Object(C.e)("FmSynth"),square:!0},s.createElement(me,{min:.5,max:4,exp:1,units:"",value:e.harmonicity,label:Object(C.e)("SynthHarmonicity"),onChange:t=>{this._onSynthHarmonicityChange(t,e,n)}}),s.createElement(me,{min:0,max:40,exp:1,units:"",value:e.modulationIndex,label:Object(C.e)("SynthModulationIndex"),onChange:t=>{this._onSynthModulationIndexChange(t,e,n)}})),s.createElement(we,{label:Object(C.e)("CarrierOscillator"),tone:this.props.tone,oscillator:i.oscillator,onSourceTypeChange:t=>{this._onSourceTypeChange(t,e,n)},onBasicTypeChange:t=>{this._onBaseTypeChange(t,e,n)},onModulatorTypeChange:t=>{this._onModulatorTypeChange(t,e,n)},onModulationIndexChange:t=>{this._onModulationIndexChange(t,e,n)},onHarmonicityChange:t=>{this._onHarmonicityChange(t,e,n)},onPWMFreqChange:t=>{this._onPWMFreqChange(t,e,n)},onPulseWidthChange:t=>{this._onPulseWidthChange(t,e,n)},onFatSpreadChange:t=>{this._onFatSpreadChange(t,e,n)},onFatCountChange:t=>{this._onFatCountChange(t,e,n)}}),s.createElement(Ae,{label:Object(C.e)("CarrierEnvelope"),tone:this.props.tone,envelope:i.envelope,onAttackChange:t=>{this._onAttackChange(t,e,n)},onReleaseChange:t=>{this._onReleaseChange(t,e,n)},onDecayChange:t=>{this._onDecayChange(t,e,n)},onSustainChange:t=>{this._onSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onDecayCurveChange(t,e,n)}}),this.renderModulationOsc(Object(C.e)("ModulationOscillator"),i.modulation,e,n),s.createElement(Ae,{label:Object(C.e)("ModulationEnvelope"),tone:this.props.tone,envelope:i.modulationEnvelope,onAttackChange:t=>{this._onModulatorAttackChange(t,e,n)},onReleaseChange:t=>{this._onModulatorReleaseChange(t,e,n)},onDecayChange:t=>{this._onModulatorDecayChange(t,e,n)},onSustainChange:t=>{this._onModulatorSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onModulatorAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onModulatorReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onModulatorDecayCurveChange(t,e,n)},color:"#03A9F4"}))}renderAMSynthSetting(){const t=this.props.channel.id,e=this.props.channel.instrument.config.data,n=this.props.arrangement.instruments[t],i=n._dummyVoice;return s.createElement("div",{style:{height:"100%"}},s.createElement(pe,{label:Object(C.e)("AmSynth"),square:!0},s.createElement(me,{min:.5,max:4,exp:1,units:"",value:e.harmonicity,label:Object(C.e)("SynthHarmonicity"),onChange:t=>{this._onSynthHarmonicityChange(t,e,n)}})),s.createElement(we,{label:Object(C.e)("CarrierOscillator"),tone:this.props.tone,oscillator:i.oscillator,onSourceTypeChange:t=>{this._onSourceTypeChange(t,e,n)},onBasicTypeChange:t=>{this._onBaseTypeChange(t,e,n)},onModulatorTypeChange:t=>{this._onModulatorTypeChange(t,e,n)},onModulationIndexChange:t=>{this._onModulationIndexChange(t,e,n)},onHarmonicityChange:t=>{this._onHarmonicityChange(t,e,n)},onPWMFreqChange:t=>{this._onPWMFreqChange(t,e,n)},onPulseWidthChange:t=>{this._onPulseWidthChange(t,e,n)},onFatSpreadChange:t=>{this._onFatSpreadChange(t,e,n)},onFatCountChange:t=>{this._onFatCountChange(t,e,n)}}),s.createElement(Ae,{label:Object(C.e)("CarrierEnvelope"),tone:this.props.tone,envelope:i.envelope,onAttackChange:t=>{this._onAttackChange(t,e,n)},onReleaseChange:t=>{this._onReleaseChange(t,e,n)},onDecayChange:t=>{this._onDecayChange(t,e,n)},onSustainChange:t=>{this._onSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onDecayCurveChange(t,e,n)}}),this.renderModulationOsc(Object(C.e)("ModulationOscillator"),i.modulation,e,n),s.createElement(Ae,{label:Object(C.e)("ModulationEnvelope"),tone:this.props.tone,envelope:i.modulationEnvelope,onAttackChange:t=>{this._onModulatorAttackChange(t,e,n)},onReleaseChange:t=>{this._onModulatorReleaseChange(t,e,n)},onDecayChange:t=>{this._onModulatorDecayChange(t,e,n)},onSustainChange:t=>{this._onModulatorSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onModulatorAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onModulatorReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onModulatorDecayCurveChange(t,e,n)},color:"#03A9F4"}))}renderMonoSynthSetting(){const t=this.props.channel.id,e=this.props.channel.instrument.config.data,n=this.props.arrangement.instruments[t],i=n._dummyVoice,o=new this.props.tone.Filter(((t,e)=>{for(var n in e||(e={}))Le.call(e,n)&&Ue(t,n,e[n]);if(je)for(var n of je(e))qe.call(e,n)&&Ue(t,n,e[n]);return t})({},e.filter));return s.createElement("div",{style:{height:"100%"}},s.createElement(we,{label:Object(C.e)("Oscillator"),tone:this.props.tone,oscillator:i.oscillator,onSourceTypeChange:t=>{this._onSourceTypeChange(t,e,n)},onBasicTypeChange:t=>{this._onBaseTypeChange(t,e,n)},onModulatorTypeChange:t=>{this._onModulatorTypeChange(t,e,n)},onModulationIndexChange:t=>{this._onModulationIndexChange(t,e,n)},onHarmonicityChange:t=>{this._onHarmonicityChange(t,e,n)},onPWMFreqChange:t=>{this._onPWMFreqChange(t,e,n)},onPulseWidthChange:t=>{this._onPulseWidthChange(t,e,n)},onFatSpreadChange:t=>{this._onFatSpreadChange(t,e,n)},onFatCountChange:t=>{this._onFatCountChange(t,e,n)}}),s.createElement(Ae,{label:Object(C.e)("CarrierEnvelope"),tone:this.props.tone,envelope:i.envelope,onAttackChange:t=>{this._onAttackChange(t,e,n)},onReleaseChange:t=>{this._onReleaseChange(t,e,n)},onDecayChange:t=>{this._onDecayChange(t,e,n)},onSustainChange:t=>{this._onSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onDecayCurveChange(t,e,n)}}),s.createElement(Be,{label:Object(C.e)("Filter"),tone:this.props.tone,filter:o,onTypeChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filter.type=t,n.set({filter:{type:t}}),o.set({type:t}))},onRolloffChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filter.rolloff=t,n.set({filter:{rolloff:t}}),o.set({rolloff:t}))},onQChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filter.Q=t,n.set({filter:{Q:t}}),o.set({Q:t}))},onGainChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filter.gain=t,n.set({filter:{gain:t}}),o.set({gain:t}))}}),s.createElement(Fe,{label:Object(C.e)("CarrierEnvelope"),tone:this.props.tone,envelope:i.filterEnvelope,onAttackChange:t=>{this._onAttackChange(t,e,n)},onReleaseChange:t=>{this._onReleaseChange(t,e,n)},onDecayChange:t=>{this._onDecayChange(t,e,n)},onSustainChange:t=>{this._onSustainChange(t,e,n)},onAttackCurveChange:t=>{this._onAttackCurveChange(t,e,n)},onReleaseCurveChange:t=>{this._onReleaseCurveChange(t,e,n)},onDecayCurveChange:t=>{this._onDecayCurveChange(t,e,n)},onBaseFreqChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filterEnvelope.baseFrequency=t,n.set({filterEnvelope:{baseFrequency:t}}),i.filterEnvelope.set({baseFrequency:t}))},onOctavesChange:t=>{this.props.arrangement.isUsingOfflineCtx||(e.filterEnvelope.octaves=t,n.set({filterEnvelope:{octaves:t}}),i.filterEnvelope.set({octaves:t}))}}))}renderSamplerPianoSetting(){const t=Object.keys(ee.c),e=this.props.channel.instrument.config.data;return t.indexOf(e.samplePack.name)<0?null:s.createElement("div",null,s.createElement(pe,{label:"Instrument sound pack",square:!0},s.createElement(_e,{label:Object(C.e)("Instrument")},s.createElement("select",{value:e.samplePack.name,onChange:t=>{t.target.value!==e.samplePack.name&&this.props.arrangement.setChannelInstrument(this.props.channel,g.d.Sampler,t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},t.map((t,e)=>s.createElement("option",{key:e,value:t},t))))))}renderDrumMachineSetting(){const t=Object.keys(ee.a),e=this.props.channel.instrument.config.data;return t.indexOf(e.samplePack.name)<0?null:s.createElement("div",null,s.createElement(pe,{label:"Instrument sound pack",square:!0},s.createElement(_e,{label:Object(C.e)("Instrument")},s.createElement("select",{value:e.samplePack.name,onChange:t=>{t.target.value!==e.samplePack.name&&this.props.arrangement.setChannelInstrument(this.props.channel,g.d.DrumMachine,t.target.value),this.setState({updateCounter:this.state.updateCounter+1})}},t.map((t,e)=>s.createElement("option",{key:e,value:t},t))))))}render(){const t=this.props.channel.instrument.config;return s.createElement("div",{className:He.pageContainer},s.createElement("header",{className:He.titleBar},s.createElement("button",{className:He.closeBtn,onClick:()=>{this.props.close()}},s.createElement("i",{className:He.icon}),Object(C.e)("Close"))),s.createElement("div",{className:He.contentWarpper},t.type===g.d.SimpleSynth?this.renderSimpleSynthSetting():"",t.type===g.d.FmSynth?this.renderFMSynthSetting():"",t.type===g.d.AmSynth?this.renderAMSynthSetting():"",t.type===g.d.Sampler?this.renderSamplerPianoSetting():"",t.type===g.d.MonoSynth?this.renderMonoSynthSetting():"",t.type===g.d.DrumMachine?this.renderDrumMachineSetting():""))}}var Qe=n(1382);const Xe=n(1593),ze=t=>{const[e,n]=Object(s.useState)(!1),[o,r]=Object(s.useState)(t.text),a=()=>{t.onFinalChange(o),n(!1)};return Object(s.useEffect)(()=>{r(t.text)},[t.text]),i.a.createElement("div",{className:Xe.editableText},e?i.a.createElement("div",{onBlur:()=>a(),onKeyDown:t=>{13==t.keyCode&&a()}},i.a.createElement("input",{className:Xe.iinlineInput,type:"text",value:o,onChange:t=>{r(t.target.value)}})):i.a.createElement("div",{onClick:()=>n(!0)},i.a.createElement("span",null,t.text||t.placeholder||"Editable content")))};const Ge=n(1594);const Ye=["aui","wav","mp3","ogg","flac","m4a"];class Ke extends s.Component{constructor(t){super(t),this._currentFileId="",this.onAudioFileUpdate=()=>{this.setState({audioFiles:this.props.arrangement.audioFiles})},this.getFormat=(t="")=>t.includes(".")?(t.split(".").pop()||"").toLowerCase():null,this.state={selectTab:0,audioFiles:this.props.arrangement.audioFiles}}componentDidMount(){this.props.arrangement.addListener(g.b.audioFileUpdate,this.onAudioFileUpdate)}componentWillUnmount(){this.props.arrangement.removeListener(g.b.audioFileUpdate,this.onAudioFileUpdate)}getFirstRegionIdByFileId(t){for(let e=0;e{var o=t=>{try{a(s.next(t))}catch(t){i(t)}},r=t=>{try{a(s.throw(t))}catch(t){i(t)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(o,r);a((s=s.apply(e,n)).next())});var e,n,s}musicIcon(){return s.createElement("svg",{version:"1.1",id:"Layer_1",x:"0px",y:"0px",viewBox:"0 0 104.23 122.88"},s.createElement("g",null,s.createElement("path",{style:{fillRule:"evenodd",clipRule:"evenodd"},d:"M87.9,78.04c2.74-0.48,5.33-0.4,7.6,0.13V24.82L39.05,41.03v61.95c0.03,0.34,0.05,0.69,0.05,1.03 c0,0,0,0.01,0,0.01c0,8.34-8.75,16.62-19.55,18.49C8.76,124.37,0,119.12,0,110.77c0-8.34,8.76-16.62,19.55-18.48 c4.06-0.7,7.84-0.39,10.97,0.71l0-76.26h0.47L104.04,0v85.92c0.13,0.63,0.2,1.27,0.2,1.91c0,0,0,0,0,0.01 c0,6.97-7.32,13.89-16.33,15.44c-9.02,1.56-16.33-2.83-16.33-9.8C71.57,86.51,78.88,79.59,87.9,78.04L87.9,78.04L87.9,78.04z"})))}render(){return s.createElement("div",{className:Ge.rightPannelContainer},s.createElement("div",{className:Ge.rightPannel},s.createElement("ul",{className:Ge.menuTabsList},s.createElement("li",{className:Ge.listItem},s.createElement("div",{className:[Ge.ffolder,Ge.small,Ge.yellow].join(" "),onClick:()=>{this.props.onTogglePanel(!this.props.isPanelOpen)}}))),this.props.isPanelOpen?s.createElement("div",{className:Ge.rightPanelContent},s.createElement("div",{className:Ge.projectResources},s.createElement("div",{className:Ge.resourceTabs},s.createElement("div",{className:[Ge.tabItem,0===this.state.selectTab?Ge.selected:""].join(" ")},"Audio Assets")),s.createElement("div",{className:Ge.resourcesViewContainer},s.createElement("table",{className:Ge.soundListTable},s.createElement("tbody",{className:Ge.soundListTableBody},this.state.audioFiles.map((t,e)=>{const n=!(this.props.arrangement.bufferCache[t.id]&&this.props.arrangement.bufferCache[t.id].audioBuffer);return s.createElement("tr",{key:e,className:n?Ge.missing:"",onClick:()=>{n&&(console.log("missing file is",t),this._currentFileId=t.id,this._importAudioInputRef.click())}},s.createElement("td",{className:Ge.fileIcon},this.musicIcon()),s.createElement("td",{className:Ge.fileName},s.createElement(ze,{text:t.name,onFinalChange:e=>{t.name=e,this.onAudioFileUpdate()},placeholder:""})),s.createElement("td",{className:Ge.column},t.url),s.createElement("td",{className:Ge.column},n?"missing":""!==t.url?"uploaded":"uploading"))}))),s.createElement("input",{type:"file",style:{width:0,height:0,display:"none"},accept:".aui,.wav,.mp3,.ogg,.flac,.m4a",ref:t=>{this._importAudioInputRef=t},onChange:t=>{this.handleAudioFileImport(this._importAudioInputRef.files).catch(t=>console.error(t))}})))):null))}}const Ze=n(1595);class Je extends s.Component{constructor(t){super(t),this.containerBoundbox={left:250,top:150,mouseDownX:0,mouseDownY:0},this.onEffectSettingRequest=t=>{const e=t.channelId,n=t.effectIdx;let s,i;for(let t=0;t{const e=t.channelId,n=t.effectIdx;e===this.state.channelId&&n===this.state.effectIdx&&this.setState({channelId:"",effectIdx:-1,opendedPanel:void 0})},this.onResizeWindow=()=>{if(this.popupWindowRef.current){const t=this.popupWindowRef.current.getBoundingClientRect();window.innerWidth-(t.x+t.width)<=20&&this.setState({left:window.innerWidth-t.width-20}),window.innerHeight-(t.y+t.height)<=20&&this.setState({top:window.innerHeight-t.height-20})}},this._onmousemove=t=>{const e=t.clientX-this.containerBoundbox.mouseDownX,n=t.clientY-this.containerBoundbox.mouseDownY;if(this.popupWindowRef.current){const t=this.popupWindowRef.current.getBoundingClientRect();if(t.x<=20&&e<0||window.innerWidth-(t.x+t.width)<=20&&e>0)return;if(t.y<=20&&n<0||window.innerHeight-(t.y+t.height)<=20&&n>0)return;this.popupWindowRef.current.style.transform=`translate(${e+this.containerBoundbox.left}px, ${n+this.containerBoundbox.top}px)`}t.stopPropagation()},this._onmouseup=t=>{if(this.popupWindowRef.current){const t=this.popupWindowRef.current.getBoundingClientRect();this.setState({left:t.x,top:t.y})}document.removeEventListener("mousemove",this._onmousemove),document.removeEventListener("mouseup",this._onmouseup),t.stopPropagation()},this.onPopupHeaderMouseDown=t=>{this.containerBoundbox.left=this.state.left,this.containerBoundbox.top=this.state.top,this.containerBoundbox.mouseDownX=t.clientX,this.containerBoundbox.mouseDownY=t.clientY,this._bindMouseEvent(),t.stopPropagation()},this.popupWindowRef=s.createRef(),this.state={updateCounter:0,opendedPanel:void 0,channelId:"",effectIdx:-1,left:this.containerBoundbox.left,top:this.containerBoundbox.top}}shouldComponentUpdate(t,e){return e.updateCounter!==this.state.updateCounter||e.opendedPanel!==this.state.opendedPanel||e.channelId!==this.state.channelId||e.effectIdx!==this.state.effectIdx||e.left!==this.state.left||e.top!==this.state.top}componentDidMount(){window.addEventListener("resize",this.onResizeWindow),this.props.arrangement.addListener(g.b.openChannelEffectSetting,this.onEffectSettingRequest),this.props.arrangement.addListener(g.b.removeChannelEffectNode,this.onEffectNodeRemoved)}componentWillUnmount(){window.removeEventListener("resize",this.onResizeWindow),this.props.arrangement.removeListener(g.b.openChannelEffectSetting,this.onEffectSettingRequest),this.props.arrangement.removeListener(g.b.removeChannelEffectNode,this.onEffectNodeRemoved)}_bindMouseEvent(){document.addEventListener("mousemove",this._onmousemove),document.addEventListener("mouseup",this._onmouseup)}renderBitcrusherPanel(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - Bitcrusher`)),s.createElement("div",{className:Ze.content},s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.wet,label:"Wet",onChange:t=>{n.wet=t,"Gain"!==i.name&&(i.wet.value=n.wet)}}),s.createElement(fe,{min:1,max:16,toFixed:0,units:"",value:n.bits,label:"Bits",onChange:t=>{n.bits=t,"Gain"!==i.name&&(i.bits.value=n.bits)}})))}return console.error("no such channel"),null}renderChebyshevPanel(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - Chebyshev`)),s.createElement("div",{className:Ze.content},s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.wet,label:"Wet",onChange:t=>{n.wet=t,i.wet.value=n.wet}}),s.createElement(fe,{min:1,max:20,toFixed:0,units:"",value:n.order,label:"Order",onChange:t=>{n.order=t,i.order=n.order}}),s.createElement("div",{className:Ze.row},s.createElement("div",{className:Ze.label},"Oversample"),s.createElement("div",{className:Ze.ratioBtnGroup},s.createElement("div",{className:[Ze.ratioBtn,"none"===n.oversample?Ze.checked:""].join(" "),onClick:()=>{n.oversample="none",i.oversample=n.oversample,this.setState({updateCounter:this.state.updateCounter+1})}},"none"),s.createElement("div",{className:[Ze.ratioBtn,"2x"===n.oversample?Ze.checked:""].join(" "),onClick:()=>{n.oversample="2x",i.oversample=n.oversample,this.setState({updateCounter:this.state.updateCounter+1})}},"2x"),s.createElement("div",{className:[Ze.ratioBtn,"4x"===n.oversample?Ze.checked:""].join(" "),onClick:()=>{n.oversample="4x",i.oversample=n.oversample,this.setState({updateCounter:this.state.updateCounter+1})}},"4x")))))}return console.error("no such channel"),null}renderFilterPanel(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - Filter`)),s.createElement("div",{className:Ze.content},s.createElement(Be,{label:Object(C.e)("Filter"),tone:this.props.tone,inDrawer:!1,filter:i,onTypeChange:t=>{this.props.arrangement.isUsingOfflineCtx||(n.type=t,i.set({type:t}))},onRolloffChange:t=>{this.props.arrangement.isUsingOfflineCtx||(n.rolloff=t,i.set({rolloff:t}))},onQChange:t=>{this.props.arrangement.isUsingOfflineCtx||(n.Q=t,i.set({Q:t}))},onGainChange:t=>{this.props.arrangement.isUsingOfflineCtx||(n.gain=t,i.set({gain:t}))}})))}return console.error("no such channel"),null}renderPingPongDelay(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - PingPongDelay`)),s.createElement("div",{className:Ze.content},s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.wet,label:"Wet",onChange:t=>{n.wet=t,i.wet.value=n.wet}}),s.createElement(fe,{min:0,max:1,toFixed:2,units:"",value:n.delayTime,label:"Delay Time",onChange:t=>{n.delayTime=t,i.delayTime.value=n.delayTime}}),s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.feedback,label:"Feedback",onChange:t=>{n.feedback=t,i.feedback.value=n.feedback}})))}return console.error("no such channel"),null}renderPitchShiftPanel(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - PitchShift`)),s.createElement("div",{className:Ze.content},s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.wet,label:"Wet",onChange:t=>{n.wet=t,i.wet.value=n.wet}}),s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.delayTime,label:"Delay Time",onChange:t=>{n.delayTime=t,i.delayTime.value=n.delayTime}}),s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.feedback,label:"Feedback",onChange:t=>{n.feedback=t,i.feedback.value=n.feedback}}),s.createElement(fe,{min:-24,max:24,toFixed:0,units:"",value:n.pitch,label:"Pitch",onChange:t=>{n.pitch=t,i.pitch=n.pitch}}),s.createElement(fe,{min:.03,max:.1,toFixed:2,units:"",value:n.windowSize,label:"WindowSize",onChange:t=>{n.windowSize=t,i.windowSize=n.windowSize}})))}return console.error("no such channel"),null}renderTremoloPanel(){let t,e=-1;for(let n=0;n{this.setState({opendedPanel:void 0})}},"X"),s.createElement("h3",null,`Channel ${e} - Tremolo`)),s.createElement("div",{className:Ze.content},s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.wet,label:"Wet",onChange:t=>{n.wet=t,i.wet.value=n.wet}}),s.createElement(_e,{label:Object(C.e)("Type"),style:{paddingTop:"10px"}},s.createElement("select",{value:n.type,onChange:t=>{n.type=t.target.value,i.type=n.type,this.setState({updateCounter:this.state.updateCounter+1})}},s.createElement("option",{value:y.h.sine},Object(C.e)(y.h.sine)),s.createElement("option",{value:y.h.square},Object(C.e)(y.h.square)),s.createElement("option",{value:y.h.sawtooth},Object(C.e)(y.h.sawtooth)),s.createElement("option",{value:y.h.triangle},Object(C.e)(y.h.triangle)))),s.createElement(fe,{min:1,max:40,toFixed:0,units:"",value:n.frequency,label:"Freuency",onChange:t=>{n.frequency=t,i.frequency.value=n.frequency}}),s.createElement(fe,{min:0,max:1,toFixed:1,units:"",value:n.depth,label:"Depth",onChange:t=>{n.depth=t,i.depth.value=n.depth}})))}return console.error("no such channel"),null}render(){const t=void 0!==this.state.opendedPanel;return s.createElement("div",{className:[Ze.effectSettingContainer,t?Ze.fill:""].join(" ")},this.state.opendedPanel===g.f.BitCrusher?this.renderBitcrusherPanel():null,this.state.opendedPanel===g.f.Chebyshev?this.renderChebyshevPanel():null,this.state.opendedPanel===g.f.Filter?this.renderFilterPanel():null,this.state.opendedPanel===g.f.PingPongDelay?this.renderPingPongDelay():null,this.state.opendedPanel===g.f.PitchShift?this.renderPitchShiftPanel():null,this.state.opendedPanel===g.f.Tremolo?this.renderTremoloPanel():null)}}var $e=n(19);const tn=n(1411);function en(t){const e=Object(s.useRef)("constructing"),[n,i]=Object(s.useState)(!1);return Object(s.useEffect)(()=>{e.current="mounted",i(!0)},[]),s.createElement("div",{onTransitionEnd:()=>{"willUnmount"===e.current&&t.cancel(),e.current},className:[tn.gridContainer,tn.generalConfirmDialog,n?tn.show:tn.hide].join(" ")},s.createElement("div",{className:[tn.Content].join(" ")},s.createElement("div",{className:[tn.ContentText].join(" ")},t.contentText)),s.createElement("div",{className:[tn.Confirm].join(" "),onClick:()=>{t.confirm()}},s.createElement("div",{className:[tn.btnLabel].join(" ")},Object(C.e)("confirm"))),s.createElement("div",{className:[tn.Cancel].join(" "),onClick:()=>{e.current="willUnmount",i(!1)}},s.createElement("div",{className:[tn.btnLabel].join(" ")},Object(C.e)("cancel"))))}var nn=n(79),sn=n(62),on=(t,e,n)=>new Promise((s,i)=>{var o=t=>{try{a(n.next(t))}catch(t){i(t)}},r=t=>{try{a(n.throw(t))}catch(t){i(t)}},a=t=>t.done?s(t.value):Promise.resolve(t.value).then(o,r);a((n=n.apply(t,e)).next())});const rn=n(1411);function an(t,e){!function(t,e){const n=t.width,s=t.height,i=t.getContext("2d");if(i){i.save(),i.strokeStyle="#010101",i.translate(0,s/2),i.globalAlpha=1,i.lineWidth=1;const t=e.length,r=Math.floor(t/180),a=n/180;i.beginPath();for(var o=0;o<=180;o++){const t=Math.floor(r*o),n=o*a,l=e[t]*s/2;i.moveTo(n,l),i.lineTo(n,-1*l)}i.stroke(),i.restore()}}(e,t.getChannelData(0))}function ln(t,e){const n=[],s=[];for(let t=0;t<3;t++)n[t]=Math.floor(256*Math.random()),s[t]=Math.floor(256*Math.random());t.width;const i=t.height,o=t.getContext("2d"),r=Math.floor(i/e);if(o){const t=(n[0]-s[0])/(e-1),i=(n[1]-s[1])/(e-1),l=(n[2]-s[2])/(e-1);for(let s=0;s{if(!t)return n(new Error("getImageBuffer: canvas is not init"));t.toBlob(t=>{if(!t)return n(new Error("getImageBuffer: blob is null"));const s=new FileReader;s.onload=t=>{e(t.target.result)},s.readAsArrayBuffer(t)},"image/jpeg",1)})}(i),a=yield t.apiUtils.uploadImage(r,nn.b.contentThumbnailUpload);try{if(-1===o||void 0===o){const n=yield t.apiUtils.firstTimeSaveProjectToServer({projectData:e,describe:t.arrangement.projecInfo.description,image:a});n&&n.content_id&&(t.arrangement.projecInfo.content_id=n.content_id),t.updateCurrentSavedProject()}else{yield t.apiUtils.updateProjectToServer({projectData:e,describe:t.arrangement.projecInfo.description,image:a,content_id:o});t.updateCurrentSavedProject()}y({is_success:!0,fail_reason:"",music_name:e.projectName,music_ID:""+o})}catch(t){return $e.a.error(t),l(!1),void y({is_success:!1,fail_reason:t,music_name:e.projectName,music_ID:""+o})}const c=t.arrangement.projecInfo.content_id;try{yield t.apiUtils.brpc.content.api.publish({content_id:c,audio_hash:u.current,duration:Math.floor(1e3*((null==(s=n.current)?void 0:s.duration)||0))});$e.a.success(Object(C.e)("PublishSuccessed")),l(!1),t.cancel()}catch(t){return console.error("publish error:",t),$e.a.error(Object(C.e)("PublishingError")),void l(!1)}}}}))}Object(s.useEffect)(()=>{const s=t.arrangement.preservedBlobData;if(s){i.current="mounted",r(!0),function(){return on(this,null,(function*(){const i=e.current;if(i&&(i.width=180,i.height=180,s)){ln(i,60);const e=yield s.arrayBuffer();n.current=yield t.arrangement.decodeAudioData(e),n.current&&an(n.current,i)}}))}().then(()=>{}).catch(t=>{console.error(t)}),s&&(h(1),t.apiUtils.uploadPrepublishAudioData(s,t=>{u.current=t,h(2)},()=>{$e.a.error(Object(C.e)("UploadFailed")),h(3)}))}t.apiUtils.queryRemainingPublishedNumber().then(t=>{null!==t&&_(t+"")}).catch(t=>{console.error(t)})},[]),Object(s.useEffect)(()=>{2===c&&""!==u.current&&!0===a&&v().catch(t=>{console.error(t)})},[c]),Object(s.useEffect)(()=>{2===c&&""!==u.current&&v().catch(t=>{console.error(t)})},[a]);const b=()=>{t.onPorjectNameChange(p),setTimeout(()=>{d(t.arrangement.projecInfo.projectName)},200)},y=t=>{(new sn.a).track(sn.c.MUSIC_PUBLISH,t)};return s.createElement("div",{onTransitionEnd:()=>{"willUnmount"===i.current&&t.cancel(),i.current},className:[rn.gridContainer,rn.publishDialog,o?rn.show:rn.hide].join(" ")},s.createElement("div",{className:rn.headerBar},s.createElement("div",{className:rn.headerBarTitle},Object(C.e)("PublishMusic")),s.createElement("div",{className:rn.closeButton,onClick:()=>{t.cancel()}},s.createElement("div",{className:rn.icon},s.createElement("div",{className:rn.stick1}),s.createElement("div",{className:rn.stick2})))),s.createElement("div",{className:rn.content},s.createElement("div",{className:rn.publishContentContainer},s.createElement("div",{className:rn.ProjectName},Object(C.e)("Title")),s.createElement("div",{className:rn.NameInput},s.createElement("input",{value:p,onBlur:()=>{b()},onKeyDown:t=>{13==t.keyCode&&b()},onChange:t=>{d(t.target.value)}})),s.createElement("div",{className:rn.BriefTitle},Object(C.e)("Description")),s.createElement("div",{className:rn.BriefInput},s.createElement("textarea",{placeholder:Object(C.e)("TextareaPlaceHolder"),value:m,maxLength:150,onChange:e=>{f(e.target.value),t.arrangement.projecInfo.description=e.target.value}})),s.createElement("div",{className:rn.ImageTitle},Object(C.e)("CoverImage")),s.createElement("div",{className:rn.Image},s.createElement("canvas",{className:rn.coverImageCanvas,ref:e}),s.createElement("div",{className:rn.randomBtn,onClick:()=>{const t=e.current,s=n.current;t&&s&&(ln(t,30),an(s,t))}},s.createElement("div",{className:rn.iconWrapper},s.createElement("div",{className:rn.icon})))),s.createElement("div",{className:rn.ImageDescription}))),s.createElement("div",{className:rn.buttonGroup},s.createElement("div",{className:rn.RemainingPublishedInfo},Object(C.e)("RemainingPublishNumber")+g),s.createElement("div",{className:rn.btnGroupWrapper},s.createElement("div",{className:[rn.publisPanelBtn,rn.cancel].join(" "),onClick:()=>{t.cancel()}},Object(C.e)("cancel")),s.createElement("div",{className:[rn.publisPanelBtn,rn.submit].join(" "),onClick:()=>{const e=t.arrangement.projecInfo.projectName.trim();""!==e&&e!==Object(C.e)("Untitled")?null!=t.arrangement.projecInfo.description&&""!==t.arrangement.projecInfo.description.trim()?l(!0):$e.a.warning(Object(C.e)("CompulsoryDescriptionWaning")):$e.a.warning(Object(C.e)("RequireSuitableName"))}},a?2!==c?Object(C.e)("Uploading"):Object(C.e)("Publishing"):Object(C.e)("submit")))))}var hn=n(58),un=n(509),pn=(t,e,n)=>new Promise((s,i)=>{var o=t=>{try{a(n.next(t))}catch(t){i(t)}},r=t=>{try{a(n.throw(t))}catch(t){i(t)}},a=t=>t.done?s(t.value):Promise.resolve(t.value).then(o,r);a((n=n.apply(t,e)).next())});class dn{constructor(t){this.contentResolver=t.contentResolver,this.backendURL=t.backendURL,this.brpc=t.brpc}uploadAudioData(t,e,n){Object(un.a)(t,nn.b.musicEditorSourceUpload).then(e).catch(()=>n(new Error(Object(C.e)("uploadFailed"))))}uploadPrepublishAudioData(t,e,n){Object(un.a)(t,nn.b.musicEditorPublish).then(e).catch(()=>n(new Error(Object(C.e)("UploadFailed"))))}firstTimeSaveProjectToServer(t){return pn(this,arguments,(function*({projectData:t,image:e,describe:n}){if(this.brpc){const s=(yield this.brpc.auth.api.online({entry:hn.c.website})).data;if(!s)return null;return yield this.brpc.content.api.addMusic({projectData:JSON.stringify(t),name:t.projectName,author_id:s.id,image:e,engine_version:"",describe:n})}return null}))}uploadImage(t,e){return pn(this,null,(function*(){return new Promise((e,n)=>{Object(un.a)(new Blob([t]),nn.b.contentThumbnailUpload).then(t=>{e(t)}).catch(t=>{console.error(t),$e.a.error(Object(C.e)("CoverImageUploadFailed"))})})}))}updateProjectToServer(t){return pn(this,arguments,(function*({projectData:t,image:e,describe:n,content_id:s}){if(this.brpc){const i=(yield this.brpc.auth.api.online({entry:hn.c.website})).data;if(!i)return null;return yield this.brpc.content.api.updateMusic({projectData:JSON.stringify(t),name:t.projectName,author_id:i.id,image:e,engine_version:"",describe:n,content_id:s})}return null}))}queryRemainingPublishedNumber(){return pn(this,null,(function*(){var t;if(this.brpc){return yield null==(t=this.brpc)?void 0:t.content.api.getMusicPublishedQuota()}return null}))}}const mn=n(1596);function fn(t,e){!function(t,e){const n=t.width,s=t.height,i=n/4,o=t.getContext("2d");if(o){o.clearRect(0,0,n,s),o.save(),o.strokeStyle="#fff",o.translate(0,s/2),o.globalAlpha=1,o.lineWidth=3;const t=e.length,a=Math.floor(t/i),l=n/i;o.beginPath();for(var r=0;r<=i;r++){const t=Math.floor(a*r),n=r*l,i=e[t]*s/2;o.moveTo(n,i),o.lineTo(n,-1*i)}o.stroke(),o.restore()}}(e,t.getChannelData(0))}function gn(t){const e=Object(s.useRef)(null),n=Object(s.useRef)(null),i=Object(s.useRef)("constructing"),[o,r]=Object(s.useState)(!1);return Object(s.useEffect)(()=>{const s=t.arrangement.preservedBlobData;if(s){i.current="mounted",r(!0),function(){return i=this,o=null,r=function*(){const i=e.current;if(i&&(i.width=600,i.height=100,s)){const e=yield s.arrayBuffer();n.current=yield t.arrangement.decodeAudioData(e),n.current&&fn(n.current,i)}},new Promise((t,e)=>{var n=t=>{try{a(r.next(t))}catch(t){e(t)}},s=t=>{try{a(r.throw(t))}catch(t){e(t)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(n,s);a((r=r.apply(i,o)).next())});var i,o,r}().then(()=>{}).catch(t=>{console.error(t)})}},[]),s.createElement("div",{className:mn.testDialog,onTransitionEnd:()=>{i.current,i.current}},s.createElement("canvas",{className:mn.coverImageCanvas,ref:e}))}var _n=Object.defineProperty,vn=Object.defineProperties,bn=Object.getOwnPropertyDescriptors,yn=Object.getOwnPropertySymbols,wn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,Sn=(t,e,n)=>e in t?_n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Cn=(t,e)=>{for(var n in e||(e={}))wn.call(e,n)&&Sn(t,n,e[n]);if(yn)for(var n of yn(e))xn.call(e,n)&&Sn(t,n,e[n]);return t},kn=(t,e)=>vn(t,bn(e)),En=(t,e,n)=>new Promise((s,i)=>{var o=t=>{try{a(n.next(t))}catch(t){i(t)}},r=t=>{try{a(n.throw(t))}catch(t){i(t)}},a=t=>t.done?s(t.value):Promise.resolve(t.value).then(o,r);a((n=n.apply(t,e)).next())});const Pn=n(1597);class Tn extends s.Component{constructor(t){super(t),this.currentEditNoteRegion=null,this.currentEditChannel=null,this.exportBtnRef=s.createRef(),this.publishBtnRef=s.createRef(),this.duringPublishProcess=!1,this.previouseServerSavedProject=JSON.stringify({channelList:[],audioMetaData:{},audioFiles:[],transportRange:[0,7680],bpm:120,projectName:Object(C.e)("Untitled")}),this.onbeforeunload=t=>{(t=window.event||t).returnValue="确定离开当前页面吗?"},this.onProjectNameInit=t=>{this.setState({projectName:t})},this.onKeydown=t=>{t.target&&"INPUT"===t.target.tagName||t.target&&"TEXTAREA"===t.target.tagName||8==t.keyCode&&(t.preventDefault(),t.stopPropagation())},this.onOfflineRendering=(t,e)=>{this.setState({offlineRenderingState:t}),t==g.e.encoding&&this.exportBtnRef.current&&(this.exportBtnRef.current.innerText=(100*e).toFixed(2)+"%"),t==g.e.failed&&(console.warn(e),setTimeout(()=>{this.setState({offlineRenderingState:g.e.finished})},2e3))},this.prePublishingRendering=(t,e)=>{t!==this.state.prePubRenderingState&&this.setState({prePubRenderingState:t}),t===g.e.encoding&&this.publishBtnRef.current&&(this.publishBtnRef.current.innerText=(100*e).toFixed(2)+"%"),t===g.e.failed&&($e.a.error(Object(C.e)("renderingFailed")),this.duringPublishProcess=!1,this.arrangement.preserveBlobForPublishing=!1,setTimeout(()=>{this.setState({prePubRenderingState:g.e.finished})},2e3)),t===g.e.finished&&(this.duringPublishProcess=!1,this.arrangement.preserveBlobForPublishing=!1,this.setState({showDialog:3}))},this.reporter=t=>{(new sn.a).track(sn.c.MUSIC_SAVE,t)},this.tone=o,this.state={selectInstrument:0,instrumentSetting:0,pianoKeyboard:!1,currentEditChannelId:"",rightPanelOpen:!1,offlineRenderingState:g.e.finished,prePubRenderingState:g.e.finished,projectName:Object(C.e)("Untitled"),showDialog:5},this.brpc=t.brpc,this.backendURL=t.backendURL,this.apiUtils=new dn({backendURL:this.backendURL,brpc:this.brpc,contentResolver:t.content}),this.arrangement=new g.a(this.tone,this.props.content,this.apiUtils)}componentDidMount(){const t=()=>En(this,null,(function*(){yield this.arrangement.ctx.resume(),document.removeEventListener("click",t)}));window.addEventListener("beforeunload",this.onbeforeunload),document.body.style.overscrollBehavior="contain",document.addEventListener("click",t),document.addEventListener("keydown",this.onKeydown),this.arrangement.addListener(g.b.initializeProjectName,this.onProjectNameInit)}componentWillUnmount(){window.removeEventListener("beforeunload",this.onbeforeunload),document.body.style.overscrollBehavior="initial",document.removeEventListener("keydown",this.onKeydown),this.arrangement.removeListener(g.b.initializeProjectName,this.onProjectNameInit)}loadProjectDataFromServer(t){this.props.content.retrieve(t.hash).then(e=>{if(this.arrangement.projecInfo.content_id=t.content_id,this.arrangement.projecInfo.description=t.description,!e)throw new Error("the data is void");{this.arrangement.importFormDAWFile((new TextDecoder).decode(e));const t=this.arrangement.getProjectData();this.previouseServerSavedProject=JSON.stringify(t)}}).catch(t=>{$e.a.error(Object(C.e)("retrieveProjectFailed")),console.error(t)})}_openFileClick(t){if(1===this.openFileInput.files.length){const t=this.openFileInput.files[0];if(!t)return;switch(t.name.substr(t.name.lastIndexOf("."))){case".daw":const e=new FileReader;e.onload=t=>{this.arrangement.importFormDAWFile(t.target.result)},e.readAsText(t)}}this.openFileInput.files=void 0,this.openFileInput.value=""}checkNameContainInvalidSymbol(t){for(let e=0;e<='<>:"/\\|?*`'.length;e++)if(t.indexOf('<>:"/\\|?*`'[e])>-1)return!0;return!1}renderExportBtn(){return this.state.offlineRenderingState===g.e.finished?s.createElement("div",{className:Pn.icon}):this.state.offlineRenderingState===g.e.rendering?Object(C.e)("Rendering")+"...":this.state.offlineRenderingState===g.e.encoding?Object(C.e)("Encoding")+"...":Object(C.e)("Failed")+" !"}renderPublishText(){return this.state.prePubRenderingState===g.e.finished?Object(C.e)("publish"):this.state.prePubRenderingState===g.e.rendering?Object(C.e)("Rendering")+"...":this.state.prePubRenderingState===g.e.encoding?Object(C.e)("Encoding")+"...":Object(C.e)("Failed")+" !"}renderProjectTools(){return s.createElement("div",{className:Pn.projectTools},s.createElement("div",{className:[Pn.tooltipWrapper].join(" ")},s.createElement("div",{className:[Pn.publishBtn].join(" "),onClick:()=>{const t=this.arrangement.getProjectData();if(0==t.channelList.length)return void $e.a.warning(Object(C.e)("CannotPiublishEmptyProject"));let e=!0;for(let n=0;n{if(this.checkNameContainInvalidSymbol(t.target.value))return t.preventDefault(),void $e.a.warning(Object(C.e)("containInvalidSymbol")+' <>:"/\\|?*`');this.setState({projectName:t.target.value},()=>{this.arrangement.projecInfo.projectName=this.state.projectName})}})),s.createElement("div",{className:[Pn.tooltipWrapper,this.state.offlineRenderingState!==g.e.finished?Pn.disable:""].join(" ")},s.createElement("div",{className:[Pn.ProjectButton,Pn.Download].join(" ")},s.createElement("span",{ref:this.exportBtnRef},this.renderExportBtn()),s.createElement("div",{className:Pn.buttonSublist},s.createElement("div",{className:Pn.btn,onClick:()=>{this.arrangement.exportToDAWFile()}},s.createElement("div",null,Object(C.e)("ProjectFile"))),s.createElement("div",{className:Pn.btn,onClick:()=>{this.duringPublishProcess?$e.a.warning(Object(C.e)("renderingPreparation")):(this.arrangement.preserveBlobForPublishing=!1,this.arrangement.exportToAudioFile(Qe.a.MP3,this.onOfflineRendering))}},s.createElement("div",null,"192kbps mp3")),s.createElement("div",{className:Pn.btn,onClick:()=>{this.duringPublishProcess?$e.a.warning(Object(C.e)("renderingPreparation")):(this.arrangement.preserveBlobForPublishing=!1,this.arrangement.exportToAudioFile(Qe.a.WAV,this.onOfflineRendering))}},s.createElement("div",null,"16bit wav"))))),s.createElement("div",{className:Pn.tooltipWrapper},s.createElement("div",{className:[Pn.ProjectButton,Pn.Save].join(" "),onClick:()=>{this.setState({showDialog:4})}},s.createElement("div",{className:Pn.icon}))),s.createElement("div",{className:Pn.tooltipWrapper},s.createElement("div",{className:[Pn.ProjectButton,Pn.Open].join(" "),onClick:()=>{JSON.stringify(this.arrangement.getProjectData())!==this.previouseServerSavedProject?this.setState({showDialog:2}):this.openFileInput.click()}},s.createElement("input",{type:"file",id:"project-file-input",style:{visibility:"hidden",display:"none",pointerEvents:"none",width:0,height:0},accept:".daw",ref:t=>{this.openFileInput=t},onChange:t=>{this._openFileClick(t)}}),s.createElement("div",{className:Pn.icon}))),s.createElement("div",{className:Pn.tooltipWrapper},s.createElement("div",{className:[Pn.ProjectButton,Pn.Exit].join(" "),onClick:()=>{JSON.stringify(this.arrangement.getProjectData())!==this.previouseServerSavedProject?this.setState({showDialog:1}):this.setState({showDialog:0})}},s.createElement("div",{className:Pn.icon}))))}render(){var t;return s.createElement("div",{className:Pn.DAWMain},this.renderProjectTools(),s.createElement(te,{tone:this.tone,arrangement:this.arrangement,pianoKeyboardOpen:this.state.pianoKeyboard,rightPanelOpen:this.state.rightPanelOpen,openNoteEditTool:(t,e)=>{const n=t.instrument.config.type;n===g.d.SimpleSynth||n===g.d.MonoSynth||n===g.d.AmSynth||n===g.d.FmSynth||n===g.d.Sampler||n===g.d.GeneralMidiSynth&&!1===t.instrument.config.data.isPercussion?(this.currentEditNoteRegion=e,this.currentEditChannel=t,this.setState({selectInstrument:2,currentEditChannelId:t.id})):(n===g.d.DrumMachine||n===g.d.GeneralMidiSynth&&!0===t.instrument.config.data.isPercussion)&&(this.currentEditNoteRegion=e,this.currentEditChannel=t,this.setState({selectInstrument:4,currentEditChannelId:t.id}))},openKeyborad:t=>{this.currentEditChannel=t,this.setState({pianoKeyboard:!0,currentEditChannelId:t.id})},openInstrumentSettingPanel:t=>{this.currentEditChannel=t,t.instrument.config.type!==g.d.SimpleSynth&&t.instrument.config.type!==g.d.AmSynth&&t.instrument.config.type!==g.d.FmSynth&&t.instrument.config.type!==g.d.MonoSynth&&t.instrument.config.type!==g.d.Sampler&&t.instrument.config.type!==g.d.DrumMachine||this.setState({instrumentSetting:1,currentEditChannelId:t.id})},toogleRightPanel:t=>{this.setState({rightPanelOpen:t})}}),s.createElement(Ke,{arrangement:this.arrangement,isPanelOpen:this.state.rightPanelOpen,onTogglePanel:t=>{this.setState({rightPanelOpen:t})}}),0!==this.state.selectInstrument&&null!==this.currentEditNoteRegion?s.createElement("div",{className:Pn.popupBG}):null,2===this.state.selectInstrument&&null!==this.currentEditNoteRegion?s.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",height:"90%",width:"90%",background:"rgba(0, 0, 0, 0.95)",zIndex:20}},s.createElement(I,{tone:this.tone,region:this.currentEditNoteRegion,channel:this.currentEditChannel,arrangement:this.arrangement,close:()=>{this.setState({selectInstrument:0})}})):"",4===this.state.selectInstrument&&null!==this.currentEditNoteRegion?s.createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",height:(null==(t=this.currentEditChannel)?void 0:t.instrument.config.type)===g.d.GeneralMidiSynth?"90%":"477px",width:"90%",background:"rgba(0, 0, 0, 0.95)",zIndex:20}},s.createElement(he,{tone:this.tone,region:this.currentEditNoteRegion,channel:this.currentEditChannel,arrangement:this.arrangement,close:()=>{this.setState({selectInstrument:0})}})):"",!0===this.state.pianoKeyboard&&this.currentEditChannel&&this.arrangement.instruments[this.currentEditChannel.id]?s.createElement("div",{className:Pn.container},s.createElement(v,{tone:this.tone,arrangement:this.arrangement,channel:this.currentEditChannel,currentEditChannelId:this.state.currentEditChannelId,closePanel:()=>this.setState({pianoKeyboard:!1})})):"",1===this.state.instrumentSetting&&this.currentEditChannel?s.createElement("div",{style:{position:"absolute",top:"73px",right:this.state.rightPanelOpen?"326px":"46px",width:"350px",height:"70%",zIndex:10}},s.createElement(We,{tone:this.tone,arrangement:this.arrangement,channel:this.currentEditChannel,currentEditChannelId:this.state.currentEditChannelId,close:()=>{this.setState({instrumentSetting:0})}})):"",s.createElement(Je,{tone:this.tone,arrangement:this.arrangement}),0==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(en,{contentText:Object(C.e)("ExitConfirmText"),cancel:()=>{this.setState({showDialog:5})},confirm:()=>{this.props.onClose(),this.arrangement.stop(),this.arrangement.composoryToStopRecording()}})):null,4==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(en,{contentText:Object(C.e)("SaveConfirmText"),cancel:()=>{this.setState({showDialog:5})},confirm:()=>En(this,null,(function*(){const t=this.arrangement.getProjectData(),e=this.arrangement.projecInfo.content_id;let n={is_success:!1,fail_reason:"",is_first_save:!1,music_name:"",music_ID:""};if(-1===e||void 0===e){const e=yield this.apiUtils.firstTimeSaveProjectToServer({projectData:t,describe:this.arrangement.projecInfo.description,image:""});e&&e.content_id&&(this.arrangement.projecInfo.content_id=e.content_id),n=kn(Cn({},n),{is_success:!!e,is_first_save:!0,music_name:(null==t?void 0:t.projectName)||"",music_ID:""})}else{const s=yield this.apiUtils.updateProjectToServer({projectData:t,describe:this.arrangement.projecInfo.description,image:"",content_id:e});n=kn(Cn({},n),{is_success:!!s,is_first_save:!1,music_name:(null==t?void 0:t.projectName)||"",music_ID:""+e})}this.reporter(n),this.previouseServerSavedProject=JSON.stringify(t),this.setState({showDialog:5})}))})):null,1==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(en,{contentText:Object(C.e)("UnSavedExitConfirmText"),cancel:()=>{this.setState({showDialog:5})},confirm:()=>{this.props.onClose(),this.arrangement.stop(),this.arrangement.composoryToStopRecording()}})):null,2==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(en,{contentText:Object(C.e)("UnSavedOpenConfirmText"),cancel:()=>{this.setState({showDialog:5})},confirm:()=>{this.openFileInput.click(),this.setState({showDialog:5})}})):null,3==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(cn,{arrangement:this.arrangement,apiUtils:this.apiUtils,onPorjectNameChange:t=>{this.checkNameContainInvalidSymbol(t)?$e.a.warning(Object(C.e)("containInvalidSymbol")+' <>:"/\\|?*`'):this.setState({projectName:t},()=>{this.arrangement.projecInfo.projectName=this.state.projectName})},updateCurrentSavedProject:()=>{const t=this.arrangement.getProjectData();this.previouseServerSavedProject=JSON.stringify(t)},cancel:()=>{this.setState({showDialog:5})}})):null,6==this.state.showDialog?s.createElement("div",{className:Pn.popupBG},s.createElement(gn,{arrangement:this.arrangement})):null)}}var Mn=n(42);class Rn extends i.a.Component{constructor(t){super(t),this.dawRef=i.a.createRef(),this.sensorsReporter=t=>{(new sn.a).track(sn.c.OPEN_MUSIC_EDITOR,t)}}componentDidMount(){const{loadMusicProject:t}=this.props;this.sensorsReporter({is_first_open:!t,music_name:(null==t?void 0:t.name)||"",music_ID:""+(null==t?void 0:t.content_id)||""}),this.dawRef.current&&this.props.loadMusicProject&&this.dawRef.current.loadProjectDataFromServer(this.props.loadMusicProject)}componentDidUpdate(t,e){var n,s,i,o;(null==(n=t.loadMusicProject)?void 0:n.content_id)===(null==(s=this.props.loadMusicProject)?void 0:s.content_id)&&(null==(i=t.loadMusicProject)?void 0:i.hash)===(null==(o=this.props.loadMusicProject)?void 0:o.hash)||this.dawRef.current&&this.props.loadMusicProject&&this.dawRef.current.loadProjectDataFromServer(this.props.loadMusicProject)}render(){return i.a.createElement(Tn,{ref:this.dawRef,brpc:this.props.brpc,backendURL:Mn.b.backendURL,onClose:this.props.onClose,content:this.props.content})}}}}]);