@opendaw/studio-core 0.0.40 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EngineWorklet.d.ts.map +1 -1
- package/dist/EngineWorklet.js +18 -1
- package/dist/FilePickerAcceptTypes.d.ts +1 -0
- package/dist/FilePickerAcceptTypes.d.ts.map +1 -1
- package/dist/FilePickerAcceptTypes.js +6 -0
- package/dist/InstrumentBox.d.ts +2 -2
- package/dist/InstrumentBox.d.ts.map +1 -1
- package/dist/InstrumentFactories.d.ts +13 -4
- package/dist/InstrumentFactories.d.ts.map +1 -1
- package/dist/InstrumentFactories.js +38 -18
- package/dist/InstrumentFactory.d.ts +3 -2
- package/dist/InstrumentFactory.d.ts.map +1 -1
- package/dist/InstrumentOptions.d.ts +2 -1
- package/dist/InstrumentOptions.d.ts.map +1 -1
- package/dist/OpenDAWHeaders.d.ts +3 -0
- package/dist/OpenDAWHeaders.d.ts.map +1 -0
- package/dist/OpenDAWHeaders.js +8 -0
- package/dist/RecordingWorklet.js +1 -1
- package/dist/Storage.d.ts +14 -0
- package/dist/Storage.d.ts.map +1 -0
- package/dist/Storage.js +32 -0
- package/dist/capture/index.d.ts +6 -0
- package/dist/capture/index.d.ts.map +1 -0
- package/dist/capture/index.js +5 -0
- package/dist/cloud/CloudAuthManager.d.ts.map +1 -0
- package/dist/{clouds → cloud}/CloudBackup.d.ts +1 -1
- package/dist/cloud/CloudBackup.d.ts.map +1 -0
- package/dist/{clouds → cloud}/CloudBackup.js +6 -4
- package/dist/cloud/CloudBackupProjects.d.ts.map +1 -0
- package/dist/cloud/CloudBackupSamples.d.ts.map +1 -0
- package/dist/{clouds → cloud}/CloudBackupSamples.js +5 -6
- package/dist/cloud/CloudBackupSoundfont.d.ts +13 -0
- package/dist/cloud/CloudBackupSoundfont.d.ts.map +1 -0
- package/dist/cloud/CloudBackupSoundfont.js +120 -0
- package/dist/cloud/CloudHandler.d.ts.map +1 -0
- package/dist/cloud/CloudService.d.ts.map +1 -0
- package/dist/cloud/DropboxHandler.d.ts.map +1 -0
- package/dist/cloud/GoogleDriveHandler.d.ts.map +1 -0
- package/dist/cloud/index.d.ts +4 -0
- package/dist/cloud/index.d.ts.map +1 -0
- package/dist/cloud/index.js +3 -0
- package/dist/dawproject/DawProjectExporter.test.js +2 -1
- package/dist/dawproject/DawProjectService.d.ts +11 -0
- package/dist/dawproject/DawProjectService.d.ts.map +1 -0
- package/dist/dawproject/DawProjectService.js +63 -0
- package/dist/dawproject/index.d.ts +5 -0
- package/dist/dawproject/index.d.ts.map +1 -0
- package/dist/dawproject/index.js +4 -0
- package/dist/index.d.ts +11 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -32
- package/dist/midi/index.d.ts +3 -0
- package/dist/midi/index.d.ts.map +1 -0
- package/dist/midi/index.js +2 -0
- package/dist/processors.js +3 -3
- package/dist/processors.js.map +4 -4
- package/dist/project/Project.d.ts +2 -1
- package/dist/project/Project.d.ts.map +1 -1
- package/dist/project/Project.js +1 -0
- package/dist/project/ProjectApi.d.ts +1 -1
- package/dist/project/ProjectApi.d.ts.map +1 -1
- package/dist/project/ProjectApi.js +3 -2
- package/dist/project/ProjectBundle.d.ts.map +1 -1
- package/dist/project/ProjectBundle.js +67 -18
- package/dist/project/ProjectEnv.d.ts +2 -1
- package/dist/project/ProjectEnv.d.ts.map +1 -1
- package/dist/project/ProjectStorage.d.ts +3 -2
- package/dist/project/ProjectStorage.d.ts.map +1 -1
- package/dist/project/ProjectStorage.js +2 -3
- package/dist/project/index.d.ts +10 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/index.js +9 -0
- package/dist/samples/DefaultSampleLoader.js +2 -2
- package/dist/samples/OpenSampleAPI.d.ts.map +1 -1
- package/dist/samples/OpenSampleAPI.js +4 -11
- package/dist/samples/SampleService.d.ts +18 -0
- package/dist/samples/SampleService.d.ts.map +1 -0
- package/dist/samples/SampleService.js +82 -0
- package/dist/samples/SampleStorage.d.ts +11 -10
- package/dist/samples/SampleStorage.d.ts.map +1 -1
- package/dist/samples/SampleStorage.js +32 -39
- package/dist/samples/index.d.ts +1 -2
- package/dist/samples/index.d.ts.map +1 -1
- package/dist/samples/index.js +1 -2
- package/dist/soundfont/DefaultSoundfontLoader.d.ts +15 -0
- package/dist/soundfont/DefaultSoundfontLoader.d.ts.map +1 -0
- package/dist/soundfont/DefaultSoundfontLoader.js +69 -0
- package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts +11 -0
- package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts.map +1 -0
- package/dist/soundfont/DefaultSoundfontLoaderManager.js +17 -0
- package/dist/soundfont/OpenSoundfontAPI.d.ts +13 -0
- package/dist/soundfont/OpenSoundfontAPI.d.ts.map +1 -0
- package/dist/soundfont/OpenSoundfontAPI.js +63 -0
- package/dist/soundfont/SoundfontProvider.d.ts +6 -0
- package/dist/soundfont/SoundfontProvider.d.ts.map +1 -0
- package/dist/soundfont/SoundfontService.d.ts +20 -0
- package/dist/soundfont/SoundfontService.d.ts.map +1 -0
- package/dist/soundfont/SoundfontService.js +98 -0
- package/dist/soundfont/SoundfontStorage.d.ts +21 -0
- package/dist/soundfont/SoundfontStorage.d.ts.map +1 -0
- package/dist/soundfont/SoundfontStorage.js +40 -0
- package/dist/soundfont/index.d.ts +7 -0
- package/dist/soundfont/index.d.ts.map +1 -0
- package/dist/soundfont/index.js +6 -0
- package/dist/sync-log/index.d.ts +4 -0
- package/dist/sync-log/index.d.ts.map +1 -0
- package/dist/sync-log/index.js +3 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/workers-main.js +2 -2
- package/dist/workers-main.js.map +3 -3
- package/dist/ysync/YMapper.d.ts.map +1 -0
- package/dist/{yjs → ysync}/YService.d.ts +1 -2
- package/dist/ysync/YService.d.ts.map +1 -0
- package/dist/{yjs → ysync}/YService.js +1 -1
- package/dist/ysync/YSync.d.ts.map +1 -0
- package/dist/{yjs → ysync}/YSync.js +1 -1
- package/dist/ysync/index.d.ts +4 -0
- package/dist/ysync/index.d.ts.map +1 -0
- package/dist/ysync/index.js +3 -0
- package/package.json +16 -18
- package/dist/clouds/CloudAuthManager.d.ts.map +0 -1
- package/dist/clouds/CloudBackup.d.ts.map +0 -1
- package/dist/clouds/CloudBackupProjects.d.ts.map +0 -1
- package/dist/clouds/CloudBackupSamples.d.ts.map +0 -1
- package/dist/clouds/CloudHandler.d.ts.map +0 -1
- package/dist/clouds/CloudService.d.ts.map +0 -1
- package/dist/clouds/DropboxHandler.d.ts.map +0 -1
- package/dist/clouds/GoogleDriveHandler.d.ts.map +0 -1
- package/dist/samples/P2PSampleProvider.d.ts +0 -13
- package/dist/samples/P2PSampleProvider.d.ts.map +0 -1
- package/dist/samples/P2PSampleProvider.js +0 -350
- package/dist/samples/SampleImporter.d.ts +0 -11
- package/dist/samples/SampleImporter.d.ts.map +0 -1
- package/dist/yjs/YMapper.d.ts.map +0 -1
- package/dist/yjs/YService.d.ts.map +0 -1
- package/dist/yjs/YSync.d.ts.map +0 -1
- /package/dist/{clouds → cloud}/CloudAuthManager.d.ts +0 -0
- /package/dist/{clouds → cloud}/CloudAuthManager.js +0 -0
- /package/dist/{clouds → cloud}/CloudBackupProjects.d.ts +0 -0
- /package/dist/{clouds → cloud}/CloudBackupProjects.js +0 -0
- /package/dist/{clouds → cloud}/CloudBackupSamples.d.ts +0 -0
- /package/dist/{clouds → cloud}/CloudHandler.d.ts +0 -0
- /package/dist/{clouds → cloud}/CloudHandler.js +0 -0
- /package/dist/{clouds → cloud}/CloudService.d.ts +0 -0
- /package/dist/{clouds → cloud}/CloudService.js +0 -0
- /package/dist/{clouds → cloud}/DropboxHandler.d.ts +0 -0
- /package/dist/{clouds → cloud}/DropboxHandler.js +0 -0
- /package/dist/{clouds → cloud}/GoogleDriveHandler.d.ts +0 -0
- /package/dist/{clouds → cloud}/GoogleDriveHandler.js +0 -0
- /package/dist/{samples/SampleImporter.js → soundfont/SoundfontProvider.js} +0 -0
- /package/dist/{yjs → ysync}/YMapper.d.ts +0 -0
- /package/dist/{yjs → ysync}/YMapper.js +0 -0
- /package/dist/{yjs → ysync}/YSync.d.ts +0 -0
package/dist/processors.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
var di=i=>i,T=i=>i!=null,Zt=i=>i===null;var Un=i=>i===void 0;var Kn=i=>i==null,tn=(i,e)=>i!=null?e(i):void 0,k=(i,e="asDefined failed")=>i??g(tr(e)),ae=(i,e)=>i instanceof e,er=(i,e)=>i instanceof e?i:g(`${i} is not instance of ${e}`),rn=(i,e)=>{i instanceof e||g(`${i} is not instance of ${e}`)};var tr=i=>i instanceof Function?i():i;var x=(i,...e)=>i?.apply(null,e),vt=i=>T(i)&&typeof i=="object",sn=(i,e,t)=>{if(!(e in i))return!1;let r=i[e];return t==="null"?r===null:typeof r===t},Ln=(i,...e)=>{let t=i;for(let r of e){if(!vt(t)||!(r in t))return;t=t[r]}return t},Ge=i=>{throw new Error(`Unhandled ${i}`)},g=i=>{throw typeof i=="string"?new Error(i):i},v=(i,e)=>i?void 0:g(tr(e));var on=i=>new Proxy({},{get(){return g(i)}});var rr=i=>{try{return{error:null,value:i(),status:"success"}}catch(e){return{error:e,value:null,status:"failure"}}};var $n=(i,e)=>Object.keys(e).length===0?g("Empty enum object (are you using `const enum`?)"):Object.keys(e).filter(s=>isNaN(Number(s))).map(s=>e[s]).includes(i)?i:g(`Invalid enum value: ${String(i)}`),nt=()=>{};var qn=i=>{};var nn;(function(i){i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(nn||(nn={}));var w=class{static#e=Object.freeze(new Array(0));static empty=()=>this.#e;static clear=e=>{e.length=0};static replace=(e,t)=>{e.length=0,e.push(...t)};static consume=(e,t)=>{for(let r=0;r<e.length;)t(e[r])?e.splice(r,1):r++};static peekFirst=e=>e.at(0)??null;static peekLast=e=>e.at(-1)??null;static getFirst=(e,t)=>k(e.at(0),t);static getLast=(e,t)=>k(e.at(-1),t);static getPrev=(e,t)=>{let r=e.indexOf(t);return r===-1?g(`${t} not found in ${e}`):k(e.at((r-1)%e.length),"Internal Error")};static getNext=(e,t)=>{let r=e.indexOf(t);return r===-1?g(`${t} not found in ${e}`):k(e.at((r+1)%e.length),"Internal Error")};static removeLast=(e,t)=>k(e.pop(),t);static create=(e,t)=>{let r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s);return r};static equals=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};static satisfy=(e,t)=>{if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++)if(!t(r,e[s]))return!1;return!0};static remove=(e,t)=>{let r=e.indexOf(t);if(r===-1)return g(`${t} not found in ${e}`);e.splice(r,1)};static removeIf=(e,t)=>{for(let r=e.length-1;r>=0;r--)t(e[r])&&e.splice(r,1)};static removeOpt=(e,t)=>{let r=e.indexOf(t);return r===-1?!1:(e.splice(r,1),!0)};static hasDuplicates=e=>new Set(e).size<e.length;static removeDuplicates=e=>{let t=0,r=new Set;for(let s of e)r.has(s)||(r.add(s),e[t++]=s);return e.length=t,e};static removeDuplicateKeys=(e,t)=>{let r=0,s=new Set;for(let o of e){let n=o[t];s.has(n)||(s.add(n),e[r++]=o)}return e.length=r,e};static subtract(e,t,r){return e.filter(s=>!t.some(o=>r(s,o)))}static intersect(e,t,r){return e.filter(s=>t.some(o=>r(s,o)))}static merge(e,t,r){return[...e.filter(s=>!t.some(o=>r(s,o))),...t]}static*iterate(e){for(let t=0;t<e.length;t++)yield e[t]}static*iterateReverse(e){for(let t=e.length-1;t>=0;t--)yield e[t]}static*iterateStateFull(e){let t=e.length-1;for(let r=0;r<=t;r++)yield{value:e[r],isFirst:r===0,isLast:r===t}}static*iterateAdjacent(e){if(!(e.length<=1))for(let t=1,r=e[0];t<e.length;t++){let s=e[t];yield[r,s],r=s}}static isSorted(e,t=nn.Ascending){if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++){let o=e[s];if(Math.sign(r-o)===t)return!1;r=o}return!0}};var p;(function(i){i.wrap=t=>T(t)?new e(t):i.None,i.from=t=>i.wrap(t()),i.tryFrom=t=>{try{return i.wrap(t())}catch{return i.None}},i.execute=(t,...r)=>i.wrap(t?.apply(null,r)),i.async=t=>t.then(r=>i.wrap(r),()=>i.None);class e{#e;constructor(r){this.#e=k(r)}unwrap(){return this.#e}unwrapOrElse(r){return this.#e}unwrapOrNull(){return this.#e}unwrapOrUndefined(){return this.#e}contains(r){return r===this.#e}match(r){return r.some(this.#e)}ifSome(r){return r(this.#e)}ifAbsent(r){}isEmpty(){return!1}nonEmpty(){return!0}map(r){return i.wrap(r(this.#e))}mapOr(r,s){return r(this.#e)}flatMap(r){return r(this.#e)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#e})}`}get[Symbol.toStringTag](){return this.toString()}}i.Some=e,i.None=new class{unwrap=t=>g(T(t)?tr(t):"unwrap failed");unwrapOrElse=t=>tr(t);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=t=>!1;match=t=>t.none();ifSome=t=>{};ifAbsent=t=>t(void 0);isEmpty=()=>!0;nonEmpty=()=>!1;map=t=>i.None;mapOr=(t,r)=>tr(r);flatMap=t=>i.None;equals=t=>t.isEmpty();assert=t=>g(tr(t)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(p||(p={}));var zn;(function(i){i.async=e=>e.then(t=>i.ok(t),t=>i.err(t)),i.tryGet=e=>{try{return i.ok(e())}catch(t){return i.err(t)}},i.ok=e=>new class{value;constructor(t){this.value=t}asOption=()=>p.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=t=>{try{return i.ok(t(this.value))}catch(r){return i.err(r)}};flatMap=t=>t(this.value);match=t=>t.ok(this.value);toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(e),i.Ok=new class{constructor(){}asOption=()=>p.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=e=>i.ok(e());flatMap=e=>e();match=e=>e.ok();toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},i.err=e=>new class{reason;constructor(t){this.reason=t}asOption=()=>p.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=t=>t.err(this.reason);toVoid=()=>i.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(e)})(zn||(zn={}));var se;(function(i){i.exact=(e,t,r)=>{let s=0,o=e.length-1;for(;s<=o;){let n=s+o>>>1,a=r(e[n],t);if(a===0)return n;a<0?s=n+1:o=n-1}return-1},i.exactMapped=(e,t,r,s)=>{let o=0,n=e.length-1;for(;o<=n;){let a=o+n>>>1,l=r(s(e[a]),t);if(l===0)return a;l<0?o=a+1:n=a-1}return-1},i.leftMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<0?s=n+1:o=n}return s},i.rightMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<=0?s=n+1:o=n}return o-1},i.leftMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<0?o=a+1:n=a}return o},i.rightMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<=0?o=a+1:n=a}return n-1},i.rangeMapped=(e,t,r,s)=>[i.leftMostMapped(e,t,r,s),i.rightMostMapped(e,t,r,s)]})(se||(se={}));var ye=class{static every=(e,t)=>(e&t)===t;static some=(e,t)=>(e&t)>0;#e;#t;constructor(e=32){this.#e=e,this.#t=new Int32Array((e-1>>>5)+1)}getBit(e){let t=e>>>5,r=1<<e-(t<<5);return(this.#t[t]&r)!==0}setBit(e,t){let r=e>>>5,s=1<<e-(r<<5),o=this.#t[r],n=t?o|s:o&~s;return n===o?!1:(this.#t[r]=n,!0)}isEmpty(){return this.#t.every(e=>e===0)}nonEmpty(){return this.#t.some(e=>e>0)}set buffer(e){this.#t.set(new Int32Array(e))}get buffer(){return this.#t.buffer}replace(e){let t=new Int32Array(e),r=!1;for(let s=0;s<t.length;s++)this.#t[s]!==t[s]&&(this.#t[s]=t[s],r=!0);return r}toString(){let e="";for(let t of w.iterateReverse(this.#t))e+=t.toString(2).padStart(32,"0");return e.substring(e.length-this.#e)}clear(){this.#t.fill(0)}};var Vi=class{#e;#t=null;constructor(e){this.#e=e}invalidate=()=>this.#t=null;get(){return this.#t===null&&(this.#t=this.#e()),this.#t}terminate(){this.invalidate()}};var Di;(function(i){i.parseCssRgbOrRgba=e=>{let t=e.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(T(t)&&t.every(r=>!isNaN(r))){if(t.length===3)return[t[0]/255,t[1]/255,t[2]/255,1];if(t.length===4)return[t[0]/255,t[1]/255,t[2]/255,t[3]]}throw new Error(`${e} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},i.hslToHex=(e,t,r)=>{let s=l=>(l+e/30)%12,o=t*Math.min(r,1-r),n=l=>r-o*Math.max(-1,Math.min(s(l)-3,Math.min(9-s(l),1))),a=l=>Math.round(l*255).toString(16).padStart(2,"0");return`#${a(n(0))}${a(n(8))}${a(n(4))}`},i.hexToHsl=e=>{let t=e.startsWith("#")?e.slice(1):e,r=parseInt(t.slice(0,2),16)/255,s=parseInt(t.slice(2,4),16)/255,o=parseInt(t.slice(4,6),16)/255,n=Math.max(r,s,o),a=Math.min(r,s,o),l=(n+a)/2,c=0,d=0;if(n!==a){let m=n-a;switch(d=l>.5?m/(2-n-a):m/(n+a),n){case r:c=((s-o)/m+(s<o?6:0))*60;break;case s:c=((o-r)/m+2)*60;break;case o:c=((r-s)/m+4)*60;break}}return{h:c,s:d,l}},i.hslStringToHex=e=>{let[t,r,s]=e.match(/\d+(\.\d+)?/g).map(Number);return i.hslToHex(t,r/100,s/100)}})(Di||(Di={}));var bt=(i,e)=>i-e,_n=(i,e)=>{let t=Math.min(i.length,e.length);for(let r=0;r<t;r++){let s=i[r]-e[r];if(s!==0)return s}return i.length-e.length};var We=Math.PI*2,Cl=Math.PI/2,an=Math.PI/4,Rl=1/Math.sqrt(2),$=(i,e,t)=>Math.max(e,Math.min(i,t));var Hn=(i,e)=>e+(1-2*e)*Math.max(0,Math.min(i,1)),at=(i,e)=>Math.floor(i/e)*e;var Gn=(i,e,t)=>i+(e-i)*t;var pi=(i,e)=>il(i/e)*e,il=i=>i-Math.floor(i),lt=i=>Math.pow(2,Math.ceil(Math.log(i)/Math.log(2)));var ln=(i,e)=>i*e/((2*e-1)*(i-1)+e);var Ue;(function(i){i.valueAt=({slope:s,steps:o,y0:n,y1:a},l)=>i.normalizedAt(l/o,s)*(a-n)+n,i.normalizedAt=(s,o)=>{if(o>.499999&&o<.500001)return s;{let n=$(o,1e-15,.999999999999999);return n*n/(1-n*2)*(Math.pow((1-n)/n,2*s)-1)}},i.inverseAt=(s,o)=>{let n=$(o,1e-15,.999999999999999);return Math.log(s*(1-2*n)/(n*n)+1)/(2*Math.log((1-n)/n))},i.coefficients=s=>{let o=i.valueAt(s,1),a=(i.valueAt(s,2)-o)/(o-s.y0),l=o-a*s.y0;return{m:a,q:l}};function*t(s,o,n,a){let{m:l,q:c}=i.coefficients({slope:s,steps:o,y0:n,y1:a});for(let d=0,m=n;d<o;d++)yield m=l*m+c}i.walk=t;function*r(s,o){let n=1/o,a=i.normalizedAt(n,s),c=(i.normalizedAt(2*n,s)-a)/a;for(let d=0,m=0;d<o;d++)yield m=c*m+a}i.walkNormalized=r,i.byHalf=(s,o,n,a)=>({slope:i.slopeByHalf(o,n,a),steps:s,y0:o,y1:a}),i.slopeByHalf=(s,o,n)=>Math.abs(n-s)<1e-6?.5:(o-s)/(n-s)})(Ue||(Ue={}));var Xe=new DataView(new ArrayBuffer(8)),Se;(function(i){i.MIN_VALUE=-2147483648,i.MAX_VALUE=2147483647,i.toByte=e=>(Xe.setInt8(0,e),Xe.getInt8(0)),i.toShort=e=>(Xe.setInt16(0,e),Xe.getInt16(0)),i.toInt=e=>(Xe.setInt32(0,e),Xe.getInt32(0))})(Se||(Se={}));var ut;(function(i){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(r),o=new Int32Array(r);i.floatToIntBits=n=>{let a=i.floatToRawIntBits(n);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},i.intBitsToFloat=n=>(o[0]=n,s[0]),i.floatToRawIntBits=n=>(s[0]=n,o[0]),i.toFloat32=n=>(Xe.setFloat32(0,n),Xe.getFloat32(0))})(ut||(ut={}));var At;(function(i){i.floatToIntBits=e=>{let t=ut.floatToIntBits(e),r=t>>>16&32768,s=(t&2147483647)+4096;return s>=1199570944?(t&2147483647)>=1199570944?s<2139095040?r|31744:r|31744|(t&8388607)>>>13:r|31743:s>=947912704?r|s-939524096>>>13:s<855638016?r:(s=(t&2147483647)>>>23,r|(t&8388607|8388608)+(8388608>>>s-102)>>>126-s)},i.intBitsToFloat=e=>{let t=e&1023,r=e&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,t===0&&r>115712)return ut.intBitsToFloat((e&32768)<<16|r<<13|1023)}else if(t!==0){r=115712;do t<<=1,r-=1024;while((t&1024)===0);t&=1023}return ut.intBitsToFloat((e&32768)<<16|(r|t)<<13)}})(At||(At={}));var Ii;(function(i){let e=9218868437227405312n,t=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),s=new Float64Array(r),o=new BigInt64Array(r);i.float64ToLongBits=n=>{let a=i.float64ToRawLongBits(n);return(a&e)===e&&(a&t)!==0n?0x7ff8000000000000n:a},i.longBitsToFloat64=n=>(o[0]=n,s[0]),i.float64ToRawLongBits=n=>(s[0]=n,o[0]),i.clamp=n=>(Xe.setFloat64(0,n),Xe.getFloat64(0))})(Ii||(Ii={}));var le=class{static*empty(){}static one(e){return[e]}static count(e){let t=0;for(let r of e)t++;return t}static some(e,t){for(let r of e)if(t(r))return!0;return!1}static every(e,t){for(let r of e)if(!t(r))return!1;return!0}static reduce(e,t,r){let s=r,o=0;for(let n of e)s=t(s,n,o++);return s}static includes(e,t){for(let r of e)if(r===t)return!0;return!1}static forEach(e,t){for(let r of e)t(r)}static*map(e,t){let r=0;for(let s of e)yield t(s,r++)}static*take(e,t){let r=0;for(let s of e){if(r++>=t)return;yield s}}static filter(e,t){let r=[];for(let s of e)t(s)&&r.push(s);return r}static filterMap(e,t){let r=[];for(let s of e){let o=t(s);T(o)&&r.push(o)}return r}static reverse(e){let t=[];for(let r of e)t.push(r);return t.reverse()}static*pairWise(e){let t=e[Symbol.iterator](),{done:r,value:s}=t.next(),o=s;if(r!==!0)for(;;){let{done:n,value:a}=t.next();if(n===!0){yield[o,null];return}yield[o,a],o=a}}};var de=class i{static create(e=1024){return this.use(new ArrayBuffer(e))}static use(e,t=0){return new i(new DataView(e,t))}littleEndian=!1;#e;#t=0;constructor(e){this.#e=e}get remaining(){return this.#e.byteLength-this.#t}get position(){return this.#t}set position(e){e<0?g(`position(${e}) cannot be negative.`):e>this.#e.byteLength?g(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}writeBoolean(e){this.writeByte(e?1:0)}writeByte(e){this.#r(1),this.#e.setInt8(this.#t++,e)}writeShort(e){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#e.setInt16(this.#t,e,this.littleEndian),this.#t+=Int16Array.BYTES_PER_ELEMENT}writeInt(e){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#e.setInt32(this.#t,e,this.littleEndian),this.#t+=Int32Array.BYTES_PER_ELEMENT}writeLong(e){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#e.setBigInt64(this.#t,e,this.littleEndian),this.#t+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(e){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#e.setFloat32(this.#t,e,this.littleEndian),this.#t+=Float32Array.BYTES_PER_ELEMENT}writeDouble(e){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#e.setFloat64(this.#t,e,this.littleEndian),this.#t+=Float64Array.BYTES_PER_ELEMENT}writeBytes(e){this.#r(e.length);for(let t=0;t<e.length;++t)this.#e.setInt8(this.#t++,e[t])}writeString(e){let t=e.length;this.#r(Int32Array.BYTES_PER_ELEMENT+t*Int16Array.BYTES_PER_ELEMENT),this.writeInt(t);for(let r=0;r<t;r++)this.writeShort(e.charCodeAt(r))}toArrayBuffer(){return this.#e.buffer.slice(0,this.#t)}#r(e){let t=this.#e.byteLength;if(this.#t+e>t){let r=this.#e;this.#e=new DataView(new ArrayBuffer(lt(t+e)));for(let s=0;s<this.#t;s++)this.#e.setInt8(s,r.getInt8(s))}}},vr=class{#e=0;writeByte(e){this.#e++}writeShort(e){this.#e+=2}writeInt(e){this.#e+=4}writeLong(e){this.#e+=8}writeFloat(e){this.#e+=4}writeDouble(e){this.#e+=8}writeBoolean(e){this.#e++}writeBytes(e){this.#e+=e.length}writeString(e){this.#e+=e.length+4}get count(){return this.#e}},Oi=class{#e;#t=0;constructor(e=32){this.#e=new Int8Array(e)}result(){return this.#e}equals(e){return e===this?!0:this.#e.every((t,r)=>e.#e[r]===t)}writeBoolean(e){this.writeByte(e?31:11)}writeShort(e){this.writeByte(e&255),this.writeByte(e>>>8&255)}writeByte(e){this.#t>=this.#e.length&&(this.#t=0),this.#e[this.#t++]^=e}writeInt(e){this.writeByte(e&255),this.writeByte(e>>>8&255),this.writeByte(e>>>16&255),this.writeByte(e>>>24&255)}writeBytes(e){e.forEach(t=>this.writeByte(t))}writeFloat(e){this.writeInt(ut.floatToIntBits(e))}writeDouble(e){this.writeLong(Ii.float64ToLongBits(e))}writeLong(e){this.writeByte(Number(e)&255),this.writeByte(Number(e>>8n)&255),this.writeByte(Number(e>>16n)&255),this.writeByte(Number(e>>24n)&255),this.writeByte(Number(e>>32n)&255),this.writeByte(Number(e>>40n)&255),this.writeByte(Number(e>>48n)&255),this.writeByte(Number(e>>56n)&255)}writeString(e){for(let t=0;t<e.length;t++)this.writeShort(e.charCodeAt(t))}toHexString(){return Array.from(le.map(this.#e.values(),e=>(e&255).toString(16).padStart(2,"0"))).join("")}},ge=class{littleEndian=!1;#e;#t=0;constructor(e,t=0){this.#e=new DataView(e,t)}get position(){return this.#t}set position(e){e<0?g(`position(${e}) cannot be negative.`):e>this.#e.byteLength?g(`position(${e}) is outside range (${this.#e.byteLength}).`):this.#t=e}readByte(){return this.#e.getInt8(this.#t++)}readShort(){let e=this.#e.getInt16(this.#t,this.littleEndian);return this.#t+=Int16Array.BYTES_PER_ELEMENT,e}readInt(){let e=this.#e.getInt32(this.#t,this.littleEndian);return this.#t+=Int32Array.BYTES_PER_ELEMENT,e}readLong(){let e=this.#e.getBigInt64(this.#t,this.littleEndian);return this.#t+=BigInt64Array.BYTES_PER_ELEMENT,e}readFloat(){let e=this.#e.getFloat32(this.#t,this.littleEndian);return this.#t+=Float32Array.BYTES_PER_ELEMENT,e}readDouble(){let e=this.#e.getFloat64(this.#t,this.littleEndian);return this.#t+=Float64Array.BYTES_PER_ELEMENT,e}readBoolean(){return this.readByte()===1}readBytes(e){for(let t=0;t<e.length;t++)e[t]=this.readByte()}readString(){let e=this.readInt(),t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.readShort());return t}available(e){return this.#t+e<=this.#e.byteLength}remaining(){return this.#e.byteLength-this.#t}skip(e){this.position+=e}};var sl=i=>T(i)?i.value!==void 0?"value":i.get!==void 0?"get":g(`Cannot resolve method key of ${i}`):g("Cannot resolve method key of undefined descriptor"),br=(i,e,t)=>{if(!T(t))return function(o,n){if(n&&n.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),e);if(!T(a?.get))return g(`Cannot find getter for property '${e}'`);let l=a.get.apply(this);return Object.defineProperty(this,e,{value:l,configurable:!1,writable:!1,enumerable:!1}),l}};let r=sl(t),s=k(t[r]);return{[r]:function(...o){if(o.length>0)return g("lazy accessory must not have any construction parameters");let n=s.apply(this);return Object.defineProperty(this,e,{value:r==="get"?n:()=>n,configurable:!1,writable:!1,enumerable:!1}),n}}};var ct;(function(i){function*e(){}i.empty=e,i.next=r=>{let{value:s,done:o}=r.next();return o?null:s};function*t(...r){for(let s of r)for(let o of s)yield o}i.flatten=t})(ct||(ct={}));var Ar;(function(i){i[i.T=0]="T",i[i.R=1]="R",i[i.B=2]="B",i[i.L=3]="L"})(Ar||(Ar={}));var wr;(function(i){i[i.TL=0]="TL",i[i.TR=1]="TR",i[i.BR=2]="BR",i[i.BL=3]="BL"})(wr||(wr={}));var Wn;(function(i){i.outerTangentPoints=(e,t)=>{let r=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,r)+Math.acos((e.r-t.r)/Math.sqrt(r*r+s*s)),n=Math.cos(o),a=Math.sin(o);return[{x:e.x+e.r*n,y:e.y+e.r*a},{x:t.x+t.r*n,y:t.y+t.r*a}]}})(Wn||(Wn={}));var jn;(function(i){i.zero=()=>({x:0,y:0}),i.create=(e,t)=>({x:e,y:t}),i.clone=e=>({...e}),i.floor=e=>({x:Math.floor(e.x),y:Math.floor(e.y)}),i.length=e=>Math.sqrt(e.x*e.x+e.y*e.y),i.distance=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),i.add=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),i.subtract=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),i.scaleBy=(e,t)=>({x:e.x*t,y:e.y*t}),i.scaleTo=(e,t)=>{let r=t/i.length(e);return{x:e.x*r,y:e.y*r}},i.fromClient=e=>({x:e.clientX,y:e.clientY})})(jn||(jn={}));var mi;(function(i){i.Empty=Object.freeze({x:0,y:0,width:0,height:0}),i.corners=e=>{let t=e.x,r=e.y,s=t+e.width,o=r+e.height;return[{x:t,y:r},{x:s,y:r},{x:s,y:o},{x:t,y:o}]},i.inflate=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}),i.contains=(e,t)=>{let r=t.x>=e.x&&t.y>=e.y,s=t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;return r&&s},i.isPointInside=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,i.intersect=(e,t)=>{let r=Math.max(e.x,t.x),s=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height),n=Math.max(e.y,t.y);return s>r&&o>n},i.axis=(e,t)=>{switch(t){case Ar.T:return e.y;case Ar.R:return e.x+e.width;case Ar.B:return e.y+e.height;case Ar.L:return e.x;default:return Ge(t)}},i.corner=(e,t)=>{switch(t){case wr.TL:return{x:e.x,y:e.y};case wr.TR:return{x:e.x+e.width,y:e.y};case wr.BR:return{x:e.x+e.width,y:e.y+e.height};case wr.BL:return{x:e.x,y:e.y+e.height};default:return Ge(t)}},i.center=e=>({x:e.x+e.width*.5,y:e.y+e.height*.5}),i.isEmpty=e=>e.width===0||e.height===0,i.union=(e,t)=>{if(i.isEmpty(e))i.isEmpty(t)||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height);else if(!i.isEmpty(t)){let r=t.x,s=t.y,o=Math.min(e.x,r),n=Math.min(e.y,s);e.width=Math.max(e.x+e.width,r+t.width)-o,e.height=Math.max(e.y+e.height,s+t.height)-n,e.x=o,e.y=n}}})(mi||(mi={}));var Qn;(function(i){i.width=e=>e.xMax-e.xMin,i.height=e=>e.yMax-e.yMin,i.from=(e,t)=>{e.xMin=t.xMin,e.xMax=t.xMax,e.yMin=t.yMin,e.yMax=t.yMax},i.extend=(e,t)=>{e.xMin-=t,e.yMin-=t,e.xMax+=t,e.yMax+=t},i.padding=(e,[t,r,s,o])=>(e.xMin+=o,e.yMin+=t,e.xMax-=r,e.yMax-=s,e),i.intersectPoint=(e,t)=>e.xMin<=t.x&&t.x<e.xMax&&e.yMin<=t.y&&t.y<e.yMax,i.intersectThat=(e,t)=>t.xMin<e.xMax&&t.xMax>e.xMin&&t.yMin<e.yMax&&t.yMax>e.yMin,i.center=e=>({x:(e.xMin+e.xMax)*.5,y:(e.yMin+e.yMax)*.5})})(Qn||(Qn={}));var Yn;(function(i){i.Identity=Object.freeze([0,0,0,0])})(Yn||(Yn={}));var Xn;(function(i){i.intersects=(r,s,o,n,a,l,c,d)=>{let m=e(r,s,o,n,a,l),f=e(r,s,o,n,c,d);if((m|f)===0||(m&f)!==0)return!1;let y=t(a,l,c,d,r,o);return y!==t(a,l,c,d,s,o)||y!==t(a,l,c,d,s,n)||y!==t(a,l,c,d,r,n)};let e=(r,s,o,n,a,l)=>{let c=0;return a<=r?c|=1:a>=s&&(c|=2),l<=o?c|=8:l>=n&&(c|=4),c},t=(r,s,o,n,a,l)=>(o-r)*(l-s)-(a-r)*(n-s)>=0})(Xn||(Xn={}));var Jn;(function(i){i.Identity={valueToAxis:e=>e,axisToValue:e=>e},i.toClamped=(e,t,r)=>({valueToAxis:s=>e.valueToAxis($(s,t,r)),axisToValue:s=>$(e.axisToValue(s),t,r)}),i.createClamped=(e,t)=>({valueToAxis:r=>$(r,e,t),axisToValue:r=>$(r,e,t)})})(Jn||(Jn={}));var Zn;(function(i){i.fromBuffers=async(...e)=>{let t=e.reduce((o,n)=>o+n.byteLength,0),r=new Uint8Array(t),s=0;for(let o of e)r.set(new Uint8Array(o),s),s+=o.byteLength;return await crypto.subtle.digest("SHA-256",r)},i.equals=(e,t)=>{v(e.byteLength===32,"First hash has invalid length"),v(t.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(e),s=new Uint8Array(t);for(let o=0;o<32;o++)if(r[o]!==s[o])return!1;return!0},i.toString=e=>Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")})(Zn||(Zn={}));var fi;(function(i){i.intersect1D=(e,t,r,s)=>Math.max(e,r)<=Math.min(t,s)})(fi||(fi={}));var ve=class{#e=new Set;#t;constructor(){this.#t=new Proxy({},{get:(e,t)=>(...r)=>this.#e.forEach(s=>Object.getPrototypeOf(s)===Object.getPrototypeOf({})?x(s[t],...r):s[t]?.apply(s,r))})}get proxy(){return this.#t}get size(){return this.#e.size}subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}forEach(e){this.#e.forEach(e)}terminate(){this.#e.clear()}};var ir=class{static createIfAbsent(e,t,r){let s=e.get(t);return s===void 0&&(s=r(t),e.set(t,s)),s}};var gi=class i{static#e=Object.freeze(new Set);static empty=()=>i.#e};var sr=class i{#e;#t;constructor(e,t){this.#e=new Map(e),this.#t=p.wrap(t),this.#t.ifSome(r=>Array.from(this.#e.values()).forEach(s=>s.sort(r)))}[Symbol.iterator](){return this.#e.entries()}clear(){this.#e.clear()}containsEntry(e,t){return le.some(this.#e.entries(),r=>e===r[0]&&r[1].includes(t))}containsKey(e){return le.includes(this.#e.keys(),e)}containsValue(e){return le.some(this.#e.values(),t=>t.includes(e))}get(e){return this.#e.get(e)??w.empty()}isEmpty(){return this.keyCount()===0}add(e,t){let r=ir.createIfAbsent(this.#e,e,()=>[]);if(this.#t.isEmpty())r.push(t);else{let s=se.leftMost(r,t,this.#t.unwrap());r.splice(s,0,t)}}addAll(e,t){let r=ir.createIfAbsent(this.#e,e,()=>[]);r.push(...t),this.#t.nonEmpty()&&r.sort(this.#t.unwrap())}remove(e,t){let r=this.#e.get(e);if(r===void 0)return!1;{let s=r.indexOf(t);return s===-1?!1:(r.splice(s,1),r.length===0&&this.#e.delete(e),!0)}}removeFromKeyIf(e,t){let r=this.#e.get(e);if(r===void 0)return null;{let s=r.findIndex(t);if(s===-1)return null;{let o=r.splice(s,1)[0];return r.length===0&&this.#e.delete(e),o}}}removeValueIf(e){let t=[];for(let[r,s]of this.#e.entries())for(let o of s.filter(n=>e(n)))t.push([r,o]);for(let[r,s]of t)this.remove(r,s);return new Set(t.map(([,r])=>r))}removeKey(e){let t=this.#e.get(e);return this.#e.delete(e),t??w.empty()}forEach(e){le.forEach(this.#e.entries(),t=>e(t[0],t[1]))}keyCount(){return this.#e.size}keys(){return this.#e.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.#e.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.#e.forEach((t,r)=>{e.#e.set(r,t.map(s=>s))}),e}},ki=class i{map;constructor(e){this.map=new Map(e?.map(t=>{let r=t[0],s=t[1];return[r,new Set(s)]}))}clear(){this.map.clear()}containsEntry(e,t){return le.some(this.map.entries(),r=>e===r[0]&&r[1].has(t))}containsKey(e){return le.includes(this.map.keys(),e)}containsValue(e){return le.some(this.map.values(),t=>t.has(e))}get(e){return this.map.get(e)??gi.empty()}isEmpty(){return this.keyCount()===0}add(e,t){ir.createIfAbsent(this.map,e,()=>new Set).add(t)}addAll(e,t){let r=ir.createIfAbsent(this.map,e,()=>new Set);for(let s of t)r.add(s)}remove(e,t){let r=this.map.get(e);return r===void 0?!1:r.delete(t)?(r.size===0&&this.map.delete(e),!0):!1}removeValueIf(e){let t=new Set;for(let[r,s]of this.map.entries()){for(let o of s)e(o)&&(s.delete(o),t.add(o));s.size===0&&this.map.delete(r)}return t}removeFromKeyIf(e,t){let r=this.map.get(e);if(r===void 0)return null;for(let s of r)if(t(s))return r.delete(s),r.size===0&&this.map.delete(e),s;return null}removeKey(e){let t=this.map.get(e);return this.map.delete(e),t??gi.empty()}forEach(e){le.forEach(this.map.entries(),t=>e(t[0],t[1]))}keyCount(){return this.map.size}keys(){return this.map.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.map.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.map.forEach((t,r)=>{e.map.set(r,new Set(Array.from(t)))}),e}};var U=Object.freeze({Empty:{terminate:nt},create:i=>({terminate:i}),many:(...i)=>({terminate:()=>{for(;i.length>0;)i.pop().terminate()}})}),D=class i{#e=[];isEmpty(){return this.#e.length===0}nonEmpty(){return this.#e.length>0}own(e){return this.#e.push(e),e}ownAll(...e){for(let t of e)this.#e.push(t)}spawn(){let e=new i;return e.own({terminate:()=>w.removeOpt(this.#e,e)}),this.own(e)}terminate(){for(;this.#e.length>0;)this.#e.pop().terminate()}};var q=class{static subscribeMany(e,...t){return U.many(...t.map(r=>r.subscribe(()=>e(r))))}#e=new Set;subscribe(e){return this.#e.add(e),{terminate:()=>this.#e.delete(e)}}isEmpty(){return this.#e.size===0}notify(e){this.#e.forEach(t=>t(e))}observers(){return this.#e}terminate(){this.#e.clear()}};var Je;(function(i){let e=Object.freeze({});i.empty=()=>e,i.mergeNoOverlap=(t,r)=>{let s=new Set(Object.keys(t));for(let o of Object.keys(r))if(s.has(o))return g(`'${o}' is an overlapping key`);return{...t,...r}},i.include=(t,...r)=>{let s={};for(let o of r)s[o]=t[o];return s},i.exclude=(t,...r)=>{let s=new Set(r);return Object.entries(t).reduce((o,[n,a])=>(s.has(n)||(o[n]=a),o),{})},i.overwrite=(t,r)=>Object.assign(t,r)})(Je||(Je={}));var ea;(function(i){i.make=e=>new class{getValue(){return e}subscribe(t){return U.Empty}catchupAndSubscribe(t){return t(this),U.Empty}}})(ea||(ea={}));var ta;(function(i){i.False=new class{getValue(){return!1}setValue(e){}subscribe(e){return U.Empty}catchupAndSubscribe(e){return e(this),U.Empty}},i.inverseBoolean=e=>new class{getValue(){return!e.getValue()}setValue(t){e.setValue(!t)}subscribe(t){return e.subscribe(t)}catchupAndSubscribe(t){return t(this),this.subscribe(t)}}})(ta||(ta={}));var Ce=class{#e;#t=p.None;#r;constructor(e,t){this.#e=new q,this.#r=t?.guard(e)??e,this.#t=p.wrap(t)}setValue(e){this.#t.nonEmpty()&&(e=this.#t.unwrap().guard(e)),this.#r!==e&&(this.#r=e,this.#e.notify(this))}getValue(){return this.#r}subscribe(e){return this.#e.subscribe(e)}catchupAndSubscribe(e){return e(this),this.#e.subscribe(e)}terminate(){this.#e.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var un=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=t-e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+$(e,0,1)*this.#r}clamp(e){return $(e,this.#e,this.#t)}floating(){return!0}},cn=class{#e;#t;#r;constructor(e,t){this.#e=$(Math.round(e),Se.MIN_VALUE,Se.MAX_VALUE),this.#t=$(Math.round(t),Se.MIN_VALUE,Se.MAX_VALUE),this.#r=this.#t-this.#e}x(e){return(this.clamp(e)-this.#e)/this.#r}y(e){return this.#e+Math.round($(e,0,1)*this.#r)}clamp(e){return $(Math.round(e),this.#e,this.#t)}floating(){return!1}},hn=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.log(t/e)}x(e){return Math.log($(e,this.#e,this.#t)/this.#e)/this.#r}y(e){return this.#e*Math.exp($(e,0,1)*this.#r)}clamp(e){return Math.min(this.#t,Math.max(this.#e,e))}floating(){return!0}},dn=class{#e;constructor(e){this.#e=e}x(e){let t=this.#e.findIndex(r=>r===e);return t===-1?g(`Could not find index for ${e}`):t/(this.#e.length-1)}y(e){let t=Math.round($(e,0,1)*(this.#e.length-1));return t>-1?k(this.#e.at(t),`Could not find value for ${e}`):g(`Index ${t} is out of box.`)}clamp(e){return e}floating(){return!1}},pn=class{#e;#t;#r;#i;#s;constructor(e,t,r){this.#e=e,this.#t=r;let s=e*e,o=r*r,n=t*t,a=e+r-2*t,l=r-t;this.#r=((2*r-t)*e-t*r)/a,this.#i=(l*s+(n-o)*e+t*o-n*r)/(s+(2*r-4*t)*e+o-4*t*r+4*n),this.#s=-l/a}y(e){return e<=0?Number.NEGATIVE_INFINITY:e>=1?this.#t:this.#r-this.#i/(e+this.#s)}x(e){return this.#e>=e?0:this.#t<=e?1:-this.#i/(e-this.#r)-this.#s}clamp(e){return Math.min(this.#t,e)}floating(){return!0}},R;(function(i){i.linear=(o,n)=>new un(o,n),i.linearInteger=(o,n)=>new cn(o,n),i.exponential=(o,n)=>new hn(o,n),i.values=o=>new dn(o),i.decibel=(o,n,a)=>new pn(o,n,a);let e=new class{x(o){return o?1:0}y(o){return o>=.5}clamp(o){return o}floating(){return!1}},t=i.linear(0,1),r=i.linear(-1,1);i.bool=e;let s=i.decibel(-72,-12,0);i.unipolar=()=>t,i.bipolar=()=>r,i.DefaultDecibel=s})(R||(R={}));var C;(function(i){i.percent=({bipolar:o,fractionDigits:n}={})=>new e("%",n,!1,o),i.numeric=({unit:o,fractionDigits:n,unitPrefix:a,bipolar:l}={})=>new e(o,n,a,l),i.indices=(o,n)=>new class{x(a){return{unit:o,value:n[a]}}y(a){let l=n.indexOf(a);return l===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:l}}},i.values=(o,n,a)=>new class{x(l){return{unit:o,value:a.at(n.indexOf(l))??"N/A"}}y(l){let c=a.indexOf(l);return c===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:n[c]}}},i.bool=new class{y(o){switch(o.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(o){return{value:String(o),unit:""}}};class e{#e;#t;#r;#i;constructor(n,a,l,c){this.#e=n??"",this.#t=a??0,this.#r=l??!1,this.#i=c??!1}y(n){let a=n.trim(),l=parseFloat(a);if(isNaN(l))return{type:"unknown",value:a};if(this.#e==="%")return{type:"explicit",value:l/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#i?$(l/200+.5,0,1):$(l/100,0,1)};{a.endsWith(this.#e)&&this.#e.length>0&&(a=a.slice(0,-this.#e.length));let m=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(T(m)){let f=t.indexOf(m);if(f>-1)return{type:"explicit",value:l*Math.pow(10,(f-4)*3)}}return{type:"explicit",value:l}}}x(n){if(Number.isNaN(n))return{value:"\u{1F4A3}",unit:this.#e};if(Number.isFinite(n)){if(this.#e==="%")return this.#i?{value:(n*200-100).toFixed(this.#t),unit:this.#e}:{value:(n*100).toFixed(this.#t),unit:this.#e};if(this.#r){let{value:a,prefix:l}=s(n);return{value:a.toFixed(this.#t),unit:`${l}${this.#e}`}}else return{value:n.toFixed(this.#t),unit:this.#e}}else return{value:n===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#e}}}let t=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=o=>Math.log(o)/Math.log(9.999999999999998),s=o=>{let n=Math.floor(r(o)/3),a=t[n+4];return T(a)?{value:o*Math.pow(10,n*-3),prefix:a}:{value:o,prefix:""}};i.decible=i.numeric({unit:"db",fractionDigits:1}),i.panning=i.percent({unit:"%",fractionDigits:0})})(C||(C={}));var Ui;(function(i){i.alwaysTrue=()=>!0,i.alwaysFalse=()=>!1,i.definedPredicate=e=>e!=null})(Ui||(Ui={}));var ra;(function(i){i.Empty=Object.freeze(e=>{}),i.split=(e,t)=>{let r=new Float32Array(t);return w.create(s=>o=>{r[s]=o,e(r.reduce((n,a)=>n+a,0)/t)},t)},i.splitWithWeights=(e,t)=>{let r=t.length,s=new Float32Array(r);if(t.length===0)return g("Weights must not be empty");if(t.some(a=>a<=0))return g("Weights must be greater than zero");let o=t.reduce((a,l)=>a+l,0),n=o>0?t.map(a=>a/o):w.create(()=>1/r,r);return w.create(a=>l=>{s[a]=l,e(s.reduce((c,d,m)=>c+d*n[m],0))},r)}})(ra||(ra={}));var Ki;(function(i){i.create=(e=252854082)=>new mn(e),i.monotoneAscending=(e,t=128,r=i.create())=>{let s=e.length;if(s<2)return g("Array must have at least 2 elements");let o=0;for(let a=1;a<s;a++){let l=Math.floor(r.uniform()*(1+t))+1;e[a]=l,o+=l}let n=0;e[0]=0;for(let a=1;a<s;a++)n+=e[a],e[a]=n/o;return e}})(Ki||(Ki={}));var mn=class{#e=0;constructor(e){this.setSeed(e)}setSeed(e){this.#e=e&4294967295}nextDouble(e,t){return e+this.uniform()*(t-e)}nextInt(e,t){return e+Math.floor(this.uniform()*(t-e))}nextElement(e){return e[Math.floor(this.uniform()*e.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let e=this.#e+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}};var Re;(function(i){class e{}i.createBuilder=r=>{let s=o=>{let n=o instanceof Array?[]:{};return Object.entries(o).forEach(([a,l])=>{l instanceof e?n[a]=l.initialValue():typeof l=="object"&&(n[a]=s(l))}),n};return()=>new t(r,Object.seal(s(r)))},i.bool=new class extends e{read(r){return r.readByte()===1}write(r,s){r.writeByte(s?1:0)}initialValue(){return!1}},i.int8=new class extends e{read(r){return r.readByte()}write(r,s){r.writeByte(s)}initialValue(){return 0}},i.int16=new class extends e{read(r){return r.readShort()}write(r,s){r.writeShort(s)}initialValue(){return 0}},i.int32=new class extends e{read(r){return r.readInt()}write(r,s){r.writeInt(s)}initialValue(){return 0}},i.float=new class extends e{read(r){return r.readFloat()}write(r,s){r.writeFloat(s)}initialValue(){return 0}},i.double=new class extends e{read(r){return r.readDouble()}write(r,s){r.writeDouble(s)}initialValue(){return 0}},i.int64=new class extends e{read(r){return r.readLong()}write(r,s){r.writeLong(s)}initialValue(){return 0n}},i.floats=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readFloat();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeFloat(o[n])}initialValue(){return new Float32Array(r)}},i.doubles=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readDouble();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeDouble(o[n])}initialValue(){return new Float64Array(r)}};class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=this.#i()}get object(){return this.#t}get bytesTotal(){return this.#r}read(s){let o=(n,a)=>{Object.entries(n).forEach(([l,c])=>{let d=a;c instanceof e?d[l]=c.read(s,d[l]):typeof c=="object"&&o(c,d[l])})};o(this.#e,this.#t)}write(s){let o=(n,a)=>{Object.entries(n).forEach(([l,c])=>{let d=a;c instanceof e?c.write(s,d[l]):typeof c=="object"&&o(c,d[l])})};o(this.#e,this.#t)}#i(){let s=new vr;return this.write(s),s.count}}})(Re||(Re={}));var wt=class{#e;#t;#r;constructor(e,t){this.#e=e,this.#t=t,this.#r=[]}add(e,t=!1){let r=this.#e(e),s=se.leftMostMapped(this.#r,r,this.#t,this.#e),o=this.#r[s];return T(o)&&this.#t(this.#e(o),r)===0?t?(this.#r.splice(s,1,e),!0):!1:(this.#r.splice(s,0,e),!0)}getOrCreate(e,t){let r=se.leftMostMapped(this.#r,e,this.#t,this.#e),s=this.#r[r];if(T(s)&&this.#t(this.#e(s),e)===0)return s;let o=t(e);return this.#r.splice(r,0,o),o}addMany(e){for(let t of e)this.#r.push(t);try{return this.#r.sort((t,r)=>{let s=this.#t(this.#e(t),this.#e(r));if(s===0)throw"cancel";return s}),!0}catch(t){if(t==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((s,o)=>this.#t(this.#e(s),this.#e(o))),!1}return g(t)}}removeByValue(e){return this.removeByKey(this.#e(e))}removeByKey(e){let t=se.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return T(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):g(`Could not remove ${e}`)}removeByKeyIfExist(e){let t=se.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return T(r)&&this.#t(this.#e(r),e)===0?(this.#r.splice(t,1),r):null}removeRange(e,t){this.#r.splice(e,(t??this.#r.length)-e)}removeByPredicate(e){let t=0,r=this.#r.length;for(;--r>=0;)e(this.#r[r])&&(this.#r.splice(r,1),t++);return t}get(e){return k(this.#i(e),`Unknown key: ${e}`)}getOrThrow(e,t){let r=this.#i(e);if(T(r))return r;throw t()}opt(e){return p.wrap(this.#i(e))}getOrNull(e){return this.#i(e)??null}getByIndex(e){return this.#r[e]}hasKey(e){return T(this.#i(e))}hasValue(e){return T(this.#i(this.#e(e)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(e){this.values().forEach(e)}values(){return this.#r}entries(){return this.#r.map(e=>[this.#e(e),e])}clear(){w.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#i(e){let t=se.leftMostMapped(this.#r,e,this.#t,this.#e),r=this.#r[t];return T(r)&&this.#t(this.#e(r),e)===0?r:void 0}};var ia;(function(i){i.hyphenToCamelCase=e=>e.replace(/-([a-z])/g,t=>t[1].toUpperCase()),i.fallback=(e,t)=>T(e)&&e.length>0?e:t,i.endsWithDigit=e=>/\d$/.test(e),i.nonEmpty=(e,t)=>T(e)&&e.trim().length>0?e:t,i.toArrayBuffer=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return t},i.getUniqueName=(e,t)=>{let r=new Set(e),s=t,o=1;if(r.has(t)||r.has(`${t} 1`))o=2;else return t;for(;r.has(s=`${t} ${o++}`););return s}})(ia||(ia={}));var sa=(()=>{let i=p.None;return{info:e=>i.match({none:()=>Promise.resolve(),some:t=>t.info(e)}),approve:e=>i.match({none:()=>Promise.resolve(!0),some:t=>t.approve(e)}),progress:e=>i.match({none:()=>({message:"",terminate:nt}),some:t=>t.progress(e)}),install:e=>{v(i.isEmpty(),"RuntimeNotification already installed"),i=p.wrap(e)}}})();var oa;(function(i){let e=new q;i.subscribe=t=>e.subscribe(t),i.dispatch=t=>e.notify(t)})(oa||(oa={}));var Et=class i{static POSITIVE_INFINITY=new i(Number.POSITIVE_INFINITY);static millis=e=>new i(e);static seconds=e=>new i(e*i.#e);static minutes=e=>new i(e*i.#t);static hours=e=>new i(e*i.#r);static days=e=>new i(e*i.#i);static#e=1e3;static#t=6e4;static#r=36e5;static#i=864e5;#s;constructor(e){this.#s=e}millis(){return this.#s}absSeconds(){return Math.abs(this.#s)/i.#e}absMinutes(){return Math.abs(this.#s)/i.#t}absHours(){return Math.abs(this.#s)/i.#r}absDays(){return Math.abs(this.#s)/i.#i}split(){return{d:Math.floor(this.absDays()),h:Math.floor(this.absHours())%24,m:Math.floor(this.absMinutes())%60,s:Math.floor(this.absSeconds())%60}}isNow(){return this.#s===0}isPast(){return this.#s<0}isFuture(){return this.#s>0}toUnitString(){let e,t,r=Math.floor(Math.abs(this.#s)/1e3),s=Math.floor(r/60),o=Math.floor(s/60),n=Math.floor(o/24);return r<60?(e=r,t="second"):s<60?(e=s,t="minute"):o<24?(e=o,t="hour"):(e=n,t="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(e*Math.sign(this.#s),t)}toString(){if(isNaN(this.#s))return"NaN";if(!isFinite(this.#s))return"\u221E";let{d:e,h:t,m:r,s}=this.split();return e>0?[i.#o("d",e),i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):t>0?[i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):r>0?[i.#o("m",r),i.#o("s",s)].join(", "):s>0?i.#o("s",s):"now"}static#o=(e,t)=>{switch(e){case"d":return`${t} ${t<2?"day":"days"}`;case"h":return`${t} ${t<2?"hour":"hours"}`;case"m":return`${t} ${t<2?"minute":"minutes"}`;case"s":return`${t} ${t<2?"second":"seconds"}`;default:return Ge(e)}}};var Er;(function(i){let e;(function(t){t[t.READING=0]="READING",t[t.READ=1]="READ",t[t.WRITING=2]="WRITING",t[t.WRITTEN=3]="WRITTEN"})(e||(e={})),i.writer=(t,r,s)=>{if(t.bytesTotal+1>r.byteLength)return g("Insufficient memory allocated.");let o=new Uint8Array(r),n=de.use(r,1);return Atomics.store(o,0,e.READ),{tryWrite:()=>Atomics.compareExchange(o,0,e.READ,e.WRITING)===e.WRITING?(s(t.object),n.position=0,t.write(n),Atomics.store(o,0,e.WRITTEN),!0):!1}},i.reader=(t,r)=>{let s=new SharedArrayBuffer(t.bytesTotal+1),o=new Uint8Array(s),n=new ge(s,1);return{buffer:s,tryRead:()=>Atomics.compareExchange(o,0,e.WRITTEN,e.READING)===e.READING?(n.position=0,t.read(n),r(t.object),Atomics.store(o,0,e.READ),!0):!1}}})(Er||(Er={}));var A;(function(i){i.length=16,i.generate=()=>e(crypto.getRandomValues(new Uint8Array(i.length))),i.sha256=async t=>{let r=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",r?new Uint8Array(t.slice(0)):t).then(s=>e(new Uint8Array(s.slice(0,i.length))))},i.validateBytes=t=>i.parse(i.toString(t)),i.validateString=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),i.asString=t=>i.validateString(t)?t:g(`Invalid UUID format: ${t}`),i.fromDataInput=t=>{let r=new Uint8Array(i.length);return t.readBytes(new Int8Array(r.buffer)),r},i.toDataOutput=(t,r)=>t.writeBytes(new Int8Array(r.buffer)),i.toString=t=>{let r=w.create(s=>(s+256).toString(16).substring(1),256);return r[t[0]]+r[t[1]]+r[t[2]]+r[t[3]]+"-"+r[t[4]]+r[t[5]]+"-"+r[t[6]]+r[t[7]]+"-"+r[t[8]]+r[t[9]]+"-"+r[t[10]]+r[t[11]]+r[t[12]]+r[t[13]]+r[t[14]]+r[t[15]]},i.parse=t=>{let r=t.replace(/-/g,"").toLowerCase();if(r.length!==32)return g("Invalid UUID format");let s=new Uint8Array(i.length);for(let o=0,n=0;o<32;o+=2,n++)s[n]=parseInt(r.slice(o,o+2),16);return s},i.Comparator=(t,r)=>{if(t.length!==i.length||r.length!==i.length)return g("Unexpected array length for uuid(v4)");for(let s=0;s<i.length;s++){let o=t[s]-r[s];if(o!==0)return o}return 0},i.equals=(t,r)=>i.Comparator(t,r)===0,i.newSet=t=>new wt(t,i.Comparator),i.Lowest=i.parse("00000000-0000-4000-8000-000000000000"),i.Highest=i.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),i.fromInt=t=>{let r=new Uint8Array(i.Lowest),s=new Uint8Array(new Uint32Array([t]).buffer);for(let o=0;o<4;o++)r[o]=s[o];return r};let e=t=>(v(t.length===i.length,"UUID must be 16 bytes long"),t[6]=t[6]&15|64,t[8]=t[8]&63|128,t)})(A||(A={}));var na;(function(i){i.create=o=>T(o)?T(o?.snap)?i.snap(o?.trackLength,o?.snap?.snapLength,Array.isArray(o?.snap?.threshold)?o?.snap.threshold:[o?.snap?.threshold]):i.identity(o?.trackLength):i.identity(),i.snap=(o=e,n=t,a)=>new s(o,n/o,a),i.identity=(o=e)=>new r(o);let e=128,t=24;class r{length;#e=NaN;#t=NaN;#r=1;constructor(n){this.length=n}begin(n){this.#t=this.#e=n}moveBy(n){v(!isNaN(this.#t),()=>"value has never been set"),this.#e+=n/this.length*this.#r,this.#t=$(this.#e,0,1)}ratio(n){this.#r=n}value(){return v(!isNaN(this.#t),()=>"value has never been set"),this.#t}disable(){}enable(){}}class s{#e;#t;#r;#i;#s=NaN;#o=NaN;#n=1;#a=!0;constructor(n,a,l){v(a>0,()=>`margin(${a}) must be greater then 0`),v(w.isSorted(l),()=>"thresholds are not sorted"),v(a<n,()=>`margin(${a}) must be lower then length(${n})`),this.#e=n,this.#t=a,this.#r=l,this.#i=l.map((c,d)=>c+d*this.#t)}begin(n){this.#a&&(this.#s=this.valueToX(n)),this.#o=n}moveBy(n){v(!isNaN(this.#o),()=>"value has never been set"),this.#s+=n/this.#e*this.#n,this.#o=this.#a?this.xToValue(this.#s):$(this.#s,0,1)}ratio(n){this.#n=n}value(){return v(!isNaN(this.#o),()=>"value has never been set"),this.#o}disable(){this.#a&&(this.#a=!1,this.#s=this.xToValue(this.#s))}enable(){this.#a||(this.#a=!0,this.#s=this.valueToX(this.#s))}valueToX(n){let a=se.rightMost(this.#r,n,bt);if(a<0)return n;{let l=this.#i[a],c=this.#r[a];return n===c?l+this.#t/2:l+this.#t+(n-c)}}xToValue(n){let a=$(n,0,1+this.#t*this.#r.length),l=se.rightMost(this.#i,a,bt);if(l<0)return a;{let c=this.#i[l],d=this.#r[l];return a>c+this.#t?a-(c+this.#t)+d:d}}get margin(){return this.#t}}})(na||(na={}));var Li;(function(i){class e extends Error{}i.Warning=e,i.warn=r=>{throw new e(r)};class t extends Error{constructor(s){super(`${s} not found`)}}i.FileNotFound=t,i.AbortError=typeof DOMException>"u"?{name:"AbortError",message:""}:Object.freeze(new DOMException("AbortError")),i.isAbort=r=>r===i.AbortError||i.isDOMException(r)&&r.name==="AbortError",i.CatchAbort=r=>r===i.AbortError?void 0:g(r),i.isOverconstrained=r=>vt(r)&&"constraint"in r,i.isDOMException=r=>vt(r)&&sn(r,"name","string")&&sn(r,"message","string")})(Li||(Li={}));var $i=Symbol.for("@openDAW/lib-std");globalThis[$i]?console.debug(`%c${$i.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[$i]=!0,console.debug(`%c${$i.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Bt=class{a1=0;a2=0;b0=0;b1=0;b2=0;constructor(){this.identity()}identity(){this.setNormalizedCoefficients(1,0,0,1,0,0)}setLowpassParams(e,t){if(e=$(e,0,1),e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1-o)/2,a=n,l=2*n,c=n,d=1+s,m=-2*o,f=1-s;this.setNormalizedCoefficients(a,l,c,d,m,f)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}setHighpassParams(e,t){if(e=$(e,0,1),e===1)this.setNormalizedCoefficients(0,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1+o)/2,a=n,l=-2*n,c=n,d=1+s,m=-2*o,f=1-s;this.setNormalizedCoefficients(a,l,c,d,m,f)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNormalizedCoefficients(e,t,r,s,o,n){let a=1/s;return this.b0=e*a,this.b1=t*a,this.b2=r*a,this.a1=o*a,this.a2=n*a,this}setLowShelfParams(e,t){e=$(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(r*r,0,0,1,0,0);else if(e>0){let s=We*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),l=2*Math.sqrt(r)*n,c=r+1,d=r-1,m=r*(c-d*a+l),f=2*r*(d-c*a),y=r*(c-d*a-l),F=c+d*a+l,S=-2*(d+c*a),M=c+d*a-l;this.setNormalizedCoefficients(m,f,y,F,S,M)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setHighShelfParams(e,t){e=$(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){let s=We*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),l=2*Math.sqrt(r)*n,c=r+1,d=r-1,m=r*(c+d*a+l),f=-2*r*(d+c*a),y=r*(c+d*a-l),F=c-d*a+l,S=2*(d-c*a),M=c-d*a-l;this.setNormalizedCoefficients(m,f,y,F,S,M)}else this.setNormalizedCoefficients(r*r,0,0,1,0,0);return this}setPeakingParams(e,t,r){e=$(e,0,1),t=Math.max(0,t);let s=Math.pow(10,r/40);if(e>0&&e<1)if(t>0){let o=We*e,n=Math.sin(o)/(2*t),a=Math.cos(o),l=1+n*s,c=-2*a,d=1-n*s,m=1+n/s,f=-2*a,y=1-n/s;this.setNormalizedCoefficients(l,c,d,m,f,y)}else this.setNormalizedCoefficients(s*s,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setAllpassParams(e,t){if(e=$(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1-s,a=-2*o,l=1+s,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(-1,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNotchParams(e,t){if(e=$(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1,a=-2*o,l=1,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(0,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setBandpassParams(e,t){if(e=Math.max(0,e),t=Math.max(0,t),e>0&&e<1){let r=We*e;if(t>0){let s=Math.sin(r)/(2*t),o=Math.cos(r),n=s,a=0,l=-s,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(1,0,0,1,0,0)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}getFrequencyResponse(e,t,r){v(e.length===t.length&&e.length===r.length,"Array lengths do not match");let s=this.b0,o=this.b1,n=this.b2,a=this.a1,l=this.a2;for(let c=0;c<e.length;++c){let d=-Math.PI*2*e[c],m=Math.cos(d),f=Math.sin(d),y=s+((o+n*m)*m-n*f*f),F=(o+n*m)*f+n*f*m,S=1+((a+l*m)*m-l*f*f),M=(a+l*m)*f+l*f*m,K=S*S+M*M,L=(y*S+F*M)/K,z=(F*S-y*M)/K;t[c]=Math.sqrt(L*L+z*z),r[c]=Math.atan2(z,L)}}};var be=class{#e=0;#t=0;#r=0;#i=0;reset(){this.#e=0,this.#t=0,this.#r=0,this.#i=0}process({a1:e,a2:t,b0:r,b1:s,b2:o},n,a,l,c){let d=this.#e,m=this.#t,f=this.#r,y=this.#i;for(let F=l;F<c;F++){let S=n[F],M=a[F]=r*S+s*d+o*m-e*f-t*y+1e-18-1e-18;m=d,d=S,y=f,f=M}this.#e=d,this.#t=m,this.#r=f,this.#i=y}processFrame({a1:e,a2:t,b0:r,b1:s,b2:o},n){let a=r*n+s*this.#e+o*this.#t-e*this.#r-t*this.#i+1e-18-1e-18;return this.#t=this.#e,this.#e=n,this.#i=this.#r,this.#r=a,a}},or=class{#e;order;constructor(e){this.#e=w.create(()=>new be,e),this.order=this.#e.length}reset(){this.#e.forEach(e=>e.reset())}process(e,t,r,s,o){for(let n=0;n<this.order;n++)this.#e[n].process(e,t,r,s,o),t=r}processFrame(e,t){for(let r=0;r<this.order;r++)t=this.#e[r].processFrame(e,t);return t}};var aa;(function(i){function e(t,r,s={}){let{interval:o=64,scanSteps:n=1024,scanSamples:a=2048,minBPM:l=90,maxBPM:c=180}=s,d=new Float32Array(Math.floor(t.length/o)),m=0,f=0,y=0;for(let O of t){let X=Math.abs(O);m+=(X-m)*(X>m?1/8:1/512),++f===o&&(f=0,d[y++]=m)}if(!d.length)return NaN;let F=(O,X)=>O[Math.floor(X)]??0,S=O=>r/(O/60)/o,M=O=>r/(O*o)*60,K=[-32,-16,-8,-4,-2,-1,1,2,4,8,16,32],L=[-.5,-.25,.25,.5],z=O=>{let X=Math.random()*d.length,ee=F(d,X),ke=0,_e=0;for(let Ee of K){let He=1/Math.abs(Ee);ke+=He*Math.abs(F(d,X+Ee*O)-ee),_e+=He}for(let Ee of L){let He=Math.abs(Ee);ke-=He*Math.abs(F(d,X+Ee*O)-ee),_e+=He}return ke/_e},_=O=>{let X=0;for(let ee=0;ee<a;++ee)X+=z(O);return X/a},te=S(l),he=S(c),ce=(te-he)/n,H=l,J=1/0;for(let O=he;O<=te;O+=ce){let X=M(O),ee=_(O)*(l/X);ee<J&&(J=ee,H=X)}return H}i.detect=e})(aa||(aa={}));var la;(function(i){i.Major=[0,2,4,5,7,9,11],i.Minor=[0,2,3,5,7,8,10],i.NoteLabels=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],i.compile=(e,t,r,s)=>w.create(o=>{let n=r+o*2,a=e[n%7]+Math.floor(n/7)*12;return t+a},s),i.toString=e=>i.NoteLabels[e%12]+(Math.floor(e/12)-2)})(la||(la={}));var nr;(function(i){i.Comparator=(e,t)=>e.position-t.position,i.PositionExtractor=e=>e.position})(nr||(nr={}));var ar;(function(i){i.complete=e=>e.position+e.duration,i.DescendingComparator=(e,t)=>i.complete(t)-i.complete(e)})(ar||(ar={}));var De;(function(i){i.globalToLocal=(t,r)=>pi(r-t.position+t.loopOffset,t.loopDuration),i.locateLoop=({position:t,complete:r,loopOffset:s,loopDuration:o},n,a)=>{let l=t-s,c=l+o;if(l>=a||c<=n)return p.None;let d=Math.max(l,n),m=Math.min(c,a);return p.wrap({index:0,rawStart:l,rawEnd:c,regionStart:Math.max(l,t),regionEnd:Math.min(c,r),resultStart:d,resultEnd:m,resultStartValue:l<d?(d-l)/o:0,resultEndValue:c>m?(m-l)/o:1})};function*e({position:t,complete:r,loopOffset:s,loopDuration:o},n,a){let l=t-s,c=Math.max(t,n),d=Math.min(r,a),m=Math.floor((c-l)/o),f=l+m*o;for(;f<d;){let y=f+o,F=Math.max(f,t),S=Math.min(y,r),M=Math.max(f,c),K=Math.min(y,d),L=f<M?(M-f)/o:0,z=y>K?(K-f)/o:1;yield{index:m++,rawStart:f,rawEnd:y,regionStart:F,regionEnd:S,resultStart:M,resultEnd:K,resultStartValue:L,resultEndValue:z},f=y}}i.locateLoops=e})(De||(De={}));var Ft=class i{static DefaultComparator=(e,t)=>e.position-t.position;static create(e){return new i(e??i.DefaultComparator)}#e;constructor(e){this.#e=new qi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?ct.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t,r){return this.#e.isEmpty()?ct.empty():this.#e.iterate(this.#e.ceilFirstIndex(e),t,r)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},Nt=class i{static Comparator=(e,t)=>e.position-t.position;static create(e){return new i(e)}#e;constructor(e=i.Comparator){this.#e=new qi(e)}add(e){this.#e.add(e)}remove(e){return this.#e.remove(e)}contains(e){return this.#e.contains(e)}clear(){this.#e.clear()}optAt(e){return this.#e.optAt(e)}asArray(){return this.#e.asArray()}lowerEqual(e,t){return this.#e.lowerEqual(e,t)}greaterEqual(e,t){return this.#e.greaterEqual(e,t)}floorLastIndex(e){return this.#e.floorLastIndex(e)}ceilFirstIndex(e){return this.#e.ceilFirstIndex(e)}iterateFrom(e,t){return this.#e.isEmpty()?ct.empty():this.#e.iterateFrom(e,t)}iterateRange(e,t){if(this.#e.isEmpty())return ct.empty();let r=Math.max(0,this.#e.floorLastIndex(e)),s=this.#e.optAt(r);if(s===null)return ct.empty();for(;s.position+s.duration<=e;)if(s=this.#e.optAt(++r),s===null||s.position>=t)return ct.empty();return this.#e.iterate(r,t)}length(){return this.#e.length()}isEmpty(){return this.#e.isEmpty()}onIndexingChanged(){this.#e.onIndexingChanged()}},Br=class{#e;constructor(){this.#e=[]}addAndRetain(e){if(this.#e.length===0)this.#e.push(e);else{let t=se.leftMost(this.#e,e,ar.DescendingComparator);this.#e.splice(t,0,e)}}*overlapping(e,t){let r=this.#e.filter(s=>s.position<=e&&e<s.position+s.duration);yield*T(t)?r.sort(t):r}*releaseLinearCompleted(e){if(this.#e.length!==0)for(let t=this.#e.length-1;t>=0;t--){let r=this.#e[t];if(ar.complete(r)<e)this.#e.splice(t,1),yield r;else return}}*releaseAll(){if(this.#e.length!==0)for(let e=this.#e.length-1;e>=0;e--){let t=this.#e[e];Number.POSITIVE_INFINITY>t.duration&&(this.#e.splice(e,1),yield t)}}isEmpty(){return this.#e.length===0}nonEmpty(){return this.#e.length>0}clear(){w.clear(this.#e)}},qi=class{comparator;#e=[];#t=!1;modCount=0;constructor(e){this.comparator=e}add(e){++this.modCount,this.#e.push(e),this.#e.length>1&&(this.#t=!0)}remove(e){++this.modCount;let t=this.#e.indexOf(e);return t===-1?!1:(this.#e.splice(t,1),!0)}contains(e){if(this.#e.length===0)return!1;this.#t&&this.#r();let r=e.position,s=se.leftMostMapped(this.#e,r,bt,nr.PositionExtractor);for(let o=s;o<this.#e.length;o++){let n=this.#e[o];if(n===e)return!0;if(n.position!==r)return!1}return!1}clear(){++this.modCount,w.clear(this.#e),this.#t=!1}optAt(e){return e<0||e>=this.#e.length?null:(this.#t&&this.#r(),this.#e[e])}asArray(){return this.#t&&this.#r(),this.#e}lowerEqual(e,t){if(t===void 0)return this.optAt(this.floorLastIndex(e));let r=this.floorLastIndex(e);for(;r>=0;){let s=this.#e[r--];if(t(s))return s}return null}greaterEqual(e,t){if(t===void 0)return this.optAt(this.ceilFirstIndex(e));let r=this.ceilFirstIndex(e);for(;r<this.#e.length;){let s=this.#e[r++];if(t(s))return s}return null}floorLastIndex(e){return this.#t&&this.#r(),se.rightMostMapped(this.#e,e,bt,nr.PositionExtractor)}ceilFirstIndex(e){return this.#t&&this.#r(),se.leftMostMapped(this.#e,e,bt,nr.PositionExtractor)}iterateFrom(e,t){let r=this.floorLastIndex(e),s=r;if(s<0)return this.iterate(0,Se.MAX_VALUE,t);for(;s>=0;){let o=this.optAt(s);if(o!==null&&t!==void 0&&t(o))return this.iterate(s,Se.MAX_VALUE,t);s--}return this.iterate(r,Se.MAX_VALUE,t)}length(){return this.#e.length}isEmpty(){return this.#e.length===0}onIndexingChanged(){this.#t=this.length()>1}*iterate(e,t,r=Ui.alwaysTrue){for(this.#t&&this.#r();e<this.#e.length;){let s=this.#e[e++];if(s.position>=t)return;r(s)&&(yield s)}}#r(){this.#e.sort(this.comparator),this.#t=!1}};var zi=class i{static reverse(e){return e=(e&1431655765)<<1|e>>>1&1431655765,e=(e&858993459)<<2|e>>>2&858993459,e=(e&252645135)<<4|e>>>4&252645135,e=e<<24|(e&65280)<<8|e>>>8&65280|e>>>24,e}#e;#t;#r;#i;constructor(e){this.#e=e;let t=e/2;this.#t=32-Math.floor(Math.log2(e))|0,this.#r=new Float32Array(t),this.#i=new Float32Array(t);for(let r=0;r<t;r++){let s=2*Math.PI*r/e;this.#r[r]=Math.cos(s),this.#i[r]=Math.sin(s)}}process(e,t){let r,s,o,n;for(let c=0;c<this.#e;++c)s=i.reverse(c)>>>this.#t,s>c&&(n=e[c],e[c]=e[s],e[s]=n,n=t[c],t[c]=t[s],t[s]=n);let a=this.#r,l=this.#i;for(let c=2;c<=this.#e;c<<=1){let d=c>>1,m=this.#e/c;for(r=0;r<this.#e;r+=c){let f=r+d;for(s=r,o=0;s<f;s++,o=o+m|0){let y=s+d|0,F=a[o],S=l[o],M=e[y],K=t[y],L=M*F+K*S,z=K*F-M*S,_=e[s],te=t[s];e[y]=_-L,t[y]=te-z,e[s]=_+L,t[s]=te+z}}if(c===this.#e)break}}};var fn=(i,e)=>Math.floor(3840/e)*i,ua=(i,e=4,t=4)=>{let r=fn(1,t),s=Math.floor(i/r),o=Math.floor(s/e),a=(Math.floor(i)-fn(o*e,t))%r,l=Math.floor(a/240),c=a%240;return{bars:o,beats:s-o*e,semiquavers:l,ticks:c}},ca=(i,e)=>i*e/60*960,ha=(i,e)=>i*60/960/e,ol=(i,e,t)=>ca(i/t,e),nl=(i,e,t)=>ha(i,e)*t,G={Bar:3840,Quarter:960,SemiQuaver:240,fromSignature:fn,toParts:ua,secondsToPulses:ca,pulsesToSeconds:ha,samplesToPulses:ol,pulsesToSamples:nl,toString:(i,e=4,t=4)=>{let{bars:r,beats:s,semiquavers:o,ticks:n}=ua(i|0,e,t);return`${r+1}.${s+1}.${o+1}:${n}`}};var je;(function(i){i.builder=()=>new e,i.toDouble=([t,r])=>t/r,i.toPPQN=([t,r])=>G.fromSignature(t,r);class e{#e=[];add(r){return this.#e.push(r),this}asArray(){return this.#e}asAscendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(r)-i.toDouble(s))}asDescendingArray(){return this.#e.toSorted((r,s)=>i.toDouble(s)-i.toDouble(r))}}})(je||(je={}));var Pt=class{static*iterate(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield o,o=++s*r}static*iterateWithIndex(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield{position:o,index:s},o=++s*r}};var _i=class{#e;#t;constructor(){this.#e=[],this.#t=new Map}addVertex(e){v(!this.#e.includes(e),"Vertex already exists"),this.#e.push(e),v(!this.#t.has(e),"Predecessor already exists"),this.#t.set(e,[])}removeVertex(e){w.remove(this.#e,e);let t=this.#t.delete(e);v(t,"Predecessor does not exists")}getPredecessors(e){return this.#t.get(e)??w.empty()}predecessors(){return this.#t}vertices(){return this.#e}addEdge([e,t]){let r=k(this.#t.get(t),`[add] Edge has unannounced vertex. (${t})`);v(!r.includes(e),`${e} is already marked.`),r.push(e)}removeEdge([e,t]){let r=k(this.#t.get(t),`[remove] Edge has unannounced vertex. (${t})`);v(r.includes(e),`${e} is not marked.`),w.remove(r,e)}isEmpty(){return this.#e.length===0}},Hi=class{#e;#t;#r;#i;#s;constructor(e){this.#e=e,this.#t=[],this.#r=new Set,this.#i=new Set,this.#s=new Map}update(){this.#o(),this.#e.vertices().forEach(e=>this.#n(e))}sorted(){return this.#t}hasLoops(){return this.#i.size!==0}#o(){this.#a();let e=new Map;for(let r of this.#e.vertices())this.#s.set(r,new Set),e.set(r,new Set);for(let r of this.#e.vertices())for(let s of this.#e.getPredecessors(r))k(this.#s.get(s),`Could not find Successor for ${s}`).add(r);let t;do{t=!1;for(let r of this.#e.vertices()){k(e.get(r)).clear();for(let s of k(this.#s.get(r)))for(let o of k(this.#s.get(s)))this.#s.get(r)?.has(o)||(t=!0,k(e.get(r)).add(o))}for(let r of this.#e.vertices()){let s=k(this.#s.get(r));k(e.get(r)).forEach(o=>s.add(o))}}while(t)}#n(e){if(!this.#r.has(e)){this.#r.add(e);for(let t of this.#e.getPredecessors(e)){if(k(this.#s.get(e)).has(t)){this.#i.add(e),this.#i.add(t);continue}this.#n(t)}this.#t.push(e)}}#a(){w.clear(this.#t),this.#r.clear(),this.#i.clear(),this.#s.clear()}};var xi;(function(i){i.Identity={warp:e=>e,unwarp:e=>e}})(xi||(xi={}));var Gi=class{#e;constructor(e){this.#e=e}warp(e){return this.#t(!0,e)}unwarp(e){return this.#t(!1,e)}#t(e,t){let r=this.#e.duration(),s=at(t,r),o=(t-s)/r,n=e?this.#e.fx(o):this.#e.fy(o);return s+n*r}};var da;(function(i){i.BlackKeyIndices=[1,3,6,8,10],i.BlackKeyBits=i.BlackKeyIndices.reduce((t,r)=>t|=1<<r,0),i.Names={English:["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],German:["C","Cis","D","Dis","E","F","Fis","G","Gis","A","Ais","H"],Solfege:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],French:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Spanish:["Do","Do#","Re","Re#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Japanese:["\u30C9","\u30C9\u266F","\u30EC","\u30EC\u266F","\u30DF","\u30D5\u30A1","\u30D5\u30A1\u266F","\u30BD","\u30BD\u266F","\u30E9","\u30E9\u266F","\u30B7"]},i.isBlackKey=t=>(i.BlackKeyBits&1<<t%12)!==0,i.toFullString=t=>`${i.Names.English[t%12]}${Math.floor(t/12)-2}`;class e{#e;#t;constructor(r,...s){this.#e=r,this.#t=s.reduce((o,n)=>o|=1<<n,0)}get name(){return this.#e}get bits(){return this.#t}has(r){return(this.#t&1<<r%12)!==0}equals(r){return this.#t===r.bits}}i.StockScales=[new e("Major",0,2,4,5,7,9,11),new e("Natural Minor",0,2,3,5,7,8,10),new e("Harmonic Minor",0,2,3,5,7,8,11),new e("Melodic Minor",0,2,3,5,7,9,11),new e("Dorian",0,2,3,5,7,9,10),new e("Phrygian",0,1,3,5,7,8,10),new e("Lydian",0,2,4,6,7,9,11),new e("Mixolydian",0,2,4,5,7,9,10),new e("Locrian",0,1,3,5,6,8,10),new e("Pentatonic Major",0,2,4,7,9),new e("Pentatonic Minor",0,3,5,7,10),new e("Blues",0,3,5,6,7,10),new e("Whole Tone",0,2,4,6,8,10),new e("Diminished",0,2,3,5,6,8,9,11),new e("Augmented",0,3,4,7,8,11)]})(da||(da={}));var Me;(function(i){i.isOfType=e=>e.type==="note-event",i.Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.pitch-t.pitch;return s!==0?s:0},i.curveFunc=(e,t)=>t<0?e**2**-t:1-(1-e)**2**t,i.inverseCurveFunc=(e,t)=>t<0?e**2**t:1-Math.max(0,1-e)**2**-t,i.CompleteComparator=(e,t)=>{let r=ar.complete(e)-ar.complete(t);return r!==0?r:e.pitch-t.pitch}})(Me||(Me={}));var ht;(function(i){i[i.sine=0]="sine",i[i.triangle=1]="triangle",i[i.sawtooth=2]="sawtooth",i[i.square=3]="square"})(ht||(ht={}));var Wi=class{#e=0;#t=0;generate(e,t,r,s,o){for(let n=s;n<o;n++){let a=this.#e%1,l=0;switch(r){case ht.sine:l=Math.sin(2*Math.PI*a);break;case ht.sawtooth:l=2*a-1,l-=this.#r(a,t);break;case ht.square:l=a<.5?1:-1,l+=this.#r(a,t),l-=this.#r((a+.5)%1,t);break;case ht.triangle:let c=a<.5?1:-1;c+=this.#r(a,t),c-=this.#r((a+.5)%1,t),this.#t+=c*(4*t),l=this.#t;break}e[n]=l,this.#e+=t}}#r(e,t){return e<t?(e/=t,e+e-e*e-1):e>1-t?(e=(e-1)/t,e*e+e+e+1):0}};var dt;(function(i){let e;(function(t){t[t.Linear=0]="Linear",t[t.EqualPower=1]="EqualPower"})(e=i.Mixing||(i.Mixing={})),i.zero=()=>({ll:0,lr:0,rl:0,rr:0}),i.identity=()=>({ll:1,lr:0,rl:0,rr:1}),i.update=(t,{gain:r,panning:s,invertL:o,invertR:n,stereo:a,swap:l},c=e.EqualPower)=>{let[d,m]=i.panningToGains(s,c),f=d*r,y=m*r;o&&(f*=-1),n&&(y*=-1);let F=Math.max(0,-a),S=Math.max(0,a),M=1-S,K=1+S,L=F*.5,z=1-F,_=(M+K)*.5,te=(M-K)*.5,he=(M-K)*.5,ce=(M+K)*.5,H=f*(L+z)*_+y*L*te,J=f*(L+z)*he+y*L*ce,O=f*L*_+y*(L+z)*te,X=f*L*he+y*(L+z)*ce;l?(t.ll=J,t.rl=H,t.lr=X,t.rr=O):(t.ll=H,t.lr=O,t.rl=J,t.rr=X)},i.panningToGains=(t,r)=>{let s=$(t,-1,1);switch(r){case e.Linear:return[Math.min(1-s,1),Math.min(s+1,1)];case e.EqualPower:return[Math.cos((s+1)*an),Math.sin((s+1)*an)]}},i.applyFrame=(t,r,s)=>[t.ll*r+t.rl*s,t.lr*r+t.rr*s],i.processFrames=(t,r,s,o,n)=>{let[a,l]=r,[c,d]=s;for(let m=o;m<n;m++){let f=a[m],y=l[m];c[m]=t.ll*f+t.rl*y,d[m]=t.lr*f+t.rr*y}},i.replaceFrames=(t,[r,s],o,n)=>{for(let a=o;a<n;a++){let l=r[a],c=s[a];r[a]=t.ll*l+t.rl*c,s[a]=t.lr*l+t.rr*c}}})(dt||(dt={}));var Qe;(function(i){i.linear=(r,s=.005)=>new e(Math.ceil(r*s)|0),i.stereoMatrix=(r,s=.005)=>new t(Math.ceil(r*s)|0);class e{#e;#t=0;#r=0;#i=0;#s=0;constructor(s){this.#e=s}set(s,o){this.#t!==s&&(o===!0?(this.#r=s,this.#i=(s-this.#t)/this.#e,this.#s=this.#e):(this.#t=this.#r=s,this.#i=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t+=this.#i,--this.#s===0&&(this.#i=0,this.#t=this.#r)),this.#t}isFixed(s){return this.#t===s&&this.#s===0}isInterpolating(){return this.#s>0}}class t{#e;#t=dt.zero();#r=dt.zero();#i=dt.zero();#s=0;constructor(s){this.#e=s}update(s,o,n){dt.update(this.#r,s,o),n===!0?(this.#i.ll=(this.#r.ll-this.#t.ll)/this.#e,this.#i.lr=(this.#r.lr-this.#t.lr)/this.#e,this.#i.rl=(this.#r.rl-this.#t.rl)/this.#e,this.#i.rr=(this.#r.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0)}processFrames(s,o,n,a){let[l,c]=s,[d,m]=o;if(this.isInterpolating())for(let f=n;f<a;f++){let y=l[f],F=c[f],S=this.moveAndGet();d[f]=S.ll*y+S.rl*F,m[f]=S.lr*y+S.rr*F}else{let f=this.#r;for(let y=n;y<a;y++){let F=l[y],S=c[y];d[y]=f.ll*F+f.rl*S,m[y]=f.lr*F+f.rr*S}}}set(s,o){this.#o(s)||(o===!0?(this.#r.ll=s.ll,this.#r.lr=s.lr,this.#r.rl=s.rl,this.#r.rr=s.rr,this.#i.ll=(s.ll-this.#t.ll)/this.#e,this.#i.lr=(s.lr-this.#t.lr)/this.#e,this.#i.rl=(s.rl-this.#t.rl)/this.#e,this.#i.rr=(s.rr-this.#t.rr)/this.#e,this.#s=this.#e):(this.#t.ll=this.#r.ll=s.ll,this.#t.lr=this.#r.lr=s.lr,this.#t.rl=this.#r.rl=s.rl,this.#t.rr=this.#r.rr=s.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0))}get(){return this.#t}moveAndGet(){return 0<this.#s&&(this.#t.ll+=this.#i.ll,this.#t.lr+=this.#i.lr,this.#t.rl+=this.#i.rl,this.#t.rr+=this.#i.rr,--this.#s===0&&(this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#t.ll=this.#r.ll,this.#t.lr=this.#r.lr,this.#t.rl=this.#r.rl,this.#t.rr=this.#r.rr)),this.#t}isFixed(s){return this.#o(s)&&this.#s===0}isInterpolating(){return this.#s>0}#o(s){return this.#t.ll===s.ll&&this.#t.lr===s.lr&&this.#t.rl===s.rl&&this.#t.rr===s.rr}}i.StereoMatrixRamp=t})(Qe||(Qe={}));var Fr=class{#e;#t;#r;#i;constructor(e){this.#e=new Float32Array(e),this.#t=1/e,this.#r=0,this.#i=0}pushPop(e){let t=e*e;return this.#i-=this.#e[this.#r],this.#i+=t,this.#e[this.#r]=t,++this.#r===this.#e.length&&(this.#r=0),this.#i<=0?0:Math.sqrt(this.#i*this.#t)}clear(){this.#e.fill(0),this.#i=0,this.#r=0}};var al=Math.log(10)/20,pa=(i=60,e=440)=>e*Math.pow(2,(i+3)/12-6);var Ae=i=>Math.exp(i*al);var ji=i=>Ae(20*Math.log10(i));var St={None:{type:"none"},Linear:{type:"linear"},Curve:i=>({type:"curve",slope:i})},Qi;(function(i){i.Comparator=(s,o)=>{let n=s.position-o.position;if(n!==0)return n;let a=s.index-o.index;return a!==0?a:s===o?0:g(`${s} and ${o} are identical in terms of comparison`)};function*e(s,o,n){if(s.isEmpty())return le.empty();for(let a of s.iterateFrom(o))if(yield a,a.position>=n)return}i.iterateWindow=e,i.nextEvent=(s,o)=>{let n=s.asArray(),a=se.rightMost(n,o,i.Comparator);return a===-1?null:n[a+1]??null},i.valueAt=(s,o,n)=>{if(s.isEmpty())return n;let a=s.iterateFrom(o),{done:l,value:c}=a.next();if(l)return n;if(c.position<=o){let{done:d,value:m}=a.next();if(d)return c.value;if(o<m.position)return r(c,m,o);if(c.interpolation===St.None)return c.value}return c.value};function*t(s,o,n,a){if(s.isEmpty())return;let l=s.iterateFrom(o),{done:c,value:d}=l.next();if(c)return;let m=n/a,f=d;if(f.position>o){for(;o<f.position;)if(yield{position:o,value:f.value},o+=m,o>n)return;f.position<=n&&(yield f)}for(;o<=n;){let{done:y,value:F}=l.next();if(y)break;for(;o<F.position;){if(o>n)return;yield{position:o,value:r(f,F,o)},o+=m}F.position<n&&(f.interpolation===St.None&&(yield{position:F.position,value:f.value}),yield F),f=F}for(;o<=n;)yield{position:o,value:f.value},o+=m}i.quantise=t;let r=({value:s,position:o,interpolation:n},a,l)=>n.type==="none"?s:n.type==="linear"?s+(l-o)/(a.position-o)*(a.value-s):n.type==="curve"?Ue.valueAt({slope:n.slope,steps:a.position-o,y0:s,y1:a.value},l-o):g("Unknown interpolation")})(Qi||(Qi={}));var yi;(function(i){let e;(function(t){t[t.Bartlett=0]="Bartlett",t[t.Blackman=1]="Blackman",t[t.BlackmanHarris=2]="BlackmanHarris",t[t.Hamming=3]="Hamming",t[t.Hanning=4]="Hanning"})(e=i.Type||(i.Type={})),i.create=(t,r)=>{let s=new Float32Array(r),o=Math.PI/(r-1);switch(t){case e.Bartlett:{let n=(r>>1)-1,a=0;for(;a<=n;++a)s[a]=2*a/(r-1);for(;a<r;++a)s[a]=2-2*a/(r-1);return s}case e.Blackman:{let n=2*o,a=4*o;for(let l=0;l<r;++l)s[l]=.42323-.49755*Math.cos(n*l)+.07922*Math.cos(a*l);return s}case e.BlackmanHarris:{let n=2*o,a=4*o,l=6*o;for(let c=0;c<r;++c)s[c]=.35875-.48829*Math.cos(n*c)+.14128*Math.cos(a*c)-.01168*Math.cos(l*c);return s}case e.Hamming:{let n=2*o;for(let a=0;a<r;++a)s[a]=.54-.46*Math.cos(n*a);return s}case e.Hanning:{let n=2*o;for(let a=0;a<r;++a)s[a]=.5-.5*Math.cos(n*a);return s}}}})(yi||(yi={}));var Yi=Symbol.for("@openDAW/lib-dsp");globalThis[Yi]?console.debug(`%c${Yi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Yi]=!0,console.debug(`%c${Yi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Xi=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o=0;constructor({processorOptions:{sab:e,numberOfChannels:t,rmsWindowInSeconds:r,valueDecay:s}}){super(),this.#e=t,this.#t=new Float32Array(t),this.#r=new Float32Array(t),this.#i=w.create(()=>new Fr(sampleRate*r),t);let o=Re.createBuilder({peak:Re.floats(t),rms:Re.floats(t)})();this.#s=Er.writer(o,e,n=>{let a=Math.exp(-(128*this.#o)/(sampleRate*s));for(let l=0;l<t;++l){let c=this.#t[l],d=this.#r[l];n.peak[l]=c,n.rms[l]=Math.sqrt(d),this.#t[l]=c*a,this.#r[l]=d*a}this.#o=0})}process([e]){for(let t=0;t<this.#e;++t){let r=e[t];if(r===void 0)this.#t[t]=0,this.#r[t]=0;else{let s=this.#i[t],o=this.#t[t],n=this.#r[t];for(let a=0;a<128;++a){let l=r[a];o=Math.max(o,Math.abs(l)),n=Math.max(n,s.pushPop(l*l))}this.#t[t]=o,this.#r[t]=n}}return this.#o++,this.#s.tryWrite(),!0}};var W=class i{static newSet(e){return new wt(e,i.Comparator)}static compose=(e,...t)=>{let r=t.length===0?this.#e:new Int16Array(t);return v(r.every((s,o)=>s===t[o]),`fieldKeys (${r.join(",")}) only allows i16`),new i(e,r)};static decode(e){let t=e.split("/");return v(t.length>0,"Unable to parse Address"),i.compose(A.parse(t[0]),...t.slice(1).map(r=>parseInt(r)))}static reconstruct(e){return this.compose(e[0],...e[1])}static boxRange(e,t,r){let s=e.values(),o=se.leftMostMapped(s,t,A.Comparator,r),n=s.length;if(o<0||o>=n)return null;for(let a=o;a<n;a++)if(A.Comparator(r(s[a]),t)!==0)return o<a?[o,a]:null;return[o,n]}static Comparator=(e,t)=>{let r=A.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return e.#r.length-t.#r.length};static MinimalComparator=(e,t)=>{let r=A.Comparator(e.#t,t.#t);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return 0};static LengthComparator=(e,t)=>{let r=A.Comparator(e.#t,t.#t);return r!==0?r:t.#r.length-e.#r.length};static#e=new Int16Array(0);#t;#r;constructor(e,t){this.#t=e,this.#r=t}get uuid(){return this.#t}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(e){return i.Comparator(this,e)===0}compareTo(e){return i.Comparator(this,e)}append(e){return new i(this.#t,new Int16Array([...this.#r,e]))}startsWith(e){return A.Comparator(e.#t,this.#t)===0&&e.#r.length<=this.#r.length&&e.#r.every((t,r)=>this.#r[r]===t)}write(e){e.writeBytes(new Int8Array(this.#t.buffer)),e.writeByte(this.#r.length),this.#r.forEach(t=>e.writeShort(t))}moveTo(e){return new i(e,this.#r)}decompose(){return[this.#t,this.#r]}toJSON(){return{uuid:Array.from(this.#t.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let e=new Uint8Array(A.length+this.#r.length);return e.set(this.#t,0),e.set(this.#r,A.length),e.buffer}toString(){return[A.toString(this.#t),...this.#r].join("/")}static read(e){let t=A.fromDataInput(e),r=e.readByte();return i.compose(t,...w.create(()=>e.readShort(),r))}},lr;(function(i){i.AddressReader=e=>e.address,i.Comparator=({address:e},{address:t})=>W.Comparator(e,t),i.equals=(e,t)=>{let[r,s]=se.rangeMapped(t,e,W.Comparator,i.AddressReader);return t.slice(r,s+1)},i.startsWith=(e,t)=>{let[r,s]=se.rangeMapped(t,e,W.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>o.address.startsWith(e))},i.endsWith=(e,t)=>{let r=se.leftMostMapped(t,e,W.LengthComparator,i.AddressReader),s=se.rightMostMapped(t,e,W.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>e.startsWith(o.address))}})(lr||(lr={}));var Ze=class i{static validate(e,t){if(e.address.equals(t.address))return p.wrap(`PointerField cannot point to itself: ${e}`);if(!t.pointerRules.accepts.some(r=>r===e.pointerType)){let r=t.pointerRules.accepts.join(", ");return p.wrap(`${String(e.pointerType)} does not satisfy any of the allowed types (${r}).`)}return p.None}#e;#t;#r;#i=p.None;constructor(e){this.#e=e,this.#t=new ve,this.#r=new ve}subscribeImmediate(e,...t){return this.#s(this.#t,e,t)}subscribeTransactual(e,...t){return this.#s(this.#r,e,t)}catchupAndSubscribeTransactual(e,...t){let r=W.newSet(s=>s.address);return r.addMany(this.filter(...t)),r.forEach(s=>e.onAdd(s)),this.subscribeTransactual({onAdd:s=>{r.add(s)&&e.onAdd(s)},onRemove:s=>{r.removeByKey(s.address),e.onRemove(s)}},...t)}filter(...e){return e.length===0?this.incoming():le.filter(this.incoming().values(),t=>e.some(r=>r===t.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(e){return this.incoming().some(t=>e.address.equals(t.address))}incoming(){return this.#e.graph.edges().incomingEdgesOf(this.#e)}onAdded(e){let t=i.validate(e,this.#e);if(t.nonEmpty())return g(t.unwrap());this.#i.isEmpty()?(this.#i=p.wrap([{type:"add",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"add",pointerField:e}),this.#t.proxy.onAdd(e)}onRemoved(e){this.#i.isEmpty()?(this.#i=p.wrap([{type:"remove",pointerField:e}]),this.#e.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"remove",pointerField:e}),this.#t.proxy.onRemove(e)}toString(){return`{Pointers ${this.#e.address}, pointers: ${this.incoming().values().map(e=>e.toString())}}`}#s(e,t,r){return e.subscribe({onAdd:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onAdd(s)},onRemove:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onRemove(s)}})}#o=()=>{let e=this.#i.unwrap("Callback without ChangeLog");e.forEach(({type:t,pointerField:r})=>{if(t==="add")this.#r.proxy.onAdd(r);else if(t==="remove")this.#r.proxy.onRemove(r);else return Ge(t)}),e.length=0,this.#i=p.None}};var gn=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},Nr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},I=class i{static hook(e){return new i(e)}#e;#t;#r;#i;constructor({parent:e,fieldKey:t,fieldName:r,pointerRules:s}){this.#e=e,this.#t=t,this.#r=r,this.#i=s,s.mandatory&&this.graph.edges().watchVertex(this)}accept(e){return x(e.visitField,this)}get box(){return this.#e.box}get graph(){return this.#e.graph}get parent(){return this.#e}get fieldKey(){return this.#t}get fieldName(){return this.#r}get pointerRules(){return this.#i}get pointerHub(){return new Ze(this)}get address(){return this.#e.address.append(this.#t)}get debugPath(){return`${this.box.name}:${this.box.mapFields(e=>e.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return w.empty()}record(){return Je.empty()}getField(e){return g()}optField(e){return p.None}read(e){}write(e){}toJSON(){}fromJSON(e){return g("fromJSON should never be called on a field")}disconnect(){if(this.pointerHub.isEmpty())return;let e=this.pointerHub.incoming();e.forEach(t=>{t.defer(),(t.mandatory||this.pointerRules.mandatory&&e.length===1)&&t.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};gn([br,Nr("design:type",Ze),Nr("design:paramtypes",[])],I.prototype,"pointerHub",null);gn([br,Nr("design:type",W),Nr("design:paramtypes",[])],I.prototype,"address",null);gn([br,Nr("design:type",String),Nr("design:paramtypes",[])],I.prototype,"debugPath",null);var h=Object.freeze({mandatory:!1,accepts:[]});var Pr=class i extends I{static create(e,t,r){return new i(e,t,r)}#e;constructor(e,t,r){super(e),this.#e=w.create(s=>t({parent:this,fieldKey:s,fieldName:String(s),pointerRules:h}),r)}accept(e){return x(e.visitArrayField,this)}fields(){return this.#e}record(){return this.#e.reduce((e,t)=>(e[String(t.fieldKey)]=t,e),{})}getField(e){return k(this.#e[e])}optField(e){return p.wrap(this.#e[e])}read(e){this.#e.forEach(t=>t.read(e))}write(e){this.#e.forEach(t=>t.write(e))}size(){return this.#e.length}toJSON(){return Object.values(this.#e).map(e=>e.toJSON()??null)}fromJSON(e){if(Array.isArray(e))e.forEach((t,r)=>this.#e[r].fromJSON(t));else return g("Type mismatch")}};var Ct;(function(i){i.writeFields=(t,r)=>{let s=Object.entries(r);t.writeInt(1179403347),t.writeShort(s.length),s.forEach(([o,n])=>{let a=de.create();n.write(a);let l=new Int8Array(a.toArrayBuffer());t.writeShort(Number(o)),t.writeInt(l.length),t.writeBytes(l)})},i.readFields=(t,r)=>{v(t.readInt()===1179403347,"Serializer header is corrupt");let s=t.readShort();for(let o=0;o<s;o++){let n=t.readShort();if(Un(r[n]))continue;let a=t.readInt(),l=new Int8Array(a);t.readBytes(l);let{status:c,error:d}=rr(()=>r[n]?.read(new ge(l.buffer)));c==="failure"&&console.warn(r,d)}}})(Ct||(Ct={}));var ll=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},ma=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},P=class i{static DEBUG_DELETION=!1;static Index=0;#e;#t;#r;#i;#s;#o=i.Index++;constructor({uuid:e,graph:t,name:r,pointerRules:s}){this.#e=W.compose(e),this.#t=t,this.#r=r,this.#i=s,this.#s=this.initializeFields(),s.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#s)}record(){return this.#s}getField(e){return k(this.#s[e])}optField(e){return p.wrap(this.#s[e])}subscribe(e,t){return this.graph.subscribeVertexUpdates(e,this.address,t)}get box(){return this}get name(){return this.#r}get graph(){return this.#t}get parent(){return this}get address(){return this.#e}get pointerRules(){return this.#i}get creationIndex(){return this.#o}get pointerHub(){return new Ze(this)}estimateMemory(){let e=new vr;return this.write(e),e.count}isBox(){return!0}asBox(e){return er(this,e)}isField(){return!1}isAttached(){return this.#t.findBox(this.address.uuid).nonEmpty()}read(e){Ct.readFields(e,this.#s)}write(e){Ct.writeFields(e,this.#s)}serialize(){let e=de.create();return e.writeInt(this.#o),e.writeString(this.name),e.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(e),e.toArrayBuffer()}toArrayBuffer(){let e=de.create();return this.write(e),e.toArrayBuffer()}toJSON(){return Object.entries(this.#s).reduce((e,[t,r])=>{let s=r.toJSON();return T(s)&&(e[t]=s),e},{})}fromJSON(e){if(vt(e))Object.entries(e).forEach(([t,r])=>{let s=this.#s[parseInt(t)];T(r)&&s.fromJSON(r)});else return g("Type mismatch")}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(e,...t){if(t.length===0)return w.empty();let r=this.getField(t[0]),s=[e(r)];for(let o=1;o<t.length;o++)r=r.getField(t[o]),s.push(e(r));return s}searchVertex(e){if(e.length===0)return p.wrap(this);let t=this.optField(e[0]);if(t.isEmpty())return p.None;for(let r=1;r<e.length;r++)if(t=t.unwrap().optField(e[r]),t.isEmpty())return p.None;return t}delete(){if(!this.isAttached())return;let{boxes:e,pointers:t}=this.graph.dependenciesOf(this);i.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...t].map(r=>r.toString()).join(`
|
1
|
+
var gi=i=>i,V=i=>i!=null,Jt=i=>i===null;var Ui=i=>i===void 0,Ki=i=>i!==void 0,Li=i=>i==null,xn=(i,e)=>i!=null?e(i):void 0,K=(i,e="asDefined failed")=>i??g(tr(e)),ae=(i,e)=>i instanceof e,er=(i,e)=>i instanceof e?i:g(`${i} is not instance of ${e}`),yn=(i,e)=>{i instanceof e||g(`${i} is not instance of ${e}`)};var tr=i=>i instanceof Function?i():i;var x=(i,...e)=>i?.apply(null,e),bt=i=>V(i)&&typeof i=="object",vn=(i,e,t)=>{if(!(e in i))return!1;let r=i[e];return t==="null"?r===null:typeof r===t},ea=(i,...e)=>{let t=i;for(let r of e){if(!bt(t)||!(r in t))return;t=t[r]}return t},Ge=i=>{throw new Error(`Unhandled ${i}`)},g=i=>{throw typeof i=="string"?new Error(i):i},b=(i,e)=>i?void 0:g(tr(e));var bn=i=>new Proxy({},{get(){return g(i)}});var rr=i=>{try{return{error:null,value:i(),status:"success"}}catch(e){return{error:e,value:null,status:"failure"}}};var ta=(i,e)=>Object.keys(e).length===0?g("Empty enum object (are you using `const enum`?)"):Object.keys(e).filter(s=>isNaN(Number(s))).map(s=>e[s]).includes(i)?i:g(`Invalid enum value: ${String(i)}`),at=()=>{};var ra=i=>{};var An;(function(i){i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(An||(An={}));var w=class{static#t=Object.freeze(new Array(0));static empty=()=>this.#t;static clear=e=>{e.length=0};static replace=(e,t)=>{e.length=0,e.push(...t)};static consume=(e,t)=>{for(let r=0;r<e.length;)t(e[r])?e.splice(r,1):r++};static peekFirst=e=>e.at(0)??null;static peekLast=e=>e.at(-1)??null;static getFirst=(e,t)=>K(e.at(0),t);static getLast=(e,t)=>K(e.at(-1),t);static getPrev=(e,t)=>{let r=e.indexOf(t);return r===-1?g(`${t} not found in ${e}`):K(e.at((r-1)%e.length),"Internal Error")};static getNext=(e,t)=>{let r=e.indexOf(t);return r===-1?g(`${t} not found in ${e}`):K(e.at((r+1)%e.length),"Internal Error")};static removeLast=(e,t)=>K(e.pop(),t);static create=(e,t)=>{let r=new Array(t);for(let s=0;s<t;s++)r[s]=e(s);return r};static equals=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0};static satisfy=(e,t)=>{if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++)if(!t(r,e[s]))return!1;return!0};static remove=(e,t)=>{let r=e.indexOf(t);if(r===-1)return g(`${t} not found in ${e}`);e.splice(r,1)};static removeIf=(e,t)=>{for(let r=e.length-1;r>=0;r--)t(e[r])&&e.splice(r,1)};static removeOpt=(e,t)=>{let r=e.indexOf(t);return r===-1?!1:(e.splice(r,1),!0)};static hasDuplicates=e=>new Set(e).size<e.length;static removeDuplicates=e=>{let t=0,r=new Set;for(let s of e)r.has(s)||(r.add(s),e[t++]=s);return e.length=t,e};static removeDuplicateKeys=(e,t)=>{let r=0,s=new Set;for(let o of e){let n=o[t];s.has(n)||(s.add(n),e[r++]=o)}return e.length=r,e};static subtract(e,t,r){return e.filter(s=>!t.some(o=>r(s,o)))}static intersect(e,t,r){return e.filter(s=>t.some(o=>r(s,o)))}static merge(e,t,r){return[...e.filter(s=>!t.some(o=>r(s,o))),...t]}static*iterate(e){for(let t=0;t<e.length;t++)yield e[t]}static*iterateReverse(e){for(let t=e.length-1;t>=0;t--)yield e[t]}static*iterateStateFull(e){let t=e.length-1;for(let r=0;r<=t;r++)yield{value:e[r],isFirst:r===0,isLast:r===t}}static*iterateAdjacent(e){if(!(e.length<=1))for(let t=1,r=e[0];t<e.length;t++){let s=e[t];yield[r,s],r=s}}static isSorted(e,t=An.Ascending){if(e.length<2)return!0;let r=e[0];for(let s=1;s<e.length;s++){let o=e[s];if(Math.sign(r-o)===t)return!1;r=o}return!0}static toRecord(e,t){return e.reduce((r,s)=>(r[t(s)]=s,r),{})}};var p;(function(i){i.wrap=t=>V(t)?new e(t):i.None,i.from=t=>i.wrap(t()),i.tryFrom=t=>{try{return i.wrap(t())}catch{return i.None}},i.execute=(t,...r)=>i.wrap(t?.apply(null,r)),i.async=t=>t.then(r=>i.wrap(r),()=>i.None);class e{#t;constructor(r){this.#t=K(r)}unwrap(){return this.#t}unwrapOrElse(r){return this.#t}unwrapOrNull(){return this.#t}unwrapOrUndefined(){return this.#t}contains(r){return r===this.#t}match(r){return r.some(this.#t)}ifSome(r){return r(this.#t)}ifAbsent(r){}isEmpty(){return!1}nonEmpty(){return!0}map(r){return i.wrap(r(this.#t))}mapOr(r,s){return r(this.#t)}flatMap(r){return r(this.#t)}equals(r){return this.unwrapOrNull()===r.unwrapOrNull()}assert(r){return this}toString(){return`{Option.Some(${this.#t})}`}get[Symbol.toStringTag](){return this.toString()}}i.Some=e,i.None=new class{unwrap=t=>g(V(t)?tr(t):"unwrap failed");unwrapOrElse=t=>tr(t);unwrapOrNull=()=>null;unwrapOrUndefined=()=>{};contains=t=>!1;match=t=>t.none();ifSome=t=>{};ifAbsent=t=>t(void 0);isEmpty=()=>!0;nonEmpty=()=>!1;map=t=>i.None;mapOr=(t,r)=>tr(r);flatMap=t=>i.None;equals=t=>t.isEmpty();assert=t=>g(tr(t)??"assert failed");toString=()=>"{Option.None}";get[Symbol.toStringTag](){return this.toString()}}})(p||(p={}));var ia;(function(i){i.async=e=>e.then(t=>i.ok(t),t=>i.err(t)),i.tryGet=e=>{try{return i.ok(e())}catch(t){return i.err(t)}},i.ok=e=>new class{value;constructor(t){this.value=t}asOption=()=>p.wrap(this.value);failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>this.value;map=t=>{try{return i.ok(t(this.value))}catch(r){return i.err(r)}};flatMap=t=>t(this.value);match=t=>t.ok(this.value);toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>`{Success: ${this.value}`;get[Symbol.toStringTag](){return"Success"}}(e),i.Ok=new class{constructor(){}asOption=()=>p.None;failureReason=()=>{throw new Error("Attempt was successful.")};isFailure=()=>!1;isSuccess=()=>!0;result=()=>{};map=e=>i.ok(e());flatMap=e=>e();match=e=>e.ok();toVoid=()=>i.ok(void 0);failure=()=>{throw new Error("Attempt was successful.")};toString=()=>"{Success: Ok";get[Symbol.toStringTag](){return"Success"}},i.err=e=>new class{reason;constructor(t){this.reason=t}asOption=()=>p.None;failureReason=()=>this.reason;isFailure=()=>!0;isSuccess=()=>!1;result=()=>{throw new Error(`No result because '${this.reason}'`)};map=()=>this;flatMap=()=>this;match=t=>t.err(this.reason);toVoid=()=>i.err(this.reason);failure=()=>this;toString=()=>`{Failure: ${this.reason}`;get[Symbol.toStringTag](){return"Failure"}}(e)})(ia||(ia={}));var oe;(function(i){i.exact=(e,t,r)=>{let s=0,o=e.length-1;for(;s<=o;){let n=s+o>>>1,a=r(e[n],t);if(a===0)return n;a<0?s=n+1:o=n-1}return-1},i.exactMapped=(e,t,r,s)=>{let o=0,n=e.length-1;for(;o<=n;){let a=o+n>>>1,l=r(s(e[a]),t);if(l===0)return a;l<0?o=a+1:n=a-1}return-1},i.leftMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<0?s=n+1:o=n}return s},i.rightMost=(e,t,r)=>{let s=0,o=e.length;for(;s<o;){let n=s+o>>>1;r(e[n],t)<=0?s=n+1:o=n}return o-1},i.leftMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<0?o=a+1:n=a}return o},i.rightMostMapped=(e,t,r,s)=>{let o=0,n=e.length;for(;o<n;){let a=o+n>>>1;r(s(e[a]),t)<=0?o=a+1:n=a}return n-1},i.rangeMapped=(e,t,r,s)=>[i.leftMostMapped(e,t,r,s),i.rightMostMapped(e,t,r,s)]})(oe||(oe={}));var ye=class{static every=(e,t)=>(e&t)===t;static some=(e,t)=>(e&t)>0;#t;#e;constructor(e=32){this.#t=e,this.#e=new Int32Array((e-1>>>5)+1)}getBit(e){let t=e>>>5,r=1<<e-(t<<5);return(this.#e[t]&r)!==0}setBit(e,t){let r=e>>>5,s=1<<e-(r<<5),o=this.#e[r],n=t?o|s:o&~s;return n===o?!1:(this.#e[r]=n,!0)}isEmpty(){return this.#e.every(e=>e===0)}nonEmpty(){return this.#e.some(e=>e>0)}set buffer(e){this.#e.set(new Int32Array(e))}get buffer(){return this.#e.buffer}replace(e){let t=new Int32Array(e),r=!1;for(let s=0;s<t.length;s++)this.#e[s]!==t[s]&&(this.#e[s]=t[s],r=!0);return r}toString(){let e="";for(let t of w.iterateReverse(this.#e))e+=t.toString(2).padStart(32,"0");return e.substring(e.length-this.#t)}clear(){this.#e.fill(0)}};var $i=class{#t;#e=null;constructor(e){this.#t=e}invalidate=()=>this.#e=null;get(){return this.#e===null&&(this.#e=this.#t()),this.#e}terminate(){this.invalidate()}};var qi;(function(i){i.parseCssRgbOrRgba=e=>{let t=e.match(/\(([^)]+)\)/)?.at(1)?.split(",")?.map(Number);if(V(t)&&t.every(r=>!isNaN(r))){if(t.length===3)return[t[0]/255,t[1]/255,t[2]/255,1];if(t.length===4)return[t[0]/255,t[1]/255,t[2]/255,t[3]]}throw new Error(`${e} is not proper formatted. Example: 'rgb(255, 255, 255)' or 'rgba(255, 255, 255, 1)'`)},i.hslToHex=(e,t,r)=>{let s=l=>(l+e/30)%12,o=t*Math.min(r,1-r),n=l=>r-o*Math.max(-1,Math.min(s(l)-3,Math.min(9-s(l),1))),a=l=>Math.round(l*255).toString(16).padStart(2,"0");return`#${a(n(0))}${a(n(8))}${a(n(4))}`},i.hexToHsl=e=>{let t=e.startsWith("#")?e.slice(1):e,r=parseInt(t.slice(0,2),16)/255,s=parseInt(t.slice(2,4),16)/255,o=parseInt(t.slice(4,6),16)/255,n=Math.max(r,s,o),a=Math.min(r,s,o),l=(n+a)/2,c=0,d=0;if(n!==a){let m=n-a;switch(d=l>.5?m/(2-n-a):m/(n+a),n){case r:c=((s-o)/m+(s<o?6:0))*60;break;case s:c=((o-r)/m+2)*60;break;case o:c=((r-s)/m+4)*60;break}}return{h:c,s:d,l}},i.hslStringToHex=e=>{let[t,r,s]=e.match(/\d+(\.\d+)?/g).map(Number);return i.hslToHex(t,r/100,s/100)}})(qi||(qi={}));var At=(i,e)=>i-e,sa=(i,e)=>{let t=Math.min(i.length,e.length);for(let r=0;r<t;r++){let s=i[r]-e[r];if(s!==0)return s}return i.length-e.length};var We=Math.PI*2,zl=Math.PI/2,wn=Math.PI/4,_l=1/Math.sqrt(2),$=(i,e,t)=>Math.max(e,Math.min(i,t));var oa=(i,e)=>e+(1-2*e)*Math.max(0,Math.min(i,1)),lt=(i,e)=>Math.floor(i/e)*e;var na=(i,e,t)=>i+(e-i)*t;var xi=(i,e)=>gl(i/e)*e,gl=i=>i-Math.floor(i),ut=i=>Math.pow(2,Math.ceil(Math.log(i)/Math.log(2)));var En=(i,e)=>i*e/((2*e-1)*(i-1)+e);var Ue;(function(i){i.valueAt=({slope:s,steps:o,y0:n,y1:a},l)=>i.normalizedAt(l/o,s)*(a-n)+n,i.normalizedAt=(s,o)=>{if(o>.499999&&o<.500001)return s;{let n=$(o,1e-15,.999999999999999);return n*n/(1-n*2)*(Math.pow((1-n)/n,2*s)-1)}},i.inverseAt=(s,o)=>{let n=$(o,1e-15,.999999999999999);return Math.log(s*(1-2*n)/(n*n)+1)/(2*Math.log((1-n)/n))},i.coefficients=s=>{let o=i.valueAt(s,1),a=(i.valueAt(s,2)-o)/(o-s.y0),l=o-a*s.y0;return{m:a,q:l}};function*t(s,o,n,a){let{m:l,q:c}=i.coefficients({slope:s,steps:o,y0:n,y1:a});for(let d=0,m=n;d<o;d++)yield m=l*m+c}i.walk=t;function*r(s,o){let n=1/o,a=i.normalizedAt(n,s),c=(i.normalizedAt(2*n,s)-a)/a;for(let d=0,m=0;d<o;d++)yield m=c*m+a}i.walkNormalized=r,i.byHalf=(s,o,n,a)=>({slope:i.slopeByHalf(o,n,a),steps:s,y0:o,y1:a}),i.slopeByHalf=(s,o,n)=>Math.abs(n-s)<1e-6?.5:(o-s)/(n-s)})(Ue||(Ue={}));var Xe=new DataView(new ArrayBuffer(8)),Se;(function(i){i.MIN_VALUE=-2147483648,i.MAX_VALUE=2147483647,i.toByte=e=>(Xe.setInt8(0,e),Xe.getInt8(0)),i.toShort=e=>(Xe.setInt16(0,e),Xe.getInt16(0)),i.toInt=e=>(Xe.setInt32(0,e),Xe.getInt32(0))})(Se||(Se={}));var ct;(function(i){let r=new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT),s=new Float32Array(r),o=new Int32Array(r);i.floatToIntBits=n=>{let a=i.floatToRawIntBits(n);return(a&2139095040)===2139095040&&(a&8388607)!==0?2143289344:a},i.intBitsToFloat=n=>(o[0]=n,s[0]),i.floatToRawIntBits=n=>(s[0]=n,o[0]),i.toFloat32=n=>(Xe.setFloat32(0,n),Xe.getFloat32(0))})(ct||(ct={}));var wt;(function(i){i.floatToIntBits=e=>{let t=ct.floatToIntBits(e),r=t>>>16&32768,s=(t&2147483647)+4096;return s>=1199570944?(t&2147483647)>=1199570944?s<2139095040?r|31744:r|31744|(t&8388607)>>>13:r|31743:s>=947912704?r|s-939524096>>>13:s<855638016?r:(s=(t&2147483647)>>>23,r|(t&8388607|8388608)+(8388608>>>s-102)>>>126-s)},i.intBitsToFloat=e=>{let t=e&1023,r=e&31744;if(r===31744)r=261120;else if(r!==0){if(r+=114688,t===0&&r>115712)return ct.intBitsToFloat((e&32768)<<16|r<<13|1023)}else if(t!==0){r=115712;do t<<=1,r-=1024;while((t&1024)===0);t&=1023}return ct.intBitsToFloat((e&32768)<<16|(r|t)<<13)}})(wt||(wt={}));var zi;(function(i){let e=9218868437227405312n,t=4503599627370495n,r=new ArrayBuffer(BigInt64Array.BYTES_PER_ELEMENT),s=new Float64Array(r),o=new BigInt64Array(r);i.float64ToLongBits=n=>{let a=i.float64ToRawLongBits(n);return(a&e)===e&&(a&t)!==0n?0x7ff8000000000000n:a},i.longBitsToFloat64=n=>(o[0]=n,s[0]),i.float64ToRawLongBits=n=>(s[0]=n,o[0]),i.clamp=n=>(Xe.setFloat64(0,n),Xe.getFloat64(0))})(zi||(zi={}));var le=class{static*empty(){}static one(e){return[e]}static count(e){let t=0;for(let r of e)t++;return t}static some(e,t){for(let r of e)if(t(r))return!0;return!1}static every(e,t){for(let r of e)if(!t(r))return!1;return!0}static reduce(e,t,r){let s=r,o=0;for(let n of e)s=t(s,n,o++);return s}static includes(e,t){for(let r of e)if(r===t)return!0;return!1}static forEach(e,t){for(let r of e)t(r)}static*map(e,t){let r=0;for(let s of e)yield t(s,r++)}static*take(e,t){let r=0;for(let s of e){if(r++>=t)return;yield s}}static filter(e,t){let r=[];for(let s of e)t(s)&&r.push(s);return r}static filterMap(e,t){let r=[];for(let s of e){let o=t(s);V(o)&&r.push(o)}return r}static reverse(e){let t=[];for(let r of e)t.push(r);return t.reverse()}static*pairWise(e){let t=e[Symbol.iterator](),{done:r,value:s}=t.next(),o=s;if(r!==!0)for(;;){let{done:n,value:a}=t.next();if(n===!0){yield[o,null];return}yield[o,a],o=a}}};var pe=class i{static create(e=1024){return this.use(new ArrayBuffer(e))}static use(e,t=0){return new i(new DataView(e,t))}littleEndian=!1;#t;#e=0;constructor(e){this.#t=e}get remaining(){return this.#t.byteLength-this.#e}get position(){return this.#e}set position(e){e<0?g(`position(${e}) cannot be negative.`):e>this.#t.byteLength?g(`position(${e}) is outside range (${this.#t.byteLength}).`):this.#e=e}writeBoolean(e){this.writeByte(e?1:0)}writeByte(e){this.#r(1),this.#t.setInt8(this.#e++,e)}writeShort(e){this.#r(Int16Array.BYTES_PER_ELEMENT),this.#t.setInt16(this.#e,e,this.littleEndian),this.#e+=Int16Array.BYTES_PER_ELEMENT}writeInt(e){this.#r(Int32Array.BYTES_PER_ELEMENT),this.#t.setInt32(this.#e,e,this.littleEndian),this.#e+=Int32Array.BYTES_PER_ELEMENT}writeLong(e){this.#r(BigInt64Array.BYTES_PER_ELEMENT),this.#t.setBigInt64(this.#e,e,this.littleEndian),this.#e+=BigInt64Array.BYTES_PER_ELEMENT}writeFloat(e){this.#r(Float32Array.BYTES_PER_ELEMENT),this.#t.setFloat32(this.#e,e,this.littleEndian),this.#e+=Float32Array.BYTES_PER_ELEMENT}writeDouble(e){this.#r(Float64Array.BYTES_PER_ELEMENT),this.#t.setFloat64(this.#e,e,this.littleEndian),this.#e+=Float64Array.BYTES_PER_ELEMENT}writeBytes(e){this.#r(e.length);for(let t=0;t<e.length;++t)this.#t.setInt8(this.#e++,e[t])}writeString(e){let t=e.length;this.#r(Int32Array.BYTES_PER_ELEMENT+t*Int16Array.BYTES_PER_ELEMENT),this.writeInt(t);for(let r=0;r<t;r++)this.writeShort(e.charCodeAt(r))}toArrayBuffer(){return this.#t.buffer.slice(0,this.#e)}#r(e){let t=this.#t.byteLength;if(this.#e+e>t){let r=this.#t;this.#t=new DataView(new ArrayBuffer(ut(t+e)));for(let s=0;s<this.#e;s++)this.#t.setInt8(s,r.getInt8(s))}}},vr=class{#t=0;writeByte(e){this.#t++}writeShort(e){this.#t+=2}writeInt(e){this.#t+=4}writeLong(e){this.#t+=8}writeFloat(e){this.#t+=4}writeDouble(e){this.#t+=8}writeBoolean(e){this.#t++}writeBytes(e){this.#t+=e.length}writeString(e){this.#t+=e.length+4}get count(){return this.#t}},_i=class{#t;#e=0;constructor(e=32){this.#t=new Int8Array(e)}result(){return this.#t}equals(e){return e===this?!0:this.#t.every((t,r)=>e.#t[r]===t)}writeBoolean(e){this.writeByte(e?31:11)}writeShort(e){this.writeByte(e&255),this.writeByte(e>>>8&255)}writeByte(e){this.#e>=this.#t.length&&(this.#e=0),this.#t[this.#e++]^=e}writeInt(e){this.writeByte(e&255),this.writeByte(e>>>8&255),this.writeByte(e>>>16&255),this.writeByte(e>>>24&255)}writeBytes(e){e.forEach(t=>this.writeByte(t))}writeFloat(e){this.writeInt(ct.floatToIntBits(e))}writeDouble(e){this.writeLong(zi.float64ToLongBits(e))}writeLong(e){this.writeByte(Number(e)&255),this.writeByte(Number(e>>8n)&255),this.writeByte(Number(e>>16n)&255),this.writeByte(Number(e>>24n)&255),this.writeByte(Number(e>>32n)&255),this.writeByte(Number(e>>40n)&255),this.writeByte(Number(e>>48n)&255),this.writeByte(Number(e>>56n)&255)}writeString(e){for(let t=0;t<e.length;t++)this.writeShort(e.charCodeAt(t))}toHexString(){return Array.from(le.map(this.#t.values(),e=>(e&255).toString(16).padStart(2,"0"))).join("")}},ge=class{littleEndian=!1;#t;#e=0;constructor(e,t=0){this.#t=new DataView(e,t)}get position(){return this.#e}set position(e){e<0?g(`position(${e}) cannot be negative.`):e>this.#t.byteLength?g(`position(${e}) is outside range (${this.#t.byteLength}).`):this.#e=e}readByte(){return this.#t.getInt8(this.#e++)}readShort(){let e=this.#t.getInt16(this.#e,this.littleEndian);return this.#e+=Int16Array.BYTES_PER_ELEMENT,e}readInt(){let e=this.#t.getInt32(this.#e,this.littleEndian);return this.#e+=Int32Array.BYTES_PER_ELEMENT,e}readLong(){let e=this.#t.getBigInt64(this.#e,this.littleEndian);return this.#e+=BigInt64Array.BYTES_PER_ELEMENT,e}readFloat(){let e=this.#t.getFloat32(this.#e,this.littleEndian);return this.#e+=Float32Array.BYTES_PER_ELEMENT,e}readDouble(){let e=this.#t.getFloat64(this.#e,this.littleEndian);return this.#e+=Float64Array.BYTES_PER_ELEMENT,e}readBoolean(){return this.readByte()===1}readBytes(e){for(let t=0;t<e.length;t++)e[t]=this.readByte()}readString(){let e=this.readInt(),t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.readShort());return t}available(e){return this.#e+e<=this.#t.byteLength}remaining(){return this.#t.byteLength-this.#e}skip(e){this.position+=e}};var xl=i=>V(i)?i.value!==void 0?"value":i.get!==void 0?"get":g(`Cannot resolve method key of ${i}`):g("Cannot resolve method key of undefined descriptor"),br=(i,e,t)=>{if(!V(t))return function(o,n){if(n&&n.kind==="getter")return function(){let a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this),e);if(!V(a?.get))return g(`Cannot find getter for property '${e}'`);let l=a.get.apply(this);return Object.defineProperty(this,e,{value:l,configurable:!1,writable:!1,enumerable:!1}),l}};let r=xl(t),s=K(t[r]);return{[r]:function(...o){if(o.length>0)return g("lazy accessory must not have any construction parameters");let n=s.apply(this);return Object.defineProperty(this,e,{value:r==="get"?n:()=>n,configurable:!1,writable:!1,enumerable:!1}),n}}};var ht;(function(i){function*e(){}i.empty=e,i.next=r=>{let{value:s,done:o}=r.next();return o?null:s};function*t(...r){for(let s of r)for(let o of s)yield o}i.flatten=t})(ht||(ht={}));var Ar;(function(i){i[i.T=0]="T",i[i.R=1]="R",i[i.B=2]="B",i[i.L=3]="L"})(Ar||(Ar={}));var wr;(function(i){i[i.TL=0]="TL",i[i.TR=1]="TR",i[i.BR=2]="BR",i[i.BL=3]="BL"})(wr||(wr={}));var aa;(function(i){i.outerTangentPoints=(e,t)=>{let r=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,r)+Math.acos((e.r-t.r)/Math.sqrt(r*r+s*s)),n=Math.cos(o),a=Math.sin(o);return[{x:e.x+e.r*n,y:e.y+e.r*a},{x:t.x+t.r*n,y:t.y+t.r*a}]}})(aa||(aa={}));var la;(function(i){i.zero=()=>({x:0,y:0}),i.create=(e,t)=>({x:e,y:t}),i.clone=e=>({...e}),i.floor=e=>({x:Math.floor(e.x),y:Math.floor(e.y)}),i.length=e=>Math.sqrt(e.x*e.x+e.y*e.y),i.distance=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),i.add=(e,t)=>({x:e.x+t.x,y:e.y+t.y}),i.subtract=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),i.scaleBy=(e,t)=>({x:e.x*t,y:e.y*t}),i.scaleTo=(e,t)=>{let r=t/i.length(e);return{x:e.x*r,y:e.y*r}},i.fromClient=e=>({x:e.clientX,y:e.clientY})})(la||(la={}));var yi;(function(i){i.Empty=Object.freeze({x:0,y:0,width:0,height:0}),i.corners=e=>{let t=e.x,r=e.y,s=t+e.width,o=r+e.height;return[{x:t,y:r},{x:s,y:r},{x:s,y:o},{x:t,y:o}]},i.inflate=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}),i.contains=(e,t)=>{let r=t.x>=e.x&&t.y>=e.y,s=t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height;return r&&s},i.isPointInside=(e,t)=>e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height,i.intersect=(e,t)=>{let r=Math.max(e.x,t.x),s=Math.min(e.x+e.width,t.x+t.width),o=Math.min(e.y+e.height,t.y+t.height),n=Math.max(e.y,t.y);return s>r&&o>n},i.axis=(e,t)=>{switch(t){case Ar.T:return e.y;case Ar.R:return e.x+e.width;case Ar.B:return e.y+e.height;case Ar.L:return e.x;default:return Ge(t)}},i.corner=(e,t)=>{switch(t){case wr.TL:return{x:e.x,y:e.y};case wr.TR:return{x:e.x+e.width,y:e.y};case wr.BR:return{x:e.x+e.width,y:e.y+e.height};case wr.BL:return{x:e.x,y:e.y+e.height};default:return Ge(t)}},i.center=e=>({x:e.x+e.width*.5,y:e.y+e.height*.5}),i.isEmpty=e=>e.width===0||e.height===0,i.union=(e,t)=>{if(i.isEmpty(e))i.isEmpty(t)||(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height);else if(!i.isEmpty(t)){let r=t.x,s=t.y,o=Math.min(e.x,r),n=Math.min(e.y,s);e.width=Math.max(e.x+e.width,r+t.width)-o,e.height=Math.max(e.y+e.height,s+t.height)-n,e.x=o,e.y=n}}})(yi||(yi={}));var ua;(function(i){i.width=e=>e.xMax-e.xMin,i.height=e=>e.yMax-e.yMin,i.from=(e,t)=>{e.xMin=t.xMin,e.xMax=t.xMax,e.yMin=t.yMin,e.yMax=t.yMax},i.extend=(e,t)=>{e.xMin-=t,e.yMin-=t,e.xMax+=t,e.yMax+=t},i.padding=(e,[t,r,s,o])=>(e.xMin+=o,e.yMin+=t,e.xMax-=r,e.yMax-=s,e),i.intersectPoint=(e,t)=>e.xMin<=t.x&&t.x<e.xMax&&e.yMin<=t.y&&t.y<e.yMax,i.intersectThat=(e,t)=>t.xMin<e.xMax&&t.xMax>e.xMin&&t.yMin<e.yMax&&t.yMax>e.yMin,i.center=e=>({x:(e.xMin+e.xMax)*.5,y:(e.yMin+e.yMax)*.5})})(ua||(ua={}));var ca;(function(i){i.Identity=Object.freeze([0,0,0,0])})(ca||(ca={}));var ha;(function(i){i.intersects=(r,s,o,n,a,l,c,d)=>{let m=e(r,s,o,n,a,l),f=e(r,s,o,n,c,d);if((m|f)===0||(m&f)!==0)return!1;let y=t(a,l,c,d,r,o);return y!==t(a,l,c,d,s,o)||y!==t(a,l,c,d,s,n)||y!==t(a,l,c,d,r,n)};let e=(r,s,o,n,a,l)=>{let c=0;return a<=r?c|=1:a>=s&&(c|=2),l<=o?c|=8:l>=n&&(c|=4),c},t=(r,s,o,n,a,l)=>(o-r)*(l-s)-(a-r)*(n-s)>=0})(ha||(ha={}));var da;(function(i){i.Identity={valueToAxis:e=>e,axisToValue:e=>e},i.toClamped=(e,t,r)=>({valueToAxis:s=>e.valueToAxis($(s,t,r)),axisToValue:s=>$(e.axisToValue(s),t,r)}),i.createClamped=(e,t)=>({valueToAxis:r=>$(r,e,t),axisToValue:r=>$(r,e,t)})})(da||(da={}));var pa;(function(i){i.fromBuffers=async(...e)=>{let t=e.reduce((o,n)=>o+n.byteLength,0),r=new Uint8Array(t),s=0;for(let o of e)r.set(new Uint8Array(o),s),s+=o.byteLength;return await crypto.subtle.digest("SHA-256",r)},i.equals=(e,t)=>{b(e.byteLength===32,"First hash has invalid length"),b(t.byteLength===32,"Second hash has invalid length");let r=new Uint8Array(e),s=new Uint8Array(t);for(let o=0;o<32;o++)if(r[o]!==s[o])return!1;return!0},i.toString=e=>Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")})(pa||(pa={}));var vi;(function(i){i.intersect1D=(e,t,r,s)=>Math.max(e,r)<=Math.min(t,s)})(vi||(vi={}));var ve=class{#t=new Set;#e;constructor(){this.#e=new Proxy({},{get:(e,t)=>(...r)=>this.#t.forEach(s=>Object.getPrototypeOf(s)===Object.getPrototypeOf({})?x(s[t],...r):s[t]?.apply(s,r))})}get proxy(){return this.#e}get size(){return this.#t.size}subscribe(e){return this.#t.add(e),{terminate:()=>this.#t.delete(e)}}forEach(e){this.#t.forEach(e)}terminate(){this.#t.clear()}};var ir=class{static createIfAbsent(e,t,r){let s=e.get(t);return s===void 0&&(s=r(t),e.set(t,s)),s}};var bi=class i{static#t=Object.freeze(new Set);static empty=()=>i.#t};var sr=class i{#t;#e;constructor(e,t){this.#t=new Map(e),this.#e=p.wrap(t),this.#e.ifSome(r=>Array.from(this.#t.values()).forEach(s=>s.sort(r)))}[Symbol.iterator](){return this.#t.entries()}clear(){this.#t.clear()}containsEntry(e,t){return le.some(this.#t.entries(),r=>e===r[0]&&r[1].includes(t))}containsKey(e){return le.includes(this.#t.keys(),e)}containsValue(e){return le.some(this.#t.values(),t=>t.includes(e))}get(e){return this.#t.get(e)??w.empty()}isEmpty(){return this.keyCount()===0}add(e,t){let r=ir.createIfAbsent(this.#t,e,()=>[]);if(this.#e.isEmpty())r.push(t);else{let s=oe.leftMost(r,t,this.#e.unwrap());r.splice(s,0,t)}}addAll(e,t){let r=ir.createIfAbsent(this.#t,e,()=>[]);r.push(...t),this.#e.nonEmpty()&&r.sort(this.#e.unwrap())}remove(e,t){let r=this.#t.get(e);if(r===void 0)return!1;{let s=r.indexOf(t);return s===-1?!1:(r.splice(s,1),r.length===0&&this.#t.delete(e),!0)}}removeFromKeyIf(e,t){let r=this.#t.get(e);if(r===void 0)return null;{let s=r.findIndex(t);if(s===-1)return null;{let o=r.splice(s,1)[0];return r.length===0&&this.#t.delete(e),o}}}removeValueIf(e){let t=[];for(let[r,s]of this.#t.entries())for(let o of s.filter(n=>e(n)))t.push([r,o]);for(let[r,s]of t)this.remove(r,s);return new Set(t.map(([,r])=>r))}removeKey(e){let t=this.#t.get(e);return this.#t.delete(e),t??w.empty()}forEach(e){le.forEach(this.#t.entries(),t=>e(t[0],t[1]))}keyCount(){return this.#t.size}keys(){return this.#t.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.#t.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.#t.forEach((t,r)=>{e.#t.set(r,t.map(s=>s))}),e}},Hi=class i{map;constructor(e){this.map=new Map(e?.map(t=>{let r=t[0],s=t[1];return[r,new Set(s)]}))}clear(){this.map.clear()}containsEntry(e,t){return le.some(this.map.entries(),r=>e===r[0]&&r[1].has(t))}containsKey(e){return le.includes(this.map.keys(),e)}containsValue(e){return le.some(this.map.values(),t=>t.has(e))}get(e){return this.map.get(e)??bi.empty()}isEmpty(){return this.keyCount()===0}add(e,t){ir.createIfAbsent(this.map,e,()=>new Set).add(t)}addAll(e,t){let r=ir.createIfAbsent(this.map,e,()=>new Set);for(let s of t)r.add(s)}remove(e,t){let r=this.map.get(e);return r===void 0?!1:r.delete(t)?(r.size===0&&this.map.delete(e),!0):!1}removeValueIf(e){let t=new Set;for(let[r,s]of this.map.entries()){for(let o of s)e(o)&&(s.delete(o),t.add(o));s.size===0&&this.map.delete(r)}return t}removeFromKeyIf(e,t){let r=this.map.get(e);if(r===void 0)return null;for(let s of r)if(t(s))return r.delete(s),r.size===0&&this.map.delete(e),s;return null}removeKey(e){let t=this.map.get(e);return this.map.delete(e),t??bi.empty()}forEach(e){le.forEach(this.map.entries(),t=>e(t[0],t[1]))}keyCount(){return this.map.size}keys(){return this.map.keys()}sortKeys(e){let t=this.clone(),r=Array.from(this.keys()).sort(e);this.map.clear();for(let s of r)this.addAll(s,t.get(s));return this}clone(){let e=new i;return this.map.forEach((t,r)=>{e.map.set(r,new Set(Array.from(t)))}),e}};var O=Object.freeze({Empty:{terminate:at},create:i=>({terminate:i}),many:(...i)=>({terminate:()=>{for(;i.length>0;)i.pop().terminate()}})}),I=class i{#t=[];isEmpty(){return this.#t.length===0}nonEmpty(){return this.#t.length>0}own(e){return this.#t.push(e),e}ownAll(...e){for(let t of e)this.#t.push(t)}spawn(){let e=new i;return e.own({terminate:()=>w.removeOpt(this.#t,e)}),this.own(e)}terminate(){for(;this.#t.length>0;)this.#t.pop().terminate()}};var q=class{static subscribeMany(e,...t){return O.many(...t.map(r=>r.subscribe(()=>e(r))))}#t=new Set;subscribe(e){return this.#t.add(e),{terminate:()=>this.#t.delete(e)}}isEmpty(){return this.#t.size===0}notify(e){this.#t.forEach(t=>t(e))}observers(){return this.#t}terminate(){this.#t.clear()}};var Ze;(function(i){let e=Object.freeze({});i.empty=()=>e,i.mergeNoOverlap=(t,r)=>{let s=new Set(Object.keys(t));for(let o of Object.keys(r))if(s.has(o))return g(`'${o}' is an overlapping key`);return{...t,...r}},i.include=(t,...r)=>{let s={};for(let o of r)s[o]=t[o];return s},i.exclude=(t,...r)=>{let s=new Set(r);return Object.entries(t).reduce((o,[n,a])=>(s.has(n)||(o[n]=a),o),{})},i.overwrite=(t,r)=>Object.assign(t,r)})(Ze||(Ze={}));var ma;(function(i){i.make=e=>new class{getValue(){return e}subscribe(t){return O.Empty}catchupAndSubscribe(t){return t(this),O.Empty}}})(ma||(ma={}));var fa;(function(i){i.False=new class{getValue(){return!1}setValue(e){}subscribe(e){return O.Empty}catchupAndSubscribe(e){return e(this),O.Empty}},i.inverseBoolean=e=>new class{getValue(){return!e.getValue()}setValue(t){e.setValue(!t)}subscribe(t){return e.subscribe(t)}catchupAndSubscribe(t){return t(this),this.subscribe(t)}}})(fa||(fa={}));var Er=class{#t;#e=p.None;constructor(e){this.#t=new q,this.wrap(e)}wrap(e){this.wrapOption(p.wrap(e))}wrapOption(e){this.#e.equals(e)||(this.#e=e,this.#t.notify(this))}clear(e){this.#e.isEmpty()||(V(e)&&e(this.#e.unwrap()),this.#e=p.None,this.#t.notify(this))}assert(e){return this.#e.assert(e),this}contains(e){return this.#e.contains(e)}equals(e){return this.#e.equals(e)}flatMap(e){return this.#e.flatMap(e)}ifSome(e){return this.#e.ifSome(e)}ifAbsent(e){return this.#e.ifAbsent(e)}isEmpty(){return this.#e.isEmpty()}map(e){return this.#e.map(e)}mapOr(e,t){return this.#e.mapOr(e,t)}match(e){return this.#e.match(e)}nonEmpty(){return this.#e.nonEmpty()}unwrap(e){return this.#e.unwrap(e)}unwrapOrElse(e){return this.#e.unwrapOrElse(e)}unwrapOrNull(){return this.#e.unwrapOrNull()}unwrapOrUndefined(){return this.#e.unwrapOrUndefined()}subscribe(e){return this.#t.subscribe(()=>e(this))}catchupAndSubscribe(e){return e(this),this.#t.subscribe(()=>e(this))}terminate(){this.#t.terminate()}};var Ce=class{#t;#e=p.None;#r;constructor(e,t){this.#t=new q,this.#r=t?.guard(e)??e,this.#e=p.wrap(t)}setValue(e){this.#e.nonEmpty()&&(e=this.#e.unwrap().guard(e)),this.#r!==e&&(this.#r=e,this.#t.notify(this))}getValue(){return this.#r}subscribe(e){return this.#t.subscribe(e)}catchupAndSubscribe(e){return e(this),this.#t.subscribe(e)}terminate(){this.#t.terminate()}toString(){return`{DefaultObservableValue value: ${this.#r}`}};var Bn=class{#t;#e;#r;constructor(e,t){this.#t=e,this.#e=t,this.#r=t-e}x(e){return(this.clamp(e)-this.#t)/this.#r}y(e){return this.#t+$(e,0,1)*this.#r}clamp(e){return $(e,this.#t,this.#e)}floating(){return!0}},Fn=class{#t;#e;#r;constructor(e,t){this.#t=$(Math.round(e),Se.MIN_VALUE,Se.MAX_VALUE),this.#e=$(Math.round(t),Se.MIN_VALUE,Se.MAX_VALUE),this.#r=this.#e-this.#t}x(e){return(this.clamp(e)-this.#t)/this.#r}y(e){return this.#t+Math.round($(e,0,1)*this.#r)}clamp(e){return $(Math.round(e),this.#t,this.#e)}floating(){return!1}},Nn=class{#t;#e;#r;constructor(e,t){this.#t=e,this.#e=t,this.#r=Math.log(t/e)}x(e){return Math.log($(e,this.#t,this.#e)/this.#t)/this.#r}y(e){return this.#t*Math.exp($(e,0,1)*this.#r)}clamp(e){return Math.min(this.#e,Math.max(this.#t,e))}floating(){return!0}},Pn=class{#t;constructor(e){this.#t=e}x(e){let t=this.#t.findIndex(r=>r===e);return t===-1?g(`Could not find index for ${e}`):t/(this.#t.length-1)}y(e){let t=Math.round($(e,0,1)*(this.#t.length-1));return t>-1?K(this.#t.at(t),`Could not find value for ${e}`):g(`Index ${t} is out of box.`)}clamp(e){return e}floating(){return!1}},Sn=class{#t;#e;#r;#i;#s;constructor(e,t,r){this.#t=e,this.#e=r;let s=e*e,o=r*r,n=t*t,a=e+r-2*t,l=r-t;this.#r=((2*r-t)*e-t*r)/a,this.#i=(l*s+(n-o)*e+t*o-n*r)/(s+(2*r-4*t)*e+o-4*t*r+4*n),this.#s=-l/a}y(e){return e<=0?Number.NEGATIVE_INFINITY:e>=1?this.#e:this.#r-this.#i/(e+this.#s)}x(e){return this.#t>=e?0:this.#e<=e?1:-this.#i/(e-this.#r)-this.#s}clamp(e){return Math.min(this.#e,e)}floating(){return!0}},M;(function(i){i.linear=(o,n)=>new Bn(o,n),i.linearInteger=(o,n)=>new Fn(o,n),i.exponential=(o,n)=>new Nn(o,n),i.values=o=>new Pn(o),i.decibel=(o,n,a)=>new Sn(o,n,a);let e=new class{x(o){return o?1:0}y(o){return o>=.5}clamp(o){return o}floating(){return!1}},t=i.linear(0,1),r=i.linear(-1,1);i.bool=e;let s=i.decibel(-72,-12,0);i.unipolar=()=>t,i.bipolar=()=>r,i.DefaultDecibel=s})(M||(M={}));var C;(function(i){i.percent=({bipolar:o,fractionDigits:n}={})=>new e("%",n,!1,o),i.numeric=({unit:o,fractionDigits:n,unitPrefix:a,bipolar:l}={})=>new e(o,n,a,l),i.indices=(o,n)=>new class{x(a){return{unit:o,value:n[a]}}y(a){let l=n.indexOf(a);return l===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:l}}},i.values=(o,n,a)=>new class{x(l){return{unit:o,value:a.at(n.indexOf(l))??"N/A"}}y(l){let c=a.indexOf(l);return c===-1?{type:"unknown",value:"\u{1F4A3}"}:{type:"explicit",value:n[c]}}},i.bool=new class{y(o){switch(o.trim()){case"on":case"yes":case"true":return{type:"explicit",value:!0};default:return{type:"explicit",value:!1}}}x(o){return{value:String(o),unit:""}}};class e{#t;#e;#r;#i;constructor(n,a,l,c){this.#t=n??"",this.#e=a??0,this.#r=l??!1,this.#i=c??!1}y(n){let a=n.trim(),l=parseFloat(a);if(isNaN(l))return{type:"unknown",value:a};if(this.#t==="%")return{type:"explicit",value:l/100};if(a.endsWith("%"))return{type:"unitValue",value:this.#i?$(l/200+.5,0,1):$(l/100,0,1)};{a.endsWith(this.#t)&&this.#t.length>0&&(a=a.slice(0,-this.#t.length));let m=/(\d+)(\D+)/.exec(a)?.at(2)?.at(0);if(V(m)){let f=t.indexOf(m);if(f>-1)return{type:"explicit",value:l*Math.pow(10,(f-4)*3)}}return{type:"explicit",value:l}}}x(n){if(Number.isNaN(n))return{value:"\u{1F4A3}",unit:this.#t};if(Number.isFinite(n)){if(this.#t==="%")return this.#i?{value:(n*200-100).toFixed(this.#e),unit:this.#t}:{value:(n*100).toFixed(this.#e),unit:this.#t};if(this.#r){let{value:a,prefix:l}=s(n);return{value:a.toFixed(this.#e),unit:`${l}${this.#t}`}}else return{value:n.toFixed(this.#e),unit:this.#t}}else return{value:n===Number.POSITIVE_INFINITY?"\u221E":"-\u221E",unit:this.#t}}}let t=Object.freeze(["p","n","\u03BC","m","","k","M","G","T"]),r=o=>Math.log(o)/Math.log(9.999999999999998),s=o=>{let n=Math.floor(r(o)/3),a=t[n+4];return V(a)?{value:o*Math.pow(10,n*-3),prefix:a}:{value:o,prefix:""}};i.decible=i.numeric({unit:"db",fractionDigits:1}),i.panning=i.percent({unit:"%",fractionDigits:0})})(C||(C={}));var Gi;(function(i){i.alwaysTrue=()=>!0,i.alwaysFalse=()=>!1,i.definedPredicate=e=>e!=null})(Gi||(Gi={}));var ga;(function(i){i.Empty=Object.freeze(e=>{}),i.split=(e,t)=>{let r=new Float32Array(t);return w.create(s=>o=>{r[s]=o,e(r.reduce((n,a)=>n+a,0)/t)},t)},i.splitWithWeights=(e,t)=>{let r=t.length,s=new Float32Array(r);if(t.length===0)return g("Weights must not be empty");if(t.some(a=>a<=0))return g("Weights must be greater than zero");let o=t.reduce((a,l)=>a+l,0),n=o>0?t.map(a=>a/o):w.create(()=>1/r,r);return w.create(a=>l=>{s[a]=l,e(s.reduce((c,d,m)=>c+d*n[m],0))},r)}})(ga||(ga={}));var Wi;(function(i){i.create=(e=252854082)=>new Cn(e),i.monotoneAscending=(e,t=128,r=i.create())=>{let s=e.length;if(s<2)return g("Array must have at least 2 elements");let o=0;for(let a=1;a<s;a++){let l=Math.floor(r.uniform()*(1+t))+1;e[a]=l,o+=l}let n=0;e[0]=0;for(let a=1;a<s;a++)n+=e[a],e[a]=n/o;return e}})(Wi||(Wi={}));var Cn=class{#t=0;constructor(e){this.setSeed(e)}setSeed(e){this.#t=e&4294967295}nextDouble(e,t){return e+this.uniform()*(t-e)}nextInt(e,t){return e+Math.floor(this.uniform()*(t-e))}nextElement(e){return e[Math.floor(this.uniform()*e.length)]}nextBoolean(){return this.uniform()<.5}uniform(){let e=this.#t+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}};var Re;(function(i){class e{}i.createBuilder=r=>{let s=o=>{let n=o instanceof Array?[]:{};return Object.entries(o).forEach(([a,l])=>{l instanceof e?n[a]=l.initialValue():typeof l=="object"&&(n[a]=s(l))}),n};return()=>new t(r,Object.seal(s(r)))},i.bool=new class extends e{read(r){return r.readByte()===1}write(r,s){r.writeByte(s?1:0)}initialValue(){return!1}},i.int8=new class extends e{read(r){return r.readByte()}write(r,s){r.writeByte(s)}initialValue(){return 0}},i.int16=new class extends e{read(r){return r.readShort()}write(r,s){r.writeShort(s)}initialValue(){return 0}},i.int32=new class extends e{read(r){return r.readInt()}write(r,s){r.writeInt(s)}initialValue(){return 0}},i.float=new class extends e{read(r){return r.readFloat()}write(r,s){r.writeFloat(s)}initialValue(){return 0}},i.double=new class extends e{read(r){return r.readDouble()}write(r,s){r.writeDouble(s)}initialValue(){return 0}},i.int64=new class extends e{read(r){return r.readLong()}write(r,s){r.writeLong(s)}initialValue(){return 0n}},i.floats=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readFloat();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeFloat(o[n])}initialValue(){return new Float32Array(r)}},i.doubles=r=>new class extends e{read(s,o){for(let n=0;n<o.length;n++)o[n]=s.readDouble();return o}write(s,o){for(let n=0;n<o.length;n++)s.writeDouble(o[n])}initialValue(){return new Float64Array(r)}};class t{#t;#e;#r;constructor(s,o){this.#t=s,this.#e=o,this.#r=this.#i()}get object(){return this.#e}get bytesTotal(){return this.#r}read(s){let o=(n,a)=>{Object.entries(n).forEach(([l,c])=>{let d=a;c instanceof e?d[l]=c.read(s,d[l]):typeof c=="object"&&o(c,d[l])})};o(this.#t,this.#e)}write(s){let o=(n,a)=>{Object.entries(n).forEach(([l,c])=>{let d=a;c instanceof e?c.write(s,d[l]):typeof c=="object"&&o(c,d[l])})};o(this.#t,this.#e)}#i(){let s=new vr;return this.write(s),s.count}}})(Re||(Re={}));var Et=class{#t;#e;#r;constructor(e,t){this.#t=e,this.#e=t,this.#r=[]}add(e,t=!1){let r=this.#t(e),s=oe.leftMostMapped(this.#r,r,this.#e,this.#t),o=this.#r[s];return V(o)&&this.#e(this.#t(o),r)===0?t?(this.#r.splice(s,1,e),!0):!1:(this.#r.splice(s,0,e),!0)}getOrCreate(e,t){let r=oe.leftMostMapped(this.#r,e,this.#e,this.#t),s=this.#r[r];if(V(s)&&this.#e(this.#t(s),e)===0)return s;let o=t(e);return this.#r.splice(r,0,o),o}addMany(e){for(let t of e)this.#r.push(t);try{return this.#r.sort((t,r)=>{let s=this.#e(this.#t(t),this.#t(r));if(s===0)throw"cancel";return s}),!0}catch(t){if(t==="cancel"){let r=new Map(this.entries());return this.#r.splice(0,this.#r.length,...r.values()),this.#r.sort((s,o)=>this.#e(this.#t(s),this.#t(o))),!1}return g(t)}}removeByValue(e){return this.removeByKey(this.#t(e))}removeByKey(e){let t=oe.leftMostMapped(this.#r,e,this.#e,this.#t),r=this.#r[t];return V(r)&&this.#e(this.#t(r),e)===0?(this.#r.splice(t,1),r):g(`Could not remove ${e}`)}removeByKeyIfExist(e){let t=oe.leftMostMapped(this.#r,e,this.#e,this.#t),r=this.#r[t];return V(r)&&this.#e(this.#t(r),e)===0?(this.#r.splice(t,1),r):null}removeRange(e,t){this.#r.splice(e,(t??this.#r.length)-e)}removeByPredicate(e){let t=0,r=this.#r.length;for(;--r>=0;)e(this.#r[r])&&(this.#r.splice(r,1),t++);return t}get(e){return K(this.#i(e),`Unknown key: ${e}`)}getOrThrow(e,t){let r=this.#i(e);if(V(r))return r;throw t()}opt(e){return p.wrap(this.#i(e))}getOrNull(e){return this.#i(e)??null}getByIndex(e){return this.#r[e]}hasKey(e){return V(this.#i(e))}hasValue(e){return V(this.#i(this.#t(e)))}size(){return this.#r.length}isEmpty(){return this.#r.length===0}forEach(e){this.values().forEach(e)}values(){return this.#r}entries(){return this.#r.map(e=>[this.#t(e),e])}clear(){w.clear(this.#r)}[Symbol.iterator](){return this.#r.values()}#i(e){let t=oe.leftMostMapped(this.#r,e,this.#e,this.#t),r=this.#r[t];return V(r)&&this.#e(this.#t(r),e)===0?r:void 0}};var xa;(function(i){i.hyphenToCamelCase=e=>e.replace(/-([a-z])/g,t=>t[1].toUpperCase()),i.fallback=(e,t)=>V(e)&&e.length>0?e:t,i.endsWithDigit=e=>/\d$/.test(e),i.nonEmpty=(e,t)=>V(e)&&e.trim().length>0?e:t,i.toArrayBuffer=e=>{let t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return t},i.getUniqueName=(e,t)=>{let r=new Set(e),s=t,o=1;if(r.has(t)||r.has(`${t} 1`))o=2;else return t;for(;r.has(s=`${t} ${o++}`););return s}})(xa||(xa={}));var ya=(()=>{let i=p.None;return{info:e=>i.match({none:()=>Promise.resolve(),some:t=>t.info(e)}),approve:e=>i.match({none:()=>Promise.resolve(!0),some:t=>t.approve(e)}),progress:e=>i.match({none:()=>({message:"",terminate:at}),some:t=>t.progress(e)}),install:e=>{b(i.isEmpty(),"RuntimeNotification already installed"),i=p.wrap(e)}}})();var va;(function(i){let e=new q;i.subscribe=t=>e.subscribe(t),i.dispatch=t=>e.notify(t)})(va||(va={}));var Bt=class i{static POSITIVE_INFINITY=new i(Number.POSITIVE_INFINITY);static millis=e=>new i(e);static seconds=e=>new i(e*i.#t);static minutes=e=>new i(e*i.#e);static hours=e=>new i(e*i.#r);static days=e=>new i(e*i.#i);static#t=1e3;static#e=6e4;static#r=36e5;static#i=864e5;#s;constructor(e){this.#s=e}millis(){return this.#s}absSeconds(){return Math.abs(this.#s)/i.#t}absMinutes(){return Math.abs(this.#s)/i.#e}absHours(){return Math.abs(this.#s)/i.#r}absDays(){return Math.abs(this.#s)/i.#i}split(){return{d:Math.floor(this.absDays()),h:Math.floor(this.absHours())%24,m:Math.floor(this.absMinutes())%60,s:Math.floor(this.absSeconds())%60}}isNow(){return this.#s===0}isPast(){return this.#s<0}isFuture(){return this.#s>0}toUnitString(){let e,t,r=Math.floor(Math.abs(this.#s)/1e3),s=Math.floor(r/60),o=Math.floor(s/60),n=Math.floor(o/24);return r<60?(e=r,t="second"):s<60?(e=s,t="minute"):o<24?(e=o,t="hour"):(e=n,t="day"),new Intl.RelativeTimeFormat("en",{numeric:"auto",style:"long"}).format(e*Math.sign(this.#s),t)}toString(){if(isNaN(this.#s))return"NaN";if(!isFinite(this.#s))return"\u221E";let{d:e,h:t,m:r,s}=this.split();return e>0?[i.#o("d",e),i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):t>0?[i.#o("h",t),i.#o("m",r),i.#o("s",s)].join(", "):r>0?[i.#o("m",r),i.#o("s",s)].join(", "):s>0?i.#o("s",s):"now"}static#o=(e,t)=>{switch(e){case"d":return`${t} ${t<2?"day":"days"}`;case"h":return`${t} ${t<2?"hour":"hours"}`;case"m":return`${t} ${t<2?"minute":"minutes"}`;case"s":return`${t} ${t<2?"second":"seconds"}`;default:return Ge(e)}}};var Br;(function(i){let e;(function(t){t[t.READING=0]="READING",t[t.READ=1]="READ",t[t.WRITING=2]="WRITING",t[t.WRITTEN=3]="WRITTEN"})(e||(e={})),i.writer=(t,r,s)=>{if(t.bytesTotal+1>r.byteLength)return g("Insufficient memory allocated.");let o=new Uint8Array(r),n=pe.use(r,1);return Atomics.store(o,0,e.READ),{tryWrite:()=>Atomics.compareExchange(o,0,e.READ,e.WRITING)===e.WRITING?(s(t.object),n.position=0,t.write(n),Atomics.store(o,0,e.WRITTEN),!0):!1}},i.reader=(t,r)=>{let s=new SharedArrayBuffer(t.bytesTotal+1),o=new Uint8Array(s),n=new ge(s,1);return{buffer:s,tryRead:()=>Atomics.compareExchange(o,0,e.WRITTEN,e.READING)===e.READING?(n.position=0,t.read(n),r(t.object),Atomics.store(o,0,e.READ),!0):!1}}})(Br||(Br={}));var A;(function(i){i.length=16,i.generate=()=>e(crypto.getRandomValues(new Uint8Array(i.length))),i.sha256=async t=>{let r=typeof process<"u"&&process.env?.VITEST==="true";return crypto.subtle.digest("SHA-256",r?new Uint8Array(t.slice(0)):t).then(s=>e(new Uint8Array(s.slice(0,i.length))))},i.validateBytes=t=>i.parse(i.toString(t)),i.validateString=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),i.asString=t=>i.validateString(t)?t:g(`Invalid UUID format: ${t}`),i.fromDataInput=t=>{let r=new Uint8Array(i.length);return t.readBytes(new Int8Array(r.buffer)),r},i.toDataOutput=(t,r)=>t.writeBytes(new Int8Array(r.buffer)),i.toString=t=>{let r=w.create(s=>(s+256).toString(16).substring(1),256);return r[t[0]]+r[t[1]]+r[t[2]]+r[t[3]]+"-"+r[t[4]]+r[t[5]]+"-"+r[t[6]]+r[t[7]]+"-"+r[t[8]]+r[t[9]]+"-"+r[t[10]]+r[t[11]]+r[t[12]]+r[t[13]]+r[t[14]]+r[t[15]]},i.parse=t=>{let r=t.replace(/-/g,"").toLowerCase();if(r.length!==32)return g("Invalid UUID format");let s=new Uint8Array(i.length);for(let o=0,n=0;o<32;o+=2,n++)s[n]=parseInt(r.slice(o,o+2),16);return s},i.Comparator=(t,r)=>{if(t.length!==i.length||r.length!==i.length)return g("Unexpected array length for uuid(v4)");for(let s=0;s<i.length;s++){let o=t[s]-r[s];if(o!==0)return o}return 0},i.equals=(t,r)=>i.Comparator(t,r)===0,i.newSet=t=>new Et(t,i.Comparator),i.Lowest=i.parse("00000000-0000-4000-8000-000000000000"),i.Highest=i.parse("FFFFFFFF-FFFF-4FFF-BFFF-FFFFFFFFFFFF"),i.fromInt=t=>{let r=new Uint8Array(i.Lowest),s=new Uint8Array(new Uint32Array([t]).buffer);for(let o=0;o<4;o++)r[o]=s[o];return r};let e=t=>(b(t.length===i.length,"UUID must be 16 bytes long"),t[6]=t[6]&15|64,t[8]=t[8]&63|128,t)})(A||(A={}));var ba;(function(i){i.create=o=>V(o)?V(o?.snap)?i.snap(o?.trackLength,o?.snap?.snapLength,Array.isArray(o?.snap?.threshold)?o?.snap.threshold:[o?.snap?.threshold]):i.identity(o?.trackLength):i.identity(),i.snap=(o=e,n=t,a)=>new s(o,n/o,a),i.identity=(o=e)=>new r(o);let e=128,t=24;class r{length;#t=NaN;#e=NaN;#r=1;constructor(n){this.length=n}begin(n){this.#e=this.#t=n}moveBy(n){b(!isNaN(this.#e),()=>"value has never been set"),this.#t+=n/this.length*this.#r,this.#e=$(this.#t,0,1)}ratio(n){this.#r=n}value(){return b(!isNaN(this.#e),()=>"value has never been set"),this.#e}disable(){}enable(){}}class s{#t;#e;#r;#i;#s=NaN;#o=NaN;#n=1;#a=!0;constructor(n,a,l){b(a>0,()=>`margin(${a}) must be greater then 0`),b(w.isSorted(l),()=>"thresholds are not sorted"),b(a<n,()=>`margin(${a}) must be lower then length(${n})`),this.#t=n,this.#e=a,this.#r=l,this.#i=l.map((c,d)=>c+d*this.#e)}begin(n){this.#a&&(this.#s=this.valueToX(n)),this.#o=n}moveBy(n){b(!isNaN(this.#o),()=>"value has never been set"),this.#s+=n/this.#t*this.#n,this.#o=this.#a?this.xToValue(this.#s):$(this.#s,0,1)}ratio(n){this.#n=n}value(){return b(!isNaN(this.#o),()=>"value has never been set"),this.#o}disable(){this.#a&&(this.#a=!1,this.#s=this.xToValue(this.#s))}enable(){this.#a||(this.#a=!0,this.#s=this.valueToX(this.#s))}valueToX(n){let a=oe.rightMost(this.#r,n,At);if(a<0)return n;{let l=this.#i[a],c=this.#r[a];return n===c?l+this.#e/2:l+this.#e+(n-c)}}xToValue(n){let a=$(n,0,1+this.#e*this.#r.length),l=oe.rightMost(this.#i,a,At);if(l<0)return a;{let c=this.#i[l],d=this.#r[l];return a>c+this.#e?a-(c+this.#e)+d:d}}get margin(){return this.#e}}})(ba||(ba={}));var ji;(function(i){class e extends Error{}i.Warning=e,i.warn=r=>{throw new e(r)};class t extends Error{constructor(s){super(`${s} not found`)}}i.FileNotFound=t,i.AbortError=typeof DOMException>"u"?{name:"AbortError",message:""}:Object.freeze(new DOMException("AbortError")),i.isAbort=r=>r===i.AbortError||i.isDOMException(r)&&r.name==="AbortError",i.CatchAbort=r=>r===i.AbortError?void 0:g(r),i.isOverconstrained=r=>bt(r)&&"constraint"in r,i.isDOMException=r=>bt(r)&&vn(r,"name","string")&&vn(r,"message","string")})(ji||(ji={}));var Qi=Symbol.for("@openDAW/lib-std");globalThis[Qi]?console.debug(`%c${Qi.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Qi]=!0,console.debug(`%c${Qi.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Ft=class{a1=0;a2=0;b0=0;b1=0;b2=0;constructor(){this.identity()}identity(){this.setNormalizedCoefficients(1,0,0,1,0,0)}setLowpassParams(e,t){if(e=$(e,0,1),e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1-o)/2,a=n,l=2*n,c=n,d=1+s,m=-2*o,f=1-s;this.setNormalizedCoefficients(a,l,c,d,m,f)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}setHighpassParams(e,t){if(e=$(e,0,1),e===1)this.setNormalizedCoefficients(0,0,0,1,0,0);else if(e>0){t=Math.pow(10,t/20);let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=(1+o)/2,a=n,l=-2*n,c=n,d=1+s,m=-2*o,f=1-s;this.setNormalizedCoefficients(a,l,c,d,m,f)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNormalizedCoefficients(e,t,r,s,o,n){let a=1/s;return this.b0=e*a,this.b1=t*a,this.b2=r*a,this.a1=o*a,this.a2=n*a,this}setLowShelfParams(e,t){e=$(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(r*r,0,0,1,0,0);else if(e>0){let s=We*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),l=2*Math.sqrt(r)*n,c=r+1,d=r-1,m=r*(c-d*a+l),f=2*r*(d-c*a),y=r*(c-d*a-l),B=c+d*a+l,S=-2*(d+c*a),R=c+d*a-l;this.setNormalizedCoefficients(m,f,y,B,S,R)}else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setHighShelfParams(e,t){e=$(e,0,1);let r=Math.pow(10,t/40);if(e===1)this.setNormalizedCoefficients(1,0,0,1,0,0);else if(e>0){let s=We*e,n=.5*Math.sin(s)*Math.sqrt((r+1/r)*(1/1-1)+2),a=Math.cos(s),l=2*Math.sqrt(r)*n,c=r+1,d=r-1,m=r*(c+d*a+l),f=-2*r*(d+c*a),y=r*(c+d*a-l),B=c-d*a+l,S=2*(d-c*a),R=c-d*a-l;this.setNormalizedCoefficients(m,f,y,B,S,R)}else this.setNormalizedCoefficients(r*r,0,0,1,0,0);return this}setPeakingParams(e,t,r){e=$(e,0,1),t=Math.max(0,t);let s=Math.pow(10,r/40);if(e>0&&e<1)if(t>0){let o=We*e,n=Math.sin(o)/(2*t),a=Math.cos(o),l=1+n*s,c=-2*a,d=1-n*s,m=1+n/s,f=-2*a,y=1-n/s;this.setNormalizedCoefficients(l,c,d,m,f,y)}else this.setNormalizedCoefficients(s*s,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setAllpassParams(e,t){if(e=$(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1-s,a=-2*o,l=1+s,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(-1,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setNotchParams(e,t){if(e=$(e,0,1),t=Math.max(0,t),e>0&&e<1)if(t>0){let r=We*e,s=Math.sin(r)/(2*t),o=Math.cos(r),n=1,a=-2*o,l=1,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(0,0,0,1,0,0);else this.setNormalizedCoefficients(1,0,0,1,0,0);return this}setBandpassParams(e,t){if(e=Math.max(0,e),t=Math.max(0,t),e>0&&e<1){let r=We*e;if(t>0){let s=Math.sin(r)/(2*t),o=Math.cos(r),n=s,a=0,l=-s,c=1+s,d=-2*o,m=1-s;this.setNormalizedCoefficients(n,a,l,c,d,m)}else this.setNormalizedCoefficients(1,0,0,1,0,0)}else this.setNormalizedCoefficients(0,0,0,1,0,0);return this}getFrequencyResponse(e,t,r){b(e.length===t.length&&e.length===r.length,"Array lengths do not match");let s=this.b0,o=this.b1,n=this.b2,a=this.a1,l=this.a2;for(let c=0;c<e.length;++c){let d=-Math.PI*2*e[c],m=Math.cos(d),f=Math.sin(d),y=s+((o+n*m)*m-n*f*f),B=(o+n*m)*f+n*f*m,S=1+((a+l*m)*m-l*f*f),R=(a+l*m)*f+l*f*m,k=S*S+R*R,L=(y*S+B*R)/k,z=(B*S-y*R)/k;t[c]=Math.sqrt(L*L+z*z),r[c]=Math.atan2(z,L)}}};var be=class{#t=0;#e=0;#r=0;#i=0;reset(){this.#t=0,this.#e=0,this.#r=0,this.#i=0}process({a1:e,a2:t,b0:r,b1:s,b2:o},n,a,l,c){let d=this.#t,m=this.#e,f=this.#r,y=this.#i;for(let B=l;B<c;B++){let S=n[B],R=a[B]=r*S+s*d+o*m-e*f-t*y+1e-18-1e-18;m=d,d=S,y=f,f=R}this.#t=d,this.#e=m,this.#r=f,this.#i=y}processFrame({a1:e,a2:t,b0:r,b1:s,b2:o},n){let a=r*n+s*this.#t+o*this.#e-e*this.#r-t*this.#i+1e-18-1e-18;return this.#e=this.#t,this.#t=n,this.#i=this.#r,this.#r=a,a}},or=class{#t;order;constructor(e){this.#t=w.create(()=>new be,e),this.order=this.#t.length}reset(){this.#t.forEach(e=>e.reset())}process(e,t,r,s,o){for(let n=0;n<this.order;n++)this.#t[n].process(e,t,r,s,o),t=r}processFrame(e,t){for(let r=0;r<this.order;r++)t=this.#t[r].processFrame(e,t);return t}};var Aa;(function(i){function e(t,r,s={}){let{interval:o=64,scanSteps:n=1024,scanSamples:a=2048,minBPM:l=90,maxBPM:c=180}=s,d=new Float32Array(Math.floor(t.length/o)),m=0,f=0,y=0;for(let U of t){let Z=Math.abs(U);m+=(Z-m)*(Z>m?1/8:1/512),++f===o&&(f=0,d[y++]=m)}if(!d.length)return NaN;let B=(U,Z)=>U[Math.floor(Z)]??0,S=U=>r/(U/60)/o,R=U=>r/(U*o)*60,k=[-32,-16,-8,-4,-2,-1,1,2,4,8,16,32],L=[-.5,-.25,.25,.5],z=U=>{let Z=Math.random()*d.length,ee=B(d,Z),ke=0,_e=0;for(let Ee of k){let He=1/Math.abs(Ee);ke+=He*Math.abs(B(d,Z+Ee*U)-ee),_e+=He}for(let Ee of L){let He=Math.abs(Ee);ke-=He*Math.abs(B(d,Z+Ee*U)-ee),_e+=He}return ke/_e},_=U=>{let Z=0;for(let ee=0;ee<a;++ee)Z+=z(U);return Z/a},ie=S(l),de=S(c),ce=(ie-de)/n,H=l,J=1/0;for(let U=de;U<=ie;U+=ce){let Z=R(U),ee=_(U)*(l/Z);ee<J&&(J=ee,H=Z)}return H}i.detect=e})(Aa||(Aa={}));var wa;(function(i){i.Major=[0,2,4,5,7,9,11],i.Minor=[0,2,3,5,7,8,10],i.NoteLabels=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],i.compile=(e,t,r,s)=>w.create(o=>{let n=r+o*2,a=e[n%7]+Math.floor(n/7)*12;return t+a},s),i.toString=e=>i.NoteLabels[e%12]+(Math.floor(e/12)-2)})(wa||(wa={}));var nr;(function(i){i.Comparator=(e,t)=>e.position-t.position,i.PositionExtractor=e=>e.position})(nr||(nr={}));var ar;(function(i){i.complete=e=>e.position+e.duration,i.DescendingComparator=(e,t)=>i.complete(t)-i.complete(e)})(ar||(ar={}));var Ie;(function(i){i.globalToLocal=(t,r)=>xi(r-t.position+t.loopOffset,t.loopDuration),i.locateLoop=({position:t,complete:r,loopOffset:s,loopDuration:o},n,a)=>{let l=t-s,c=l+o;if(l>=a||c<=n)return p.None;let d=Math.max(l,n),m=Math.min(c,a);return p.wrap({index:0,rawStart:l,rawEnd:c,regionStart:Math.max(l,t),regionEnd:Math.min(c,r),resultStart:d,resultEnd:m,resultStartValue:l<d?(d-l)/o:0,resultEndValue:c>m?(m-l)/o:1})};function*e({position:t,complete:r,loopOffset:s,loopDuration:o},n,a){let l=t-s,c=Math.max(t,n),d=Math.min(r,a),m=Math.floor((c-l)/o),f=l+m*o;for(;f<d;){let y=f+o,B=Math.max(f,t),S=Math.min(y,r),R=Math.max(f,c),k=Math.min(y,d),L=f<R?(R-f)/o:0,z=y>k?(k-f)/o:1;yield{index:m++,rawStart:f,rawEnd:y,regionStart:B,regionEnd:S,resultStart:R,resultEnd:k,resultStartValue:L,resultEndValue:z},f=y}}i.locateLoops=e})(Ie||(Ie={}));var Nt=class i{static DefaultComparator=(e,t)=>e.position-t.position;static create(e){return new i(e??i.DefaultComparator)}#t;constructor(e){this.#t=new Yi(e)}add(e){this.#t.add(e)}remove(e){return this.#t.remove(e)}contains(e){return this.#t.contains(e)}clear(){this.#t.clear()}optAt(e){return this.#t.optAt(e)}asArray(){return this.#t.asArray()}lowerEqual(e,t){return this.#t.lowerEqual(e,t)}greaterEqual(e,t){return this.#t.greaterEqual(e,t)}floorLastIndex(e){return this.#t.floorLastIndex(e)}ceilFirstIndex(e){return this.#t.ceilFirstIndex(e)}iterateFrom(e,t){return this.#t.isEmpty()?ht.empty():this.#t.iterateFrom(e,t)}iterateRange(e,t,r){return this.#t.isEmpty()?ht.empty():this.#t.iterate(this.#t.ceilFirstIndex(e),t,r)}length(){return this.#t.length()}isEmpty(){return this.#t.isEmpty()}onIndexingChanged(){this.#t.onIndexingChanged()}},Pt=class i{static Comparator=(e,t)=>e.position-t.position;static create(e){return new i(e)}#t;constructor(e=i.Comparator){this.#t=new Yi(e)}add(e){this.#t.add(e)}remove(e){return this.#t.remove(e)}contains(e){return this.#t.contains(e)}clear(){this.#t.clear()}optAt(e){return this.#t.optAt(e)}asArray(){return this.#t.asArray()}lowerEqual(e,t){return this.#t.lowerEqual(e,t)}greaterEqual(e,t){return this.#t.greaterEqual(e,t)}floorLastIndex(e){return this.#t.floorLastIndex(e)}ceilFirstIndex(e){return this.#t.ceilFirstIndex(e)}iterateFrom(e,t){return this.#t.isEmpty()?ht.empty():this.#t.iterateFrom(e,t)}iterateRange(e,t){if(this.#t.isEmpty())return ht.empty();let r=Math.max(0,this.#t.floorLastIndex(e)),s=this.#t.optAt(r);if(s===null)return ht.empty();for(;s.position+s.duration<=e;)if(s=this.#t.optAt(++r),s===null||s.position>=t)return ht.empty();return this.#t.iterate(r,t)}length(){return this.#t.length()}isEmpty(){return this.#t.isEmpty()}onIndexingChanged(){this.#t.onIndexingChanged()}},Fr=class{#t;constructor(){this.#t=[]}addAndRetain(e){if(this.#t.length===0)this.#t.push(e);else{let t=oe.leftMost(this.#t,e,ar.DescendingComparator);this.#t.splice(t,0,e)}}*overlapping(e,t){let r=this.#t.filter(s=>s.position<=e&&e<s.position+s.duration);yield*V(t)?r.sort(t):r}*releaseLinearCompleted(e){if(this.#t.length!==0)for(let t=this.#t.length-1;t>=0;t--){let r=this.#t[t];if(ar.complete(r)<e)this.#t.splice(t,1),yield r;else return}}*releaseAll(){if(this.#t.length!==0)for(let e=this.#t.length-1;e>=0;e--){let t=this.#t[e];Number.POSITIVE_INFINITY>t.duration&&(this.#t.splice(e,1),yield t)}}isEmpty(){return this.#t.length===0}nonEmpty(){return this.#t.length>0}clear(){w.clear(this.#t)}},Yi=class{comparator;#t=[];#e=!1;modCount=0;constructor(e){this.comparator=e}add(e){++this.modCount,this.#t.push(e),this.#t.length>1&&(this.#e=!0)}remove(e){++this.modCount;let t=this.#t.indexOf(e);return t===-1?!1:(this.#t.splice(t,1),!0)}contains(e){if(this.#t.length===0)return!1;this.#e&&this.#r();let r=e.position,s=oe.leftMostMapped(this.#t,r,At,nr.PositionExtractor);for(let o=s;o<this.#t.length;o++){let n=this.#t[o];if(n===e)return!0;if(n.position!==r)return!1}return!1}clear(){++this.modCount,w.clear(this.#t),this.#e=!1}optAt(e){return e<0||e>=this.#t.length?null:(this.#e&&this.#r(),this.#t[e])}asArray(){return this.#e&&this.#r(),this.#t}lowerEqual(e,t){if(t===void 0)return this.optAt(this.floorLastIndex(e));let r=this.floorLastIndex(e);for(;r>=0;){let s=this.#t[r--];if(t(s))return s}return null}greaterEqual(e,t){if(t===void 0)return this.optAt(this.ceilFirstIndex(e));let r=this.ceilFirstIndex(e);for(;r<this.#t.length;){let s=this.#t[r++];if(t(s))return s}return null}floorLastIndex(e){return this.#e&&this.#r(),oe.rightMostMapped(this.#t,e,At,nr.PositionExtractor)}ceilFirstIndex(e){return this.#e&&this.#r(),oe.leftMostMapped(this.#t,e,At,nr.PositionExtractor)}iterateFrom(e,t){let r=this.floorLastIndex(e),s=r;if(s<0)return this.iterate(0,Se.MAX_VALUE,t);for(;s>=0;){let o=this.optAt(s);if(o!==null&&t!==void 0&&t(o))return this.iterate(s,Se.MAX_VALUE,t);s--}return this.iterate(r,Se.MAX_VALUE,t)}length(){return this.#t.length}isEmpty(){return this.#t.length===0}onIndexingChanged(){this.#e=this.length()>1}*iterate(e,t,r=Gi.alwaysTrue){for(this.#e&&this.#r();e<this.#t.length;){let s=this.#t[e++];if(s.position>=t)return;r(s)&&(yield s)}}#r(){this.#t.sort(this.comparator),this.#e=!1}};var Xi=class i{static reverse(e){return e=(e&1431655765)<<1|e>>>1&1431655765,e=(e&858993459)<<2|e>>>2&858993459,e=(e&252645135)<<4|e>>>4&252645135,e=e<<24|(e&65280)<<8|e>>>8&65280|e>>>24,e}#t;#e;#r;#i;constructor(e){this.#t=e;let t=e/2;this.#e=32-Math.floor(Math.log2(e))|0,this.#r=new Float32Array(t),this.#i=new Float32Array(t);for(let r=0;r<t;r++){let s=2*Math.PI*r/e;this.#r[r]=Math.cos(s),this.#i[r]=Math.sin(s)}}process(e,t){let r,s,o,n;for(let c=0;c<this.#t;++c)s=i.reverse(c)>>>this.#e,s>c&&(n=e[c],e[c]=e[s],e[s]=n,n=t[c],t[c]=t[s],t[s]=n);let a=this.#r,l=this.#i;for(let c=2;c<=this.#t;c<<=1){let d=c>>1,m=this.#t/c;for(r=0;r<this.#t;r+=c){let f=r+d;for(s=r,o=0;s<f;s++,o=o+m|0){let y=s+d|0,B=a[o],S=l[o],R=e[y],k=t[y],L=R*B+k*S,z=k*B-R*S,_=e[s],ie=t[s];e[y]=_-L,t[y]=ie-z,e[s]=_+L,t[s]=ie+z}}if(c===this.#t)break}}};var Rn=(i,e)=>Math.floor(3840/e)*i,Ea=(i,e=4,t=4)=>{let r=Rn(1,t),s=Math.floor(i/r),o=Math.floor(s/e),a=(Math.floor(i)-Rn(o*e,t))%r,l=Math.floor(a/240),c=a%240;return{bars:o,beats:s-o*e,semiquavers:l,ticks:c}},Ba=(i,e)=>i*e/60*960,Fa=(i,e)=>i*60/960/e,yl=(i,e,t)=>Ba(i/t,e),vl=(i,e,t)=>Fa(i,e)*t,W={Bar:3840,Quarter:960,SemiQuaver:240,fromSignature:Rn,toParts:Ea,secondsToPulses:Ba,pulsesToSeconds:Fa,samplesToPulses:yl,pulsesToSamples:vl,toString:(i,e=4,t=4)=>{let{bars:r,beats:s,semiquavers:o,ticks:n}=Ea(i|0,e,t);return`${r+1}.${s+1}.${o+1}:${n}`}};var je;(function(i){i.builder=()=>new e,i.toDouble=([t,r])=>t/r,i.toPPQN=([t,r])=>W.fromSignature(t,r);class e{#t=[];add(r){return this.#t.push(r),this}asArray(){return this.#t}asAscendingArray(){return this.#t.toSorted((r,s)=>i.toDouble(r)-i.toDouble(s))}asDescendingArray(){return this.#t.toSorted((r,s)=>i.toDouble(s)-i.toDouble(r))}}})(je||(je={}));var St=class{static*iterate(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield o,o=++s*r}static*iterateWithIndex(e,t,r){let s=Math.ceil(e/r),o=s*r;for(;o<t;)yield{position:o,index:s},o=++s*r}};var Zi=class{#t;#e;constructor(){this.#t=[],this.#e=new Map}addVertex(e){b(!this.#t.includes(e),"Vertex already exists"),this.#t.push(e),b(!this.#e.has(e),"Predecessor already exists"),this.#e.set(e,[])}removeVertex(e){w.remove(this.#t,e);let t=this.#e.delete(e);b(t,"Predecessor does not exists")}getPredecessors(e){return this.#e.get(e)??w.empty()}predecessors(){return this.#e}vertices(){return this.#t}addEdge([e,t]){let r=K(this.#e.get(t),`[add] Edge has unannounced vertex. (${t})`);b(!r.includes(e),`${e} is already marked.`),r.push(e)}removeEdge([e,t]){let r=K(this.#e.get(t),`[remove] Edge has unannounced vertex. (${t})`);b(r.includes(e),`${e} is not marked.`),w.remove(r,e)}isEmpty(){return this.#t.length===0}},Ji=class{#t;#e;#r;#i;#s;constructor(e){this.#t=e,this.#e=[],this.#r=new Set,this.#i=new Set,this.#s=new Map}update(){this.#o(),this.#t.vertices().forEach(e=>this.#n(e))}sorted(){return this.#e}hasLoops(){return this.#i.size!==0}#o(){this.#a();let e=new Map;for(let r of this.#t.vertices())this.#s.set(r,new Set),e.set(r,new Set);for(let r of this.#t.vertices())for(let s of this.#t.getPredecessors(r))K(this.#s.get(s),`Could not find Successor for ${s}`).add(r);let t;do{t=!1;for(let r of this.#t.vertices()){K(e.get(r)).clear();for(let s of K(this.#s.get(r)))for(let o of K(this.#s.get(s)))this.#s.get(r)?.has(o)||(t=!0,K(e.get(r)).add(o))}for(let r of this.#t.vertices()){let s=K(this.#s.get(r));K(e.get(r)).forEach(o=>s.add(o))}}while(t)}#n(e){if(!this.#r.has(e)){this.#r.add(e);for(let t of this.#t.getPredecessors(e)){if(K(this.#s.get(e)).has(t)){this.#i.add(e),this.#i.add(t);continue}this.#n(t)}this.#e.push(e)}}#a(){w.clear(this.#e),this.#r.clear(),this.#i.clear(),this.#s.clear()}};var Ai;(function(i){i.Identity={warp:e=>e,unwarp:e=>e}})(Ai||(Ai={}));var es=class{#t;constructor(e){this.#t=e}warp(e){return this.#e(!0,e)}unwarp(e){return this.#e(!1,e)}#e(e,t){let r=this.#t.duration(),s=lt(t,r),o=(t-s)/r,n=e?this.#t.fx(o):this.#t.fy(o);return s+n*r}};var Na;(function(i){i.BlackKeyIndices=[1,3,6,8,10],i.BlackKeyBits=i.BlackKeyIndices.reduce((t,r)=>t|=1<<r,0),i.Names={English:["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],German:["C","Cis","D","Dis","E","F","Fis","G","Gis","A","Ais","H"],Solfege:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],French:["Do","Do#","R\xE9","R\xE9#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Spanish:["Do","Do#","Re","Re#","Mi","Fa","Fa#","Sol","Sol#","La","La#","Si"],Japanese:["\u30C9","\u30C9\u266F","\u30EC","\u30EC\u266F","\u30DF","\u30D5\u30A1","\u30D5\u30A1\u266F","\u30BD","\u30BD\u266F","\u30E9","\u30E9\u266F","\u30B7"]},i.isBlackKey=t=>(i.BlackKeyBits&1<<t%12)!==0,i.toFullString=t=>`${i.Names.English[t%12]}${Math.floor(t/12)-2}`;class e{#t;#e;constructor(r,...s){this.#t=r,this.#e=s.reduce((o,n)=>o|=1<<n,0)}get name(){return this.#t}get bits(){return this.#e}has(r){return(this.#e&1<<r%12)!==0}equals(r){return this.#e===r.bits}}i.StockScales=[new e("Major",0,2,4,5,7,9,11),new e("Natural Minor",0,2,3,5,7,8,10),new e("Harmonic Minor",0,2,3,5,7,8,11),new e("Melodic Minor",0,2,3,5,7,9,11),new e("Dorian",0,2,3,5,7,9,10),new e("Phrygian",0,1,3,5,7,8,10),new e("Lydian",0,2,4,6,7,9,11),new e("Mixolydian",0,2,4,5,7,9,10),new e("Locrian",0,1,3,5,6,8,10),new e("Pentatonic Major",0,2,4,7,9),new e("Pentatonic Minor",0,3,5,7,10),new e("Blues",0,3,5,6,7,10),new e("Whole Tone",0,2,4,6,8,10),new e("Diminished",0,2,3,5,6,8,9,11),new e("Augmented",0,3,4,7,8,11)]})(Na||(Na={}));var Me;(function(i){i.isOfType=e=>e.type==="note-event",i.Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.pitch-t.pitch;return s!==0?s:0},i.curveFunc=(e,t)=>t<0?e**2**-t:1-(1-e)**2**t,i.inverseCurveFunc=(e,t)=>t<0?e**2**t:1-Math.max(0,1-e)**2**-t,i.CompleteComparator=(e,t)=>{let r=ar.complete(e)-ar.complete(t);return r!==0?r:e.pitch-t.pitch}})(Me||(Me={}));var dt;(function(i){i[i.sine=0]="sine",i[i.triangle=1]="triangle",i[i.sawtooth=2]="sawtooth",i[i.square=3]="square"})(dt||(dt={}));var ts=class{#t=0;#e=0;generate(e,t,r,s,o){for(let n=s;n<o;n++){let a=this.#t%1,l=0;switch(r){case dt.sine:l=Math.sin(2*Math.PI*a);break;case dt.sawtooth:l=2*a-1,l-=this.#r(a,t);break;case dt.square:l=a<.5?1:-1,l+=this.#r(a,t),l-=this.#r((a+.5)%1,t);break;case dt.triangle:let c=a<.5?1:-1;c+=this.#r(a,t),c-=this.#r((a+.5)%1,t),this.#e+=c*(4*t),l=this.#e;break}e[n]=l,this.#t+=t}}#r(e,t){return e<t?(e/=t,e+e-e*e-1):e>1-t?(e=(e-1)/t,e*e+e+e+1):0}};var pt;(function(i){let e;(function(t){t[t.Linear=0]="Linear",t[t.EqualPower=1]="EqualPower"})(e=i.Mixing||(i.Mixing={})),i.zero=()=>({ll:0,lr:0,rl:0,rr:0}),i.identity=()=>({ll:1,lr:0,rl:0,rr:1}),i.update=(t,{gain:r,panning:s,invertL:o,invertR:n,stereo:a,swap:l},c=e.EqualPower)=>{let[d,m]=i.panningToGains(s,c),f=d*r,y=m*r;o&&(f*=-1),n&&(y*=-1);let B=Math.max(0,-a),S=Math.max(0,a),R=1-S,k=1+S,L=B*.5,z=1-B,_=(R+k)*.5,ie=(R-k)*.5,de=(R-k)*.5,ce=(R+k)*.5,H=f*(L+z)*_+y*L*ie,J=f*(L+z)*de+y*L*ce,U=f*L*_+y*(L+z)*ie,Z=f*L*de+y*(L+z)*ce;l?(t.ll=J,t.rl=H,t.lr=Z,t.rr=U):(t.ll=H,t.lr=U,t.rl=J,t.rr=Z)},i.panningToGains=(t,r)=>{let s=$(t,-1,1);switch(r){case e.Linear:return[Math.min(1-s,1),Math.min(s+1,1)];case e.EqualPower:return[Math.cos((s+1)*wn),Math.sin((s+1)*wn)]}},i.applyFrame=(t,r,s)=>[t.ll*r+t.rl*s,t.lr*r+t.rr*s],i.processFrames=(t,r,s,o,n)=>{let[a,l]=r,[c,d]=s;for(let m=o;m<n;m++){let f=a[m],y=l[m];c[m]=t.ll*f+t.rl*y,d[m]=t.lr*f+t.rr*y}},i.replaceFrames=(t,[r,s],o,n)=>{for(let a=o;a<n;a++){let l=r[a],c=s[a];r[a]=t.ll*l+t.rl*c,s[a]=t.lr*l+t.rr*c}}})(pt||(pt={}));var Qe;(function(i){i.linear=(r,s=.005)=>new e(Math.ceil(r*s)|0),i.stereoMatrix=(r,s=.005)=>new t(Math.ceil(r*s)|0);class e{#t;#e=0;#r=0;#i=0;#s=0;constructor(s){this.#t=s}set(s,o){this.#e!==s&&(o===!0?(this.#r=s,this.#i=(s-this.#e)/this.#t,this.#s=this.#t):(this.#e=this.#r=s,this.#i=0,this.#s=0))}get(){return this.#e}moveAndGet(){return 0<this.#s&&(this.#e+=this.#i,--this.#s===0&&(this.#i=0,this.#e=this.#r)),this.#e}isFixed(s){return this.#e===s&&this.#s===0}isInterpolating(){return this.#s>0}}class t{#t;#e=pt.zero();#r=pt.zero();#i=pt.zero();#s=0;constructor(s){this.#t=s}update(s,o,n){pt.update(this.#r,s,o),n===!0?(this.#i.ll=(this.#r.ll-this.#e.ll)/this.#t,this.#i.lr=(this.#r.lr-this.#e.lr)/this.#t,this.#i.rl=(this.#r.rl-this.#e.rl)/this.#t,this.#i.rr=(this.#r.rr-this.#e.rr)/this.#t,this.#s=this.#t):(this.#e.ll=this.#r.ll,this.#e.lr=this.#r.lr,this.#e.rl=this.#r.rl,this.#e.rr=this.#r.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0)}processFrames(s,o,n,a){let[l,c]=s,[d,m]=o;if(this.isInterpolating())for(let f=n;f<a;f++){let y=l[f],B=c[f],S=this.moveAndGet();d[f]=S.ll*y+S.rl*B,m[f]=S.lr*y+S.rr*B}else{let f=this.#r;for(let y=n;y<a;y++){let B=l[y],S=c[y];d[y]=f.ll*B+f.rl*S,m[y]=f.lr*B+f.rr*S}}}set(s,o){this.#o(s)||(o===!0?(this.#r.ll=s.ll,this.#r.lr=s.lr,this.#r.rl=s.rl,this.#r.rr=s.rr,this.#i.ll=(s.ll-this.#e.ll)/this.#t,this.#i.lr=(s.lr-this.#e.lr)/this.#t,this.#i.rl=(s.rl-this.#e.rl)/this.#t,this.#i.rr=(s.rr-this.#e.rr)/this.#t,this.#s=this.#t):(this.#e.ll=this.#r.ll=s.ll,this.#e.lr=this.#r.lr=s.lr,this.#e.rl=this.#r.rl=s.rl,this.#e.rr=this.#r.rr=s.rr,this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#s=0))}get(){return this.#e}moveAndGet(){return 0<this.#s&&(this.#e.ll+=this.#i.ll,this.#e.lr+=this.#i.lr,this.#e.rl+=this.#i.rl,this.#e.rr+=this.#i.rr,--this.#s===0&&(this.#i.ll=0,this.#i.lr=0,this.#i.rl=0,this.#i.rr=0,this.#e.ll=this.#r.ll,this.#e.lr=this.#r.lr,this.#e.rl=this.#r.rl,this.#e.rr=this.#r.rr)),this.#e}isFixed(s){return this.#o(s)&&this.#s===0}isInterpolating(){return this.#s>0}#o(s){return this.#e.ll===s.ll&&this.#e.lr===s.lr&&this.#e.rl===s.rl&&this.#e.rr===s.rr}}i.StereoMatrixRamp=t})(Qe||(Qe={}));var Nr=class{#t;#e;#r;#i;constructor(e){this.#t=new Float32Array(e),this.#e=1/e,this.#r=0,this.#i=0}pushPop(e){let t=e*e;return this.#i-=this.#t[this.#r],this.#i+=t,this.#t[this.#r]=t,++this.#r===this.#t.length&&(this.#r=0),this.#i<=0?0:Math.sqrt(this.#i*this.#e)}clear(){this.#t.fill(0),this.#i=0,this.#r=0}};var bl=Math.log(10)/20,wi=(i=60,e=440)=>e*Math.pow(2,(i+3)/12-6);var Ae=i=>Math.exp(i*bl);var Pr=i=>Ae(20*Math.log10(i));var Ct={None:{type:"none"},Linear:{type:"linear"},Curve:i=>({type:"curve",slope:i})},rs;(function(i){i.Comparator=(s,o)=>{let n=s.position-o.position;if(n!==0)return n;let a=s.index-o.index;return a!==0?a:s===o?0:g(`${s} and ${o} are identical in terms of comparison`)};function*e(s,o,n){if(s.isEmpty())return le.empty();for(let a of s.iterateFrom(o))if(yield a,a.position>=n)return}i.iterateWindow=e,i.nextEvent=(s,o)=>{let n=s.asArray(),a=oe.rightMost(n,o,i.Comparator);return a===-1?null:n[a+1]??null},i.valueAt=(s,o,n)=>{if(s.isEmpty())return n;let a=s.iterateFrom(o),{done:l,value:c}=a.next();if(l)return n;if(c.position<=o){let{done:d,value:m}=a.next();if(d)return c.value;if(o<m.position)return r(c,m,o);if(c.interpolation===Ct.None)return c.value}return c.value};function*t(s,o,n,a){if(s.isEmpty())return;let l=s.iterateFrom(o),{done:c,value:d}=l.next();if(c)return;let m=n/a,f=d;if(f.position>o){for(;o<f.position;)if(yield{position:o,value:f.value},o+=m,o>n)return;f.position<=n&&(yield f)}for(;o<=n;){let{done:y,value:B}=l.next();if(y)break;for(;o<B.position;){if(o>n)return;yield{position:o,value:r(f,B,o)},o+=m}B.position<n&&(f.interpolation===Ct.None&&(yield{position:B.position,value:f.value}),yield B),f=B}for(;o<=n;)yield{position:o,value:f.value},o+=m}i.quantise=t;let r=({value:s,position:o,interpolation:n},a,l)=>n.type==="none"?s:n.type==="linear"?s+(l-o)/(a.position-o)*(a.value-s):n.type==="curve"?Ue.valueAt({slope:n.slope,steps:a.position-o,y0:s,y1:a.value},l-o):g("Unknown interpolation")})(rs||(rs={}));var Ei;(function(i){let e;(function(t){t[t.Bartlett=0]="Bartlett",t[t.Blackman=1]="Blackman",t[t.BlackmanHarris=2]="BlackmanHarris",t[t.Hamming=3]="Hamming",t[t.Hanning=4]="Hanning"})(e=i.Type||(i.Type={})),i.create=(t,r)=>{let s=new Float32Array(r),o=Math.PI/(r-1);switch(t){case e.Bartlett:{let n=(r>>1)-1,a=0;for(;a<=n;++a)s[a]=2*a/(r-1);for(;a<r;++a)s[a]=2-2*a/(r-1);return s}case e.Blackman:{let n=2*o,a=4*o;for(let l=0;l<r;++l)s[l]=.42323-.49755*Math.cos(n*l)+.07922*Math.cos(a*l);return s}case e.BlackmanHarris:{let n=2*o,a=4*o,l=6*o;for(let c=0;c<r;++c)s[c]=.35875-.48829*Math.cos(n*c)+.14128*Math.cos(a*c)-.01168*Math.cos(l*c);return s}case e.Hamming:{let n=2*o;for(let a=0;a<r;++a)s[a]=.54-.46*Math.cos(n*a);return s}case e.Hanning:{let n=2*o;for(let a=0;a<r;++a)s[a]=.5-.5*Math.cos(n*a);return s}}}})(Ei||(Ei={}));var is=Symbol.for("@openDAW/lib-dsp");globalThis[is]?console.debug(`%c${is.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[is]=!0,console.debug(`%c${is.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var ss=class extends AudioWorkletProcessor{#t;#e;#r;#i;#s;#o=0;constructor({processorOptions:{sab:e,numberOfChannels:t,rmsWindowInSeconds:r,valueDecay:s}}){super(),this.#t=t,this.#e=new Float32Array(t),this.#r=new Float32Array(t),this.#i=w.create(()=>new Nr(sampleRate*r),t);let o=Re.createBuilder({peak:Re.floats(t),rms:Re.floats(t)})();this.#s=Br.writer(o,e,n=>{let a=Math.exp(-(128*this.#o)/(sampleRate*s));for(let l=0;l<t;++l){let c=this.#e[l],d=this.#r[l];n.peak[l]=c,n.rms[l]=Math.sqrt(d),this.#e[l]=c*a,this.#r[l]=d*a}this.#o=0})}process([e]){for(let t=0;t<this.#t;++t){let r=e[t];if(r===void 0)this.#e[t]=0,this.#r[t]=0;else{let s=this.#i[t],o=this.#e[t],n=this.#r[t];for(let a=0;a<128;++a){let l=r[a];o=Math.max(o,Math.abs(l)),n=Math.max(n,s.pushPop(l*l))}this.#e[t]=o,this.#r[t]=n}}return this.#o++,this.#s.tryWrite(),!0}};var j=class i{static newSet(e){return new Et(e,i.Comparator)}static compose=(e,...t)=>{let r=t.length===0?this.#t:new Int16Array(t);return b(r.every((s,o)=>s===t[o]),`fieldKeys (${r.join(",")}) only allows i16`),new i(e,r)};static decode(e){let t=e.split("/");return b(t.length>0,"Unable to parse Address"),i.compose(A.parse(t[0]),...t.slice(1).map(r=>parseInt(r)))}static reconstruct(e){return this.compose(e[0],...e[1])}static boxRange(e,t,r){let s=e.values(),o=oe.leftMostMapped(s,t,A.Comparator,r),n=s.length;if(o<0||o>=n)return null;for(let a=o;a<n;a++)if(A.Comparator(r(s[a]),t)!==0)return o<a?[o,a]:null;return[o,n]}static Comparator=(e,t)=>{let r=A.Comparator(e.#e,t.#e);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return e.#r.length-t.#r.length};static MinimalComparator=(e,t)=>{let r=A.Comparator(e.#e,t.#e);if(r!==0)return r;let s=Math.min(e.#r.length,t.#r.length);for(let o=0;o<s;o++){let n=e.#r[o]-t.#r[o];if(n!==0)return n}return 0};static LengthComparator=(e,t)=>{let r=A.Comparator(e.#e,t.#e);return r!==0?r:t.#r.length-e.#r.length};static#t=new Int16Array(0);#e;#r;constructor(e,t){this.#e=e,this.#r=t}get uuid(){return this.#e}get fieldKeys(){return this.#r}isBox(){return this.#r.length===0}isContent(){return!this.isBox()}equals(e){return i.Comparator(this,e)===0}compareTo(e){return i.Comparator(this,e)}append(e){return new i(this.#e,new Int16Array([...this.#r,e]))}startsWith(e){return A.Comparator(e.#e,this.#e)===0&&e.#r.length<=this.#r.length&&e.#r.every((t,r)=>this.#r[r]===t)}write(e){e.writeBytes(new Int8Array(this.#e.buffer)),e.writeByte(this.#r.length),this.#r.forEach(t=>e.writeShort(t))}moveTo(e){return new i(e,this.#r)}decompose(){return[this.#e,this.#r]}toJSON(){return{uuid:Array.from(this.#e.values()),fields:Array.from(this.#r.values())}}toArrayBuffer(){let e=new Uint8Array(A.length+this.#r.length);return e.set(this.#e,0),e.set(this.#r,A.length),e.buffer}toString(){return[A.toString(this.#e),...this.#r].join("/")}static read(e){let t=A.fromDataInput(e),r=e.readByte();return i.compose(t,...w.create(()=>e.readShort(),r))}},lr;(function(i){i.AddressReader=e=>e.address,i.Comparator=({address:e},{address:t})=>j.Comparator(e,t),i.equals=(e,t)=>{let[r,s]=oe.rangeMapped(t,e,j.Comparator,i.AddressReader);return t.slice(r,s+1)},i.startsWith=(e,t)=>{let[r,s]=oe.rangeMapped(t,e,j.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>o.address.startsWith(e))},i.endsWith=(e,t)=>{let r=oe.leftMostMapped(t,e,j.LengthComparator,i.AddressReader),s=oe.rightMostMapped(t,e,j.MinimalComparator,i.AddressReader);return t.slice(r,s+1).filter(o=>e.startsWith(o.address))}})(lr||(lr={}));var Je=class i{static validate(e,t){if(e.address.equals(t.address))return p.wrap(`PointerField cannot point to itself: ${e}`);if(!t.pointerRules.accepts.some(r=>r===e.pointerType)){let r=t.pointerRules.accepts.join(", ");return p.wrap(`${String(e.pointerType)} does not satisfy any of the allowed types (${r}).`)}return p.None}#t;#e;#r;#i=p.None;constructor(e){this.#t=e,this.#e=new ve,this.#r=new ve}subscribeImmediate(e,...t){return this.#s(this.#e,e,t)}subscribeTransactual(e,...t){return this.#s(this.#r,e,t)}catchupAndSubscribeTransactual(e,...t){let r=j.newSet(s=>s.address);return r.addMany(this.filter(...t)),r.forEach(s=>e.onAdd(s)),this.subscribeTransactual({onAdd:s=>{r.add(s)&&e.onAdd(s)},onRemove:s=>{r.removeByKey(s.address),e.onRemove(s)}},...t)}filter(...e){return e.length===0?this.incoming():le.filter(this.incoming().values(),t=>e.some(r=>r===t.pointerType))}size(){return this.incoming().length}isEmpty(){return this.size()===0}nonEmpty(){return this.size()>0}contains(e){return this.incoming().some(t=>e.address.equals(t.address))}incoming(){return this.#t.graph.edges().incomingEdgesOf(this.#t)}onAdded(e){let t=i.validate(e,this.#t);if(t.nonEmpty())return g(t.unwrap());this.#i.isEmpty()?(this.#i=p.wrap([{type:"add",pointerField:e}]),this.#t.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"add",pointerField:e}),this.#e.proxy.onAdd(e)}onRemoved(e){this.#i.isEmpty()?(this.#i=p.wrap([{type:"remove",pointerField:e}]),this.#t.graph.subscribeEndTransaction(this.#o)):this.#i.unwrap().push({type:"remove",pointerField:e}),this.#e.proxy.onRemove(e)}toString(){return`{Pointers ${this.#t.address}, pointers: ${this.incoming().values().map(e=>e.toString())}}`}#s(e,t,r){return e.subscribe({onAdd:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onAdd(s)},onRemove:s=>{(r.length===0||r.some(o=>o===s.pointerType))&&t.onRemove(s)}})}#o=()=>{let e=this.#i.unwrap("Callback without ChangeLog");e.forEach(({type:t,pointerField:r})=>{if(t==="add")this.#r.proxy.onAdd(r);else if(t==="remove")this.#r.proxy.onRemove(r);else return Ge(t)}),e.length=0,this.#i=p.None}};var Mn=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},Sr=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},T=class i{static hook(e){return new i(e)}#t;#e;#r;#i;constructor({parent:e,fieldKey:t,fieldName:r,pointerRules:s}){this.#t=e,this.#e=t,this.#r=r,this.#i=s,s.mandatory&&this.graph.edges().watchVertex(this)}accept(e){return x(e.visitField,this)}get box(){return this.#t.box}get graph(){return this.#t.graph}get parent(){return this.#t}get fieldKey(){return this.#e}get fieldName(){return this.#r}get pointerRules(){return this.#i}get pointerHub(){return new Je(this)}get address(){return this.#t.address.append(this.#e)}get debugPath(){return`${this.box.name}:${this.box.mapFields(e=>e.fieldName,...this.address.fieldKeys).join("/")}`}isBox(){return!1}isField(){return!0}isAttached(){return this.graph.findBox(this.address.uuid).nonEmpty()}fields(){return w.empty()}record(){return Ze.empty()}getField(e){return g()}optField(e){return p.None}read(e){}write(e){}toJSON(){}fromJSON(e){return g("fromJSON should never be called on a field")}disconnect(){if(this.pointerHub.isEmpty())return;let e=this.pointerHub.incoming();e.forEach(t=>{t.defer(),(t.mandatory||this.pointerRules.mandatory&&e.length===1)&&t.box.delete()})}toString(){return`{${this.box.constructor.name}:${this.constructor.name} (${this.fieldName}) ${this.address.toString()}`}};Mn([br,Sr("design:type",Je),Sr("design:paramtypes",[])],T.prototype,"pointerHub",null);Mn([br,Sr("design:type",j),Sr("design:paramtypes",[])],T.prototype,"address",null);Mn([br,Sr("design:type",String),Sr("design:paramtypes",[])],T.prototype,"debugPath",null);var h=Object.freeze({mandatory:!1,accepts:[]});var Cr=class i extends T{static create(e,t,r){return new i(e,t,r)}#t;constructor(e,t,r){super(e),this.#t=w.create(s=>t({parent:this,fieldKey:s,fieldName:String(s),pointerRules:h}),r)}accept(e){return x(e.visitArrayField,this)}fields(){return this.#t}record(){return w.toRecord(this.#t,e=>String(e.fieldKey))}getField(e){return K(this.#t[e])}optField(e){return p.wrap(this.#t[e])}read(e){this.#t.forEach(t=>t.read(e))}write(e){this.#t.forEach(t=>t.write(e))}size(){return this.#t.length}toJSON(){return Object.values(this.#t).map(e=>e.toJSON()??null)}fromJSON(e){if(Array.isArray(e))e.forEach((t,r)=>this.#t[r].fromJSON(t));else return g("Type mismatch")}};var Rt;(function(i){i.writeFields=(t,r)=>{let s=Object.entries(r);t.writeInt(1179403347),t.writeShort(s.length),s.forEach(([o,n])=>{let a=pe.create();n.write(a);let l=new Int8Array(a.toArrayBuffer());t.writeShort(Number(o)),t.writeInt(l.length),t.writeBytes(l)})},i.readFields=(t,r)=>{b(t.readInt()===1179403347,"Serializer header is corrupt");let s=t.readShort();for(let o=0;o<s;o++){let n=t.readShort();if(Ui(r[n]))continue;let a=t.readInt(),l=new Int8Array(a);t.readBytes(l);let{status:c,error:d}=rr(()=>r[n]?.read(new ge(l.buffer)));c==="failure"&&console.warn(r,d)}}})(Rt||(Rt={}));var Al=function(i,e,t,r){var s=arguments.length,o=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(i,e,t,r);else for(var a=i.length-1;a>=0;a--)(n=i[a])&&(o=(s<3?n(o):s>3?n(e,t,o):n(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o},Pa=function(i,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(i,e)},F=class i{static DEBUG_DELETION=!1;static Index=0;#t;#e;#r;#i;#s;#o=i.Index++;constructor({uuid:e,graph:t,name:r,pointerRules:s}){this.#t=j.compose(e),this.#e=t,this.#r=r,this.#i=s,this.#s=this.initializeFields(),s.mandatory&&this.graph.edges().watchVertex(this)}fields(){return Object.values(this.#s)}record(){return this.#s}getField(e){return K(this.#s[e])}optField(e){return p.wrap(this.#s[e])}subscribe(e,t){return this.graph.subscribeVertexUpdates(e,this.address,t)}get box(){return this}get name(){return this.#r}get graph(){return this.#e}get parent(){return this}get address(){return this.#t}get pointerRules(){return this.#i}get creationIndex(){return this.#o}get pointerHub(){return new Je(this)}estimateMemory(){let e=new vr;return this.write(e),e.count}isBox(){return!0}asBox(e){return er(this,e)}isField(){return!1}isAttached(){return this.#e.findBox(this.address.uuid).nonEmpty()}read(e){Rt.readFields(e,this.#s)}write(e){Rt.writeFields(e,this.#s)}serialize(){let e=pe.create();return e.writeInt(this.#o),e.writeString(this.name),e.writeBytes(new Int8Array(this.address.uuid.buffer)),this.write(e),e.toArrayBuffer()}toArrayBuffer(){let e=pe.create();return this.write(e),e.toArrayBuffer()}toJSON(){return Object.entries(this.#s).reduce((e,[t,r])=>{let s=r.toJSON();return V(s)&&(e[t]=s),e},{})}fromJSON(e){if(bt(e))Object.entries(e).forEach(([t,r])=>{let s=this.#s[parseInt(t)];V(r)&&s.fromJSON(r)});else return g("Type mismatch")}incomingEdges(){return this.graph.edges().incomingEdgesOf(this)}outgoingEdges(){return this.graph.edges().outgoingEdgesOf(this)}mapFields(e,...t){if(t.length===0)return w.empty();let r=this.getField(t[0]),s=[e(r)];for(let o=1;o<t.length;o++)r=r.getField(t[o]),s.push(e(r));return s}searchVertex(e){if(e.length===0)return p.wrap(this);let t=this.optField(e[0]);if(t.isEmpty())return p.None;for(let r=1;r<e.length;r++)if(t=t.unwrap().optField(e[r]),t.isEmpty())return p.None;return t}delete(){if(!this.isAttached())return;let{boxes:e,pointers:t}=this.graph.dependenciesOf(this);i.DEBUG_DELETION&&(console.debug(`Delete ${this.toString()}`),console.debug(" unplugs",[...t].map(r=>r.toString()).join(`
|
2
2
|
`)),console.debug(" unstages",[...e].map(r=>r.toString()).join(`
|
3
|
-
`),this));for(let r of t)r.defer();for(let r of e)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}toString(){return`${this.constructor.name} ${this.address.toString()}`}};ll([br,ma("design:type",Ze),ma("design:paramtypes",[])],P.prototype,"pointerHub",null);var Q;(function(i){i[i.This=0]="This",i[i.Parent=1]="Parent",i[i.Children=2]="Children"})(Q||(Q={}));var Ji;(function(i){i.create=()=>new xn})(Ji||(Ji={}));var xn=class{#e=new vi(lr.equals);#t=new vi(lr.startsWith);#r=new vi(lr.endsWith);#i=[];#s=0;#o=!1;subscribe(e,t,r){let s=new yn(t,e,this.#s++,r);if(this.#o){let o=new vn(s,e);return this.#i.push(o),o}else return this.subscribeMonitor(s,e)}dispatch(e){this.#o=!0,[...this.#e.filter(e),...this.#t.filter(e),...this.#r.filter(e)].sort(({order:r},{order:s})=>r-s).forEach(r=>r.procedure(e)),this.#o=!1,this.#i.forEach(r=>r.subscribe(this)),this.#i.length=0}subscribeMonitor(e,t){switch(t){case Q.This:return this.#e.subscribe(e);case Q.Parent:return this.#t.subscribe(e);case Q.Children:return this.#r.subscribe(e);default:return Ge(t)}}countStations(){return this.#e.count()+this.#t.count()+this.#r.count()}},yn=class{address;propagation;order;procedure;constructor(e,t,r,s){this.address=e,this.propagation=t,this.order=r,this.procedure=s}toString(){return`{ Monitor address: ${this.address}, propagation: ${Q[this.propagation]}, order: ${this.order} }`}},vi=class{filterStrategy;#e=[];#t=!0;constructor(e){this.filterStrategy=e}subscribe(e){return this.#e.push(e),this.#t=this.#e.length<2,{terminate:()=>{let t=this.#e.length;for(;--t>=0;)this.#e[t]===e&&this.#e.splice(t,1)}}}stations(){return this.#t||(this.#e.sort(lr.Comparator),this.#t=!0),this.#e}filter(e){return this.filterStrategy(e.address,this.stations())}count(){return this.#e.length}},vn=class{monitor;propagation;#e=new D;#t=!1;constructor(e,t){this.monitor=e,this.propagation=t}subscribe(e){this.#t||(this.#e.terminate(),this.#e.own(e.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#t=!0,this.#e.terminate()}};var pe;(function(i){i.Boolean="boolean",i.Float32="float32",i.Int32="int32",i.String="string",i.Bytes="bytes"})(pe||(pe={}));var cr={[pe.Boolean]:{type:pe.Boolean,encode:(i,e)=>i.writeBoolean(e),decode:i=>i.readBoolean()},[pe.Float32]:{type:pe.Float32,encode:(i,e)=>i.writeFloat(e),decode:i=>i.readFloat()},[pe.Int32]:{type:pe.Int32,encode:(i,e)=>i.writeInt(e),decode:i=>i.readInt()},[pe.String]:{type:pe.String,encode:(i,e)=>i.writeString(e),decode:i=>i.readString()},[pe.Bytes]:{type:pe.Bytes,encode:(i,e)=>{i.writeInt(e.length),i.writeBytes(e)},decode:i=>{let e=new Int8Array(i.readInt());return i.readBytes(e),e}}},ur=class extends I{#e;#t;#r;constructor(e,t,r){super(e),this.#e=t,this.#t=this.clamp(r),this.#r=this.#t}accept(e){return x(e.visitPrimitiveField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(Q.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.subscribe(e)}get type(){return this.#e}get initValue(){return this.#t}setInitValue(e){v(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#t=e)}getValue(){return this.#r}setValue(e){let t=this.#r,r=this.clamp(e);this.equals(r)||(this.#r=e,this.graph.onPrimitiveValueUpdate(this,t,r))}writeValue(e,t){this.serialization().encode(e,t)}readValue(e){return this.serialization().decode(e)}toJSON(){let e=this.getValue();return ArrayBuffer.isView(e)?g("not implemented"):e}fromJSON(e){return g("Type mismatch")}reset(){this.setValue(this.#t)}},N=class i extends ur{static create(e,t=!1){return new i(e,t)}constructor(e,t){super(e,pe.Boolean,t)}toggle(){this.setValue(!this.getValue())}serialization(){return cr[pe.Boolean]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readBoolean())}write(e){e.writeBoolean(this.getValue())}fromJSON(e){typeof e=="boolean"?this.setValue(e):console.warn("BooleanField Type mismatch",e,this.address.toString())}},B=class i extends ur{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Float32,t)}serialization(){return cr[pe.Float32]}equals(e){return this.getValue()===e}clamp(e){return ut.toFloat32(e)}read(e){this.setValue(e.readFloat())}write(e){e.writeFloat(this.getValue())}fromJSON(e){typeof e=="number"?this.setValue(e):console.warn("Float32Field Type mismatch",e,this.address.toString())}},b=class i extends ur{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,pe.Int32,t)}serialization(){return cr[pe.Int32]}equals(e){return this.getValue()===e}clamp(e){return Se.toInt(e)}read(e){this.setValue(e.readInt())}write(e){e.writeInt(this.getValue())}fromJSON(e){typeof e=="number"&&e===Math.floor(e)&&e>=Se.MIN_VALUE&&e<=Se.MAX_VALUE?this.setValue(e):console.warn("Int32Field Type mismatch",e,this.address.toString())}},V=class i extends ur{static create(e,t=""){return new i(e,t)}constructor(e,t){super(e,pe.String,t)}serialization(){return cr[pe.String]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readString())}write(e){e.writeString(this.getValue())}fromJSON(e){typeof e=="string"?this.setValue(e):console.warn("StringField Type mismatch",e,this.address.toString())}},fa=class i extends ur{static create(e,t=this.#e){return new i(e,t)}static#e=Object.freeze(new Int8Array(0));constructor(e,t){super(e,pe.Bytes,t)}serialization(){return cr[pe.Bytes]}equals(e){return this.getValue().length===e.length&&this.getValue().every((t,r)=>e[r]===t)}clamp(e){return e}read(e){let t=new Int8Array(e.readInt());e.readBytes(t),this.setValue(t)}write(e){let t=this.getValue();e.writeInt(t.length),e.writeBytes(t)}toJSON(){return Array.from(this.getValue().values())}fromJSON(e){Array.isArray(e)&&e.every(t=>typeof t=="number")?this.setValue(new Int8Array(e)):console.warn("ByteArrayField Type mismatch",e,this.address.toString())}};var ga;(function(i){i.decode=e=>{let t=e.readInt();return w.create(()=>{switch(e.readString()){case"new":{let s=A.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new bi(s,o,n.buffer)}case"pointer":{let s=W.read(e),o=e.readBoolean()?p.wrap(W.read(e)):p.None,n=e.readBoolean()?p.wrap(W.read(e)):p.None;return new wi(s,o,n)}case"primitive":{let s=W.read(e),o=e.readString(),n=cr[o],a=n.decode(e),l=n.decode(e);return new Ai(s,n,a,l)}case"delete":{let s=A.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new Ei(s,o,n.buffer)}}},t)}})(ga||(ga={}));var bi=class{type="new";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}inverse(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}write(e){e.writeString(this.type),A.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${A.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}toDebugString(e){return this.toString()}},Ai=class{type="primitive";#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}get address(){return this.#e}get oldValue(){return this.#r}get newValue(){return this.#i}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).setValue(this.#r)}forward(e){this.field(e).setValue(this.#i)}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PrimitiveField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),e.writeString(this.#t.type),this.#t.encode(e,this.#r),this.#t.encode(e,this.#i)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#i}`}},wi=class{type="pointer";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get address(){return this.#e}get oldAddress(){return this.#t}get newAddress(){return this.#r}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).targetAddress=this.#t}forward(e){this.field(e).targetAddress=this.#r}field(e){return e.findVertex(this.#e).unwrap(()=>`Could not find PointerField at ${this.#e}`)}write(e){e.writeString(this.type),this.#e.write(e),this.#t.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}}),this.#r.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toString(){return`{PointerUpdate oldValue: ${this.#t.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},Ei=class{type="delete";#e;#t;#r;constructor(e,t,r){this.#e=e,this.#t=t,this.#r=r}get uuid(){return this.#e}get name(){return this.#t}get settings(){return this.#r}forward(e){e.findBox(this.#e).unwrap(()=>`Could not find ${this.#t}`).unstage()}inverse(e){e.createBox(this.#t,this.#e,t=>t.read(new ge(this.#r)))}write(e){e.writeString(this.type),A.toDataOutput(e,this.#e),e.writeString(this.#t),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${A.toString(this.#e)}, attachment: ${this.settings.byteLength}b`}};var bp=Symbol("Unreferenceable"),E=class i extends I{static create(e,t,r){return new i(e,t,r)}static encodeWith(e,t){v(this.#e.isEmpty(),"SerializationEncoder already in use"),this.#e=p.wrap(e);let r=rr(t);if(this.#e=p.None,r.status==="failure")throw r.error;return r.value}static decodeWith(e,t){v(this.#t.isEmpty(),"SerializationDecoder already in use"),this.#t=p.wrap(e);let r=rr(t);if(this.#t=p.None,r.status==="failure")throw r.error;return r.value}static#e=p.None;static#t=p.None;#r;#i;#s=p.None;#o=p.None;constructor(e,t,r){super(e),this.#r=t,this.#i=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return g(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#i}accept(e){return x(e.visitPointerField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(Q.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.graph.subscribeVertexUpdates(Q.This,this.address,()=>this.graph.subscribeEndTransaction(()=>e(this)))}refer(e){this.targetVertex=p.wrap(e)}defer(){this.targetVertex=p.None}get targetVertex(){return this.graph.inTransaction()?this.#o.flatMap(e=>this.graph.findVertex(e)):this.#s}set targetVertex(e){if(e.nonEmpty()){let t=Ze.validate(this,e.unwrap());t.nonEmpty()&&g(t.unwrap())}this.targetAddress=e.map(t=>t.address)}get targetAddress(){return this.#o}set targetAddress(e){let t=this.#o;t.isEmpty()&&e.isEmpty()||(e.nonEmpty()&&t.unwrapOrNull()?.equals(e.unwrap()))===!0||(this.#o=e,this.graph.onPointerAddressUpdated(this,t,e))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(e){this.#s=e}read(e){let t=e.readBoolean()?p.wrap(W.read(e)):p.None;this.targetAddress=i.#t.match({none:()=>t,some:r=>r.map(this,t)})}write(e){i.#e.match({none:()=>this.#o,some:t=>t.map(this)}).match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toJSON(){return i.#e.match({none:()=>this.#o,some:e=>e.map(this)}).match({none:()=>null,some:e=>e.toString()})}fromJSON(e){if(Zt(e)||typeof e=="string"){let t=p.wrap(Zt(e)?null:W.decode(e));this.targetAddress=i.#t.match({none:()=>t,some:r=>r.map(this,t)})}else return g(`Pointer: Type mismatch. value (${typeof e}) must be a string.`)}};var Zi=class{#e;#t;#r;#i;constructor(){this.#e=W.newSet(e=>e.address),this.#t=W.newSet(e=>e.address),this.#r=W.newSet(([e])=>e),this.#i=W.newSet(([e])=>e.address)}watchVertex(e){if(ae(e,E)){if(!e.mandatory)return g("watchVertex called but has no edge requirement");this.#e.add(e)}else{if(!e.pointerRules.mandatory)return g("watchVertex called but has no edge requirement");this.#t.add(e)}}unwatchVerticesOf(...e){let t=({box:{address:{uuid:r}}})=>r;for(let{address:{uuid:r}}of e)this.#o(this.#e,r,t),this.#o(this.#t,r,t);for(let r of e){let s=this.outgoingEdgesOf(r);if(s.length>0)return g(`${r} has outgoing edges: ${s.map(([n,a])=>`[${n.toString()}, ${a.toString()}]`)}`);let o=this.incomingEdgesOf(r);if(o.length>0)return g(`${r} has incoming edges from: ${o.map(n=>n.toString())}`)}}connect(e,t){this.#i.add([e,t]),this.#r.opt(t).match({none:()=>this.#r.add([t,[e]]),some:([,r])=>r.push(e)})}disconnect(e){let[,t]=this.#i.removeByKey(e.address),[,r]=this.#r.get(t);w.remove(r,e),r.length===0&&this.#r.removeByKey(t)}outgoingEdgesOf(e){return this.#s(this.#i,e.address.uuid,([{box:{address:{uuid:t}}}])=>t)}incomingEdgesOf(e){return e.isBox()?this.#s(this.#r,e.address.uuid,([{uuid:t}])=>t).flatMap(([t,r])=>r):this.#r.opt(e.address).mapOr(([t,r])=>r,w.empty())}validateRequirements(){this.#e.forEach(e=>{if(v(e.isAttached(),`Pointer ${e.address.toString()} is not attached`),e.isEmpty())return e.mandatory?g(`Pointer ${e.toString()} requires an edge.`):g(`Illegal state: ${e} has no edge requirements.`)}),this.#t.forEach(e=>{if(v(e.isAttached(),`Target ${e.address.toString()} is not attached`),e.pointerHub.isEmpty())return e.pointerRules.mandatory?g(`Target ${e.toString()} requires an edge.`):g(`Illegal state: ${e} has no edge requirements.`)})}#s(e,t,r){let s=W.boxRange(e,t,r);return T(s)?e.values().slice(s[0],s[1]):w.empty()}#o(e,t,r){let s=W.boxRange(e,t,r);T(s)&&e.removeRange(s[0],s[1])}};var es=class{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=!1;#c=!1;constructor(e=p.None){this.#e=e,this.#t=A.newSet(t=>t.address.uuid),this.#r=[],this.#n=Ji.create(),this.#i=new ve,this.#s=new ve,this.#o=new ve,this.#a=new Zi,this.#l=[]}beginTransaction(){v(!this.#u,"Transaction already in progress"),this.#u=!0,this.#o.proxy.onBeginTransaction()}endTransaction(){for(v(this.#u,"No transaction in progress"),this.#u=!1,this.#r.length>0&&(this.#r.forEach(({pointerField:e,update:t})=>this.#h(e,t)),this.#r.length=0);this.#l.length>0;)this.#l.splice(0).forEach(e=>e()),this.#l.length>0&&console.debug(`${this.#l.length} new observers while notifying`);this.#o.proxy.onEndTransaction()}inTransaction(){return this.#u}constructingBox(){return this.#c}createBox(e,t,r){return this.#e.unwrap("No box-factory installed")(e,this,t,r)}stageBox(e,t){this.#d(),v(!this.#c,"Cannot construct box while other box is constructing"),T(t)&&(this.#c=!0,t(e),this.#c=!1);let r=this.#t.add(e);v(r,`${e} already staged`);let s=new bi(e.address.uuid,e.name,e.toArrayBuffer());return this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s),e}subscribeTransaction(e){return this.#o.subscribe(e)}subscribeToAllUpdates(e){return this.#i.subscribe(e)}subscribeToAllUpdatesImmediate(e){return this.#s.subscribe(e)}subscribeVertexUpdates(e,t,r){return this.#n.subscribe(e,t,r)}subscribeEndTransaction(e){this.#l.push(e)}unstageBox(e){this.#d();let t=this.#t.removeByKey(e.address.uuid);v(t===e,`${e} could not be found to unstage`),this.#a.unwatchVerticesOf(e);let r=new Ei(e.address.uuid,e.name,e.toArrayBuffer());this.#i.proxy.onUpdate(r),this.#s.proxy.onUpdate(r)}findBox(e){return this.#t.opt(e)}findVertex(e){return this.#t.opt(e.uuid).flatMap(t=>t.searchVertex(e.fieldKeys))}boxes(){return this.#t.values()}edges(){return this.#a}checksum(){let e=new Oi;return this.boxes().forEach(t=>t.write(e)),e.result()}onPrimitiveValueUpdate(e,t,r){if(this.#d(),e.isAttached()&&!this.#c){let s=new Ai(e.address,e.serialization(),t,r);this.#n.dispatch(s),this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s)}}onPointerAddressUpdated(e,t,r){this.#d(),t.nonEmpty()&&this.#a.disconnect(e),r.nonEmpty()&&this.#a.connect(e,r.unwrap());let s=new wi(e.address,t,r);this.#c?this.#r.push({pointerField:e,update:s}):(this.#h(e,s),this.#s.proxy.onUpdate(s))}#h(e,t){let{oldAddress:r,newAddress:s}=t,o=r.flatMap(a=>this.findVertex(a)),n=s.flatMap(a=>this.findVertex(a));e.resolvedTo(n),o.equals(n)||(o.ifSome(a=>a.pointerHub.onRemoved(e)),n.ifSome(a=>a.pointerHub.onAdded(e))),this.#n.dispatch(t),this.#i.proxy.onUpdate(t)}dependenciesOf(e){let t=new Set,r=new Set,s=o=>{t.has(o)||(t.add(o),o.outgoingEdges().filter(([n])=>!r.has(n)).forEach(([n,a])=>{let l=this.findVertex(a).unwrap(`Could not find target of ${n.toString()}`);if(r.add(n),l.pointerRules.mandatory&&l.pointerHub.incoming().every(c=>r.has(c)))return s(l.box)}),o.incomingEdges().forEach(n=>{r.add(n),n.mandatory&&s(n.box)}))};return s(e),t.delete(e),{boxes:t,pointers:Array.from(r).reverse()}}verifyPointers(){this.#a.validateRequirements();let e=0,t=r=>{for(let s of r.fields())s.accept({visitPointerField:o=>{if(o.targetAddress.nonEmpty()){let n=o.targetVertex.nonEmpty(),a=this.findVertex(o.targetAddress.unwrap()).nonEmpty();v(n,`pointer ${o.address} is broken`),v(a,`Cannot find target for pointer ${o.address}`),e++}},visitObjectField:o=>t(o)})};return this.#t.forEach(r=>t(r)),console.debug("verification complete."),{count:e}}debugBoxes(){console.table(this.#t.values().reduce((e,t)=>(e[A.toString(t.address.uuid)]={class:t.name,"incoming links":t.incomingEdges().length,"outgoing links":t.outgoingEdges().length,"est. memory (bytes)":t.estimateMemory()},e),{}))}debugDependencies(){console.debug("Dependencies:"),this.boxes().forEach(e=>{console.debug(` ${e}`);for(let t of this.dependenciesOf(e).boxes)console.debug(` ${t}`)})}addressToDebugPath(e){return e.flatMap(t=>t.isBox()?this.findBox(t.uuid).map(r=>r.name):this.findBox(t.uuid).flatMap(r=>r.searchVertex(t.fieldKeys).map(s=>s.isField()?s.debugPath:g("Unknown address"))))}toArrayBuffer(){let e=de.create(),t=this.#t.values();return e.writeInt(t.length),t.forEach(r=>{let s=r.serialize();e.writeInt(s.byteLength),e.writeBytes(new Int8Array(s))}),e.toArrayBuffer()}fromArrayBuffer(e){v(this.#t.isEmpty(),"Cannot call fromArrayBuffer if boxes is not empty");let t=new ge(e),r=t.readInt();this.beginTransaction();let s=[];for(let o=0;o<r;o++){let n=t.readInt(),a=new Int8Array(n);t.readBytes(a);let l=new ge(a.buffer),c=l.readInt(),d=l.readString(),m=A.fromDataInput(l);s.push({creationIndex:c,name:d,uuid:m,boxStream:l})}s.sort((o,n)=>o.creationIndex-n.creationIndex).forEach(({name:o,uuid:n,boxStream:a})=>this.createBox(o,n,l=>l.read(a))),this.endTransaction()}toJSON(){return this.#t.values().map(e=>({name:e.name,uuid:e.address.toString(),fields:k(e.toJSON())}))}#d(){v(this.#u,()=>"Modification only prohibited in transaction mode.")}};var xa;(function(i){i.insertOrder=(e,t=Number.MAX_SAFE_INTEGER)=>{let r=i.collectIndexedBoxes(e),s=$(t,0,r.length);if(s<r.length)for(let o=s;o<r.length;o++)r[o].index.setValue(o+1);return s},i.removeOrder=(e,t)=>{let r=i.collectIndexedBoxes(e);if(t<r.length)for(let s=t+1;s<r.length;s++)r[s].index.setValue(s-1)},i.moveIndex=(e,t,r)=>{let s=i.collectIndexedBoxes(e),o=s[t];if(r<0){let n=$(t+r,0,s.length-1);for(let a=n;a<t;a++)s[a].index.setValue(a+1);o.index.setValue(n)}else if(r>1){let n=$(t+(r-1),0,s.length-1);for(let a=t;a<n;a++)s[a+1].index.setValue(a);o.index.setValue(n)}else console.warn(`moveIndex had no effect: startIndex: ${t}, delta: ${r}`)},i.isIndexedBox=e=>"index"in e&&e.index instanceof b,i.collectIndexedBoxes=(e,t)=>e.pointerHub.incoming().map(({box:r})=>i.isIndexedBox(r)&&(t===void 0||r instanceof t)?r:g(`${r} has no index field`)).sort((r,s)=>r.index.getValue()-s.index.getValue())})(xa||(xa={}));var ue=class extends I{#e;constructor(e){super(e),this.#e=this.initializeFields()}accept(e){return x(e.visitObjectField,this)}fields(){return Object.values(this.#e)}record(){return this.#e}getField(e){return k(this.#e[e])}optField(e){return p.wrap(this.#e[e])}read(e){Ct.readFields(e,this.#e)}write(e){Ct.writeFields(e,this.#e)}toJSON(){return Object.entries(this.#e).reduce((e,[t,r])=>(e[t]=r.toJSON(),e),{})}fromJSON(e){if(vt(e))Object.entries(e).forEach(([t,r])=>{let s=this.#e[parseInt(t)];T(r)&&s.fromJSON(r)});else return g("Type mismatch")}};var Te;(function(i){i.sender=(r,s)=>s(new e(r)),i.executor=(r,s)=>new t(r,s);class e{#e;#t=new Map;#r;#i=0;constructor(s){this.#e=s,this.#r=s.subscribe(this.#s)}terminate(){this.#r.terminate()}dispatchAndForget=(s,...o)=>this.#e.send({type:"send",returnId:!1,func:s.name,args:Array.from(le.map(o,n=>({value:n})))});dispatchAndReturn=(s,...o)=>new Promise((n,a)=>{let l=le.reduce(o,(c,d,m)=>(typeof d=="function"&&c.push([m,d]),c),[]);this.#t.set(this.#i,{executorTuple:{resolve:n,reject:a},callbacks:new Map(l)}),this.#e.send({type:"send",returnId:this.#i,func:s.name,args:Array.from(le.map(o,(c,d)=>typeof c=="function"?{callback:d}:{value:c}))}),this.#i++});#s=s=>{let o=this.#t.get(s.returnId);T(o)?s.type==="resolve"?(o.executorTuple.resolve(s.resolve),this.#t.delete(s.returnId)):s.type==="reject"?(o.executorTuple.reject(s.reject),this.#t.delete(s.returnId)):s.type==="callback"&&o.callbacks?.get(s.funcAt).apply(this,s.args):g(`Promise has already been resolved. ${JSON.stringify(s)}`)}}class t{#e;#t;#r;constructor(s,o){this.#e=s,this.#t=o,this.#r=s.subscribe(this.#i)}terminate(){this.#r.terminate()}#i=s=>{v(s.type==="send",()=>"Message type must be 'send'");let o=Object.getPrototypeOf(this.#t)===Object.getPrototypeOf({})?this.#t:Object.getPrototypeOf(this.#t),n=k(o[s.func],`${s.func.toString()} does not exists on ${this.#t}`),a=s.returnId;if(a===!1)n.apply(this.#t,s.args.map(l=>"value"in l?l.value:g(`${s.func.toString()} has no promise.`)));else try{n.apply(this.#t,s.args.map(c=>"callback"in c?(...d)=>this.#n(a,c.callback,d):c.value)).then(c=>this.#s(a,c),c=>this.#o(a,c))}catch(l){this.#o(a,l)}};#s=(s,o)=>this.#e.send({type:"resolve",returnId:s,resolve:o});#o=(s,o)=>this.#e.send({type:"reject",returnId:s,reject:o});#n=(s,o,n)=>this.#e.send({type:"callback",returnId:s,funcAt:o,args:n})}i.Executor=t})(Te||(Te={}));var ya;(function(i){i.ProgressArrayBuffer=e=>async t=>{if(!t.headers.has("Content-Length"))return console.debug("No Content-Length"),t.arrayBuffer();let r=parseInt(t.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return t.arrayBuffer();e(0);let s=de.create(r),o=k(t.body,"response.body is empty").getReader();for(;;){let{done:n,value:a}=await o.read();if(n)break;a.forEach(l=>s.writeByte(l)),e(s.position/r)}return e(1),s.toArrayBuffer()}})(ya||(ya={}));var va;(function(i){i.debounce=(()=>{let e;return(t,r=1e3)=>{clearTimeout(e),e=setTimeout(t,r)}})(),i.scheduleInterval=(e,t,...r)=>{let s=setInterval(e,t,...r);return{terminate:()=>clearInterval(s)}},i.scheduleTimeout=(e,t,...r)=>{let s=setTimeout(e,t,...r);return{terminate:()=>clearTimeout(s)}}})(va||(va={}));var ba={for:i=>new bn(i)},bn=class{#e;#t=new q;constructor(e){if(this.#e=e,T(e.onmessage)||T(e.onmessageerror))throw console.error(e),new Error(`${e} is already wrapped.`);e.onmessage=t=>this.#t.notify(t.data),e.onmessageerror=t=>{throw new Error(t.type)}}send(e){this.#e.postMessage(e)}channel(e){return new An(this,e)}subscribe(e){return this.#t.subscribe(e)}terminate(){this.#t.terminate(),this.#e.onmessage=null,this.#e.onmessageerror=null}},An=class i{#e;#t;#r=new q;#i;constructor(e,t){this.#e=e,this.#t=t,this.#i=e.subscribe(r=>{"__id__"in r&&r.__id__==="42"&&"message"in r&&"channel"in r&&r.channel===t&&this.#r.notify(r.message)})}send(e){this.#e.send({__id__:"42",channel:this.#t,message:e})}channel(e){return new i(this,e)}subscribe(e){return this.#r.subscribe(e)}terminate(){this.#i.terminate(),this.#r.terminate()}};var ts;(function(i){i.frame=()=>new Promise(e=>requestAnimationFrame(()=>e())),i.frames=e=>new Promise(t=>{let r=e,s=()=>{--r<=0?t():requestAnimationFrame(s)};requestAnimationFrame(s)}),i.timeSpan=(e,...t)=>new Promise(r=>setTimeout(r,e.millis(),...t)),i.event=(e,t)=>new Promise(r=>e.addEventListener(t,r,{once:!0})),i.observable=e=>new Promise(t=>{let r=e.subscribe(()=>{r.terminate(),t()})}),i.complete=e=>new Promise((t,r)=>{let s=setInterval(()=>{let{status:o,value:n,error:a}=rr(()=>e.next());if(o==="success"){let{done:l,value:c}=n;l&&(clearInterval(s),t(c))}else clearInterval(s),r(a)},0)})})(ts||(ts={}));var wn=class{maxRetry;timeSpan;#e=0;constructor(e,t){this.maxRetry=e,this.timeSpan=t}retry(e,t){return++this.#e===this.maxRetry?!1:(console.debug(`${e} > will retry in ${this.timeSpan.toString()}`),setTimeout(t,this.timeSpan.millis()),!0)}},Rt;(function(i){class e{value;status="resolved";constructor(a){this.value=a}error=on("Cannot access error when promise is resolved")}i.ResolveResult=e;class t{error;status="rejected";constructor(a){this.error=a}value=on("Cannot access value when promise is rejected")}i.RejectedResult=t,i.makeAbortable=async(n,a)=>{let l=!0;return n.own(U.create(()=>l=!1)),new Promise((c,d)=>a.then(m=>{l&&c(m)},m=>{l&&d(m)}))},i.tryCatch=n=>n.then(a=>new e(a),a=>new t(a));let r=new wn(3,Et.seconds(3));i.retry=(n,a=r)=>n().catch(l=>new Promise((c,d)=>{let m=f=>{a.retry(f,()=>n().then(y=>c(y),m))||d(f)};m(l)})),i.guardedRetry=(n,a)=>{let l=async(c=0)=>{try{return await n()}catch(d){if(a(d,++c))return await ts.timeSpan(Et.seconds(1)),l(c);throw d}};return l()},i.approvedRetry=(n,a)=>{let l=async()=>{try{return await n()}catch(c){if(await sa.approve(a(c)))return l();throw c}};return l()},i.fail=(n,a)=>{let l=()=>new Promise((c,d)=>setTimeout(()=>d("fails first"),n.millis()));return()=>{let c=l();return l=a,c}},i.timeout=(n,a,l)=>new Promise((c,d)=>{let m=!0,f=setTimeout(()=>{m=!1,d(new Error(l??"timeout"))},a.millis());n.then(y=>{m&&c(y)},y=>{m&&d(y)}).finally(()=>clearTimeout(f))}),i.sequentialAll=n=>n.reduce((a,l)=>a.then(async c=>[...c,await l()]),Promise.resolve([])),i.sequentialize=n=>{let a=Promise.resolve();return l=>{let c=()=>n(l),d=a.then(c,c);return a=d.catch(()=>{}),d}},i.memoizeAsync=(n,a)=>{let l=null,c=Date.now();return()=>{let d=Date.now();return(Zt(l)||T(a)&&d-c>a.millis())&&(c=d,l=n(),l.catch(m=>(l=null,m))),l}},i.allWithLimit=async(n,a=1)=>{let l=new Array(n.length),c=0,d=!1,m=async()=>{for(;c<n.length&&!d;){let f=c++;try{let y=await n[f]();d||(l[f]=y)}catch(y){throw d=!0,y}}};return await Promise.all(Array.from({length:Math.min(a,n.length)},m)),l},i.allSettledWithLimit=async(n,a=1)=>{let l=new Array(n.length),c=0,d=async()=>{for(;c<n.length;){let m=c++;try{let f=await n[m]();l[m]={status:"fulfilled",value:f}}catch(f){l[m]={status:"rejected",reason:f}}}};return await Promise.all(Array.from({length:Math.min(a,n.length)},d)),l};class s{max;#e;#t=0;constructor(a=1){this.max=a,this.#e=[]}async add(a){if(this.#t<this.max)return this.#t++,a().finally(()=>this.#r());{let l=Promise.withResolvers();return this.#e.push([a,l]),l.promise.finally(()=>this.#r())}}#r(){if(v(this.#t>0,"Internal Error in Promises.Limit"),--this.#t<this.max&&this.#e.length>0){let[a,{resolve:l,reject:c}]=this.#e.shift();this.#t++,a().then(l,c)}}}i.Limit=s;class o{#e;#t;#r;#i=p.None;constructor(a,l,c){this.#e=a,this.#t=l,this.#r=c}update(a){this.#i=p.wrap(a),a.then(l=>{this.#i.contains(a)&&this.#e(l)}).catch(l=>{this.#i.contains(a)&&this.#t(l)}).finally(()=>{this.#i.contains(a)&&(this.terminate(),x(this.#r))})}terminate(){this.#i=p.None}}i.Latest=o})(Rt||(Rt={}));var Aa;(function(i){let e=new Rt.Limit(4);i.limitFetch=(t,r)=>e.add(()=>fetch(t,r)),i.DefaultRetry=(t,r)=>!ae(t,Li.FileNotFound)||r<=100})(Aa||(Aa={}));var wa=(i="debug")=>{let e=performance.now();return{lab:t=>console[i].call(console,`${t} in ${(performance.now()-e).toFixed(1)}ms`)}};var Ea;(function(i){i.startEstimator=()=>{let e=performance.now();return t=>{if(t===0)return Et.POSITIVE_INFINITY;let r=performance.now()-e;return Et.millis(r/t-r)}}})(Ea||(Ea={}));var rs=Symbol.for("@openDAW/lib-runtime");globalThis[rs]?console.debug(`%c${rs.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[rs]=!0,console.debug(`%c${rs.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Ba=(i,e)=>Te.executor(e,new class{sendUpdates(t){i.beginTransaction(),t.forEach(r=>{let s=r.type;s==="new"?i.createBox(r.name,r.uuid,o=>o.read(new ge(r.buffer))):s==="update-primitive"?i.findVertex(W.reconstruct(r.address)).unwrap(()=>`Could not find primitive field ${r.address}`).setValue(r.value):s==="update-pointer"?i.findVertex(W.reconstruct(r.address)).unwrap(()=>`Could not find pointer field ${r.address}`).targetAddress=T(r.target)?p.wrap(W.reconstruct(r.target)):p.None:r.type==="delete"&&i.unstageBox(i.findBox(r.uuid).unwrap(()=>`Could not find box ${A.toString(r.uuid)}`))}),i.endTransaction()}checksum(t){return w.equals(i.checksum(),t)?Promise.resolve():Promise.reject("Checksum mismatch")}});var is=Symbol.for("@openDAW/lib-box");globalThis[is]?console.debug(`%c${is.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[is]=!0,console.debug(`%c${is.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var ss=class{#e=0;#t=!1;#r=!1;isRecording=!1;isCountingIn=!1;metronomeEnabled=!1;getLeapStateAndReset(){let e=this.#r;return this.#r=!1,e}get position(){return this.#e}set position(e){this.#e=e,this.#r=!0}get transporting(){return this.#t}set transporting(e){this.#t!==e&&(this.#t=e)}pause(){this.#t=!1,this.isRecording=!1,this.isCountingIn=!1}advanceTo(e){this.#e=e}};var u;(function(i){i[i.Timeline=0]="Timeline",i[i.Selection=1]="Selection",i[i.PianoMode=2]="PianoMode",i[i.User=3]="User",i[i.AudioConnection=4]="AudioConnection",i[i.InstrumentHost=5]="InstrumentHost",i[i.AudioOutput=6]="AudioOutput",i[i.Capture=7]="Capture",i[i.NotesConnection=8]="NotesConnection",i[i.VoltageConnection=9]="VoltageConnection",i[i.AudioUnits=10]="AudioUnits",i[i.MidiEffectHost=11]="MidiEffectHost",i[i.AudioEffectHost=12]="AudioEffectHost",i[i.AudioBusses=13]="AudioBusses",i[i.AuxSend=14]="AuxSend",i[i.Modulation=15]="Modulation",i[i.Automation=16]="Automation",i[i.ParameterController=17]="ParameterController",i[i.MidiControl=18]="MidiControl",i[i.StepAutomation=19]="StepAutomation",i[i.Editing=20]="Editing",i[i.AudioFile=21]="AudioFile",i[i.AudioUnit=22]="AudioUnit",i[i.MarkerTrack=23]="MarkerTrack",i[i.MarkerEvents=24]="MarkerEvents",i[i.ClipCollection=25]="ClipCollection",i[i.RegionCollection=26]="RegionCollection",i[i.TrackCollection=27]="TrackCollection",i[i.Device=28]="Device",i[i.Groove=29]="Groove",i[i.ModularSetup=30]="ModularSetup",i[i.ModuleCollection=31]="ModuleCollection",i[i.ConnectionCollection=32]="ConnectionCollection",i[i.DeviceUserInterface=33]="DeviceUserInterface",i[i.NoteEvents=34]="NoteEvents",i[i.NoteEventFeature=35]="NoteEventFeature",i[i.NoteEventCollection=36]="NoteEventCollection",i[i.ValueEvents=37]="ValueEvents",i[i.ValueEventCollection=38]="ValueEventCollection",i[i.ValueInterpolation=39]="ValueInterpolation",i[i.Sample=40]="Sample"})(u||(u={}));var Fa;(function(i){i.NoSync="nosync",i.Pitch="pitch",i.Timestretch="timestretch",i.AudioFit="audiofit"})(Fa||(Fa={}));var Na;(function(i){i[i.Pre=0]="Pre",i[i.Post=1]="Post"})(Na||(Na={}));var hr;(function(i){i.Instrument="instrument",i.Bus="bus",i.Aux="aux",i.Output="output"})(hr||(hr={}));var Pa=(i,e)=>{if(i===e)return 0;let t=i-e;return t===0?g(`Indices cannot be equal (${i}, ${e})`):t};var Be=class i{static create(e,t,r){return new i(e,t,r)}#e;#t;#r;#i;#s=null;constructor(e,t,r){this.#e=e,this.#t=A.newSet(s=>s.adapter.uuid),this.#r=new ve,this.#i=e.pointerHub.catchupAndSubscribeTransactual({onAdd:s=>{this.#s=null;let o=t(s.box),n=o.indexField.subscribe(()=>{this.#s=null,this.#r.proxy.onReorder(o)}),a=this.#t.add({adapter:o,subscription:n});v(a,`Could not add ${o}`),this.#r.proxy.onAdd(o)},onRemove:s=>{this.#s=null;let o=s.box.address.uuid,{adapter:n,subscription:a}=this.#t.removeByKey(o);a.terminate(),this.#r.proxy.onRemove(n)}},r)}field(){return this.#e}subscribe(e){return this.#r.subscribe(e)}catchupAndSubscribe(e){return this.#t.forEach(({adapter:t})=>e.onAdd(t)),this.subscribe(e)}getAdapterByIndex(e){let t=se.exactMapped(this.adapters(),e,Pa,r=>r.indexField.getValue());return t===-1?p.None:p.wrap(this.adapters()[t])}getAdapterById(e){return this.#t.opt(e).map(({adapter:t})=>t)}getMinFreeIndex(){let e=this.adapters();for(let t=0;t<e.length;t++)if(e[t].indexField.getValue()>t)return t;return e.length}adapters(){return this.#s===null&&(this.#s=this.#t.values().map(({adapter:e})=>e).sort((e,t)=>e.indexField.getValue()-t.indexField.getValue())),this.#s}move(e,t){this.moveIndex(e.indexField.getValue(),t)}moveIndex(e,t){let r=this.adapters(),s=r[e];if(t<0){let o=$(e+t,0,r.length-1);for(let n=o;n<e;n++)r[n].indexField.setValue(n+1);s.indexField.setValue(o)}else if(t>1){let o=$(e+(t-1),0,r.length-1);for(let n=e;n<o;n++)r[n+1].indexField.setValue(n);s.indexField.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${t}`)}size(){return this.#t.size()}isEmpty(){return this.size()===0}terminate(){this.#s=null,this.#t.forEach(({subscription:e})=>e.terminate()),this.#t.clear(),this.#r.terminate(),this.#i.terminate()}};var os;(function(i){i.create=(e,t,r,s)=>{switch(e){case"RootBox":return Sr.create(t,r,s);case"SelectionBox":return Bi.create(t,r,s);case"UserInterfaceBox":return ns.create(t,r,s);case"TimelineBox":return as.create(t,r,s);case"TrackBox":return Cr.create(t,r,s);case"NoteEventBox":return Mt.create(t,r,s);case"NoteEventRepeatBox":return ls.create(t,r,s);case"NoteEventCollectionBox":return pt.create(t,r,s);case"NoteRegionBox":return dr.create(t,r,s);case"NoteClipBox":return Rr.create(t,r,s);case"ValueEventBox":return Tt.create(t,r,s);case"ValueEventCollectionBox":return mt.create(t,r,s);case"ValueEventCurveBox":return Vt.create(t,r,s);case"ValueRegionBox":return pr.create(t,r,s);case"ValueClipBox":return Mr.create(t,r,s);case"AudioRegionBox":return Tr.create(t,r,s);case"AudioClipBox":return Vr.create(t,r,s);case"MarkerBox":return Dr.create(t,r,s);case"AudioFileBox":return us.create(t,r,s);case"AudioUnitBox":return Ye.create(t,r,s);case"CaptureAudioBox":return cs.create(t,r,s);case"CaptureMidiBox":return hs.create(t,r,s);case"AudioBusBox":return Ir.create(t,r,s);case"AuxSendBox":return ds.create(t,r,s);case"StepAutomationBox":return ps.create(t,r,s);case"GrooveShuffleBox":return ms.create(t,r,s);case"UnknownAudioEffectDeviceBox":return fs.create(t,r,s);case"UnknownMidiEffectDeviceBox":return gs.create(t,r,s);case"DeviceInterfaceKnobBox":return xs.create(t,r,s);case"ModularDeviceBox":return ys.create(t,r,s);case"DeviceClashBox":return vs.create(t,r,s);case"StereoToolDeviceBox":return bs.create(t,r,s);case"DelayDeviceBox":return As.create(t,r,s);case"RevampDeviceBox":return ws.create(t,r,s);case"ReverbDeviceBox":return Es.create(t,r,s);case"VaporisateurDeviceBox":return Bs.create(t,r,s);case"NanoDeviceBox":return Fs.create(t,r,s);case"PlayfieldDeviceBox":return Ns.create(t,r,s);case"PlayfieldSampleBox":return Or.create(t,r,s);case"TapeDeviceBox":return Ps.create(t,r,s);case"ArpeggioDeviceBox":return Ss.create(t,r,s);case"PitchDeviceBox":return Cs.create(t,r,s);case"ZeitgeistDeviceBox":return Rs.create(t,r,s);case"ModularBox":return Ms.create(t,r,s);case"ModuleConnectionBox":return Ts.create(t,r,s);case"ModularAudioInputBox":return Vs.create(t,r,s);case"ModularAudioOutputBox":return Ds.create(t,r,s);case"ModuleDelayBox":return Is.create(t,r,s);case"ModuleMultiplierBox":return Os.create(t,r,s);case"ModuleGainBox":return ks.create(t,r,s);default:return g(`Unknown box class '${e}'`)}},i.deserialize=(e,t)=>{let r=new ge(t),s=r.readString(),o=A.fromDataInput(r),n=i.create(s,e,o);return n.read(r),n}})(os||(os={}));var Us=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get keyboard(){return this.getField(1)}get timeRangeInQuarters(){return this.getField(2)}get noteScale(){return this.getField(3)}get noteLabels(){return this.getField(4)}get transpose(){return this.getField(5)}initializeFields(){return{1:b.create({parent:this,fieldKey:1,fieldName:"keyboard",pointerRules:h},0),2:B.create({parent:this,fieldKey:2,fieldName:"timeRangeInQuarters",pointerRules:h},8),3:B.create({parent:this,fieldKey:3,fieldName:"noteScale",pointerRules:h},1.5),4:N.create({parent:this,fieldKey:4,fieldName:"noteLabels",pointerRules:h},!0),5:b.create({parent:this,fieldKey:5,fieldName:"transpose",pointerRules:h},0)}}};var Sr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RootBox",pointerRules:h}),r)}static ClassName="RootBox";constructor(e){super(e)}accept(e){return x(e.visitRootBox,this)}get timeline(){return this.getField(1)}get users(){return this.getField(2)}get created(){return this.getField(3)}get groove(){return this.getField(4)}get modularSetups(){return this.getField(10)}get audioUnits(){return this.getField(20)}get audioBusses(){return this.getField(21)}get outputDevice(){return this.getField(30)}get pianoMode(){return this.getField(40)}get editingChannel(){return this.getField(111)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"timeline",pointerRules:h},u.Timeline,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"users",pointerRules:{accepts:[u.User],mandatory:!0}}),3:V.create({parent:this,fieldKey:3,fieldName:"created",pointerRules:h}),4:E.create({parent:this,fieldKey:4,fieldName:"groove",pointerRules:h},u.Groove,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"modularSetups",pointerRules:{accepts:[u.ModularSetup],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"audioUnits",pointerRules:{accepts:[u.AudioUnits],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"audioBusses",pointerRules:{accepts:[u.AudioBusses],mandatory:!1}}),30:I.hook({parent:this,fieldKey:30,fieldName:"outputDevice",pointerRules:{accepts:[u.AudioOutput],mandatory:!0}}),40:Us.create({parent:this,fieldKey:40,fieldName:"pianoMode",pointerRules:h}),111:E.create({parent:this,fieldKey:111,fieldName:"editingChannel",pointerRules:h},u.Editing,!1)}}};var Bi=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SelectionBox",pointerRules:h}),r)}static ClassName="SelectionBox";constructor(e){super(e)}accept(e){return x(e.visitSelectionBox,this)}get selection(){return this.getField(1)}get selectable(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"selection",pointerRules:h},u.Selection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"selectable",pointerRules:h},u.Selection,!0)}}};var ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UserInterfaceBox",pointerRules:h}),r)}static ClassName="UserInterfaceBox";constructor(e){super(e)}accept(e){return x(e.visitUserInterfaceBox,this)}get root(){return this.getField(1)}get selection(){return this.getField(10)}get editingDeviceChain(){return this.getField(21)}get editingTimelineRegion(){return this.getField(22)}get editingModularSystem(){return this.getField(23)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"root",pointerRules:h},u.User,!0),10:I.hook({parent:this,fieldKey:10,fieldName:"selection",pointerRules:{accepts:[u.Selection],mandatory:!1}}),21:E.create({parent:this,fieldKey:21,fieldName:"editingDeviceChain",pointerRules:h},u.Editing,!1),22:E.create({parent:this,fieldKey:22,fieldName:"editingTimelineRegion",pointerRules:h},u.Editing,!1),23:E.create({parent:this,fieldKey:23,fieldName:"editingModularSystem",pointerRules:h},u.Editing,!1)}}};var Ks=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get nominator(){return this.getField(1)}get denominator(){return this.getField(2)}initializeFields(){return{1:b.create({parent:this,fieldKey:1,fieldName:"nominator",pointerRules:h},4),2:b.create({parent:this,fieldKey:2,fieldName:"denominator",pointerRules:h},4)}}};var Ls=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get from(){return this.getField(2)}get to(){return this.getField(3)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:h},!0),2:b.create({parent:this,fieldKey:2,fieldName:"from",pointerRules:h},0),3:b.create({parent:this,fieldKey:3,fieldName:"to",pointerRules:h},15360)}}};var $s=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get markers(){return this.getField(1)}get index(){return this.getField(10)}get enabled(){return this.getField(20)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"markers",pointerRules:{accepts:[u.MarkerTrack],mandatory:!1}}),10:b.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:h}),20:N.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:h},!0)}}};var as=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TimelineBox",pointerRules:h}),r)}static ClassName="TimelineBox";constructor(e){super(e)}accept(e){return x(e.visitTimelineBox,this)}get root(){return this.getField(1)}get signature(){return this.getField(10)}get loopArea(){return this.getField(11)}get deprecatedMarkerTrack(){return this.getField(20)}get markerTrack(){return this.getField(21)}get durationInPulses(){return this.getField(30)}get bpm(){return this.getField(31)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"root",pointerRules:{accepts:[u.Timeline],mandatory:!0}}),10:Ks.create({parent:this,fieldKey:10,fieldName:"signature",pointerRules:h}),11:Ls.create({parent:this,fieldKey:11,fieldName:"loopArea",pointerRules:h}),20:I.hook({parent:this,fieldKey:20,fieldName:"deprecatedMarkerTrack",pointerRules:{accepts:[u.MarkerTrack],mandatory:!1}}),21:$s.create({parent:this,fieldKey:21,fieldName:"markerTrack",pointerRules:h}),30:b.create({parent:this,fieldKey:30,fieldName:"durationInPulses",pointerRules:h},491520),31:B.create({parent:this,fieldKey:31,fieldName:"bpm",pointerRules:h},120)}}};var Cr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TrackBox",pointerRules:{accepts:[u.Selection,u.PianoMode],mandatory:!1}}),r)}static ClassName="TrackBox";constructor(e){super(e)}accept(e){return x(e.visitTrackBox,this)}get tracks(){return this.getField(1)}get target(){return this.getField(2)}get regions(){return this.getField(3)}get clips(){return this.getField(4)}get index(){return this.getField(10)}get type(){return this.getField(11)}get enabled(){return this.getField(20)}get excludePianoMode(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"tracks",pointerRules:h},u.TrackCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"target",pointerRules:h},u.Automation,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"regions",pointerRules:{accepts:[u.RegionCollection],mandatory:!1}}),4:I.hook({parent:this,fieldKey:4,fieldName:"clips",pointerRules:{accepts:[u.ClipCollection],mandatory:!1}}),10:b.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"type",pointerRules:h}),20:N.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:h},!0),30:N.create({parent:this,fieldKey:30,fieldName:"excludePianoMode",pointerRules:h},!1)}}};var Mt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventBox",pointerRules:{accepts:[u.Selection,u.NoteEventFeature],mandatory:!1}}),r)}static ClassName="NoteEventBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get pitch(){return this.getField(20)}get velocity(){return this.getField(21)}get playCount(){return this.getField(22)}get playCurve(){return this.getField(23)}get cent(){return this.getField(24)}get chance(){return this.getField(25)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:h},u.NoteEvents,!0),10:b.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h},240),20:b.create({parent:this,fieldKey:20,fieldName:"pitch",pointerRules:h},60),21:B.create({parent:this,fieldKey:21,fieldName:"velocity",pointerRules:h},.7874015748031497),22:b.create({parent:this,fieldKey:22,fieldName:"playCount",pointerRules:h},1),23:B.create({parent:this,fieldKey:23,fieldName:"playCurve",pointerRules:h},0),24:B.create({parent:this,fieldKey:24,fieldName:"cent",pointerRules:h},0),25:b.create({parent:this,fieldKey:25,fieldName:"chance",pointerRules:h},100)}}};var ls=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventRepeatBox",pointerRules:h}),r)}static ClassName="NoteEventRepeatBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventRepeatBox,this)}get event(){return this.getField(1)}get count(){return this.getField(2)}get curve(){return this.getField(3)}get length(){return this.getField(4)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:h},u.NoteEventFeature,!0),2:b.create({parent:this,fieldKey:2,fieldName:"count",pointerRules:h},1),3:B.create({parent:this,fieldKey:3,fieldName:"curve",pointerRules:h},0),4:B.create({parent:this,fieldKey:4,fieldName:"length",pointerRules:h},1)}}};var pt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventCollectionBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="NoteEventCollectionBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[u.NoteEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[u.NoteEventCollection],mandatory:!0}})}}};var dr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="NoteRegionBox";constructor(e){super(e)}accept(e){return x(e.visitNoteRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get eventOffset(){return this.getField(14)}get mute(){return this.getField(15)}get label(){return this.getField(16)}get hue(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.NoteEventCollection,!0),10:b.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:b.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:b.create({parent:this,fieldKey:14,fieldName:"eventOffset",pointerRules:h}),15:N.create({parent:this,fieldKey:15,fieldName:"mute",pointerRules:h}),16:V.create({parent:this,fieldKey:16,fieldName:"label",pointerRules:h}),17:b.create({parent:this,fieldKey:17,fieldName:"hue",pointerRules:h})}}};var Dt=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get loop(){return this.getField(1)}get reverse(){return this.getField(2)}get mute(){return this.getField(3)}get speed(){return this.getField(4)}get quantise(){return this.getField(5)}get trigger(){return this.getField(6)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"loop",pointerRules:h},!0),2:N.create({parent:this,fieldKey:2,fieldName:"reverse",pointerRules:h}),3:N.create({parent:this,fieldKey:3,fieldName:"mute",pointerRules:h}),4:b.create({parent:this,fieldKey:4,fieldName:"speed",pointerRules:h}),5:b.create({parent:this,fieldKey:5,fieldName:"quantise",pointerRules:h}),6:b.create({parent:this,fieldKey:6,fieldName:"trigger",pointerRules:h})}}};var Rr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="NoteClipBox";constructor(e){super(e)}accept(e){return x(e.visitNoteClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.NoteEventCollection,!0),3:b.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Dt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:b.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:V.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h})}}};var Tt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ValueEventBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get index(){return this.getField(11)}get interpolation(){return this.getField(12)}get value(){return this.getField(13)}get slope(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:h},u.ValueEvents,!0),10:b.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:h}),12:b.create({parent:this,fieldKey:12,fieldName:"interpolation",pointerRules:{accepts:[u.ValueInterpolation],mandatory:!1}},1),13:B.create({parent:this,fieldKey:13,fieldName:"value",pointerRules:h}),14:B.create({parent:this,fieldKey:14,fieldName:"slope",pointerRules:h})}}};var mt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCollectionBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ValueEventCollectionBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[u.ValueEvents],mandatory:!1}}),2:I.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[u.ValueEventCollection],mandatory:!0}})}}};var Vt=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCurveBox",pointerRules:h}),r)}static ClassName="ValueEventCurveBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventCurveBox,this)}get event(){return this.getField(1)}get slope(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:h},u.ValueInterpolation,!0),2:B.create({parent:this,fieldKey:2,fieldName:"slope",pointerRules:h},.5)}}};var pr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="ValueRegionBox";constructor(e){super(e)}accept(e){return x(e.visitValueRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.ValueEventCollection,!0),10:b.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:b.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:h}),15:V.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:h}),16:b.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:h})}}};var Mr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="ValueClipBox";constructor(e){super(e)}accept(e){return x(e.visitValueClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.ValueEventCollection,!0),3:b.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Dt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:b.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:V.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h})}}};var Tr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="AudioRegionBox";constructor(e){super(e)}accept(e){return x(e.visitAudioRegionBox,this)}get regions(){return this.getField(1)}get file(){return this.getField(2)}get playback(){return this.getField(3)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:h},u.AudioFile,!0),3:V.create({parent:this,fieldKey:3,fieldName:"playback",pointerRules:h},"pitch"),10:b.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:b.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:b.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:h}),15:V.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:h}),16:b.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:h}),17:B.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:h})}}};var Vr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="AudioClipBox";constructor(e){super(e)}accept(e){return x(e.visitAudioClipBox,this)}get clips(){return this.getField(1)}get file(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}get gain(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:h},u.AudioFile,!0),3:b.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Dt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:b.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:V.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:b.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h}),14:B.create({parent:this,fieldKey:14,fieldName:"gain",pointerRules:h})}}};var Dr=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"MarkerBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="MarkerBox";constructor(e){super(e)}accept(e){return x(e.visitMarkerBox,this)}get track(){return this.getField(1)}get position(){return this.getField(2)}get plays(){return this.getField(3)}get label(){return this.getField(4)}get hue(){return this.getField(5)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"track",pointerRules:h},u.MarkerTrack,!0),2:b.create({parent:this,fieldKey:2,fieldName:"position",pointerRules:h}),3:b.create({parent:this,fieldKey:3,fieldName:"plays",pointerRules:h},1),4:V.create({parent:this,fieldKey:4,fieldName:"label",pointerRules:h}),5:b.create({parent:this,fieldKey:5,fieldName:"hue",pointerRules:h})}}};var us=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioFileBox",pointerRules:{accepts:[u.AudioFile],mandatory:!0}}),r)}static ClassName="AudioFileBox";constructor(e){super(e)}accept(e){return x(e.visitAudioFileBox,this)}get startInSeconds(){return this.getField(1)}get endInSeconds(){return this.getField(2)}get fileName(){return this.getField(3)}initializeFields(){return{1:b.create({parent:this,fieldKey:1,fieldName:"startInSeconds",pointerRules:h}),2:b.create({parent:this,fieldKey:2,fieldName:"endInSeconds",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"fileName",pointerRules:h})}}};var Ye=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioUnitBox",pointerRules:{accepts:[u.Selection,u.Automation],mandatory:!1}}),r)}static ClassName="AudioUnitBox";constructor(e){super(e)}accept(e){return x(e.visitAudioUnitBox,this)}get type(){return this.getField(1)}get collection(){return this.getField(2)}get editing(){return this.getField(3)}get index(){return this.getField(11)}get volume(){return this.getField(12)}get panning(){return this.getField(13)}get mute(){return this.getField(14)}get solo(){return this.getField(15)}get tracks(){return this.getField(20)}get midiEffects(){return this.getField(21)}get input(){return this.getField(22)}get audioEffects(){return this.getField(23)}get auxSends(){return this.getField(24)}get output(){return this.getField(25)}get capture(){return this.getField(26)}initializeFields(){return{1:V.create({parent:this,fieldKey:1,fieldName:"type",pointerRules:h},"instrument"),2:E.create({parent:this,fieldKey:2,fieldName:"collection",pointerRules:h},u.AudioUnits,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[u.Editing],mandatory:!1}}),11:b.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:h}),12:B.create({parent:this,fieldKey:12,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:B.create({parent:this,fieldKey:13,fieldName:"panning",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:N.create({parent:this,fieldKey:15,fieldName:"solo",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),20:I.hook({parent:this,fieldKey:20,fieldName:"tracks",pointerRules:{accepts:[u.TrackCollection],mandatory:!1}}),21:I.hook({parent:this,fieldKey:21,fieldName:"midiEffects",pointerRules:{accepts:[u.MidiEffectHost],mandatory:!1}}),22:I.hook({parent:this,fieldKey:22,fieldName:"input",pointerRules:{accepts:[u.InstrumentHost,u.AudioOutput],mandatory:!1}}),23:I.hook({parent:this,fieldKey:23,fieldName:"audioEffects",pointerRules:{accepts:[u.AudioEffectHost],mandatory:!1}}),24:I.hook({parent:this,fieldKey:24,fieldName:"auxSends",pointerRules:{accepts:[u.AuxSend],mandatory:!1}}),25:E.create({parent:this,fieldKey:25,fieldName:"output",pointerRules:h},u.AudioOutput,!1),26:E.create({parent:this,fieldKey:26,fieldName:"capture",pointerRules:h},u.Capture,!1)}}};var cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureAudioBox",pointerRules:{accepts:[u.Capture],mandatory:!0}}),r)}static ClassName="CaptureAudioBox";constructor(e){super(e)}accept(e){return x(e.visitCaptureAudioBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get requestChannels(){return this.getField(10)}get gainDb(){return this.getField(11)}initializeFields(){return{1:V.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:h}),2:V.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:h},"normal"),10:b.create({parent:this,fieldKey:10,fieldName:"requestChannels",pointerRules:h},1),11:B.create({parent:this,fieldKey:11,fieldName:"gainDb",pointerRules:h},0)}}};var hs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureMidiBox",pointerRules:{accepts:[u.Capture],mandatory:!0}}),r)}static ClassName="CaptureMidiBox";constructor(e){super(e)}accept(e){return x(e.visitCaptureMidiBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get channel(){return this.getField(10)}initializeFields(){return{1:V.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:h}),2:V.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:h},"normal"),10:b.create({parent:this,fieldKey:10,fieldName:"channel",pointerRules:h},-1)}}};var Ir=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioBusBox",pointerRules:h}),r)}static ClassName="AudioBusBox";constructor(e){super(e)}accept(e){return x(e.visitAudioBusBox,this)}get collection(){return this.getField(1)}get output(){return this.getField(2)}get input(){return this.getField(3)}get enabled(){return this.getField(4)}get icon(){return this.getField(5)}get label(){return this.getField(6)}get color(){return this.getField(7)}get minimized(){return this.getField(8)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.AudioBusses,!0),2:E.create({parent:this,fieldKey:2,fieldName:"output",pointerRules:h},u.AudioOutput,!0),3:I.hook({parent:this,fieldKey:3,fieldName:"input",pointerRules:{accepts:[u.AudioOutput],mandatory:!1}}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:V.create({parent:this,fieldKey:5,fieldName:"icon",pointerRules:h}),6:V.create({parent:this,fieldKey:6,fieldName:"label",pointerRules:h}),7:V.create({parent:this,fieldKey:7,fieldName:"color",pointerRules:h},"red"),8:N.create({parent:this,fieldKey:8,fieldName:"minimized",pointerRules:h})}}};var ds=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AuxSendBox",pointerRules:h}),r)}static ClassName="AuxSendBox";constructor(e){super(e)}accept(e){return x(e.visitAuxSendBox,this)}get audioUnit(){return this.getField(1)}get targetBus(){return this.getField(2)}get index(){return this.getField(3)}get routing(){return this.getField(4)}get sendGain(){return this.getField(5)}get sendPan(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"audioUnit",pointerRules:h},u.AuxSend,!0),2:E.create({parent:this,fieldKey:2,fieldName:"targetBus",pointerRules:h},u.AudioOutput,!0),3:b.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:b.create({parent:this,fieldKey:4,fieldName:"routing",pointerRules:h},1),5:B.create({parent:this,fieldKey:5,fieldName:"sendGain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),6:B.create({parent:this,fieldKey:6,fieldName:"sendPan",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StepAutomationBox",pointerRules:h}),r)}static ClassName="StepAutomationBox";constructor(e){super(e)}accept(e){return x(e.visitStepAutomationBox,this)}get step(){return this.getField(1)}get parameter(){return this.getField(2)}get value(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"step",pointerRules:h},u.StepAutomation,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:h},u.StepAutomation,!0),3:B.create({parent:this,fieldKey:3,fieldName:"value",pointerRules:h})}}};var ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"GrooveShuffleBox",pointerRules:{accepts:[u.Groove],mandatory:!0}}),r)}static ClassName="GrooveShuffleBox";constructor(e){super(e)}accept(e){return x(e.visitGrooveShuffleBox,this)}get label(){return this.getField(1)}get amount(){return this.getField(10)}get duration(){return this.getField(11)}initializeFields(){return{1:V.create({parent:this,fieldKey:1,fieldName:"label",pointerRules:h}),10:B.create({parent:this,fieldKey:10,fieldName:"amount",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.6),11:b.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},480)}}};var fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownAudioEffectDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="UnknownAudioEffectDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitUnknownAudioEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:V.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:h})}}};var gs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownMidiEffectDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="UnknownMidiEffectDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitUnknownMidiEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:V.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:h})}}};var xs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceInterfaceKnobBox",pointerRules:h}),r)}static ClassName="DeviceInterfaceKnobBox";constructor(e){super(e)}accept(e){return x(e.visitDeviceInterfaceKnobBox,this)}get userInterface(){return this.getField(1)}get parameter(){return this.getField(2)}get index(){return this.getField(3)}get anchor(){return this.getField(10)}get color(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"userInterface",pointerRules:h},u.DeviceUserInterface,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:h},u.ParameterController,!0),3:b.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),10:B.create({parent:this,fieldKey:10,fieldName:"anchor",pointerRules:h}),11:V.create({parent:this,fieldKey:11,fieldName:"color",pointerRules:h})}}};var qs=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get elements(){return this.getField(1)}initializeFields(){return{1:I.hook({parent:this,fieldKey:1,fieldName:"elements",pointerRules:{accepts:[u.DeviceUserInterface],mandatory:!1}})}}};var ys=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ModularDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitModularDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modularSetup(){return this.getField(10)}get userInterface(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:E.create({parent:this,fieldKey:10,fieldName:"modularSetup",pointerRules:h},u.ModularSetup,!0),11:qs.create({parent:this,fieldKey:11,fieldName:"userInterface",pointerRules:h})}}};var zs=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get active(){return this.getField(1)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"active",pointerRules:{accepts:[u.StepAutomation],mandatory:!1}})}}};var _s=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get steps(){return this.getField(10)}get length(){return this.getField(11)}get scale(){return this.getField(12)}initializeFields(){return{10:Pr.create({parent:this,fieldKey:10,fieldName:"steps",pointerRules:h},e=>zs.create(e),128),11:b.create({parent:this,fieldKey:11,fieldName:"length",pointerRules:h},16),12:b.create({parent:this,fieldKey:12,fieldName:"scale",pointerRules:h},960)}}};var vs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceClashBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="DeviceClashBox";constructor(e){super(e)}accept(e){return x(e.visitDeviceClashBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}get patterns(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},.5),11:B.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},.9),12:B.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},0),13:B.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},0),14:B.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},-3),15:B.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},-3),30:Pr.create({parent:this,fieldKey:30,fieldName:"patterns",pointerRules:h},e=>_s.create(e),16)}}};var bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StereoToolDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="StereoToolDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitStereoToolDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get panning(){return this.getField(11)}get stereo(){return this.getField(12)}get invertL(){return this.getField(13)}get invertR(){return this.getField(14)}get swap(){return this.getField(15)}get panningMixing(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:B.create({parent:this,fieldKey:11,fieldName:"panning",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:B.create({parent:this,fieldKey:12,fieldName:"stereo",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:N.create({parent:this,fieldKey:13,fieldName:"invertL",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:N.create({parent:this,fieldKey:14,fieldName:"invertR",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:N.create({parent:this,fieldKey:15,fieldName:"swap",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),20:b.create({parent:this,fieldKey:20,fieldName:"panningMixing",pointerRules:h},1)}}};var As=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DelayDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="DelayDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitDelayDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},4),11:B.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),12:B.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),13:B.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),14:B.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-6),15:B.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0)}}};var Fi=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get order(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:B.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:b.create({parent:this,fieldKey:11,fieldName:"order",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:B.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Ni=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:B.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:B.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var kr=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:B.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:B.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:B.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var ws=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RevampDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="RevampDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitRevampDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get highPass(){return this.getField(10)}get lowShelf(){return this.getField(11)}get lowBell(){return this.getField(12)}get midBell(){return this.getField(13)}get highBell(){return this.getField(14)}get highShelf(){return this.getField(15)}get lowPass(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:Fi.create({parent:this,fieldKey:10,fieldName:"highPass",pointerRules:h}),11:Ni.create({parent:this,fieldKey:11,fieldName:"lowShelf",pointerRules:h}),12:kr.create({parent:this,fieldKey:12,fieldName:"lowBell",pointerRules:h}),13:kr.create({parent:this,fieldKey:13,fieldName:"midBell",pointerRules:h}),14:kr.create({parent:this,fieldKey:14,fieldName:"highBell",pointerRules:h}),15:Ni.create({parent:this,fieldKey:15,fieldName:"highShelf",pointerRules:h}),16:Fi.create({parent:this,fieldKey:16,fieldName:"lowPass",pointerRules:h}),17:B.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Es=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ReverbDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ReverbDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitReverbDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get decay(){return this.getField(10)}get preDelay(){return this.getField(11)}get damp(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"decay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),11:B.create({parent:this,fieldKey:11,fieldName:"preDelay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),12:B.create({parent:this,fieldKey:12,fieldName:"damp",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),13:B.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),14:B.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-3),15:B.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0)}}};var Bs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"VaporisateurDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="VaporisateurDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitVaporisateurDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get octave(){return this.getField(11)}get tune(){return this.getField(12)}get waveform(){return this.getField(13)}get cutoff(){return this.getField(14)}get resonance(){return this.getField(15)}get attack(){return this.getField(16)}get release(){return this.getField(17)}get filterEnvelope(){return this.getField(18)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:b.create({parent:this,fieldKey:11,fieldName:"octave",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:B.create({parent:this,fieldKey:12,fieldName:"tune",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:b.create({parent:this,fieldKey:13,fieldName:"waveform",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:B.create({parent:this,fieldKey:14,fieldName:"cutoff",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:B.create({parent:this,fieldKey:15,fieldName:"resonance",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),16:B.create({parent:this,fieldKey:16,fieldName:"attack",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),17:B.create({parent:this,fieldKey:17,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),18:B.create({parent:this,fieldKey:18,fieldName:"filterEnvelope",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Fs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NanoDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="NanoDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitNanoDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get file(){return this.getField(15)}get release(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-3),15:E.create({parent:this,fieldKey:15,fieldName:"file",pointerRules:h},u.AudioFile,!1),20:B.create({parent:this,fieldKey:20,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.1)}}};var Ns=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="PlayfieldDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitPlayfieldDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get samples(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:I.hook({parent:this,fieldKey:10,fieldName:"samples",pointerRules:{accepts:[u.Sample],mandatory:!1}})}}};var Or=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldSampleBox",pointerRules:{accepts:[u.Editing],mandatory:!1}}),r)}static ClassName="PlayfieldSampleBox";constructor(e){super(e)}accept(e){return x(e.visitPlayfieldSampleBox,this)}get device(){return this.getField(10)}get file(){return this.getField(11)}get midiEffects(){return this.getField(12)}get audioEffects(){return this.getField(13)}get index(){return this.getField(15)}get label(){return this.getField(20)}get icon(){return this.getField(21)}get enabled(){return this.getField(22)}get minimized(){return this.getField(23)}get mute(){return this.getField(40)}get solo(){return this.getField(41)}get exclude(){return this.getField(42)}get polyphone(){return this.getField(43)}get gate(){return this.getField(44)}get pitch(){return this.getField(45)}get sampleStart(){return this.getField(46)}get sampleEnd(){return this.getField(47)}get attack(){return this.getField(48)}get release(){return this.getField(49)}initializeFields(){return{10:E.create({parent:this,fieldKey:10,fieldName:"device",pointerRules:h},u.Sample,!0),11:E.create({parent:this,fieldKey:11,fieldName:"file",pointerRules:h},u.AudioFile,!0),12:I.hook({parent:this,fieldKey:12,fieldName:"midiEffects",pointerRules:{accepts:[u.MidiEffectHost],mandatory:!1}}),13:I.hook({parent:this,fieldKey:13,fieldName:"audioEffects",pointerRules:{accepts:[u.AudioEffectHost],mandatory:!1}}),15:b.create({parent:this,fieldKey:15,fieldName:"index",pointerRules:h},60),20:V.create({parent:this,fieldKey:20,fieldName:"label",pointerRules:h}),21:V.create({parent:this,fieldKey:21,fieldName:"icon",pointerRules:h}),22:N.create({parent:this,fieldKey:22,fieldName:"enabled",pointerRules:h},!0),23:N.create({parent:this,fieldKey:23,fieldName:"minimized",pointerRules:h},!1),40:N.create({parent:this,fieldKey:40,fieldName:"mute",pointerRules:h}),41:N.create({parent:this,fieldKey:41,fieldName:"solo",pointerRules:h}),42:N.create({parent:this,fieldKey:42,fieldName:"exclude",pointerRules:h}),43:N.create({parent:this,fieldKey:43,fieldName:"polyphone",pointerRules:h}),44:b.create({parent:this,fieldKey:44,fieldName:"gate",pointerRules:h},0),45:B.create({parent:this,fieldKey:45,fieldName:"pitch",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),46:B.create({parent:this,fieldKey:46,fieldName:"sampleStart",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),47:B.create({parent:this,fieldKey:47,fieldName:"sampleEnd",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),48:B.create({parent:this,fieldKey:48,fieldName:"attack",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.001),49:B.create({parent:this,fieldKey:49,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.02)}}};var Ps=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TapeDeviceBox",pointerRules:{accepts:[u.Device,u.Selection,u.Automation],mandatory:!1}}),r)}static ClassName="TapeDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitTapeDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get flutter(){return this.getField(10)}get wow(){return this.getField(11)}get noise(){return this.getField(12)}get saturation(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:B.create({parent:this,fieldKey:10,fieldName:"flutter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:B.create({parent:this,fieldKey:11,fieldName:"wow",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:B.create({parent:this,fieldKey:12,fieldName:"noise",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:B.create({parent:this,fieldKey:13,fieldName:"saturation",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Ss=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ArpeggioDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ArpeggioDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitArpeggioDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modeIndex(){return this.getField(10)}get numOctaves(){return this.getField(11)}get rateIndex(){return this.getField(12)}get gate(){return this.getField(13)}get repeat(){return this.getField(14)}get velocity(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:b.create({parent:this,fieldKey:10,fieldName:"modeIndex",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:b.create({parent:this,fieldKey:11,fieldName:"numOctaves",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),12:b.create({parent:this,fieldKey:12,fieldName:"rateIndex",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},9),13:B.create({parent:this,fieldKey:13,fieldName:"gate",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),14:b.create({parent:this,fieldKey:14,fieldName:"repeat",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),15:B.create({parent:this,fieldKey:15,fieldName:"velocity",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Cs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PitchDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="PitchDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitPitchDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get semiTones(){return this.getField(10)}get cents(){return this.getField(11)}get octaves(){return this.getField(12)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:b.create({parent:this,fieldKey:10,fieldName:"semiTones",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:B.create({parent:this,fieldKey:11,fieldName:"cents",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:b.create({parent:this,fieldKey:12,fieldName:"octaves",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Rs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ZeitgeistDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ZeitgeistDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitZeitgeistDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get groove(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:b.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:V.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:E.create({parent:this,fieldKey:10,fieldName:"groove",pointerRules:h},u.Groove,!0)}}};var Ms=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularBox",pointerRules:h}),r)}static ClassName="ModularBox";constructor(e){super(e)}accept(e){return x(e.visitModularBox,this)}get collection(){return this.getField(1)}get device(){return this.getField(2)}get editing(){return this.getField(3)}get modules(){return this.getField(11)}get connections(){return this.getField(12)}get label(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ModularSetup,!0),2:I.hook({parent:this,fieldKey:2,fieldName:"device",pointerRules:{accepts:[u.ModularSetup],mandatory:!0}}),3:I.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[u.Editing],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"modules",pointerRules:{accepts:[u.ModuleCollection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"connections",pointerRules:{accepts:[u.ConnectionCollection],mandatory:!1}}),13:V.create({parent:this,fieldKey:13,fieldName:"label",pointerRules:h})}}};var Ts=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleConnectionBox",pointerRules:h}),r)}static ClassName="ModuleConnectionBox";constructor(e){super(e)}accept(e){return x(e.visitModuleConnectionBox,this)}get collection(){return this.getField(1)}get source(){return this.getField(2)}get target(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ConnectionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"source",pointerRules:h},u.VoltageConnection,!0),3:E.create({parent:this,fieldKey:3,fieldName:"target",pointerRules:h},u.VoltageConnection,!0)}}};var Ke=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get collection(){return this.getField(1)}get label(){return this.getField(2)}get x(){return this.getField(3)}get y(){return this.getField(4)}get collapsed(){return this.getField(5)}get removable(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ModuleCollection,!0),2:V.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:b.create({parent:this,fieldKey:3,fieldName:"x",pointerRules:h}),4:b.create({parent:this,fieldKey:4,fieldName:"y",pointerRules:h}),5:N.create({parent:this,fieldKey:5,fieldName:"collapsed",pointerRules:h},!1),6:N.create({parent:this,fieldKey:6,fieldName:"removable",pointerRules:h},!0)}}};var Vs=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioInputBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModularAudioInputBox";constructor(e){super(e)}accept(e){return x(e.visitModularAudioInputBox,this)}get attributes(){return this.getField(1)}get output(){return this.getField(10)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:I.hook({parent:this,fieldKey:10,fieldName:"output",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}})}}};var Ds=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioOutputBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModularAudioOutputBox";constructor(e){super(e)}accept(e){return x(e.visitModularAudioOutputBox,this)}get attributes(){return this.getField(1)}get input(){return this.getField(10)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:I.hook({parent:this,fieldKey:10,fieldName:"input",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}})}}};var Is=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleDelayBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleDelayBox";constructor(e){super(e)}accept(e){return x(e.visitModuleDelayBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(11)}get time(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:B.create({parent:this,fieldKey:20,fieldName:"time",pointerRules:{accepts:[u.ParameterController],mandatory:!1}},500)}}};var Os=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleMultiplierBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleMultiplierBox";constructor(e){super(e)}accept(e){return x(e.visitModuleMultiplierBox,this)}get attributes(){return this.getField(1)}get voltageInputX(){return this.getField(10)}get voltageInputY(){return this.getField(11)}get voltageOutput(){return this.getField(12)}get multiplier(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInputX",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),11:I.hook({parent:this,fieldKey:11,fieldName:"voltageInputY",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:B.create({parent:this,fieldKey:20,fieldName:"multiplier",pointerRules:h})}}};var ks=class i extends P{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleGainBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleGainBox";constructor(e){super(e)}accept(e){return x(e.visitModuleGainBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(12)}get gain(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:I.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),12:I.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:B.create({parent:this,fieldKey:20,fieldName:"gain",pointerRules:{accepts:[u.ParameterController],mandatory:!1}})}}};var et;(function(i){i.write=(e,t)=>{if(t.type==="none")e.disconnect(),e.setValue(0);else if(t.type==="linear")e.disconnect(),e.setValue(1);else if(t.type==="curve"){e.setValue(0);let r=e.pointerHub.filter(u.ValueInterpolation).at(0)?.box;T(r)?(rn(r,Vt),r.slope.setValue(t.slope)):Vt.create(e.box.graph,A.generate(),s=>{s.slope.setValue(t.slope),s.event.refer(e)})}},i.read=e=>{let t=e.pointerHub.incoming().at(0)?.box;return T(t)?(rn(t,Vt),{type:"curve",slope:t.slope.getValue()}):e.getValue()===0?St.None:e.getValue()===1?St.Linear:g("Unknown Interpolation value")}})(et||(et={}));var It=class i{static Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.index-t.index;if(s!==0)return s;throw new Error(`${e} and ${t} are identical in terms of comparison`)};type="value-event";#e=new D;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new Vi(()=>et.read(this.#r.interpolation)));let r=()=>{this.#i.invalidate(),this.collection.ifSome(s=>s.onEventPropertyChanged())};this.#e.ownAll(this.#r.subscribe(Q.Children,s=>{if(!this.collection.isEmpty()&&(s.type==="primitive"||s.type==="pointer")){let o=this.collection.unwrap(),n=s.address.fieldKeys,a=w.equals(this.#r.index.address.fieldKeys,n),l=w.equals(this.#r.position.address.fieldKeys,n);a||l?o.requestSorting():o.onEventPropertyChanged()}}),this.#r.interpolation.subscribe(r),this.#r.interpolation.pointerHub.subscribeImmediate({onAdd:({box:s})=>{this.#s.terminate(),this.#s=s.subscribe(Q.Children,r),r()},onRemove:()=>{this.#s.terminate(),this.#s=U.Empty,r()}})),this.#s=this.#r.interpolation.pointerHub.filter(u.ValueInterpolation).at(0)?.box.subscribe(Q.Children,r)??U.Empty}onSelected(){this.#o=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#o=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#s.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get index(){return this.#r.index.getValue()}set interpolation(e){et.write(this.#r.interpolation,e)}get interpolation(){return this.#i.get()}get value(){return this.#r.value.getValue()}get isSelected(){return this.#o}get collection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Le))}copyTo(e){let t=Tt.create(this.#t.boxGraph,A.generate(),r=>{r.position.setValue(e?.position??this.position),r.index.setValue(e?.index??this.index),r.events.refer(e?.events??this.collection.unwrap().box.events),r.value.setValue(e?.value??this.value)});return et.write(t.interpolation,e?.interpolation??this.interpolation),this.#t.boxAdapters.adapterFor(t,i)}copyFrom(e){return this.#r.position.setValue(e?.position??this.position),this.#r.index.setValue(e?.index??this.index),this.#r.events.refer(e?.events??this.collection.unwrap().box.events),this.#r.value.setValue(e?.value??this.value),et.write(this.#r.interpolation,e?.interpolation??this.interpolation),this}toString(){return`{ValueEventBoxAdapter position: ${this.position} index: ${this.index}}`}};var Le=class i{#e=new D;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new q,this.#s=A.newSet(s=>s.uuid),this.#o=Ft.create(It.Comparator);let r=s=>{let o=k(s.accept({visitValueEventBox:n=>this.#t.boxAdapters.adapterFor(n,It)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#n())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#n()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}valueAt(e,t){return Qi.valueAt(this.#o,e,t)}copy(){let e=this.#t.boxGraph,t=mt.create(e,A.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}cut(e){let t=this.events.lowerEqual(e),r=this.events.greaterEqual(e);if(r===null)return t===null?p.None:p.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t===null)return p.wrap(this.createEvent({position:e,value:r.value,index:r.index,interpolation:r.interpolation}));if(t.position===e)return p.wrap(t);if(t.interpolation.type==="none")return p.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t.interpolation.type==="linear"){let{position:s,value:o}=t,{position:n,value:a}=r;return p.wrap(this.createEvent({position:e,value:Gn(o,a,(e-s)/(n-s)),index:0,interpolation:t.interpolation}))}if(t.interpolation.type==="curve"){let{position:s,value:o}=t,{position:n,value:a}=r,l=n-s,c=e-s,d=Ue.byHalf(l,o,Ue.valueAt({slope:t.interpolation.slope,steps:l,y0:o,y1:a},l*.5),a),m=Ue.valueAt(d,c),f=Ue.slopeByHalf(o,Ue.valueAt(d,c*.5),m);return et.write(t.box.interpolation,St.Curve(f)),p.wrap(this.createEvent({position:e,value:m,index:0,interpolation:St.Curve(Ue.slopeByHalf(m,Ue.valueAt(d,(c+l)*.5),a))}))}return g("Unknown interpolation type")}subscribeChange(e){return this.#i.subscribe(e)}createEvent({position:e,index:t,value:r,interpolation:s}){let o=Tt.create(this.#t.boxGraph,A.generate(),n=>{n.position.setValue(e),n.index.setValue(t),n.value.setValue(r),n.events.refer(this.#r.events)});return et.write(o.interpolation,s),this.#t.boxAdapters.adapterFor(o,It)}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#n()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(u.ValueEventCollection).length}get events(){return this.#o}toString(){return`{ValueEventCollectionBox ${A.toString(this.#r.address.uuid)}}`}#n(){this.#i.notify(this)}};var Ot=class{type="value-clip";#e=new D;#t;#r;#i;#s;#o;#n=U.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Ce(!1)),this.#s=this.#e.own(new q),this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(Q.Children,r=>this.#a())),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>U.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Le).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(e%this.duration,t)}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitValueClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Mr.create(this.#t.boxGraph,A.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Le))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{ValueClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var tt=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get startInSeconds(){return this.#t.startInSeconds.getValue()}get endInSeconds(){return this.#t.endInSeconds.getValue()}get data(){return this.getOrCreateLoader().data}get peaks(){return this.getOrCreateLoader().peaks}getOrCreateLoader(){return this.#e.sampleManager.getOrCreate(this.#t.address.uuid)}terminate(){}};var kt=class{type="audio-clip";#e=new D;#t;#r;#i;#s;#o;#n=p.None;#a=p.None;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Ce(!1)),this.#s=this.#e.own(new q),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,tt)),this.#a.ifSome(s=>s.terminate()),this.#a=this.#n.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(Q.Children,r=>this.#l()),{terminate:()=>{this.#a.ifSome(r=>r.terminate()),this.#a=p.None}}),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitAudioClipBoxAdapter,this)}consolidate(){}clone(e){Vr.create(this.#t.boxGraph,A.generate(),t=>{t.index.setValue(this.indexField.getValue()),t.gain.setValue(this.gain),t.label.setValue(this.label),t.hue.setValue(this.hue),t.duration.setValue(this.duration),t.mute.setValue(this.mute),t.clips.refer(this.#r.clips.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap())})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#n.unwrap("Cannot access file.")}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return p.None}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return!1}get canMirror(){return!1}toString(){return`{AudioClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#l(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var mr=class i{type="note-event";#e;#t;#r;#i=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=this.#t.subscribe(Q.Children,r=>{if(!this.collection.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.collection.unwrap(),o=r.address.fieldKeys,n=w.equals(this.#t.pitch.address.fieldKeys,o),a=w.equals(this.#t.position.address.fieldKeys,o);n||a?s.requestSorting():s.onEventPropertyChanged()}})}onSelected(){this.#i=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#i=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#r.terminate()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get position(){return this.#t.position.getValue()}get duration(){return this.#t.duration.getValue()}get complete(){return this.position+this.duration}get velocity(){return this.#t.velocity.getValue()}get pitch(){return this.#t.pitch.getValue()}get cent(){return this.#t.cent.getValue()}get chance(){return this.#t.chance.getValue()}get playCount(){return this.#t.playCount.getValue()}get playCurve(){return this.#t.playCurve.getValue()}get isSelected(){return this.#i}get collection(){return this.#t.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,$e))}normalizedPitch(){if(this.collection.isEmpty())return .5;let{minPitch:e,maxPitch:t}=this.collection.unwrap();return e===t?.5:1-(this.pitch-e)/(t-e)}copyAsNoteEvent(){return{type:"note-event",position:this.position,duration:this.duration,pitch:this.pitch,cent:this.cent,velocity:this.velocity}}copyTo(e){return this.#e.boxAdapters.adapterFor(Mt.create(this.#e.boxGraph,A.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.pitch.setValue(e?.pitch??this.pitch),t.playCount.setValue(e?.playCount??this.playCount),t.events.refer(e?.events??this.collection.unwrap().box.events),t.velocity.setValue(this.velocity),t.cent.setValue(this.cent),t.chance.setValue(this.chance)}),i)}computeCurveValue(e){return Me.curveFunc(e,this.playCurve)}canConsolidate(){return this.playCount>1}consolidate(){let e=this.playCount,t=this.collection.unwrap().box.events,r=w.create(s=>{let o=Math.floor(this.computeCurveValue(s/e)*this.duration),n=Math.floor(this.computeCurveValue((s+1)/e)*this.duration);return this.copyTo({position:Math.floor(this.position+o),duration:Math.max(1,n-o),playCount:1,events:t})},e);return this.#t.delete(),r}};var $e=class i{#e=new D;#t;#r;#i;#s;#o;#n=60;#a=60;#l=0;#u=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=new q,this.#s=A.newSet(s=>s.uuid),this.#o=Ft.create(Me.Comparator);let r=s=>{let o=k(s.accept({visitNoteEventBox:n=>this.#t.boxAdapters.adapterFor(n,mr)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#c())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#e.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#c()}})),this.#e.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}copy(){let e=this.#t.boxGraph,t=pt.create(e,A.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#t.boxAdapters.adapterFor(t,i)}createEvent({position:e,duration:t,velocity:r,pitch:s,chance:o,playCount:n,cent:a}){return this.#t.boxAdapters.adapterFor(Mt.create(this.#t.boxGraph,A.generate(),l=>{l.position.setValue(e),l.duration.setValue(t),l.velocity.setValue(r),l.pitch.setValue(s),l.chance.setValue(o),l.playCount.setValue(n),l.cent.setValue(a),l.events.refer(this.#r.events)}),mr)}subscribeChange(e){return this.#i.subscribe(e)}selectable(){return this.#o.asArray()}selectableAt(e){for(let t of this.#o.asArray())if(t.position<=e.u&&e.u<t.complete&&t.pitch===e.v)return le.one(t);return le.empty()}selectablesBetween(e,t){let r=[];for(let s of this.#o.asArray())fi.intersect1D(s.position,s.complete,e.u,t.u)&&fi.intersect1D(s.pitch,s.pitch,e.v,t.v)&&r.push(s);return r}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#c()}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(u.NoteEventCollection).length}get events(){return this.#u||this.#h(),this.#o}get minPitch(){return this.#u||this.#h(),this.#n}get maxPitch(){return this.#u||this.#h(),this.#a}get maxDuration(){return this.#u||this.#h(),this.#l}toString(){return`{NoteEventCollectionBox ${A.toString(this.#r.address.uuid)}}`}#c(){this.#u=!1,this.#i.notify(this)}#h(){let e=127,t=0,r=0;this.#o.asArray().forEach(({pitch:s,duration:o})=>{e=Math.min(e,s),t=Math.max(t,s),r=Math.max(r,o)}),this.#n=e,this.#a=t,this.#l=r,this.#u=!0}};var Ur=class{type="note-clip";#e=new D;#t;#r;#i;#s;#o;#n=U.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=this.#e.own(new Ce(!1)),this.#s=this.#e.own(new q),this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(Q.Children,r=>this.#a()),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>U.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,$e).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitNoteClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Rr.create(this.#t.boxGraph,A.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get events(){return this.optCollection.map(e=>e.events)}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,$e))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{NoteClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${G.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var Hs={for:(i,e)=>k(e.accept({visitNoteClipBox:t=>i.adapterFor(t,Ur),visitValueClipBox:t=>i.adapterFor(t,Ot),visitAudioClipBox:t=>i.adapterFor(t,kt)}),"")};var Gs=class{#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=new D,this.#r=this.#t.own(new q),this.#i=this.#t.own(Be.create(e.box.clips,r=>Hs.for(t,r),u.ClipCollection)),this.#i.subscribe({onAdd:()=>this.dispatchChange(),onRemove:()=>this.dispatchChange(),onReorder:()=>this.dispatchChange()})}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}dispatchChange(){this.#r.notify()}subscribeChanges(e){return this.#r.subscribe(e)}terminate(){this.#t.terminate()}};var Ut=class i{type="audio-region";#e;#t;#r;#i;#s=p.None;#o=p.None;#n;#a;constructor(e,t){this.#t=e,this.#r=t,this.#e=new D,this.#i=new q,this.#n=!1,this.#a=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#s=r.targetVertex.map(s=>this.#t.boxAdapters.adapterFor(s.box,tt)),this.#o.ifSome(s=>s.terminate()),this.#o=this.#s.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(Q.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#l()):this.#l()}}),{terminate:()=>{this.#o.ifSome(r=>r.terminate()),this.#o=p.None}}),this.#a=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitAudioRegionBoxAdapter,this)}onSelected(){this.#n=!0,this.#l()}onDeselected(){this.#n=!1,this.#l()}get isSelected(){return this.#n}terminate(){this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){let e=this.#r.duration.getValue();if(e===0){let t=this.#s.unwrap("Cannot compute duration without file"),r=t.startInSeconds,o=t.endInSeconds-r;return G.secondsToPulses(o,this.#t.bpm)}return e}get complete(){return this.position+this.duration}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#s.unwrap("Cannot access file.")}get hasCollection(){return this.#s.nonEmpty()}get optCollection(){return p.None}get label(){if(this.#s.isEmpty())return"No Audio File";let e=this.#s.unwrap().getOrCreateLoader().state;return e.type==="progress"?`${Math.round(e.progress*100)}%`:e.type==="error"?String(e.reason):this.#r.label.getValue()}get isMirrowed(){return!1}get canMirror(){return!1}get trackBoxAdapter(){return this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}copyTo(e){return this.#t.boxAdapters.adapterFor(Tr.create(this.#t.boxGraph,A.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.loopOffset.setValue(e?.loopOffset??this.loopOffset),t.loopDuration.setValue(e?.loopDuration??this.loopDuration),t.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap()),t.mute.setValue(this.mute),t.hue.setValue(this.hue),t.label.setValue(this.label),t.gain.setValue(this.gain)}),i)}consolidate(){}canFlatten(e){return!1}flatten(e){return p.None}toString(){return`{AudioRegionBoxAdapter ${A.toString(this.#r.address.uuid)}}`}#l(){this.#a||(this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange())}};var Kt=class i{type="note-region";#e=new D;#t;#r;#i;#s;#o;#n=U.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#i=new q,this.#o=!1,this.#s=!0,this.#e.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(Q.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}}),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>U.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,$e).subscribeChange(()=>this.#a())}),this.#a()})),this.#s=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitNoteRegionBoxAdapter,this)}onSelected(){this.#o=!0,this.#a()}onDeselected(){this.#o=!1,this.#a()}get isSelected(){return this.#o}*iterateActiveNotesAt(e){let t=this.optCollection;if(t.isEmpty())return;let r=t.unwrap(),s=De.globalToLocal(this,e);for(let o of r.events.iterateFrom(s-r.maxDuration)){if(s<o.position)return;s<o.complete&&(yield o.copyAsNoteEvent())}}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return this.optCollection.nonEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,$e))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#s?p.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(dr.create(this.#t.boxGraph,A.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.optCollection.ifSome(e=>{let t=this.#t.boxGraph,r=pt.create(t,A.generate());e.events.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return e.length>0&&w.satisfy(e,(t,r)=>t.trackBoxAdapter.contains(r.trackBoxAdapter.unwrap()))&&e.every(t=>t.isSelected&&t instanceof i)}flatten(e){if(!this.canFlatten(e))return p.None;let t=this.#t.boxGraph,r=e.toSorted(Nt.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,l=s.trackBoxAdapter.unwrap(),c=pt.create(t,A.generate()),d=Array.from(l.regions.collection.iterateRange(n,a));return d.filter(m=>m.isSelected).forEach(m=>{let f=m;for(let{resultStart:y,resultEnd:F,rawStart:S}of De.locateLoops(f,f.position,f.complete)){let M=Math.floor(y-S),K=Math.floor(F-S);for(let L of f.optCollection.unwrap().events.iterateRange(M,K))L.copyTo({position:L.position+S-s.position,events:c.events})}}),d.forEach(({box:m})=>m.delete()),p.wrap(dr.create(t,A.generate(),m=>{m.position.setValue(n),m.duration.setValue(a-n),m.loopDuration.setValue(a-n),m.loopOffset.setValue(0),m.hue.setValue(this.hue),m.mute.setValue(this.mute),m.label.setValue(this.label),m.events.refer(c.owners),m.regions.refer(l.box.regions)}))}toString(){return`{NoteRegionBoxAdapter ${A.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var ft=class i{type="value-region";#e=new D;#t;#r;#i;#s;#o;#n=U.Empty;constructor(e,t){this.#t=e,this.#r=t,this.#o=!0,this.#i=new q,this.#s=!1,this.#e.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#e.own(this.#r.subscribe(Q.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}})),this.#e.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>U.Empty,some:({box:s})=>this.#t.boxAdapters.adapterFor(s,Le).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(De.globalToLocal(this,e),t)}incomingValue(e){return this.valueAt(this.position,e)}outgoingValue(e){let t=this.optCollection;if(t.isEmpty())return e;let r=t.unwrap();return(this.complete-this.offset)%this.loopDuration===0?r.valueAt(this.loopDuration,e):r.valueAt(De.globalToLocal(this,this.complete),e)}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitValueRegionBoxAdapter,this)}onSelected(){this.#s=!0,this.#a()}onDeselected(){this.#s=!1,this.#a()}get isSelected(){return this.#s}onValuesPropertyChanged(){this.#a()}onValuesSortingChanged(){this.onValuesPropertyChanged()}terminate(){this.#n.terminate(),this.#e.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,Le))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.regions.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,me))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#t.boxAdapters.adapterFor(pr.create(this.#t.boxGraph,A.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.events.ifSome(e=>{let t=this.#t.boxGraph,r=mt.create(t,A.generate());e.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return!1}flatten(e){if(!this.canFlatten(e))return p.None;let t=this.#t.boxGraph,r=e.toSorted(Nt.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,l=s.trackBoxAdapter.unwrap(),c=mt.create(t,A.generate()),d=Array.from(l.regions.collection.iterateRange(n,a));return d.filter(m=>m.isSelected).forEach(m=>{let f=m;for(let{resultStart:y,resultEnd:F,rawStart:S}of De.locateLoops(f,f.position,f.complete)){let M=Math.floor(y-S),K=Math.floor(F-S);for(let L of f.events.unwrap().iterateRange(M,K));}}),d.forEach(({box:m})=>m.delete()),p.wrap(pr.create(t,A.generate(),m=>{m.position.setValue(n),m.duration.setValue(a-n),m.loopDuration.setValue(a-n),m.loopOffset.setValue(0),m.hue.setValue(this.hue),m.mute.setValue(this.mute),m.label.setValue(this.label),m.events.refer(c.owners),m.regions.refer(l.box.regions)}))}toString(){return`{ValueRegionBoxAdapter ${A.toString(this.#r.address.uuid)} p: ${G.toString(this.position)}, c: ${G.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var Sa=(i,e)=>i.position-e.position,Ca={for:(i,e)=>k(e.accept({visitNoteRegionBox:t=>i.adapterFor(t,Kt),visitAudioRegionBox:t=>i.adapterFor(t,Ut),visitValueRegionBox:t=>i.adapterFor(t,ft)}),"")};var Ws=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=new D,this.#r=this.#t.own(new q),this.#i=Nt.create(Sa),this.#s=A.newSet(r=>r.uuid),this.#t.ownAll(this.#e.box.regions.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{let s=Ca.for(t,r),o=this.#s.add(s);v(o,`Cannot add ${r}`),this.#i.add(s),this.dispatchChange()},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#s.removeByKey(r)),this.dispatchChange()}},u.RegionCollection))}get trackBoxAdapter(){return this.#e}get collection(){return this.#i}get adapters(){return this.#s}onIndexingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}subscribeChanges(e){return this.#r.subscribe(e)}dispatchChange(){this.#r.notify()}terminate(){this.#t.terminate()}};var we;(function(i){i[i.Rectangle=0]="Rectangle",i[i.Checkbox=1]="Checkbox",i[i.Cursor=2]="Cursor",i[i.Panel=3]="Panel",i[i.MainMenu=4]="MainMenu",i[i.Dropdown=5]="Dropdown",i[i.Dropbox=6]="Dropbox",i[i.GoogleDrive=7]="GoogleDrive",i[i.AudioDevice=8]="AudioDevice",i[i.GuitarTab=9]="GuitarTab",i[i.Effects=10]="Effects",i[i.Flask=11]="Flask",i[i.Robot=12]="Robot",i[i.NotePad=13]="NotePad",i[i.Pencil=14]="Pencil",i[i.Waveform=15]="Waveform",i[i.Mix=16]="Mix",i[i.Adsr=17]="Adsr",i[i.Dial=18]="Dial",i[i.Record=19]="Record",i[i.Play=20]="Play",i[i.Stop=21]="Stop",i[i.Loop=22]="Loop",i[i.Timeline=23]="Timeline",i[i.Region=24]="Region",i[i.Box=25]="Box",i[i.Mixing=26]="Mixing",i[i.Vinyl=27]="Vinyl",i[i.Help=28]="Help",i[i.Metronome=29]="Metronome",i[i.System=30]="System",i[i.Add=31]="Add",i[i.Subtract=32]="Subtract",i[i.Peak=33]="Peak",i[i.LowPass=34]="LowPass",i[i.HighPass=35]="HighPass",i[i.LowShelf=36]="LowShelf",i[i.HighShelf=37]="HighShelf",i[i.RoundUp=38]="RoundUp",i[i.RoundDown=39]="RoundDown",i[i.Mute=40]="Mute",i[i.Solo=41]="Solo",i[i.Exclude=42]="Exclude",i[i.Menu=43]="Menu",i[i.Pointer=44]="Pointer",i[i.Eraser=45]="Eraser",i[i.Scissors=46]="Scissors",i[i.Tape=47]="Tape",i[i.CollapseDown=48]="CollapseDown",i[i.FileList=49]="FileList",i[i.Close=50]="Close",i[i.DragConnections=51]="DragConnections",i[i.Heart=52]="Heart",i[i.Merge=53]="Merge",i[i.SpeakerHeadphone=54]="SpeakerHeadphone",i[i.AudioBus=55]="AudioBus",i[i.DrumSet=56]="DrumSet",i[i.BassGuitar=57]="BassGuitar",i[i.Guitar=58]="Guitar",i[i.Saxophone=59]="Saxophone",i[i.Microphone=60]="Microphone",i[i.New=61]="New",i[i.Piano=62]="Piano",i[i.ExpandWidth=63]="ExpandWidth",i[i.OpenDAW=64]="OpenDAW",i[i.Automation=65]="Automation",i[i.Embed=66]="Embed",i[i.Popout=67]="Popout",i[i.Minimized=68]="Minimized",i[i.Maximized=69]="Maximized",i[i.Search=70]="Search",i[i.Generator=71]="Generator",i[i.Groove=72]="Groove",i[i.Table=73]="Table",i[i.Note=74]="Note",i[i.Exit=75]="Exit",i[i.Start=76]="Start",i[i.Duration=77]="Duration",i[i.Velocity=78]="Velocity",i[i.Random=79]="Random",i[i.Divide=80]="Divide",i[i.Curve=81]="Curve",i[i.Primary=82]="Primary",i[i.Clips=83]="Clips",i[i.NoAudio=84]="NoAudio",i[i.Unknown=85]="Unknown",i[i.UserFolder=86]="UserFolder",i[i.CloudFolder=87]="CloudFolder",i[i.Run=88]="Run",i[i.Insert=89]="Insert",i[i.ArrayDown=90]="ArrayDown",i[i.Sun=91]="Sun",i[i.Book=92]="Book",i[i.Stack=93]="Stack",i[i.EditBox=94]="EditBox",i[i.Delete=95]="Delete",i[i.Time=96]="Time",i[i.EQ=97]="EQ",i[i.Cube=98]="Cube",i[i.NanoWave=99]="NanoWave",i[i.Midi=100]="Midi",i[i.DinSlot=101]="DinSlot",i[i.VUMeter=102]="VUMeter",i[i.Playfield=103]="Playfield",i[i.Invert=104]="Invert",i[i.Headphone=105]="Headphone",i[i.Stereo=106]="Stereo",i[i.AutoGain=107]="AutoGain",i[i.AudioFile=108]="AudioFile",i[i.Tool=109]="Tool",i[i.Focus=110]="Focus",i[i.Swap=111]="Swap",i[i.Connected=112]="Connected",i[i.Disconnected=113]="Disconnected",i[i.Zeitgeist=114]="Zeitgeist"})(we||(we={}));(function(i){i.toName=e=>i[e],i.fromName=e=>i[e]??i.Rectangle})(we||(we={}));var Z;(function(i){i[i.Undefined=0]="Undefined",i[i.Notes=1]="Notes",i[i.Audio=2]="Audio",i[i.Value=3]="Value"})(Z||(Z={}));(function(i){i.toLabelString=e=>{switch(e){case i.Audio:return"Audio";case i.Notes:return"Notes";case i.Value:return"Automation";case i.Undefined:default:return"N/A"}},i.toIconSymbol=e=>{switch(e){case i.Audio:return we.Waveform;case i.Notes:return we.Piano;case i.Value:return we.Automation;case i.Undefined:return we.AudioBus;default:return we.Unknown}}})(Z||(Z={}));var js;(function(i){i.isDeviceBox=e=>"host"in e&&ae(e.host,E)&&"label"in e&&ae(e.label,V)&&"enabled"in e&&ae(e.enabled,N)&&"minimized"in e&&ae(e.minimized,N),i.isInstrumentDeviceBox=e=>i.isDeviceBox(e)&&e.host.pointerType===u.InstrumentHost,i.isEffectDeviceBox=e=>i.isDeviceBox(e)&&"index"in e&&ae(e.index,b)&&(e.host.pointerType===u.MidiEffectHost||e.host.pointerType===u.AudioEffectHost),i.lookupHostField=e=>T(e)&&"host"in e&&ae(e.host,E)?e.host:g(`Could not find 'host' field in '${e?.name}'`),i.lookupLabelField=e=>T(e)&&"label"in e&&ae(e.label,V)?e.label:g(`Could not find 'label' field in '${e?.name}'`),i.lookupEnabledField=e=>T(e)&&"enabled"in e&&ae(e.enabled,N)?e.enabled:g(`Could not find 'enabled' field in '${e?.name}'`),i.lookupMinimizedField=e=>T(e)&&"minimized"in e&&ae(e.minimized,N)?e.minimized:g(`Could not find 'minimized' field in '${e?.name}'`),i.lookupIndexField=e=>T(e)&&"index"in e&&ae(e.index,b)?e.index:g(`Could not find 'index' field in '${e?.name}'`)})(js||(js={}));var Ra;(function(i){i.toTrackType=e=>{switch(e){case"midi":return Z.Notes;case"audio":return Z.Audio;default:return g()}}})(Ra||(Ra={}));var j;(function(i){i.isAny=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="bus"||e.type==="instrument"||e.type==="audio-effect"),i.isEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="audio-effect"),i.isInstrument=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="instrument",i.isMidiEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="midi-effect",i.isAudioEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="audio-effect",i.isHost=e=>e!==null&&typeof e=="object"&&"class"in e&&e.class==="device-host",i.deleteEffectDevices=e=>{if(e.length===0)return;v(w.satisfy(e,(s,o)=>s.deviceHost().address.equals(o.deviceHost().address)),"Devices are not connected to the same host");let t=e[0];(t.accepts==="audio"?t.deviceHost().audioEffects.field().pointerHub.filter(u.AudioEffectHost):t.accepts==="midi"?t.deviceHost().midiEffects.field().pointerHub.filter(u.MidiEffectHost):g("unknown type")).map(({box:s})=>js.lookupIndexField(s)).filter(s=>e.some(o=>A.Comparator(o.uuid,s.address.uuid)!==0)).sort((s,o)=>s.getValue()-o.getValue()).forEach((s,o)=>s.setValue(o)),e.forEach(s=>s.box.delete())}})(j||(j={}));var Qs=class{#e;#t=new q;#r;#i;#s;constructor(e,t){this.#e=e,this.#r=Be.create(e.box.tracks,r=>t.adapterFor(r,me),u.TrackCollection),this.#i=A.newSet(({uuid:r})=>r),this.#s=this.#r.catchupAndSubscribe({onAdd:r=>this.#i.add({uuid:r.uuid,subscription:r.regions.subscribeChanges(()=>this.#t.notify())}),onRemove:({uuid:r})=>this.#i.removeByKey(r).subscription.terminate(),onReorder:r=>{}})}create(e,t,r){let s=this.#e.box.graph,o=this.#e.box.tracks;Cr.create(s,A.generate(),n=>{n.index.setValue(r??this.#r.getMinFreeIndex()),n.type.setValue(e),n.tracks.refer(o),n.target.refer(t)})}controls(e){return p.wrap(this.#r.adapters().find(t=>t.target.targetVertex.contains(e),!1))}delete(e){let t=this.#r.adapters(),r=t.indexOf(e);if(r===-1)return g(`Cannot delete ${e}. Does not exist.`);for(let s=r+1;s<t.length;s++)t[s].indexField.setValue(s-1);e.box.delete()}get collection(){return this.#r}values(){return this.#r.adapters()}catchupAndSubscribe(e){return this.#r.catchupAndSubscribe(e)}subscribeAnyChange(e){return this.#t.subscribe(e)}terminate(){this.#r.terminate(),this.#s.terminate(),this.#i.forEach(({subscription:e})=>e.terminate()),this.#i.clear()}};var Ve=class{type="bus";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}catchupAndSubscribe(e){return e(this),this.#t.subscribe(Q.Children,()=>e(this))}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get iconField(){return this.#t.icon}get labelField(){return this.#t.label}get colorField(){return this.#t.color}get iconSymbol(){return we.fromName(this.iconField.getValue()??"audio-bus")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.output.targetVertex.unwrap("No AudioUnitBox found").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}toString(){return`{${this.constructor.name}}`}};var Ys=class{#e;#t;#r;#i;#s=U.Empty;constructor(e,t){this.#e=new D,this.#t=this.#e.own(new q),this.#r=this.#e.own(new Ce(we.Unknown)),this.#i=this.#e.own(new Ce(p.None)),this.#e.own(this.#i.subscribe(r=>{this.#s.terminate(),this.#s=r.getValue().match({none:()=>(this.#t.notify(p.None),U.Empty),some:({labelField:s,iconField:o})=>U.many(o.catchupAndSubscribe(n=>this.#r.setValue(we.fromName(n.getValue()))),s.catchupAndSubscribe(n=>this.#t.notify(p.wrap(n.getValue()))))})})),this.#e.own(e.catchupAndSubscribeTransactual({onAdd:({box:r})=>{v(this.#i.getValue().isEmpty(),"Already set");let s=r instanceof Ir?t.adapterFor(r,Ve):t.adapterFor(r,j.isInstrument);this.#i.getValue().unwrapOrNull()!==s&&this.#i.setValue(p.wrap(s))},onRemove:({box:r})=>{v(this.#i.getValue().unwrap("Cannot remove").box.address.equals(r.address),"Unexpected value to remove"),this.#i.setValue(p.None)}},u.InstrumentHost,u.AudioOutput))}getValue(){return this.#i.getValue()}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.#i),this.subscribe(e)}catchupAndSubscribeLabelChange(e){return e(this.label),this.#t.subscribe(e)}catchupAndSubscribeIconChange(e){return this.#r.catchupAndSubscribe(e)}set label(e){this.getValue().ifSome(t=>t.labelField.setValue(e))}get label(){return this.getValue().map(e=>e.labelField.getValue())}set icon(e){this.getValue().ifSome(t=>t.iconField.setValue(we.toName(e)))}get icon(){return this.getValue().match({none:()=>we.Unknown,some:e=>we.fromName(e.iconField.getValue())})}get iconValue(){return this.#r}terminate(){this.#e.terminate(),this.#s.terminate()}};var re=class{#e;#t;constructor(e){this.#e=e,this.#t=new wt(t=>t.address.fieldKeys,_n)}terminate(){this.#t.forEach(e=>e.terminate()),this.#t.clear()}parameters(){return this.#t.values()}parameterAt(e){return this.#t.getOrThrow(e,()=>new Error(`No ParameterAdapter found at [${e}]`))}createParameter(e,t,r,s,o){let n=new fr(this.#e,e,t,r,s,o),a=this.#t.add(n);return v(a,`Could not add adapter for ${e}`),n}removeParameter(e){this.#t.removeByValue(e)}};var Kr=class{#e;#t;#r;#i;#s;#o;#n=U.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new D,this.#i=this.#r.own(new q),this.#r.own(t.targetBus.catchupAndSubscribe(()=>{this.#n.terminate(),this.#n=this.optTargetBus.match({none:()=>(this.#i.notify(p.None),U.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(p.wrap(s)))})})),this.#s=this.#r.own(new fr(this.#e,this.#t.sendPan,R.bipolar(),C.percent({unit:"%",fractionDigits:0}),"panning")),this.#o=this.#r.own(new fr(this.#e,this.#t.sendGain,R.DefaultDecibel,C.numeric({unit:"dB",fractionDigits:1}),"gain"))}catchupAndSubscribeBusChanges(e){return e(this.optTargetBus),this.#i.subscribe(e)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get indexField(){return this.#t.index}get sendPan(){return this.#s}get sendGain(){return this.#o}get targetBus(){return this.#e.boxAdapters.adapterFor(this.#t.targetBus.targetVertex.unwrap("no audioUnit").box,Ve)}get optTargetBus(){return this.#t.targetBus.targetVertex.flatMap(e=>p.wrap(e.box.accept({visitAudioBusBox:t=>this.#e.boxAdapters.adapterFor(t,Ve)})))}delete(){this.#t.delete()}terminate(){this.#r.terminate(),this.#n.terminate()}};var Xs=class{#e;#t;#r;#i;#s=U.Empty;constructor(e,t){this.#e=e,this.#t=t,this.#r=new D,this.#i=this.#r.own(new q),this.#r.own(e.catchupAndSubscribe(()=>{this.#s.terminate(),this.#s=this.adapter.match({none:()=>(this.#i.notify(p.None),U.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(p.wrap(s)))})}))}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.adapter),this.subscribe(e)}get adapter(){return this.#e.targetVertex.flatMap(e=>p.wrap(e.box.accept({visitAudioBusBox:t=>this.#t.adapterFor(t,Ve)})))}terminate(){this.#r.terminate(),this.#s.terminate()}};var rt=class i{static VolumeMapper=R.decibel(-96,-9,6);class="device-host";#e=new D;#t;#r;#i;#s;#o;#n;#a;#l;#u;namedParameter;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new re(this.#t)),this.#s=this.#e.own(new Qs(this,this.#t.boxAdapters)),this.#o=this.#e.own(new Ys(this.#r.input.pointerHub,this.#t.boxAdapters)),this.#n=this.#e.own(Be.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,j.isMidiEffect),u.MidiEffectHost)),this.#a=this.#e.own(Be.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,j.isAudioEffect),u.AudioEffectHost)),this.#l=this.#e.own(Be.create(this.#r.auxSends,r=>this.#t.boxAdapters.adapterFor(r,Kr),u.AuxSend)),this.#u=this.#e.own(new Xs(this.#r.output,this.#t.boxAdapters)),this.namedParameter=this.#c(t),this.#h()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get type(){return this.#r.type.getValue()}get captureBox(){return this.#r.capture.targetVertex}get tracks(){return this.#s}get input(){return this.#o}get midiEffects(){return this.#n}get audioEffects(){return this.#a}get inputAdapter(){return this.#o.getValue()}get auxSends(){return this.#l}get output(){return this.#u}get isBus(){return this.input.getValue().mapOr(e=>e.type==="bus",!1)}get isInstrument(){return this.input.getValue().mapOr(e=>e.type==="instrument",!1)}get isOutput(){return this.#r.output.targetVertex.mapOr(e=>e.box.address.equals(this.#t.rootBoxAdapter.address),!1)}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.#r.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.#r.tracks}get minimizedField(){return this.#o.getValue().unwrap().minimizedField}get isAudioUnit(){return!0}get label(){return this.#o.getValue().mapOr(e=>e.labelField.getValue(),"")}audioUnitBoxAdapter(){return this}indicesLimit(){let e=this.#t.rootBoxAdapter.audioUnits.adapters(),t=this.indexField.getValue(),r=this.type,s=t,o=t;for(;s>0&&e[s-1].type===r;)s--;for(;o<e.length-1&&e[o+1].type===r;)o++;return[s,o+1]}move(e){this.#t.rootBoxAdapter.audioUnits.move(this,e)}moveTrack(e,t){this.#s.collection.move(e,t)}deleteTrack(e){this.#s.delete(e)}toString(){return`{${this.constructor.name}}`}terminate(){this.#e.terminate()}#c(e){return{volume:this.#i.createParameter(e.volume,i.VolumeMapper,C.decible,"volume"),panning:this.#i.createParameter(e.panning,R.bipolar(),C.panning,"panning",.5),mute:this.#i.createParameter(e.mute,R.bool,C.bool,"mute"),solo:this.#i.createParameter(e.solo,R.bool,C.bool,"solo")}}#h(){let e=this.address.toString(),t=this.#r.capture.targetAddress.unwrapOrUndefined(),r=()=>`AudioUnit '${e}' must have a capture. AudioUnit is typed ${this.type} and has input ${this.#r.input.pointerHub.incoming().at(0)?.box.name}, but capture is ${t}`;v(this.type!==hr.Instrument||this.#r.capture.targetAddress.nonEmpty(),r)}};var Js=G.fromSignature(1,384);var me=class{#e;#t;#r;#i;#s;#o;constructor(e,t){this.#e=e,this.#t=t,this.#r=new D,this.#i=this.#r.own(new Gs(this,e.boxAdapters)),this.#s=this.#r.own(new Ws(this,e.boxAdapters)),this.#o=this.#r.own(new Ce(-1))}catchupAndSubscribePath(e){let t=[p.None,p.None],r=()=>{t.every(s=>s.nonEmpty())?e(p.wrap(t.map(s=>s.unwrap()))):e(p.None)};return U.many(this.#n(s=>{t[0].equals(s)||(t[0]=s,r())}),this.#a(s=>{t[1].equals(s)||(t[1]=s,r())}))}set targetDeviceName(e){this.#t.target.targetVertex.ifSome(t=>{let r=t.box;if(r instanceof Ye)return this.#e.boxAdapters.adapterFor(r,rt).input.getValue().ifSome(({labelField:o})=>o.setValue(e));if("label"in r&&r.label instanceof V)return r.label.setValue(e)})}get targetDeviceName(){return this.#t.target.targetVertex.flatMap(e=>{let t=e.box;return t instanceof Ye?this.#e.boxAdapters.adapterFor(t,rt).input.label:"label"in t&&t.label instanceof V?p.wrap(t.label.getValue()):p.wrap(t.name)})}#n(e){let t=this.#t.target.targetVertex;if(t.nonEmpty()){let r=t.unwrap().box;return r instanceof Ye?this.#e.boxAdapters.adapterFor(r,rt).input.catchupAndSubscribeLabelChange(o=>e(o)):"label"in r&&r.label instanceof V?r.label.catchupAndSubscribe(s=>e(p.wrap(s.getValue()))):(e(p.wrap(r.name)),U.Empty)}return e(p.None),U.Empty}#a(e){let t=this.type;switch(t){case Z.Audio:case Z.Notes:return e(p.wrap(Z[t])),U.Empty;case Z.Value:{let r=this.#t.target.targetVertex.unwrap();if(r.isField())e(this.#e.parameterFieldAdapters.opt(r.address).map(s=>s.name));else if(r.isBox())e(p.wrap(r.name));else return g("Illegal State. Vertex is not a field nor box.");return U.Empty}case Z.Undefined:return e(p.wrap("")),U.Empty;default:return e(p.None),U.Empty}}terminate(){this.#r.terminate()}get audioUnit(){return er(this.#t.tracks.targetVertex.unwrap().box,Ye)}get target(){return this.#t.target}get clips(){return this.#i}get regions(){return this.#s}get enabled(){return this.#t.enabled}get indexField(){return this.#t.index}get type(){return this.#t.type.getValue()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get listIndex(){return this.#o.getValue()}set listIndex(e){this.#o.setValue(e)}accepts(e){switch(e.type){case"audio-clip":return this.type===Z.Audio;case"note-clip":return this.type===Z.Notes;case"value-clip":return this.type===Z.Value;case"audio-region":return this.type===Z.Audio;case"note-region":return this.type===Z.Notes;case"value-region":return this.type===Z.Value}}valueAt(e,t){if(!this.enabled.getValue())return t;let r=t,s=this.#e.clipSequencing.iterate(this.uuid,e,e+Js);for(let{optClip:o,sectionFrom:n}of s)r=o.match({none:()=>{let a=this.regions.collection.lowerEqual(e,l=>!l.mute);if(a===null){let l=this.regions.collection.optAt(0);return ae(l,ft)?l.incomingValue(t):t}else if(ae(a,ft))return e<a.complete?a.valueAt(e,t):a.outgoingValue(t);return t},some:a=>n===e&&ae(a,Ot)?a.valueAt(e,t):t});return r}};var Ma=[u.Automation,u.Modulation,u.MidiControl,u.ParameterController],fr=class{#e;#t;#r;#i;#s;#o;#n=new D;#a;#l;#u=p.None;#c=p.None;#h=null;#d=!1;constructor(e,t,r,s,o,n){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o,this.#o=n??0,this.#n.own(this.#e.parameterFieldAdapters.register(this)),this.#a=this.#n.own(new q),this.#l=new ve,this.#n.own(this.#t.subscribe(()=>this.#a.notify(this))),this.#n.own(this.#t.pointerHub.catchupAndSubscribeTransactual({onAdd:a=>{this.#l.proxy.onControlSourceAdd(En(a.pointerType)),a.box.accept({visitTrackBox:l=>{v(this.#u.isEmpty(),"Already assigned");let c=this.#e.boxAdapters.adapterFor(l,me);this.#u=p.wrap(c),this.#e.isMainThread&&(this.#c=p.wrap(this.#e.liveStreamReceiver.subscribeFloat(this.#t.address,d=>{this.#h!==d&&(this.#h=d,this.#a.notify(this))})))}})},onRemove:a=>{this.#l.proxy.onControlSourceRemove(En(a.pointerType)),a.box.accept({visitTrackBox:l=>{v(this.#u.unwrapOrNull()?.address?.equals(l.address)===!0,`Unknown ${l}`),this.#u=p.None,this.#e.isMainThread&&(this.#c.ifSome(c=>c.terminate()),this.#c=p.None,this.#h=null,this.#a.notify(this))}})}},...Ma)),t.getValue()!==r.clamp(t.getValue())&&console.warn(`${o} (${t.getValue()}) is out of bounds`,r)}registerMidiControl(){return this.#l.proxy.onControlSourceAdd("midi"),this.#d=!0,{terminate:()=>{this.#d=!1,this.#l.proxy.onControlSourceRemove("midi")}}}get field(){return this.#t}get valueMapping(){return this.#r}get stringMapping(){return this.#i}get name(){return this.#s}get anchor(){return this.#o}get type(){return this.#t.type}get address(){return this.#t.address}get track(){return this.#u}valueAt(e){let t=this.#u;if(t.nonEmpty()){let r=t.unwrap();if(r.enabled)return this.valueMapping.y(r.valueAt(e,this.getUnitValue()))}return this.getValue()}subscribe(e){return this.#a.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}catchupAndSubscribeControlSources(e){return this.#d&&e.onControlSourceAdd("midi"),this.#t.pointerHub.filter(...Ma).forEach(t=>e.onControlSourceAdd(En(t.pointerType))),this.#l.subscribe(e)}getValue(){return this.#t.getValue()}setValue(e){this.#t.setValue(e)}setUnitValue(e){this.setValue(this.#r.y(e))}getUnitValue(){return this.#r.x(this.getValue())}getControlledValue(){return this.#r.y(this.getControlledUnitValue())}getControlledUnitValue(){return this.#h??this.getUnitValue()}getControlledPrintValue(){return this.#i.x(this.getControlledValue())}getPrintValue(){return this.#i.x(this.getValue())}setPrintValue(e){let t=this.#i.y(e);t.type==="unitValue"?this.setUnitValue($(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#r.clamp(this.#t.initValue))}terminate(){this.#c.ifSome(e=>e.terminate()),this.#c=p.None,this.#n.terminate()}},En=i=>{switch(i){case u.Automation:return"automated";case u.Modulation:return"modulated";case u.MidiControl:return"midi";case u.ParameterController:return"external";default:return g(`${i.toString()} is an unknown pointer type`)}};var Zs=class{#e;#t;#r;constructor(e,t,r){this.#e=A.newSet(s=>s.uuid),this.#t=new ve,this.#r=e.catchupAndSubscribeTransactual({onAdd:s=>{let o=t(s.box),n=this.#e.add(o);v(n,`Could not add ${o}`),this.#t.proxy.onAdd(o)},onRemove:s=>{let o=s.box.address.uuid;this.#t.proxy.onRemove(this.#e.removeByKey(o))}},r)}subscribe(e){return this.#t.subscribe(e)}catchupAndSubscribe(e){return this.#e.forEach(t=>e.onAdd(t)),this.subscribe(e)}adapters(){return this.#e.values()}size(){return this.#e.size()}isEmpty(){return this.size()===0}terminate(){this.#e.clear(),this.#t.terminate(),this.#r.terminate()}};var gt=class i{static OffsetFractions=je.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static OffsetStringMapping=C.indices("",this.OffsetFractions.map(([e,t])=>`${e}/${t}`));type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{delay:this.#r.createParameter(e.delay,R.linearInteger(0,i.OffsetFractions.length-1),i.OffsetStringMapping,"delay"),feedback:this.#r.createParameter(e.feedback,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"feedback"),cross:this.#r.createParameter(e.cross,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"cross"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter",.5),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var Lr=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{decay:this.#r.createParameter(e.decay,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"Room-Size"),preDelay:this.#r.createParameter(e.preDelay,R.exponential(.001,.5),C.numeric({unit:"s",fractionDigits:1,unitPrefix:!0}),"Pre-Delay"),damp:this.#r.createParameter(e.damp,R.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"damping"),filter:this.#r.createParameter(e.filter,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter"),dry:this.#r.createParameter(e.dry,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var $r=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get spectrum(){return this.#t.address.append(4095)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{highPass:Ta(this.#r,e.highPass,"High-Pass"),lowShelf:Va(this.#r,e.lowShelf,"Low-Shelf"),lowBell:Bn(this.#r,e.lowBell,"Low-Bell"),midBell:Bn(this.#r,e.midBell,"Mid-Bell"),highBell:Bn(this.#r,e.highBell,"High-Bell"),highShelf:Va(this.#r,e.highShelf,"High-Shelf"),lowPass:Ta(this.#r,e.lowPass,"Low-Pass")}}},Fn=R.exponential(20,2e4),Da=R.linear(-24,24),Ia=R.exponential(.01,10),Ta=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Fn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),order:i.createParameter(e.order,R.linearInteger(1,4),C.indices("db",["12","24","36","48"]),`${t} Order`),q:i.createParameter(e.q,Ia,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)}),Va=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Fn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Da,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5)}),Bn=(i,e,t)=>({enabled:i.createParameter(e.enabled,R.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Fn,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Da,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5),q:i.createParameter(e.q,Ia,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)});var gr=class{static Comparator=(e,t)=>e.position-t.position;type="marker-event";#e=new D;#t;#r;constructor(e,t){this.#t=e,this.#r=t,this.#e.own(this.#r.subscribe(Q.Children,r=>{if(!this.trackAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackAdapter.unwrap();this.#r.position.address.equals(r.address)?s.onSortingChanged():s.dispatchChange()}}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get plays(){return this.#r.plays.getValue()}get hue(){return this.#r.hue.getValue()}get label(){return this.#r.label.getValue()}get trackAdapter(){return this.#r.track.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,it).markerTrack)}terminate(){this.#e.terminate()}toString(){return`{MarkerBoxAdapter ${A.toString(this.#r.address.uuid).substring(0,4)}, plays: ${this.plays}`}};var eo=class{#e;#t;changeNotifier;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.changeNotifier=new q,this.#r=A.newSet(r=>r.uuid),this.#i=Ft.create(gr.Comparator),this.#s=this.#t.markers.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{if(r instanceof Dr){let s=this.#e.boxAdapters.adapterFor(r,gr),o=this.#r.add(s);v(o,"Could not add adapter"),this.#i.add(s),this.dispatchChange()}},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#r.removeByKey(r)),this.dispatchChange()}})}subscribe(e){return this.changeNotifier.subscribe(e)}get context(){return this.#e}get enabled(){return this.#t.enabled.getValue()}get events(){return this.#i}get object(){return this.#t}dispatchChange(){this.changeNotifier.notify()}onSortingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}terminate(){this.#s.terminate()}};var it=class{#e;#t;constructor(e,t){this.#e=t,this.#t=new eo(e,this.#e.markerTrack)}terminate(){}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get markerTrack(){return this.#t}};var Lt=class{#e;constructor(e,t){this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get source(){return this.#e.source.targetVertex.unwrap("Insufficient Vertex")}get target(){return this.#e.target.targetVertex.unwrap("Insufficient Vertex")}terminate(){}};var qe=class{#e;#t;#r;#i;#s;#o=!1;constructor(e,t){this.#e=e,this.#t=t,this.#r=new D,this.#i=t.attributes,this.#s=this.#r.own(new re(e))}get inputs(){throw new Error("Method not implemented.")}get outputs(){throw new Error("Method not implemented.")}own(e){return this.#r.own(e)}ownAll(...e){this.#r.ownAll(...e)}onSelected(){this.#o=!0}onDeselected(){this.#o=!1}isSelected(){return this.#o}get box(){return this.#t}get attributes(){return this.#i}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get parameters(){return this.#s}get modular(){return this.#e.boxAdapters.adapterFor(this.#t.attributes.collection.targetVertex.unwrap().box,$t)}terminate(){this.#r.terminate()}};var Ne;(function(i){i.Input="input",i.Output="output"})(Ne||(Ne={}));var Pe=class i{static create(e,t,r,s){return new i(e,t,r,s??t.fieldName)}#e;#t;#r;#i;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#r=r,this.#i=s}matches(e){return this.direction!==e.direction&&this.field.pointerRules.accepts.some(t=>e.field.pointerRules.accepts.some(r=>r===t))}get connections(){return this.#t.pointerHub.isEmpty()?w.empty():this.#t.pointerHub.filter(u.VoltageConnection).map(({box:e})=>this.#e.adapterFor(e,Lt))}get field(){return this.#t}get address(){return this.#t.address}get direction(){return this.#r}get name(){return this.#i}toString(){return`{ModuleConnectorAdapter address: ${this.#t.address.toString()}, direction: ${this.#r}}`}};var qr=class extends qe{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.time,R.exponential(1,1e4),C.numeric({unit:"ms"}),"Time"),this.#t=Pe.create(e.boxAdapters,t.voltageInput,Ne.Input,"Input"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Output")}get parameterTime(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var zr=class extends qe{#e;constructor(e,t){super(e,t),this.#e=Pe.create(e.boxAdapters,t.input,Ne.Input,"Input")}get voltageInput(){return this.#e}get inputs(){return[this.#e]}get outputs(){return w.empty()}};var _r=class extends qe{#e;#t;#r;constructor(e,t){super(e,t),this.#e=this.parameters.createParameter(t.gain,R.DefaultDecibel,C.numeric({unit:"db"}),"Gain"),this.#t=Pe.create(e.boxAdapters,t.voltageInput,Ne.Input,"Input"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Output")}get parameterGain(){return this.#e}get voltageInput(){return this.#t}get voltageOutput(){return this.#r}get inputs(){return[this.#t]}get outputs(){return[this.#r]}};var Hr=class extends qe{#e;#t;#r;constructor(e,t){super(e,t),this.#e=Pe.create(e.boxAdapters,t.voltageInputX,Ne.Input,"X"),this.#t=Pe.create(e.boxAdapters,t.voltageInputY,Ne.Input,"Y"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Result")}get inputs(){return[this.#e,this.#t]}get outputs(){return[this.#r]}};var Gr=class extends qe{#e;constructor(e,t){super(e,t),this.#e=Pe.create(e.boxAdapters,t.output,Ne.Output,"Output")}get voltageOutput(){return this.#e}get inputs(){return w.empty()}get outputs(){return[this.#e]}};var Wr;(function(i){i.isVertexOfModule=e=>e.box.accept({visitModuleGainBox:()=>!0,visitModuleDelayBox:()=>!0,visitModuleMultiplierBox:()=>!0,visitModularAudioInputBox:()=>!0,visitModularAudioOutputBox:()=>!0})??!1,i.adapterFor=(e,t)=>k(t.accept({visitModuleGainBox:r=>e.adapterFor(r,_r),visitModuleDelayBox:r=>e.adapterFor(r,qr),visitModuleMultiplierBox:r=>e.adapterFor(r,Hr),visitModularAudioInputBox:r=>e.adapterFor(r,Gr),visitModularAudioOutputBox:r=>e.adapterFor(r,zr)}),`Could not find ModuleAdapter for ${t.name}`)})(Wr||(Wr={}));var jr=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get moduleAdapter(){return Wr.adapterFor(this.#e.boxAdapters,this.#r.box)}get parameterAdapter(){return this.moduleAdapter.parameters.parameterAt(this.#r.address.fieldKeys)}get#r(){return this.#t.parameter.targetVertex.unwrap("Parameter not assigned")}terminate(){}};var qt=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return g("Not yet implemented")}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}modular(){return this.#e.boxAdapters.adapterFor(this.#t.modularSetup.targetVertex.unwrap("No Modular found").box,$t)}elements(){return this.#t.userInterface.elements.pointerHub.filter(u.DeviceUserInterface).map(e=>this.#e.boxAdapters.adapterFor(e.box,jr))}terminate(){}};var $t=class{#e=new D;#t;#r;#i;#s;#o;constructor(e,t){this.#r=e,this.#i=t,this.#t=this.#e.own(new ve),this.#s=A.newSet(a=>a.uuid),this.#o=A.newSet(a=>a.uuid);let r=a=>{let l=Wr.adapterFor(this.#r.boxAdapters,a.box);this.#s.add(l)&&this.#t.proxy.onModuleAdded(l)},s=a=>this.#t.proxy.onModuleRemoved(this.#s.removeByKey(a.address.uuid)),o=a=>{let l=this.#r.boxAdapters.adapterFor(a.box,Lt);this.#o.add(l)&&this.#t.proxy.onConnectionAdded(l)},n=a=>this.#t.proxy.onConnectionRemoved(this.#o.removeByKey(a.address.uuid));this.#i.modules.pointerHub.filter(u.ModuleCollection).forEach(r),this.#i.connections.pointerHub.filter(u.ConnectionCollection).forEach(o),this.#e.own(this.#i.modules.pointerHub.subscribeTransactual({onAdd:r,onRemove:s},u.ModuleCollection)),this.#e.own(this.#i.connections.pointerHub.subscribeTransactual({onAdd:o,onRemove:n},u.ConnectionCollection))}catchupAndSubscribe(e){return tn(e.onModuleAdded,t=>this.#s.forEach(r=>t(r))),tn(e.onConnectionAdded,t=>this.#o.forEach(r=>t(r))),this.#t.subscribe(e)}get box(){return this.#i}get address(){return this.#i.address}get uuid(){return this.#i.address.uuid}get editingField(){return this.#i.editing}get labelField(){return this.#i.label}get modules(){return this.#s.values()}get connections(){return this.#o.values()}get device(){return this.#r.boxAdapters.adapterFor(k(this.#i.device.pointerHub.incoming().at(0),"No device found").box,qt)}terminate(){console.debug(`terminate ${this}`),this.#e.terminate()}};var Qr=class i{static Durations=[[1,8],[1,4],[1,4],[1,2],[1,1],[2,1],[4,1],[8,1],[16,1]];static DurationPPQNs=i.Durations.map(([e,t])=>G.fromSignature(e,t));static DurationStrings=i.Durations.map(([e,t])=>`${e}/${t}`);type="groove-adapter";#e=new D;#t;#r;#i;namedParameter;#s=new Gi({duration:()=>this.#n,fx:e=>ln(e,this.#o),fy:e=>ln(e,1-this.#o)});#o=0;#n=G.SemiQuaver*2;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(new re(this.#t)),this.namedParameter=this.#a(t),this.#e.ownAll(this.namedParameter.duration.catchupAndSubscribe(r=>this.#n=r.getValue()),this.namedParameter.amount.catchupAndSubscribe(r=>this.#o=Hn(r.getValue(),.01)))}unwarp(e){return this.#s.unwarp(e)}warp(e){return this.#s.warp(e)}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#e.terminate()}#a(e){return{duration:this.#i.createParameter(e.duration,R.values(i.DurationPPQNs),C.values("",i.DurationPPQNs,i.DurationStrings),"duration"),amount:this.#i.createParameter(e.amount,R.unipolar(),C.percent({fractionDigits:0}),"amount")}}};var zt=class{#e;#t;#r;#i;#s;#o=new D;#n;#a=p.None;constructor(e,t,r,s,o){this.#e=e,this.#t=t,this.#r=r,this.#i=s,this.#s=o??0,this.#n=this.#o.own(new q),this.#o.own(this.#e.subscribe(()=>this.#n.notify(this))),e.getValue()!==t.clamp(e.getValue())&&console.warn(`${s} (${e.getValue()}) is out of bounds`,t)}get field(){return this.#e}get valueMapping(){return this.#t}get stringMapping(){return this.#r}get name(){return this.#i}get anchor(){return this.#s}get type(){return this.#e.type}get address(){return this.#e.address}get track(){return this.#a}subscribe(e){return this.#n.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}getValue(){return this.#e.getValue()}setValue(e){this.#e.setValue(this.#t.clamp(e))}setUnitValue(e){this.setValue(this.#t.y(e))}getUnitValue(){return this.#t.x(this.getValue())}getPrintValue(){return this.#r.x(this.getValue())}setPrintValue(e){let t=this.#r.y(e);t.type==="unitValue"?this.setUnitValue($(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#t.clamp(this.#e.initValue))}terminate(){this.#o.terminate()}};var to=class{#e;#t;#r;#i;#s;#o;constructor(e){this.#e=e,this.#t=new zt(this.#e.keyboard,R.values([88,76,61,49]),C.numeric({fractionDigits:1}),"Keyboard Type"),this.#r=new zt(this.#e.timeRangeInQuarters,R.exponential(1,64),C.numeric({fractionDigits:1}),"Time-Range"),this.#i=new zt(this.#e.noteScale,R.exponential(.5,2),C.numeric({fractionDigits:1}),"Note Scale"),this.#s=new zt(this.#e.noteLabels,R.bool,C.bool,"Note Labels"),this.#o=new zt(this.#e.transpose,R.linearInteger(-48,48),C.numeric({fractionDigits:0}),"Transpose")}subscribe(e){return this.#e.box.subscribe(Q.Children,()=>e(this))}get object(){return this.#e}get keyboard(){return this.#t}get timeRangeInQuarters(){return this.#r}get noteScale(){return this.#i}get noteLabels(){return this.#s}get transpose(){return this.#o}};var Yr=class{#e;#t;#r;#i;#s;constructor(e,t){this.#e=e,this.#t=t,this.#r=Be.create(this.#t.audioUnits,r=>this.#e.boxAdapters.adapterFor(r,rt),u.AudioUnits),this.#i=new Zs(this.#t.audioBusses.pointerHub,r=>this.#e.boxAdapters.adapterFor(r,Ve),u.AudioBusses),this.#s=new to(this.#t.pianoMode)}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get box(){return this.#t}get audioBusses(){return this.#i}get audioUnits(){return this.#r}get clips(){return this.#r.adapters().flatMap(e=>e.tracks.collection.adapters()).flatMap(e=>e.clips.collection.adapters())}get groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,Qr)}get timeline(){return this.#e.boxAdapters.adapterFor(this.#t.timeline.targetVertex.unwrap("no timeline").box,it)}get pianoMode(){return this.#s}get created(){return new Date(this.#t.created.getValue())}terminate(){this.#r.terminate()}};var Xr=class{type="instrument";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return Z.Audio}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!1}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{flutter:this.#r.createParameter(e.flutter,R.unipolar(),C.percent(),"flutter"),wow:this.#r.createParameter(e.wow,R.unipolar(),C.percent(),"wow"),noise:this.#r.createParameter(e.noise,R.unipolar(),C.percent(),"noise"),saturation:this.#r.createParameter(e.saturation,R.unipolar(),C.percent(),"saturation")}}};var Jr=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return Z.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),octave:this.#r.createParameter(e.octave,R.linearInteger(-3,3),C.numeric(),"octave",.5),tune:this.#r.createParameter(e.tune,R.linear(-1200,1200),C.numeric({unit:"cent",fractionDigits:0}),"tune",.5),waveform:this.#r.createParameter(e.waveform,R.linearInteger(0,3),C.indices("",["sine","triangle","sawtooth","square"]),"waveform"),cutoff:this.#r.createParameter(e.cutoff,R.exponential(20,18e3),C.numeric({unit:"Hz"}),"cutoff"),resonance:this.#r.createParameter(e.resonance,R.exponential(.1,20),C.numeric({unit:"q",fractionDigits:1}),"resonance"),attack:this.#r.createParameter(e.attack,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"attack"),release:this.#r.createParameter(e.release,R.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"release"),filterEnvelope:this.#r.createParameter(e.filterEnvelope,R.linear(-.5,.5),C.percent(),"filter env",.5)}}};var _t=class i{static RateFractions=je.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static RateStringMapping=C.indices("",this.RateFractions.map(([e,t])=>`${e}/${t}`));type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}parameterAt(e){return this.#r.parameterAt(e)}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{modeIndex:this.#r.createParameter(e.modeIndex,R.linearInteger(0,2),C.indices("",["Up","Down","UpDown"]),"mode"),numOctaves:this.#r.createParameter(e.numOctaves,R.linearInteger(1,5),C.numeric({unit:"",fractionDigits:0}),"Octaves"),rate:this.#r.createParameter(e.rateIndex,R.linearInteger(0,i.RateFractions.length-1),i.RateStringMapping,"Rate"),gate:this.#r.createParameter(e.gate,R.linear(0,2),C.percent({fractionDigits:0}),"Gate"),repeat:this.#r.createParameter(e.repeat,R.linearInteger(1,16),C.numeric({fractionDigits:0}),"Repeat"),velocity:this.#r.createParameter(e.velocity,R.bipolar(),C.percent({fractionDigits:0,bipolar:!1}),"Velocity")}}};var Zr=class{type="midi-effect";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{octaves:this.#r.createParameter(e.octaves,R.linearInteger(-7,7),C.numeric({unit:"oct",fractionDigits:0}),"octaves"),semiTones:this.#r.createParameter(e.semiTones,R.linearInteger(-36,36),C.numeric({unit:"st",fractionDigits:0}),"semi-tones"),cent:this.#r.createParameter(e.cents,R.linear(-50,50),C.numeric({unit:"cents",fractionDigits:1}),"cents")}}};var ei=class{type="instrument";accepts="midi";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return Z.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),release:this.#r.createParameter(e.release,R.exponential(.001,8),C.numeric({unit:"s",fractionDigits:3}),"release")}}};var ti=class{class="device-host";accepts=!1;type="instrument";#e=new D;#t;#r;#i;#s;#o;namedParameter;#n=p.None;constructor(e,t){this.#t=e,this.#r=t,this.#i=this.#e.own(Be.create(this.#r.midiEffects,r=>this.#t.boxAdapters.adapterFor(r,j.isMidiEffect),u.MidiEffectHost)),this.#s=this.#e.own(Be.create(this.#r.audioEffects,r=>this.#t.boxAdapters.adapterFor(r,j.isAudioEffect),u.AudioEffectHost)),this.#o=this.#e.own(new re(this.#t)),this.namedParameter=this.#a(t),this.#e.own(this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(({box:s})=>this.#t.boxAdapters.adapterFor(s,tt)),this.#n.unwrapOrNull()?.getOrCreateLoader()}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get peakAddress(){return this.#r.address.append(1001)}get indexField(){return this.#r.index}get gate(){return this.#r.gate.getValue()}get exclude(){return this.#r.exclude.getValue()}get label(){return`${this.device().labelField.getValue()} > ${this.#n.mapOr(e=>e.box.fileName.getValue(),"No file")}`}get iconField(){return this.#r.icon}get defaultTrackType(){return Z.Notes}get acceptsMidiEvents(){return!0}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.audioUnitBoxAdapter().box.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.audioUnitBoxAdapter().box.tracks}get isAudioUnit(){return!1}file(){return this.#n}fileUUID(){return this.#r.file.targetAddress.unwrap().uuid}resetParameters(){this.#r.mute.reset(),this.#r.solo.reset(),this.#r.exclude.reset(),this.#r.polyphone.reset(),this.#r.pitch.reset(),this.#r.attack.reset(),this.#r.release.reset(),this.#r.sampleStart.reset(),this.#r.sampleEnd.reset(),this.#r.gate.reset()}copyToIndex(e){Or.create(this.#r.graph,A.generate(),t=>{t.file.refer(this.#r.file.targetVertex.unwrap()),t.device.refer(this.#r.device.targetVertex.unwrap()),t.index.setValue(e),t.mute.setValue(this.#r.mute.getValue()),t.solo.setValue(this.#r.solo.getValue()),t.sampleStart.setValue(this.#r.sampleStart.getValue()),t.sampleEnd.setValue(this.#r.sampleEnd.getValue()),t.attack.setValue(this.#r.attack.getValue()),t.release.setValue(this.#r.release.getValue()),t.pitch.setValue(this.#r.pitch.getValue()),t.exclude.setValue(this.#r.exclude.getValue()),t.gate.setValue(this.#r.gate.getValue())})}get midiEffects(){return this.#i}get inputAdapter(){return p.wrap(this)}get audioEffects(){return this.#s}get labelField(){return this.#r.label}get enabledField(){return this.#r.enabled}get minimizedField(){return this.#r.minimized}device(){return this.#t.boxAdapters.adapterFor(this.#r.device.targetVertex.unwrap().box,Ht)}deviceHost(){return this.device().deviceHost()}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#e.terminate()}#a(e){return{gate:this.#o.createParameter(e.gate,R.linearInteger(0,2),C.indices("",["Off","On","Loop"]),"Gate"),mute:this.#o.createParameter(e.mute,R.bool,C.bool,"Mute"),solo:this.#o.createParameter(e.solo,R.bool,C.bool,"Solo"),polyphone:this.#o.createParameter(e.polyphone,R.bool,C.bool,"Polyphone"),exclude:this.#o.createParameter(e.exclude,R.bool,C.bool,"Exclude"),pitch:this.#o.createParameter(e.pitch,R.linear(-1200,1200),C.numeric({unit:"cents",bipolar:!0,fractionDigits:0}),"Pitch",0),sampleStart:this.#o.createParameter(e.sampleStart,R.unipolar(),C.percent(),"Start",0),sampleEnd:this.#o.createParameter(e.sampleEnd,R.unipolar(),C.percent(),"End",1),attack:this.#o.createParameter(e.attack,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Attack"),release:this.#o.createParameter(e.release,R.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Release")}}};var Ht=class{type="instrument";accepts="midi";#e;#t;#r;#i;constructor(e,t){this.#e=e,this.#t=t,this.#r=Be.create(t.samples,r=>e.boxAdapters.adapterFor(r,ti),u.Sample),this.#i=new re(this.#e)}reset(){this.#r.adapters().forEach(e=>e.box.delete())}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get notesAddress(){return this.#t.address.append(1e3)}get labelField(){return this.#t.label}get iconField(){return this.#t.icon}get defaultTrackType(){return Z.Notes}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get acceptsMidiEvents(){return!0}get samples(){return this.#r}get context(){return this.#e}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#i.terminate()}};var ri=class{type="audio-effect";accepts="audio";#e;#t;#r;namedParameter;constructor(e,t){this.#e=e,this.#t=t,this.#r=new re(this.#e),this.namedParameter=this.#i(t)}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,R.decibel(-72,0,12),C.numeric({unit:"db",fractionDigits:1}),"Volume"),panning:this.#r.createParameter(e.panning,R.bipolar(),C.panning,"Panning",.5),stereo:this.#r.createParameter(e.stereo,R.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"stereo",.5),invertL:this.#r.createParameter(e.invertL,R.bool,C.bool,"Invert Left"),invertR:this.#r.createParameter(e.invertR,R.bool,C.bool,"Invert Right"),swap:this.#r.createParameter(e.swap,R.bool,C.bool,"Swap")}}};var xr;(function(i){i.checkType=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="groove-adapter"})(xr||(xr={}));var ii=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t,this.groove()}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}groove(){return this.#e.boxAdapters.adapterFor(this.#t.groove.targetVertex.unwrap("no groove").box,xr.checkType)}catchupAndSubscribeGroove(e){return this.#t.groove.catchupAndSubscribe(t=>e(this.#e.boxAdapters.adapterFor(t.targetVertex.unwrap("No groove found").box,xr.checkType)))}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var si=class{type="audio-effect";accepts="audio";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var oi=class{type="midi-effect";accepts="midi";#e;#t;constructor(e,t){this.#e=e,this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get indexField(){return this.#t.index}get labelField(){return this.#t.label}get enabledField(){return this.#t.enabled}get minimizedField(){return this.#t.minimized}get host(){return this.#t.host}get commentField(){return this.#t.comment}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#t.host.targetVertex.unwrap("no device-host").box,j.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var ro=class{#e;#t;#r;#i;constructor(e){this.#e=e,this.#t=A.newSet(t=>t.uuid),this.#r=new Set,this.#i=this.#e.boxGraph.subscribeToAllUpdates({onUpdate:t=>{if(t.type==="delete"){let r=this.#t.getOrNull(t.uuid);T(r)&&(this.#r.add(r.box),this.#t.removeByValue(r).terminate())}}})}terminate(){this.#t.values().forEach(e=>e.terminate()),this.#t.clear(),this.#i.terminate()}adapterFor(e,t){if(this.#r.has(e))return g(`Cannot resolve adapter for already deleted box: ${e}`);let r=this.#t.getOrNull(e.address.uuid);if(r===null){r=this.#s(e);let s=this.#t.add(r);v(s,`Could not add adapter for ${e}`)}return typeof t=="function"?Object.hasOwn(t,"prototype")?r instanceof t?r:g(`${r} is not instance of ${t}`):t(r)?r:g(`${r} did not pass custom type guard`):g("Unknown checkType method")}#s(e){return k(e.accept({visitRootBox:t=>new Yr(this.#e,t),visitArpeggioDeviceBox:t=>new _t(this.#e,t),visitPitchDeviceBox:t=>new Zr(this.#e,t),visitStereoToolDeviceBox:t=>new ri(this.#e,t),visitDelayDeviceBox:t=>new gt(this.#e,t),visitReverbDeviceBox:t=>new Lr(this.#e,t),visitRevampDeviceBox:t=>new $r(this.#e,t),visitUnknownAudioEffectDeviceBox:t=>new si(this.#e,t),visitPlayfieldDeviceBox:t=>new Ht(this.#e,t),visitPlayfieldSampleBox:t=>new ti(this.#e,t),visitModularDeviceBox:t=>new qt(this.#e,t),visitTapeDeviceBox:t=>new Xr(this.#e,t),visitNanoDeviceBox:t=>new ei(this.#e,t),visitVaporisateurDeviceBox:t=>new Jr(this.#e,t),visitModularBox:t=>new $t(this.#e,t),visitModuleConnectionBox:t=>new Lt(this.#e,t),visitModuleDelayBox:t=>new qr(this.#e,t),visitModuleGainBox:t=>new _r(this.#e,t),visitModuleMultiplierBox:t=>new Hr(this.#e,t),visitModularAudioInputBox:t=>new Gr(this.#e,t),visitModularAudioOutputBox:t=>new zr(this.#e,t),visitDeviceInterfaceKnobBox:t=>new jr(this.#e,t),visitAudioUnitBox:t=>new rt(this.#e,t),visitAudioBusBox:t=>new Ve(this.#e,t),visitAuxSendBox:t=>new Kr(this.#e,t),visitAudioFileBox:t=>new tt(this.#e,t),visitAudioClipBox:t=>new kt(this.#e,t),visitAudioRegionBox:t=>new Ut(this.#e,t),visitNoteEventBox:t=>new mr(this.#e,t),visitNoteEventCollectionBox:t=>new $e(this.#e,t),visitNoteClipBox:t=>new Ur(this.#e,t),visitNoteRegionBox:t=>new Kt(this.#e,t),visitValueEventBox:t=>new It(this.#e,t),visitValueEventCollectionBox:t=>new Le(this.#e,t),visitValueClipBox:t=>new Ot(this.#e,t),visitValueRegionBox:t=>new ft(this.#e,t),visitTrackBox:t=>new me(this.#e,t),visitTimelineBox:t=>new it(this.#e,t),visitMarkerBox:t=>new gr(this.#e,t),visitZeitgeistDeviceBox:t=>new ii(this.#e,t),visitUnknownMidiEffectDeviceBox:t=>new oi(this.#e,t),visitGrooveShuffleBox:t=>new Qr(this.#e,t)}),`Could not find factory for ${e}`)}};var Oa;(function(i){i.countStems=e=>e.match({none:()=>1,some:t=>Object.keys(t).length}),i.sanitizeFileName=e=>e.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").trim(),i.sanitizeExportNamesInPlace=e=>{let t=new Map,r=s=>{let o=t.get(s)??0,n=s;for(;t.has(n);)o++,n=`${s} ${o}`;return t.set(s,o),t.set(n,1),n};Object.keys(e).forEach(s=>{let o=e[s];o.fileName=r(i.sanitizeFileName(o.fileName))})}})(Oa||(Oa={}));var ka=Re.createBuilder({position:Re.float,playbackTimestamp:Re.float,countInBeatsRemaining:Re.float,countInBeatsTotal:Re.float,isPlaying:Re.bool,isCountingIn:Re.bool,isRecording:Re.bool});var st=class{#e=new D;#t;#r;#i;constructor(e,t){this.#t=e,this.#r=t,this.#i=new ye(128),this.#e.own(this.#t.broadcastIntegers(this.#r,new Int32Array(this.#i.buffer),nt))}noteOn(e){e>=0&&e<128&&this.#i.setBit(e,!0)}noteOff(e){e>=0&&e<128&&this.#i.setBit(e,!1)}reset(){}clear(){this.#i.clear()}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var xt;(function(i){i[i.MTHD=1297377380]="MTHD",i[i.MTRK=1297379947]="MTRK"})(xt||(xt={}));var Fe;(function(i){i[i.NOTE_ON=144]="NOTE_ON",i[i.NOTE_OFF=128]="NOTE_OFF",i[i.NOTE_AFTER_TOUCH=160]="NOTE_AFTER_TOUCH",i[i.CONTROLLER=176]="CONTROLLER",i[i.PROGRAM_CHANGE=192]="PROGRAM_CHANGE",i[i.CHANNEL_AFTER_TOUCH=208]="CHANNEL_AFTER_TOUCH",i[i.PITCH_BEND=224]="PITCH_BEND"})(Fe||(Fe={}));var io=class i{ticks;type;param0;param1;static Comparator=(e,t)=>e.ticks-t.ticks;constructor(e,t,r,s){this.ticks=e,this.type=t,this.param0=r,this.param1=s}static decode(e,t,r){switch(t){case Fe.NOTE_ON:case Fe.NOTE_OFF:case Fe.CONTROLLER:case Fe.PITCH_BEND:case Fe.NOTE_AFTER_TOUCH:return new i(r,t,e.readByte(),e.readByte());case Fe.PROGRAM_CHANGE:case Fe.CHANNEL_AFTER_TOUCH:return new i(r,t,e.readByte(),0)}{let s;do s=e.readByte()&255;while(s<128);e.skip(-1)}return null}accept(e){switch(this.type){case Fe.NOTE_ON:{this.param1===0?x(e.noteOff,this.param0):x(e.noteOn,this.param0,this.param1/127);break}case Fe.NOTE_OFF:{x(e.noteOff,this.param0);break}case Fe.PITCH_BEND:{let t=this.param0&127,r=this.param1&127,s=t|r<<7;x(e.pitchBend,8192>=s?s/8192-1:(s-8191)/8192);break}case Fe.CONTROLLER:{x(e.controller,this.param0,this.param1/127);break}default:break}}toString(){return`ControlEvent{ticks: ${this.ticks}, type: ${this.type}, param0: ${this.param0}, param1: ${this.param1}}`}};var xe;(function(i){i[i.SEQUENCE_NUMBER=0]="SEQUENCE_NUMBER",i[i.TEXT_EVENT=1]="TEXT_EVENT",i[i.COPYRIGHT_NOTICE=2]="COPYRIGHT_NOTICE",i[i.SEQUENCE_TRACK_NAME=3]="SEQUENCE_TRACK_NAME",i[i.INSTRUMENT_NAME=4]="INSTRUMENT_NAME",i[i.LYRICS=5]="LYRICS",i[i.MARKER=6]="MARKER",i[i.CUE_POINT=7]="CUE_POINT",i[i.CHANNEL_PREFIX=32]="CHANNEL_PREFIX",i[i.SET_TEMPO=81]="SET_TEMPO",i[i.SMPTE_OFFSET=84]="SMPTE_OFFSET",i[i.TIME_SIGNATURE=88]="TIME_SIGNATURE",i[i.KEY_SIGNATURE=89]="KEY_SIGNATURE",i[i.SEQUENCER_SPECIFIC=127]="SEQUENCER_SPECIFIC",i[i.PREFIX_PORT=33]="PREFIX_PORT",i[i.END_OF_TRACK=47]="END_OF_TRACK"})(xe||(xe={}));var so=class i{ticks;type;value;constructor(e,t,r){this.ticks=e,this.type=t,this.value=r}static decode(e,t){let r=e.readByte()&255,s=e.readVarLen();switch(r){case xe.SET_TEMPO:return new i(t,r,e.readTempo());case xe.TIME_SIGNATURE:return new i(t,r,e.readSignature());case xe.END_OF_TRACK:return new i(t,r,null);case xe.TEXT_EVENT:case xe.COPYRIGHT_NOTICE:case xe.SEQUENCE_TRACK_NAME:case xe.INSTRUMENT_NAME:case xe.LYRICS:case xe.MARKER:case xe.CUE_POINT:case xe.SEQUENCE_NUMBER:case xe.CHANNEL_PREFIX:case xe.KEY_SIGNATURE:case xe.SEQUENCER_SPECIFIC:case xe.PREFIX_PORT:case xe.SMPTE_OFFSET:default:e.skip(s)}return null}toString(){return`MetaEvent{ticks: ${this.ticks}, type: ${this.type}, value: ${this.value}}`}};var Gt;(function(i){let e;(function(t){t[t.NoteOn=144]="NoteOn",t[t.NoteOff=128]="NoteOff",t[t.PitchBend=224]="PitchBend",t[t.Controller=176]="Controller"})(e=i.Command||(i.Command={})),i.readCommand=t=>t[0]&240,i.readChannel=t=>t[0]&15,i.readParam1=t=>1<t.length?t[1]&255:0,i.readParam2=t=>2<t.length?t[2]&255:0,i.readPitch=t=>t[1],i.readVelocity=t=>t[2]/127,i.isNoteOn=t=>i.readCommand(t)===e.NoteOn&&i.readVelocity(t)>0,i.isNoteOff=t=>i.readCommand(t)===e.NoteOff||i.readCommand(t)===e.NoteOn&&i.readVelocity(t)===0,i.isPitchWheel=t=>i.readCommand(t)===e.PitchBend,i.asPitchBend=t=>{let r=i.readParam1(t)&127,s=i.readParam2(t)&127,o=r|s<<7;return 8192>=o?o/8192-1:(o-8191)/8192},i.isController=t=>i.readCommand(t)===e.Controller,i.asValue=t=>{let r=i.readParam2(t);return 64<r?.5+(r-63)/128:64>r?r/128:.5},i.noteOn=(t,r,s)=>{let o=new Uint8Array(3);return o[0]=t|e.NoteOn,o[1]=r|0,o[2]=s|0,o},i.noteOff=(t,r)=>{let s=new Uint8Array(3);return s[0]=t|e.NoteOff,s[1]=r,s},i.accept=(t,r)=>{if(!Zt(t))if(i.isNoteOn(t))x(r.noteOn,i.readPitch(t),i.readVelocity(t));else if(i.isNoteOff(t))x(r.noteOff,i.readPitch(t));else if(i.isPitchWheel(t)){let s=i.readParam1(t)&127,o=i.readParam2(t)&127,n=s|o<<7;x(r.pitchBend,8192>=n?n/8192-1:(n-8191)/8192)}else i.isController(t)&&x(r.controller,i.readParam1(t),i.readParam2(t)/127)},i.debug=t=>t===null?"null":i.isNoteOn(t)?`NoteOn #${i.readChannel(t)} ${i.readPitch(t)} : ${i.readVelocity(t).toFixed(2)}`:i.isNoteOff(t)?`NoteOff #${i.readChannel(t)} ${i.readPitch(t)}`:i.isPitchWheel(t)?`PitchWheel #${i.readChannel(t)} ${i.asPitchBend(t)}`:i.isController(t)?`Control #${i.readChannel(t)} ${i.asValue(t)}`:"Unknown"})(Gt||(Gt={}));var oo=class{tracks;formatType;timeDivision;constructor(e,t,r){this.tracks=e,this.formatType=t,this.timeDivision=r}};var no=class i{controlEvents;metaEvents;static decode(e){let t=new sr,r=[],s=0,o=0,n=0;for(;;){let a=e.readVarLen(),l=e.readByte()&255;if(l<240){s+=a,l<128?e.skip(-1):(o=l&240,n=l&15);let c=io.decode(e,o,s);T(c)&&t.add(n,c)}else if(l<248)e.skipSysEx(l);else{s+=a;let c=so.decode(e,s);if(c!==null&&(r.push(c),c.type===xe.END_OF_TRACK))break}}return new i(t,r)}static createEmpty(){return new i(new sr,[])}constructor(e,t){this.controlEvents=e,this.metaEvents=t}encode(){let e=de.create(),t=r=>{if(r<=127)e.writeByte(r);else{let s=r,o=[];for(o.push(s&127),s>>=7;s;){let n=s&127|128;o.push(n),s>>=7}o.reverse().forEach(n=>e.writeByte(n))}};return this.controlEvents.forEach((r,s)=>{let o=0,n=-1;s.forEach(a=>{let l=a.ticks-o;if(t(l),a.type===Fe.NOTE_ON){let c=144|r;c!==n&&e.writeByte(c),e.writeByte(a.param0),e.writeByte(a.param1)}else if(a.type===Fe.NOTE_OFF){let c=144|r;c!==n&&e.writeByte(c),e.writeByte(a.param0),e.writeByte(a.param1)}else console.warn("Unknown ControlType");o=a.ticks})}),e.toArrayBuffer()}};var ao=class{input;#e=!1;#t=!1;constructor(e){this.input=e}decode(){this.input.littleEndian=!1;let e=this.input.readInt();if(e===xt.MTHD){if(this.input.readInt()!==6)throw new Error("2nd int in header must be 6")}else throw console.warn(`Unsupported midi format ${e} !== ${xt.MTHD}`),new Error("Unsupported midi format");let t=this.input.readShort(),r=this.input.readShort(),s=this.input.readShort(),o=[];for(let n=0;n<r;n++){let a=this.input.readInt(),l=this.input.readInt(),c=this.input.position;a===xt.MTRK&&(o[n]=no.decode(this)),this.input.position=c+l}return 0<this.input.remaining()&&console.warn(`${this.input.remaining()} bytes remaining.`),new oo(o,t,s)}readVarLen(){let e=this.input.readByte()&255,t;if(0<(e&128)){e&=127;do t=this.input.readByte()&255,e=(e<<7)+(t&127);while(0<(t&128))}return e}readSignature(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255,s=this.input.readByte()&255;return this.#e,[e,1<<t]}readTempo(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255;return 6e7/(e<<16|t<<8|r)}skipSysEx(e){if(e===240){if(this.#t)throw new Error("System message already in progress");this.input.skip(this.readVarLen()-1),this.#t=!0}else e===247&&(this.#t?this.#t=!1:(this.input.skip(this.readVarLen()-1),this.#t=!0))}skip(e){this.input.skip(e)}readByte(){return this.input.readByte()}};var Ua;(function(i){i.decoder=t=>new ao(new ge(t)),i.encoder=()=>new e;class e{static writeVarLen(r,s){let o=[];for(;s>127;)o.push(s&127|128),s>>=7;o.push(s&127);for(let n=o.length-1;n>=0;n--)r.writeByte(o[n])}#e=[];addTrack(r){return this.#e.push(r),this}encode(){let r=de.create();return r.littleEndian=!1,r.writeInt(xt.MTHD),r.writeInt(6),r.writeShort(0),r.writeShort(this.#e.length),r.writeShort(96),this.#e.forEach(s=>{r.writeInt(xt.MTRK);let o=s.encode();r.writeInt(o.byteLength),r.writeBytes(new Int8Array(o))}),r}}})(Ua||(Ua={}));var lo=Symbol.for("@openDAW/lib-midi");globalThis[lo]?console.debug(`%c${lo.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[lo]=!0,console.debug(`%c${lo.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var Wt;(function(i){i.on=(e,t,r)=>({type:"note-on",uuid:e,pitch:t,velocity:r}),i.off=(e,t)=>({type:"note-off",uuid:e,pitch:t}),i.isOn=e=>e.type==="note-on",i.isOff=e=>e.type==="note-off",i.fromEvent=(e,t)=>{let r=e.data;if(Gt.isNoteOn(r)){let s=Gt.readPitch(r),o=Gt.readVelocity(r);return{type:"note-on",uuid:t,pitch:s,velocity:o}}else if(Gt.isNoteOff(r)){let s=Gt.readPitch(r);return{type:"note-off",uuid:t,pitch:s}}return g("Unknown MIDI event")}})(Wt||(Wt={}));var Ka;(function(i){i.start=(e,t,r,s=1)=>{let o=!0;return e(Wt.on(t,r,s)),{terminate:()=>{o&&(e(Wt.off(t,r)),o=!1)}}}})(Ka||(Ka={}));var uo=class{#e;constructor(){this.#e=W.newSet(e=>e.field.address)}register(e){return this.#e.add(e),{terminate:()=>this.#e.removeByValue(e)}}get(e){return this.#e.get(e)}opt(e){return this.#e.opt(e)}};var co;(function(i){i.reader=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s},o)=>{let n=!0,a=new Int32Array(e,0,2),l=new Float32Array(e,8),c=new Float32Array(r*s),d=typeof document>"u",m=()=>{if(!n)return;let f=Atomics.load(a,1),y=Atomics.load(a,0);if(f===y){if(d)Atomics.wait(a,0,y);else{setTimeout(m,1);return}y=Atomics.load(a,0)}for(;f!==y;){let F=f*r*s;c.set(l.subarray(F,F+r*s));let S=[];for(let M=0;M<r;M++){let K=M*s,L=K+s;S.push(c.slice(K,L))}if(f=(f+1)%t,Atomics.store(a,1,f),!n)return;o(S)}m()};return m(),{stop:()=>n=!1}},i.writer=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s})=>{let o=new Int32Array(e,0,2),n=new Float32Array(e,8);return Object.freeze({write:a=>{if(a.length!==r)return;for(let d of a)if(d.length!==s)return g("Each channel buffer must contain 'bufferSize' samples");let l=Atomics.load(o,0),c=l*r*s;a.forEach((d,m)=>n.set(d,c+m*s)),Atomics.store(o,0,(l+1)%t),Atomics.notify(o,0)}})}})(co||(co={}));var Nn={isClipBox:i=>i.accept({visitNoteClipBox:e=>!0,visitAudioClipBox:e=>!0,visitValueClipBox:e=>!0})??!1,isRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1,asRegionBox:i=>i.accept({visitNoteRegionBox:e=>e,visitAudioRegionBox:e=>e,visitValueRegionBox:e=>e})??g("Could not cast to AnyRegionBox"),isLoopableRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1};var Pn={isRegion:i=>Nn.isRegionBox(i.box),isLoopableRegion:i=>Nn.isLoopableRegionBox(i.box)};var ot;(function(i){i[i.Off=0]="Off",i[i.On=1]="On",i[i.Loop=2]="Loop"})(ot||(ot={}));var ho;(function(i){i.MAGIC_HEADER_OPEN=1330660686,i.FORMAT_VERSION=2,i.decode=t=>{let r=new ge(t);v(r.readInt()===i.MAGIC_HEADER_OPEN,"Corrupt header. Probably not an openDAW project file."),v(r.readInt()===i.FORMAT_VERSION,"Deprecated Format");let s=r.readInt(),o=new Int8Array(s);r.readBytes(o);let n=new es(p.wrap(os.create));return n.fromArrayBuffer(o.buffer),{boxGraph:n,mandatoryBoxes:e(n,r)}},i.findMandatoryBoxes=t=>{let r={};for(let s of t.boxes())s.accept({visitRootBox:o=>r.rootBox=o,visitTimelineBox:o=>r.timelineBox=o,visitUserInterfaceBox:o=>{let n=o.root.targetVertex.unwrapOrNull()?.box;ae(n,Sr)&&(r.userInterfaceBox=o)},visitAudioUnitBox:o=>{o.type.getValue()===hr.Output&&(r.masterAudioUnit=o)},visitAudioBusBox:o=>{let n=o.output.targetVertex.unwrapOrNull()?.box;ae(n,Ye)&&n.type.getValue()===hr.Output&&(r.masterBusBox=o)}});return v(r.rootBox!==void 0,"RootBox not found"),v(r.timelineBox!==void 0,"TimelineBox not found"),v(r.userInterfaceBox!==void 0,"UserInterfaceBox not found"),v(r.masterAudioUnit!==void 0,"MasterAudioUnit not found"),v(r.masterBusBox!==void 0,"MasterBusBox not found"),r};let e=(t,r)=>{let s=t.findBox(A.fromDataInput(r)).unwrap("RootBox not found"),o=t.findBox(A.fromDataInput(r)).unwrap("UserInterfaceBox not found"),n=t.findBox(A.fromDataInput(r)).unwrap("AudioBusBox not found"),a=t.findBox(A.fromDataInput(r)).unwrap("AudioUnitBox not found"),l=t.findBox(A.fromDataInput(r)).unwrap("TimelineBox not found");return{rootBox:s,userInterfaceBox:o,masterBusBox:n,masterAudioUnit:a,timelineBox:l}}})(ho||(ho={}));var La;(function(i){i.cut=(e,t,r)=>{if(!(e.position>=t||t>=e.complete))if(Pn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;e.box.duration.setValue(t-s),e.copyTo({position:t,duration:o-t,loopOffset:pi(n+(t-s),a),consolidate:r})}else return g("Not yet implemented")},i.clip=(e,t,r)=>{if(Pn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;if(o-r<=0)return g(`duration will zero or negative(${o-r})`);e.box.duration.setValue(t-s),e.copyTo({position:r,duration:o-r,loopOffset:pi(n+(r-s),a)})}else return g("Not yet implemented")}})(La||(La={}));var ni;(e=>e.create=(t,r,s,o)=>0|(t?1:0)|(r?2:0)|(s?4:0)|(o?8:0))(ni||={});var ie=class i{static Empty=new i(2);#e;constructor(e=2){this.#e=w.create(()=>new Float32Array(128),e)}clear(e,t){this.#e.forEach(r=>r.fill(0,e,t))}numChannels(){return this.#e.length}getChannel(e){return e<this.numChannels()?this.#e[e]:this.#e[this.numChannels()-1]}assertSanity(){v(!this.#e.some(e=>e.some(t=>isNaN(t))),"AudioBuffer is invalid (NaN)")}channels(){return this.#e}replace(e){this.replaceInto(e.#e)}replaceInto(e){v(e.length===2,"mixLayout: target.length must be 2"),v(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2"),this.#e.length===1?(e[0].set(this.#e[0]),e[1].set(this.#e[0])):(e[0].set(this.#e[0]),e[1].set(this.#e[1]))}mixInto(e){v(e.length===2,"mixLayout: target.length must be 2"),v(this.#e.length===1||this.#e.length===2,"mixLayout: target.length must be 1 or 2");let[t,r]=e;if(this.#e.length===1){let[s]=this.#e;for(let o=0;o<128;o++)t[o]+=s[o],r[o]+=s[o]}else{let[s,o]=this.#e;for(let n=0;n<128;n++)t[n]+=s[n],r[n]+=o[n]}}};var ne=class i{static PEAK_DECAY=Math.exp(-1/(sampleRate*.25));static RMS_WINDOW=Math.floor(sampleRate*.1);#e;#t;#r;#i;#s;#o=0;#n=0;#a=0;#l=0;constructor(e,t){this.#e=e,this.#t=t,this.#r=new Float32Array(4),this.#i=w.create(()=>new Fr(i.RMS_WINDOW),2),this.#s=this.#e.broadcastFloats(this.#t,this.#r,()=>{this.#r[0]=this.#o,this.#r[1]=this.#n,this.#r[2]=this.#a,this.#r[3]=this.#l})}clear(){this.#i[0].clear(),this.#i[1].clear(),this.#o=0,this.#n=0}process(e,t,r=0,s=128){let[o,n]=this.#i;for(let a=r;a<s;a++){let l=e[a],c=t[a];this.#o<l?this.#o=l:this.#o*=i.PEAK_DECAY,this.#n<c?this.#n=c:this.#n*=i.PEAK_DECAY,this.#a=o.pushPop(l),this.#l=n.pushPop(c)}}processStereo([e,t],r=0,s=128){this.process(e,t,r,s)}terminate(){this.#s.terminate()}};var po=class{#e=new D;#t;#r;#i;#s=p.None;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=new q,this.#o=this.#r.getValue(),this.#e.own(this.#r.subscribe(r=>{this.#o=r.getValue(),this.#i.notify(this)}))}subscribe(e){return this.#i.subscribe(e)}getValue(){return this.#o}getUnitValue(){return this.#r.valueMapping.x(this.#o)}onStartAutomation(){v(this.#s.isEmpty(),"Already broadcasting"),this.#s=p.wrap(this.#t.broadcaster.broadcastFloat(this.#r.address,()=>this.getUnitValue()))}updateAutomation(e){let t=this.#r.valueAt(e);return this.#o!==t?(this.#o=t,!0):!1}onStopAutomation(){v(this.#s.nonEmpty(),"Never started broadcasting"),this.#s.unwrap().terminate(),this.#s=p.None,this.#o=this.#r.getValue()}own(e){return this.#e.own(e)}ownAll(...e){this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#e.terminate()}};var ai=class{#e;constructor(){this.#e=new sr(w.empty(),nr.Comparator)}add(e,t){this.#e.add(e,t)}get(e){return this.#e.get(e)}forEach(e){return this.#e.forEach(e)}clear(){this.#e.clear()}};var Ie=class{#e=new D;#t;#r;#i;#s;#o=p.None;constructor(e){this.#t=e,this.#r=new ai,this.#i=[],this.#s=[]}parameterChanged(e){return g(`Got update event for ${e}, but has no parameter change method`)}get context(){return this.#t}get eventInput(){return this.#r}bindParameter(e){let t=new po(this.#t,e);return t.ownAll(e.field.pointerHub.catchupAndSubscribeTransactual({onAdd:r=>{this.#o.isEmpty()&&(this.#o=p.wrap(this.#t.updateClock.addEventOutput(this.#r))),this.#s.push(t),t.onStartAutomation()},onRemove:r=>{w.remove(this.#s,t),this.#s.length===0&&(this.#o.ifSome(s=>s.terminate()),this.#o=p.None),t.onStopAutomation()}},u.Automation),t.subscribe(()=>this.parameterChanged(t))),this.#i.push(t),t}updateParameter(e){this.#s.forEach(t=>{t.updateAutomation(e)&&this.parameterChanged(t)})}readAllParameters(){this.#i.forEach(e=>this.parameterChanged(e))}own(e){return this.#e.own(e)}ownAll(...e){return this.#e.ownAll(...e)}spawn(){return this.#e.spawn()}terminate(){this.#o.ifSome(e=>e.terminate()),this.#o=p.None,this.#i.length=0,this.#e.terminate()}toString(){return`{${this.constructor.name}}`}};var Si;(e=>e.isOfType=t=>t.type==="update-event")(Si||={});var mo=class extends Ie{#e=[];constructor(e){super(e),this.own(this.context.registerProcessor(this))}reset(){this.eventInput.clear()}addEventOutput(e){return this.#e.push(e),{terminate:()=>w.remove(this.#e,e)}}process({blocks:e}){e.forEach(({p0:t,p1:r,flags:s},o)=>{if(ye.every(s,1))for(let n of Pt.iterate(t,r,Js)){let a={type:"update-event",position:n};this.#e.forEach(l=>l.add(o,a))}})}toString(){return`{${this.constructor.name}}`}};var fe=class extends Ie{constructor(e){super(e)}process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,s0:o,s1:n,bpm:a}=t,l=null,c=o;for(let d of this.eventInput.get(r)){let m=d.position-s,f=Math.abs(m)<1e-7?o:o+Math.floor(G.pulsesToSamples(m,a,sampleRate));v(o<=f&&f<=n,()=>`${f} out of bounds. event: ${d.position} (${d.type}), p0: ${s}`),l?.forEach(y=>this.handleEvent(y)),l=null,c<f&&(this.processAudio(t,c,f),c=f),Si.isOfType(d)?this.updateParameter(d.position):(l??=[]).push(d)}l?.forEach(d=>this.handleEvent(d)),l=null,c<n&&this.processAudio(t,c,n)}),this.eventInput.clear(),this.finishProcess()}introduceBlock(e){}handleEvent(e){return g(`${this} received an event but has no accepting method.`)}finishProcess(){}};var fo=class i{static#e=R.exponential(20/sampleRate,2e4/sampleRate);#t;#r;#i;#s;#o;feedback=.7;cross=0;wet=.75;dry=.75;#n=0;#a=0;#l=0;#u=0;#c=0;#h=!1;#d=!1;constructor(e,t){let r=lt(e);this.#t=r,this.#r=[new Float32Array(r),new Float32Array(r)],this.#i=[new be,new be],this.#s=new Bt,this.#o=t}reset(){this.#a=0,this.#h&&(this.#i.forEach(e=>e.reset()),this.#r.forEach(e=>e.fill(0)),this.#h=!1,this.#d=!1),this.#f()}set offset(e){v(0<=e&&e<this.#t,"Out of bounds"),this.#u!==e&&(this.#u=e,this.#h?this.#x():this.#f())}get offset(){return this.#u}set filter(e){e===0?this.#s.identity():e>0?this.#s.setHighpassParams(i.#e.y(e),.001):e<0&&this.#s.setLowpassParams(i.#e.y(1+e),.001)}process(e,t,r,s){this.#d?this.#g(e,t,r,s):this.#p(e,t,r,s),this.#h=!0}#p(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,l=this.wet,c=this.dry,d=this.#a,m=d-Math.floor(this.#l);m<0&&(m+=this.#t);let f=e[0],y=e[1],F=t[0],S=t[1],M=this.#i[0],K=this.#i[1],L=n[0],z=n[1];for(let _=r;_<s;++_){let te=f[_],he=y[_],ce=M.processFrame(this.#s,L[m]*.96),H=K.processFrame(this.#s,z[m]*.96),J=this.cross*(H-ce),O=ce+J,X=H-J;L[d]=(te+O)*a+1e-18-1e-18,z[d]=(he+X)*a+1e-18-1e-18,F[_]=O*l+te*c,S[_]=X*l+he*c,m=++m&o,d=++d&o}this.#a=d}#g(e,t,r,s){let o=this.#t-1,n=this.#r,a=this.feedback,l=this.wet,c=this.dry,d=this.#a;for(let m=r;m<s;++m){0<this.#c?(this.#l+=this.#n,this.#c--):(this.#l=this.#u,this.#d=!1);let f=d-this.#l;f<0&&(f+=this.#t);let y=f|0,F=f-y,S=e[0][m],M=e[1][m],K=n[0][y],L=n[0][y],z=this.#i[0].processFrame(this.#s,K+F*(n[0][y+1&o]-K)),_=this.#i[1].processFrame(this.#s,L+F*(n[1][y+1&o]-L));n[0][d]=S+z*a+1e-18-1e-18,n[1][d]=M+z*a+1e-18-1e-18,t[0][m]=z*l+S*c,t[1][m]=_*l+M*c,d=++d&o}this.#a=d}#f(){this.#l=this.#u,this.#c=0,this.#d=!1}#x(){this.#u!==this.#l&&(this.#c=this.#o,this.#n=(this.#u-this.#l)/this.#c,this.#d=!0)}};var go=class i extends fe{static ID=0;#e=i.ID++;#t;parameterDelay;parameterFeedback;parameterCross;parameterFilter;parameterDry;parameterWet;#r;#i;#s;#o=p.None;#n=!0;constructor(e,t){super(e),this.#t=t,this.#r=new ie,this.#i=this.own(new ne(e.broadcaster,t.address));let{delay:r,feedback:s,cross:o,filter:n,dry:a,wet:l}=t.namedParameter;this.parameterDelay=this.own(this.bindParameter(r)),this.parameterFeedback=this.own(this.bindParameter(s)),this.parameterCross=this.own(this.bindParameter(o)),this.parameterFilter=this.own(this.bindParameter(n)),this.parameterDry=this.own(this.bindParameter(a)),this.parameterWet=this.own(this.bindParameter(l));let c=G.pulsesToSamples(je.toPPQN(gt.OffsetFractions[0]),30,sampleRate),d=Math.floor(.5*sampleRate);this.#s=new fo(c,d),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.reset(),this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#o=p.wrap(e),{terminate:()=>this.#o=p.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}handleEvent(e){}processAudio({bpm:e,flags:t},r,s){if(this.#o.isEmpty())return;if(this.#n||ye.some(t,8)){let n=this.parameterDelay.getValue(),a=je.toPPQN(gt.OffsetFractions[n]);this.#s.offset=G.pulsesToSamples(a,e,sampleRate),this.#n=!1}let o=this.#o.unwrap();this.#s.process(o.channels(),this.#r.channels(),r,s),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1),r,s)}parameterChanged(e){e===this.parameterDelay?this.#n=!0:e===this.parameterFeedback?this.#s.feedback=this.parameterFeedback.getValue():e===this.parameterCross?this.#s.cross=this.parameterCross.getValue():e===this.parameterFilter?this.#s.filter=this.parameterFilter.getValue():e===this.parameterDry?this.#s.dry=Ae(this.parameterDry.getValue()):e===this.parameterWet&&(this.#s.wet=Ae(this.parameterWet.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Ci=class i extends Ie{static ID=0;#e=i.ID++;#t;#r;#i;#s=p.None;constructor(e,t){super(e),this.#t=t,this.#r=new ie,this.#i=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#s=p.wrap(e),{terminate:()=>this.#s=p.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}process(e){if(this.#s.isEmpty())return;let t=this.#s.unwrap(),[r,s]=t.channels(),[o,n]=this.#r.channels();for(let a=0;a<128;a++)o[a]=r[a],n[a]=s[a];this.#i.process(o,n)}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})`}};var li=class i extends Ie{static ID=0;#e=i.ID++;#t;#r;#i;#s;constructor(e,t){super(e),this.#t=t,this.#r=new ie,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=[],this.own(e.registerProcessor(this))}get noteEventTarget(){return p.None}get incoming(){return this}get outgoing(){return this}get uuid(){return this.#t.uuid}reset(){this.#i.clear(),this.#r.clear()}addAudioSource(e){return this.#s.push(e),{terminate:()=>{w.remove(this.#s,e),this.#r.clear()}}}get adapter(){return this.#t}get audioOutput(){return this.#r}process(e){this.#r.clear();let[t,r]=this.#r.channels();for(let s of this.#s){let[o,n]=s.channels();for(let a=0;a<128;a++)t[a]+=o[a],r[a]+=n[a]}this.#r.assertSanity(),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1))}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#e})}`}};var Y;(n=>{n.start=(a,l,c,d,m=0)=>({type:"note-event",position:a,duration:l,pitch:c,velocity:d,cent:m,id:++o}),n.startWith=(a,l,c)=>({type:"note-event",position:l??a.position,duration:c??a.duration,pitch:a.pitch,cent:a.cent,velocity:a.velocity,id:++o}),n.stop=({id:a,pitch:l},c)=>({type:"note-complete-event",position:c,pitch:l,id:a}),n.isStart=a=>a.type==="note-event"&&"id"in a&&typeof a.id=="number",n.isStop=a=>a.type==="note-complete-event";let o=0})(Y||={});var jt=class{#e=new D;#t;#r;#i=p.None;constructor(e,t,r){this.#t=e,this.#r=this.#e.own(new st(t,r))}setNoteEventSource(e){return v(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=p.wrap(e),this.#t.reset(),U.create(()=>{this.#i=p.None,this.#t.reset()})}introduceBlock({index:e,p0:t,p1:r,flags:s}){if(!this.#i.isEmpty())for(let o of this.#i.unwrap().processNotes(t,r,s))o.pitch>=0&&o.pitch<=127&&(this.#t.eventInput.add(e,o),this.#s(o))}clear(){}terminate(){this.#e.terminate()}#s(e){Y.isStart(e)?this.#r.noteOn(e.pitch):Y.isStop(e)&&this.#r.noteOff(e.pitch)}};var xo=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#c;#h;#d;#p;gain=1;freqMult=1;attack=1;release=1;waveform=ht.sine;cutoff=1;resonance=1;filterEnvelope=0;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new jt(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#i=new ie,this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.octave)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.tune)),this.#l=this.own(this.bindParameter(this.#e.namedParameter.attack)),this.#u=this.own(this.bindParameter(this.#e.namedParameter.release)),this.#c=this.own(this.bindParameter(this.#e.namedParameter.waveform)),this.#h=this.own(this.bindParameter(this.#e.namedParameter.cutoff)),this.#d=this.own(this.bindParameter(this.#e.namedParameter.resonance)),this.#p=this.own(this.bindParameter(this.#e.namedParameter.filterEnvelope)),this.own(e.registerProcessor(this)),this.readAllParameters()}get noteEventTarget(){return p.wrap(this)}introduceBlock(e){this.#r.introduceBlock(e)}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.clear(),this.#t.length=0,this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#i}get adapter(){return this.#e}handleEvent(e){Y.isStart(e)?this.#t.push(new Sn(this,e)):Y.isStop(e)&&this.#t.find(t=>t.event.id===e.id)?.stop()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#i,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n||e===this.#a?this.freqMult=2**(this.#n.getValue()+this.#a.getValue()/1200):e===this.#l?this.attack=Math.floor(this.#l.getValue()*sampleRate):e===this.#u?this.release=Math.floor(this.#u.getValue()*sampleRate):e===this.#c?this.waveform=$n(this.#c.getValue(),ht):e===this.#h?this.cutoff=this.#h.getValue():e===this.#d?this.resonance=this.#d.getValue():e===this.#p&&(this.filterEnvelope=this.#p.getValue())}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return"{VaporisateurDevice}"}},Sn=class{device;event;osc;buffer;filterCoeff;filterProcessor;phase=0;position=0;decayPosition=Number.POSITIVE_INFINITY;constructor(e,t){this.device=e,this.event=t,this.osc=new Wi,this.buffer=new Float32Array(128),this.filterCoeff=new Bt,this.filterProcessor=new be}stop(){this.decayPosition=this.position-this.device.attack}processAdd(e,t,r){let s=pa(this.event.pitch+this.event.cent/100,440)*this.device.freqMult,o=ji(this.event.velocity)*this.device.gain*Ae(-15),n=this.device.waveform,a=this.device.attack,l=this.device.release,c=this.device.adapter.namedParameter.cutoff.valueMapping,d=c.x(this.device.cutoff),m=this.device.resonance,f=this.device.filterEnvelope,y=e.getChannel(0),F=e.getChannel(1);this.osc.generate(this.buffer,s/sampleRate,n,t,r);for(let S=t;S<r;S++){let M=Math.min(this.position/a,1-(this.position-(this.decayPosition+a))/l,1)**2;this.filterCoeff.setLowpassParams(c.y($(d+M*f,0,1))/sampleRate,m);let K=this.filterProcessor.processFrame(this.filterCoeff,this.buffer[S])*o*M;if(y[S]+=K,F[S]+=K,++this.position-this.decayPosition>a+l)return!0}return!1}};var yo=class extends Ie{#e;#t;#r;#i=NaN;#s=0;#o=128;constructor(e,t){super(e),this.#e=t,this.#t=new ie(2),this.#r=this.own(new ne(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get noteEventTarget(){return p.None}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear(),this.#i=NaN,this.#s=0}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#t}process({blocks:e}){this.#t.clear(0,128);let[t,r]=this.#t.channels();this.#e.deviceHost().audioUnitBoxAdapter().tracks.collection.adapters().filter(s=>s.type===Z.Audio&&s.enabled.getValue()).forEach(s=>e.forEach(o=>{let{p0:n,p1:a,flags:l}=o;if(!ye.every(l,5))return;let c=this.context.clipSequencing.iterate(s.uuid,n,a);for(let{optClip:d,sectionFrom:m,sectionTo:f}of c)d.match({none:()=>{for(let y of s.regions.collection.iterateRange(n,a)){if(y.mute||!ae(y,Ut))continue;let S=y.file.getOrCreateLoader().data;if(S.isEmpty())return;let M=S.unwrap();for(let K of De.locateLoops(y,n,a))this.#n(this.#t,M,K,o)}},some:y=>{if(!ae(y,kt))return;let F=y.file.getOrCreateLoader().data;if(F.isEmpty())return;let S=F.unwrap();for(let M of De.locateLoops({position:0,loopDuration:y.duration,loopOffset:0,complete:Number.POSITIVE_INFINITY},m,f))this.#n(this.#t,S,M,o)}})})),this.#t.assertSanity(),this.#r.process(t,r)}parameterChanged(e){}#n(e,t,r,{p0:s,p1:o,s0:n,s1:a}){let[l,c]=e.channels(),{numberOfFrames:d,frames:m}=t,f=m[0],y=m.length===1?m[0]:m[1],F=a-n,S=o-s,M=d*r.resultStartValue,K=d*r.resultEndValue,L=(r.resultStart-s)/S,z=(r.resultEnd-s)/S,_=n+F*L,te=n+F*z,he=te-_|0,ce=(K-M)/he;v(n<=_&&te<=a,`Out of bounds ${_}, ${te}`);let H=!Number.isFinite(this.#i)||Math.abs(M-(this.#i+ce))>2;for(let J=0,O=_|0;J<he;J++,O++){let X=M+J*ce,ee=X|0,ke=0,_e=0;if(ee>=0&&ee<d-1){let Ee=X-ee,He=f[ee],hi=y[ee];ke=He+Ee*(f[ee+1]-He),_e=hi+Ee*(y[ee+1]-hi)}if(H&&J<this.#o&&Number.isFinite(this.#i)){let Ee=J/this.#o,He=1-Ee,hi=this.#i+J*this.#s,Jt=hi|0;if(Jt>=0&&Jt<d-1){let In=hi-Jt,On=f[Jt],kn=y[Jt],tl=On+In*(f[Jt+1]-On),rl=kn+In*(y[Jt+1]-kn);l[O]+=He*tl+Ee*ke,c[O]+=He*rl+Ee*_e}else l[O]+=ke,c[O]+=_e}else l[O]+=ke,c[O]+=_e}this.#i=M+(he-1)*ce,this.#s=ce}};var ze=class extends Ie{process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,p1:o}=t,n=null,a=s;for(let l of this.eventInput.get(r))n?.forEach(c=>this.handleEvent(t,c)),n=null,a<l.position&&(this.processEvents(t,a,l.position),a=l.position),Si.isOfType(l)?this.updateParameter(l.position):(n??=[]).push(l);n?.forEach(l=>this.handleEvent(t,l)),n=null,a<o&&this.processEvents(t,a,o)}),this.eventInput.clear()}introduceBlock(e){}};var ui;(t=>(t.create=()=>({mult:1,add:0}),t.apply=(r,s)=>s*r.mult+r.add))(ui||={});var vo=Object.freeze([{name:"up",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=t%n,c=Math.floor(t%a/n),d=i[l];return Y.start(r,s,d.pitch+c*12,ui.apply(o,d.velocity))}},{name:"down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=n-1-t%n,c=e-1-Math.floor(t%a/n),d=i[l];return Y.start(r,s,d.pitch+c*12,ui.apply(o,d.velocity))}},{name:"up-down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=Math.max(1,a*2-2),c=t%l,d=c<a?c:l-c,m=d%n,f=Math.floor(d/n),y=i[m];return Y.start(r,s,y.pitch+f*12,ui.apply(o,y.velocity))}}]);var bo=class extends ze{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u=ui.create();#c=p.None;#h=vo[0];#d=NaN;#p=1;#g=1;#f=1;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new Br,this.#i=this.own(this.bindParameter(t.namedParameter.modeIndex)),this.#s=this.own(this.bindParameter(t.namedParameter.rate)),this.#o=this.own(this.bindParameter(t.namedParameter.gate)),this.#n=this.own(this.bindParameter(t.namedParameter.repeat)),this.#a=this.own(this.bindParameter(t.namedParameter.numOctaves)),this.#l=this.own(this.bindParameter(t.namedParameter.velocity)),this.ownAll(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get noteEventTarget(){return p.wrap(this)}setNoteEventSource(e){return v(this.#c.isEmpty(),"NoteEventSource already set"),this.#c=p.wrap(e),U.create(()=>this.#c=p.None)}*processNotes(e,t,r){if(this.#r.nonEmpty())if(ye.every(r,2))for(let o of this.#r.releaseAll())yield Y.stop(o,e);else for(let o of this.#r.releaseLinearCompleted(t))yield Y.stop(o,o.position+o.duration);if(this.#c.nonEmpty()){let s=this.#c.unwrap();for(let n of s.processNotes(e,t,r));let o=!ye.every(r,1);for(let{position:n,index:a}of Pt.iterateWithIndex(e,t,this.#d)){let l=Array.from(s.iterateActiveNotesAt(n,o));if(l.length===0)continue;let c=Math.floor(a/this.#g),d=Math.max(1,Math.floor(this.#d*this.#p)),m=this.#h.run(l,this.#f,c,n,d,this.#u);this.#r.addAndRetain({...m}),yield m}for(let n of this.#r.releaseLinearCompleted(t))yield Y.stop(n,n.position+n.duration)}}*iterateActiveNotesAt(e,t){this.#c.isEmpty()||t||(yield*this.#r.overlapping(e,Me.Comparator))}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){if(e===this.#i)this.#h=vo.at(this.#i.getValue())??vo[0];else if(e===this.#s)this.#d=je.toPPQN(_t.RateFractions[this.#s.getValue()]);else if(e===this.#o)this.#p=this.#o.getValue();else if(e===this.#n)this.#g=this.#n.getValue();else if(e===this.#a)this.#f=this.#a.getValue();else if(e===this.#l){let t=this.#l.getValue();t<=0?(this.#u.add=1+t,this.#u.mult=0):(this.#u.add=1-t,this.#u.mult=t)}}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var Ao=class extends ze{#e;#t;#r;#i;#s;#o=p.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new st(e.broadcaster,t.address)),this.#r=this.own(this.bindParameter(t.namedParameter.octaves)),this.#i=this.own(this.bindParameter(t.namedParameter.semiTones)),this.#s=this.own(this.bindParameter(t.namedParameter.cent)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return v(this.#o.isEmpty(),"NoteEventSource already set"),this.#o=p.wrap(e),U.create(()=>this.#o=p.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#o.isEmpty())for(let s of this.#o.unwrap().processNotes(e,t,r))if(Y.isStart(s)){this.#t.noteOn(s.pitch);let{cent:o,octaves:n,semiTones:a}=this.#e.namedParameter;yield Je.overwrite(s,{pitch:s.pitch+n.valueAt(s.position)*12+a.valueAt(s.position),cent:s.cent+o.valueAt(s.position)})}else this.#t.noteOff(s.pitch),yield s}*iterateActiveNotesAt(e,t){if(!this.#o.isEmpty()){for(let r of this.#o.unwrap().iterateActiveNotesAt(e,t))if(r.type==="note-event"){let{cent:s,octaves:o,semiTones:n}=this.#e.namedParameter;yield Je.overwrite(r,{pitch:r.pitch+o.valueAt(r.position)*12+n.valueAt(r.position),cent:r.cent+s.valueAt(r.position)})}}}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var wo=class i{static DEFAULT_SIZE=1024;#e;#t;#r;#i;#s;#o;#n;#a=0;decay=!1;constructor(e=i.DEFAULT_SIZE){this.#e=e,this.#r=new zi(this.#e),this.#i=new Float32Array(this.#e),this.#s=new Float32Array(this.#e),this.#o=yi.create(yi.Type.Blackman,this.#e),this.#t=this.#e>>1,this.#n=new Float32Array(this.#t)}clear(){this.#n.fill(0),this.#a=0}numBins(){return this.#t}bins(){return this.#n}process(e,t,r,s){for(let o=r;o<s;++o)this.#i[this.#a]=this.#o[this.#a]*(e[o]+t[o]),++this.#a===this.#e&&this.#l()}#l(){this.#r.process(this.#i,this.#s);let e=1/this.#t;for(let t=0;t<this.#t;++t){let r=this.#i[t],s=this.#s[t],o=Math.sqrt(r*r+s*s)*e;this.#n[t]<o?this.#n[t]=o:this.decay&&(this.#n[t]*=.9)}this.#a=0,this.#s.fill(0),this.decay=!1}};var Eo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#c;#h;#d;#p;#g;#f;#x;#B;#P;#S;#F;#D;#C;#v;#y;#b;#R;#M;#T;#A;#E;#w;#N;#V;#I;#k;#U;#O=p.None;constructor(e,t){super(e),this.#t=t,this.#r=new ie,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new wo,this.#o=new Float32Array(this.#s.numBins()),this.#n=w.create(()=>new Bt,7),this.#a=[new or(4),new or(4)],this.#l=[new or(4),new or(4)],this.#u=[this.#l,[new be,new be],[new be,new be],[new be,new be],[new be,new be],[new be,new be],this.#a],this.#c=w.create(()=>!0,7);let r=this.#t.namedParameter;this.#h=this.own(this.bindParameter(r.highPass.enabled)),this.#p=this.own(this.bindParameter(r.highPass.q)),this.#d=this.own(this.bindParameter(r.highPass.frequency)),this.#g=this.own(this.bindParameter(r.highPass.order)),this.#f=this.own(this.bindParameter(r.lowShelf.enabled)),this.#x=this.own(this.bindParameter(r.lowShelf.frequency)),this.#B=this.own(this.bindParameter(r.lowShelf.gain)),this.#P=this.own(this.bindParameter(r.lowBell.enabled)),this.#S=this.own(this.bindParameter(r.lowBell.frequency)),this.#F=this.own(this.bindParameter(r.lowBell.gain)),this.#D=this.own(this.bindParameter(r.lowBell.q)),this.#C=this.own(this.bindParameter(r.midBell.enabled)),this.#v=this.own(this.bindParameter(r.midBell.frequency)),this.#y=this.own(this.bindParameter(r.midBell.gain)),this.#b=this.own(this.bindParameter(r.midBell.q)),this.#R=this.own(this.bindParameter(r.highBell.enabled)),this.#M=this.own(this.bindParameter(r.highBell.frequency)),this.#T=this.own(this.bindParameter(r.highBell.gain)),this.#A=this.own(this.bindParameter(r.highBell.q)),this.#E=this.own(this.bindParameter(r.highShelf.enabled)),this.#w=this.own(this.bindParameter(r.highShelf.frequency)),this.#N=this.own(this.bindParameter(r.highShelf.gain)),this.#V=this.own(this.bindParameter(r.lowPass.enabled)),this.#I=this.own(this.bindParameter(r.lowPass.frequency)),this.#k=this.own(this.bindParameter(r.lowPass.q)),this.#U=this.own(this.bindParameter(r.lowPass.order)),this.own(e.registerProcessor(this)),e.broadcaster.broadcastFloats(t.spectrum,this.#o,()=>{this.#o.set(this.#s.bins()),this.#s.decay=!0}),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.#u.forEach(e=>e.forEach(t=>t.reset())),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#O=p.wrap(e),{terminate:()=>this.#O=p.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#O.isEmpty())return;let[s,o]=this.#r.channels(),n=this.#O.unwrap();if(this.#c.some(a=>a)){let[a,l]=n.channels();this.#n.forEach((c,d)=>{if(this.#c[d]){let[m,f]=this.#u[d];m.process(c,a,s,t,r),f.process(c,l,o,t,r),a=s,l=o}})}else{let[a,l]=n.channels();for(let c=t;c<r;c++)s[c]=a[c],o[c]=l[c]}this.#i.process(s,o,t,r),this.#s.process(s,o,t,r)}parameterChanged(e){if(e===this.#U){let t=this.#U.getValue();this.#a[0].order=t,this.#a[1].order=t}else if(e===this.#g){let t=this.#g.getValue();this.#l[0].order=t,this.#l[1].order=t}else if(e===this.#d||e===this.#p){let t=this.#d.getValue(),r=this.#p.getValue();this.#n[0].setHighpassParams(t/sampleRate,r)}else if(e===this.#x||e===this.#B){let t=this.#x.getValue(),r=this.#B.getValue();this.#n[1].setLowShelfParams(t/sampleRate,r)}else if(e===this.#S||e===this.#F||e===this.#D){let t=this.#S.getValue(),r=this.#F.getValue(),s=this.#D.getValue();this.#n[2].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#v||e===this.#y||e===this.#b){let t=this.#v.getValue(),r=this.#y.getValue(),s=this.#b.getValue();this.#n[3].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#M||e===this.#T||e===this.#A){let t=this.#M.getValue(),r=this.#T.getValue(),s=this.#A.getValue();this.#n[4].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#w||e===this.#N){let t=this.#w.getValue(),r=this.#N.getValue();this.#n[5].setHighShelfParams(t/sampleRate,r)}else if(e===this.#I||e===this.#k){let t=this.#I.getValue(),r=this.#k.getValue();this.#n[6].setLowpassParams(t/sampleRate,r)}else e===this.#h?this.#c[0]=this.#h.getValue():e===this.#f?this.#c[1]=this.#f.getValue():e===this.#P?this.#c[2]=this.#P.getValue():e===this.#C?this.#c[3]=this.#C.getValue():e===this.#R?this.#c[4]=this.#R.getValue():e===this.#E?this.#c[5]=this.#E.getValue():e===this.#V&&(this.#c[6]=this.#V.getValue())}toString(){return`{${this.constructor.name} (${this.#e})`}};var Bo=class{roomSize;damp;predelayInSamples;wetGain;dryGain;#e=new Float32Array(2048);#t=new Float32Array(2048);#r=new Float32Array(2048);#i=new Float32Array(2048);#s=new Float32Array(2048);#o=new Float32Array(2048);#n=new Float32Array(2048);#a=new Float32Array(2048);#l=new Float32Array(1024);#u=new Float32Array(512);#c=new Float32Array(512);#h=new Float32Array(256);#d=new Float32Array(2048);#p=new Float32Array(2048);#g=new Float32Array(2048);#f=new Float32Array(2048);#x=new Float32Array(2048);#B=new Float32Array(2048);#P=new Float32Array(2048);#S=new Float32Array(2048);#F=new Float32Array(1024);#D=new Float32Array(512);#C=new Float32Array(512);#v=new Float32Array(256);#y;#b;#R=0;#M=0;#T=0;#A=0;#E=0;#w=0;#N=0;#V=0;#I=0;#k=0;#U=0;#O=0;#L=0;#$=0;#q=0;#z=0;#_=0;#H=0;#G=0;#W=0;#j=0;#Q=0;#Y=0;#X=0;#J=0;#Z=0;#ee=0;#te=0;#re=0;#ie=0;#se=0;#oe=0;#ne=0;#ae=0;#le=0;#ue=0;#ce=0;#he=0;#de=0;#pe=0;#m=0;#K=0;constructor(e=.5){this.#y=lt(Math.ceil(e*sampleRate)),this.#b=new Float32Array(this.#y<<1),this.damp=0,this.roomSize=.5,this.wetGain=.3333,this.dryGain=1-this.wetGain,this.#m=0,this.#K=0,this.predelayInSamples=.008*sampleRate,this.clearHistory()}clear(){this.#m=0,this.#K=0,this.clearHistory(),this.clearBuffers()}process(e,t,r,s){let[o,n]=t.channels(),[a,l]=e.channels(),c=.4*this.damp,d=1-c,m=.7+.28*this.roomSize;for(let f=r;f<s;++f){let y=o[f],F=n[f],S=this.#K-this.predelayInSamples;S<0&&(S+=this.#y);let M;M=S<<1;let K=.01,L=this.#b[M]*K,z=this.#b[M+1]*K;M=this.#K<<1,this.#b[M]=y,this.#b[M+1]=F,this.#K=this.#K+1&this.#y-1;let _=this.#m&2047;this.#R=d*this.#M+c*this.#R,this.#e[_]=L+m*this.#R,this.#M=this.#e[this.#m-1617&2047],this.#T=d*this.#A+c*this.#T,this.#t[_]=L+m*this.#T,this.#A=this.#t[this.#m-1557&2047],this.#E=d*this.#w+c*this.#E,this.#r[_]=L+m*this.#E,this.#w=this.#r[this.#m-1491&2047],this.#N=d*this.#V+c*this.#N,this.#i[_]=L+m*this.#N,this.#V=this.#i[this.#m-1422&2047],this.#I=d*this.#k+c*this.#I,this.#s[_]=L+m*this.#I,this.#k=this.#s[this.#m-1356&2047],this.#U=d*this.#O+c*this.#U,this.#o[_]=L+m*this.#U,this.#O=this.#o[this.#m-1277&2047],this.#L=d*this.#$+c*this.#L,this.#n[_]=L+m*this.#L,this.#$=this.#n[this.#m-1188&2047],this.#q=d*this.#z+c*this.#q,this.#a[_]=L+m*this.#q,this.#z=this.#a[this.#m-1116&2047];let te=this.#z+this.#$+this.#O+this.#k+this.#V+this.#w+this.#A+this.#M,he=this.#_-te,ce=this.#H-he,H=this.#G-ce;this.#l[this.#m&1023]=te+.5*this.#_,this.#_=this.#l[this.#m-556&1023],this.#u[this.#m&511]=he+.5*this.#H,this.#H=this.#u[this.#m-441&511],this.#c[this.#m&511]=ce+.5*this.#G,this.#G=this.#c[this.#m-341&511],this.#h[this.#m&255]=H+.5*this.#W,this.#W=this.#h[this.#m-225&255],a[f]=this.dryGain*y+this.wetGain*(this.#W-H),this.#j=d*this.#Q+c*this.#j,this.#d[_]=z+m*this.#j,this.#Q=this.#d[this.#m-1640&2047],this.#Y=d*this.#X+c*this.#Y,this.#p[_]=z+m*this.#Y,this.#X=this.#p[this.#m-1580&2047],this.#J=d*this.#Z+c*this.#J,this.#g[_]=z+m*this.#J,this.#Z=this.#g[this.#m-1514&2047],this.#ee=d*this.#te+c*this.#ee,this.#f[_]=z+m*this.#ee,this.#te=this.#f[this.#m-1445&2047],this.#re=d*this.#ie+c*this.#re,this.#x[_]=z+m*this.#re,this.#ie=this.#x[this.#m-1379&2047],this.#se=d*this.#oe+c*this.#se,this.#B[_]=z+m*this.#se,this.#oe=this.#B[this.#m-1300&2047],this.#ne=d*this.#ae+c*this.#ne,this.#P[_]=z+m*this.#ne,this.#ae=this.#P[this.#m-1211&2047],this.#le=d*this.#ue+c*this.#le,this.#S[_]=z+m*this.#le,this.#ue=this.#S[this.#m-1139&2047];let J=this.#ue+this.#ae+this.#oe+this.#ie+this.#te+this.#Z+this.#X+this.#Q,O=this.#ce-J,X=this.#he-O,ee=this.#de-X;this.#F[this.#m&1023]=J+.5*this.#ce,this.#ce=this.#F[this.#m-579&1023],this.#D[this.#m&511]=O+.5*this.#he,this.#he=this.#D[this.#m-464&511],this.#C[this.#m&511]=X+.5*this.#de,this.#de=this.#C[this.#m-364&511],this.#v[this.#m&255]=ee+.5*this.#pe,this.#pe=this.#v[this.#m-248&255],l[f]=this.dryGain*F+this.wetGain*(this.#pe-ee),this.#m++}}clearBuffers(){this.#e.fill(0),this.#t.fill(0),this.#r.fill(0),this.#i.fill(0),this.#s.fill(0),this.#o.fill(0),this.#n.fill(0),this.#a.fill(0),this.#l.fill(0),this.#u.fill(0),this.#c.fill(0),this.#h.fill(0),this.#d.fill(0),this.#p.fill(0),this.#g.fill(0),this.#f.fill(0),this.#x.fill(0),this.#B.fill(0),this.#P.fill(0),this.#S.fill(0),this.#F.fill(0),this.#D.fill(0),this.#C.fill(0),this.#v.fill(0),this.#b.fill(0)}clearHistory(){this.#R=0,this.#M=0,this.#T=0,this.#A=0,this.#E=0,this.#w=0,this.#N=0,this.#V=0,this.#I=0,this.#k=0,this.#U=0,this.#O=0,this.#L=0,this.#$=0,this.#q=0,this.#z=0,this.#_=0,this.#H=0,this.#G=0,this.#W=0,this.#j=0,this.#Q=0,this.#Y=0,this.#X=0,this.#J=0,this.#Z=0,this.#ee=0,this.#te=0,this.#re=0,this.#ie=0,this.#se=0,this.#oe=0,this.#ne=0,this.#ae=0,this.#le=0,this.#ue=0,this.#ce=0,this.#he=0,this.#de=0,this.#pe=0}};var Fo=class i extends fe{static ID=0;#e=i.ID++;#t;#r;#i;#s;#o;#n;#a;#l;#u;#c=p.None;constructor(e,t){super(e),this.#t=t,this.#r=new ie,this.#i=this.own(new ne(e.broadcaster,t.address)),this.#s=new Bo;let{decay:r,preDelay:s,damp:o,wet:n,dry:a}=this.#t.namedParameter;this.#o=this.own(this.bindParameter(r)),this.#n=this.own(this.bindParameter(s)),this.#a=this.own(this.bindParameter(o)),this.#l=this.own(this.bindParameter(n)),this.#u=this.own(this.bindParameter(a)),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#s.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#c=p.wrap(e),{terminate:()=>this.#c=p.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#c.isEmpty())return;this.#s.process(this.#r,this.#c.unwrap(),t,r);let[s,o]=this.#r.channels();this.#i.process(s,o,t,r)}parameterChanged(e){this.#o===e?this.#s.roomSize=this.#o.getValue():this.#n===e?this.#s.predelayInSamples=Math.ceil(this.#n.getValue()*sampleRate):this.#a===e?this.#s.damp=this.#a.getValue():this.#l===e?this.#s.wetGain=Ae(this.#l.getValue()):this.#u===e&&(this.#s.dryGain=Ae(this.#u.getValue()))}toString(){return`{${this.constructor.name} (${this.#e})`}};var No=class extends fe{#e;#t;#r;#i;#s;#o;#n;gain=1;release=1;loader=p.None;constructor(e,t){super(e),this.#e=t,this.#t=[],this.#r=new ie,this.#i=new jt(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#s=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.release)),this.ownAll(e.registerProcessor(this),t.box.file.catchupAndSubscribe(r=>this.loader=r.targetVertex.map(({box:s})=>e.sampleManager.getOrCreate(s.address.uuid)))),this.readAllParameters()}get noteEventTarget(){return p.wrap(this)}introduceBlock(e){this.#i.introduceBlock(e)}setNoteEventSource(e){return this.#i.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#t.length=0,this.#r.clear(),this.eventInput.clear(),this.#i.clear(),this.#s.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}get adapter(){return this.#e}handleEvent(e){Y.isStart(e)?this.#t.push(new Cn(this,e)):Y.isStop(e)&&this.#t.find(t=>t.event().id===e.id)?.stop()}processAudio(e,t,r){this.#r.clear(t,r);for(let s=this.#t.length-1;s>=0;s--)this.#t[s].processAdd(this.#r,t,r)&&this.#t.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n&&(this.release=this.#n.getValue()*sampleRate)}finishProcess(){this.#r.assertSanity(),this.#s.process(this.#r.getChannel(0),this.#r.getChannel(1))}toString(){return"{NanoDevice}"}},Cn=class{#e;#t;#r=1;#i=0;#s=0;#o=Number.POSITIVE_INFINITY;constructor(e,t){this.#e=e,this.#t=t,this.#r=Math.pow(2,(t.pitch+t.cent/100)/12-5)}event(){return this.#t}stop(){this.#o=this.#s}processAdd(e,t,r){let s=this.#e.loader;if(s.isEmpty())return!0;let o=s.unwrap();return o.data.isEmpty()?!0:this.processSimple(e.channels(),o.data.unwrap(),t,r)}processSimple(e,t,r,s){let[o,n]=e,a=t.frames[0],l=t.frames[1]??a,c=t.numberOfFrames,d=t.sampleRate/sampleRate,m=this.#e.gain,f=this.#e.release,y=1/f;for(let F=r;F<s;F++){let S=this.#i|0;if(S>=c-1)return!0;let M=this.#i-S,K=Math.min(1-(this.#s-this.#o)*y,1)**2,L=a[S]*(1-M)+a[S+1]*M,z=l[S]*(1-M)+l[S+1]*M;if(o[F]+=L*m*K,n[F]+=z*m*K,this.#i+=this.#r*d,++this.#s-this.#o>f)return!0}return!1}};var Po=class extends ze{#e;#t;constructor(e,t){super(e),this.#e=t,this.#t=new jt(this,e.broadcaster,t.adapter.audioUnitBoxAdapter().address),this.own(e.registerProcessor(this)),this.readAllParameters()}introduceBlock(e){this.#t.introduceBlock(e)}setNoteEventSource(e){return this.#t.setNoteEventSource(e)}reset(){this.eventInput.clear(),this.#t.clear()}processEvents(e,t,r){}handleEvent({index:e},t){Y.isStart(t)?this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t)):Y.isStop(t)&&this.#e.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t))}toString(){return"{PlayfieldSequencer}"}};var So=class extends fe{#e;#t;#r;#i;#s;constructor(e,t){super(e),this.#e=t,this.#t=new ie,this.#r=this.own(new ne(e.broadcaster,t.adapter.address)),this.#i=[],this.#s=new ai,this.own(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}setAudioSource(e){return this.#i.push(e),{terminate:()=>{w.remove(this.#i,e),this.#t.clear()}}}get audioOutput(){return this.#t}get eventInput(){return this.#s}processAudio(e,t,r){}reset(){this.#r.clear()}finishProcess(){this.#t.clear();let[e,t]=this.#t.channels();for(let r of this.#i){let[s,o]=r.channels();for(let n=0;n<128;n++)e[n]+=s[n],t[n]+=o[n]}this.#t.assertSanity(),this.#r.process(this.#t.getChannel(0),this.#t.getChannel(1))}toString(){return"{PlayfieldMixProcessor}"}};var Co=class i{static create(e,t,r,s){return new i(e,t,r,s)}#e=new D;#t;#r;#i=[];#s=!0;constructor(e,t,r,s){this.#t=A.newSet(({device:o})=>o.uuid),this.#r=this.#e.own(new D),this.#e.ownAll(t.catchupAndSubscribe({onAdd:o=>{this.invalidateWiring();let n=Ri.create(e,o.box),a=this.#t.add({device:n,subscription:n.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(a,"Could not add.")},onRemove:o=>{this.invalidateWiring();let{device:n,subscription:a}=this.#t.removeByKey(o.uuid);a.terminate(),n.terminate()},onReorder:o=>this.invalidateWiring()}),e.subscribeProcessPhase(o=>{if(o===0&&this.#s){let n=r;w.replace(this.#i,t.adapters().map(({uuid:a})=>this.#t.get(a).device));for(let a of this.#i)a.adapter().enabledField.getValue()&&(this.#r.own(a.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,a.incoming)),n=a);this.#r.own(s.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,s.incoming)),this.#s=!1}}))}invalidateWiring(){this.#r.terminate(),this.#s=!0}terminate(){this.#e.terminate(),this.#t.forEach(({device:e})=>e.terminate()),this.#t.clear(),this.#i=[]}toString(){return`{${this.constructor.name}}`}};var Mi=Math.floor(.005*sampleRate),Mo=class{#e;#t;#r;#i;#s;#o;#n=0;#a=Number.POSITIVE_INFINITY;#l;#u;#c;#h;#d;#p;#g=!0;#f=!1;constructor(e,t,r,s){this.#e=e,this.#t=t,this.#i=r,this.#r=s,this.#s=e.gate,this.#o=ji(this.#r.velocity);let{attack:o,release:n,sampleStart:a,sampleEnd:l}=this.#t;this.#l=o.getValue()*sampleRate,this.#u=n.getValue()*sampleRate,this.#c=(r.numberOfFrames-1)*a.getValue(),this.#h=(r.numberOfFrames-1)*l.getValue(),this.#d=this.#c,this.#p=0}get sample(){return this.#e}get event(){return this.#r}get position(){return this.#d}get envelope(){return this.#p}release(e=!1){this.#g&&(e?(this.#u=Mi,this.#x(),this.#g=!1):this.#s!==ot.Off&&this.#x())}processAdd(e,t,r){let[s,o]=e,{frames:n,numberOfFrames:a}=this.#i,l=n[0],c=n[1]??l,{pitch:d}=this.#t,m=this.#h-this.#c,f=Math.sign(m),y=this.#i.sampleRate/sampleRate*f*2**(d.getValue()/1200),F=0;for(let S=t;S<r;S++){let M=this.#d|0,K=this.#d-M,L=l[M]*(1-K)+(l[M+1]??0)*K,z=c[M]*(1-K)+(c[M+1]??0)*K;if(F=Math.min(this.#n/this.#l,1-(this.#n-(this.#a+this.#l))/this.#u,1),this.#d+=y,f>0){if(this.#s===ot.Off){if(this.#d>=a)return!0;!this.#f&&this.#d>=this.#h&&this.#x()}else if(this.#s===ot.On){if(this.#d>=this.#h-Mi){if(this.#d>=this.#h)return!0;F*=(this.#h-this.#d)/Mi}}else if(this.#s===ot.Loop)for(;this.#d>=this.#h;)this.#d-=m}else if(f<0){if(this.#s===ot.Off){if(this.#d<=0)return!0;!this.#f&&this.#d<=this.#h&&this.#x()}else if(this.#s===ot.On){if(this.#d<=this.#h+Mi){if(this.#d<=this.#h)return!0;F*=(this.#h-this.#d)/Mi}}else if(this.#s===ot.Loop)for(;this.#d<=this.#h;)this.#d-=m}if(++this.#n-this.#a>this.#l+this.#u)return!0;F*=this.#o*F,s[S]+=L*F,o[S]+=z*F}return this.#p=F,!1}toString(){return"{PlayfieldSampleVoice}"}#x(){this.#f||(this.#f=!0,this.#a=this.#n<this.#l?this.#n-this.#l:this.#n)}};var To=class extends fe{#e;#t;#r;#i;#s;#o;constructor(e,t,r,s){super(e),this.#e=t,this.#t=r,this.#r=[],this.#i=new ie,this.#s=this.own(new ne(e.broadcaster,r.peakAddress));let{sampleStart:o,sampleEnd:n,attack:a,release:l,pitch:c}=r.namedParameter;this.#o=Object.freeze({sampleStart:this.own(this.bindParameter(o)),sampleEnd:this.own(this.bindParameter(n)),attack:this.own(this.bindParameter(a)),release:this.own(this.bindParameter(l)),pitch:this.own(this.bindParameter(c))});let d=new Float32Array(16);this.ownAll(Co.create(e,r.audioEffects,this,s),e.broadcaster.broadcastFloats(r.address,d,()=>{let m=this.#r.length<d.length?this.#r:this.#r.slice(0,d.length);m.forEach(({position:f},y)=>d[y]=f),d[m.length]=-1}),e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#i}get adapter(){return this.#t}handleEvent(e){if(Y.isStart(e)){let t=this.#t.file().flatMap(d=>d.getOrCreateLoader().data);if(t.isEmpty())return;let{mute:r,solo:s,polyphone:o,exclude:n}=this.#t.namedParameter,a=r.getValue(),l=s.getValue();if(a||this.#e.hasSolo()&&!l)return;o.getValue()||this.#r.forEach(d=>d.release(!0)),n.getValue()&&this.#e.stopExcludeOthers(this.#t),this.#r.push(new Mo(this.#t,this.#o,t.unwrap(),e))}else Y.isStop(e)&&this.#r.find(t=>t.event.id===e.id)?.release()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#r.length-1;s>=0;s--)this.#r[s].processAdd(this.#i.channels(),t,r)&&this.#r.splice(s,1)}forceStop(){this.#r.forEach(e=>e.release(!0))}parameterChanged(e){}reset(){this.#r.length=0,this.#i.clear(),this.#s.clear()}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return`{PlayfieldSampleProcessor note: ${this.#t.indexField.getValue()}}`}};var Vo=class{#e=new D;#t;#r;#i;#s;constructor(e,t){this.#t=t,this.#r=this.#e.own(new Po(e,this)),this.#i=this.#e.own(new So(e,this)),this.#s=A.newSet(r=>r.uuid),this.#e.ownAll(t.samples.catchupAndSubscribe({onAdd:r=>{let s=new To(e,this,r,this.#i);this.#s.add({uuid:r.uuid,processor:s,terminable:e.registerEdge(this.#r,s)}),e.sampleManager.getOrCreate(r.fileUUID())},onRemove:r=>{let{terminable:s,processor:o}=this.#s.removeByKey(r.uuid);s.terminate(),o.terminate()},onReorder:r=>{}}),{terminate:()=>{this.#s.forEach(({terminable:r,processor:s})=>{r.terminate(),s.terminate()}),this.#s.clear()}})}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get noteEventTarget(){return p.wrap(this)}get incoming(){return this.#r}get outgoing(){return this.#i}optSampleProcessor(e){return this.#t.samples.getAdapterByIndex(e).flatMap(t=>this.#s.opt(t.uuid)).map(t=>t.processor)}hasSolo(){return this.#t.samples.adapters().some(e=>e.namedParameter.solo.getValue())}stopExcludeOthers(e){for(let t of this.#t.samples.adapters())t.exclude&&t!==e&&this.#s.opt(t.uuid).ifSome(({processor:r})=>r.forceStop())}get uuid(){return this.#t.uuid}get adapter(){return this.#t}get audioOutput(){return this.#i.audioOutput}parameterChanged(e){}terminate(){this.#e.terminate()}toString(){return"{PlayfieldDeviceProcessor}"}};var Do=class extends fe{#e;#t;#r;#i=Qe.stereoMatrix(sampleRate);#s={gain:0,panning:0,stereo:0,invertL:!1,invertR:!1,swap:!1};#o;#n;#a;#l;#u;#c;#h=p.None;#d=dt.Mixing.Linear;#p=!0;#g=!1;constructor(e,t){super(e),this.#e=t,this.#t=new ie,this.#r=this.own(new ne(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(t.namedParameter.volume)),this.#n=this.own(this.bindParameter(t.namedParameter.panning)),this.#a=this.own(this.bindParameter(t.namedParameter.stereo)),this.#l=this.own(this.bindParameter(t.namedParameter.invertL)),this.#u=this.own(this.bindParameter(t.namedParameter.invertR)),this.#c=this.own(this.bindParameter(t.namedParameter.swap)),this.ownAll(t.box.panningMixing.catchupAndSubscribe(r=>{this.#d=r.getValue(),this.#p=!0}),e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#t.clear(),this.eventInput.clear(),this.#g=!1}get uuid(){return this.#e.uuid}get audioOutput(){return this.#t}setAudioSource(e){return this.#h=p.wrap(e),{terminate:()=>this.#h=p.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}processAudio(e,t,r){if(this.#h.isEmpty())return;this.#p&&(this.#i.update(this.#s,this.#d,this.#g),this.#p=!1);let s=this.#h.unwrap().channels(),o=this.#t.channels();this.#i.processFrames(s,o,t,r),this.#r.processStereo(o,t,r),this.#g=!0}parameterChanged(e){switch(e){case this.#o:this.#s.gain=Ae(this.#o.getValue()),this.#p=!0;return;case this.#n:this.#s.panning=this.#n.getValue(),this.#p=!0;return;case this.#a:this.#s.stereo=this.#a.getValue(),this.#p=!0;return;case this.#l:this.#s.invertL=this.#l.getValue(),this.#p=!0;return;case this.#u:this.#s.invertR=this.#u.getValue(),this.#p=!0;return;case this.#c:this.#s.swap=this.#c.getValue(),this.#p=!0;return}}toString(){return`{${this.constructor.name}}`}};var Io=class extends ze{#e;#t;#r=p.None;#i=p.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new st(e.broadcaster,t.address)),this.ownAll(t.box.groove.catchupAndSubscribe(r=>{this.#r.ifSome(s=>s.terminate()),this.#r=p.wrap(r.targetVertex.isEmpty()?null:e.boxAdapters.adapterFor(r.targetVertex.unwrap().box,xr.checkType))}),U.create(()=>{this.#r.ifSome(r=>r.terminate()),this.#r=p.None}),e.registerProcessor(this))}get uuid(){return this.#e.uuid}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}setNoteEventSource(e){return v(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=p.wrap(e),U.create(()=>this.#i=p.None)}*processNotes(e,t,r){if(this.#i.isEmpty())return;let s=this.#i.unwrap(),o=this.#r.mapOr(di,xi.Identity);for(let n of s.processNotes(o.unwarp(e),o.unwarp(t),r))Y.isStart(n)?this.#t.noteOn(n.pitch):this.#t.noteOff(n.pitch),yield Je.overwrite(n,{position:$(o.warp(n.position),e,t)})}*iterateActiveNotesAt(e,t){if(this.#i.isEmpty())return;let r=this.#i.unwrap(),s=this.#r.mapOr(di,xi.Identity);for(let o of r.iterateActiveNotesAt(s.unwarp(e),t))yield Je.overwrite(o,{position:s.warp(o.position)})}reset(){this.eventInput.clear()}parameterChanged(e){}handleEvent(e,t){}processEvents(e,t,r){}};var Oo=class extends ze{#e;#t;#r=p.None;constructor(e,t){super(e),this.#e=t,this.#t=this.own(new st(e.broadcaster,t.address)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return v(this.#r.isEmpty(),"NoteEventSource already set"),this.#r=p.wrap(e),U.create(()=>this.#r=p.None)}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#r.isEmpty())for(let s of this.#r.unwrap().processNotes(e,t,r))yield s}*iterateActiveNotesAt(e,t){if(!this.#r.isEmpty())for(let r of this.#r.unwrap().iterateActiveNotesAt(e,t))yield r}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}};var Rn;(e=>e.create=(t,r)=>r.accept({visitAudioBusBox:s=>new li(t,t.boxAdapters.adapterFor(s,Ve)),visitVaporisateurDeviceBox:s=>new xo(t,t.boxAdapters.adapterFor(s,Jr)),visitNanoDeviceBox:s=>new No(t,t.boxAdapters.adapterFor(s,ei)),visitTapeDeviceBox:s=>new yo(t,t.boxAdapters.adapterFor(s,Xr)),visitPlayfieldDeviceBox:s=>new Vo(t,t.boxAdapters.adapterFor(s,Ht))}))(Rn||={});var Mn;(e=>e.create=(t,r)=>k(r.accept({visitUnknownMidiEffectDeviceBox:s=>new Oo(t,t.boxAdapters.adapterFor(s,oi)),visitArpeggioDeviceBox:s=>new bo(t,t.boxAdapters.adapterFor(s,_t)),visitPitchDeviceBox:s=>new Ao(t,t.boxAdapters.adapterFor(s,Zr)),visitZeitgeistDeviceBox:s=>new Io(t,t.boxAdapters.adapterFor(s,ii))}),`Could not create midi-effect for'${r.name}'`))(Mn||={});var Ri;(e=>e.create=(t,r)=>k(r.accept({visitUnknownAudioEffectDeviceBox:s=>new Ci(t,t.boxAdapters.adapterFor(s,si)),visitStereoToolDeviceBox:s=>new Do(t,t.boxAdapters.adapterFor(s,ri)),visitDelayDeviceBox:s=>new go(t,t.boxAdapters.adapterFor(s,gt)),visitReverbDeviceBox:s=>new Fo(t,t.boxAdapters.adapterFor(s,Lr)),visitRevampDeviceBox:s=>new Eo(t,t.boxAdapters.adapterFor(s,$r)),visitModularDeviceBox:s=>new Ci(t,t.boxAdapters.adapterFor(s,qt))}),`Could not create audio-effect for'${r.name}'`))(Ri||={});var ko=class extends fe{#e;#t;#r;#i;#s;#o;#n=p.None;#a=!0;#l=!1;constructor(e,t){super(e),this.#e=t,this.#t=new ie,this.#r=Qe.linear(sampleRate),this.#i=Qe.linear(sampleRate),this.#s=this.own(this.bindParameter(t.sendGain)),this.#o=this.own(this.bindParameter(t.sendPan)),this.own(e.registerProcessor(this)),this.readAllParameters()}reset(){this.#t.clear()}get adapter(){return this.#e}setAudioSource(e){return this.#n=p.wrap(e),{terminate:()=>this.#n=p.None}}get audioOutput(){return this.#t}processAudio(e,t,r){if(this.#n.isEmpty())return;if(this.#a){let c=Ae(this.#s.getValue()),d=this.#o.getValue();this.#r.set((1-Math.max(0,d))*c,this.#l),this.#i.set((1+Math.min(0,d))*c,this.#l),this.#a=!1}let s=this.#t.getChannel(0),o=this.#t.getChannel(1),n=this.#n.unwrap(),a=n.getChannel(0),l=n.getChannel(1);if(this.#r.isInterpolating()||this.#i.isInterpolating())for(let c=t;c<r;c++)s[c]=a[c]*this.#r.moveAndGet(),o[c]=l[c]*this.#i.moveAndGet();else{let c=this.#r.get(),d=this.#i.get();for(let m=t;m<r;m++)s[m]=a[m]*c,o[m]=l[m]*d}this.#l=!0}parameterChanged(e){this.#a=!0}};var Uo=class extends fe{#e;#t;#r;#i;#s;#o;#n;#a;#l=Qe.linear(sampleRate);#u=Qe.linear(sampleRate);#c=Qe.linear(sampleRate);#h=p.None;#d=!0;#p=!1;constructor(e,t){super(e),this.#e=t,this.#t=new ie,this.#r=[new Float32Array(128),new Float32Array(128)],this.#i=this.own(new ne(e.broadcaster,this.#e.address)),this.#s=this.own(this.bindParameter(this.#e.namedParameter.volume)),this.#o=this.own(this.bindParameter(this.#e.namedParameter.panning)),this.#n=this.own(this.bindParameter(this.#e.namedParameter.mute)),this.#a=this.own(this.bindParameter(this.#e.namedParameter.solo)),this.ownAll(e.registerProcessor(this),e.mixer.attachChannelStrip(this)),this.readAllParameters()}reset(){this.#i.clear(),this.#t.clear(),this.#r[0].fill(0),this.#r[1].fill(0),this.#p=!1}get isMute(){return this.#n.getValue()}get isSolo(){return this.#a.getValue()}get adapter(){return this.#e}get audioOutput(){return this.#t}handleEvent(e){}processAudio(e,t,r){if(this.#h.isEmpty())return;if(this.#d){let m=this.context.mixer;m.updateSolo();let f=this.isSolo||m.isVirtualSolo(this),y=this.isMute||m.hasChannelSolo()&&!f&&!this.#e.isOutput,F=Ae(this.#s.getValue()),S=this.#o.getValue();this.#l.set((1-Math.max(0,S))*F,this.#p),this.#u.set((1+Math.min(0,S))*F,this.#p),this.#c.set(y?0:1,this.#p),this.#d=!1}let s=this.#h.unwrap(),[o,n]=s.channels(),[a,l]=this.#t.channels(),[c,d]=this.#r;if(this.#l.isInterpolating()||this.#u.isInterpolating()||this.#c.isInterpolating())for(let m=t;m<r;m++){let f=this.#c.moveAndGet(),y=o[m]*this.#l.moveAndGet(),F=n[m]*this.#u.moveAndGet();a[m]=y*f,l[m]=F*f,c[m]=y,d[m]=F}else{let m=this.#l.get(),f=this.#u.get(),y=this.#c.get();for(let F=t;F<r;F++){let S=o[F]*m,M=n[F]*f;c[F]=S,d[F]=M,a[F]=S*y,l[F]=M*y}}this.#i.process(c,d,t,r),this.#p=!0}finishProcess(){this.#t.assertSanity()}parameterChanged(e){e===this.#s?this.requestGainUpdate():e===this.#o?this.requestGainUpdate():e===this.#n?this.requestGainUpdate():e===this.#a&&this.context.mixer.onChannelStripSoloChanged(this)}requestGainUpdate(){this.#d=!0}requestSoloUpdate(){this.#d=!0}setAudioSource(e){return this.#h=p.wrap(e),{terminate:()=>this.#h=p.None}}toString(){return`{${this.constructor.name}}`}};var Ko=class{#e=new D;#t;#r;#i;#s;#o;#n;#a=[];#l=!1;constructor(e,t){this.#t=e,this.#r=t,this.#i=A.newSet(r=>r.adapter.uuid),this.#s=this.#e.own(new Uo(this.#t.context,this.#t.adapter)),this.#o=A.newSet(({device:r})=>r.uuid),this.#n=this.#e.own(new D),this.#e.ownAll(this.#t.adapter.audioEffects.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=Ri.create(this.#t.context,r.box),o=this.#o.add({device:s,subscription:s.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(o,"Could not add.")},onRemove:r=>{this.invalidateWiring();let{device:s,subscription:o}=this.#o.removeByKey(r.uuid);o.terminate(),s.terminate()},onReorder:r=>this.invalidateWiring()}),this.#t.adapter.auxSends.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=this.#i.add(new ko(this.#t.context,r));v(s,"Could not add.")},onRemove:({uuid:r})=>{this.invalidateWiring(),this.#i.removeByKey(r).terminate()},onReorder:r=>{}}),this.#t.adapter.output.catchupAndSubscribe(r=>this.invalidateWiring()),this.#t.context.subscribeProcessPhase(r=>{r===0&&this.#l&&(this.#u(),this.#l=!1)}))}get channelStrip(){return this.#s}invalidateWiring(){this.#n.terminate(),this.#l=!0}terminate(){this.#e.terminate(),this.#o.forEach(({device:e})=>e.terminate()),this.#o.clear(),this.#a=[]}toString(){return`{${this.constructor.name}}`}#u(){let e=this.#t.adapter.isOutput,t=this.#t.context,r=this.#t.input(),s=this.#t.adapter.output.adapter.map(n=>t.getAudioUnit(n.deviceHost().uuid).inputAsAudioBus());if(r.isEmpty()||s.isEmpty()&&!e)return;let o=r.unwrap();if(this.#r.includeAudioEffects){w.replace(this.#a,this.#t.adapter.audioEffects.adapters().map(({uuid:n})=>this.#o.get(n).device));for(let n of this.#a)n.adapter().enabledField.getValue()&&(this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n.incoming)),o=n)}if(this.#r.includeSends&&this.#i.forEach(n=>{let a=t.getAudioUnit(n.adapter.targetBus.deviceHost().uuid);this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(a.inputAsAudioBus().addAudioSource(n.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n)),this.#n.own(t.registerEdge(n,a.inputAsAudioBus()))}),this.#n.own(this.#s.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,this.#s)),s.nonEmpty()&&!e){let n=s.unwrap();this.#n.own(n.addAudioSource(this.#s.audioOutput)),this.#n.own(t.registerEdge(this.#s,n))}}};var Lo=class{#e=new D;#t;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#r=t,this.#i=Ki.create(268431651),this.#s=new Set,this.#o=new Br,this.#e.ownAll(this.#t.subscribeProcessPhase(r=>{if(r===1)for(let s of this.#s)s.gate||this.#s.delete(s)}))}get uuid(){return this.#r.uuid}terminate(){this.#e.terminate()}pushRawNoteOn(e,t){this.#s.add({pitch:e,velocity:t,gate:!0,running:p.None})}pushRawNoteOff(e){for(let t of this.#s)if(t.running.isEmpty())this.#s.delete(t);else if(t.pitch===e){t.gate=!1;return}}*processNotes(e,t,r){let s=ye.every(r,5);if(this.#o.nonEmpty()&&(!s||ye.every(r,2)?yield*this.#u(e):yield*this.#c(e,t)),this.#s.size>0)for(let o of this.#s){if(o.running.isEmpty()){let{pitch:n,velocity:a}=o,l=Number.POSITIVE_INFINITY,c=Y.start(e,l,n,a);o.running=p.wrap(c),yield c}o.gate||(this.#s.delete(o),yield Y.stop(o.running.unwrap("raw note never started"),e))}if(s){let o=this.#r.tracks.collection.adapters().filter(n=>n.type===Z.Notes&&n.enabled.getValue());for(let n of o)for(let{optClip:a,sectionFrom:l,sectionTo:c}of this.#t.clipSequencing.iterate(n.uuid,e,t))a.isEmpty()?yield*this.#a(n,l,c):yield*this.#n(a.unwrap(),l,c);yield*this.#c(e,t)}}*iterateActiveNotesAt(e,t){if(this.#s.size>0)for(let{pitch:r,velocity:s}of this.#s)yield{type:"note-event",position:e,duration:Number.POSITIVE_INFINITY,pitch:r,velocity:s,cent:0};t||(yield*this.#o.overlapping(e,Me.Comparator))}reset(){this.#o.clear(),this.#s.clear()}toString(){return`{${this.constructor.name}}`}*#n(e,t,r){if(e.optCollection.isEmpty())return;let s=e.optCollection.unwrap(),o=e.duration,n=at(t,o),a=n+o;r>a?(yield*this.#l(s,t,a,n),yield*this.#l(s,a,r,a)):yield*this.#l(s,t,r,n)}*#a(e,t,r){for(let s of e.regions.collection.iterateRange(t,r)){if(this.#t.ignoresRegion(s.address.uuid)||s.mute||!ae(s,Kt))continue;let o=s.optCollection;if(o.isEmpty())continue;let n=o.unwrap();for(let{resultStart:a,resultEnd:l,rawStart:c}of De.locateLoops(s,t,r))yield*this.#l(n,a,l,c)}}*#l(e,t,r,s){let o=t-s,n=r-s;for(let a of e.events.iterateRange(o-e.maxDuration,n)){if(!Me.isOfType(a))continue;let{position:l,duration:c,chance:d,playCount:m,playCurve:f}=a;if(!(d<100&&this.#i.nextDouble(0,100)>d)){if(m>1){let y=Me.inverseCurveFunc((o-l)/c,f),F=Me.inverseCurveFunc((n-l)/c,f),S=Math.floor(y*m),M=S/m;for(;M<F;){if(M>=y){let K=Me.curveFunc(M,f)*c;if(K>=c)break;let L=Me.curveFunc(M+1/m,f)*c,z=Y.startWith(a,l+K+s,L-K);this.#o.addAndRetain({...z}),yield z}M=++S/m}}else if(o<=l&&l<n){let y=Y.startWith(a,l+s);this.#o.addAndRetain({...y}),yield y}}}}*#u(e){for(let t of this.#o.releaseAll())yield Y.stop(t,e)}*#c(e,t){for(let r of this.#o.releaseLinearCompleted(t)){let s=$(r.position+r.duration,e,t);yield Y.stop(r,s)}}};var $o=class{#e=new D;#t;#r;#i;#s;#o=!1;constructor(e){this.#t=e,this.#r=this.#e.own(new Lo(this.#t.context,this.#t.adapter)),this.#i=A.newSet(({device:t})=>t.uuid),this.#s=this.#e.own(new D),this.#e.ownAll(this.#t.adapter.midiEffects.catchupAndSubscribe({onAdd:t=>{this.invalidateWiring();let r=Mn.create(this.#t.context,t.box),s=this.#i.add({device:r,subscription:r.adapter().enabledField.subscribe(()=>this.invalidateWiring())});v(s,"Could not add.")},onRemove:t=>{this.invalidateWiring();let{device:r,subscription:s}=this.#i.removeByKey(t.uuid);s.terminate(),r.terminate()},onReorder:t=>this.invalidateWiring()}),this.#t.context.subscribeProcessPhase(t=>{t===0&&this.#o&&(this.#n(),this.#o=!1)}))}get noteSequencer(){return this.#r}invalidateWiring(){this.#s.terminate(),this.#o=!0}terminate(){this.#e.terminate()}toString(){return`{${this.constructor.name}}`}#n(){let e=this.#t.input().flatMap(s=>s.noteEventTarget);if(e.isEmpty())return;let t=e.unwrap(),r=this.#r;this.#t.adapter.midiEffects.adapters().map(s=>this.#i.get(s.uuid).device).forEach(s=>{s.adapter().enabledField.getValue()&&(this.#s.ownAll(s.setNoteEventSource(r),this.#t.context.registerEdge(s,t.incoming)),r=s)}),this.#s.own(t.setNoteEventSource(r))}};var qo=class i{static ID=0;#e=i.ID++;#t=new D;#r;#i;#s;#o;#n=p.None;constructor(e,t,r){this.#r=e,this.#i=t,this.#s=this.#t.own(new $o(this)),this.#o=this.#t.own(new Ko(this,r)),this.#t.ownAll(this.#i.input.catchupAndSubscribe(s=>{this.#s.invalidateWiring(),this.#o.invalidateWiring(),this.#n.ifSome(o=>o.terminate()),this.#n=s.getValue().flatMap(o=>p.wrap(Rn.create(e,o.box.box)))}))}input(){return this.#n}inputAsAudioBus(){return er(this.#n.unwrap("No input available"),li)}audioOutput(){return this.#o.channelStrip.audioOutput}get midiDeviceChain(){return this.#s}get audioDeviceChain(){return this.#o}get context(){return this.#r}get adapter(){return this.#i}terminate(){console.debug(`terminate ${this}`),this.#t.terminate(),this.#n.ifSome(e=>e.terminate()),this.#n=p.None}toString(){return`{${this.constructor.name}(${this.#e})}`}};var zo=class{#e;#t;#r;#i=!1;constructor(){this.#e=A.newSet(e=>e.adapter.uuid),this.#t=new Set,this.#r=new Set}attachChannelStrip(e){return this.#e.add(e),U.many(e.adapter.input.subscribe(()=>this.#s()),e.adapter.output.subscribe(()=>this.#s()),{terminate:()=>{this.#t.delete(e),this.#e.removeByValue(e),this.#s()}})}onChannelStripSoloChanged(e){e.isSolo?this.#t.add(e):this.#t.delete(e),this.#s()}hasChannelSolo(){return this.#t.size>0}isVirtualSolo(e){return this.#r.has(e)}#s(){this.#i||(this.#i=!0,this.#e.forEach(e=>e.requestSoloUpdate()))}updateSolo(){if(!this.#i)return;this.#r.clear();let e=new Set,t=r=>{e.has(r)||(e.add(r),r.adapter.input.getValue().ifSome(s=>{s.type==="bus"&&s.box.input.pointerHub.filter(u.AudioOutput).map(o=>k(o.box.accept({visitAudioUnitBox:({address:{uuid:n}})=>this.#e.get(n),visitAuxSendBox:({audioUnit:{targetVertex:n}})=>this.#e.get(n.unwrap().address.uuid)}),"Could not resolve channel-strip")).forEach(o=>{o.isSolo||this.#r.add(o),t(o)})}))};this.#e.forEach(r=>{r.isSolo&&t(r)}),this.#i=!1}};var Qt;(function(i){let e=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,t=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;i.isLocalHost=()=>e&&location.host.includes("localhost"),i.isMacOS=()=>t&&navigator.userAgent.includes("Mac OS X"),i.isWindows=()=>t&&navigator.userAgent.includes("Windows"),i.isFirefox=()=>t&&navigator.userAgent.toLowerCase().includes("firefox"),i.isWeb=()=>!i.isTauriApp(),i.isVitest=typeof process<"u"&&process.env?.VITEST==="true",i.isTauriApp=()=>"__TAURI__"in window,i.userAgent=t?navigator.userAgent.replace(/^Mozilla\/[\d.]+\s*/,"").replace(/\bAppleWebKit\/[\d.]+\s*/g,"").replace(/\(KHTML, like Gecko\)\s*/g,"").replace(/\bSafari\/[\d.]+\s*/g,"").replace(/\s+/g," ").trim():"N/A",i.id=()=>{if(!e)return"";let r="__id__",s=localStorage.getItem(r);if(T(s))return s;let o=A.toString(A.generate());return localStorage.setItem(r,o),o}})(Qt||(Qt={}));var $a;(function(i){i.encode=async(e,t="gzip")=>{let r=new CompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()},i.decode=async(e,t="gzip")=>{let r=new DecompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()}})($a||($a={}));var qa;(function(i){i.exportMethod=(s,o)=>r(s,{value:o}),i.exportBoolean=(s,o=!1)=>{let n=new Ce(o);return i.exportAccessor(s,()=>n.getValue(),a=>{let l=!!a;console.debug(`set to ${l}`),n.setValue(l)}),n},i.exportAccessor=(s,o,n=qn)=>r(s,{get:()=>{try{return console.debug(o()),0}catch(a){return console.error(a),1}},set:a=>{try{return n(a),o()}catch(l){return console.error(l),1}},enumerable:!1,configurable:!1});let e=(()=>{try{return self}catch{return{}}})(),t=e.opendaw??={},r=(s,o)=>{let n=s.split("."),a=n.splice(-1)[0],l=t;for(let c of n)l=l[c]??={};Object.defineProperty(l,a,o),console.debug(`Console command 'opendaw.${s}' exported`)}})(qa||(qa={}));var za;(function(i){i.resolveString=e=>{if(!Kn(e)){if(typeof e=="string")return e;if(Array.isArray(e))return e.join(",");if(typeof e=="object"){if(typeof e.exact=="string")return e.exact;if(Array.isArray(e.exact))return e.exact.join(",");if(typeof e.ideal=="string")return e.ideal;if(Array.isArray(e.ideal))return e.ideal.join(",")}}}})(za||(za={}));var _a;(function(i){i.truncateText=(e,t,r)=>{if(t.length===0)return{text:"",width:0};let s=e.measureText(t).width;if(s<=r)return{text:t,width:s};let o=e.measureText("\u2026").width,n=0,a=t.length|0;for(;n<a;){let c=a+n>>>1;s=e.measureText(t.substring(0,c+1)).width+o,s<=r?n=c+1:a=c}if(n===0)return{text:"",width:0};let l=t.substring(0,n);return{text:l+"\u2026",width:e.measureText(l).width+o}}})(_a||(_a={}));var Ha;(function(i){i.calc=(t,r,s)=>{let o=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,n=t;return n.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(o))).forEach(([a,l,c])=>{let d=parseFloat(l);if(isNaN(d))return g(`${a} does not contain a number`);if(c==="em")n=n.replaceAll(a,`${d*s}`);else if(c==="%")n=n.replaceAll(a,`${d/100*r}`);else if(c==="px")n=n.replaceAll(a,`${d}`);else return g(`Unknown unit '${c}'`)}),Function(`return ${n}`)()};let e=new Map;i.registerCustomCursor=(t,r)=>e.set(t,r),i.setCursor=(t,r=document)=>{r.documentElement.style.cursor=typeof t=="number"?e.get(t)??"auto":t}})(Ha||(Ha={}));var Ti;(function(i){let e=new Set,t=new Set,r=new Array,s=-1,o=null;i.add=n=>(t.add(n),{terminate:()=>t.delete(n)}),i.once=n=>{e.add(n)},i.start=n=>{let a=()=>{o===n&&((t.size>0||e.size>0)&&(t.forEach(l=>r.push(l)),e.forEach(l=>r.push(l)),e.clear(),r.forEach(l=>l()),r.length=0),s=n.requestAnimationFrame(a))};s=n.requestAnimationFrame(a),o=n,a()},i.terminate=()=>{console.debug("AnimationFrame terminate"),e.clear(),t.clear(),r.length=0,cancelAnimationFrame(s)}})(Ti||(Ti={}));var Oe=class{static subscribe(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static subscribeAny(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(e,t)=>{let r=0;return this.subscribe(e,"pointerdown",s=>{let o=performance.now();o-r<this.DOUBLE_DOWN_THRESHOLD&&t(s),r=o},{capture:!0})};static PreventDefault=e=>e.preventDefault();static isTextInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&T(e.getAttribute("contenteditable"))};var Yt;(function(i){i.isControlKey=({ctrlKey:e,metaKey:t})=>Qt.isMacOS()?t:e,i.isCopyKey=({altKey:e})=>e,i.GlobalShortcut=Object.freeze({isDelete:e=>!Oe.isTextInput(e.target)&&(e.code==="Delete"||e.code==="Backspace"),isSelectAll:e=>i.isControlKey(e)&&!e.shiftKey&&e.code==="KeyA",isDeselectAll:e=>i.isControlKey(e)&&e.shiftKey&&e.code==="KeyA"})})(Yt||(Yt={}));var Ga;(function(i){i.attach=(e,t,r)=>{let s=new D;return U.many(s,Oe.subscribe(e,"pointerdown",o=>{if(r?.multiTouch!==!0&&!o.isPrimary||o.buttons!==1||Qt.isMacOS()&&o.ctrlKey)return;let n=t(o);if(n.isEmpty())return;let a=n.unwrap(),l=o.pointerId;o.stopPropagation(),o.stopImmediatePropagation(),e.setPointerCapture(l);let c={clientX:o.clientX,clientY:o.clientY,altKey:o.altKey,shiftKey:o.shiftKey,ctrlKey:Yt.isControlKey(o)};r?.immediate===!0&&a.update(c),r?.permanentUpdates===!0?(s.own(Ti.add(()=>a.update(c))),s.own(Oe.subscribe(e,"pointermove",f=>{f.pointerId===l&&(c.clientX=f.clientX,c.clientY=f.clientY,c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f))}))):s.own(Oe.subscribe(e,"pointermove",f=>{f.pointerId===l&&(c.clientX=f.clientX,c.clientY=f.clientY,c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),a.update(c))}));let d=()=>{a.cancel?.call(a),a.finally?.call(a),s.terminate()},m=Ln(e,"ownerDocument","defaultView")??self;s.ownAll(Oe.subscribe(e,"pointerup",f=>{f.pointerId===l&&(a.approve?.call(a),a.finally?.call(a),s.terminate())},{capture:!0}),Oe.subscribe(e,"pointercancel",f=>{console.debug(f.type),f.pointerId===l&&(e.releasePointerCapture(l),d())},{capture:!0}),Oe.subscribe(m,"beforeunload",f=>{e.releasePointerCapture(l),d()},{capture:!0}),Oe.subscribe(m,"keydown",f=>{c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),f.key==="Escape"?d():a.update(c)}),Oe.subscribe(m,"keyup",f=>{c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),a.update(c)})),T(a.abortSignal)&&s.own(Oe.subscribe(a.abortSignal,"abort",()=>{e.releasePointerCapture(l),d()}))}))}})(Ga||(Ga={}));var Wa;(function(i){i.save=async(e,t)=>{if(T(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(t),s=await r.createWritable();return await s.truncate(0),await s.write(e),await s.close(),r.name??"unknown"}else{let r=new Blob([e]),s=URL.createObjectURL(r),o=document.createElement("a");return o.href=s,o.download=t?.suggestedName??"unknown",o.click(),URL.revokeObjectURL(s),t?.suggestedName??"Unknown"}},i.open=async e=>{if(T(window.showOpenFilePicker)){let{status:t,value:r,error:s}=await Rt.tryCatch(window.showOpenFilePicker(e));return t==="rejected"?Promise.reject(s):Promise.all(r.map(o=>o.getFile()))}else return new Promise((t,r)=>{T(e)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let s=document.createElement("input");s.type="file",s.multiple=e?.multiple??!1,s.style.display="none",s.addEventListener("cancel",async()=>{s.remove(),r(new DOMException("cancel","AbortError"))}),s.addEventListener("change",async o=>{let a=o.target.files;T(a)?t(w.create(l=>k(a.item(l),`No file at index ${l}`),a.length)):r(new DOMException("cancel","AbortError")),s.remove()}),document.body.appendChild(s),s.click()})}})(Wa||(Wa={}));var ja;(function(i){i.parse=e=>{let t=document.createElement("div");if(t.innerHTML=e,t.childElementCount!==1)return g(`Source html has more than one root elements: '${e}'`);let r=t.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:g(`Cannot parse to HTMLOrSVGElement from '${e}'`)},i.empty=e=>{for(;e.firstChild!==null;)e.firstChild.remove()},i.query=(e,t=document)=>k(t.querySelector(e)),i.queryAll=(e,t=document)=>Array.from(t.querySelectorAll(e)),i.sanitize=e=>{e.querySelectorAll("script").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&t.removeAttribute(r.name)})})},i.nextID=(()=>{let e=0;return()=>(++e).toString(16).padStart(4,"0")})(),i.adoptStyleSheet=(e,t)=>{v(e.includes("component"),`No 'component' found in: ${e}`);let r=`${t??"C"}${i.nextID()}`,s=new CSSStyleSheet;return s.replaceSync(e.replaceAll("component",`.${r}`)),s.cssRules.length===0?g(`No cssRules found in: ${e}`):(document.adoptedStyleSheets.push(s),r)},i.buildClassList=(...e)=>e.filter(t=>t!==!1&&t!==void 0).join(" "),i.readCssVarColor=(...e)=>{let t=document.createElement("div");document.body.appendChild(t);let r=e.map(s=>(t.style.color=s,Di.parseCssRgbOrRgba(getComputedStyle(t).color)));return t.remove(),r},i.watchResize=(e,t,r)=>{let s=new ResizeObserver(([o],n)=>t(o,n));return s.observe(e,r),{terminate:()=>s.disconnect()}},i.watchIntersection=(e,t,r)=>{let s=new IntersectionObserver(t,r);return s.observe(e),{terminate:()=>s.disconnect()}},i.secureBoundingBox=e=>{let t=e.getBoundingClientRect();if(!mi.isEmpty(t))return t;for(let r of e.children)mi.union(t,i.secureBoundingBox(r));return t},i.unfocus=(e=self)=>{let t=e.document.activeElement;t!==null&&"blur"in t&&typeof t.blur=="function"&&t.blur()},i.selectContent=e=>{let t=document.createRange(),r=window.getSelection();T(r)&&(t.selectNodeContents(e),r.removeAllRanges(),r.addRange(t))},i.unselectContent=e=>{let t=window.getSelection();!T(t)||t.rangeCount===0||e.contains(t.getRangeAt(0).commonAncestorContainer)&&t.removeAllRanges()},i.limitChars=(e,t,r)=>{if(!(t in e))return g(`${t} not found in ${e}`);if(typeof e[t]!="string")return g(`${t} in ${e} is not a string`);if(e[t].length>r)if(e[t]=e[t].substring(0,r),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.setSelectionRange(r,r);else{let s=e.ownerDocument,o=s.createRange(),n=s.defaultView?.getSelection();if(!T(n))return;o.selectNodeContents(e),o.collapse(!1),n.removeAllRanges(),n.addRange(o)}},i.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(ja||(ja={}));var aO=(()=>{let i={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},e={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:i,Win:e,System:Qt.isMacOS()?i:e})})();var Qa;(function(i){i.read=async e=>{let t=[];for(;;){let{done:n,value:a}=await e.read();if(n)break;t.push(a)}let r=t.reduce((n,a)=>n+a.length,0),s=new Uint8Array(r),o=0;for(let n of t)s.set(n,o),o+=n.length;return s.buffer}})(Qa||(Qa={}));var Ya;(function(i){i.pathBuilder=()=>new class{#e="";moveTo(e,t){return this.#e+=`M${e.toFixed(3)} ${t.toFixed(3)}`,this}lineTo(e,t){return this.#e+=`L${e.toFixed(3)} ${t.toFixed(3)}`,this}quadratic(e,t,r,s){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)}`,this}quadraticTo(e,t){return this.#e+=`T${e.toFixed(3)} ${t.toFixed(3)}`,this}cubic(e,t,r,s,o,n){return this.#e+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)} ${o.toFixed(3)} ${n.toFixed(3)}`,this}arc(e,t,r,s,o,n,a){return this.#e+=`A${e} ${t} ${r} ${s?1:0} ${o?1:0} ${n.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(e,t,r,s,o){let n=e+Math.cos(s)*r,a=t+Math.sin(s)*r,l=e+Math.cos(o)*r,c=t+Math.sin(o)*r,d=o-s;for(;d<0;)d+=Math.PI*2;return this.moveTo(n,a).arc(r,r,0,d>Math.PI,!0,l,c)}close(){return this.#e+="Z",this}get(){return this.#e}}})(Ya||(Ya={}));var Xa;(function(i){let e=new Array;i.watchWeak=(r,s)=>{let o=new WeakRef(r),n=s(o);return e.push([o,n]),e.length===1&&t(),r};let t=()=>{console.debug("start weak watching");let r=setInterval(()=>{let s=e.length;for(;--s>=0;){let o=e[s];o[0].deref()===void 0&&(o[1].terminate(),e.splice(s,1),e.length===0&&clearInterval(r))}},1e3)}})(Xa||(Xa={}));var _o=Symbol.for("@openDAW/lib-dom");globalThis[_o]?console.debug(`%c${_o.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[_o]=!0,console.debug(`%c${_o.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var yt;(function(i){i[i.Float=0]="Float",i[i.FloatArray=1]="FloatArray",i[i.Integer=2]="Integer",i[i.IntegerArray=3]="IntegerArray",i[i.ByteArray=4]="ByteArray"})(yt||(yt={}));var ci;(function(i){i[i.WRITE=0]="WRITE",i[i.READ=1]="READ"})(ci||(ci={}));var yr;(function(i){i[i.ID=15793935]="ID",i[i.START=15790320]="START",i[i.END=986895]="END"})(yr||(yr={}));var Ho=class i{static create(e,t){return new i(e.channel(t))}#e=[];#t=new SharedArrayBuffer(1);#r=new Int8Array(this.#t);#i;#s=de.create(0);#o=p.None;#n=p.None;#a=-1;#l=-1;#u=!1;#c=!1;constructor(e){this.#i=Te.sender(e,({dispatchAndForget:t})=>new class{sendShareLock(r){t(this.sendShareLock,r)}sendUpdateData(r){t(this.sendUpdateData,r)}sendUpdateStructure(r){t(this.sendUpdateStructure,r)}})}flush(){let e=this.#h();if(e.nonEmpty()){this.#c||(this.#i.sendShareLock(this.#t),this.#c=!0),this.#i.sendUpdateStructure(e.unwrap());let t=this.#d();if(this.#s.remaining<t){let r=lt(t),s=new SharedArrayBuffer(r);this.#s=de.use(s),this.#o=p.wrap(s),this.#i.sendUpdateData(s)}}this.#o.isEmpty()||Atomics.load(this.#r,0)===ci.WRITE&&(this.#p(this.#s),this.#s.position=0,Atomics.store(this.#r,0,ci.READ))}broadcastFloat(e,t){return this.#f(new class{type=yt.Float;address=e;capacity=8;put(r){r.writeFloat(t())}})}broadcastInteger(e,t){return this.#f(new class{type=yt.Integer;address=e;capacity=8;put(r){r.writeInt(t())}})}broadcastFloats(e,t,r){return this.#f(new class{type=yt.FloatArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length);for(let o of t)s.writeFloat(o)}})}broadcastIntegers(e,t,r){return this.#f(new class{type=yt.IntegerArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length),t.forEach(o=>s.writeInt(o))}})}broadcastByteArray(e,t,r){return this.#f(new class{type=yt.ByteArray;address=e;capacity=4+t.byteLength;put(s){r(),s.writeInt(t.byteLength),s.writeBytes(t)}})}#h(){if(this.#u){try{this.#n=p.wrap(this.#B())}catch(e){throw e}this.#u=!1}if(this.#n.nonEmpty()){let e=this.#n;return this.#n=p.None,e}return p.None}#d(){return this.#l===-1&&(this.#l=this.#g()+12),this.#l}terminate(){w.clear(this.#e),this.#n=p.None,this.#u=!1,this.#l=0}#p(e){v(!this.#u&&this.#n.isEmpty(),"Cannot flush while update is available");let t=this.#d();v(e.remaining>=t,"Insufficient data"),e.writeInt(this.#a),e.writeInt(yr.START);for(let r of this.#e)r.put(e);e.writeInt(yr.END)}#g(){return this.#e.reduce((e,t)=>e+t.capacity,0)}#f(e){return this.#e.push(e),this.#x(),{terminate:()=>{w.removeOpt(this.#e,e),this.#x()}}}#x(){this.#l=-1,this.#u=!0}#B(){let e=de.create();e.writeInt(yr.ID),e.writeInt(++this.#a),e.writeInt(this.#e.length);for(let{address:t,type:r}of this.#e)t.write(e),e.writeByte(r);return e.toArrayBuffer()}};var Xt;(function(i){class e{shift;numPeaks;dataOffset;constructor(r,s,o){this.shift=r,this.numPeaks=s,this.dataOffset=o}unitsEachPeak(){return 1<<this.shift}}i.Stage=e,i.unpack=(t,r)=>{switch(r){case 0:return At.intBitsToFloat(t);case 1:return At.intBitsToFloat(t>>16);default:return Ge(r)}}})(Xt||(Xt={}));var Go=class i{stages;data;numFrames;numChannels;static from(e){v(e.readString()==="PEAKS","Wrong header");let t=e.readInt(),r=[];for(let l=0;l<t;l++){let c=e.readInt(),d=e.readInt(),m=e.readInt();e.readInt(),r[l]=new Xt.Stage(m,d,c)}let s=e.readInt(),o=[];for(let l=0;l<s;l++){let c=new Int8Array(e.readInt());e.readBytes(c),o[l]=new Int32Array(c.buffer)}let n=e.readInt(),a=e.readInt();return new i(r,o,n,a)}static None=new i([],[],0,0);static findBestFit=(e,t=1200)=>{let r=e/t;if(r<=1)return new Uint8Array(0);let s=3,o=Math.floor(Math.log(r)/Math.LN2),n=Math.max(1,Math.floor(o/s));return new Uint8Array(w.create(a=>s*(a+1),n))};constructor(e,t,r,s){this.stages=e,this.data=t,this.numFrames=r,this.numChannels=s}nearest(e){if(this.stages.length===0)return null;let t=Math.floor(Math.log(Math.abs(e))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(t>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let e=de.create();e.writeString("PEAKS"),e.writeInt(this.stages.length);for(let t=0;t<this.stages.length;t++){let{dataOffset:r,numPeaks:s,shift:o}=this.stages[t];e.writeInt(r),e.writeInt(s),e.writeInt(o),e.writeInt((1<<o)-1)}e.writeInt(this.data.length);for(let t=0;t<this.data.length;t++){let r=new Int8Array(this.data[t].buffer);e.writeInt(r.length),e.writeBytes(r)}return e.writeInt(this.numFrames),e.writeInt(this.numChannels),e.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var Ja;(function(i){i.install=r=>Te.executor(r.channel("peaks"),new class{async generateAsync(s,o,n,a,l){return e(s,o,n,a,l).toArrayBuffer()}});let e=(r,s,o,n,a)=>{if(o.length!==a)return g(`Invalid numberOfChannels. Expected: ${a}. Got ${o.length}`);class l{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let c=wa(),d=s.length,[m,f]=t(s,n),y=w.create(()=>new Int32Array(f),a),F=(1<<m[0].shift)-1,S=a*n,M=0;for(let K=0;K<a;++K){let L=y[K],z=o[K],_=w.create(()=>new l,d),te=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY,ce=0;for(let H=0;H<n;++H){let J=z[H];if(te=Math.min(J,te),he=Math.max(J,he),(++ce&F)===0){for(let O=0;O<d;++O){let X=m[O],ee=_[O];ee.min=Math.min(ee.min,te),ee.max=Math.max(ee.max,he),((1<<X.shift)-1&ce)===0&&(L[X.dataOffset+ee.index++]=i.pack(ee.min,ee.max),ee.min=Number.POSITIVE_INFINITY,ee.max=Number.NEGATIVE_INFINITY)}te=Number.POSITIVE_INFINITY,he=Number.NEGATIVE_INFINITY}(++M&65535)===0&&r(M/S)}}return r(1),c.lab(`SamplePeaks '${self.constructor.name}'`),new Go(m,y,n,a)},t=(r,s)=>{let o=0;return[w.create(a=>{let l=r[a],c=Math.ceil(s/(1<<l)),d=new Xt.Stage(l,c,o);return o+=c,d},r.length),o]};i.pack=(r,s)=>{let o=At.floatToIntBits(r),n=At.floatToIntBits(s);return o|n<<16}})(Ja||(Ja={}));var Za;(function(i){i.renderBlocks=(e,t,r,{u0:s,u1:o,v0:n,v1:a,x0:l,x1:c,y0:d,y1:m})=>{let f=(o-s)/(c-l),y=t.nearest(f);if(y===null)return;let F=(m-d-1)/(a-n),S=y.unitsEachPeak(),M=l-Math.floor(l),K=f/S,L=(s-M*f)/f*K,z=Math.floor(L),_=0,te=0,he=t.data[r];for(let ce=Math.floor(l);ce<Math.floor(c);ce++){let H=L+K,J=Math.floor(H),O=!1;for(;z<J;){let Ee=he[y.dataOffset+z++];_=Math.min(Xt.unpack(Ee,0),_),te=Math.max(Xt.unpack(Ee,1),te),O=!0}let X=d+Math.floor((_-n)*F),ee=d+Math.floor((te-n)*F),ke=Math.max(d,Math.min(X,ee)),_e=Math.min(m,Math.max(X,ee));if(e.fillRect(ce,ke,1,_e===ke?1:_e-ke),O){let Ee=te;te=_,_=Ee}L=H,z=J}}})(Za||(Za={}));var el;(function(i){i.init=r=>Te.executor(r.channel("opfs"),new class{#e=new Map;async write(s,o){await this.#t(s,async()=>{let n=await this.#r(s,{create:!0});try{n.truncate(o.length),n.write(o.buffer,{at:0}),n.flush()}finally{n.close()}})}async read(s){return await this.#t(s,async()=>{let o=await this.#r(s);try{let n=o.getSize(),a=new Uint8Array(n);return o.read(a),a}finally{o.close()}})}async delete(s){await this.#t(s,async()=>{let o=t(s);return o.length===0?this.clear():this.#i(o.slice(0,-1)).then(n=>n.removeEntry(k(o.at(-1)),{recursive:!0}))})}async list(s){let o=t(s),{status:n,value:a}=await Rt.tryCatch(this.#i(o));if(n==="rejected")return w.empty();let l=[];for await(let{name:c,kind:d}of a.values())l.push({name:c,kind:d});return l}async clear(){let s=await navigator.storage.getDirectory();for await(let[o,n]of s.entries())n.kind==="file"?await s.removeEntry(o):n.kind==="directory"&&await s.removeEntry(o,{recursive:!0})}async#t(s,o){let n=this.#e.get(s);n&&await n;let a=()=>g("Lock not acquired"),l=new Promise(c=>a=c);this.#e.set(s,l);try{return await o()}finally{a(),this.#e.get(s)===l&&this.#e.delete(s)}}async#r(s,o){let n=t(s);return await(await(await this.#i(n.slice(0,-1),o)).getFileHandle(k(n.at(-1)),o)).createSyncAccessHandle()}async#i(s,o){let n=await navigator.storage.getDirectory();for(let a of s)n=await n.getDirectoryHandle(a,o);return n}});let t=r=>{let s=r.replace(/^\/+|\/+$/g,"");return s===""?[]:s.split("/")}})(el||(el={}));var Wo=Symbol.for("@openDAW/lib-fusion");globalThis[Wo]?console.debug(`%c${Wo.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[Wo]=!0,console.debug(`%c${Wo.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var jo=class{#e;#t=new ie;#r=[];constructor(e){this.#e=e}process({blocks:e}){e.forEach(({p0:t,p1:r,bpm:s,s0:o,s1:n,flags:a})=>{if(this.#e.metronomeEnabled&&ye.every(a,1))for(let l of Pt.iterate(t,r,G.Quarter)){v(t<=l&&l<r,`${l} out of bounds (${t}, ${r})`);let c=Math.floor(G.pulsesToSamples(l-t,s,sampleRate));this.#r.push(new Tn(l,o+c))}this.#t.clear(o,n);for(let l=this.#r.length-1;l>=0;l--)this.#r[l].processAdd(this.#t,o,n)&&this.#r.splice(l,1)})}get output(){return this.#t}},Tn=class{#e;#t=0;#r=0;constructor(e,t){v(t>=0&&t<128,`${t} out of bounds`),this.#e=G.toParts(e).beats===0?880:440,this.#r=t}processAdd(e,t,r){let[s,o]=e.channels(),n=Math.floor(.002*sampleRate),a=Math.floor(.05*sampleRate);for(let l=Math.max(this.#r,t);l<r;l++){let c=Math.min(this.#t/n,1-(this.#t-n)/a),d=Math.sin(this.#t/sampleRate*We*this.#e)*.25*c*c;if(s[l]+=d,o[l]+=d,++this.#t>n+a)return!0}return this.#r=0,!1}};var Qo=class{#e;#t;#r=!0;#i=!1;#s=null;#o=!1;#n=0;constructor(e,t){this.#e=e,this.#e.timelineBoxAdapter.markerTrack.subscribe(()=>this.#o=!0),this.#e.timelineBoxAdapter.box.bpm.subscribe(()=>this.#i=!0),this.#r=t?.pauseOnLoopDisabled??!1,this.#t=new ki}setCallback(e,t){return this.#t.add(e,t),U.create(()=>this.#t.remove(e,t))}reset(){this.#i=!1,this.#o=!1,this.#n=0,this.#s=null}process(e){let t=!1,{timeInfo:r,timelineBoxAdapter:{box:s,markerTrack:o}}=this.#e,n=s.bpm.getValue(),a=r.transporting;if(a){let l=[],c=r.position,d=0,m=0,f=r.getLeapStateAndReset();for(;d<128;){if(this.#o||f){this.#o=!1;let H=o.events.lowerEqual(c);(this.#s?.at(0)??null)!==H&&(this.#s=T(H)?[H,0]:null,t=!0)}let y=128-d,F=c+G.samplesToPulses(y,n,sampleRate),S=null,M=Number.POSITIVE_INFINITY;if(o.enabled){let H=Array.from(le.take(o.events.iterateFrom(c),2));if(H.length>0){let[J,O]=H;this.#s===null?J.position>=c&&J.position<F&&(S={type:"marker",prev:J,next:O},M=J.position):T(O)&&O!==this.#s[0]&&J.position<c&&O.position<F&&(S={type:"marker",prev:J,next:O},M=O.position)}}let{isRecording:K,isCountingIn:L}=this.#e.timeInfo,{from:z,to:_,enabled:te}=s.loopArea;if(te.getValue()&&!(K||L)||this.#r){let H=_.getValue();c<H&&F>H&&H<M&&(S={type:"loop",target:z.getValue()},M=H)}if(this.#t.keyCount()>0)for(let H of this.#t.keys())c<H&&F>H&&H<M&&(S={type:"callback",position:H,callbacks:this.#t.get(H)},M=H);let ce=!r.isCountingIn;if(S===null){let H=d+y;l.push({index:m++,p0:c,p1:F,s0:d,s1:H,bpm:n,flags:ni.create(a,f,ce,this.#i)}),f=!1,c=F,d=H}else{let H=()=>{if(M>c){let O=d+G.pulsesToSamples(M-c,n,sampleRate)|0;l.push({index:m++,p0:c,p1:M,s0:d,s1:O,bpm:n,flags:ni.create(a,f,ce,this.#i)}),f=!1,c=M,d=O}},J=()=>{if(d<128){let O=d+G.pulsesToSamples(F-c,n,sampleRate)|0;l.push({index:m++,p0:c,p1:M,s0:d,s1:O,bpm:n,flags:ni.create(!1,!1,!1,this.#i)}),d=O}};switch(S.type){case"loop":{H(),this.#r?(this.#e.timeInfo.pause(),J()):(c=S.target,f=!0);break}case"marker":{let{prev:O,next:X}=S;!T(this.#s)||this.#s[0]!==O?this.#s=[O,0]:++this.#s[1]<O.plays||O.plays===0?(H(),c=O.position,f=!0):this.#s=[X,0],t=!0;break}case"callback":{H(),S.callbacks.forEach(O=>O());break}}}this.#i=!1}e({blocks:l}),r.advanceTo(c),this.#n=c}else{if(this.#o||r.getLeapStateAndReset()){this.#o=!1;let m=o.events.lowerEqual(r.position);m!==null&&this.#s?.at(0)!==m&&(this.#s=[m,0],t=!0)}let l=this.#n,c=l+G.samplesToPulses(128,n,sampleRate),d={blocks:[{index:0,p0:l,p1:c,s0:0,s1:128,bpm:n,flags:ni.create(!1,!1,!1,!1)}]};e(d),this.#n=c}t&&this.#e.engineToClient.switchMarkerState(T(this.#s)?[this.#s[0].uuid,this.#s[1]]:null)}};var Vn=class{constructor(e,t){this.uuid=e;this.engineToClient=t;t.fetchAudio(e).then(r=>this.#t=p.wrap(r))}peaks=p.None;#e={type:"idle"};#t=p.None;get data(){return this.#t}get state(){return this.#e}subscribe(e){return U.Empty}invalidate(){}toString(){return"{AudioLoaderWorklet}"}},Yo=class{#e;#t;constructor(e){this.#e=e,this.#t=A.newSet(t=>t.uuid)}record(e){}getOrCreate(e){return this.#t.getOrCreate(e,t=>new Vn(t,this.#e))}remove(e){}invalidate(e){}};var Xo=class{constructor(e){this.uuid=e}waiting=p.None;playing=p.None},Jo=class{#e;#t;#r=[];#i=[];#s=[];constructor(e){this.#e=e,this.#e.subscribeToAllUpdatesImmediate({onUpdate:t=>{if(t.type==="delete"){let r=t.uuid;this.#t.opt(r).ifSome(s=>{s.playing.ifSome(o=>this.#n(o.uuid)),s.playing=p.None,s.waiting=p.None}),this.#t.forEach(s=>{s.playing.nonEmpty()&&A.equals(s.playing.unwrap().uuid,r)&&(s.playing=p.None,this.#n(r));let o=s.waiting.flatMap(di);o.nonEmpty()&&A.equals(o.unwrap().uuid,r)&&(s.waiting=p.None)})}}}),this.#t=A.newSet(t=>t.uuid)}schedulePlay(e){e.trackBoxAdapter.ifSome(({uuid:t})=>{let r=this.#t.getOrCreate(t,o=>new Xo(o));if(r.playing.nonEmpty()&&r.playing.unwrap()===e){console.debug(`${e} is already playing (ignore)`);return}let s=r.waiting.flatMap(o=>o);s.nonEmpty()&&(console.debug("obsolete",s.unwrap()),this.#s.push(s.unwrap().uuid),r.waiting=p.None),console.debug(`schedulePlay(${A.toString(r.uuid)} > ${e})`),w.removeOpt(this.#s,e.uuid),r.waiting=p.wrap(p.wrap(e))})}scheduleStop({uuid:e}){let t=this.#t.getOrCreate(e,s=>new Xo(s)),r=t.waiting.flatMap(s=>s);r.nonEmpty()&&(console.debug("obsolete",r.unwrap()),this.#s.push(r.unwrap().uuid),t.waiting=p.None),t.playing.nonEmpty()&&(console.debug(`scheduleStop(${A.toString(e)})`),t.waiting=p.wrap(p.None))}reset(){this.#t.forEach(e=>{e.waiting.ifSome(t=>t.ifSome(r=>this.#s.push(r.uuid))),e.waiting=p.None,e.playing.ifSome(t=>this.#n(t.uuid)),e.playing=p.None}),this.#t.clear()}*iterate(e,t,r){let s=this.#t.getOrNull(e);if(s===null){yield{optClip:p.None,sectionFrom:t,sectionTo:r};return}if(s.waiting.nonEmpty()){let o=s.waiting.unwrap(),n=s.playing.mapOr(l=>l.duration,G.Bar),a=at(r,n);a>=t?(t<a&&(yield{optClip:s.playing,sectionFrom:t,sectionTo:a}),s.waiting=p.None,s.playing.ifSome(l=>this.#n(l.uuid)),o.nonEmpty()?(s.playing=o,this.#o(o.unwrap().uuid)):s.playing=p.None,yield{optClip:s.playing,sectionFrom:a,sectionTo:r}):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}else if(s.playing.nonEmpty()){let o=s.playing.unwrap();if(o.box.playback.loop.getValue())yield{optClip:s.playing,sectionFrom:t,sectionTo:r};else{let n=at(t,o.duration)+o.duration;n<=r?(yield{optClip:s.playing,sectionFrom:t,sectionTo:n},s.playing=p.None,this.#n(o.uuid),n<r&&(yield{optClip:p.None,sectionFrom:n,sectionTo:r})):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}}else yield{optClip:p.None,sectionFrom:t,sectionTo:r}}changes(){if(this.#r.length>0||this.#i.length>0||this.#s.length>0){let e=p.wrap({started:this.#r.slice(),stopped:this.#i.slice(),obsolete:this.#s.slice()});return this.#r.length=0,this.#i.length=0,this.#s.length=0,e}return p.None}terminate(){this.#t.clear(),this.#r.length=0,this.#i.length=0,this.#s.length=0}#o(e){this.#r.push(e)}#n(e){this.#i.push(e)}};var Dn;(e=>e.Default={includeAudioEffects:!0,includeSends:!0})(Dn||={});var ul=!1,Zo=class extends AudioWorkletProcessor{#e;#t;#r;#i;#s;#o;#n;#a;#l;#u;#c;#h;#d;#p;#g;#f;#x;#B;#P;#S;#F;#D;#C;#v;#y=p.None;#b=p.None;#R=p.None;#M=!1;#T=!0;#A=!1;#E=0;#w=0;#N=!0;#V=4;constructor({processorOptions:{sab:e,project:t,exportConfiguration:r,options:s}}){super();let{boxGraph:o,mandatoryBoxes:{rootBox:n,timelineBox:a}}=ho.decode(t);this.#e=new D,this.#t=ba.for(this.port),this.#r=o,this.#i=new ss,this.#s=Te.sender(this.#t.channel("engine-to-client"),l=>new class{log(c){l.dispatchAndForget(this.log,c)}fetchAudio(c){return l.dispatchAndReturn(this.fetchAudio,c)}notifyClipSequenceChanges(c){l.dispatchAndForget(this.notifyClipSequenceChanges,c)}switchMarkerState(c){l.dispatchAndForget(this.switchMarkerState,c)}ready(){l.dispatchAndForget(this.ready)}}),this.#n=new Yo(this.#s),this.#a=A.newSet(l=>l.adapter.uuid),this.#c=new uo,this.#o=this.#e.own(new ro(this)),this.#l=this.#o.adapterFor(n,Yr),this.#u=this.#o.adapterFor(a,it),this.#h=new _i,this.#d=new Hi(this.#h),this.#p=new q,this.#g=new zo,this.#S=new jo(this.#i),this.#F=new Qo(this,s),this.#v=A.newSet(l=>l),this.#D=Er.writer(ka(),e,l=>{let{transporting:c,isCountingIn:d,isRecording:m,position:f}=this.#i;l.position=f,l.playbackTimestamp=this.#w,l.countInBeatsTotal=this.#V,l.countInBeatsRemaining=d?(this.#E-f)/G.Quarter:0,l.isPlaying=c,l.isRecording=m,l.isCountingIn=d}),this.#f=this.#e.own(Ho.create(this.#t,"engine-live-data")),this.#B=new mo(this),this.#P=this.#e.own(new ne(this.#f,W.compose(A.Lowest))),this.#x=this.#e.own(new Jo(this.#r)),this.#e.ownAll(Ba(this.#r,this.#t.channel("engine-sync")),Te.executor(this.#t.channel("engine-commands"),{play:()=>{this.#N&&(this.#i.position=this.#w),this.#i.transporting=!0},stop:l=>{(this.#i.isRecording||this.#i.isCountingIn)&&(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.position=this.#N?this.#w:0);let c=this.#i.transporting;this.#i.transporting=!1,this.#i.metronomeEnabled=this.#A,this.#v.clear(),(l||!c)&&this.#I()},setPosition:l=>{this.#i.isRecording||(this.#i.position=this.#w=l)},startRecording:l=>{if(!(this.#i.isRecording||this.#i.isCountingIn))if(!this.#i.transporting&&l){let c=this.#i.position,d=this.#u.box.signature.nominator.getValue(),m=this.#u.box.signature.denominator.getValue();this.#E=at(c,G.fromSignature(d,m)),this.#i.isCountingIn=!0,this.#i.metronomeEnabled=!0,this.#i.transporting=!0,this.#i.position=this.#E-G.fromSignature(this.#V,m);let f=this.#F.setCallback(this.#E,()=>{this.#i.isCountingIn=!1,this.#i.isRecording=!0,this.#i.metronomeEnabled=this.#A,f.terminate()})}else this.#i.transporting=!0,this.#i.isRecording=!0},stopRecording:()=>{!this.#i.isRecording&&!this.#i.isCountingIn||(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#A,this.#i.transporting=!1,this.#v.clear())},setMetronomeEnabled:l=>this.#i.metronomeEnabled=this.#A=l,setPlaybackTimestampEnabled:l=>this.#N=l,queryLoadingComplete:()=>Promise.resolve(this.#r.boxes().every(l=>l.accept({visitAudioFileBox:c=>this.#n.getOrCreate(c.address.uuid).data.nonEmpty()&&c.pointerHub.nonEmpty()})??!0)),panic:()=>this.#M=!0,noteSignal:l=>{if(Wt.isOn(l)){let{uuid:c,pitch:d,velocity:m}=l;this.optAudioUnit(c).ifSome(f=>f.midiDeviceChain.noteSequencer.pushRawNoteOn(d,m))}else if(Wt.isOff(l)){let{uuid:c,pitch:d}=l;this.optAudioUnit(c).ifSome(m=>m.midiDeviceChain.noteSequencer.pushRawNoteOff(d))}},ignoreNoteRegion:l=>this.#v.add(l),scheduleClipPlay:l=>{l.forEach(c=>{let d=this.#r.findBox(c);if(d.isEmpty())console.warn(`Could not scheduleClipPlay. Cannot find clip: '${A.toString(c)}'`);else{let m=Hs.for(this.#o,d.unwrap());this.#x.schedulePlay(m)}}),this.#i.transporting=!0},scheduleClipStop:l=>{l.forEach(c=>{let d=this.#r.findBox(c);d.isEmpty()?console.warn(`Could not scheduleClipStop. Cannot find track: '${A.toString(c)}'`):this.#x.scheduleStop(this.#o.adapterFor(d.unwrap(),me))})},terminate:()=>{this.#R.ifSome(l=>l.terminate()),this.#R=p.None,this.#T=!1,this.#v.clear(),this.#e.terminate()}}),this.#l.audioUnits.catchupAndSubscribe({onAdd:l=>{let c=A.toString(l.uuid),d=T(r?.[c])?r[c]:Dn.Default,m=new qo(this,l,d),f=this.#a.add(m);if(v(f,`Could not add ${m}`),m.adapter.isOutput){v(this.#b.isEmpty(),"Output can only assigned once."),this.#b=p.wrap(m);return}},onRemove:({uuid:l})=>this.#a.removeByKey(l).terminate(),onReorder:nt})),this.#C=p.wrap(r).match({none:()=>w.empty(),some:l=>Object.keys(l).map(c=>this.#a.get(A.parse(c)))}),this.#s.ready(),console.log=(...l)=>this.#s.log(l.join(", "))}ignoresRegion(e){return this.#v.hasKey(e)}process(e,t){try{return this.render(e,t)}catch(r){throw this.#s.log(r),r}}render(e,[t]){if(!this.#T)return!1;if(this.#M)return g("Manual Panic");let r=this.#i.metronomeEnabled;this.#p.notify(0),this.#y.isEmpty()&&(this.#d.update(),this.#y=p.wrap(this.#d.sorted().concat()),ul&&console.debug(`%cAudio-Graph%c
|
3
|
+
`),this));for(let r of t)r.defer();for(let r of e)r.unstage();this.unstage()}unstage(){this.graph.unstageBox(this)}isValid(){if(this.#i.mandatory&&this.pointerHub.incoming().length===0)return!1;let e=t=>t.every(r=>r.accept({visitPointerField:s=>!s.mandatory||s.nonEmpty(),visitArrayField:s=>e(s.fields()),visitObjectField:s=>e(s.fields()),visitPrimitiveField:s=>!0,visitField:s=>!0})??!0);return e(this.fields())}toString(){return`${this.constructor.name} ${this.address.toString()}`}};Al([br,Pa("design:type",Je),Pa("design:paramtypes",[])],F.prototype,"pointerHub",null);var Y;(function(i){i[i.This=0]="This",i[i.Parent=1]="Parent",i[i.Children=2]="Children"})(Y||(Y={}));var os;(function(i){i.create=()=>new Dn})(os||(os={}));var Dn=class{#t=new Bi(lr.equals);#e=new Bi(lr.startsWith);#r=new Bi(lr.endsWith);#i=[];#s=0;#o=!1;subscribe(e,t,r){let s=new Vn(t,e,this.#s++,r);if(this.#o){let o=new In(s,e);return this.#i.push(o),o}else return this.subscribeMonitor(s,e)}dispatch(e){this.#o=!0,[...this.#t.filter(e),...this.#e.filter(e),...this.#r.filter(e)].sort(({order:r},{order:s})=>r-s).forEach(r=>r.procedure(e)),this.#o=!1,this.#i.forEach(r=>r.subscribe(this)),this.#i.length=0}subscribeMonitor(e,t){switch(t){case Y.This:return this.#t.subscribe(e);case Y.Parent:return this.#e.subscribe(e);case Y.Children:return this.#r.subscribe(e);default:return Ge(t)}}countStations(){return this.#t.count()+this.#e.count()+this.#r.count()}},Vn=class{address;propagation;order;procedure;constructor(e,t,r,s){this.address=e,this.propagation=t,this.order=r,this.procedure=s}toString(){return`{ Monitor address: ${this.address}, propagation: ${Y[this.propagation]}, order: ${this.order} }`}},Bi=class{filterStrategy;#t=[];#e=!0;constructor(e){this.filterStrategy=e}subscribe(e){return this.#t.push(e),this.#e=this.#t.length<2,{terminate:()=>{let t=this.#t.length;for(;--t>=0;)this.#t[t]===e&&this.#t.splice(t,1)}}}stations(){return this.#e||(this.#t.sort(lr.Comparator),this.#e=!0),this.#t}filter(e){return this.filterStrategy(e.address,this.stations())}count(){return this.#t.length}},In=class{monitor;propagation;#t=new I;#e=!1;constructor(e,t){this.monitor=e,this.propagation=t}subscribe(e){this.#e||(this.#t.terminate(),this.#t.own(e.subscribeMonitor(this.monitor,this.propagation)))}terminate(){this.#e=!0,this.#t.terminate()}};var me;(function(i){i.Boolean="boolean",i.Float32="float32",i.Int32="int32",i.String="string",i.Bytes="bytes"})(me||(me={}));var cr={[me.Boolean]:{type:me.Boolean,encode:(i,e)=>i.writeBoolean(e),decode:i=>i.readBoolean()},[me.Float32]:{type:me.Float32,encode:(i,e)=>i.writeFloat(e),decode:i=>i.readFloat()},[me.Int32]:{type:me.Int32,encode:(i,e)=>i.writeInt(e),decode:i=>i.readInt()},[me.String]:{type:me.String,encode:(i,e)=>i.writeString(e),decode:i=>i.readString()},[me.Bytes]:{type:me.Bytes,encode:(i,e)=>{i.writeInt(e.length),i.writeBytes(e)},decode:i=>{let e=new Int8Array(i.readInt());return i.readBytes(e),e}}},ur=class extends T{#t;#e;#r;constructor(e,t,r){super(e),this.#t=t,this.#e=this.clamp(r),this.#r=this.#e}accept(e){return x(e.visitPrimitiveField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(Y.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.subscribe(e)}get type(){return this.#t}get initValue(){return this.#e}setInitValue(e){b(this.graph.constructingBox(),"Cannot change initial value at runtime"),this.setValue(this.#e=e)}getValue(){return this.#r}setValue(e){let t=this.#r,r=this.clamp(e);this.equals(r)||(this.#r=e,this.graph.onPrimitiveValueUpdate(this,t,r))}writeValue(e,t){this.serialization().encode(e,t)}readValue(e){return this.serialization().decode(e)}toJSON(){let e=this.getValue();return ArrayBuffer.isView(e)?g("not implemented"):e}fromJSON(e){return g("Type mismatch")}reset(){this.setValue(this.#e)}},N=class i extends ur{static create(e,t=!1){return new i(e,t)}constructor(e,t){super(e,me.Boolean,t)}toggle(){this.setValue(!this.getValue())}serialization(){return cr[me.Boolean]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readBoolean())}write(e){e.writeBoolean(this.getValue())}fromJSON(e){typeof e=="boolean"?this.setValue(e):console.warn("BooleanField Type mismatch",e,this.address.toString())}},P=class i extends ur{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,me.Float32,t)}serialization(){return cr[me.Float32]}equals(e){return this.getValue()===e}clamp(e){return ct.toFloat32(e)}read(e){this.setValue(e.readFloat())}write(e){e.writeFloat(this.getValue())}fromJSON(e){typeof e=="number"?this.setValue(e):console.warn("Float32Field Type mismatch",e,this.address.toString())}},v=class i extends ur{static create(e,t=0){return new i(e,t)}constructor(e,t){super(e,me.Int32,t)}serialization(){return cr[me.Int32]}equals(e){return this.getValue()===e}clamp(e){return Se.toInt(e)}read(e){this.setValue(e.readInt())}write(e){e.writeInt(this.getValue())}fromJSON(e){typeof e=="number"&&e===Math.floor(e)&&e>=Se.MIN_VALUE&&e<=Se.MAX_VALUE?this.setValue(e):console.warn("Int32Field Type mismatch",e,this.address.toString())}},D=class i extends ur{static create(e,t=""){return new i(e,t)}constructor(e,t){super(e,me.String,t)}serialization(){return cr[me.String]}equals(e){return this.getValue()===e}clamp(e){return e}read(e){this.setValue(e.readString())}write(e){e.writeString(this.getValue())}fromJSON(e){typeof e=="string"?this.setValue(e):console.warn("StringField Type mismatch",e,this.address.toString())}},Sa=class i extends ur{static create(e,t=this.#t){return new i(e,t)}static#t=Object.freeze(new Int8Array(0));constructor(e,t){super(e,me.Bytes,t)}serialization(){return cr[me.Bytes]}equals(e){return this.getValue().length===e.length&&this.getValue().every((t,r)=>e[r]===t)}clamp(e){return e}read(e){let t=new Int8Array(e.readInt());e.readBytes(t),this.setValue(t)}write(e){let t=this.getValue();e.writeInt(t.length),e.writeBytes(t)}toJSON(){return Array.from(this.getValue().values())}fromJSON(e){Array.isArray(e)&&e.every(t=>typeof t=="number")?this.setValue(new Int8Array(e)):console.warn("ByteArrayField Type mismatch",e,this.address.toString())}};var Ca;(function(i){i.decode=e=>{let t=e.readInt();return w.create(()=>{switch(e.readString()){case"new":{let s=A.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new Fi(s,o,n.buffer)}case"pointer":{let s=j.read(e),o=e.readBoolean()?p.wrap(j.read(e)):p.None,n=e.readBoolean()?p.wrap(j.read(e)):p.None;return new Pi(s,o,n)}case"primitive":{let s=j.read(e),o=e.readString(),n=cr[o],a=n.decode(e),l=n.decode(e);return new Ni(s,n,a,l)}case"delete":{let s=A.fromDataInput(e),o=e.readString(),n=new Int8Array(e.readInt());return e.readBytes(n),new Si(s,o,n.buffer)}}},t)}})(Ca||(Ca={}));var Fi=class{type="new";#t;#e;#r;constructor(e,t,r){this.#t=e,this.#e=t,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(e){e.createBox(this.#e,this.#t,t=>t.read(new ge(this.#r)))}inverse(e){e.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}write(e){e.writeString(this.type),A.toDataOutput(e,this.#t),e.writeString(this.#e),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{NewUpdate uuid: ${A.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}toDebugString(e){return this.toString()}},Ni=class{type="primitive";#t;#e;#r;#i;constructor(e,t,r,s){this.#t=e,this.#e=t,this.#r=r,this.#i=s}get address(){return this.#t}get oldValue(){return this.#r}get newValue(){return this.#i}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).setValue(this.#r)}forward(e){this.field(e).setValue(this.#i)}field(e){return e.findVertex(this.#t).unwrap(()=>`Could not find PrimitiveField at ${this.#t}`)}write(e){e.writeString(this.type),this.#t.write(e),e.writeString(this.#e.type),this.#e.encode(e,this.#r),this.#e.encode(e,this.#i)}toString(){return`{PrimitiveUpdate oldValue: ${this.#r}, newValue: ${this.#i}`}},Pi=class{type="pointer";#t;#e;#r;constructor(e,t,r){this.#t=e,this.#e=t,this.#r=r}get address(){return this.#t}get oldAddress(){return this.#e}get newAddress(){return this.#r}matches(e){return e.address.equals(this.address)}inverse(e){this.field(e).targetAddress=this.#e}forward(e){this.field(e).targetAddress=this.#r}field(e){return e.findVertex(this.#t).unwrap(()=>`Could not find PointerField at ${this.#t}`)}write(e){e.writeString(this.type),this.#t.write(e),this.#e.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}}),this.#r.match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toString(){return`{PointerUpdate oldValue: ${this.#e.unwrapOrNull()}, newValue: ${this.#r.unwrapOrNull()}`}},Si=class{type="delete";#t;#e;#r;constructor(e,t,r){this.#t=e,this.#e=t,this.#r=r}get uuid(){return this.#t}get name(){return this.#e}get settings(){return this.#r}forward(e){e.findBox(this.#t).unwrap(()=>`Could not find ${this.#e}`).unstage()}inverse(e){e.createBox(this.#e,this.#t,t=>t.read(new ge(this.#r)))}write(e){e.writeString(this.type),A.toDataOutput(e,this.#t),e.writeString(this.#e),e.writeInt(this.#r.byteLength),e.writeBytes(new Int8Array(this.#r))}toString(){return`{DeleteUpdate uuid: ${A.toString(this.#t)}, attachment: ${this.settings.byteLength}b`}};var Ip=Symbol("Unreferenceable"),E=class i extends T{static create(e,t,r){return new i(e,t,r)}static encodeWith(e,t){b(this.#t.isEmpty(),"SerializationEncoder already in use"),this.#t=p.wrap(e);let r=rr(t);if(this.#t=p.None,r.status==="failure")throw r.error;return r.value}static decodeWith(e,t){b(this.#e.isEmpty(),"SerializationDecoder already in use"),this.#e=p.wrap(e);let r=rr(t);if(this.#e=p.None,r.status==="failure")throw r.error;return r.value}static#t=p.None;static#e=p.None;#r;#i;#s=p.None;#o=p.None;constructor(e,t,r){super(e),this.#r=t,this.#i=r,r&&this.graph.edges().watchVertex(this)}get pointerHub(){return g(`${this} cannot be pointed to`)}get pointerType(){return this.#r}get mandatory(){return this.#i}accept(e){return x(e.visitPointerField,this)}subscribe(e){return this.graph.subscribeVertexUpdates(Y.This,this.address,()=>e(this))}catchupAndSubscribe(e){return e(this),this.graph.subscribeVertexUpdates(Y.This,this.address,()=>this.graph.subscribeEndTransaction(()=>e(this)))}refer(e){this.targetVertex=p.wrap(e)}defer(){this.targetVertex=p.None}get targetVertex(){return this.graph.inTransaction()?this.#o.flatMap(e=>this.graph.findVertex(e)):this.#s}set targetVertex(e){if(e.nonEmpty()){let t=Je.validate(this,e.unwrap());t.nonEmpty()&&g(t.unwrap())}this.targetAddress=e.map(t=>t.address)}get targetAddress(){return this.#o}set targetAddress(e){let t=this.#o;t.isEmpty()&&e.isEmpty()||(e.nonEmpty()&&t.unwrapOrNull()?.equals(e.unwrap()))===!0||(this.#o=e,this.graph.onPointerAddressUpdated(this,t,e))}isEmpty(){return this.targetAddress.isEmpty()}nonEmpty(){return this.targetAddress.nonEmpty()}resolvedTo(e){this.#s=e}read(e){let t=e.readBoolean()?p.wrap(j.read(e)):p.None;this.targetAddress=i.#e.match({none:()=>t,some:r=>r.map(this,t)})}write(e){i.#t.match({none:()=>this.#o,some:t=>t.map(this)}).match({none:()=>e.writeBoolean(!1),some:t=>{e.writeBoolean(!0),t.write(e)}})}toJSON(){return i.#t.match({none:()=>this.#o,some:e=>e.map(this)}).match({none:()=>null,some:e=>e.toString()})}fromJSON(e){if(Jt(e)||typeof e=="string"){let t=p.wrap(Jt(e)?null:j.decode(e));this.targetAddress=i.#e.match({none:()=>t,some:r=>r.map(this,t)})}else return g(`Pointer: Type mismatch. value (${typeof e}) must be a string.`)}};var ns=class{#t;#e;#r;#i;constructor(){this.#t=j.newSet(e=>e.address),this.#e=j.newSet(e=>e.address),this.#r=j.newSet(([e])=>e),this.#i=j.newSet(([e])=>e.address)}watchVertex(e){if(ae(e,E)){if(!e.mandatory)return g("watchVertex called but has no edge requirement");this.#t.add(e)}else{if(!e.pointerRules.mandatory)return g("watchVertex called but has no edge requirement");this.#e.add(e)}}unwatchVerticesOf(...e){let t=({box:{address:{uuid:r}}})=>r;for(let{address:{uuid:r}}of e)this.#o(this.#t,r,t),this.#o(this.#e,r,t);for(let r of e){let s=this.outgoingEdgesOf(r);if(s.length>0)return g(`${r} has outgoing edges: ${s.map(([n,a])=>`[${n.toString()}, ${a.toString()}]`)}`);let o=this.incomingEdgesOf(r);if(o.length>0)return g(`${r} has incoming edges from: ${o.map(n=>n.toString())}`)}}connect(e,t){this.#i.add([e,t]),this.#r.opt(t).match({none:()=>this.#r.add([t,[e]]),some:([,r])=>r.push(e)})}disconnect(e){let[,t]=this.#i.removeByKey(e.address),[,r]=this.#r.get(t);w.remove(r,e),r.length===0&&this.#r.removeByKey(t)}outgoingEdgesOf(e){return this.#s(this.#i,e.address.uuid,([{box:{address:{uuid:t}}}])=>t)}incomingEdgesOf(e){return e.isBox()?this.#s(this.#r,e.address.uuid,([{uuid:t}])=>t).flatMap(([t,r])=>r):this.#r.opt(e.address).mapOr(([t,r])=>r,w.empty())}validateRequirements(){this.#t.forEach(e=>{if(b(e.isAttached(),`Pointer ${e.address.toString()} is not attached`),e.isEmpty())return e.mandatory?g(`Pointer ${e.toString()} requires an edge.`):g(`Illegal state: ${e} has no edge requirements.`)}),this.#e.forEach(e=>{if(b(e.isAttached(),`Target ${e.address.toString()} is not attached`),e.pointerHub.isEmpty())return e.pointerRules.mandatory?g(`Target ${e.toString()} requires an edge.`):g(`Illegal state: ${e} has no edge requirements.`)})}#s(e,t,r){let s=j.boxRange(e,t,r);return V(s)?e.values().slice(s[0],s[1]):w.empty()}#o(e,t,r){let s=j.boxRange(e,t,r);V(s)&&e.removeRange(s[0],s[1])}};var as=class{#t;#e;#r;#i;#s;#o;#n;#a;#l;#u=!1;#c=!1;constructor(e=p.None){this.#t=e,this.#e=A.newSet(t=>t.address.uuid),this.#r=[],this.#n=os.create(),this.#i=new ve,this.#s=new ve,this.#o=new ve,this.#a=new ns,this.#l=[]}beginTransaction(){b(!this.#u,"Transaction already in progress"),this.#u=!0,this.#o.proxy.onBeginTransaction()}endTransaction(){for(b(this.#u,"No transaction in progress"),this.#u=!1,this.#r.length>0&&(this.#r.forEach(({pointerField:e,update:t})=>this.#d(e,t)),this.#r.length=0);this.#l.length>0;)this.#l.splice(0).forEach(e=>e()),this.#l.length>0&&console.debug(`${this.#l.length} new observers while notifying`);this.#o.proxy.onEndTransaction()}inTransaction(){return this.#u}constructingBox(){return this.#c}createBox(e,t,r){return this.#t.unwrap("No box-factory installed")(e,this,t,r)}stageBox(e,t){this.#h(),b(!this.#c,"Cannot construct box while other box is constructing"),V(t)&&(this.#c=!0,t(e),this.#c=!1);let r=this.#e.add(e);b(r,`${e} already staged`);let s=new Fi(e.address.uuid,e.name,e.toArrayBuffer());return this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s),e}subscribeTransaction(e){return this.#o.subscribe(e)}subscribeToAllUpdates(e){return this.#i.subscribe(e)}subscribeToAllUpdatesImmediate(e){return this.#s.subscribe(e)}subscribeVertexUpdates(e,t,r){return this.#n.subscribe(e,t,r)}subscribeEndTransaction(e){this.#l.push(e)}unstageBox(e){this.#h();let t=this.#e.removeByKey(e.address.uuid);b(t===e,`${e} could not be found to unstage`),this.#a.unwatchVerticesOf(e);let r=new Si(e.address.uuid,e.name,e.toArrayBuffer());this.#i.proxy.onUpdate(r),this.#s.proxy.onUpdate(r)}findBox(e){return this.#e.opt(e)}findVertex(e){return this.#e.opt(e.uuid).flatMap(t=>t.searchVertex(e.fieldKeys))}boxes(){return this.#e.values()}edges(){return this.#a}checksum(){let e=new _i;return this.boxes().forEach(t=>t.write(e)),e.result()}onPrimitiveValueUpdate(e,t,r){if(this.#h(),e.isAttached()&&!this.#c){let s=new Ni(e.address,e.serialization(),t,r);this.#n.dispatch(s),this.#i.proxy.onUpdate(s),this.#s.proxy.onUpdate(s)}}onPointerAddressUpdated(e,t,r){this.#h(),t.nonEmpty()&&this.#a.disconnect(e),r.nonEmpty()&&this.#a.connect(e,r.unwrap());let s=new Pi(e.address,t,r);this.#c?this.#r.push({pointerField:e,update:s}):(this.#d(e,s),this.#s.proxy.onUpdate(s))}#d(e,t){let{oldAddress:r,newAddress:s}=t,o=r.flatMap(a=>this.findVertex(a)),n=s.flatMap(a=>this.findVertex(a));e.resolvedTo(n),o.equals(n)||(o.ifSome(a=>a.pointerHub.onRemoved(e)),n.ifSome(a=>a.pointerHub.onAdded(e))),this.#n.dispatch(t),this.#i.proxy.onUpdate(t)}dependenciesOf(e){let t=new Set,r=new Set,s=o=>{t.has(o)||(t.add(o),o.outgoingEdges().filter(([n])=>!r.has(n)).forEach(([n,a])=>{let l=this.findVertex(a).unwrap(`Could not find target of ${n.toString()}`);if(r.add(n),l.pointerRules.mandatory&&l.pointerHub.incoming().every(c=>r.has(c)))return s(l.box)}),o.incomingEdges().forEach(n=>{r.add(n),n.mandatory&&s(n.box)}))};return s(e),t.delete(e),{boxes:t,pointers:Array.from(r).reverse()}}verifyPointers(){this.#a.validateRequirements();let e=0,t=r=>{for(let s of r.fields())s.accept({visitPointerField:o=>{if(o.targetAddress.nonEmpty()){let n=o.targetVertex.nonEmpty(),a=this.findVertex(o.targetAddress.unwrap()).nonEmpty();b(n,`pointer ${o.address} is broken`),b(a,`Cannot find target for pointer ${o.address}`),e++}},visitObjectField:o=>t(o)})};return this.#e.forEach(r=>t(r)),console.debug("verification complete."),{count:e}}debugBoxes(){console.table(this.#e.values().reduce((e,t)=>(e[A.toString(t.address.uuid)]={class:t.name,"incoming links":t.incomingEdges().length,"outgoing links":t.outgoingEdges().length,"est. memory (bytes)":t.estimateMemory()},e),{}))}debugDependencies(){console.debug("Dependencies:"),this.boxes().forEach(e=>{console.debug(` ${e}`);for(let t of this.dependenciesOf(e).boxes)console.debug(` ${t}`)})}addressToDebugPath(e){return e.flatMap(t=>t.isBox()?this.findBox(t.uuid).map(r=>r.name):this.findBox(t.uuid).flatMap(r=>r.searchVertex(t.fieldKeys).map(s=>s.isField()?s.debugPath:g("Unknown address"))))}toArrayBuffer(){let e=pe.create(),t=this.#e.values();return e.writeInt(t.length),t.forEach(r=>{let s=r.serialize();e.writeInt(s.byteLength),e.writeBytes(new Int8Array(s))}),e.toArrayBuffer()}fromArrayBuffer(e){b(this.#e.isEmpty(),"Cannot call fromArrayBuffer if boxes is not empty");let t=new ge(e),r=t.readInt();this.beginTransaction();let s=[];for(let o=0;o<r;o++){let n=t.readInt(),a=new Int8Array(n);t.readBytes(a);let l=new ge(a.buffer),c=l.readInt(),d=l.readString(),m=A.fromDataInput(l);s.push({creationIndex:c,name:d,uuid:m,boxStream:l})}s.sort((o,n)=>o.creationIndex-n.creationIndex).forEach(({name:o,uuid:n,boxStream:a})=>this.createBox(o,n,l=>l.read(a))),this.endTransaction()}toJSON(){return this.#e.values().map(e=>({name:e.name,uuid:e.address.toString(),fields:K(e.toJSON())}))}#h(){b(this.#u,()=>"Modification only prohibited in transaction mode.")}};var Ra;(function(i){i.insertOrder=(e,t=Number.MAX_SAFE_INTEGER)=>{let r=i.collectIndexedBoxes(e),s=$(t,0,r.length);if(s<r.length)for(let o=s;o<r.length;o++)r[o].index.setValue(o+1);return s},i.removeOrder=(e,t)=>{let r=i.collectIndexedBoxes(e);if(t<r.length)for(let s=t+1;s<r.length;s++)r[s].index.setValue(s-1)},i.moveIndex=(e,t,r)=>{let s=i.collectIndexedBoxes(e),o=s[t];if(r<0){let n=$(t+r,0,s.length-1);for(let a=n;a<t;a++)s[a].index.setValue(a+1);o.index.setValue(n)}else if(r>1){let n=$(t+(r-1),0,s.length-1);for(let a=t;a<n;a++)s[a+1].index.setValue(a);o.index.setValue(n)}else console.warn(`moveIndex had no effect: startIndex: ${t}, delta: ${r}`)},i.isIndexedBox=e=>"index"in e&&e.index instanceof v,i.collectIndexedBoxes=(e,t)=>e.pointerHub.incoming().map(({box:r})=>i.isIndexedBox(r)&&(t===void 0||r instanceof t)?r:g(`${r} has no index field`)).sort((r,s)=>r.index.getValue()-s.index.getValue())})(Ra||(Ra={}));var ue=class extends T{#t;constructor(e){super(e),this.#t=this.initializeFields()}accept(e){return x(e.visitObjectField,this)}fields(){return Object.values(this.#t)}record(){return this.#t}getField(e){return K(this.#t[e])}optField(e){return p.wrap(this.#t[e])}read(e){Rt.readFields(e,this.#t)}write(e){Rt.writeFields(e,this.#t)}toJSON(){return Object.entries(this.#t).reduce((e,[t,r])=>(e[t]=r.toJSON(),e),{})}fromJSON(e){if(bt(e))Object.entries(e).forEach(([t,r])=>{let s=this.#t[parseInt(t)];V(r)&&s.fromJSON(r)});else return g("Type mismatch")}};var De;(function(i){i.sender=(r,s)=>s(new e(r)),i.executor=(r,s)=>new t(r,s);class e{#t;#e=new Map;#r;#i=0;constructor(s){this.#t=s,this.#r=s.subscribe(this.#s)}terminate(){this.#r.terminate()}dispatchAndForget=(s,...o)=>this.#t.send({type:"send",returnId:!1,func:s.name,args:Array.from(le.map(o,n=>({value:n})))});dispatchAndReturn=(s,...o)=>new Promise((n,a)=>{let l=le.reduce(o,(c,d,m)=>(typeof d=="function"&&c.push([m,d]),c),[]);this.#e.set(this.#i,{executorTuple:{resolve:n,reject:a},callbacks:new Map(l)}),this.#t.send({type:"send",returnId:this.#i,func:s.name,args:Array.from(le.map(o,(c,d)=>typeof c=="function"?{callback:d}:{value:c}))}),this.#i++});#s=s=>{let o=this.#e.get(s.returnId);V(o)?s.type==="resolve"?(o.executorTuple.resolve(s.resolve),this.#e.delete(s.returnId)):s.type==="reject"?(o.executorTuple.reject(s.reject),this.#e.delete(s.returnId)):s.type==="callback"&&o.callbacks?.get(s.funcAt).apply(this,s.args):g(`Promise has already been resolved. ${JSON.stringify(s)}`)}}class t{#t;#e;#r;constructor(s,o){this.#t=s,this.#e=o,this.#r=s.subscribe(this.#i)}terminate(){this.#r.terminate()}#i=s=>{b(s.type==="send",()=>"Message type must be 'send'");let o=Object.getPrototypeOf(this.#e)===Object.getPrototypeOf({})?this.#e:Object.getPrototypeOf(this.#e),n=K(o[s.func],`${s.func.toString()} does not exists on ${this.#e}`),a=s.returnId;if(a===!1)n.apply(this.#e,s.args.map(l=>"value"in l?l.value:g(`${s.func.toString()} has no promise.`)));else try{n.apply(this.#e,s.args.map(c=>"callback"in c?(...d)=>this.#n(a,c.callback,d):c.value)).then(c=>this.#s(a,c),c=>this.#o(a,c))}catch(l){this.#o(a,l)}};#s=(s,o)=>this.#t.send({type:"resolve",returnId:s,resolve:o});#o=(s,o)=>this.#t.send({type:"reject",returnId:s,reject:o});#n=(s,o,n)=>this.#t.send({type:"callback",returnId:s,funcAt:o,args:n})}i.Executor=t})(De||(De={}));var Ma;(function(i){i.ProgressArrayBuffer=e=>async t=>{if(!t.headers.has("Content-Length"))return console.debug("No Content-Length"),t.arrayBuffer();let r=parseInt(t.headers.get("Content-Length"));if(console.debug(`Content-Length: ${r}b`),isNaN(r)||r<4096)return t.arrayBuffer();e(0);let s=pe.create(r),o=K(t.body,"response.body is empty").getReader();for(;;){let{done:n,value:a}=await o.read();if(n)break;a.forEach(l=>s.writeByte(l)),e(s.position/r)}return e(1),s.toArrayBuffer()}})(Ma||(Ma={}));var Da;(function(i){i.debounce=(()=>{let e;return(t,r=1e3)=>{clearTimeout(e),e=setTimeout(t,r)}})(),i.scheduleInterval=(e,t,...r)=>{let s=setInterval(e,t,...r);return{terminate:()=>clearInterval(s)}},i.scheduleTimeout=(e,t,...r)=>{let s=setTimeout(e,t,...r);return{terminate:()=>clearTimeout(s)}}})(Da||(Da={}));var Va={for:i=>new Tn(i)},Tn=class{#t;#e=new q;constructor(e){if(this.#t=e,V(e.onmessage)||V(e.onmessageerror))throw console.error(e),new Error(`${e} is already wrapped.`);e.onmessage=t=>this.#e.notify(t.data),e.onmessageerror=t=>{throw new Error(t.type)}}send(e){this.#t.postMessage(e)}channel(e){return new On(this,e)}subscribe(e){return this.#e.subscribe(e)}terminate(){this.#e.terminate(),this.#t.onmessage=null,this.#t.onmessageerror=null}},On=class i{#t;#e;#r=new q;#i;constructor(e,t){this.#t=e,this.#e=t,this.#i=e.subscribe(r=>{"__id__"in r&&r.__id__==="42"&&"message"in r&&"channel"in r&&r.channel===t&&this.#r.notify(r.message)})}send(e){this.#t.send({__id__:"42",channel:this.#e,message:e})}channel(e){return new i(this,e)}subscribe(e){return this.#r.subscribe(e)}terminate(){this.#i.terminate(),this.#r.terminate()}};var ls;(function(i){i.frame=()=>new Promise(e=>requestAnimationFrame(()=>e())),i.frames=e=>new Promise(t=>{let r=e,s=()=>{--r<=0?t():requestAnimationFrame(s)};requestAnimationFrame(s)}),i.timeSpan=(e,...t)=>new Promise(r=>setTimeout(r,e.millis(),...t)),i.event=(e,t)=>new Promise(r=>e.addEventListener(t,r,{once:!0})),i.observable=e=>new Promise(t=>{let r=e.subscribe(()=>{r.terminate(),t()})}),i.complete=e=>new Promise((t,r)=>{let s=setInterval(()=>{let{status:o,value:n,error:a}=rr(()=>e.next());if(o==="success"){let{done:l,value:c}=n;l&&(clearInterval(s),t(c))}else clearInterval(s),r(a)},0)})})(ls||(ls={}));var kn=class{maxRetry;timeSpan;#t=0;constructor(e,t){this.maxRetry=e,this.timeSpan=t}retry(e,t){return++this.#t===this.maxRetry?!1:(console.debug(`${e} > will retry in ${this.timeSpan.toString()}`),setTimeout(t,this.timeSpan.millis()),!0)}},Mt;(function(i){class e{value;status="resolved";constructor(a){this.value=a}error=bn("Cannot access error when promise is resolved")}i.ResolveResult=e;class t{error;status="rejected";constructor(a){this.error=a}value=bn("Cannot access value when promise is rejected")}i.RejectedResult=t,i.makeAbortable=async(n,a)=>{let l=!0;return n.own(O.create(()=>l=!1)),new Promise((c,d)=>a.then(m=>{l&&c(m)},m=>{l&&d(m)}))},i.tryCatch=n=>n.then(a=>new e(a),a=>new t(a));let r=new kn(3,Bt.seconds(3));i.retry=(n,a=r)=>n().catch(l=>new Promise((c,d)=>{let m=f=>{a.retry(f,()=>n().then(y=>c(y),m))||d(f)};m(l)})),i.guardedRetry=(n,a)=>{let l=async(c=0)=>{try{return await n()}catch(d){if(a(d,++c))return await ls.timeSpan(Bt.seconds(1)),l(c);throw d}};return l()},i.approvedRetry=(n,a)=>{let l=async()=>{try{return await n()}catch(c){if(await ya.approve(a(c)))return l();throw c}};return l()},i.fail=(n,a)=>{let l=()=>new Promise((c,d)=>setTimeout(()=>d("fails first"),n.millis()));return()=>{let c=l();return l=a,c}},i.timeout=(n,a,l)=>new Promise((c,d)=>{let m=!0,f=setTimeout(()=>{m=!1,d(new Error(l??"timeout"))},a.millis());n.then(y=>{m&&c(y)},y=>{m&&d(y)}).finally(()=>clearTimeout(f))}),i.sequentialAll=n=>n.reduce((a,l)=>a.then(async c=>[...c,await l()]),Promise.resolve([])),i.sequentialize=n=>{let a=Promise.resolve();return l=>{let c=()=>n(l),d=a.then(c,c);return a=d.catch(()=>{}),d}},i.memoizeAsync=(n,a)=>{let l=null,c=Date.now();return()=>{let d=Date.now();return(Jt(l)||V(a)&&d-c>a.millis())&&(c=d,l=n(),l.catch(m=>(l=null,m))),l}},i.allWithLimit=async(n,a=1)=>{let l=new Array(n.length),c=0,d=!1,m=async()=>{for(;c<n.length&&!d;){let f=c++;try{let y=await n[f]();d||(l[f]=y)}catch(y){throw d=!0,y}}};return await Promise.all(Array.from({length:Math.min(a,n.length)},m)),l},i.allSettledWithLimit=async(n,a=1)=>{let l=new Array(n.length),c=0,d=async()=>{for(;c<n.length;){let m=c++;try{let f=await n[m]();l[m]={status:"fulfilled",value:f}}catch(f){l[m]={status:"rejected",reason:f}}}};return await Promise.all(Array.from({length:Math.min(a,n.length)},d)),l};class s{max;#t;#e=0;constructor(a=1){this.max=a,this.#t=[]}async add(a){if(this.#e<this.max)return this.#e++,a().finally(()=>this.#r());{let l=Promise.withResolvers();return this.#t.push([a,l]),l.promise.finally(()=>this.#r())}}#r(){if(b(this.#e>0,"Internal Error in Promises.Limit"),--this.#e<this.max&&this.#t.length>0){let[a,{resolve:l,reject:c}]=this.#t.shift();this.#e++,a().then(l,c)}}}i.Limit=s;class o{#t;#e;#r;#i=p.None;constructor(a,l,c){this.#t=a,this.#e=l,this.#r=c}update(a){this.#i=p.wrap(a),a.then(l=>{this.#i.contains(a)&&this.#t(l)}).catch(l=>{this.#i.contains(a)&&this.#e(l)}).finally(()=>{this.#i.contains(a)&&(this.terminate(),x(this.#r))})}terminate(){this.#i=p.None}}i.Latest=o})(Mt||(Mt={}));var Ia;(function(i){let e=new Mt.Limit(4);i.limitFetch=(t,r)=>e.add(()=>fetch(t,r)),i.DefaultRetry=(t,r)=>!ae(t,ji.FileNotFound)||r<=100})(Ia||(Ia={}));var Ta=(i="debug")=>{let e=performance.now();return{lab:t=>console[i].call(console,`${t} in ${(performance.now()-e).toFixed(1)}ms`)}};var Oa;(function(i){i.startEstimator=()=>{let e=performance.now();return t=>{if(t===0)return Bt.POSITIVE_INFINITY;let r=performance.now()-e;return Bt.millis(r/t-r)}}})(Oa||(Oa={}));var us=Symbol.for("@openDAW/lib-runtime");globalThis[us]?console.debug(`%c${us.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[us]=!0,console.debug(`%c${us.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var ka=(i,e)=>De.executor(e,new class{sendUpdates(t){i.beginTransaction(),t.forEach(r=>{let s=r.type;s==="new"?i.createBox(r.name,r.uuid,o=>o.read(new ge(r.buffer))):s==="update-primitive"?i.findVertex(j.reconstruct(r.address)).unwrap(()=>`Could not find primitive field ${r.address}`).setValue(r.value):s==="update-pointer"?i.findVertex(j.reconstruct(r.address)).unwrap(()=>`Could not find pointer field ${r.address}`).targetAddress=V(r.target)?p.wrap(j.reconstruct(r.target)):p.None:r.type==="delete"&&i.unstageBox(i.findBox(r.uuid).unwrap(()=>`Could not find box ${A.toString(r.uuid)}`))}),i.endTransaction()}checksum(t){return w.equals(i.checksum(),t)?Promise.resolve():Promise.reject("Checksum mismatch")}});var cs=Symbol.for("@openDAW/lib-box");globalThis[cs]?console.debug(`%c${cs.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[cs]=!0,console.debug(`%c${cs.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var hs=class{#t=0;#e=!1;#r=!1;isRecording=!1;isCountingIn=!1;metronomeEnabled=!1;getLeapStateAndReset(){let e=this.#r;return this.#r=!1,e}get position(){return this.#t}set position(e){this.#t=e,this.#r=!0}get transporting(){return this.#e}set transporting(e){this.#e!==e&&(this.#e=e)}pause(){this.#e=!1,this.isRecording=!1,this.isCountingIn=!1}advanceTo(e){this.#t=e}};var u;(function(i){i[i.Timeline=0]="Timeline",i[i.Selection=1]="Selection",i[i.PianoMode=2]="PianoMode",i[i.User=3]="User",i[i.AudioConnection=4]="AudioConnection",i[i.InstrumentHost=5]="InstrumentHost",i[i.AudioOutput=6]="AudioOutput",i[i.Capture=7]="Capture",i[i.NotesConnection=8]="NotesConnection",i[i.VoltageConnection=9]="VoltageConnection",i[i.AudioUnits=10]="AudioUnits",i[i.MidiEffectHost=11]="MidiEffectHost",i[i.AudioEffectHost=12]="AudioEffectHost",i[i.AudioBusses=13]="AudioBusses",i[i.AuxSend=14]="AuxSend",i[i.Modulation=15]="Modulation",i[i.Automation=16]="Automation",i[i.ParameterController=17]="ParameterController",i[i.MidiControl=18]="MidiControl",i[i.StepAutomation=19]="StepAutomation",i[i.Editing=20]="Editing",i[i.AudioFile=21]="AudioFile",i[i.SoundfontFile=22]="SoundfontFile",i[i.AudioUnit=23]="AudioUnit",i[i.MarkerTrack=24]="MarkerTrack",i[i.MarkerEvents=25]="MarkerEvents",i[i.ClipCollection=26]="ClipCollection",i[i.RegionCollection=27]="RegionCollection",i[i.TrackCollection=28]="TrackCollection",i[i.Device=29]="Device",i[i.Groove=30]="Groove",i[i.ModularSetup=31]="ModularSetup",i[i.ModuleCollection=32]="ModuleCollection",i[i.ConnectionCollection=33]="ConnectionCollection",i[i.DeviceUserInterface=34]="DeviceUserInterface",i[i.NoteEvents=35]="NoteEvents",i[i.NoteEventFeature=36]="NoteEventFeature",i[i.NoteEventCollection=37]="NoteEventCollection",i[i.ValueEvents=38]="ValueEvents",i[i.ValueEventCollection=39]="ValueEventCollection",i[i.ValueInterpolation=40]="ValueInterpolation",i[i.Sample=41]="Sample"})(u||(u={}));var Ua;(function(i){i.NoSync="nosync",i.Pitch="pitch",i.Timestretch="timestretch",i.AudioFit="audiofit"})(Ua||(Ua={}));var Ka;(function(i){i[i.Pre=0]="Pre",i[i.Post=1]="Post"})(Ka||(Ka={}));var hr;(function(i){i.Instrument="instrument",i.Bus="bus",i.Aux="aux",i.Output="output"})(hr||(hr={}));var La=(i,e)=>{if(i===e)return 0;let t=i-e;return t===0?g(`Indices cannot be equal (${i}, ${e})`):t};var Be=class i{static create(e,t,r){return new i(e,t,r)}#t;#e;#r;#i;#s=null;constructor(e,t,r){this.#t=e,this.#e=A.newSet(s=>s.adapter.uuid),this.#r=new ve,this.#i=e.pointerHub.catchupAndSubscribeTransactual({onAdd:s=>{this.#s=null;let o=t(s.box),n=o.indexField.subscribe(()=>{this.#s=null,this.#r.proxy.onReorder(o)}),a=this.#e.add({adapter:o,subscription:n});b(a,`Could not add ${o}`),this.#r.proxy.onAdd(o)},onRemove:s=>{this.#s=null;let o=s.box.address.uuid,{adapter:n,subscription:a}=this.#e.removeByKey(o);a.terminate(),this.#r.proxy.onRemove(n)}},r)}field(){return this.#t}subscribe(e){return this.#r.subscribe(e)}catchupAndSubscribe(e){return this.#e.forEach(({adapter:t})=>e.onAdd(t)),this.subscribe(e)}getAdapterByIndex(e){let t=oe.exactMapped(this.adapters(),e,La,r=>r.indexField.getValue());return t===-1?p.None:p.wrap(this.adapters()[t])}getAdapterById(e){return this.#e.opt(e).map(({adapter:t})=>t)}getMinFreeIndex(){let e=this.adapters();for(let t=0;t<e.length;t++)if(e[t].indexField.getValue()>t)return t;return e.length}adapters(){return this.#s===null&&(this.#s=this.#e.values().map(({adapter:e})=>e).sort((e,t)=>e.indexField.getValue()-t.indexField.getValue())),this.#s}move(e,t){this.moveIndex(e.indexField.getValue(),t)}moveIndex(e,t){let r=this.adapters(),s=r[e];if(t<0){let o=$(e+t,0,r.length-1);for(let n=o;n<e;n++)r[n].indexField.setValue(n+1);s.indexField.setValue(o)}else if(t>1){let o=$(e+(t-1),0,r.length-1);for(let n=e;n<o;n++)r[n+1].indexField.setValue(n);s.indexField.setValue(o)}else console.warn(`moveIndex had no effect: startIndex: ${e}, delta: ${t}`)}size(){return this.#e.size()}isEmpty(){return this.size()===0}terminate(){this.#s=null,this.#e.forEach(({subscription:e})=>e.terminate()),this.#e.clear(),this.#r.terminate(),this.#i.terminate()}};var ds;(function(i){i.create=(e,t,r,s)=>{switch(e){case"RootBox":return Rr.create(t,r,s);case"SelectionBox":return Ci.create(t,r,s);case"UserInterfaceBox":return ps.create(t,r,s);case"TimelineBox":return ms.create(t,r,s);case"TrackBox":return Mr.create(t,r,s);case"NoteEventBox":return Dt.create(t,r,s);case"NoteEventRepeatBox":return fs.create(t,r,s);case"NoteEventCollectionBox":return mt.create(t,r,s);case"NoteRegionBox":return dr.create(t,r,s);case"NoteClipBox":return Dr.create(t,r,s);case"ValueEventBox":return Vt.create(t,r,s);case"ValueEventCollectionBox":return ft.create(t,r,s);case"ValueEventCurveBox":return It.create(t,r,s);case"ValueRegionBox":return pr.create(t,r,s);case"ValueClipBox":return Vr.create(t,r,s);case"AudioRegionBox":return Ir.create(t,r,s);case"AudioClipBox":return Tr.create(t,r,s);case"MarkerBox":return Or.create(t,r,s);case"AudioFileBox":return gs.create(t,r,s);case"SoundfontFileBox":return xs.create(t,r,s);case"AudioUnitBox":return Ye.create(t,r,s);case"CaptureAudioBox":return ys.create(t,r,s);case"CaptureMidiBox":return vs.create(t,r,s);case"AudioBusBox":return kr.create(t,r,s);case"AuxSendBox":return bs.create(t,r,s);case"StepAutomationBox":return As.create(t,r,s);case"GrooveShuffleBox":return ws.create(t,r,s);case"UnknownAudioEffectDeviceBox":return Es.create(t,r,s);case"UnknownMidiEffectDeviceBox":return Bs.create(t,r,s);case"DeviceInterfaceKnobBox":return Fs.create(t,r,s);case"ModularDeviceBox":return Ns.create(t,r,s);case"DeviceClashBox":return Ps.create(t,r,s);case"StereoToolDeviceBox":return Ss.create(t,r,s);case"DelayDeviceBox":return Cs.create(t,r,s);case"RevampDeviceBox":return Rs.create(t,r,s);case"ReverbDeviceBox":return Ms.create(t,r,s);case"VaporisateurDeviceBox":return Ds.create(t,r,s);case"SoundfontDeviceBox":return Vs.create(t,r,s);case"NanoDeviceBox":return Is.create(t,r,s);case"PlayfieldDeviceBox":return Ts.create(t,r,s);case"PlayfieldSampleBox":return Ur.create(t,r,s);case"TapeDeviceBox":return Os.create(t,r,s);case"ArpeggioDeviceBox":return ks.create(t,r,s);case"PitchDeviceBox":return Us.create(t,r,s);case"ZeitgeistDeviceBox":return Ks.create(t,r,s);case"ModularBox":return Ls.create(t,r,s);case"ModuleConnectionBox":return $s.create(t,r,s);case"ModularAudioInputBox":return qs.create(t,r,s);case"ModularAudioOutputBox":return zs.create(t,r,s);case"ModuleDelayBox":return _s.create(t,r,s);case"ModuleMultiplierBox":return Hs.create(t,r,s);case"ModuleGainBox":return Gs.create(t,r,s);default:return g(`Unknown box class '${e}'`)}},i.deserialize=(e,t)=>{let r=new ge(t),s=r.readString(),o=A.fromDataInput(r),n=i.create(s,e,o);return n.read(r),n}})(ds||(ds={}));var Ws=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get keyboard(){return this.getField(1)}get timeRangeInQuarters(){return this.getField(2)}get noteScale(){return this.getField(3)}get noteLabels(){return this.getField(4)}get transpose(){return this.getField(5)}initializeFields(){return{1:v.create({parent:this,fieldKey:1,fieldName:"keyboard",pointerRules:h},0),2:P.create({parent:this,fieldKey:2,fieldName:"timeRangeInQuarters",pointerRules:h},8),3:P.create({parent:this,fieldKey:3,fieldName:"noteScale",pointerRules:h},1.5),4:N.create({parent:this,fieldKey:4,fieldName:"noteLabels",pointerRules:h},!0),5:v.create({parent:this,fieldKey:5,fieldName:"transpose",pointerRules:h},0)}}};var Rr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RootBox",pointerRules:h}),r)}static ClassName="RootBox";constructor(e){super(e)}accept(e){return x(e.visitRootBox,this)}get timeline(){return this.getField(1)}get users(){return this.getField(2)}get created(){return this.getField(3)}get groove(){return this.getField(4)}get modularSetups(){return this.getField(10)}get audioUnits(){return this.getField(20)}get audioBusses(){return this.getField(21)}get outputDevice(){return this.getField(30)}get pianoMode(){return this.getField(40)}get editingChannel(){return this.getField(111)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"timeline",pointerRules:h},u.Timeline,!0),2:T.hook({parent:this,fieldKey:2,fieldName:"users",pointerRules:{accepts:[u.User],mandatory:!0}}),3:D.create({parent:this,fieldKey:3,fieldName:"created",pointerRules:h}),4:E.create({parent:this,fieldKey:4,fieldName:"groove",pointerRules:h},u.Groove,!0),10:T.hook({parent:this,fieldKey:10,fieldName:"modularSetups",pointerRules:{accepts:[u.ModularSetup],mandatory:!1}}),20:T.hook({parent:this,fieldKey:20,fieldName:"audioUnits",pointerRules:{accepts:[u.AudioUnits],mandatory:!1}}),21:T.hook({parent:this,fieldKey:21,fieldName:"audioBusses",pointerRules:{accepts:[u.AudioBusses],mandatory:!1}}),30:T.hook({parent:this,fieldKey:30,fieldName:"outputDevice",pointerRules:{accepts:[u.AudioOutput],mandatory:!0}}),40:Ws.create({parent:this,fieldKey:40,fieldName:"pianoMode",pointerRules:h}),111:E.create({parent:this,fieldKey:111,fieldName:"editingChannel",pointerRules:h},u.Editing,!1)}}};var Ci=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SelectionBox",pointerRules:h}),r)}static ClassName="SelectionBox";constructor(e){super(e)}accept(e){return x(e.visitSelectionBox,this)}get selection(){return this.getField(1)}get selectable(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"selection",pointerRules:h},u.Selection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"selectable",pointerRules:h},u.Selection,!0)}}};var ps=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UserInterfaceBox",pointerRules:h}),r)}static ClassName="UserInterfaceBox";constructor(e){super(e)}accept(e){return x(e.visitUserInterfaceBox,this)}get root(){return this.getField(1)}get selection(){return this.getField(10)}get editingDeviceChain(){return this.getField(21)}get editingTimelineRegion(){return this.getField(22)}get editingModularSystem(){return this.getField(23)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"root",pointerRules:h},u.User,!0),10:T.hook({parent:this,fieldKey:10,fieldName:"selection",pointerRules:{accepts:[u.Selection],mandatory:!1}}),21:E.create({parent:this,fieldKey:21,fieldName:"editingDeviceChain",pointerRules:h},u.Editing,!1),22:E.create({parent:this,fieldKey:22,fieldName:"editingTimelineRegion",pointerRules:h},u.Editing,!1),23:E.create({parent:this,fieldKey:23,fieldName:"editingModularSystem",pointerRules:h},u.Editing,!1)}}};var js=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get nominator(){return this.getField(1)}get denominator(){return this.getField(2)}initializeFields(){return{1:v.create({parent:this,fieldKey:1,fieldName:"nominator",pointerRules:h},4),2:v.create({parent:this,fieldKey:2,fieldName:"denominator",pointerRules:h},4)}}};var Qs=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get from(){return this.getField(2)}get to(){return this.getField(3)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:h},!0),2:v.create({parent:this,fieldKey:2,fieldName:"from",pointerRules:h},0),3:v.create({parent:this,fieldKey:3,fieldName:"to",pointerRules:h},15360)}}};var Ys=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get markers(){return this.getField(1)}get index(){return this.getField(10)}get enabled(){return this.getField(20)}initializeFields(){return{1:T.hook({parent:this,fieldKey:1,fieldName:"markers",pointerRules:{accepts:[u.MarkerTrack],mandatory:!1}}),10:v.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:h}),20:N.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:h},!0)}}};var ms=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TimelineBox",pointerRules:h}),r)}static ClassName="TimelineBox";constructor(e){super(e)}accept(e){return x(e.visitTimelineBox,this)}get root(){return this.getField(1)}get signature(){return this.getField(10)}get loopArea(){return this.getField(11)}get deprecatedMarkerTrack(){return this.getField(20)}get markerTrack(){return this.getField(21)}get durationInPulses(){return this.getField(30)}get bpm(){return this.getField(31)}initializeFields(){return{1:T.hook({parent:this,fieldKey:1,fieldName:"root",pointerRules:{accepts:[u.Timeline],mandatory:!0}}),10:js.create({parent:this,fieldKey:10,fieldName:"signature",pointerRules:h}),11:Qs.create({parent:this,fieldKey:11,fieldName:"loopArea",pointerRules:h}),20:T.hook({parent:this,fieldKey:20,fieldName:"deprecatedMarkerTrack",pointerRules:{accepts:[u.MarkerTrack],mandatory:!1}}),21:Ys.create({parent:this,fieldKey:21,fieldName:"markerTrack",pointerRules:h}),30:v.create({parent:this,fieldKey:30,fieldName:"durationInPulses",pointerRules:h},491520),31:P.create({parent:this,fieldKey:31,fieldName:"bpm",pointerRules:h},120)}}};var Mr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TrackBox",pointerRules:{accepts:[u.Selection,u.PianoMode],mandatory:!1}}),r)}static ClassName="TrackBox";constructor(e){super(e)}accept(e){return x(e.visitTrackBox,this)}get tracks(){return this.getField(1)}get target(){return this.getField(2)}get regions(){return this.getField(3)}get clips(){return this.getField(4)}get index(){return this.getField(10)}get type(){return this.getField(11)}get enabled(){return this.getField(20)}get excludePianoMode(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"tracks",pointerRules:h},u.TrackCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"target",pointerRules:h},u.Automation,!0),3:T.hook({parent:this,fieldKey:3,fieldName:"regions",pointerRules:{accepts:[u.RegionCollection],mandatory:!1}}),4:T.hook({parent:this,fieldKey:4,fieldName:"clips",pointerRules:{accepts:[u.ClipCollection],mandatory:!1}}),10:v.create({parent:this,fieldKey:10,fieldName:"index",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"type",pointerRules:h}),20:N.create({parent:this,fieldKey:20,fieldName:"enabled",pointerRules:h},!0),30:N.create({parent:this,fieldKey:30,fieldName:"excludePianoMode",pointerRules:h},!1)}}};var Dt=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventBox",pointerRules:{accepts:[u.Selection,u.NoteEventFeature],mandatory:!1}}),r)}static ClassName="NoteEventBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get pitch(){return this.getField(20)}get velocity(){return this.getField(21)}get playCount(){return this.getField(22)}get playCurve(){return this.getField(23)}get cent(){return this.getField(24)}get chance(){return this.getField(25)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:h},u.NoteEvents,!0),10:v.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h},240),20:v.create({parent:this,fieldKey:20,fieldName:"pitch",pointerRules:h},60),21:P.create({parent:this,fieldKey:21,fieldName:"velocity",pointerRules:h},.7874015748031497),22:v.create({parent:this,fieldKey:22,fieldName:"playCount",pointerRules:h},1),23:P.create({parent:this,fieldKey:23,fieldName:"playCurve",pointerRules:h},0),24:P.create({parent:this,fieldKey:24,fieldName:"cent",pointerRules:h},0),25:v.create({parent:this,fieldKey:25,fieldName:"chance",pointerRules:h},100)}}};var fs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventRepeatBox",pointerRules:h}),r)}static ClassName="NoteEventRepeatBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventRepeatBox,this)}get event(){return this.getField(1)}get count(){return this.getField(2)}get curve(){return this.getField(3)}get length(){return this.getField(4)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:h},u.NoteEventFeature,!0),2:v.create({parent:this,fieldKey:2,fieldName:"count",pointerRules:h},1),3:P.create({parent:this,fieldKey:3,fieldName:"curve",pointerRules:h},0),4:P.create({parent:this,fieldKey:4,fieldName:"length",pointerRules:h},1)}}};var mt=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteEventCollectionBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="NoteEventCollectionBox";constructor(e){super(e)}accept(e){return x(e.visitNoteEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:T.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[u.NoteEvents],mandatory:!1}}),2:T.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[u.NoteEventCollection],mandatory:!0}})}}};var dr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="NoteRegionBox";constructor(e){super(e)}accept(e){return x(e.visitNoteRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get eventOffset(){return this.getField(14)}get mute(){return this.getField(15)}get label(){return this.getField(16)}get hue(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.NoteEventCollection,!0),10:v.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:v.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:v.create({parent:this,fieldKey:14,fieldName:"eventOffset",pointerRules:h}),15:N.create({parent:this,fieldKey:15,fieldName:"mute",pointerRules:h}),16:D.create({parent:this,fieldKey:16,fieldName:"label",pointerRules:h}),17:v.create({parent:this,fieldKey:17,fieldName:"hue",pointerRules:h})}}};var Tt=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get loop(){return this.getField(1)}get reverse(){return this.getField(2)}get mute(){return this.getField(3)}get speed(){return this.getField(4)}get quantise(){return this.getField(5)}get trigger(){return this.getField(6)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"loop",pointerRules:h},!0),2:N.create({parent:this,fieldKey:2,fieldName:"reverse",pointerRules:h}),3:N.create({parent:this,fieldKey:3,fieldName:"mute",pointerRules:h}),4:v.create({parent:this,fieldKey:4,fieldName:"speed",pointerRules:h}),5:v.create({parent:this,fieldKey:5,fieldName:"quantise",pointerRules:h}),6:v.create({parent:this,fieldKey:6,fieldName:"trigger",pointerRules:h})}}};var Dr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NoteClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="NoteClipBox";constructor(e){super(e)}accept(e){return x(e.visitNoteClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.NoteEventCollection,!0),3:v.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Tt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:v.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:D.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h})}}};var Vt=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ValueEventBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventBox,this)}get events(){return this.getField(1)}get position(){return this.getField(10)}get index(){return this.getField(11)}get interpolation(){return this.getField(12)}get value(){return this.getField(13)}get slope(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"events",pointerRules:h},u.ValueEvents,!0),10:v.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:h}),12:v.create({parent:this,fieldKey:12,fieldName:"interpolation",pointerRules:{accepts:[u.ValueInterpolation],mandatory:!1}},1),13:P.create({parent:this,fieldKey:13,fieldName:"value",pointerRules:h}),14:P.create({parent:this,fieldKey:14,fieldName:"slope",pointerRules:h})}}};var ft=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCollectionBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ValueEventCollectionBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventCollectionBox,this)}get events(){return this.getField(1)}get owners(){return this.getField(2)}initializeFields(){return{1:T.hook({parent:this,fieldKey:1,fieldName:"events",pointerRules:{accepts:[u.ValueEvents],mandatory:!1}}),2:T.hook({parent:this,fieldKey:2,fieldName:"owners",pointerRules:{accepts:[u.ValueEventCollection],mandatory:!0}})}}};var It=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueEventCurveBox",pointerRules:h}),r)}static ClassName="ValueEventCurveBox";constructor(e){super(e)}accept(e){return x(e.visitValueEventCurveBox,this)}get event(){return this.getField(1)}get slope(){return this.getField(2)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"event",pointerRules:h},u.ValueInterpolation,!0),2:P.create({parent:this,fieldKey:2,fieldName:"slope",pointerRules:h},.5)}}};var pr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="ValueRegionBox";constructor(e){super(e)}accept(e){return x(e.visitValueRegionBox,this)}get regions(){return this.getField(1)}get events(){return this.getField(2)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.ValueEventCollection,!0),10:v.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:v.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:h}),15:D.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:h}),16:v.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:h})}}};var Vr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ValueClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="ValueClipBox";constructor(e){super(e)}accept(e){return x(e.visitValueClipBox,this)}get clips(){return this.getField(1)}get events(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"events",pointerRules:h},u.ValueEventCollection,!0),3:v.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Tt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:v.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:D.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h})}}};var Ir=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioRegionBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="AudioRegionBox";constructor(e){super(e)}accept(e){return x(e.visitAudioRegionBox,this)}get regions(){return this.getField(1)}get file(){return this.getField(2)}get playback(){return this.getField(3)}get position(){return this.getField(10)}get duration(){return this.getField(11)}get loopOffset(){return this.getField(12)}get loopDuration(){return this.getField(13)}get mute(){return this.getField(14)}get label(){return this.getField(15)}get hue(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"regions",pointerRules:h},u.RegionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:h},u.AudioFile,!0),3:D.create({parent:this,fieldKey:3,fieldName:"playback",pointerRules:h},"pitch"),10:v.create({parent:this,fieldKey:10,fieldName:"position",pointerRules:h}),11:v.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:h}),12:v.create({parent:this,fieldKey:12,fieldName:"loopOffset",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"loopDuration",pointerRules:h}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:h}),15:D.create({parent:this,fieldKey:15,fieldName:"label",pointerRules:h}),16:v.create({parent:this,fieldKey:16,fieldName:"hue",pointerRules:h}),17:P.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:h})}}};var Tr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioClipBox",pointerRules:{accepts:[u.Selection,u.Editing],mandatory:!1}}),r)}static ClassName="AudioClipBox";constructor(e){super(e)}accept(e){return x(e.visitAudioClipBox,this)}get clips(){return this.getField(1)}get file(){return this.getField(2)}get index(){return this.getField(3)}get playback(){return this.getField(4)}get duration(){return this.getField(10)}get mute(){return this.getField(11)}get label(){return this.getField(12)}get hue(){return this.getField(13)}get gain(){return this.getField(14)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"clips",pointerRules:h},u.ClipCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"file",pointerRules:h},u.AudioFile,!0),3:v.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:Tt.create({parent:this,fieldKey:4,fieldName:"playback",pointerRules:h}),10:v.create({parent:this,fieldKey:10,fieldName:"duration",pointerRules:h}),11:N.create({parent:this,fieldKey:11,fieldName:"mute",pointerRules:h}),12:D.create({parent:this,fieldKey:12,fieldName:"label",pointerRules:h}),13:v.create({parent:this,fieldKey:13,fieldName:"hue",pointerRules:h}),14:P.create({parent:this,fieldKey:14,fieldName:"gain",pointerRules:h})}}};var Or=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"MarkerBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="MarkerBox";constructor(e){super(e)}accept(e){return x(e.visitMarkerBox,this)}get track(){return this.getField(1)}get position(){return this.getField(2)}get plays(){return this.getField(3)}get label(){return this.getField(4)}get hue(){return this.getField(5)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"track",pointerRules:h},u.MarkerTrack,!0),2:v.create({parent:this,fieldKey:2,fieldName:"position",pointerRules:h}),3:v.create({parent:this,fieldKey:3,fieldName:"plays",pointerRules:h},1),4:D.create({parent:this,fieldKey:4,fieldName:"label",pointerRules:h}),5:v.create({parent:this,fieldKey:5,fieldName:"hue",pointerRules:h})}}};var gs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioFileBox",pointerRules:{accepts:[u.AudioFile],mandatory:!0}}),r)}static ClassName="AudioFileBox";constructor(e){super(e)}accept(e){return x(e.visitAudioFileBox,this)}get startInSeconds(){return this.getField(1)}get endInSeconds(){return this.getField(2)}get fileName(){return this.getField(3)}initializeFields(){return{1:v.create({parent:this,fieldKey:1,fieldName:"startInSeconds",pointerRules:h}),2:v.create({parent:this,fieldKey:2,fieldName:"endInSeconds",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"fileName",pointerRules:h})}}};var xs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SoundfontFileBox",pointerRules:{accepts:[u.SoundfontFile],mandatory:!0}}),r)}static ClassName="SoundfontFileBox";constructor(e){super(e)}accept(e){return x(e.visitSoundfontFileBox,this)}get fileName(){return this.getField(1)}initializeFields(){return{1:D.create({parent:this,fieldKey:1,fieldName:"fileName",pointerRules:h})}}};var Ye=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioUnitBox",pointerRules:{accepts:[u.Selection,u.Automation],mandatory:!1}}),r)}static ClassName="AudioUnitBox";constructor(e){super(e)}accept(e){return x(e.visitAudioUnitBox,this)}get type(){return this.getField(1)}get collection(){return this.getField(2)}get editing(){return this.getField(3)}get index(){return this.getField(11)}get volume(){return this.getField(12)}get panning(){return this.getField(13)}get mute(){return this.getField(14)}get solo(){return this.getField(15)}get tracks(){return this.getField(20)}get midiEffects(){return this.getField(21)}get input(){return this.getField(22)}get audioEffects(){return this.getField(23)}get auxSends(){return this.getField(24)}get output(){return this.getField(25)}get capture(){return this.getField(26)}initializeFields(){return{1:D.create({parent:this,fieldKey:1,fieldName:"type",pointerRules:h},"instrument"),2:E.create({parent:this,fieldKey:2,fieldName:"collection",pointerRules:h},u.AudioUnits,!0),3:T.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[u.Editing],mandatory:!1}}),11:v.create({parent:this,fieldKey:11,fieldName:"index",pointerRules:h}),12:P.create({parent:this,fieldKey:12,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:P.create({parent:this,fieldKey:13,fieldName:"panning",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:N.create({parent:this,fieldKey:14,fieldName:"mute",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:N.create({parent:this,fieldKey:15,fieldName:"solo",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),20:T.hook({parent:this,fieldKey:20,fieldName:"tracks",pointerRules:{accepts:[u.TrackCollection],mandatory:!1}}),21:T.hook({parent:this,fieldKey:21,fieldName:"midiEffects",pointerRules:{accepts:[u.MidiEffectHost],mandatory:!1}}),22:T.hook({parent:this,fieldKey:22,fieldName:"input",pointerRules:{accepts:[u.InstrumentHost,u.AudioOutput],mandatory:!1}}),23:T.hook({parent:this,fieldKey:23,fieldName:"audioEffects",pointerRules:{accepts:[u.AudioEffectHost],mandatory:!1}}),24:T.hook({parent:this,fieldKey:24,fieldName:"auxSends",pointerRules:{accepts:[u.AuxSend],mandatory:!1}}),25:E.create({parent:this,fieldKey:25,fieldName:"output",pointerRules:h},u.AudioOutput,!1),26:E.create({parent:this,fieldKey:26,fieldName:"capture",pointerRules:h},u.Capture,!1)}}};var ys=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureAudioBox",pointerRules:{accepts:[u.Capture],mandatory:!0}}),r)}static ClassName="CaptureAudioBox";constructor(e){super(e)}accept(e){return x(e.visitCaptureAudioBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get requestChannels(){return this.getField(10)}get gainDb(){return this.getField(11)}initializeFields(){return{1:D.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:h}),2:D.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:h},"normal"),10:v.create({parent:this,fieldKey:10,fieldName:"requestChannels",pointerRules:h},1),11:P.create({parent:this,fieldKey:11,fieldName:"gainDb",pointerRules:h},0)}}};var vs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"CaptureMidiBox",pointerRules:{accepts:[u.Capture],mandatory:!0}}),r)}static ClassName="CaptureMidiBox";constructor(e){super(e)}accept(e){return x(e.visitCaptureMidiBox,this)}get deviceId(){return this.getField(1)}get recordMode(){return this.getField(2)}get channel(){return this.getField(10)}initializeFields(){return{1:D.create({parent:this,fieldKey:1,fieldName:"deviceId",pointerRules:h}),2:D.create({parent:this,fieldKey:2,fieldName:"recordMode",pointerRules:h},"normal"),10:v.create({parent:this,fieldKey:10,fieldName:"channel",pointerRules:h},-1)}}};var kr=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AudioBusBox",pointerRules:h}),r)}static ClassName="AudioBusBox";constructor(e){super(e)}accept(e){return x(e.visitAudioBusBox,this)}get collection(){return this.getField(1)}get output(){return this.getField(2)}get input(){return this.getField(3)}get enabled(){return this.getField(4)}get icon(){return this.getField(5)}get label(){return this.getField(6)}get color(){return this.getField(7)}get minimized(){return this.getField(8)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.AudioBusses,!0),2:E.create({parent:this,fieldKey:2,fieldName:"output",pointerRules:h},u.AudioOutput,!0),3:T.hook({parent:this,fieldKey:3,fieldName:"input",pointerRules:{accepts:[u.AudioOutput],mandatory:!1}}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:D.create({parent:this,fieldKey:5,fieldName:"icon",pointerRules:h}),6:D.create({parent:this,fieldKey:6,fieldName:"label",pointerRules:h}),7:D.create({parent:this,fieldKey:7,fieldName:"color",pointerRules:h},"red"),8:N.create({parent:this,fieldKey:8,fieldName:"minimized",pointerRules:h})}}};var bs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"AuxSendBox",pointerRules:h}),r)}static ClassName="AuxSendBox";constructor(e){super(e)}accept(e){return x(e.visitAuxSendBox,this)}get audioUnit(){return this.getField(1)}get targetBus(){return this.getField(2)}get index(){return this.getField(3)}get routing(){return this.getField(4)}get sendGain(){return this.getField(5)}get sendPan(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"audioUnit",pointerRules:h},u.AuxSend,!0),2:E.create({parent:this,fieldKey:2,fieldName:"targetBus",pointerRules:h},u.AudioOutput,!0),3:v.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),4:v.create({parent:this,fieldKey:4,fieldName:"routing",pointerRules:h},1),5:P.create({parent:this,fieldKey:5,fieldName:"sendGain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),6:P.create({parent:this,fieldKey:6,fieldName:"sendPan",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var As=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StepAutomationBox",pointerRules:h}),r)}static ClassName="StepAutomationBox";constructor(e){super(e)}accept(e){return x(e.visitStepAutomationBox,this)}get step(){return this.getField(1)}get parameter(){return this.getField(2)}get value(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"step",pointerRules:h},u.StepAutomation,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:h},u.StepAutomation,!0),3:P.create({parent:this,fieldKey:3,fieldName:"value",pointerRules:h})}}};var ws=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"GrooveShuffleBox",pointerRules:{accepts:[u.Groove],mandatory:!0}}),r)}static ClassName="GrooveShuffleBox";constructor(e){super(e)}accept(e){return x(e.visitGrooveShuffleBox,this)}get label(){return this.getField(1)}get amount(){return this.getField(10)}get duration(){return this.getField(11)}initializeFields(){return{1:D.create({parent:this,fieldKey:1,fieldName:"label",pointerRules:h}),10:P.create({parent:this,fieldKey:10,fieldName:"amount",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.6),11:v.create({parent:this,fieldKey:11,fieldName:"duration",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},480)}}};var Es=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownAudioEffectDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="UnknownAudioEffectDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitUnknownAudioEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:D.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:h})}}};var Bs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"UnknownMidiEffectDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="UnknownMidiEffectDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitUnknownMidiEffectDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get comment(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:D.create({parent:this,fieldKey:10,fieldName:"comment",pointerRules:h})}}};var Fs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceInterfaceKnobBox",pointerRules:h}),r)}static ClassName="DeviceInterfaceKnobBox";constructor(e){super(e)}accept(e){return x(e.visitDeviceInterfaceKnobBox,this)}get userInterface(){return this.getField(1)}get parameter(){return this.getField(2)}get index(){return this.getField(3)}get anchor(){return this.getField(10)}get color(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"userInterface",pointerRules:h},u.DeviceUserInterface,!0),2:E.create({parent:this,fieldKey:2,fieldName:"parameter",pointerRules:h},u.ParameterController,!0),3:v.create({parent:this,fieldKey:3,fieldName:"index",pointerRules:h}),10:P.create({parent:this,fieldKey:10,fieldName:"anchor",pointerRules:h}),11:D.create({parent:this,fieldKey:11,fieldName:"color",pointerRules:h})}}};var Xs=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get elements(){return this.getField(1)}initializeFields(){return{1:T.hook({parent:this,fieldKey:1,fieldName:"elements",pointerRules:{accepts:[u.DeviceUserInterface],mandatory:!1}})}}};var Ns=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ModularDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitModularDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modularSetup(){return this.getField(10)}get userInterface(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:E.create({parent:this,fieldKey:10,fieldName:"modularSetup",pointerRules:h},u.ModularSetup,!0),11:Xs.create({parent:this,fieldKey:11,fieldName:"userInterface",pointerRules:h})}}};var Zs=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get active(){return this.getField(1)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"active",pointerRules:{accepts:[u.StepAutomation],mandatory:!1}})}}};var Js=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get steps(){return this.getField(10)}get length(){return this.getField(11)}get scale(){return this.getField(12)}initializeFields(){return{10:Cr.create({parent:this,fieldKey:10,fieldName:"steps",pointerRules:h},e=>Zs.create(e),128),11:v.create({parent:this,fieldKey:11,fieldName:"length",pointerRules:h},16),12:v.create({parent:this,fieldKey:12,fieldName:"scale",pointerRules:h},960)}}};var Ps=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DeviceClashBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="DeviceClashBox";constructor(e){super(e)}accept(e){return x(e.visitDeviceClashBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}get patterns(){return this.getField(30)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},.5),11:P.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},.9),12:P.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},0),13:P.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},0),14:P.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},-3),15:P.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.StepAutomation],mandatory:!1}},-3),30:Cr.create({parent:this,fieldKey:30,fieldName:"patterns",pointerRules:h},e=>Js.create(e),16)}}};var Ss=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"StereoToolDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="StereoToolDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitStereoToolDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get panning(){return this.getField(11)}get stereo(){return this.getField(12)}get invertL(){return this.getField(13)}get invertR(){return this.getField(14)}get swap(){return this.getField(15)}get panningMixing(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:P.create({parent:this,fieldKey:11,fieldName:"panning",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:P.create({parent:this,fieldKey:12,fieldName:"stereo",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:N.create({parent:this,fieldKey:13,fieldName:"invertL",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:N.create({parent:this,fieldKey:14,fieldName:"invertR",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:N.create({parent:this,fieldKey:15,fieldName:"swap",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),20:v.create({parent:this,fieldKey:20,fieldName:"panningMixing",pointerRules:h},1)}}};var Cs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"DelayDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="DelayDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitDelayDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get delay(){return this.getField(10)}get feedback(){return this.getField(11)}get cross(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"delay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},4),11:P.create({parent:this,fieldKey:11,fieldName:"feedback",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),12:P.create({parent:this,fieldKey:12,fieldName:"cross",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),13:P.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),14:P.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-6),15:P.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0)}}};var Ri=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get order(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:P.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:v.create({parent:this,fieldKey:11,fieldName:"order",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:P.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Mi=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:P.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:P.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Kr=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get enabled(){return this.getField(1)}get frequency(){return this.getField(10)}get gain(){return this.getField(11)}get q(){return this.getField(12)}initializeFields(){return{1:N.create({parent:this,fieldKey:1,fieldName:"enabled",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),10:P.create({parent:this,fieldKey:10,fieldName:"frequency",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:P.create({parent:this,fieldKey:11,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:P.create({parent:this,fieldKey:12,fieldName:"q",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Rs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"RevampDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="RevampDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitRevampDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get highPass(){return this.getField(10)}get lowShelf(){return this.getField(11)}get lowBell(){return this.getField(12)}get midBell(){return this.getField(13)}get highBell(){return this.getField(14)}get highShelf(){return this.getField(15)}get lowPass(){return this.getField(16)}get gain(){return this.getField(17)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:Ri.create({parent:this,fieldKey:10,fieldName:"highPass",pointerRules:h}),11:Mi.create({parent:this,fieldKey:11,fieldName:"lowShelf",pointerRules:h}),12:Kr.create({parent:this,fieldKey:12,fieldName:"lowBell",pointerRules:h}),13:Kr.create({parent:this,fieldKey:13,fieldName:"midBell",pointerRules:h}),14:Kr.create({parent:this,fieldKey:14,fieldName:"highBell",pointerRules:h}),15:Mi.create({parent:this,fieldKey:15,fieldName:"highShelf",pointerRules:h}),16:Ri.create({parent:this,fieldKey:16,fieldName:"lowPass",pointerRules:h}),17:P.create({parent:this,fieldKey:17,fieldName:"gain",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Ms=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ReverbDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ReverbDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitReverbDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get decay(){return this.getField(10)}get preDelay(){return this.getField(11)}get damp(){return this.getField(12)}get filter(){return this.getField(13)}get wet(){return this.getField(14)}get dry(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.AudioEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"decay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),11:P.create({parent:this,fieldKey:11,fieldName:"preDelay",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),12:P.create({parent:this,fieldKey:12,fieldName:"damp",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.5),13:P.create({parent:this,fieldKey:13,fieldName:"filter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),14:P.create({parent:this,fieldKey:14,fieldName:"wet",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-3),15:P.create({parent:this,fieldKey:15,fieldName:"dry",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0)}}};var Ds=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"VaporisateurDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="VaporisateurDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitVaporisateurDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get octave(){return this.getField(11)}get tune(){return this.getField(12)}get waveform(){return this.getField(13)}get cutoff(){return this.getField(14)}get resonance(){return this.getField(15)}get attack(){return this.getField(16)}get release(){return this.getField(17)}get filterEnvelope(){return this.getField(18)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:v.create({parent:this,fieldKey:11,fieldName:"octave",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:P.create({parent:this,fieldKey:12,fieldName:"tune",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:v.create({parent:this,fieldKey:13,fieldName:"waveform",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),14:P.create({parent:this,fieldKey:14,fieldName:"cutoff",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),15:P.create({parent:this,fieldKey:15,fieldName:"resonance",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),16:P.create({parent:this,fieldKey:16,fieldName:"attack",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),17:P.create({parent:this,fieldKey:17,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),18:P.create({parent:this,fieldKey:18,fieldName:"filterEnvelope",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Vs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"SoundfontDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="SoundfontDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitSoundfontDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get file(){return this.getField(10)}get presetIndex(){return this.getField(11)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:E.create({parent:this,fieldKey:10,fieldName:"file",pointerRules:h},u.SoundfontFile,!1),11:v.create({parent:this,fieldKey:11,fieldName:"presetIndex",pointerRules:h})}}};var Is=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"NanoDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="NanoDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitNanoDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get volume(){return this.getField(10)}get file(){return this.getField(15)}get release(){return this.getField(20)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"volume",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},-3),15:E.create({parent:this,fieldKey:15,fieldName:"file",pointerRules:h},u.AudioFile,!1),20:P.create({parent:this,fieldKey:20,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.1)}}};var Ts=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="PlayfieldDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitPlayfieldDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get samples(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:T.hook({parent:this,fieldKey:10,fieldName:"samples",pointerRules:{accepts:[u.Sample],mandatory:!1}})}}};var Ur=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PlayfieldSampleBox",pointerRules:{accepts:[u.Editing],mandatory:!1}}),r)}static ClassName="PlayfieldSampleBox";constructor(e){super(e)}accept(e){return x(e.visitPlayfieldSampleBox,this)}get device(){return this.getField(10)}get file(){return this.getField(11)}get midiEffects(){return this.getField(12)}get audioEffects(){return this.getField(13)}get index(){return this.getField(15)}get label(){return this.getField(20)}get icon(){return this.getField(21)}get enabled(){return this.getField(22)}get minimized(){return this.getField(23)}get mute(){return this.getField(40)}get solo(){return this.getField(41)}get exclude(){return this.getField(42)}get polyphone(){return this.getField(43)}get gate(){return this.getField(44)}get pitch(){return this.getField(45)}get sampleStart(){return this.getField(46)}get sampleEnd(){return this.getField(47)}get attack(){return this.getField(48)}get release(){return this.getField(49)}initializeFields(){return{10:E.create({parent:this,fieldKey:10,fieldName:"device",pointerRules:h},u.Sample,!0),11:E.create({parent:this,fieldKey:11,fieldName:"file",pointerRules:h},u.AudioFile,!0),12:T.hook({parent:this,fieldKey:12,fieldName:"midiEffects",pointerRules:{accepts:[u.MidiEffectHost],mandatory:!1}}),13:T.hook({parent:this,fieldKey:13,fieldName:"audioEffects",pointerRules:{accepts:[u.AudioEffectHost],mandatory:!1}}),15:v.create({parent:this,fieldKey:15,fieldName:"index",pointerRules:h},60),20:D.create({parent:this,fieldKey:20,fieldName:"label",pointerRules:h}),21:D.create({parent:this,fieldKey:21,fieldName:"icon",pointerRules:h}),22:N.create({parent:this,fieldKey:22,fieldName:"enabled",pointerRules:h},!0),23:N.create({parent:this,fieldKey:23,fieldName:"minimized",pointerRules:h},!1),40:N.create({parent:this,fieldKey:40,fieldName:"mute",pointerRules:h}),41:N.create({parent:this,fieldKey:41,fieldName:"solo",pointerRules:h}),42:N.create({parent:this,fieldKey:42,fieldName:"exclude",pointerRules:h}),43:N.create({parent:this,fieldKey:43,fieldName:"polyphone",pointerRules:h}),44:v.create({parent:this,fieldKey:44,fieldName:"gate",pointerRules:h},0),45:P.create({parent:this,fieldKey:45,fieldName:"pitch",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),46:P.create({parent:this,fieldKey:46,fieldName:"sampleStart",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},0),47:P.create({parent:this,fieldKey:47,fieldName:"sampleEnd",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),48:P.create({parent:this,fieldKey:48,fieldName:"attack",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.001),49:P.create({parent:this,fieldKey:49,fieldName:"release",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},.02)}}};var Os=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"TapeDeviceBox",pointerRules:{accepts:[u.Device,u.Selection,u.Automation],mandatory:!1}}),r)}static ClassName="TapeDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitTapeDeviceBox,this)}get host(){return this.getField(1)}get label(){return this.getField(2)}get icon(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get flutter(){return this.getField(10)}get wow(){return this.getField(11)}get noise(){return this.getField(12)}get saturation(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.InstrumentHost,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"icon",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:P.create({parent:this,fieldKey:10,fieldName:"flutter",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:P.create({parent:this,fieldKey:11,fieldName:"wow",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:P.create({parent:this,fieldKey:12,fieldName:"noise",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),13:P.create({parent:this,fieldKey:13,fieldName:"saturation",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var ks=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ArpeggioDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ArpeggioDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitArpeggioDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get modeIndex(){return this.getField(10)}get numOctaves(){return this.getField(11)}get rateIndex(){return this.getField(12)}get gate(){return this.getField(13)}get repeat(){return this.getField(14)}get velocity(){return this.getField(15)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:v.create({parent:this,fieldKey:10,fieldName:"modeIndex",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:v.create({parent:this,fieldKey:11,fieldName:"numOctaves",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),12:v.create({parent:this,fieldKey:12,fieldName:"rateIndex",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},9),13:P.create({parent:this,fieldKey:13,fieldName:"gate",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),14:v.create({parent:this,fieldKey:14,fieldName:"repeat",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}},1),15:P.create({parent:this,fieldKey:15,fieldName:"velocity",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Us=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"PitchDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="PitchDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitPitchDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get semiTones(){return this.getField(10)}get cents(){return this.getField(11)}get octaves(){return this.getField(12)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:v.create({parent:this,fieldKey:10,fieldName:"semiTones",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),11:P.create({parent:this,fieldKey:11,fieldName:"cents",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}}),12:v.create({parent:this,fieldKey:12,fieldName:"octaves",pointerRules:{accepts:[u.Modulation,u.Automation,u.MidiControl],mandatory:!1}})}}};var Ks=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ZeitgeistDeviceBox",pointerRules:{accepts:[u.Device,u.Selection],mandatory:!1}}),r)}static ClassName="ZeitgeistDeviceBox";constructor(e){super(e)}accept(e){return x(e.visitZeitgeistDeviceBox,this)}get host(){return this.getField(1)}get index(){return this.getField(2)}get label(){return this.getField(3)}get enabled(){return this.getField(4)}get minimized(){return this.getField(5)}get groove(){return this.getField(10)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"host",pointerRules:h},u.MidiEffectHost,!0),2:v.create({parent:this,fieldKey:2,fieldName:"index",pointerRules:h}),3:D.create({parent:this,fieldKey:3,fieldName:"label",pointerRules:h}),4:N.create({parent:this,fieldKey:4,fieldName:"enabled",pointerRules:h},!0),5:N.create({parent:this,fieldKey:5,fieldName:"minimized",pointerRules:h},!1),10:E.create({parent:this,fieldKey:10,fieldName:"groove",pointerRules:h},u.Groove,!0)}}};var Ls=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularBox",pointerRules:h}),r)}static ClassName="ModularBox";constructor(e){super(e)}accept(e){return x(e.visitModularBox,this)}get collection(){return this.getField(1)}get device(){return this.getField(2)}get editing(){return this.getField(3)}get modules(){return this.getField(11)}get connections(){return this.getField(12)}get label(){return this.getField(13)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ModularSetup,!0),2:T.hook({parent:this,fieldKey:2,fieldName:"device",pointerRules:{accepts:[u.ModularSetup],mandatory:!0}}),3:T.hook({parent:this,fieldKey:3,fieldName:"editing",pointerRules:{accepts:[u.Editing],mandatory:!1}}),11:T.hook({parent:this,fieldKey:11,fieldName:"modules",pointerRules:{accepts:[u.ModuleCollection],mandatory:!1}}),12:T.hook({parent:this,fieldKey:12,fieldName:"connections",pointerRules:{accepts:[u.ConnectionCollection],mandatory:!1}}),13:D.create({parent:this,fieldKey:13,fieldName:"label",pointerRules:h})}}};var $s=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleConnectionBox",pointerRules:h}),r)}static ClassName="ModuleConnectionBox";constructor(e){super(e)}accept(e){return x(e.visitModuleConnectionBox,this)}get collection(){return this.getField(1)}get source(){return this.getField(2)}get target(){return this.getField(3)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ConnectionCollection,!0),2:E.create({parent:this,fieldKey:2,fieldName:"source",pointerRules:h},u.VoltageConnection,!0),3:E.create({parent:this,fieldKey:3,fieldName:"target",pointerRules:h},u.VoltageConnection,!0)}}};var Ke=class i extends ue{static create(e){return new i(e)}constructor(e){super(e)}get collection(){return this.getField(1)}get label(){return this.getField(2)}get x(){return this.getField(3)}get y(){return this.getField(4)}get collapsed(){return this.getField(5)}get removable(){return this.getField(6)}initializeFields(){return{1:E.create({parent:this,fieldKey:1,fieldName:"collection",pointerRules:h},u.ModuleCollection,!0),2:D.create({parent:this,fieldKey:2,fieldName:"label",pointerRules:h}),3:v.create({parent:this,fieldKey:3,fieldName:"x",pointerRules:h}),4:v.create({parent:this,fieldKey:4,fieldName:"y",pointerRules:h}),5:N.create({parent:this,fieldKey:5,fieldName:"collapsed",pointerRules:h},!1),6:N.create({parent:this,fieldKey:6,fieldName:"removable",pointerRules:h},!0)}}};var qs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioInputBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModularAudioInputBox";constructor(e){super(e)}accept(e){return x(e.visitModularAudioInputBox,this)}get attributes(){return this.getField(1)}get output(){return this.getField(10)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:T.hook({parent:this,fieldKey:10,fieldName:"output",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}})}}};var zs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModularAudioOutputBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModularAudioOutputBox";constructor(e){super(e)}accept(e){return x(e.visitModularAudioOutputBox,this)}get attributes(){return this.getField(1)}get input(){return this.getField(10)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:T.hook({parent:this,fieldKey:10,fieldName:"input",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}})}}};var _s=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleDelayBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleDelayBox";constructor(e){super(e)}accept(e){return x(e.visitModuleDelayBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(11)}get time(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:T.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),11:T.hook({parent:this,fieldKey:11,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:P.create({parent:this,fieldKey:20,fieldName:"time",pointerRules:{accepts:[u.ParameterController],mandatory:!1}},500)}}};var Hs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleMultiplierBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleMultiplierBox";constructor(e){super(e)}accept(e){return x(e.visitModuleMultiplierBox,this)}get attributes(){return this.getField(1)}get voltageInputX(){return this.getField(10)}get voltageInputY(){return this.getField(11)}get voltageOutput(){return this.getField(12)}get multiplier(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:T.hook({parent:this,fieldKey:10,fieldName:"voltageInputX",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),11:T.hook({parent:this,fieldKey:11,fieldName:"voltageInputY",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),12:T.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:P.create({parent:this,fieldKey:20,fieldName:"multiplier",pointerRules:h})}}};var Gs=class i extends F{static create(e,t,r){return e.stageBox(new i({uuid:t,graph:e,name:"ModuleGainBox",pointerRules:{accepts:[u.Selection],mandatory:!1}}),r)}static ClassName="ModuleGainBox";constructor(e){super(e)}accept(e){return x(e.visitModuleGainBox,this)}get attributes(){return this.getField(1)}get voltageInput(){return this.getField(10)}get voltageOutput(){return this.getField(12)}get gain(){return this.getField(20)}initializeFields(){return{1:Ke.create({parent:this,fieldKey:1,fieldName:"attributes",pointerRules:h}),10:T.hook({parent:this,fieldKey:10,fieldName:"voltageInput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),12:T.hook({parent:this,fieldKey:12,fieldName:"voltageOutput",pointerRules:{accepts:[u.VoltageConnection],mandatory:!1}}),20:P.create({parent:this,fieldKey:20,fieldName:"gain",pointerRules:{accepts:[u.ParameterController],mandatory:!1}})}}};var et;(function(i){i.write=(e,t)=>{if(t.type==="none")e.disconnect(),e.setValue(0);else if(t.type==="linear")e.disconnect(),e.setValue(1);else if(t.type==="curve"){e.setValue(0);let r=e.pointerHub.filter(u.ValueInterpolation).at(0)?.box;V(r)?(yn(r,It),r.slope.setValue(t.slope)):It.create(e.box.graph,A.generate(),s=>{s.slope.setValue(t.slope),s.event.refer(e)})}},i.read=e=>{let t=e.pointerHub.incoming().at(0)?.box;return V(t)?(yn(t,It),{type:"curve",slope:t.slope.getValue()}):e.getValue()===0?Ct.None:e.getValue()===1?Ct.Linear:g("Unknown Interpolation value")}})(et||(et={}));var Ot=class i{static Comparator=(e,t)=>{let r=e.position-t.position;if(r!==0)return r;let s=e.index-t.index;if(s!==0)return s;throw new Error(`${e} and ${t} are identical in terms of comparison`)};type="value-event";#t=new I;#e;#r;#i;#s;#o=!1;constructor(e,t){this.#e=e,this.#r=t,this.#i=this.#t.own(new $i(()=>et.read(this.#r.interpolation)));let r=()=>{this.#i.invalidate(),this.collection.ifSome(s=>s.onEventPropertyChanged())};this.#t.ownAll(this.#r.subscribe(Y.Children,s=>{if(!this.collection.isEmpty()&&(s.type==="primitive"||s.type==="pointer")){let o=this.collection.unwrap(),n=s.address.fieldKeys,a=w.equals(this.#r.index.address.fieldKeys,n),l=w.equals(this.#r.position.address.fieldKeys,n);a||l?o.requestSorting():o.onEventPropertyChanged()}}),this.#r.interpolation.subscribe(r),this.#r.interpolation.pointerHub.subscribeImmediate({onAdd:({box:s})=>{this.#s.terminate(),this.#s=s.subscribe(Y.Children,r),r()},onRemove:()=>{this.#s.terminate(),this.#s=O.Empty,r()}})),this.#s=this.#r.interpolation.pointerHub.filter(u.ValueInterpolation).at(0)?.box.subscribe(Y.Children,r)??O.Empty}onSelected(){this.#o=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#o=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#s.terminate(),this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get index(){return this.#r.index.getValue()}set interpolation(e){et.write(this.#r.interpolation,e)}get interpolation(){return this.#i.get()}get value(){return this.#r.value.getValue()}get isSelected(){return this.#o}get collection(){return this.#r.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,Le))}copyTo(e){let t=Vt.create(this.#e.boxGraph,A.generate(),r=>{r.position.setValue(e?.position??this.position),r.index.setValue(e?.index??this.index),r.events.refer(e?.events??this.collection.unwrap().box.events),r.value.setValue(e?.value??this.value)});return et.write(t.interpolation,e?.interpolation??this.interpolation),this.#e.boxAdapters.adapterFor(t,i)}copyFrom(e){return this.#r.position.setValue(e?.position??this.position),this.#r.index.setValue(e?.index??this.index),this.#r.events.refer(e?.events??this.collection.unwrap().box.events),this.#r.value.setValue(e?.value??this.value),et.write(this.#r.interpolation,e?.interpolation??this.interpolation),this}toString(){return`{ValueEventBoxAdapter position: ${this.position} index: ${this.index}}`}};var Le=class i{#t=new I;#e;#r;#i;#s;#o;constructor(e,t){this.#e=e,this.#r=t,this.#i=new q,this.#s=A.newSet(s=>s.uuid),this.#o=Nt.create(Ot.Comparator);let r=s=>{let o=K(s.accept({visitValueEventBox:n=>this.#e.boxAdapters.adapterFor(n,Ot)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#n())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#t.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#n()}})),this.#t.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}valueAt(e,t){return rs.valueAt(this.#o,e,t)}copy(){let e=this.#e.boxGraph,t=ft.create(e,A.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#e.boxAdapters.adapterFor(t,i)}cut(e){let t=this.events.lowerEqual(e),r=this.events.greaterEqual(e);if(r===null)return t===null?p.None:p.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t===null)return p.wrap(this.createEvent({position:e,value:r.value,index:r.index,interpolation:r.interpolation}));if(t.position===e)return p.wrap(t);if(t.interpolation.type==="none")return p.wrap(this.createEvent({position:e,value:t.value,index:t.index,interpolation:t.interpolation}));if(t.interpolation.type==="linear"){let{position:s,value:o}=t,{position:n,value:a}=r;return p.wrap(this.createEvent({position:e,value:na(o,a,(e-s)/(n-s)),index:0,interpolation:t.interpolation}))}if(t.interpolation.type==="curve"){let{position:s,value:o}=t,{position:n,value:a}=r,l=n-s,c=e-s,d=Ue.byHalf(l,o,Ue.valueAt({slope:t.interpolation.slope,steps:l,y0:o,y1:a},l*.5),a),m=Ue.valueAt(d,c),f=Ue.slopeByHalf(o,Ue.valueAt(d,c*.5),m);return et.write(t.box.interpolation,Ct.Curve(f)),p.wrap(this.createEvent({position:e,value:m,index:0,interpolation:Ct.Curve(Ue.slopeByHalf(m,Ue.valueAt(d,(c+l)*.5),a))}))}return g("Unknown interpolation type")}subscribeChange(e){return this.#i.subscribe(e)}createEvent({position:e,index:t,value:r,interpolation:s}){let o=Vt.create(this.#e.boxGraph,A.generate(),n=>{n.position.setValue(e),n.index.setValue(t),n.value.setValue(r),n.events.refer(this.#r.events)});return et.write(o.interpolation,s),this.#e.boxAdapters.adapterFor(o,Ot)}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#n()}terminate(){this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(u.ValueEventCollection).length}get events(){return this.#o}toString(){return`{ValueEventCollectionBox ${A.toString(this.#r.address.uuid)}}`}#n(){this.#i.notify(this)}};var kt=class{type="value-clip";#t=new I;#e;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#r=t,this.#o=!0,this.#i=this.#t.own(new Ce(!1)),this.#s=this.#t.own(new q),this.#t.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#t.own(this.#r.subscribe(Y.Children,r=>this.#a())),this.#t.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#e.boxAdapters.adapterFor(s,Le).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(e%this.duration,t)}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitValueClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Vr.create(this.#e.boxGraph,A.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,Le))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{ValueClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${W.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var tt=class{#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get startInSeconds(){return this.#e.startInSeconds.getValue()}get endInSeconds(){return this.#e.endInSeconds.getValue()}get data(){return this.getOrCreateLoader().data}get peaks(){return this.getOrCreateLoader().peaks}getOrCreateLoader(){return this.#t.sampleManager.getOrCreate(this.#e.address.uuid)}terminate(){}};var Ut=class{type="audio-clip";#t=new I;#e;#r;#i;#s;#o;#n=p.None;#a=p.None;constructor(e,t){this.#e=e,this.#r=t,this.#o=!0,this.#i=this.#t.own(new Ce(!1)),this.#s=this.#t.own(new q),this.#t.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(s=>this.#e.boxAdapters.adapterFor(s.box,tt)),this.#a.ifSome(s=>s.terminate()),this.#a=this.#n.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(Y.Children,r=>this.#l()),{terminate:()=>{this.#a.ifSome(r=>r.terminate()),this.#a=p.None}}),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitAudioClipBoxAdapter,this)}consolidate(){}clone(e){Tr.create(this.#e.boxGraph,A.generate(),t=>{t.index.setValue(this.indexField.getValue()),t.gain.setValue(this.gain),t.label.setValue(this.label),t.hue.setValue(this.hue),t.duration.setValue(this.duration),t.mute.setValue(this.mute),t.clips.refer(this.#r.clips.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap())})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#n.unwrap("Cannot access file.")}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return p.None}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}get isMirrowed(){return!1}get canMirror(){return!1}toString(){return`{AudioClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${W.toString(this.duration)}}`}#l(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var mr=class i{type="note-event";#t;#e;#r;#i=!1;constructor(e,t){this.#t=e,this.#e=t,this.#r=this.#e.subscribe(Y.Children,r=>{if(!this.collection.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.collection.unwrap(),o=r.address.fieldKeys,n=w.equals(this.#e.pitch.address.fieldKeys,o),a=w.equals(this.#e.position.address.fieldKeys,o);n||a?s.requestSorting():s.onEventPropertyChanged()}})}onSelected(){this.#i=!0,this.collection.ifSome(e=>e.onEventPropertyChanged())}onDeselected(){this.#i=!1,this.collection.ifSome(e=>e.onEventPropertyChanged())}terminate(){this.#r.terminate()}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get position(){return this.#e.position.getValue()}get duration(){return this.#e.duration.getValue()}get complete(){return this.position+this.duration}get velocity(){return this.#e.velocity.getValue()}get pitch(){return this.#e.pitch.getValue()}get cent(){return this.#e.cent.getValue()}get chance(){return this.#e.chance.getValue()}get playCount(){return this.#e.playCount.getValue()}get playCurve(){return this.#e.playCurve.getValue()}get isSelected(){return this.#i}get collection(){return this.#e.events.targetVertex.map(e=>this.#t.boxAdapters.adapterFor(e.box,$e))}normalizedPitch(){if(this.collection.isEmpty())return .5;let{minPitch:e,maxPitch:t}=this.collection.unwrap();return e===t?.5:1-(this.pitch-e)/(t-e)}copyAsNoteEvent(){return{type:"note-event",position:this.position,duration:this.duration,pitch:this.pitch,cent:this.cent,velocity:this.velocity}}copyTo(e){return this.#t.boxAdapters.adapterFor(Dt.create(this.#t.boxGraph,A.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.pitch.setValue(e?.pitch??this.pitch),t.playCount.setValue(e?.playCount??this.playCount),t.events.refer(e?.events??this.collection.unwrap().box.events),t.velocity.setValue(this.velocity),t.cent.setValue(this.cent),t.chance.setValue(this.chance)}),i)}computeCurveValue(e){return Me.curveFunc(e,this.playCurve)}canConsolidate(){return this.playCount>1}consolidate(){let e=this.playCount,t=this.collection.unwrap().box.events,r=w.create(s=>{let o=Math.floor(this.computeCurveValue(s/e)*this.duration),n=Math.floor(this.computeCurveValue((s+1)/e)*this.duration);return this.copyTo({position:Math.floor(this.position+o),duration:Math.max(1,n-o),playCount:1,events:t})},e);return this.#e.delete(),r}};var $e=class i{#t=new I;#e;#r;#i;#s;#o;#n=60;#a=60;#l=0;#u=!1;constructor(e,t){this.#e=e,this.#r=t,this.#i=new q,this.#s=A.newSet(s=>s.uuid),this.#o=Nt.create(Me.Comparator);let r=s=>{let o=K(s.accept({visitNoteEventBox:n=>this.#e.boxAdapters.adapterFor(n,mr)}),`Could not find adapter for ${s}`);this.#s.add(o)&&(this.#o.add(o),this.#c())};this.#r.events.pointerHub.incoming().forEach(({box:s})=>r(s)),this.#t.own(this.#r.events.pointerHub.subscribeTransactual({onAdd:({box:s})=>r(s),onRemove:({box:{address:{uuid:s}}})=>{this.#o.remove(this.#s.removeByKey(s)),this.#c()}})),this.#t.own(this.#r.owners.pointerHub.subscribeTransactual({onAdd:()=>this.#i.notify(this),onRemove:()=>this.#i.notify(this)}))}copy(){let e=this.#e.boxGraph,t=mt.create(e,A.generate());return this.#o.asArray().forEach(r=>r.copyTo({events:t.events})),this.#e.boxAdapters.adapterFor(t,i)}createEvent({position:e,duration:t,velocity:r,pitch:s,chance:o,playCount:n,cent:a}){return this.#e.boxAdapters.adapterFor(Dt.create(this.#e.boxGraph,A.generate(),l=>{l.position.setValue(e),l.duration.setValue(t),l.velocity.setValue(r),l.pitch.setValue(s),l.chance.setValue(o),l.playCount.setValue(n),l.cent.setValue(a),l.events.refer(this.#r.events)}),mr)}subscribeChange(e){return this.#i.subscribe(e)}selectable(){return this.#o.asArray()}selectableAt(e){for(let t of this.#o.asArray())if(t.position<=e.u&&e.u<t.complete&&t.pitch===e.v)return le.one(t);return le.empty()}selectablesBetween(e,t){let r=[];for(let s of this.#o.asArray())vi.intersect1D(s.position,s.complete,e.u,t.u)&&vi.intersect1D(s.pitch,s.pitch,e.v,t.v)&&r.push(s);return r}requestSorting(){this.#o.onIndexingChanged(),this.onEventPropertyChanged()}onEventPropertyChanged(){this.#c()}terminate(){this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get numOwners(){return this.#r.owners.pointerHub.filter(u.NoteEventCollection).length}get events(){return this.#u||this.#d(),this.#o}get minPitch(){return this.#u||this.#d(),this.#n}get maxPitch(){return this.#u||this.#d(),this.#a}get maxDuration(){return this.#u||this.#d(),this.#l}toString(){return`{NoteEventCollectionBox ${A.toString(this.#r.address.uuid)}}`}#c(){this.#u=!1,this.#i.notify(this)}#d(){let e=127,t=0,r=0;this.#o.asArray().forEach(({pitch:s,duration:o})=>{e=Math.min(e,s),t=Math.max(t,s),r=Math.max(r,o)}),this.#n=e,this.#a=t,this.#l=r,this.#u=!0}};var Lr=class{type="note-clip";#t=new I;#e;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#r=t,this.#o=!0,this.#i=this.#t.own(new Ce(!1)),this.#s=this.#t.own(new q),this.#t.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(Y.Children,r=>this.#a()),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#e.boxAdapters.adapterFor(s,$e).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}catchupAndSubscribeSelected(e){return this.#i.catchupAndSubscribe(e)}subscribeChange(e){return this.#s.subscribe(e)}accept(e){return x(e.visitNoteClipBoxAdapter,this)}consolidate(){this.#r.events.refer(this.optCollection.unwrap().copy().box.owners)}clone(e){let t=e?this.optCollection.unwrap().copy().box.owners:this.#r.events.targetVertex.unwrap();Dr.create(this.#e.boxGraph,A.generate(),r=>{r.index.setValue(this.indexField.getValue()),r.label.setValue(this.label),r.hue.setValue(this.hue),r.duration.setValue(this.duration),r.mute.setValue(this.mute),r.clips.refer(this.#r.clips.targetVertex.unwrap()),r.events.refer(t)})}onSelected(){this.#i.setValue(!0)}onDeselected(){this.#i.setValue(!1)}get isSelected(){return this.#i.getValue()}terminate(){this.#n.terminate(),this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get duration(){return this.#r.duration.getValue()}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get events(){return this.optCollection.map(e=>e.events)}get hasCollection(){return!this.optCollection.isEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,$e))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.clips.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}toString(){return`{NoteClipBoxAdapter ${A.toString(this.#r.address.uuid)} d: ${W.toString(this.duration)}}`}#a(){this.#s.notify(),this.trackBoxAdapter.unwrapOrNull()?.clips?.dispatchChange()}};var eo={for:(i,e)=>K(e.accept({visitNoteClipBox:t=>i.adapterFor(t,Lr),visitValueClipBox:t=>i.adapterFor(t,kt),visitAudioClipBox:t=>i.adapterFor(t,Ut)}),"")};var to=class{#t;#e;#r;#i;constructor(e,t){this.#t=e,this.#e=new I,this.#r=this.#e.own(new q),this.#i=this.#e.own(Be.create(e.box.clips,r=>eo.for(t,r),u.ClipCollection)),this.#i.subscribe({onAdd:()=>this.dispatchChange(),onRemove:()=>this.dispatchChange(),onReorder:()=>this.dispatchChange()})}get trackBoxAdapter(){return this.#t}get collection(){return this.#i}dispatchChange(){this.#r.notify()}subscribeChanges(e){return this.#r.subscribe(e)}terminate(){this.#e.terminate()}};var Kt=class i{type="audio-region";#t;#e;#r;#i;#s=p.None;#o=p.None;#n;#a;constructor(e,t){this.#e=e,this.#r=t,this.#t=new I,this.#i=new q,this.#n=!1,this.#a=!0,this.#t.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#l(),onRemove:()=>this.#l()}),this.#r.file.catchupAndSubscribe(r=>{this.#s=r.targetVertex.map(s=>this.#e.boxAdapters.adapterFor(s.box,tt)),this.#o.ifSome(s=>s.terminate()),this.#o=this.#s.map(s=>s.getOrCreateLoader().subscribe(()=>this.#l()))}),this.#r.subscribe(Y.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#l()):this.#l()}}),{terminate:()=>{this.#o.ifSome(r=>r.terminate()),this.#o=p.None}}),this.#a=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitAudioRegionBoxAdapter,this)}onSelected(){this.#n=!0,this.#l()}onDeselected(){this.#n=!1,this.#l()}get isSelected(){return this.#n}terminate(){this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){let e=this.#r.duration.getValue();if(e===0){let t=this.#s.unwrap("Cannot compute duration without file"),r=t.startInSeconds,o=t.endInSeconds-r;return W.secondsToPulses(o,this.#e.bpm)}return e}get complete(){return this.position+this.duration}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get gain(){return this.#r.gain.getValue()}get file(){return this.#s.unwrap("Cannot access file.")}get hasCollection(){return this.#s.nonEmpty()}get optCollection(){return p.None}get label(){if(this.#s.isEmpty())return"No Audio File";let e=this.#s.unwrap().getOrCreateLoader().state;return e.type==="progress"?`${Math.round(e.progress*100)}%`:e.type==="error"?String(e.reason):this.#r.label.getValue()}get isMirrowed(){return!1}get canMirror(){return!1}get trackBoxAdapter(){return this.#r.regions.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}copyTo(e){return this.#e.boxAdapters.adapterFor(Ir.create(this.#e.boxGraph,A.generate(),t=>{t.position.setValue(e?.position??this.position),t.duration.setValue(e?.duration??this.duration),t.loopOffset.setValue(e?.loopOffset??this.loopOffset),t.loopDuration.setValue(e?.loopDuration??this.loopDuration),t.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap()),t.file.refer(this.#r.file.targetVertex.unwrap()),t.mute.setValue(this.mute),t.hue.setValue(this.hue),t.label.setValue(this.label),t.gain.setValue(this.gain)}),i)}consolidate(){}canFlatten(e){return!1}flatten(e){return p.None}toString(){return`{AudioRegionBoxAdapter ${A.toString(this.#r.address.uuid)}}`}#l(){this.#a||(this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange())}};var Lt=class i{type="note-region";#t=new I;#e;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#r=t,this.#i=new q,this.#o=!1,this.#s=!0,this.#t.ownAll(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()}),this.#r.subscribe(Y.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}}),this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#e.boxAdapters.adapterFor(s,$e).subscribeChange(()=>this.#a())}),this.#a()})),this.#s=!1}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitNoteRegionBoxAdapter,this)}onSelected(){this.#o=!0,this.#a()}onDeselected(){this.#o=!1,this.#a()}get isSelected(){return this.#o}*iterateActiveNotesAt(e){let t=this.optCollection;if(t.isEmpty())return;let r=t.unwrap(),s=Ie.globalToLocal(this,e);for(let o of r.events.iterateFrom(s-r.maxDuration)){if(s<o.position)return;s<o.complete&&(yield o.copyAsNoteEvent())}}terminate(){this.#n.terminate(),this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return this.optCollection.nonEmpty()}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,$e))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#s?p.None:this.#r.regions.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#e.boxAdapters.adapterFor(dr.create(this.#e.boxGraph,A.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.optCollection.ifSome(e=>{let t=this.#e.boxGraph,r=mt.create(t,A.generate());e.events.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return e.length>0&&w.satisfy(e,(t,r)=>t.trackBoxAdapter.contains(r.trackBoxAdapter.unwrap()))&&e.every(t=>t.isSelected&&t instanceof i)}flatten(e){if(!this.canFlatten(e))return p.None;let t=this.#e.boxGraph,r=e.toSorted(Pt.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,l=s.trackBoxAdapter.unwrap(),c=mt.create(t,A.generate()),d=Array.from(l.regions.collection.iterateRange(n,a));return d.filter(m=>m.isSelected).forEach(m=>{let f=m;for(let{resultStart:y,resultEnd:B,rawStart:S}of Ie.locateLoops(f,f.position,f.complete)){let R=Math.floor(y-S),k=Math.floor(B-S);for(let L of f.optCollection.unwrap().events.iterateRange(R,k))L.copyTo({position:L.position+S-s.position,events:c.events})}}),d.forEach(({box:m})=>m.delete()),p.wrap(dr.create(t,A.generate(),m=>{m.position.setValue(n),m.duration.setValue(a-n),m.loopDuration.setValue(a-n),m.loopOffset.setValue(0),m.hue.setValue(this.hue),m.mute.setValue(this.mute),m.label.setValue(this.label),m.events.refer(c.owners),m.regions.refer(l.box.regions)}))}toString(){return`{NoteRegionBoxAdapter ${A.toString(this.#r.address.uuid)} p: ${W.toString(this.position)}, c: ${W.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var gt=class i{type="value-region";#t=new I;#e;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#e=e,this.#r=t,this.#o=!0,this.#i=new q,this.#s=!1,this.#t.own(this.#r.pointerHub.subscribeImmediate({onAdd:()=>this.#a(),onRemove:()=>this.#a()})),this.#t.own(this.#r.subscribe(Y.Children,r=>{if(!this.trackBoxAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackBoxAdapter.unwrap();this.#r.position.address.equals(r.address)?(s.regions.onIndexingChanged(),this.#a()):this.#a()}})),this.#t.own(this.#r.events.catchupAndSubscribe(({targetVertex:r})=>{this.#n.terminate(),this.#n=r.match({none:()=>O.Empty,some:({box:s})=>this.#e.boxAdapters.adapterFor(s,Le).subscribeChange(()=>this.#a())}),this.#a()})),this.#o=!1}valueAt(e,t){let r=this.optCollection;return r.isEmpty()?t:r.unwrap().valueAt(Ie.globalToLocal(this,e),t)}incomingValue(e){return this.valueAt(this.position,e)}outgoingValue(e){let t=this.optCollection;if(t.isEmpty())return e;let r=t.unwrap();return(this.complete-this.offset)%this.loopDuration===0?r.valueAt(this.loopDuration,e):r.valueAt(Ie.globalToLocal(this,this.complete),e)}subscribeChange(e){return this.#i.subscribe(e)}accept(e){return x(e.visitValueRegionBoxAdapter,this)}onSelected(){this.#s=!0,this.#a()}onDeselected(){this.#s=!1,this.#a()}get isSelected(){return this.#s}onValuesPropertyChanged(){this.#a()}onValuesSortingChanged(){this.onValuesPropertyChanged()}terminate(){this.#n.terminate(),this.#t.terminate()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get duration(){return this.#r.duration.getValue()}get loopOffset(){return this.#r.loopOffset.getValue()}get loopDuration(){return this.#r.loopDuration.getValue()}get offset(){return this.position-this.loopOffset}get complete(){return this.position+this.duration}get mute(){return this.#r.mute.getValue()}get hue(){return this.#r.hue.getValue()}get hasCollection(){return!this.optCollection.isEmpty()}get events(){return this.optCollection.map(e=>e.events)}get optCollection(){return this.#r.events.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,Le))}get label(){return this.#r.label.getValue()}get trackBoxAdapter(){return this.#o?p.None:this.#r.regions.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,fe))}get isMirrowed(){return this.optCollection.mapOr(e=>e.numOwners>1,!1)}get canMirror(){return!0}copyTo(e){let t=this.optCollection.unwrap("Cannot make copy without event-collection"),r=e?.consolidate===!0?t.copy().box.owners:t.box.owners;return this.#e.boxAdapters.adapterFor(pr.create(this.#e.boxGraph,A.generate(),s=>{s.position.setValue(e?.position??this.position),s.duration.setValue(e?.duration??this.duration),s.loopOffset.setValue(e?.loopOffset??this.loopOffset),s.loopDuration.setValue(e?.loopDuration??this.loopDuration),s.hue.setValue(this.hue),s.label.setValue(this.label),s.mute.setValue(this.mute),s.events.refer(r),s.regions.refer(e?.track??this.#r.regions.targetVertex.unwrap())}),i)}consolidate(){this.isMirrowed&&this.events.ifSome(e=>{let t=this.#e.boxGraph,r=ft.create(t,A.generate());e.asArray().forEach(s=>s.copyTo({events:r.events})),this.#r.events.refer(r.owners)})}canFlatten(e){return!1}flatten(e){if(!this.canFlatten(e))return p.None;let t=this.#e.boxGraph,r=e.toSorted(Pt.Comparator),s=w.getFirst(r,"Internal error (no first)"),o=w.getLast(r,"Internal error (no last)"),n=s.position,a=o.position+o.duration,l=s.trackBoxAdapter.unwrap(),c=ft.create(t,A.generate()),d=Array.from(l.regions.collection.iterateRange(n,a));return d.filter(m=>m.isSelected).forEach(m=>{let f=m;for(let{resultStart:y,resultEnd:B,rawStart:S}of Ie.locateLoops(f,f.position,f.complete)){let R=Math.floor(y-S),k=Math.floor(B-S);for(let L of f.events.unwrap().iterateRange(R,k));}}),d.forEach(({box:m})=>m.delete()),p.wrap(pr.create(t,A.generate(),m=>{m.position.setValue(n),m.duration.setValue(a-n),m.loopDuration.setValue(a-n),m.loopOffset.setValue(0),m.hue.setValue(this.hue),m.mute.setValue(this.mute),m.label.setValue(this.label),m.events.refer(c.owners),m.regions.refer(l.box.regions)}))}toString(){return`{ValueRegionBoxAdapter ${A.toString(this.#r.address.uuid)} p: ${W.toString(this.position)}, c: ${W.toString(this.complete)}}`}#a(){this.#i.notify(),this.trackBoxAdapter.unwrapOrNull()?.regions?.dispatchChange()}};var $a=(i,e)=>i.position-e.position,qa={for:(i,e)=>K(e.accept({visitNoteRegionBox:t=>i.adapterFor(t,Lt),visitAudioRegionBox:t=>i.adapterFor(t,Kt),visitValueRegionBox:t=>i.adapterFor(t,gt)}),"")};var ro=class{#t;#e;#r;#i;#s;constructor(e,t){this.#t=e,this.#e=new I,this.#r=this.#e.own(new q),this.#i=Pt.create($a),this.#s=A.newSet(r=>r.uuid),this.#e.ownAll(this.#t.box.regions.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{let s=qa.for(t,r),o=this.#s.add(s);b(o,`Cannot add ${r}`),this.#i.add(s),this.dispatchChange()},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#s.removeByKey(r)),this.dispatchChange()}},u.RegionCollection))}get trackBoxAdapter(){return this.#t}get collection(){return this.#i}get adapters(){return this.#s}onIndexingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}subscribeChanges(e){return this.#r.subscribe(e)}dispatchChange(){this.#r.notify()}terminate(){this.#e.terminate()}};var we;(function(i){i[i.Rectangle=0]="Rectangle",i[i.Checkbox=1]="Checkbox",i[i.Cursor=2]="Cursor",i[i.Panel=3]="Panel",i[i.MainMenu=4]="MainMenu",i[i.Dropdown=5]="Dropdown",i[i.Dropbox=6]="Dropbox",i[i.GoogleDrive=7]="GoogleDrive",i[i.AudioDevice=8]="AudioDevice",i[i.GuitarTab=9]="GuitarTab",i[i.Effects=10]="Effects",i[i.Flask=11]="Flask",i[i.Robot=12]="Robot",i[i.NotePad=13]="NotePad",i[i.Pencil=14]="Pencil",i[i.Waveform=15]="Waveform",i[i.Mix=16]="Mix",i[i.Adsr=17]="Adsr",i[i.Dial=18]="Dial",i[i.Record=19]="Record",i[i.Play=20]="Play",i[i.Stop=21]="Stop",i[i.Loop=22]="Loop",i[i.Timeline=23]="Timeline",i[i.Region=24]="Region",i[i.Box=25]="Box",i[i.Mixing=26]="Mixing",i[i.Vinyl=27]="Vinyl",i[i.Help=28]="Help",i[i.Metronome=29]="Metronome",i[i.System=30]="System",i[i.Add=31]="Add",i[i.Subtract=32]="Subtract",i[i.Peak=33]="Peak",i[i.LowPass=34]="LowPass",i[i.HighPass=35]="HighPass",i[i.LowShelf=36]="LowShelf",i[i.HighShelf=37]="HighShelf",i[i.RoundUp=38]="RoundUp",i[i.RoundDown=39]="RoundDown",i[i.Mute=40]="Mute",i[i.Solo=41]="Solo",i[i.Exclude=42]="Exclude",i[i.Menu=43]="Menu",i[i.Pointer=44]="Pointer",i[i.Eraser=45]="Eraser",i[i.Scissors=46]="Scissors",i[i.Tape=47]="Tape",i[i.CollapseDown=48]="CollapseDown",i[i.FileList=49]="FileList",i[i.Close=50]="Close",i[i.DragConnections=51]="DragConnections",i[i.Heart=52]="Heart",i[i.Merge=53]="Merge",i[i.SpeakerHeadphone=54]="SpeakerHeadphone",i[i.AudioBus=55]="AudioBus",i[i.DrumSet=56]="DrumSet",i[i.BassGuitar=57]="BassGuitar",i[i.Guitar=58]="Guitar",i[i.Saxophone=59]="Saxophone",i[i.Microphone=60]="Microphone",i[i.New=61]="New",i[i.Piano=62]="Piano",i[i.ExpandWidth=63]="ExpandWidth",i[i.OpenDAW=64]="OpenDAW",i[i.Automation=65]="Automation",i[i.Embed=66]="Embed",i[i.Popout=67]="Popout",i[i.Minimized=68]="Minimized",i[i.Maximized=69]="Maximized",i[i.Search=70]="Search",i[i.Generator=71]="Generator",i[i.Groove=72]="Groove",i[i.Table=73]="Table",i[i.Note=74]="Note",i[i.Exit=75]="Exit",i[i.Start=76]="Start",i[i.Duration=77]="Duration",i[i.Velocity=78]="Velocity",i[i.Random=79]="Random",i[i.Divide=80]="Divide",i[i.Curve=81]="Curve",i[i.Primary=82]="Primary",i[i.Clips=83]="Clips",i[i.NoAudio=84]="NoAudio",i[i.Unknown=85]="Unknown",i[i.UserFolder=86]="UserFolder",i[i.CloudFolder=87]="CloudFolder",i[i.Run=88]="Run",i[i.Insert=89]="Insert",i[i.ArrayDown=90]="ArrayDown",i[i.Sun=91]="Sun",i[i.Book=92]="Book",i[i.Stack=93]="Stack",i[i.EditBox=94]="EditBox",i[i.Delete=95]="Delete",i[i.Time=96]="Time",i[i.EQ=97]="EQ",i[i.Cube=98]="Cube",i[i.NanoWave=99]="NanoWave",i[i.Midi=100]="Midi",i[i.DinSlot=101]="DinSlot",i[i.VUMeter=102]="VUMeter",i[i.Playfield=103]="Playfield",i[i.Invert=104]="Invert",i[i.Headphone=105]="Headphone",i[i.Stereo=106]="Stereo",i[i.AutoGain=107]="AutoGain",i[i.AudioFile=108]="AudioFile",i[i.Tool=109]="Tool",i[i.Focus=110]="Focus",i[i.Swap=111]="Swap",i[i.Connected=112]="Connected",i[i.Disconnected=113]="Disconnected",i[i.Zeitgeist=114]="Zeitgeist"})(we||(we={}));(function(i){i.toName=e=>i[e],i.fromName=e=>i[e]??i.Rectangle})(we||(we={}));var X;(function(i){i[i.Undefined=0]="Undefined",i[i.Notes=1]="Notes",i[i.Audio=2]="Audio",i[i.Value=3]="Value"})(X||(X={}));(function(i){i.toLabelString=e=>{switch(e){case i.Audio:return"Audio";case i.Notes:return"Notes";case i.Value:return"Automation";case i.Undefined:default:return"N/A"}},i.toIconSymbol=e=>{switch(e){case i.Audio:return we.Waveform;case i.Notes:return we.Piano;case i.Value:return we.Automation;case i.Undefined:return we.AudioBus;default:return we.Unknown}}})(X||(X={}));var io;(function(i){i.isDeviceBox=e=>"host"in e&&ae(e.host,E)&&"label"in e&&ae(e.label,D)&&"enabled"in e&&ae(e.enabled,N)&&"minimized"in e&&ae(e.minimized,N),i.isInstrumentDeviceBox=e=>i.isDeviceBox(e)&&e.host.pointerType===u.InstrumentHost,i.isEffectDeviceBox=e=>i.isDeviceBox(e)&&"index"in e&&ae(e.index,v)&&(e.host.pointerType===u.MidiEffectHost||e.host.pointerType===u.AudioEffectHost),i.lookupHostField=e=>V(e)&&"host"in e&&ae(e.host,E)?e.host:g(`Could not find 'host' field in '${e?.name}'`),i.lookupLabelField=e=>V(e)&&"label"in e&&ae(e.label,D)?e.label:g(`Could not find 'label' field in '${e?.name}'`),i.lookupEnabledField=e=>V(e)&&"enabled"in e&&ae(e.enabled,N)?e.enabled:g(`Could not find 'enabled' field in '${e?.name}'`),i.lookupMinimizedField=e=>V(e)&&"minimized"in e&&ae(e.minimized,N)?e.minimized:g(`Could not find 'minimized' field in '${e?.name}'`),i.lookupIndexField=e=>V(e)&&"index"in e&&ae(e.index,v)?e.index:g(`Could not find 'index' field in '${e?.name}'`)})(io||(io={}));var za;(function(i){i.toTrackType=e=>{switch(e){case"midi":return X.Notes;case"audio":return X.Audio;default:return g()}}})(za||(za={}));var G;(function(i){i.isAny=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="bus"||e.type==="instrument"||e.type==="audio-effect"),i.isEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&(e.type==="midi-effect"||e.type==="audio-effect"),i.isInstrument=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="instrument",i.isMidiEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="midi-effect",i.isAudioEffect=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="audio-effect",i.isHost=e=>e!==null&&typeof e=="object"&&"class"in e&&e.class==="device-host",i.deleteEffectDevices=e=>{if(e.length===0)return;b(w.satisfy(e,(s,o)=>s.deviceHost().address.equals(o.deviceHost().address)),"Devices are not connected to the same host");let t=e[0];(t.accepts==="audio"?t.deviceHost().audioEffects.field().pointerHub.filter(u.AudioEffectHost):t.accepts==="midi"?t.deviceHost().midiEffects.field().pointerHub.filter(u.MidiEffectHost):g("unknown type")).map(({box:s})=>io.lookupIndexField(s)).filter(s=>e.some(o=>A.Comparator(o.uuid,s.address.uuid)!==0)).sort((s,o)=>s.getValue()-o.getValue()).forEach((s,o)=>s.setValue(o)),e.forEach(s=>s.box.delete())}})(G||(G={}));var so=class{#t;#e=new q;#r;#i;#s;constructor(e,t){this.#t=e,this.#r=Be.create(e.box.tracks,r=>t.adapterFor(r,fe),u.TrackCollection),this.#i=A.newSet(({uuid:r})=>r),this.#s=this.#r.catchupAndSubscribe({onAdd:r=>this.#i.add({uuid:r.uuid,subscription:r.regions.subscribeChanges(()=>this.#e.notify())}),onRemove:({uuid:r})=>this.#i.removeByKey(r).subscription.terminate(),onReorder:r=>{}})}create(e,t,r){let s=this.#t.box.graph,o=this.#t.box.tracks;Mr.create(s,A.generate(),n=>{n.index.setValue(r??this.#r.getMinFreeIndex()),n.type.setValue(e),n.tracks.refer(o),n.target.refer(t)})}controls(e){return p.wrap(this.#r.adapters().find(t=>t.target.targetVertex.contains(e),!1))}delete(e){let t=this.#r.adapters(),r=t.indexOf(e);if(r===-1)return g(`Cannot delete ${e}. Does not exist.`);for(let s=r+1;s<t.length;s++)t[s].indexField.setValue(s-1);e.box.delete()}get collection(){return this.#r}values(){return this.#r.adapters()}catchupAndSubscribe(e){return this.#r.catchupAndSubscribe(e)}subscribeAnyChange(e){return this.#e.subscribe(e)}terminate(){this.#r.terminate(),this.#s.terminate(),this.#i.forEach(({subscription:e})=>e.terminate()),this.#i.clear()}};var Ve=class{type="bus";accepts="audio";#t;#e;constructor(e,t){this.#t=e,this.#e=t}catchupAndSubscribe(e){return e(this),this.#e.subscribe(Y.Children,()=>e(this))}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get box(){return this.#e}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get iconField(){return this.#e.icon}get labelField(){return this.#e.label}get colorField(){return this.#e.color}get iconSymbol(){return we.fromName(this.iconField.getValue()??"audio-bus")}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.output.targetVertex.unwrap("No AudioUnitBox found").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}toString(){return`{${this.constructor.name}}`}};var oo=class{#t;#e;#r;#i;#s=O.Empty;constructor(e,t){this.#t=new I,this.#e=this.#t.own(new q),this.#r=this.#t.own(new Ce(we.Unknown)),this.#i=this.#t.own(new Ce(p.None)),this.#t.own(this.#i.subscribe(r=>{this.#s.terminate(),this.#s=r.getValue().match({none:()=>(this.#e.notify(p.None),O.Empty),some:({labelField:s,iconField:o})=>O.many(o.catchupAndSubscribe(n=>this.#r.setValue(we.fromName(n.getValue()))),s.catchupAndSubscribe(n=>this.#e.notify(p.wrap(n.getValue()))))})})),this.#t.own(e.catchupAndSubscribeTransactual({onAdd:({box:r})=>{b(this.#i.getValue().isEmpty(),"Already set");let s=r instanceof kr?t.adapterFor(r,Ve):t.adapterFor(r,G.isInstrument);this.#i.getValue().unwrapOrNull()!==s&&this.#i.setValue(p.wrap(s))},onRemove:({box:r})=>{b(this.#i.getValue().unwrap("Cannot remove").box.address.equals(r.address),"Unexpected value to remove"),this.#i.setValue(p.None)}},u.InstrumentHost,u.AudioOutput))}getValue(){return this.#i.getValue()}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.#i),this.subscribe(e)}catchupAndSubscribeLabelChange(e){return e(this.label),this.#e.subscribe(e)}catchupAndSubscribeIconChange(e){return this.#r.catchupAndSubscribe(e)}set label(e){this.getValue().ifSome(t=>t.labelField.setValue(e))}get label(){return this.getValue().map(e=>e.labelField.getValue())}set icon(e){this.getValue().ifSome(t=>t.iconField.setValue(we.toName(e)))}get icon(){return this.getValue().match({none:()=>we.Unknown,some:e=>we.fromName(e.iconField.getValue())})}get iconValue(){return this.#r}terminate(){this.#t.terminate(),this.#s.terminate()}};var te=class{#t;#e;constructor(e){this.#t=e,this.#e=new Et(t=>t.address.fieldKeys,sa)}terminate(){this.#e.forEach(e=>e.terminate()),this.#e.clear()}parameters(){return this.#e.values()}parameterAt(e){return this.#e.getOrThrow(e,()=>new Error(`No ParameterAdapter found at [${e}]`))}createParameter(e,t,r,s,o){let n=new fr(this.#t,e,t,r,s,o),a=this.#e.add(n);return b(a,`Could not add adapter for ${e}`),n}removeParameter(e){this.#e.removeByValue(e)}};var $r=class{#t;#e;#r;#i;#s;#o;#n=O.Empty;constructor(e,t){this.#t=e,this.#e=t,this.#r=new I,this.#i=this.#r.own(new q),this.#r.own(t.targetBus.catchupAndSubscribe(()=>{this.#n.terminate(),this.#n=this.optTargetBus.match({none:()=>(this.#i.notify(p.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(p.wrap(s)))})})),this.#s=this.#r.own(new fr(this.#t,this.#e.sendPan,M.bipolar(),C.percent({unit:"%",fractionDigits:0}),"panning")),this.#o=this.#r.own(new fr(this.#t,this.#e.sendGain,M.DefaultDecibel,C.numeric({unit:"dB",fractionDigits:1}),"gain"))}catchupAndSubscribeBusChanges(e){return e(this.optTargetBus),this.#i.subscribe(e)}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get box(){return this.#e}get indexField(){return this.#e.index}get sendPan(){return this.#s}get sendGain(){return this.#o}get targetBus(){return this.#t.boxAdapters.adapterFor(this.#e.targetBus.targetVertex.unwrap("no audioUnit").box,Ve)}get optTargetBus(){return this.#e.targetBus.targetVertex.flatMap(e=>p.wrap(e.box.accept({visitAudioBusBox:t=>this.#t.boxAdapters.adapterFor(t,Ve)})))}delete(){this.#e.delete()}terminate(){this.#r.terminate(),this.#n.terminate()}};var no=class{#t;#e;#r;#i;#s=O.Empty;constructor(e,t){this.#t=e,this.#e=t,this.#r=new I,this.#i=this.#r.own(new q),this.#r.own(e.catchupAndSubscribe(()=>{this.#s.terminate(),this.#s=this.adapter.match({none:()=>(this.#i.notify(p.None),O.Empty),some:r=>r.catchupAndSubscribe(s=>this.#i.notify(p.wrap(s)))})}))}subscribe(e){return this.#i.subscribe(e)}catchupAndSubscribe(e){return e(this.adapter),this.subscribe(e)}get adapter(){return this.#t.targetVertex.flatMap(e=>p.wrap(e.box.accept({visitAudioBusBox:t=>this.#e.adapterFor(t,Ve)})))}terminate(){this.#r.terminate(),this.#s.terminate()}};var rt=class i{static VolumeMapper=M.decibel(-96,-9,6);class="device-host";#t=new I;#e;#r;#i;#s;#o;#n;#a;#l;#u;namedParameter;constructor(e,t){this.#e=e,this.#r=t,this.#i=this.#t.own(new te(this.#e)),this.#s=this.#t.own(new so(this,this.#e.boxAdapters)),this.#o=this.#t.own(new oo(this.#r.input.pointerHub,this.#e.boxAdapters)),this.#n=this.#t.own(Be.create(this.#r.midiEffects,r=>this.#e.boxAdapters.adapterFor(r,G.isMidiEffect),u.MidiEffectHost)),this.#a=this.#t.own(Be.create(this.#r.audioEffects,r=>this.#e.boxAdapters.adapterFor(r,G.isAudioEffect),u.AudioEffectHost)),this.#l=this.#t.own(Be.create(this.#r.auxSends,r=>this.#e.boxAdapters.adapterFor(r,$r),u.AuxSend)),this.#u=this.#t.own(new no(this.#r.output,this.#e.boxAdapters)),this.namedParameter=this.#c(t),this.#d()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get indexField(){return this.#r.index}get type(){return this.#r.type.getValue()}get captureBox(){return this.#r.capture.targetVertex}get tracks(){return this.#s}get input(){return this.#o}get midiEffects(){return this.#n}get audioEffects(){return this.#a}get inputAdapter(){return this.#o.getValue()}get auxSends(){return this.#l}get output(){return this.#u}get isBus(){return this.input.getValue().mapOr(e=>e.type==="bus",!1)}get isInstrument(){return this.input.getValue().mapOr(e=>e.type==="instrument",!1)}get isOutput(){return this.#r.output.targetVertex.mapOr(e=>e.box.address.equals(this.#e.rootBoxAdapter.address),!1)}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.#r.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.#r.tracks}get minimizedField(){return this.#o.getValue().unwrap().minimizedField}get isAudioUnit(){return!0}get label(){return this.#o.getValue().mapOr(e=>e.labelField.getValue(),"")}audioUnitBoxAdapter(){return this}indicesLimit(){let e=this.#e.rootBoxAdapter.audioUnits.adapters(),t=this.indexField.getValue(),r=this.type,s=t,o=t;for(;s>0&&e[s-1].type===r;)s--;for(;o<e.length-1&&e[o+1].type===r;)o++;return[s,o+1]}move(e){this.#e.rootBoxAdapter.audioUnits.move(this,e)}moveTrack(e,t){this.#s.collection.move(e,t)}deleteTrack(e){this.#s.delete(e)}toString(){return`{${this.constructor.name}}`}terminate(){this.#t.terminate()}#c(e){return{volume:this.#i.createParameter(e.volume,i.VolumeMapper,C.decible,"volume"),panning:this.#i.createParameter(e.panning,M.bipolar(),C.panning,"panning",.5),mute:this.#i.createParameter(e.mute,M.bool,C.bool,"mute"),solo:this.#i.createParameter(e.solo,M.bool,C.bool,"solo")}}#d(){let e=this.address.toString(),t=this.#r.capture.targetAddress.unwrapOrUndefined(),r=()=>`AudioUnit '${e}' must have a capture. AudioUnit is typed ${this.type} and has input ${this.#r.input.pointerHub.incoming().at(0)?.box.name}, but capture is ${t}`;b(this.type!==hr.Instrument||this.#r.capture.targetAddress.nonEmpty(),r)}};var ao=W.fromSignature(1,384);var fe=class{#t;#e;#r;#i;#s;#o;constructor(e,t){this.#t=e,this.#e=t,this.#r=new I,this.#i=this.#r.own(new to(this,e.boxAdapters)),this.#s=this.#r.own(new ro(this,e.boxAdapters)),this.#o=this.#r.own(new Ce(-1))}catchupAndSubscribePath(e){let t=[p.None,p.None],r=()=>{t.every(s=>s.nonEmpty())?e(p.wrap(t.map(s=>s.unwrap()))):e(p.None)};return O.many(this.#n(s=>{t[0].equals(s)||(t[0]=s,r())}),this.#a(s=>{t[1].equals(s)||(t[1]=s,r())}))}set targetDeviceName(e){this.#e.target.targetVertex.ifSome(t=>{let r=t.box;if(r instanceof Ye)return this.#t.boxAdapters.adapterFor(r,rt).input.getValue().ifSome(({labelField:o})=>o.setValue(e));if("label"in r&&r.label instanceof D)return r.label.setValue(e)})}get targetDeviceName(){return this.#e.target.targetVertex.flatMap(e=>{let t=e.box;return t instanceof Ye?this.#t.boxAdapters.adapterFor(t,rt).input.label:"label"in t&&t.label instanceof D?p.wrap(t.label.getValue()):p.wrap(t.name)})}#n(e){let t=this.#e.target.targetVertex;if(t.nonEmpty()){let r=t.unwrap().box;return r instanceof Ye?this.#t.boxAdapters.adapterFor(r,rt).input.catchupAndSubscribeLabelChange(o=>e(o)):"label"in r&&r.label instanceof D?r.label.catchupAndSubscribe(s=>e(p.wrap(s.getValue()))):(e(p.wrap(r.name)),O.Empty)}return e(p.None),O.Empty}#a(e){let t=this.type;switch(t){case X.Audio:case X.Notes:return e(p.wrap(X[t])),O.Empty;case X.Value:{let r=this.#e.target.targetVertex.unwrap();if(r.isField())e(this.#t.parameterFieldAdapters.opt(r.address).map(s=>s.name));else if(r.isBox())e(p.wrap(r.name));else return g("Illegal State. Vertex is not a field nor box.");return O.Empty}case X.Undefined:return e(p.wrap("")),O.Empty;default:return e(p.None),O.Empty}}terminate(){this.#r.terminate()}get audioUnit(){return er(this.#e.tracks.targetVertex.unwrap().box,Ye)}get target(){return this.#e.target}get clips(){return this.#i}get regions(){return this.#s}get enabled(){return this.#e.enabled}get indexField(){return this.#e.index}get type(){return this.#e.type.getValue()}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get listIndex(){return this.#o.getValue()}set listIndex(e){this.#o.setValue(e)}accepts(e){switch(e.type){case"audio-clip":return this.type===X.Audio;case"note-clip":return this.type===X.Notes;case"value-clip":return this.type===X.Value;case"audio-region":return this.type===X.Audio;case"note-region":return this.type===X.Notes;case"value-region":return this.type===X.Value}}valueAt(e,t){if(!this.enabled.getValue())return t;let r=t,s=this.#t.clipSequencing.iterate(this.uuid,e,e+ao);for(let{optClip:o,sectionFrom:n}of s)r=o.match({none:()=>{let a=this.regions.collection.lowerEqual(e,l=>!l.mute);if(a===null){let l=this.regions.collection.optAt(0);return ae(l,gt)?l.incomingValue(t):t}else if(ae(a,gt))return e<a.complete?a.valueAt(e,t):a.outgoingValue(t);return t},some:a=>n===e&&ae(a,kt)?a.valueAt(e,t):t});return r}};var _a=[u.Automation,u.Modulation,u.MidiControl,u.ParameterController],fr=class{#t;#e;#r;#i;#s;#o;#n=new I;#a;#l;#u=p.None;#c=p.None;#d=null;#h=!1;constructor(e,t,r,s,o,n){this.#t=e,this.#e=t,this.#r=r,this.#i=s,this.#s=o,this.#o=n??0,this.#n.own(this.#t.parameterFieldAdapters.register(this)),this.#a=this.#n.own(new q),this.#l=new ve,this.#n.own(this.#e.subscribe(()=>this.#a.notify(this))),this.#n.own(this.#e.pointerHub.catchupAndSubscribeTransactual({onAdd:a=>{this.#l.proxy.onControlSourceAdd(Un(a.pointerType)),a.box.accept({visitTrackBox:l=>{b(this.#u.isEmpty(),"Already assigned");let c=this.#t.boxAdapters.adapterFor(l,fe);this.#u=p.wrap(c),this.#t.isMainThread&&(this.#c=p.wrap(this.#t.liveStreamReceiver.subscribeFloat(this.#e.address,d=>{this.#d!==d&&(this.#d=d,this.#a.notify(this))})))}})},onRemove:a=>{this.#l.proxy.onControlSourceRemove(Un(a.pointerType)),a.box.accept({visitTrackBox:l=>{b(this.#u.unwrapOrNull()?.address?.equals(l.address)===!0,`Unknown ${l}`),this.#u=p.None,this.#t.isMainThread&&(this.#c.ifSome(c=>c.terminate()),this.#c=p.None,this.#d=null,this.#a.notify(this))}})}},..._a)),t.getValue()!==r.clamp(t.getValue())&&console.warn(`${o} (${t.getValue()}) is out of bounds`,r)}registerMidiControl(){return this.#l.proxy.onControlSourceAdd("midi"),this.#h=!0,{terminate:()=>{this.#h=!1,this.#l.proxy.onControlSourceRemove("midi")}}}get field(){return this.#e}get valueMapping(){return this.#r}get stringMapping(){return this.#i}get name(){return this.#s}get anchor(){return this.#o}get type(){return this.#e.type}get address(){return this.#e.address}get track(){return this.#u}valueAt(e){let t=this.#u;if(t.nonEmpty()){let r=t.unwrap();if(r.enabled)return this.valueMapping.y(r.valueAt(e,this.getUnitValue()))}return this.getValue()}subscribe(e){return this.#a.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}catchupAndSubscribeControlSources(e){return this.#h&&e.onControlSourceAdd("midi"),this.#e.pointerHub.filter(..._a).forEach(t=>e.onControlSourceAdd(Un(t.pointerType))),this.#l.subscribe(e)}getValue(){return this.#e.getValue()}setValue(e){this.#e.setValue(e)}setUnitValue(e){this.setValue(this.#r.y(e))}getUnitValue(){return this.#r.x(this.getValue())}getControlledValue(){return this.#r.y(this.getControlledUnitValue())}getControlledUnitValue(){return this.#d??this.getUnitValue()}getControlledPrintValue(){return this.#i.x(this.getControlledValue())}getPrintValue(){return this.#i.x(this.getValue())}setPrintValue(e){let t=this.#i.y(e);t.type==="unitValue"?this.setUnitValue($(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#r.clamp(this.#e.initValue))}terminate(){this.#c.ifSome(e=>e.terminate()),this.#c=p.None,this.#n.terminate()}},Un=i=>{switch(i){case u.Automation:return"automated";case u.Modulation:return"modulated";case u.MidiControl:return"midi";case u.ParameterController:return"external";default:return g(`${i.toString()} is an unknown pointer type`)}};var lo=class{#t;#e;#r;constructor(e,t,r){this.#t=A.newSet(s=>s.uuid),this.#e=new ve,this.#r=e.catchupAndSubscribeTransactual({onAdd:s=>{let o=t(s.box),n=this.#t.add(o);b(n,`Could not add ${o}`),this.#e.proxy.onAdd(o)},onRemove:s=>{let o=s.box.address.uuid;this.#e.proxy.onRemove(this.#t.removeByKey(o))}},r)}subscribe(e){return this.#e.subscribe(e)}catchupAndSubscribe(e){return this.#t.forEach(t=>e.onAdd(t)),this.subscribe(e)}adapters(){return this.#t.values()}size(){return this.#t.size()}isEmpty(){return this.size()===0}terminate(){this.#t.clear(),this.#e.terminate(),this.#r.terminate()}};var xt=class i{static OffsetFractions=je.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static OffsetStringMapping=C.indices("",this.OffsetFractions.map(([e,t])=>`${e}/${t}`));type="audio-effect";accepts="audio";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{delay:this.#r.createParameter(e.delay,M.linearInteger(0,i.OffsetFractions.length-1),i.OffsetStringMapping,"delay"),feedback:this.#r.createParameter(e.feedback,M.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"feedback"),cross:this.#r.createParameter(e.cross,M.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"cross"),filter:this.#r.createParameter(e.filter,M.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter",.5),dry:this.#r.createParameter(e.dry,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var qr=class{type="audio-effect";accepts="audio";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{decay:this.#r.createParameter(e.decay,M.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"Room-Size"),preDelay:this.#r.createParameter(e.preDelay,M.exponential(.001,.5),C.numeric({unit:"s",fractionDigits:1,unitPrefix:!0}),"Pre-Delay"),damp:this.#r.createParameter(e.damp,M.unipolar(),C.numeric({unit:"%",fractionDigits:0}),"damping"),filter:this.#r.createParameter(e.filter,M.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"filter"),dry:this.#r.createParameter(e.dry,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"dry"),wet:this.#r.createParameter(e.wet,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"wet")}}};var zr=class{type="audio-effect";accepts="audio";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}get spectrum(){return this.#e.address.append(4095)}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{highPass:Ha(this.#r,e.highPass,"High-Pass"),lowShelf:Ga(this.#r,e.lowShelf,"Low-Shelf"),lowBell:Kn(this.#r,e.lowBell,"Low-Bell"),midBell:Kn(this.#r,e.midBell,"Mid-Bell"),highBell:Kn(this.#r,e.highBell,"High-Bell"),highShelf:Ga(this.#r,e.highShelf,"High-Shelf"),lowPass:Ha(this.#r,e.lowPass,"Low-Pass")}}},Ln=M.exponential(20,2e4),Wa=M.linear(-24,24),ja=M.exponential(.01,10),Ha=(i,e,t)=>({enabled:i.createParameter(e.enabled,M.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Ln,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),order:i.createParameter(e.order,M.linearInteger(1,4),C.indices("db",["12","24","36","48"]),`${t} Order`),q:i.createParameter(e.q,ja,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)}),Ga=(i,e,t)=>({enabled:i.createParameter(e.enabled,M.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Ln,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Wa,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5)}),Kn=(i,e,t)=>({enabled:i.createParameter(e.enabled,M.bool,C.bool,"enabled"),frequency:i.createParameter(e.frequency,Ln,C.numeric({unit:"Hz",fractionDigits:0}),`${t} Freq`),gain:i.createParameter(e.gain,Wa,C.numeric({unit:"db",fractionDigits:1,bipolar:!0}),`${t} Gain`,.5),q:i.createParameter(e.q,ja,C.numeric({unit:"",fractionDigits:3}),`${t} Q`)});var gr=class{static Comparator=(e,t)=>e.position-t.position;type="marker-event";#t=new I;#e;#r;constructor(e,t){this.#e=e,this.#r=t,this.#t.own(this.#r.subscribe(Y.Children,r=>{if(!this.trackAdapter.isEmpty()&&(r.type==="primitive"||r.type==="pointer")){let s=this.trackAdapter.unwrap();this.#r.position.address.equals(r.address)?s.onSortingChanged():s.dispatchChange()}}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get position(){return this.#r.position.getValue()}get plays(){return this.#r.plays.getValue()}get hue(){return this.#r.hue.getValue()}get label(){return this.#r.label.getValue()}get trackAdapter(){return this.#r.track.targetVertex.map(e=>this.#e.boxAdapters.adapterFor(e.box,it).markerTrack)}terminate(){this.#t.terminate()}toString(){return`{MarkerBoxAdapter ${A.toString(this.#r.address.uuid).substring(0,4)}, plays: ${this.plays}`}};var uo=class{#t;#e;changeNotifier;#r;#i;#s;constructor(e,t){this.#t=e,this.#e=t,this.changeNotifier=new q,this.#r=A.newSet(r=>r.uuid),this.#i=Nt.create(gr.Comparator),this.#s=this.#e.markers.pointerHub.catchupAndSubscribeTransactual({onAdd:({box:r})=>{if(r instanceof Or){let s=this.#t.boxAdapters.adapterFor(r,gr),o=this.#r.add(s);b(o,"Could not add adapter"),this.#i.add(s),this.dispatchChange()}},onRemove:({box:{address:{uuid:r}}})=>{this.#i.remove(this.#r.removeByKey(r)),this.dispatchChange()}})}subscribe(e){return this.changeNotifier.subscribe(e)}get context(){return this.#t}get enabled(){return this.#e.enabled.getValue()}get events(){return this.#i}get object(){return this.#e}dispatchChange(){this.changeNotifier.notify()}onSortingChanged(){this.#i.onIndexingChanged(),this.dispatchChange()}terminate(){this.#s.terminate()}};var it=class{#t;#e;constructor(e,t){this.#t=t,this.#e=new uo(e,this.#t.markerTrack)}terminate(){}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get markerTrack(){return this.#e}};var $t=class{#t;constructor(e,t){this.#t=t}get box(){return this.#t}get uuid(){return this.#t.address.uuid}get address(){return this.#t.address}get source(){return this.#t.source.targetVertex.unwrap("Insufficient Vertex")}get target(){return this.#t.target.targetVertex.unwrap("Insufficient Vertex")}terminate(){}};var qe=class{#t;#e;#r;#i;#s;#o=!1;constructor(e,t){this.#t=e,this.#e=t,this.#r=new I,this.#i=t.attributes,this.#s=this.#r.own(new te(e))}get inputs(){throw new Error("Method not implemented.")}get outputs(){throw new Error("Method not implemented.")}own(e){return this.#r.own(e)}ownAll(...e){this.#r.ownAll(...e)}onSelected(){this.#o=!0}onDeselected(){this.#o=!1}isSelected(){return this.#o}get box(){return this.#e}get attributes(){return this.#i}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get parameters(){return this.#s}get modular(){return this.#t.boxAdapters.adapterFor(this.#e.attributes.collection.targetVertex.unwrap().box,qt)}terminate(){this.#r.terminate()}};var Ne;(function(i){i.Input="input",i.Output="output"})(Ne||(Ne={}));var Pe=class i{static create(e,t,r,s){return new i(e,t,r,s??t.fieldName)}#t;#e;#r;#i;constructor(e,t,r,s){this.#t=e,this.#e=t,this.#r=r,this.#i=s}matches(e){return this.direction!==e.direction&&this.field.pointerRules.accepts.some(t=>e.field.pointerRules.accepts.some(r=>r===t))}get connections(){return this.#e.pointerHub.isEmpty()?w.empty():this.#e.pointerHub.filter(u.VoltageConnection).map(({box:e})=>this.#t.adapterFor(e,$t))}get field(){return this.#e}get address(){return this.#e.address}get direction(){return this.#r}get name(){return this.#i}toString(){return`{ModuleConnectorAdapter address: ${this.#e.address.toString()}, direction: ${this.#r}}`}};var _r=class extends qe{#t;#e;#r;constructor(e,t){super(e,t),this.#t=this.parameters.createParameter(t.time,M.exponential(1,1e4),C.numeric({unit:"ms"}),"Time"),this.#e=Pe.create(e.boxAdapters,t.voltageInput,Ne.Input,"Input"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Output")}get parameterTime(){return this.#t}get voltageInput(){return this.#e}get voltageOutput(){return this.#r}get inputs(){return[this.#e]}get outputs(){return[this.#r]}};var Hr=class extends qe{#t;constructor(e,t){super(e,t),this.#t=Pe.create(e.boxAdapters,t.input,Ne.Input,"Input")}get voltageInput(){return this.#t}get inputs(){return[this.#t]}get outputs(){return w.empty()}};var Gr=class extends qe{#t;#e;#r;constructor(e,t){super(e,t),this.#t=this.parameters.createParameter(t.gain,M.DefaultDecibel,C.numeric({unit:"db"}),"Gain"),this.#e=Pe.create(e.boxAdapters,t.voltageInput,Ne.Input,"Input"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Output")}get parameterGain(){return this.#t}get voltageInput(){return this.#e}get voltageOutput(){return this.#r}get inputs(){return[this.#e]}get outputs(){return[this.#r]}};var Wr=class extends qe{#t;#e;#r;constructor(e,t){super(e,t),this.#t=Pe.create(e.boxAdapters,t.voltageInputX,Ne.Input,"X"),this.#e=Pe.create(e.boxAdapters,t.voltageInputY,Ne.Input,"Y"),this.#r=Pe.create(e.boxAdapters,t.voltageOutput,Ne.Output,"Result")}get inputs(){return[this.#t,this.#e]}get outputs(){return[this.#r]}};var jr=class extends qe{#t;constructor(e,t){super(e,t),this.#t=Pe.create(e.boxAdapters,t.output,Ne.Output,"Output")}get voltageOutput(){return this.#t}get inputs(){return w.empty()}get outputs(){return[this.#t]}};var Qr;(function(i){i.isVertexOfModule=e=>e.box.accept({visitModuleGainBox:()=>!0,visitModuleDelayBox:()=>!0,visitModuleMultiplierBox:()=>!0,visitModularAudioInputBox:()=>!0,visitModularAudioOutputBox:()=>!0})??!1,i.adapterFor=(e,t)=>K(t.accept({visitModuleGainBox:r=>e.adapterFor(r,Gr),visitModuleDelayBox:r=>e.adapterFor(r,_r),visitModuleMultiplierBox:r=>e.adapterFor(r,Wr),visitModularAudioInputBox:r=>e.adapterFor(r,jr),visitModularAudioOutputBox:r=>e.adapterFor(r,Hr)}),`Could not find ModuleAdapter for ${t.name}`)})(Qr||(Qr={}));var Yr=class{#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get moduleAdapter(){return Qr.adapterFor(this.#t.boxAdapters,this.#r.box)}get parameterAdapter(){return this.moduleAdapter.parameters.parameterAt(this.#r.address.fieldKeys)}get#r(){return this.#e.parameter.targetVertex.unwrap("Parameter not assigned")}terminate(){}};var zt=class{type="audio-effect";accepts="audio";#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}parameterAt(e){return g("Not yet implemented")}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}modular(){return this.#t.boxAdapters.adapterFor(this.#e.modularSetup.targetVertex.unwrap("No Modular found").box,qt)}elements(){return this.#e.userInterface.elements.pointerHub.filter(u.DeviceUserInterface).map(e=>this.#t.boxAdapters.adapterFor(e.box,Yr))}terminate(){}};var qt=class{#t=new I;#e;#r;#i;#s;#o;constructor(e,t){this.#r=e,this.#i=t,this.#e=this.#t.own(new ve),this.#s=A.newSet(a=>a.uuid),this.#o=A.newSet(a=>a.uuid);let r=a=>{let l=Qr.adapterFor(this.#r.boxAdapters,a.box);this.#s.add(l)&&this.#e.proxy.onModuleAdded(l)},s=a=>this.#e.proxy.onModuleRemoved(this.#s.removeByKey(a.address.uuid)),o=a=>{let l=this.#r.boxAdapters.adapterFor(a.box,$t);this.#o.add(l)&&this.#e.proxy.onConnectionAdded(l)},n=a=>this.#e.proxy.onConnectionRemoved(this.#o.removeByKey(a.address.uuid));this.#i.modules.pointerHub.filter(u.ModuleCollection).forEach(r),this.#i.connections.pointerHub.filter(u.ConnectionCollection).forEach(o),this.#t.own(this.#i.modules.pointerHub.subscribeTransactual({onAdd:r,onRemove:s},u.ModuleCollection)),this.#t.own(this.#i.connections.pointerHub.subscribeTransactual({onAdd:o,onRemove:n},u.ConnectionCollection))}catchupAndSubscribe(e){return xn(e.onModuleAdded,t=>this.#s.forEach(r=>t(r))),xn(e.onConnectionAdded,t=>this.#o.forEach(r=>t(r))),this.#e.subscribe(e)}get box(){return this.#i}get address(){return this.#i.address}get uuid(){return this.#i.address.uuid}get editingField(){return this.#i.editing}get labelField(){return this.#i.label}get modules(){return this.#s.values()}get connections(){return this.#o.values()}get device(){return this.#r.boxAdapters.adapterFor(K(this.#i.device.pointerHub.incoming().at(0),"No device found").box,zt)}terminate(){console.debug(`terminate ${this}`),this.#t.terminate()}};var Xr=class i{static Durations=[[1,8],[1,4],[1,4],[1,2],[1,1],[2,1],[4,1],[8,1],[16,1]];static DurationPPQNs=i.Durations.map(([e,t])=>W.fromSignature(e,t));static DurationStrings=i.Durations.map(([e,t])=>`${e}/${t}`);type="groove-adapter";#t=new I;#e;#r;#i;namedParameter;#s=new es({duration:()=>this.#n,fx:e=>En(e,this.#o),fy:e=>En(e,1-this.#o)});#o=0;#n=W.SemiQuaver*2;constructor(e,t){this.#e=e,this.#r=t,this.#i=this.#t.own(new te(this.#e)),this.namedParameter=this.#a(t),this.#t.ownAll(this.namedParameter.duration.catchupAndSubscribe(r=>this.#n=r.getValue()),this.namedParameter.amount.catchupAndSubscribe(r=>this.#o=oa(r.getValue(),.01)))}unwarp(e){return this.#s.unwarp(e)}warp(e){return this.#s.warp(e)}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#t.terminate()}#a(e){return{duration:this.#i.createParameter(e.duration,M.values(i.DurationPPQNs),C.values("",i.DurationPPQNs,i.DurationStrings),"duration"),amount:this.#i.createParameter(e.amount,M.unipolar(),C.percent({fractionDigits:0}),"amount")}}};var _t=class{#t;#e;#r;#i;#s;#o=new I;#n;#a=p.None;constructor(e,t,r,s,o){this.#t=e,this.#e=t,this.#r=r,this.#i=s,this.#s=o??0,this.#n=this.#o.own(new q),this.#o.own(this.#t.subscribe(()=>this.#n.notify(this))),e.getValue()!==t.clamp(e.getValue())&&console.warn(`${s} (${e.getValue()}) is out of bounds`,t)}get field(){return this.#t}get valueMapping(){return this.#e}get stringMapping(){return this.#r}get name(){return this.#i}get anchor(){return this.#s}get type(){return this.#t.type}get address(){return this.#t.address}get track(){return this.#a}subscribe(e){return this.#n.subscribe(e)}catchupAndSubscribe(e){return e(this),this.subscribe(e)}getValue(){return this.#t.getValue()}setValue(e){this.#t.setValue(this.#e.clamp(e))}setUnitValue(e){this.setValue(this.#e.y(e))}getUnitValue(){return this.#e.x(this.getValue())}getPrintValue(){return this.#r.x(this.getValue())}setPrintValue(e){let t=this.#r.y(e);t.type==="unitValue"?this.setUnitValue($(t.value,0,1)):t.type==="explicit"?this.setValue(this.valueMapping.clamp(t.value)):console.debug(`Unknown text input: '${t.value}'`)}reset(){this.setValue(this.#e.clamp(this.#t.initValue))}terminate(){this.#o.terminate()}};var co=class{#t;#e;#r;#i;#s;#o;constructor(e){this.#t=e,this.#e=new _t(this.#t.keyboard,M.values([88,76,61,49]),C.numeric({fractionDigits:1}),"Keyboard Type"),this.#r=new _t(this.#t.timeRangeInQuarters,M.exponential(1,64),C.numeric({fractionDigits:1}),"Time-Range"),this.#i=new _t(this.#t.noteScale,M.exponential(.5,2),C.numeric({fractionDigits:1}),"Note Scale"),this.#s=new _t(this.#t.noteLabels,M.bool,C.bool,"Note Labels"),this.#o=new _t(this.#t.transpose,M.linearInteger(-48,48),C.numeric({fractionDigits:0}),"Transpose")}subscribe(e){return this.#t.box.subscribe(Y.Children,()=>e(this))}get object(){return this.#t}get keyboard(){return this.#e}get timeRangeInQuarters(){return this.#r}get noteScale(){return this.#i}get noteLabels(){return this.#s}get transpose(){return this.#o}};var Zr=class{#t;#e;#r;#i;#s;constructor(e,t){this.#t=e,this.#e=t,this.#r=Be.create(this.#e.audioUnits,r=>this.#t.boxAdapters.adapterFor(r,rt),u.AudioUnits),this.#i=new lo(this.#e.audioBusses.pointerHub,r=>this.#t.boxAdapters.adapterFor(r,Ve),u.AudioBusses),this.#s=new co(this.#e.pianoMode)}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get box(){return this.#e}get audioBusses(){return this.#i}get audioUnits(){return this.#r}get clips(){return this.#r.adapters().flatMap(e=>e.tracks.collection.adapters()).flatMap(e=>e.clips.collection.adapters())}get groove(){return this.#t.boxAdapters.adapterFor(this.#e.groove.targetVertex.unwrap("no groove").box,Xr)}get timeline(){return this.#t.boxAdapters.adapterFor(this.#e.timeline.targetVertex.unwrap("no timeline").box,it)}get pianoMode(){return this.#s}get created(){return new Date(this.#e.created.getValue())}terminate(){this.#r.terminate()}};var Jr=class{type="instrument";accepts="audio";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get labelField(){return this.#e.label}get iconField(){return this.#e.icon}get defaultTrackType(){return X.Audio}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get acceptsMidiEvents(){return!1}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{flutter:this.#r.createParameter(e.flutter,M.unipolar(),C.percent(),"flutter"),wow:this.#r.createParameter(e.wow,M.unipolar(),C.percent(),"wow"),noise:this.#r.createParameter(e.noise,M.unipolar(),C.percent(),"noise"),saturation:this.#r.createParameter(e.saturation,M.unipolar(),C.percent(),"saturation")}}};var ei=class{type="instrument";accepts="midi";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get labelField(){return this.#e.label}get iconField(){return this.#e.icon}get defaultTrackType(){return X.Notes}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),octave:this.#r.createParameter(e.octave,M.linearInteger(-3,3),C.numeric(),"octave",.5),tune:this.#r.createParameter(e.tune,M.linear(-1200,1200),C.numeric({unit:"cent",fractionDigits:0}),"tune",.5),waveform:this.#r.createParameter(e.waveform,M.linearInteger(0,3),C.indices("",["sine","triangle","sawtooth","square"]),"waveform"),cutoff:this.#r.createParameter(e.cutoff,M.exponential(20,18e3),C.numeric({unit:"Hz"}),"cutoff"),resonance:this.#r.createParameter(e.resonance,M.exponential(.1,20),C.numeric({unit:"q",fractionDigits:1}),"resonance"),attack:this.#r.createParameter(e.attack,M.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"attack"),release:this.#r.createParameter(e.release,M.exponential(.001,1),C.numeric({unit:"s",fractionDigits:3}),"release"),filterEnvelope:this.#r.createParameter(e.filterEnvelope,M.linear(-.5,.5),C.percent(),"filter env",.5)}}};var Ht=class i{static RateFractions=je.builder().add([1,1]).add([1,2]).add([1,3]).add([1,4]).add([3,16]).add([1,6]).add([1,8]).add([3,32]).add([1,12]).add([1,16]).add([3,64]).add([1,24]).add([1,32]).add([1,48]).add([1,64]).add([1,96]).add([1,128]).asDescendingArray();static RateStringMapping=C.indices("",this.RateFractions.map(([e,t])=>`${e}/${t}`));type="midi-effect";accepts="midi";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}parameterAt(e){return this.#r.parameterAt(e)}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{modeIndex:this.#r.createParameter(e.modeIndex,M.linearInteger(0,2),C.indices("",["Up","Down","UpDown"]),"mode"),numOctaves:this.#r.createParameter(e.numOctaves,M.linearInteger(1,5),C.numeric({unit:"",fractionDigits:0}),"Octaves"),rate:this.#r.createParameter(e.rateIndex,M.linearInteger(0,i.RateFractions.length-1),i.RateStringMapping,"Rate"),gate:this.#r.createParameter(e.gate,M.linear(0,2),C.percent({fractionDigits:0}),"Gate"),repeat:this.#r.createParameter(e.repeat,M.linearInteger(1,16),C.numeric({fractionDigits:0}),"Repeat"),velocity:this.#r.createParameter(e.velocity,M.bipolar(),C.percent({fractionDigits:0,bipolar:!1}),"Velocity")}}};var ti=class{type="midi-effect";accepts="midi";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{octaves:this.#r.createParameter(e.octaves,M.linearInteger(-7,7),C.numeric({unit:"oct",fractionDigits:0}),"octaves"),semiTones:this.#r.createParameter(e.semiTones,M.linearInteger(-36,36),C.numeric({unit:"st",fractionDigits:0}),"semi-tones"),cent:this.#r.createParameter(e.cents,M.linear(-50,50),C.numeric({unit:"cents",fractionDigits:1}),"cents")}}};var ri=class{type="instrument";accepts="midi";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get labelField(){return this.#e.label}get iconField(){return this.#e.icon}get defaultTrackType(){return X.Notes}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#r.parameterAt(e)}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,M.DefaultDecibel,C.numeric({unit:"db",fractionDigits:1}),"volume"),release:this.#r.createParameter(e.release,M.exponential(.001,8),C.numeric({unit:"s",fractionDigits:3}),"release")}}};var ii=class{class="device-host";accepts=!1;type="instrument";#t=new I;#e;#r;#i;#s;#o;namedParameter;#n=p.None;constructor(e,t){this.#e=e,this.#r=t,this.#i=this.#t.own(Be.create(this.#r.midiEffects,r=>this.#e.boxAdapters.adapterFor(r,G.isMidiEffect),u.MidiEffectHost)),this.#s=this.#t.own(Be.create(this.#r.audioEffects,r=>this.#e.boxAdapters.adapterFor(r,G.isAudioEffect),u.AudioEffectHost)),this.#o=this.#t.own(new te(this.#e)),this.namedParameter=this.#a(t),this.#t.own(this.#r.file.catchupAndSubscribe(r=>{this.#n=r.targetVertex.map(({box:s})=>this.#e.boxAdapters.adapterFor(s,tt)),this.#n.unwrapOrNull()?.getOrCreateLoader()}))}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get peakAddress(){return this.#r.address.append(1001)}get indexField(){return this.#r.index}get gate(){return this.#r.gate.getValue()}get exclude(){return this.#r.exclude.getValue()}get label(){return`${this.device().labelField.getValue()} > ${this.#n.mapOr(e=>e.box.fileName.getValue(),"No file")}`}get iconField(){return this.#r.icon}get defaultTrackType(){return X.Notes}get acceptsMidiEvents(){return!0}get midiEffectsField(){return this.#r.midiEffects}get inputField(){return this.audioUnitBoxAdapter().box.input}get audioEffectsField(){return this.#r.audioEffects}get tracksField(){return this.audioUnitBoxAdapter().box.tracks}get isAudioUnit(){return!1}file(){return this.#n}fileUUID(){return this.#r.file.targetAddress.unwrap().uuid}resetParameters(){this.#r.mute.reset(),this.#r.solo.reset(),this.#r.exclude.reset(),this.#r.polyphone.reset(),this.#r.pitch.reset(),this.#r.attack.reset(),this.#r.release.reset(),this.#r.sampleStart.reset(),this.#r.sampleEnd.reset(),this.#r.gate.reset()}copyToIndex(e){Ur.create(this.#r.graph,A.generate(),t=>{t.file.refer(this.#r.file.targetVertex.unwrap()),t.device.refer(this.#r.device.targetVertex.unwrap()),t.index.setValue(e),t.mute.setValue(this.#r.mute.getValue()),t.solo.setValue(this.#r.solo.getValue()),t.sampleStart.setValue(this.#r.sampleStart.getValue()),t.sampleEnd.setValue(this.#r.sampleEnd.getValue()),t.attack.setValue(this.#r.attack.getValue()),t.release.setValue(this.#r.release.getValue()),t.pitch.setValue(this.#r.pitch.getValue()),t.exclude.setValue(this.#r.exclude.getValue()),t.gate.setValue(this.#r.gate.getValue())})}get midiEffects(){return this.#i}get inputAdapter(){return p.wrap(this)}get audioEffects(){return this.#s}get labelField(){return this.#r.label}get enabledField(){return this.#r.enabled}get minimizedField(){return this.#r.minimized}device(){return this.#e.boxAdapters.adapterFor(this.#r.device.targetVertex.unwrap().box,Gt)}deviceHost(){return this.device().deviceHost()}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#t.terminate()}#a(e){return{gate:this.#o.createParameter(e.gate,M.linearInteger(0,2),C.indices("",["Off","On","Loop"]),"Gate"),mute:this.#o.createParameter(e.mute,M.bool,C.bool,"Mute"),solo:this.#o.createParameter(e.solo,M.bool,C.bool,"Solo"),polyphone:this.#o.createParameter(e.polyphone,M.bool,C.bool,"Polyphone"),exclude:this.#o.createParameter(e.exclude,M.bool,C.bool,"Exclude"),pitch:this.#o.createParameter(e.pitch,M.linear(-1200,1200),C.numeric({unit:"cents",bipolar:!0,fractionDigits:0}),"Pitch",0),sampleStart:this.#o.createParameter(e.sampleStart,M.unipolar(),C.percent(),"Start",0),sampleEnd:this.#o.createParameter(e.sampleEnd,M.unipolar(),C.percent(),"End",1),attack:this.#o.createParameter(e.attack,M.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Attack"),release:this.#o.createParameter(e.release,M.exponential(.001,5),C.numeric({unit:"s",unitPrefix:!0,fractionDigits:1}),"Release")}}};var Gt=class{type="instrument";accepts="midi";#t;#e;#r;#i;constructor(e,t){this.#t=e,this.#e=t,this.#r=Be.create(t.samples,r=>e.boxAdapters.adapterFor(r,ii),u.Sample),this.#i=new te(this.#t)}reset(){this.#r.adapters().forEach(e=>e.box.delete())}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get notesAddress(){return this.#e.address.append(1e3)}get labelField(){return this.#e.label}get iconField(){return this.#e.icon}get defaultTrackType(){return X.Notes}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get acceptsMidiEvents(){return!0}get samples(){return this.#r}get context(){return this.#t}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#i.terminate()}};var si=class{type="audio-effect";accepts="audio";#t;#e;#r;namedParameter;constructor(e,t){this.#t=e,this.#e=t,this.#r=new te(this.#t),this.namedParameter=this.#i(t)}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){this.#r.terminate()}#i(e){return{volume:this.#r.createParameter(e.volume,M.decibel(-72,0,12),C.numeric({unit:"db",fractionDigits:1}),"Volume"),panning:this.#r.createParameter(e.panning,M.bipolar(),C.panning,"Panning",.5),stereo:this.#r.createParameter(e.stereo,M.bipolar(),C.numeric({unit:"%",fractionDigits:0}),"stereo",.5),invertL:this.#r.createParameter(e.invertL,M.bool,C.bool,"Invert Left"),invertR:this.#r.createParameter(e.invertR,M.bool,C.bool,"Invert Right"),swap:this.#r.createParameter(e.swap,M.bool,C.bool,"Swap")}}};var xr;(function(i){i.checkType=e=>e!==null&&typeof e=="object"&&"type"in e&&e.type==="groove-adapter"})(xr||(xr={}));var oi=class{type="midi-effect";accepts="midi";#t;#e;constructor(e,t){this.#t=e,this.#e=t,this.groove()}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}groove(){return this.#t.boxAdapters.adapterFor(this.#e.groove.targetVertex.unwrap("no groove").box,xr.checkType)}catchupAndSubscribeGroove(e){return this.#e.groove.catchupAndSubscribe(t=>e(this.#t.boxAdapters.adapterFor(t.targetVertex.unwrap("No groove found").box,xr.checkType)))}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var ni=class{type="audio-effect";accepts="audio";#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}get commentField(){return this.#e.comment}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var ai=class{type="midi-effect";accepts="midi";#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get indexField(){return this.#e.index}get labelField(){return this.#e.label}get enabledField(){return this.#e.enabled}get minimizedField(){return this.#e.minimized}get host(){return this.#e.host}get commentField(){return this.#e.comment}deviceHost(){return this.#t.boxAdapters.adapterFor(this.#e.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}terminate(){}};var li=class{type="instrument";accepts="midi";#t=new I;#e;#r;#i;namedParameter;#s;#o;#n;constructor(e,t){this.#e=e,this.#r=t,this.#i=new te(this.#e),this.namedParameter=this.#a(t),this.#s=new Er,this.#o=new Er,this.#n=new Er,this.#t.ownAll(this.#s.subscribe(this.#l),this.#r.file.catchupAndSubscribe(({targetVertex:r})=>this.#s.wrapOption(r.map(({box:s})=>e.soundfontManager.getOrCreate(s.address.uuid)))),this.#r.presetIndex.catchupAndSubscribe(r=>this.#o.match({none:()=>this.#n.clear(),some:s=>this.#n.wrap(s.presets[r.getValue()]??s.presets[0])})))}get loader(){return this.#s}get soundfont(){return this.#o}get preset(){return this.#n}get presetIndex(){return this.#r.presetIndex.getValue()}get box(){return this.#r}get uuid(){return this.#r.address.uuid}get address(){return this.#r.address}get labelField(){return this.#r.label}get iconField(){return this.#r.icon}get defaultTrackType(){return X.Notes}get enabledField(){return this.#r.enabled}get minimizedField(){return this.#r.minimized}get acceptsMidiEvents(){return!0}deviceHost(){return this.#e.boxAdapters.adapterFor(this.#r.host.targetVertex.unwrap("no device-host").box,G.isHost)}audioUnitBoxAdapter(){return this.deviceHost().audioUnitBoxAdapter()}parameterAt(e){return this.#i.parameterAt(e)}terminate(){this.#i.terminate()}#a(e){return{}}#l=e=>e.match({none:()=>{this.#n.clear(),this.#o.clear()},some:t=>t.soundfont.match({none:()=>{this.#n.clear(),this.#o.clear();let r=t.subscribe(s=>{if(s.type==="loaded"){r.terminate();let o=t.soundfont.unwrap();this.#n.wrap(o.presets[this.presetIndex]??o.presets[0]),this.#o.wrap(o)}else s.type==="error"?(r.terminate(),this.#n.clear(),this.#o.clear()):s.type==="idle"&&(r.terminate(),this.#n.clear(),this.#o.clear())})},some:r=>this.#o.wrap(r)})})};var ho=class{#t;#e;constructor(e,t){this.#t=e,this.#e=t}get box(){return this.#e}get uuid(){return this.#e.address.uuid}get address(){return this.#e.address}get soundfont(){return this.getOrCreateLoader().soundfont}getOrCreateLoader(){return this.#t.soundfontManager.getOrCreate(this.#e.address.uuid)}terminate(){}};var po=class{#t;#e;#r;#i;constructor(e){this.#t=e,this.#e=A.newSet(t=>t.uuid),this.#r=new Set,this.#i=this.#t.boxGraph.subscribeToAllUpdates({onUpdate:t=>{if(t.type==="delete"){let r=this.#e.getOrNull(t.uuid);V(r)&&(this.#r.add(r.box),this.#e.removeByValue(r).terminate())}}})}terminate(){this.#e.values().forEach(e=>e.terminate()),this.#e.clear(),this.#i.terminate()}adapterFor(e,t){if(this.#r.has(e))return g(`Cannot resolve adapter for already deleted box: ${e}`);let r=this.#e.getOrNull(e.address.uuid);if(r===null){r=this.#s(e);let s=this.#e.add(r);b(s,`Could not add adapter for ${e}`)}return typeof t=="function"?Object.hasOwn(t,"prototype")?r instanceof t?r:g(`${r} is not instance of ${t}`):t(r)?r:g(`${r} did not pass custom type guard`):g("Unknown checkType method")}#s(e){return K(e.accept({visitRootBox:t=>new Zr(this.#t,t),visitArpeggioDeviceBox:t=>new Ht(this.#t,t),visitPitchDeviceBox:t=>new ti(this.#t,t),visitStereoToolDeviceBox:t=>new si(this.#t,t),visitDelayDeviceBox:t=>new xt(this.#t,t),visitReverbDeviceBox:t=>new qr(this.#t,t),visitRevampDeviceBox:t=>new zr(this.#t,t),visitUnknownAudioEffectDeviceBox:t=>new ni(this.#t,t),visitPlayfieldDeviceBox:t=>new Gt(this.#t,t),visitPlayfieldSampleBox:t=>new ii(this.#t,t),visitModularDeviceBox:t=>new zt(this.#t,t),visitTapeDeviceBox:t=>new Jr(this.#t,t),visitNanoDeviceBox:t=>new ri(this.#t,t),visitVaporisateurDeviceBox:t=>new ei(this.#t,t),visitSoundfontDeviceBox:t=>new li(this.#t,t),visitModularBox:t=>new qt(this.#t,t),visitModuleConnectionBox:t=>new $t(this.#t,t),visitModuleDelayBox:t=>new _r(this.#t,t),visitModuleGainBox:t=>new Gr(this.#t,t),visitModuleMultiplierBox:t=>new Wr(this.#t,t),visitModularAudioInputBox:t=>new jr(this.#t,t),visitModularAudioOutputBox:t=>new Hr(this.#t,t),visitDeviceInterfaceKnobBox:t=>new Yr(this.#t,t),visitAudioUnitBox:t=>new rt(this.#t,t),visitAudioBusBox:t=>new Ve(this.#t,t),visitAuxSendBox:t=>new $r(this.#t,t),visitSoundfontFileBox:t=>new ho(this.#t,t),visitAudioFileBox:t=>new tt(this.#t,t),visitAudioClipBox:t=>new Ut(this.#t,t),visitAudioRegionBox:t=>new Kt(this.#t,t),visitNoteEventBox:t=>new mr(this.#t,t),visitNoteEventCollectionBox:t=>new $e(this.#t,t),visitNoteClipBox:t=>new Lr(this.#t,t),visitNoteRegionBox:t=>new Lt(this.#t,t),visitValueEventBox:t=>new Ot(this.#t,t),visitValueEventCollectionBox:t=>new Le(this.#t,t),visitValueClipBox:t=>new kt(this.#t,t),visitValueRegionBox:t=>new gt(this.#t,t),visitTrackBox:t=>new fe(this.#t,t),visitTimelineBox:t=>new it(this.#t,t),visitMarkerBox:t=>new gr(this.#t,t),visitZeitgeistDeviceBox:t=>new oi(this.#t,t),visitUnknownMidiEffectDeviceBox:t=>new ai(this.#t,t),visitGrooveShuffleBox:t=>new Xr(this.#t,t)}),`Could not find factory for ${e}`)}};var Qa;(function(i){i.countStems=e=>e.match({none:()=>1,some:t=>Object.keys(t).length}),i.sanitizeFileName=e=>e.replace(/[<>:"/\\|?*\x00-\x1F]/g,"_").trim(),i.sanitizeExportNamesInPlace=e=>{let t=new Map,r=s=>{let o=t.get(s)??0,n=s;for(;t.has(n);)o++,n=`${s} ${o}`;return t.set(s,o),t.set(n,1),n};Object.keys(e).forEach(s=>{let o=e[s];o.fileName=r(i.sanitizeFileName(o.fileName))})}})(Qa||(Qa={}));var Ya=Re.createBuilder({position:Re.float,playbackTimestamp:Re.float,countInBeatsRemaining:Re.float,countInBeatsTotal:Re.float,isPlaying:Re.bool,isCountingIn:Re.bool,isRecording:Re.bool});var st=class{#t=new I;#e;#r;#i;constructor(e,t){this.#e=e,this.#r=t,this.#i=new ye(128),this.#t.own(this.#e.broadcastIntegers(this.#r,new Int32Array(this.#i.buffer),at))}noteOn(e){e>=0&&e<128&&this.#i.setBit(e,!0)}noteOff(e){e>=0&&e<128&&this.#i.setBit(e,!1)}reset(){}clear(){this.#i.clear()}terminate(){this.#t.terminate()}toString(){return`{${this.constructor.name}}`}};var yt;(function(i){i[i.MTHD=1297377380]="MTHD",i[i.MTRK=1297379947]="MTRK"})(yt||(yt={}));var Fe;(function(i){i[i.NOTE_ON=144]="NOTE_ON",i[i.NOTE_OFF=128]="NOTE_OFF",i[i.NOTE_AFTER_TOUCH=160]="NOTE_AFTER_TOUCH",i[i.CONTROLLER=176]="CONTROLLER",i[i.PROGRAM_CHANGE=192]="PROGRAM_CHANGE",i[i.CHANNEL_AFTER_TOUCH=208]="CHANNEL_AFTER_TOUCH",i[i.PITCH_BEND=224]="PITCH_BEND"})(Fe||(Fe={}));var mo=class i{ticks;type;param0;param1;static Comparator=(e,t)=>e.ticks-t.ticks;constructor(e,t,r,s){this.ticks=e,this.type=t,this.param0=r,this.param1=s}static decode(e,t,r){switch(t){case Fe.NOTE_ON:case Fe.NOTE_OFF:case Fe.CONTROLLER:case Fe.PITCH_BEND:case Fe.NOTE_AFTER_TOUCH:return new i(r,t,e.readByte(),e.readByte());case Fe.PROGRAM_CHANGE:case Fe.CHANNEL_AFTER_TOUCH:return new i(r,t,e.readByte(),0)}{let s;do s=e.readByte()&255;while(s<128);e.skip(-1)}return null}accept(e){switch(this.type){case Fe.NOTE_ON:{this.param1===0?x(e.noteOff,this.param0):x(e.noteOn,this.param0,this.param1/127);break}case Fe.NOTE_OFF:{x(e.noteOff,this.param0);break}case Fe.PITCH_BEND:{let t=this.param0&127,r=this.param1&127,s=t|r<<7;x(e.pitchBend,8192>=s?s/8192-1:(s-8191)/8192);break}case Fe.CONTROLLER:{x(e.controller,this.param0,this.param1/127);break}default:break}}toString(){return`ControlEvent{ticks: ${this.ticks}, type: ${this.type}, param0: ${this.param0}, param1: ${this.param1}}`}};var xe;(function(i){i[i.SEQUENCE_NUMBER=0]="SEQUENCE_NUMBER",i[i.TEXT_EVENT=1]="TEXT_EVENT",i[i.COPYRIGHT_NOTICE=2]="COPYRIGHT_NOTICE",i[i.SEQUENCE_TRACK_NAME=3]="SEQUENCE_TRACK_NAME",i[i.INSTRUMENT_NAME=4]="INSTRUMENT_NAME",i[i.LYRICS=5]="LYRICS",i[i.MARKER=6]="MARKER",i[i.CUE_POINT=7]="CUE_POINT",i[i.CHANNEL_PREFIX=32]="CHANNEL_PREFIX",i[i.SET_TEMPO=81]="SET_TEMPO",i[i.SMPTE_OFFSET=84]="SMPTE_OFFSET",i[i.TIME_SIGNATURE=88]="TIME_SIGNATURE",i[i.KEY_SIGNATURE=89]="KEY_SIGNATURE",i[i.SEQUENCER_SPECIFIC=127]="SEQUENCER_SPECIFIC",i[i.PREFIX_PORT=33]="PREFIX_PORT",i[i.END_OF_TRACK=47]="END_OF_TRACK"})(xe||(xe={}));var fo=class i{ticks;type;value;constructor(e,t,r){this.ticks=e,this.type=t,this.value=r}static decode(e,t){let r=e.readByte()&255,s=e.readVarLen();switch(r){case xe.SET_TEMPO:return new i(t,r,e.readTempo());case xe.TIME_SIGNATURE:return new i(t,r,e.readSignature());case xe.END_OF_TRACK:return new i(t,r,null);case xe.TEXT_EVENT:case xe.COPYRIGHT_NOTICE:case xe.SEQUENCE_TRACK_NAME:case xe.INSTRUMENT_NAME:case xe.LYRICS:case xe.MARKER:case xe.CUE_POINT:case xe.SEQUENCE_NUMBER:case xe.CHANNEL_PREFIX:case xe.KEY_SIGNATURE:case xe.SEQUENCER_SPECIFIC:case xe.PREFIX_PORT:case xe.SMPTE_OFFSET:default:e.skip(s)}return null}toString(){return`MetaEvent{ticks: ${this.ticks}, type: ${this.type}, value: ${this.value}}`}};var Wt;(function(i){let e;(function(t){t[t.NoteOn=144]="NoteOn",t[t.NoteOff=128]="NoteOff",t[t.PitchBend=224]="PitchBend",t[t.Controller=176]="Controller"})(e=i.Command||(i.Command={})),i.readCommand=t=>t[0]&240,i.readChannel=t=>t[0]&15,i.readParam1=t=>1<t.length?t[1]&255:0,i.readParam2=t=>2<t.length?t[2]&255:0,i.readPitch=t=>t[1],i.readVelocity=t=>t[2]/127,i.isNoteOn=t=>i.readCommand(t)===e.NoteOn&&i.readVelocity(t)>0,i.isNoteOff=t=>i.readCommand(t)===e.NoteOff||i.readCommand(t)===e.NoteOn&&i.readVelocity(t)===0,i.isPitchWheel=t=>i.readCommand(t)===e.PitchBend,i.asPitchBend=t=>{let r=i.readParam1(t)&127,s=i.readParam2(t)&127,o=r|s<<7;return 8192>=o?o/8192-1:(o-8191)/8192},i.isController=t=>i.readCommand(t)===e.Controller,i.asValue=t=>{let r=i.readParam2(t);return 64<r?.5+(r-63)/128:64>r?r/128:.5},i.noteOn=(t,r,s)=>{let o=new Uint8Array(3);return o[0]=t|e.NoteOn,o[1]=r|0,o[2]=s|0,o},i.noteOff=(t,r)=>{let s=new Uint8Array(3);return s[0]=t|e.NoteOff,s[1]=r,s},i.accept=(t,r)=>{if(!Jt(t))if(i.isNoteOn(t))x(r.noteOn,i.readPitch(t),i.readVelocity(t));else if(i.isNoteOff(t))x(r.noteOff,i.readPitch(t));else if(i.isPitchWheel(t)){let s=i.readParam1(t)&127,o=i.readParam2(t)&127,n=s|o<<7;x(r.pitchBend,8192>=n?n/8192-1:(n-8191)/8192)}else i.isController(t)&&x(r.controller,i.readParam1(t),i.readParam2(t)/127)},i.debug=t=>t===null?"null":i.isNoteOn(t)?`NoteOn #${i.readChannel(t)} ${i.readPitch(t)} : ${i.readVelocity(t).toFixed(2)}`:i.isNoteOff(t)?`NoteOff #${i.readChannel(t)} ${i.readPitch(t)}`:i.isPitchWheel(t)?`PitchWheel #${i.readChannel(t)} ${i.asPitchBend(t)}`:i.isController(t)?`Control #${i.readChannel(t)} ${i.asValue(t)}`:"Unknown"})(Wt||(Wt={}));var go=class{tracks;formatType;timeDivision;constructor(e,t,r){this.tracks=e,this.formatType=t,this.timeDivision=r}};var xo=class i{controlEvents;metaEvents;static decode(e){let t=new sr,r=[],s=0,o=0,n=0;for(;;){let a=e.readVarLen(),l=e.readByte()&255;if(l<240){s+=a,l<128?e.skip(-1):(o=l&240,n=l&15);let c=mo.decode(e,o,s);V(c)&&t.add(n,c)}else if(l<248)e.skipSysEx(l);else{s+=a;let c=fo.decode(e,s);if(c!==null&&(r.push(c),c.type===xe.END_OF_TRACK))break}}return new i(t,r)}static createEmpty(){return new i(new sr,[])}constructor(e,t){this.controlEvents=e,this.metaEvents=t}encode(){let e=pe.create(),t=r=>{if(r<=127)e.writeByte(r);else{let s=r,o=[];for(o.push(s&127),s>>=7;s;){let n=s&127|128;o.push(n),s>>=7}o.reverse().forEach(n=>e.writeByte(n))}};return this.controlEvents.forEach((r,s)=>{let o=0,n=-1;s.forEach(a=>{let l=a.ticks-o;if(t(l),a.type===Fe.NOTE_ON){let c=144|r;c!==n&&e.writeByte(c),e.writeByte(a.param0),e.writeByte(a.param1)}else if(a.type===Fe.NOTE_OFF){let c=144|r;c!==n&&e.writeByte(c),e.writeByte(a.param0),e.writeByte(a.param1)}else console.warn("Unknown ControlType");o=a.ticks})}),e.toArrayBuffer()}};var yo=class{input;#t=!1;#e=!1;constructor(e){this.input=e}decode(){this.input.littleEndian=!1;let e=this.input.readInt();if(e===yt.MTHD){if(this.input.readInt()!==6)throw new Error("2nd int in header must be 6")}else throw console.warn(`Unsupported midi format ${e} !== ${yt.MTHD}`),new Error("Unsupported midi format");let t=this.input.readShort(),r=this.input.readShort(),s=this.input.readShort(),o=[];for(let n=0;n<r;n++){let a=this.input.readInt(),l=this.input.readInt(),c=this.input.position;a===yt.MTRK&&(o[n]=xo.decode(this)),this.input.position=c+l}return 0<this.input.remaining()&&console.warn(`${this.input.remaining()} bytes remaining.`),new go(o,t,s)}readVarLen(){let e=this.input.readByte()&255,t;if(0<(e&128)){e&=127;do t=this.input.readByte()&255,e=(e<<7)+(t&127);while(0<(t&128))}return e}readSignature(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255,s=this.input.readByte()&255;return this.#t,[e,1<<t]}readTempo(){let e=this.input.readByte()&255,t=this.input.readByte()&255,r=this.input.readByte()&255;return 6e7/(e<<16|t<<8|r)}skipSysEx(e){if(e===240){if(this.#e)throw new Error("System message already in progress");this.input.skip(this.readVarLen()-1),this.#e=!0}else e===247&&(this.#e?this.#e=!1:(this.input.skip(this.readVarLen()-1),this.#e=!0))}skip(e){this.input.skip(e)}readByte(){return this.input.readByte()}};var Xa;(function(i){i.decoder=t=>new yo(new ge(t)),i.encoder=()=>new e;class e{static writeVarLen(r,s){let o=[];for(;s>127;)o.push(s&127|128),s>>=7;o.push(s&127);for(let n=o.length-1;n>=0;n--)r.writeByte(o[n])}#t=[];addTrack(r){return this.#t.push(r),this}encode(){let r=pe.create();return r.littleEndian=!1,r.writeInt(yt.MTHD),r.writeInt(6),r.writeShort(0),r.writeShort(this.#t.length),r.writeShort(96),this.#t.forEach(s=>{r.writeInt(yt.MTRK);let o=s.encode();r.writeInt(o.byteLength),r.writeBytes(new Int8Array(o))}),r}}})(Xa||(Xa={}));var vo=Symbol.for("@openDAW/lib-midi");globalThis[vo]?console.debug(`%c${vo.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[vo]=!0,console.debug(`%c${vo.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var jt;(function(i){i.on=(e,t,r)=>({type:"note-on",uuid:e,pitch:t,velocity:r}),i.off=(e,t)=>({type:"note-off",uuid:e,pitch:t}),i.isOn=e=>e.type==="note-on",i.isOff=e=>e.type==="note-off",i.fromEvent=(e,t)=>{let r=e.data;if(Wt.isNoteOn(r)){let s=Wt.readPitch(r),o=Wt.readVelocity(r);return{type:"note-on",uuid:t,pitch:s,velocity:o}}else if(Wt.isNoteOff(r)){let s=Wt.readPitch(r);return{type:"note-off",uuid:t,pitch:s}}return g("Unknown MIDI event")}})(jt||(jt={}));var Za;(function(i){i.start=(e,t,r,s=1)=>{let o=!0;return e(jt.on(t,r,s)),{terminate:()=>{o&&(e(jt.off(t,r)),o=!1)}}}})(Za||(Za={}));var bo=class{#t;constructor(){this.#t=j.newSet(e=>e.field.address)}register(e){return this.#t.add(e),{terminate:()=>this.#t.removeByValue(e)}}get(e){return this.#t.get(e)}opt(e){return this.#t.opt(e)}};var Ao;(function(i){i.reader=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s},o)=>{let n=!0,a=new Int32Array(e,0,2),l=new Float32Array(e,8),c=new Float32Array(r*s),d=typeof document>"u",m=()=>{if(!n)return;let f=Atomics.load(a,1),y=Atomics.load(a,0);if(f===y){if(d)Atomics.wait(a,0,y);else{setTimeout(m,1);return}y=Atomics.load(a,0)}for(;f!==y;){let B=f*r*s;c.set(l.subarray(B,B+r*s));let S=[];for(let R=0;R<r;R++){let k=R*s,L=k+s;S.push(c.slice(k,L))}if(f=(f+1)%t,Atomics.store(a,1,f),!n)return;o(S)}m()};return m(),{stop:()=>n=!1}},i.writer=({sab:e,numChunks:t,numberOfChannels:r,bufferSize:s})=>{let o=new Int32Array(e,0,2),n=new Float32Array(e,8);return Object.freeze({write:a=>{if(a.length!==r)return;for(let d of a)if(d.length!==s)return g("Each channel buffer must contain 'bufferSize' samples");let l=Atomics.load(o,0),c=l*r*s;a.forEach((d,m)=>n.set(d,c+m*s)),Atomics.store(o,0,(l+1)%t),Atomics.notify(o,0)}})}})(Ao||(Ao={}));var $n={isClipBox:i=>i.accept({visitNoteClipBox:e=>!0,visitAudioClipBox:e=>!0,visitValueClipBox:e=>!0})??!1,isRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1,asRegionBox:i=>i.accept({visitNoteRegionBox:e=>e,visitAudioRegionBox:e=>e,visitValueRegionBox:e=>e})??g("Could not cast to AnyRegionBox"),isLoopableRegionBox:i=>i.accept({visitNoteRegionBox:e=>!0,visitAudioRegionBox:e=>!0,visitValueRegionBox:e=>!0})??!1};var qn={isRegion:i=>$n.isRegionBox(i.box),isLoopableRegion:i=>$n.isLoopableRegionBox(i.box)};var ot;(function(i){i[i.Off=0]="Off",i[i.On=1]="On",i[i.Loop=2]="Loop"})(ot||(ot={}));var wo;(function(i){i.MAGIC_HEADER_OPEN=1330660686,i.FORMAT_VERSION=2,i.decode=t=>{let r=new ge(t);b(r.readInt()===i.MAGIC_HEADER_OPEN,"Corrupt header. Probably not an openDAW project file."),b(r.readInt()===i.FORMAT_VERSION,"Deprecated Format");let s=r.readInt(),o=new Int8Array(s);r.readBytes(o);let n=new as(p.wrap(ds.create));return n.fromArrayBuffer(o.buffer),{boxGraph:n,mandatoryBoxes:e(n,r)}},i.findMandatoryBoxes=t=>{let r={};for(let s of t.boxes())s.accept({visitRootBox:o=>r.rootBox=o,visitTimelineBox:o=>r.timelineBox=o,visitUserInterfaceBox:o=>{let n=o.root.targetVertex.unwrapOrNull()?.box;ae(n,Rr)&&(r.userInterfaceBox=o)},visitAudioUnitBox:o=>{o.type.getValue()===hr.Output&&(r.masterAudioUnit=o)},visitAudioBusBox:o=>{let n=o.output.targetVertex.unwrapOrNull()?.box;ae(n,Ye)&&n.type.getValue()===hr.Output&&(r.masterBusBox=o)}});return b(r.rootBox!==void 0,"RootBox not found"),b(r.timelineBox!==void 0,"TimelineBox not found"),b(r.userInterfaceBox!==void 0,"UserInterfaceBox not found"),b(r.masterAudioUnit!==void 0,"MasterAudioUnit not found"),b(r.masterBusBox!==void 0,"MasterBusBox not found"),r};let e=(t,r)=>{let s=t.findBox(A.fromDataInput(r)).unwrap("RootBox not found"),o=t.findBox(A.fromDataInput(r)).unwrap("UserInterfaceBox not found"),n=t.findBox(A.fromDataInput(r)).unwrap("AudioBusBox not found"),a=t.findBox(A.fromDataInput(r)).unwrap("AudioUnitBox not found"),l=t.findBox(A.fromDataInput(r)).unwrap("TimelineBox not found");return{rootBox:s,userInterfaceBox:o,masterBusBox:n,masterAudioUnit:a,timelineBox:l}}})(wo||(wo={}));var Ja;(function(i){i.cut=(e,t,r)=>{if(!(e.position>=t||t>=e.complete))if(qn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;e.box.duration.setValue(t-s),e.copyTo({position:t,duration:o-t,loopOffset:xi(n+(t-s),a),consolidate:r})}else return g("Not yet implemented")},i.clip=(e,t,r)=>{if(qn.isLoopableRegion(e)){let{position:s,complete:o,loopOffset:n,loopDuration:a}=e;if(o-r<=0)return g(`duration will zero or negative(${o-r})`);e.box.duration.setValue(t-s),e.copyTo({position:r,duration:o-r,loopOffset:xi(n+(r-s),a)})}else return g("Not yet implemented")}})(Ja||(Ja={}));var ui;(e=>e.create=(t,r,s,o)=>0|(t?1:0)|(r?2:0)|(s?4:0)|(o?8:0))(ui||={});var re=class i{static Empty=new i(2);#t;constructor(e=2){this.#t=w.create(()=>new Float32Array(128),e)}clear(e,t){this.#t.forEach(r=>r.fill(0,e,t))}numChannels(){return this.#t.length}getChannel(e){return e<this.numChannels()?this.#t[e]:this.#t[this.numChannels()-1]}assertSanity(){b(!this.#t.some(e=>e.some(t=>isNaN(t))),"AudioBuffer is invalid (NaN)")}channels(){return this.#t}replace(e){this.replaceInto(e.#t)}replaceInto(e){b(e.length===2,"mixLayout: target.length must be 2"),b(this.#t.length===1||this.#t.length===2,"mixLayout: target.length must be 1 or 2"),this.#t.length===1?(e[0].set(this.#t[0]),e[1].set(this.#t[0])):(e[0].set(this.#t[0]),e[1].set(this.#t[1]))}mixInto(e){b(e.length===2,"mixLayout: target.length must be 2"),b(this.#t.length===1||this.#t.length===2,"mixLayout: target.length must be 1 or 2");let[t,r]=e;if(this.#t.length===1){let[s]=this.#t;for(let o=0;o<128;o++)t[o]+=s[o],r[o]+=s[o]}else{let[s,o]=this.#t;for(let n=0;n<128;n++)t[n]+=s[n],r[n]+=o[n]}}};var se=class i{static PEAK_DECAY=Math.exp(-1/(sampleRate*.25));static RMS_WINDOW=Math.floor(sampleRate*.1);#t;#e;#r;#i;#s;#o=0;#n=0;#a=0;#l=0;constructor(e,t){this.#t=e,this.#e=t,this.#r=new Float32Array(4),this.#i=w.create(()=>new Nr(i.RMS_WINDOW),2),this.#s=this.#t.broadcastFloats(this.#e,this.#r,()=>{this.#r[0]=this.#o,this.#r[1]=this.#n,this.#r[2]=this.#a,this.#r[3]=this.#l})}clear(){this.#i[0].clear(),this.#i[1].clear(),this.#o=0,this.#n=0}process(e,t,r=0,s=128){let[o,n]=this.#i;for(let a=r;a<s;a++){let l=e[a],c=t[a];this.#o<l?this.#o=l:this.#o*=i.PEAK_DECAY,this.#n<c?this.#n=c:this.#n*=i.PEAK_DECAY,this.#a=o.pushPop(l),this.#l=n.pushPop(c)}}processStereo([e,t],r=0,s=128){this.process(e,t,r,s)}terminate(){this.#s.terminate()}};var Eo=class{#t=new I;#e;#r;#i;#s=p.None;#o;constructor(e,t){this.#e=e,this.#r=t,this.#i=new q,this.#o=this.#r.getValue(),this.#t.own(this.#r.subscribe(r=>{this.#o=r.getValue(),this.#i.notify(this)}))}subscribe(e){return this.#i.subscribe(e)}getValue(){return this.#o}getUnitValue(){return this.#r.valueMapping.x(this.#o)}onStartAutomation(){b(this.#s.isEmpty(),"Already broadcasting"),this.#s=p.wrap(this.#e.broadcaster.broadcastFloat(this.#r.address,()=>this.getUnitValue()))}updateAutomation(e){let t=this.#r.valueAt(e);return this.#o!==t?(this.#o=t,!0):!1}onStopAutomation(){b(this.#s.nonEmpty(),"Never started broadcasting"),this.#s.unwrap().terminate(),this.#s=p.None,this.#o=this.#r.getValue()}own(e){return this.#t.own(e)}ownAll(...e){this.#t.ownAll(...e)}spawn(){return this.#t.spawn()}terminate(){this.#t.terminate()}};var ci=class{#t;constructor(){this.#t=new sr(w.empty(),nr.Comparator)}add(e,t){this.#t.add(e,t)}get(e){return this.#t.get(e)}forEach(e){return this.#t.forEach(e)}clear(){this.#t.clear()}};var Te=class{#t=new I;#e;#r;#i;#s;#o=p.None;constructor(e){this.#e=e,this.#r=new ci,this.#i=[],this.#s=[]}parameterChanged(e){return g(`Got update event for ${e}, but has no parameter change method`)}get context(){return this.#e}get eventInput(){return this.#r}bindParameter(e){let t=new Eo(this.#e,e);return t.ownAll(e.field.pointerHub.catchupAndSubscribeTransactual({onAdd:r=>{this.#o.isEmpty()&&(this.#o=p.wrap(this.#e.updateClock.addEventOutput(this.#r))),this.#s.push(t),t.onStartAutomation()},onRemove:r=>{w.remove(this.#s,t),this.#s.length===0&&(this.#o.ifSome(s=>s.terminate()),this.#o=p.None),t.onStopAutomation()}},u.Automation),t.subscribe(()=>this.parameterChanged(t))),this.#i.push(t),t}updateParameter(e){this.#s.forEach(t=>{t.updateAutomation(e)&&this.parameterChanged(t)})}readAllParameters(){this.#i.forEach(e=>this.parameterChanged(e))}own(e){return this.#t.own(e)}ownAll(...e){return this.#t.ownAll(...e)}spawn(){return this.#t.spawn()}terminate(){this.#o.ifSome(e=>e.terminate()),this.#o=p.None,this.#i.length=0,this.#t.terminate()}toString(){return`{${this.constructor.name}}`}};var Vi;(e=>e.isOfType=t=>t.type==="update-event")(Vi||={});var Bo=class extends Te{#t=[];constructor(e){super(e),this.own(this.context.registerProcessor(this))}reset(){this.eventInput.clear()}addEventOutput(e){return this.#t.push(e),{terminate:()=>w.remove(this.#t,e)}}process({blocks:e}){e.forEach(({p0:t,p1:r,flags:s},o)=>{if(ye.every(s,1))for(let n of St.iterate(t,r,ao)){let a={type:"update-event",position:n};this.#t.forEach(l=>l.add(o,a))}})}toString(){return`{${this.constructor.name}}`}};var he=class extends Te{constructor(e){super(e)}process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,s0:o,s1:n,bpm:a}=t,l=null,c=o;for(let d of this.eventInput.get(r)){let m=d.position-s,f=Math.abs(m)<1e-7?o:o+Math.floor(W.pulsesToSamples(m,a,sampleRate));b(o<=f&&f<=n,()=>`${f} out of bounds. event: ${d.position} (${d.type}), p0: ${s}`),l?.forEach(y=>this.handleEvent(y)),l=null,c<f&&(this.processAudio(t,c,f),c=f),Vi.isOfType(d)?this.updateParameter(d.position):(l??=[]).push(d)}l?.forEach(d=>this.handleEvent(d)),l=null,c<n&&this.processAudio(t,c,n)}),this.eventInput.clear(),this.finishProcess()}introduceBlock(e){}handleEvent(e){return g(`${this} received an event but has no accepting method.`)}finishProcess(){}};var Fo=class i{static#t=M.exponential(20/sampleRate,2e4/sampleRate);#e;#r;#i;#s;#o;feedback=.7;cross=0;wet=.75;dry=.75;#n=0;#a=0;#l=0;#u=0;#c=0;#d=!1;#h=!1;constructor(e,t){let r=ut(e);this.#e=r,this.#r=[new Float32Array(r),new Float32Array(r)],this.#i=[new be,new be],this.#s=new Ft,this.#o=t}reset(){this.#a=0,this.#d&&(this.#i.forEach(e=>e.reset()),this.#r.forEach(e=>e.fill(0)),this.#d=!1,this.#h=!1),this.#f()}set offset(e){b(0<=e&&e<this.#e,"Out of bounds"),this.#u!==e&&(this.#u=e,this.#d?this.#x():this.#f())}get offset(){return this.#u}set filter(e){e===0?this.#s.identity():e>0?this.#s.setHighpassParams(i.#t.y(e),.001):e<0&&this.#s.setLowpassParams(i.#t.y(1+e),.001)}process(e,t,r,s){this.#h?this.#g(e,t,r,s):this.#p(e,t,r,s),this.#d=!0}#p(e,t,r,s){let o=this.#e-1,n=this.#r,a=this.feedback,l=this.wet,c=this.dry,d=this.#a,m=d-Math.floor(this.#l);m<0&&(m+=this.#e);let f=e[0],y=e[1],B=t[0],S=t[1],R=this.#i[0],k=this.#i[1],L=n[0],z=n[1];for(let _=r;_<s;++_){let ie=f[_],de=y[_],ce=R.processFrame(this.#s,L[m]*.96),H=k.processFrame(this.#s,z[m]*.96),J=this.cross*(H-ce),U=ce+J,Z=H-J;L[d]=(ie+U)*a+1e-18-1e-18,z[d]=(de+Z)*a+1e-18-1e-18,B[_]=U*l+ie*c,S[_]=Z*l+de*c,m=++m&o,d=++d&o}this.#a=d}#g(e,t,r,s){let o=this.#e-1,n=this.#r,a=this.feedback,l=this.wet,c=this.dry,d=this.#a;for(let m=r;m<s;++m){0<this.#c?(this.#l+=this.#n,this.#c--):(this.#l=this.#u,this.#h=!1);let f=d-this.#l;f<0&&(f+=this.#e);let y=f|0,B=f-y,S=e[0][m],R=e[1][m],k=n[0][y],L=n[0][y],z=this.#i[0].processFrame(this.#s,k+B*(n[0][y+1&o]-k)),_=this.#i[1].processFrame(this.#s,L+B*(n[1][y+1&o]-L));n[0][d]=S+z*a+1e-18-1e-18,n[1][d]=R+z*a+1e-18-1e-18,t[0][m]=z*l+S*c,t[1][m]=_*l+R*c,d=++d&o}this.#a=d}#f(){this.#l=this.#u,this.#c=0,this.#h=!1}#x(){this.#u!==this.#l&&(this.#c=this.#o,this.#n=(this.#u-this.#l)/this.#c,this.#h=!0)}};var No=class i extends he{static ID=0;#t=i.ID++;#e;parameterDelay;parameterFeedback;parameterCross;parameterFilter;parameterDry;parameterWet;#r;#i;#s;#o=p.None;#n=!0;constructor(e,t){super(e),this.#e=t,this.#r=new re,this.#i=this.own(new se(e.broadcaster,t.address));let{delay:r,feedback:s,cross:o,filter:n,dry:a,wet:l}=t.namedParameter;this.parameterDelay=this.own(this.bindParameter(r)),this.parameterFeedback=this.own(this.bindParameter(s)),this.parameterCross=this.own(this.bindParameter(o)),this.parameterFilter=this.own(this.bindParameter(n)),this.parameterDry=this.own(this.bindParameter(a)),this.parameterWet=this.own(this.bindParameter(l));let c=W.pulsesToSamples(je.toPPQN(xt.OffsetFractions[0]),30,sampleRate),d=Math.floor(.5*sampleRate);this.#s=new Fo(c,d),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.reset(),this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#o=p.wrap(e),{terminate:()=>this.#o=p.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}handleEvent(e){}processAudio({bpm:e,flags:t},r,s){if(this.#o.isEmpty())return;if(this.#n||ye.some(t,8)){let n=this.parameterDelay.getValue(),a=je.toPPQN(xt.OffsetFractions[n]);this.#s.offset=W.pulsesToSamples(a,e,sampleRate),this.#n=!1}let o=this.#o.unwrap();this.#s.process(o.channels(),this.#r.channels(),r,s),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1),r,s)}parameterChanged(e){e===this.parameterDelay?this.#n=!0:e===this.parameterFeedback?this.#s.feedback=this.parameterFeedback.getValue():e===this.parameterCross?this.#s.cross=this.parameterCross.getValue():e===this.parameterFilter?this.#s.filter=this.parameterFilter.getValue():e===this.parameterDry?this.#s.dry=Ae(this.parameterDry.getValue()):e===this.parameterWet&&(this.#s.wet=Ae(this.parameterWet.getValue()))}toString(){return`{${this.constructor.name} (${this.#t})}`}};var Ii=class i extends Te{static ID=0;#t=i.ID++;#e;#r;#i;#s=p.None;constructor(e,t){super(e),this.#e=t,this.#r=new re,this.#i=this.own(new se(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#s=p.wrap(e),{terminate:()=>this.#s=p.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}process(e){if(this.#s.isEmpty())return;let t=this.#s.unwrap(),[r,s]=t.channels(),[o,n]=this.#r.channels();for(let a=0;a<128;a++)o[a]=r[a],n[a]=s[a];this.#i.process(o,n)}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#t})`}};var hi=class i extends Te{static ID=0;#t=i.ID++;#e;#r;#i;#s;constructor(e,t){super(e),this.#e=t,this.#r=new re,this.#i=this.own(new se(e.broadcaster,t.address)),this.#s=[],this.own(e.registerProcessor(this))}get noteEventTarget(){return p.None}get incoming(){return this}get outgoing(){return this}get uuid(){return this.#e.uuid}reset(){this.#i.clear(),this.#r.clear()}addAudioSource(e){return this.#s.push(e),{terminate:()=>{w.remove(this.#s,e),this.#r.clear()}}}get adapter(){return this.#e}get audioOutput(){return this.#r}process(e){this.#r.clear();let[t,r]=this.#r.channels();for(let s of this.#s){let[o,n]=s.channels();for(let a=0;a<128;a++)t[a]+=o[a],r[a]+=n[a]}this.#r.assertSanity(),this.#i.process(this.#r.getChannel(0),this.#r.getChannel(1))}parameterChanged(e){}toString(){return`{${this.constructor.name} (${this.#t})}`}};var Q;(n=>{n.start=(a,l,c,d,m=0)=>({type:"note-event",position:a,duration:l,pitch:c,velocity:d,cent:m,id:++o}),n.startWith=(a,l,c)=>({type:"note-event",position:l??a.position,duration:c??a.duration,pitch:a.pitch,cent:a.cent,velocity:a.velocity,id:++o}),n.stop=({id:a,pitch:l},c)=>({type:"note-complete-event",position:c,pitch:l,id:a}),n.isStart=a=>a.type==="note-event"&&"id"in a&&typeof a.id=="number",n.isStop=a=>a.type==="note-complete-event";let o=0})(Q||={});var nt=class{#t=new I;#e;#r;#i=p.None;constructor(e,t,r){this.#e=e,this.#r=this.#t.own(new st(t,r))}setNoteEventSource(e){return b(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=p.wrap(e),this.#e.reset(),O.create(()=>{this.#i=p.None,this.#e.reset()})}introduceBlock({index:e,p0:t,p1:r,flags:s}){if(!this.#i.isEmpty())for(let o of this.#i.unwrap().processNotes(t,r,s))o.pitch>=0&&o.pitch<=127&&(this.#e.eventInput.add(e,o),this.#s(o))}clear(){}terminate(){this.#t.terminate()}#s(e){Q.isStart(e)?this.#r.noteOn(e.pitch):Q.isStop(e)&&this.#r.noteOff(e.pitch)}};var Po=class extends he{#t;#e;#r;#i;#s;#o;#n;#a;#l;#u;#c;#d;#h;#p;gain=1;freqMult=1;attack=1;release=1;waveform=dt.sine;cutoff=1;resonance=1;filterEnvelope=0;constructor(e,t){super(e),this.#t=t,this.#e=[],this.#r=new nt(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#i=new re,this.#s=this.own(new se(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#t.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#t.namedParameter.octave)),this.#a=this.own(this.bindParameter(this.#t.namedParameter.tune)),this.#l=this.own(this.bindParameter(this.#t.namedParameter.attack)),this.#u=this.own(this.bindParameter(this.#t.namedParameter.release)),this.#c=this.own(this.bindParameter(this.#t.namedParameter.waveform)),this.#d=this.own(this.bindParameter(this.#t.namedParameter.cutoff)),this.#h=this.own(this.bindParameter(this.#t.namedParameter.resonance)),this.#p=this.own(this.bindParameter(this.#t.namedParameter.filterEnvelope)),this.own(e.registerProcessor(this)),this.readAllParameters()}get noteEventTarget(){return p.wrap(this)}introduceBlock(e){this.#r.introduceBlock(e)}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#s.clear(),this.#e.length=0,this.#i.clear(),this.eventInput.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#i}get adapter(){return this.#t}handleEvent(e){Q.isStart(e)?this.#e.push(new zn(this,e)):Q.isStop(e)&&this.#e.find(t=>t.event.id===e.id)?.stop()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#e.length-1;s>=0;s--)this.#e[s].processAdd(this.#i,t,r)&&this.#e.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n||e===this.#a?this.freqMult=2**(this.#n.getValue()+this.#a.getValue()/1200):e===this.#l?this.attack=Math.floor(this.#l.getValue()*sampleRate):e===this.#u?this.release=Math.floor(this.#u.getValue()*sampleRate):e===this.#c?this.waveform=ta(this.#c.getValue(),dt):e===this.#d?this.cutoff=this.#d.getValue():e===this.#h?this.resonance=this.#h.getValue():e===this.#p&&(this.filterEnvelope=this.#p.getValue())}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return"{VaporisateurDevice}"}},zn=class{device;event;osc;buffer;filterCoeff;filterProcessor;phase=0;position=0;decayPosition=Number.POSITIVE_INFINITY;constructor(e,t){this.device=e,this.event=t,this.osc=new ts,this.buffer=new Float32Array(128),this.filterCoeff=new Ft,this.filterProcessor=new be}stop(){this.decayPosition=this.position-this.device.attack}processAdd(e,t,r){let s=wi(this.event.pitch+this.event.cent/100,440)*this.device.freqMult,o=Pr(this.event.velocity)*this.device.gain*Ae(-15),n=this.device.waveform,a=this.device.attack,l=this.device.release,c=this.device.adapter.namedParameter.cutoff.valueMapping,d=c.x(this.device.cutoff),m=this.device.resonance,f=this.device.filterEnvelope,y=e.getChannel(0),B=e.getChannel(1);this.osc.generate(this.buffer,s/sampleRate,n,t,r);for(let S=t;S<r;S++){let R=Math.min(this.position/a,1-(this.position-(this.decayPosition+a))/l,1)**2;this.filterCoeff.setLowpassParams(c.y($(d+R*f,0,1))/sampleRate,m);let k=this.filterProcessor.processFrame(this.filterCoeff,this.buffer[S])*o*R;if(y[S]+=k,B[S]+=k,++this.position-this.decayPosition>a+l)return!0}return!1}};var So=class extends Te{#t;#e;#r;#i=NaN;#s=0;#o=128;constructor(e,t){super(e),this.#t=t,this.#e=new re(2),this.#r=this.own(new se(e.broadcaster,t.address)),this.own(e.registerProcessor(this))}get noteEventTarget(){return p.None}reset(){this.#r.clear(),this.#e.clear(),this.eventInput.clear(),this.#i=NaN,this.#s=0}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#e}process({blocks:e}){this.#e.clear(0,128);let[t,r]=this.#e.channels();this.#t.deviceHost().audioUnitBoxAdapter().tracks.collection.adapters().filter(s=>s.type===X.Audio&&s.enabled.getValue()).forEach(s=>e.forEach(o=>{let{p0:n,p1:a,flags:l}=o;if(!ye.every(l,5))return;let c=this.context.clipSequencing.iterate(s.uuid,n,a);for(let{optClip:d,sectionFrom:m,sectionTo:f}of c)d.match({none:()=>{for(let y of s.regions.collection.iterateRange(n,a)){if(y.mute||!ae(y,Kt))continue;let S=y.file.getOrCreateLoader().data;if(S.isEmpty())return;let R=S.unwrap();for(let k of Ie.locateLoops(y,n,a))this.#n(this.#e,R,k,o)}},some:y=>{if(!ae(y,Ut))return;let B=y.file.getOrCreateLoader().data;if(B.isEmpty())return;let S=B.unwrap();for(let R of Ie.locateLoops({position:0,loopDuration:y.duration,loopOffset:0,complete:Number.POSITIVE_INFINITY},m,f))this.#n(this.#e,S,R,o)}})})),this.#e.assertSanity(),this.#r.process(t,r)}parameterChanged(e){}#n(e,t,r,{p0:s,p1:o,s0:n,s1:a}){let[l,c]=e.channels(),{numberOfFrames:d,frames:m}=t,f=m[0],y=m.length===1?m[0]:m[1],B=a-n,S=o-s,R=d*r.resultStartValue,k=d*r.resultEndValue,L=(r.resultStart-s)/S,z=(r.resultEnd-s)/S,_=n+B*L,ie=n+B*z,de=ie-_|0,ce=(k-R)/de;b(n<=_&&ie<=a,`Out of bounds ${_}, ${ie}`);let H=!Number.isFinite(this.#i)||Math.abs(R-(this.#i+ce))>2;for(let J=0,U=_|0;J<de;J++,U++){let Z=R+J*ce,ee=Z|0,ke=0,_e=0;if(ee>=0&&ee<d-1){let Ee=Z-ee,He=f[ee],fi=y[ee];ke=He+Ee*(f[ee+1]-He),_e=fi+Ee*(y[ee+1]-fi)}if(H&&J<this.#o&&Number.isFinite(this.#i)){let Ee=J/this.#o,He=1-Ee,fi=this.#i+J*this.#s,Zt=fi|0;if(Zt>=0&&Zt<d-1){let Xn=fi-Zt,Zn=f[Zt],Jn=y[Zt],ml=Zn+Xn*(f[Zt+1]-Zn),fl=Jn+Xn*(y[Zt+1]-Jn);l[U]+=He*ml+Ee*ke,c[U]+=He*fl+Ee*_e}else l[U]+=ke,c[U]+=_e}else l[U]+=ke,c[U]+=_e}this.#i=R+(de-1)*ce,this.#s=ce}};var ze=class extends Te{process({blocks:e}){e.forEach(t=>{this.introduceBlock(t);let{index:r,p0:s,p1:o}=t,n=null,a=s;for(let l of this.eventInput.get(r))n?.forEach(c=>this.handleEvent(t,c)),n=null,a<l.position&&(this.processEvents(t,a,l.position),a=l.position),Vi.isOfType(l)?this.updateParameter(l.position):(n??=[]).push(l);n?.forEach(l=>this.handleEvent(t,l)),n=null,a<o&&this.processEvents(t,a,o)}),this.eventInput.clear()}introduceBlock(e){}};var di;(t=>(t.create=()=>({mult:1,add:0}),t.apply=(r,s)=>s*r.mult+r.add))(di||={});var Co=Object.freeze([{name:"up",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=t%n,c=Math.floor(t%a/n),d=i[l];return Q.start(r,s,d.pitch+c*12,di.apply(o,d.velocity))}},{name:"down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=n-1-t%n,c=e-1-Math.floor(t%a/n),d=i[l];return Q.start(r,s,d.pitch+c*12,di.apply(o,d.velocity))}},{name:"up-down",run:(i,e,t,r,s,o)=>{let n=i.length,a=n*e,l=Math.max(1,a*2-2),c=t%l,d=c<a?c:l-c,m=d%n,f=Math.floor(d/n),y=i[m];return Q.start(r,s,y.pitch+f*12,di.apply(o,y.velocity))}}]);var Ro=class extends ze{#t;#e;#r;#i;#s;#o;#n;#a;#l;#u=di.create();#c=p.None;#d=Co[0];#h=NaN;#p=1;#g=1;#f=1;constructor(e,t){super(e),this.#t=t,this.#e=[],this.#r=new Fr,this.#i=this.own(this.bindParameter(t.namedParameter.modeIndex)),this.#s=this.own(this.bindParameter(t.namedParameter.rate)),this.#o=this.own(this.bindParameter(t.namedParameter.gate)),this.#n=this.own(this.bindParameter(t.namedParameter.repeat)),this.#a=this.own(this.bindParameter(t.namedParameter.numOctaves)),this.#l=this.own(this.bindParameter(t.namedParameter.velocity)),this.ownAll(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}get noteEventTarget(){return p.wrap(this)}setNoteEventSource(e){return b(this.#c.isEmpty(),"NoteEventSource already set"),this.#c=p.wrap(e),O.create(()=>this.#c=p.None)}*processNotes(e,t,r){if(this.#r.nonEmpty())if(ye.every(r,2))for(let o of this.#r.releaseAll())yield Q.stop(o,e);else for(let o of this.#r.releaseLinearCompleted(t))yield Q.stop(o,o.position+o.duration);if(this.#c.nonEmpty()){let s=this.#c.unwrap();for(let n of s.processNotes(e,t,r));let o=!ye.every(r,1);for(let{position:n,index:a}of St.iterateWithIndex(e,t,this.#h)){let l=Array.from(s.iterateActiveNotesAt(n,o));if(l.length===0)continue;let c=Math.floor(a/this.#g),d=Math.max(1,Math.floor(this.#h*this.#p)),m=this.#d.run(l,this.#f,c,n,d,this.#u);this.#r.addAndRetain({...m}),yield m}for(let n of this.#r.releaseLinearCompleted(t))yield Q.stop(n,n.position+n.duration)}}*iterateActiveNotesAt(e,t){this.#c.isEmpty()||t||(yield*this.#r.overlapping(e,Me.Comparator))}reset(){this.#e.length=0,this.#r.clear(),this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){if(e===this.#i)this.#d=Co.at(this.#i.getValue())??Co[0];else if(e===this.#s)this.#h=je.toPPQN(Ht.RateFractions[this.#s.getValue()]);else if(e===this.#o)this.#p=this.#o.getValue();else if(e===this.#n)this.#g=this.#n.getValue();else if(e===this.#a)this.#f=this.#a.getValue();else if(e===this.#l){let t=this.#l.getValue();t<=0?(this.#u.add=1+t,this.#u.mult=0):(this.#u.add=1-t,this.#u.mult=t)}}handleEvent(e,t){}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}};var Mo=class extends ze{#t;#e;#r;#i;#s;#o=p.None;constructor(e,t){super(e),this.#t=t,this.#e=this.own(new st(e.broadcaster,t.address)),this.#r=this.own(this.bindParameter(t.namedParameter.octaves)),this.#i=this.own(this.bindParameter(t.namedParameter.semiTones)),this.#s=this.own(this.bindParameter(t.namedParameter.cent)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return b(this.#o.isEmpty(),"NoteEventSource already set"),this.#o=p.wrap(e),O.create(()=>this.#o=p.None)}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#o.isEmpty())for(let s of this.#o.unwrap().processNotes(e,t,r))if(Q.isStart(s)){this.#e.noteOn(s.pitch);let{cent:o,octaves:n,semiTones:a}=this.#t.namedParameter;yield Ze.overwrite(s,{pitch:s.pitch+n.valueAt(s.position)*12+a.valueAt(s.position),cent:s.cent+o.valueAt(s.position)})}else this.#e.noteOff(s.pitch),yield s}*iterateActiveNotesAt(e,t){if(!this.#o.isEmpty()){for(let r of this.#o.unwrap().iterateActiveNotesAt(e,t))if(r.type==="note-event"){let{cent:s,octaves:o,semiTones:n}=this.#t.namedParameter;yield Ze.overwrite(r,{pitch:r.pitch+o.valueAt(r.position)*12+n.valueAt(r.position),cent:r.cent+s.valueAt(r.position)})}}}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}};var Do=class i{static DEFAULT_SIZE=1024;#t;#e;#r;#i;#s;#o;#n;#a=0;decay=!1;constructor(e=i.DEFAULT_SIZE){this.#t=e,this.#r=new Xi(this.#t),this.#i=new Float32Array(this.#t),this.#s=new Float32Array(this.#t),this.#o=Ei.create(Ei.Type.Blackman,this.#t),this.#e=this.#t>>1,this.#n=new Float32Array(this.#e)}clear(){this.#n.fill(0),this.#a=0}numBins(){return this.#e}bins(){return this.#n}process(e,t,r,s){for(let o=r;o<s;++o)this.#i[this.#a]=this.#o[this.#a]*(e[o]+t[o]),++this.#a===this.#t&&this.#l()}#l(){this.#r.process(this.#i,this.#s);let e=1/this.#e;for(let t=0;t<this.#e;++t){let r=this.#i[t],s=this.#s[t],o=Math.sqrt(r*r+s*s)*e;this.#n[t]<o?this.#n[t]=o:this.decay&&(this.#n[t]*=.9)}this.#a=0,this.#s.fill(0),this.decay=!1}};var Vo=class i extends he{static ID=0;#t=i.ID++;#e;#r;#i;#s;#o;#n;#a;#l;#u;#c;#d;#h;#p;#g;#f;#x;#v;#I;#P;#S;#B;#T;#C;#b;#y;#F;#R;#M;#D;#A;#E;#w;#N;#V;#O;#U;#k=p.None;constructor(e,t){super(e),this.#e=t,this.#r=new re,this.#i=this.own(new se(e.broadcaster,t.address)),this.#s=new Do,this.#o=new Float32Array(this.#s.numBins()),this.#n=w.create(()=>new Ft,7),this.#a=[new or(4),new or(4)],this.#l=[new or(4),new or(4)],this.#u=[this.#l,[new be,new be],[new be,new be],[new be,new be],[new be,new be],[new be,new be],this.#a],this.#c=w.create(()=>!0,7);let r=this.#e.namedParameter;this.#d=this.own(this.bindParameter(r.highPass.enabled)),this.#p=this.own(this.bindParameter(r.highPass.q)),this.#h=this.own(this.bindParameter(r.highPass.frequency)),this.#g=this.own(this.bindParameter(r.highPass.order)),this.#f=this.own(this.bindParameter(r.lowShelf.enabled)),this.#x=this.own(this.bindParameter(r.lowShelf.frequency)),this.#v=this.own(this.bindParameter(r.lowShelf.gain)),this.#I=this.own(this.bindParameter(r.lowBell.enabled)),this.#P=this.own(this.bindParameter(r.lowBell.frequency)),this.#S=this.own(this.bindParameter(r.lowBell.gain)),this.#B=this.own(this.bindParameter(r.lowBell.q)),this.#T=this.own(this.bindParameter(r.midBell.enabled)),this.#C=this.own(this.bindParameter(r.midBell.frequency)),this.#b=this.own(this.bindParameter(r.midBell.gain)),this.#y=this.own(this.bindParameter(r.midBell.q)),this.#F=this.own(this.bindParameter(r.highBell.enabled)),this.#R=this.own(this.bindParameter(r.highBell.frequency)),this.#M=this.own(this.bindParameter(r.highBell.gain)),this.#D=this.own(this.bindParameter(r.highBell.q)),this.#A=this.own(this.bindParameter(r.highShelf.enabled)),this.#E=this.own(this.bindParameter(r.highShelf.frequency)),this.#w=this.own(this.bindParameter(r.highShelf.gain)),this.#N=this.own(this.bindParameter(r.lowPass.enabled)),this.#V=this.own(this.bindParameter(r.lowPass.frequency)),this.#O=this.own(this.bindParameter(r.lowPass.q)),this.#U=this.own(this.bindParameter(r.lowPass.order)),this.own(e.registerProcessor(this)),e.broadcaster.broadcastFloats(t.spectrum,this.#o,()=>{this.#o.set(this.#s.bins()),this.#s.decay=!0}),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#r.clear(),this.#u.forEach(e=>e.forEach(t=>t.reset())),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#k=p.wrap(e),{terminate:()=>this.#k=p.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}processAudio(e,t,r){if(this.#k.isEmpty())return;let[s,o]=this.#r.channels(),n=this.#k.unwrap();if(this.#c.some(a=>a)){let[a,l]=n.channels();this.#n.forEach((c,d)=>{if(this.#c[d]){let[m,f]=this.#u[d];m.process(c,a,s,t,r),f.process(c,l,o,t,r),a=s,l=o}})}else{let[a,l]=n.channels();for(let c=t;c<r;c++)s[c]=a[c],o[c]=l[c]}this.#i.process(s,o,t,r),this.#s.process(s,o,t,r)}parameterChanged(e){if(e===this.#U){let t=this.#U.getValue();this.#a[0].order=t,this.#a[1].order=t}else if(e===this.#g){let t=this.#g.getValue();this.#l[0].order=t,this.#l[1].order=t}else if(e===this.#h||e===this.#p){let t=this.#h.getValue(),r=this.#p.getValue();this.#n[0].setHighpassParams(t/sampleRate,r)}else if(e===this.#x||e===this.#v){let t=this.#x.getValue(),r=this.#v.getValue();this.#n[1].setLowShelfParams(t/sampleRate,r)}else if(e===this.#P||e===this.#S||e===this.#B){let t=this.#P.getValue(),r=this.#S.getValue(),s=this.#B.getValue();this.#n[2].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#C||e===this.#b||e===this.#y){let t=this.#C.getValue(),r=this.#b.getValue(),s=this.#y.getValue();this.#n[3].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#R||e===this.#M||e===this.#D){let t=this.#R.getValue(),r=this.#M.getValue(),s=this.#D.getValue();this.#n[4].setPeakingParams(t/sampleRate,s,r)}else if(e===this.#E||e===this.#w){let t=this.#E.getValue(),r=this.#w.getValue();this.#n[5].setHighShelfParams(t/sampleRate,r)}else if(e===this.#V||e===this.#O){let t=this.#V.getValue(),r=this.#O.getValue();this.#n[6].setLowpassParams(t/sampleRate,r)}else e===this.#d?this.#c[0]=this.#d.getValue():e===this.#f?this.#c[1]=this.#f.getValue():e===this.#I?this.#c[2]=this.#I.getValue():e===this.#T?this.#c[3]=this.#T.getValue():e===this.#F?this.#c[4]=this.#F.getValue():e===this.#A?this.#c[5]=this.#A.getValue():e===this.#N&&(this.#c[6]=this.#N.getValue())}toString(){return`{${this.constructor.name} (${this.#t})`}};var Io=class{roomSize;damp;predelayInSamples;wetGain;dryGain;#t=new Float32Array(2048);#e=new Float32Array(2048);#r=new Float32Array(2048);#i=new Float32Array(2048);#s=new Float32Array(2048);#o=new Float32Array(2048);#n=new Float32Array(2048);#a=new Float32Array(2048);#l=new Float32Array(1024);#u=new Float32Array(512);#c=new Float32Array(512);#d=new Float32Array(256);#h=new Float32Array(2048);#p=new Float32Array(2048);#g=new Float32Array(2048);#f=new Float32Array(2048);#x=new Float32Array(2048);#v=new Float32Array(2048);#I=new Float32Array(2048);#P=new Float32Array(2048);#S=new Float32Array(1024);#B=new Float32Array(512);#T=new Float32Array(512);#C=new Float32Array(256);#b;#y;#F=0;#R=0;#M=0;#D=0;#A=0;#E=0;#w=0;#N=0;#V=0;#O=0;#U=0;#k=0;#L=0;#$=0;#q=0;#z=0;#_=0;#H=0;#G=0;#W=0;#j=0;#Q=0;#Y=0;#X=0;#Z=0;#J=0;#ee=0;#te=0;#re=0;#ie=0;#se=0;#oe=0;#ne=0;#ae=0;#le=0;#ue=0;#ce=0;#he=0;#de=0;#pe=0;#m=0;#K=0;constructor(e=.5){this.#b=ut(Math.ceil(e*sampleRate)),this.#y=new Float32Array(this.#b<<1),this.damp=0,this.roomSize=.5,this.wetGain=.3333,this.dryGain=1-this.wetGain,this.#m=0,this.#K=0,this.predelayInSamples=.008*sampleRate,this.clearHistory()}clear(){this.#m=0,this.#K=0,this.clearHistory(),this.clearBuffers()}process(e,t,r,s){let[o,n]=t.channels(),[a,l]=e.channels(),c=.4*this.damp,d=1-c,m=.7+.28*this.roomSize;for(let f=r;f<s;++f){let y=o[f],B=n[f],S=this.#K-this.predelayInSamples;S<0&&(S+=this.#b);let R;R=S<<1;let k=.01,L=this.#y[R]*k,z=this.#y[R+1]*k;R=this.#K<<1,this.#y[R]=y,this.#y[R+1]=B,this.#K=this.#K+1&this.#b-1;let _=this.#m&2047;this.#F=d*this.#R+c*this.#F,this.#t[_]=L+m*this.#F,this.#R=this.#t[this.#m-1617&2047],this.#M=d*this.#D+c*this.#M,this.#e[_]=L+m*this.#M,this.#D=this.#e[this.#m-1557&2047],this.#A=d*this.#E+c*this.#A,this.#r[_]=L+m*this.#A,this.#E=this.#r[this.#m-1491&2047],this.#w=d*this.#N+c*this.#w,this.#i[_]=L+m*this.#w,this.#N=this.#i[this.#m-1422&2047],this.#V=d*this.#O+c*this.#V,this.#s[_]=L+m*this.#V,this.#O=this.#s[this.#m-1356&2047],this.#U=d*this.#k+c*this.#U,this.#o[_]=L+m*this.#U,this.#k=this.#o[this.#m-1277&2047],this.#L=d*this.#$+c*this.#L,this.#n[_]=L+m*this.#L,this.#$=this.#n[this.#m-1188&2047],this.#q=d*this.#z+c*this.#q,this.#a[_]=L+m*this.#q,this.#z=this.#a[this.#m-1116&2047];let ie=this.#z+this.#$+this.#k+this.#O+this.#N+this.#E+this.#D+this.#R,de=this.#_-ie,ce=this.#H-de,H=this.#G-ce;this.#l[this.#m&1023]=ie+.5*this.#_,this.#_=this.#l[this.#m-556&1023],this.#u[this.#m&511]=de+.5*this.#H,this.#H=this.#u[this.#m-441&511],this.#c[this.#m&511]=ce+.5*this.#G,this.#G=this.#c[this.#m-341&511],this.#d[this.#m&255]=H+.5*this.#W,this.#W=this.#d[this.#m-225&255],a[f]=this.dryGain*y+this.wetGain*(this.#W-H),this.#j=d*this.#Q+c*this.#j,this.#h[_]=z+m*this.#j,this.#Q=this.#h[this.#m-1640&2047],this.#Y=d*this.#X+c*this.#Y,this.#p[_]=z+m*this.#Y,this.#X=this.#p[this.#m-1580&2047],this.#Z=d*this.#J+c*this.#Z,this.#g[_]=z+m*this.#Z,this.#J=this.#g[this.#m-1514&2047],this.#ee=d*this.#te+c*this.#ee,this.#f[_]=z+m*this.#ee,this.#te=this.#f[this.#m-1445&2047],this.#re=d*this.#ie+c*this.#re,this.#x[_]=z+m*this.#re,this.#ie=this.#x[this.#m-1379&2047],this.#se=d*this.#oe+c*this.#se,this.#v[_]=z+m*this.#se,this.#oe=this.#v[this.#m-1300&2047],this.#ne=d*this.#ae+c*this.#ne,this.#I[_]=z+m*this.#ne,this.#ae=this.#I[this.#m-1211&2047],this.#le=d*this.#ue+c*this.#le,this.#P[_]=z+m*this.#le,this.#ue=this.#P[this.#m-1139&2047];let J=this.#ue+this.#ae+this.#oe+this.#ie+this.#te+this.#J+this.#X+this.#Q,U=this.#ce-J,Z=this.#he-U,ee=this.#de-Z;this.#S[this.#m&1023]=J+.5*this.#ce,this.#ce=this.#S[this.#m-579&1023],this.#B[this.#m&511]=U+.5*this.#he,this.#he=this.#B[this.#m-464&511],this.#T[this.#m&511]=Z+.5*this.#de,this.#de=this.#T[this.#m-364&511],this.#C[this.#m&255]=ee+.5*this.#pe,this.#pe=this.#C[this.#m-248&255],l[f]=this.dryGain*B+this.wetGain*(this.#pe-ee),this.#m++}}clearBuffers(){this.#t.fill(0),this.#e.fill(0),this.#r.fill(0),this.#i.fill(0),this.#s.fill(0),this.#o.fill(0),this.#n.fill(0),this.#a.fill(0),this.#l.fill(0),this.#u.fill(0),this.#c.fill(0),this.#d.fill(0),this.#h.fill(0),this.#p.fill(0),this.#g.fill(0),this.#f.fill(0),this.#x.fill(0),this.#v.fill(0),this.#I.fill(0),this.#P.fill(0),this.#S.fill(0),this.#B.fill(0),this.#T.fill(0),this.#C.fill(0),this.#y.fill(0)}clearHistory(){this.#F=0,this.#R=0,this.#M=0,this.#D=0,this.#A=0,this.#E=0,this.#w=0,this.#N=0,this.#V=0,this.#O=0,this.#U=0,this.#k=0,this.#L=0,this.#$=0,this.#q=0,this.#z=0,this.#_=0,this.#H=0,this.#G=0,this.#W=0,this.#j=0,this.#Q=0,this.#Y=0,this.#X=0,this.#Z=0,this.#J=0,this.#ee=0,this.#te=0,this.#re=0,this.#ie=0,this.#se=0,this.#oe=0,this.#ne=0,this.#ae=0,this.#le=0,this.#ue=0,this.#ce=0,this.#he=0,this.#de=0,this.#pe=0}};var To=class i extends he{static ID=0;#t=i.ID++;#e;#r;#i;#s;#o;#n;#a;#l;#u;#c=p.None;constructor(e,t){super(e),this.#e=t,this.#r=new re,this.#i=this.own(new se(e.broadcaster,t.address)),this.#s=new Io;let{decay:r,preDelay:s,damp:o,wet:n,dry:a}=this.#e.namedParameter;this.#o=this.own(this.bindParameter(r)),this.#n=this.own(this.bindParameter(s)),this.#a=this.own(this.bindParameter(o)),this.#l=this.own(this.bindParameter(n)),this.#u=this.own(this.bindParameter(a)),this.own(e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#i.clear(),this.#s.clear(),this.#r.clear(),this.eventInput.clear()}get uuid(){return this.#e.uuid}get audioOutput(){return this.#r}setAudioSource(e){return this.#c=p.wrap(e),{terminate:()=>this.#c=p.None}}index(){return this.#e.indexField.getValue()}adapter(){return this.#e}processAudio(e,t,r){if(this.#c.isEmpty())return;this.#s.process(this.#r,this.#c.unwrap(),t,r);let[s,o]=this.#r.channels();this.#i.process(s,o,t,r)}parameterChanged(e){this.#o===e?this.#s.roomSize=this.#o.getValue():this.#n===e?this.#s.predelayInSamples=Math.ceil(this.#n.getValue()*sampleRate):this.#a===e?this.#s.damp=this.#a.getValue():this.#l===e?this.#s.wetGain=Ae(this.#l.getValue()):this.#u===e&&(this.#s.dryGain=Ae(this.#u.getValue()))}toString(){return`{${this.constructor.name} (${this.#t})`}};var Oo=class extends he{#t;#e;#r;#i;#s;#o;#n;gain=1;release=1;loader=p.None;constructor(e,t){super(e),this.#t=t,this.#e=[],this.#r=new re,this.#i=new nt(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#s=this.own(new se(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(this.#t.namedParameter.volume)),this.#n=this.own(this.bindParameter(this.#t.namedParameter.release)),this.ownAll(e.registerProcessor(this),t.box.file.catchupAndSubscribe(r=>this.loader=r.targetVertex.map(({box:s})=>e.sampleManager.getOrCreate(s.address.uuid)))),this.readAllParameters()}get noteEventTarget(){return p.wrap(this)}introduceBlock(e){this.#i.introduceBlock(e)}setNoteEventSource(e){return this.#i.setNoteEventSource(e)}get incoming(){return this}get outgoing(){return this}reset(){this.#e.length=0,this.#r.clear(),this.eventInput.clear(),this.#i.clear(),this.#s.clear()}get uuid(){return this.#t.uuid}get audioOutput(){return this.#r}get adapter(){return this.#t}handleEvent(e){Q.isStart(e)?this.#e.push(new _n(this,e)):Q.isStop(e)&&this.#e.find(t=>t.event().id===e.id)?.stop()}processAudio(e,t,r){this.#r.clear(t,r);for(let s=this.#e.length-1;s>=0;s--)this.#e[s].processAdd(this.#r,t,r)&&this.#e.splice(s,1)}parameterChanged(e){e===this.#o?this.gain=Ae(this.#o.getValue()):e===this.#n&&(this.release=this.#n.getValue()*sampleRate)}finishProcess(){this.#r.assertSanity(),this.#s.process(this.#r.getChannel(0),this.#r.getChannel(1))}toString(){return"{NanoDevice}"}},_n=class{#t;#e;#r=1;#i=0;#s=0;#o=Number.POSITIVE_INFINITY;constructor(e,t){this.#t=e,this.#e=t,this.#r=Math.pow(2,(t.pitch+t.cent/100)/12-5)}event(){return this.#e}stop(){this.#o=this.#s}processAdd(e,t,r){let s=this.#t.loader;if(s.isEmpty())return!0;let o=s.unwrap();return o.data.isEmpty()?!0:this.processSimple(e.channels(),o.data.unwrap(),t,r)}processSimple(e,t,r,s){let[o,n]=e,a=t.frames[0],l=t.frames[1]??a,c=t.numberOfFrames,d=t.sampleRate/sampleRate,m=this.#t.gain,f=this.#t.release,y=1/f;for(let B=r;B<s;B++){let S=this.#i|0;if(S>=c-1)return!0;let R=this.#i-S,k=Math.min(1-(this.#s-this.#o)*y,1)**2,L=a[S]*(1-R)+a[S+1]*R,z=l[S]*(1-R)+l[S+1]*R;if(o[B]+=L*m*k,n[B]+=z*m*k,this.#i+=this.#r*d,++this.#s-this.#o>f)return!0}return!1}};var ko=class extends ze{#t;#e;constructor(e,t){super(e),this.#t=t,this.#e=new nt(this,e.broadcaster,t.adapter.audioUnitBoxAdapter().address),this.own(e.registerProcessor(this)),this.readAllParameters()}introduceBlock(e){this.#e.introduceBlock(e)}setNoteEventSource(e){return this.#e.setNoteEventSource(e)}reset(){this.eventInput.clear(),this.#e.clear()}processEvents(e,t,r){}handleEvent({index:e},t){Q.isStart(t)?this.#t.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t)):Q.isStop(t)&&this.#t.optSampleProcessor(t.pitch).ifSome(({eventInput:r})=>r.add(e,t))}toString(){return"{PlayfieldSequencer}"}};var Uo=class extends he{#t;#e;#r;#i;#s;constructor(e,t){super(e),this.#t=t,this.#e=new re,this.#r=this.own(new se(e.broadcaster,t.adapter.address)),this.#i=[],this.#s=new ci,this.own(e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}setAudioSource(e){return this.#i.push(e),{terminate:()=>{w.remove(this.#i,e),this.#e.clear()}}}get audioOutput(){return this.#e}get eventInput(){return this.#s}processAudio(e,t,r){}reset(){this.#r.clear()}finishProcess(){this.#e.clear();let[e,t]=this.#e.channels();for(let r of this.#i){let[s,o]=r.channels();for(let n=0;n<128;n++)e[n]+=s[n],t[n]+=o[n]}this.#e.assertSanity(),this.#r.process(this.#e.getChannel(0),this.#e.getChannel(1))}toString(){return"{PlayfieldMixProcessor}"}};var Ko=class i{static create(e,t,r,s){return new i(e,t,r,s)}#t=new I;#e;#r;#i=[];#s=!0;constructor(e,t,r,s){this.#e=A.newSet(({device:o})=>o.uuid),this.#r=this.#t.own(new I),this.#t.ownAll(t.catchupAndSubscribe({onAdd:o=>{this.invalidateWiring();let n=Ti.create(e,o.box),a=this.#e.add({device:n,subscription:n.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(a,"Could not add.")},onRemove:o=>{this.invalidateWiring();let{device:n,subscription:a}=this.#e.removeByKey(o.uuid);a.terminate(),n.terminate()},onReorder:o=>this.invalidateWiring()}),e.subscribeProcessPhase(o=>{if(o===0&&this.#s){let n=r;w.replace(this.#i,t.adapters().map(({uuid:a})=>this.#e.get(a).device));for(let a of this.#i)a.adapter().enabledField.getValue()&&(this.#r.own(a.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,a.incoming)),n=a);this.#r.own(s.setAudioSource(n.audioOutput)),this.#r.own(e.registerEdge(n.outgoing,s.incoming)),this.#s=!1}}))}invalidateWiring(){this.#r.terminate(),this.#s=!0}terminate(){this.#t.terminate(),this.#e.forEach(({device:e})=>e.terminate()),this.#e.clear(),this.#i=[]}toString(){return`{${this.constructor.name}}`}};var Oi=Math.floor(.005*sampleRate),$o=class{#t;#e;#r;#i;#s;#o;#n=0;#a=Number.POSITIVE_INFINITY;#l;#u;#c;#d;#h;#p;#g=!0;#f=!1;constructor(e,t,r,s){this.#t=e,this.#e=t,this.#i=r,this.#r=s,this.#s=e.gate,this.#o=Pr(this.#r.velocity);let{attack:o,release:n,sampleStart:a,sampleEnd:l}=this.#e;this.#l=o.getValue()*sampleRate,this.#u=n.getValue()*sampleRate,this.#c=(r.numberOfFrames-1)*a.getValue(),this.#d=(r.numberOfFrames-1)*l.getValue(),this.#h=this.#c,this.#p=0}get sample(){return this.#t}get event(){return this.#r}get position(){return this.#h}get envelope(){return this.#p}release(e=!1){this.#g&&(e?(this.#u=Oi,this.#x(),this.#g=!1):this.#s!==ot.Off&&this.#x())}processAdd(e,t,r){let[s,o]=e,{frames:n,numberOfFrames:a}=this.#i,l=n[0],c=n[1]??l,{pitch:d}=this.#e,m=this.#d-this.#c,f=Math.sign(m),y=this.#i.sampleRate/sampleRate*f*2**(d.getValue()/1200),B=0;for(let S=t;S<r;S++){let R=this.#h|0,k=this.#h-R,L=l[R]*(1-k)+(l[R+1]??0)*k,z=c[R]*(1-k)+(c[R+1]??0)*k;if(B=Math.min(this.#n/this.#l,1-(this.#n-(this.#a+this.#l))/this.#u,1),this.#h+=y,f>0){if(this.#s===ot.Off){if(this.#h>=a)return!0;!this.#f&&this.#h>=this.#d&&this.#x()}else if(this.#s===ot.On){if(this.#h>=this.#d-Oi){if(this.#h>=this.#d)return!0;B*=(this.#d-this.#h)/Oi}}else if(this.#s===ot.Loop)for(;this.#h>=this.#d;)this.#h-=m}else if(f<0){if(this.#s===ot.Off){if(this.#h<=0)return!0;!this.#f&&this.#h<=this.#d&&this.#x()}else if(this.#s===ot.On){if(this.#h<=this.#d+Oi){if(this.#h<=this.#d)return!0;B*=(this.#d-this.#h)/Oi}}else if(this.#s===ot.Loop)for(;this.#h<=this.#d;)this.#h-=m}if(++this.#n-this.#a>this.#l+this.#u)return!0;B*=this.#o*B,s[S]+=L*B,o[S]+=z*B}return this.#p=B,!1}toString(){return"{PlayfieldSampleVoice}"}#x(){this.#f||(this.#f=!0,this.#a=this.#n<this.#l?this.#n-this.#l:this.#n)}};var qo=class extends he{#t;#e;#r;#i;#s;#o;constructor(e,t,r,s){super(e),this.#t=t,this.#e=r,this.#r=[],this.#i=new re,this.#s=this.own(new se(e.broadcaster,r.peakAddress));let{sampleStart:o,sampleEnd:n,attack:a,release:l,pitch:c}=r.namedParameter;this.#o=Object.freeze({sampleStart:this.own(this.bindParameter(o)),sampleEnd:this.own(this.bindParameter(n)),attack:this.own(this.bindParameter(a)),release:this.own(this.bindParameter(l)),pitch:this.own(this.bindParameter(c))});let d=new Float32Array(16);this.ownAll(Ko.create(e,r.audioEffects,this,s),e.broadcaster.broadcastFloats(r.address,d,()=>{let m=this.#r.length<d.length?this.#r:this.#r.slice(0,d.length);m.forEach(({position:f},y)=>d[y]=f),d[m.length]=-1}),e.registerProcessor(this)),this.readAllParameters()}get uuid(){return this.#e.uuid}get incoming(){return this}get outgoing(){return this}get audioOutput(){return this.#i}get adapter(){return this.#e}handleEvent(e){if(Q.isStart(e)){let t=this.#e.file().flatMap(d=>d.getOrCreateLoader().data);if(t.isEmpty())return;let{mute:r,solo:s,polyphone:o,exclude:n}=this.#e.namedParameter,a=r.getValue(),l=s.getValue();if(a||this.#t.hasSolo()&&!l)return;o.getValue()||this.#r.forEach(d=>d.release(!0)),n.getValue()&&this.#t.stopExcludeOthers(this.#e),this.#r.push(new $o(this.#e,this.#o,t.unwrap(),e))}else Q.isStop(e)&&this.#r.find(t=>t.event.id===e.id)?.release()}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#r.length-1;s>=0;s--)this.#r[s].processAdd(this.#i.channels(),t,r)&&this.#r.splice(s,1)}forceStop(){this.#r.forEach(e=>e.release(!0))}parameterChanged(e){}reset(){this.#r.length=0,this.#i.clear(),this.#s.clear()}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return`{PlayfieldSampleProcessor note: ${this.#e.indexField.getValue()}}`}};var zo=class{#t=new I;#e;#r;#i;#s;constructor(e,t){this.#e=t,this.#r=this.#t.own(new ko(e,this)),this.#i=this.#t.own(new Uo(e,this)),this.#s=A.newSet(r=>r.uuid),this.#t.ownAll(t.samples.catchupAndSubscribe({onAdd:r=>{let s=new qo(e,this,r,this.#i);this.#s.add({uuid:r.uuid,processor:s,terminable:e.registerEdge(this.#r,s)}),e.sampleManager.getOrCreate(r.fileUUID())},onRemove:r=>{let{terminable:s,processor:o}=this.#s.removeByKey(r.uuid);s.terminate(),o.terminate()},onReorder:r=>{}}),{terminate:()=>{this.#s.forEach(({terminable:r,processor:s})=>{r.terminate(),s.terminate()}),this.#s.clear()}})}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get noteEventTarget(){return p.wrap(this)}get incoming(){return this.#r}get outgoing(){return this.#i}optSampleProcessor(e){return this.#e.samples.getAdapterByIndex(e).flatMap(t=>this.#s.opt(t.uuid)).map(t=>t.processor)}hasSolo(){return this.#e.samples.adapters().some(e=>e.namedParameter.solo.getValue())}stopExcludeOthers(e){for(let t of this.#e.samples.adapters())t.exclude&&t!==e&&this.#s.opt(t.uuid).ifSome(({processor:r})=>r.forceStop())}get uuid(){return this.#e.uuid}get adapter(){return this.#e}get audioOutput(){return this.#i.audioOutput}parameterChanged(e){}terminate(){this.#t.terminate()}toString(){return"{PlayfieldDeviceProcessor}"}};var _o=class extends he{#t;#e;#r;#i=Qe.stereoMatrix(sampleRate);#s={gain:0,panning:0,stereo:0,invertL:!1,invertR:!1,swap:!1};#o;#n;#a;#l;#u;#c;#d=p.None;#h=pt.Mixing.Linear;#p=!0;#g=!1;constructor(e,t){super(e),this.#t=t,this.#e=new re,this.#r=this.own(new se(e.broadcaster,t.address)),this.#o=this.own(this.bindParameter(t.namedParameter.volume)),this.#n=this.own(this.bindParameter(t.namedParameter.panning)),this.#a=this.own(this.bindParameter(t.namedParameter.stereo)),this.#l=this.own(this.bindParameter(t.namedParameter.invertL)),this.#u=this.own(this.bindParameter(t.namedParameter.invertR)),this.#c=this.own(this.bindParameter(t.namedParameter.swap)),this.ownAll(t.box.panningMixing.catchupAndSubscribe(r=>{this.#h=r.getValue(),this.#p=!0}),e.registerProcessor(this)),this.readAllParameters()}get incoming(){return this}get outgoing(){return this}reset(){this.#r.clear(),this.#e.clear(),this.eventInput.clear(),this.#g=!1}get uuid(){return this.#t.uuid}get audioOutput(){return this.#e}setAudioSource(e){return this.#d=p.wrap(e),{terminate:()=>this.#d=p.None}}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}processAudio(e,t,r){if(this.#d.isEmpty())return;this.#p&&(this.#i.update(this.#s,this.#h,this.#g),this.#p=!1);let s=this.#d.unwrap().channels(),o=this.#e.channels();this.#i.processFrames(s,o,t,r),this.#r.processStereo(o,t,r),this.#g=!0}parameterChanged(e){switch(e){case this.#o:this.#s.gain=Ae(this.#o.getValue()),this.#p=!0;return;case this.#n:this.#s.panning=this.#n.getValue(),this.#p=!0;return;case this.#a:this.#s.stereo=this.#a.getValue(),this.#p=!0;return;case this.#l:this.#s.invertL=this.#l.getValue(),this.#p=!0;return;case this.#u:this.#s.invertR=this.#u.getValue(),this.#p=!0;return;case this.#c:this.#s.swap=this.#c.getValue(),this.#p=!0;return}}toString(){return`{${this.constructor.name}}`}};var Ho=class extends ze{#t;#e;#r=p.None;#i=p.None;constructor(e,t){super(e),this.#t=t,this.#e=this.own(new st(e.broadcaster,t.address)),this.ownAll(t.box.groove.catchupAndSubscribe(r=>{this.#r.ifSome(s=>s.terminate()),this.#r=p.wrap(r.targetVertex.isEmpty()?null:e.boxAdapters.adapterFor(r.targetVertex.unwrap().box,xr.checkType))}),O.create(()=>{this.#r.ifSome(r=>r.terminate()),this.#r=p.None}),e.registerProcessor(this))}get uuid(){return this.#t.uuid}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}setNoteEventSource(e){return b(this.#i.isEmpty(),"NoteEventSource already set"),this.#i=p.wrap(e),O.create(()=>this.#i=p.None)}*processNotes(e,t,r){if(this.#i.isEmpty())return;let s=this.#i.unwrap(),o=this.#r.mapOr(gi,Ai.Identity);for(let n of s.processNotes(o.unwarp(e),o.unwarp(t),r))Q.isStart(n)?this.#e.noteOn(n.pitch):this.#e.noteOff(n.pitch),yield Ze.overwrite(n,{position:$(o.warp(n.position),e,t)})}*iterateActiveNotesAt(e,t){if(this.#i.isEmpty())return;let r=this.#i.unwrap(),s=this.#r.mapOr(gi,Ai.Identity);for(let o of r.iterateActiveNotesAt(s.unwarp(e),t))yield Ze.overwrite(o,{position:s.warp(o.position)})}reset(){this.eventInput.clear()}parameterChanged(e){}handleEvent(e,t){}processEvents(e,t,r){}};var Go=class extends ze{#t;#e;#r=p.None;constructor(e,t){super(e),this.#t=t,this.#e=this.own(new st(e.broadcaster,t.address)),this.own(e.registerProcessor(this)),this.readAllParameters()}setNoteEventSource(e){return b(this.#r.isEmpty(),"NoteEventSource already set"),this.#r=p.wrap(e),O.create(()=>this.#r=p.None)}get uuid(){return this.#t.uuid}get incoming(){return this}get outgoing(){return this}*processNotes(e,t,r){if(!this.#r.isEmpty())for(let s of this.#r.unwrap().processNotes(e,t,r))yield s}*iterateActiveNotesAt(e,t){if(!this.#r.isEmpty())for(let r of this.#r.unwrap().iterateActiveNotesAt(e,t))yield r}reset(){this.eventInput.clear()}processEvents(e,t,r){}parameterChanged(e){}handleEvent(e,t){}index(){return this.#t.indexField.getValue()}adapter(){return this.#t}};var Wo=class{attackSamples;decaySamples;sustainLevel;releaseSamples;#t=0;#e=0;#r=0;#i=0;constructor(e,t,r,s){this.attackSamples=e*sampleRate,this.decaySamples=t*sampleRate,this.sustainLevel=Math.max(0,Math.min(1,r)),this.releaseSamples=s*sampleRate}get isComplete(){return this.#t===4}release(){this.#t!==4&&this.#t!==3&&(this.#i=this.#r,this.#t=3,this.#e=0)}process(){switch(this.#t){case 0:this.attackSamples<=0?(this.#r=1,this.#t=1,this.#e=0):(this.#r=this.#e++/this.attackSamples,this.#r>=1&&(this.#r=1,this.#t=1,this.#e=0));break;case 1:this.decaySamples<=0?(this.#r=this.sustainLevel,this.#t=2,this.#e=0):(this.#r=1-this.#e++/this.decaySamples*(1-this.sustainLevel),this.#r<=this.sustainLevel&&(this.#r=this.sustainLevel,this.#t=2,this.#e=0));break;case 2:this.#r=this.sustainLevel;break;case 3:this.releaseSamples<=0?(this.#r=0,this.#t=4):(this.#r=this.#i*(1-this.#e++/this.releaseSamples),(this.#r<=.001||this.#e>=this.releaseSamples)&&(this.#r=0,this.#t=4));break;case 4:this.#r=0;break}return this.#r}};var jo=(i,e)=>(i[e]??i[e.toString()])?.value,pi=(i,e,t)=>jo(e,t)??jo(i,t),Qo=class{event;sampleData;envelope;rootKey;sampleRate;loopStart;loopEnd;pan;shouldLoop;playbackPosition=0;isReleasing=!1;constructor(e,t,r,s){this.event=e;let o=t.generators,n=r?.generators,a=jo(n,53)??0,l=r?.sample??s.samples[a];this.sampleData=l.data,this.rootKey=jo(n,58)??l?.header.originalPitch??60,this.sampleRate=l?.header.sampleRate??sampleRate,this.loopStart=l?.header.startLoop??0,this.loopEnd=l?.header.endLoop??this.sampleData.length;let c=pi(o,n,54)??0;this.shouldLoop=c===1||c===3,this.pan=(pi(o,n,17)??0)/1e3;let d=pi(o,n,34),m=pi(o,n,36),f=pi(o,n,37),y=pi(o,n,38),B=Ki(d)?Math.pow(2,d/1200):.005,S=Ki(m)?Math.pow(2,m/1200):.005,R=1-(f??0)/1e3,k=Ki(y)?Math.pow(2,y/1200):.005;this.envelope=new Wo(B,S,R,k)}release(){this.isReleasing=!0,this.envelope.release()}processAdd(e,t,r){let o=wi(this.event.pitch+this.event.cent/100,440)/wi(this.rootKey,440)*(this.sampleRate/sampleRate),n=Pr(this.event.velocity),a=Math.cos((this.pan+1)*Math.PI/4),l=Math.sin((this.pan+1)*Math.PI/4),c=e.getChannel(0),d=e.getChannel(1);for(let m=t;m<r;m++){let f=Math.floor(this.playbackPosition),y=this.envelope.process(),S=this.#t(f)/32768*n*y;if(c[m]+=S*a,d[m]+=S*l,this.playbackPosition+=o,this.shouldLoop)this.playbackPosition>=this.loopEnd&&this.loopEnd>this.loopStart&&(this.playbackPosition=this.loopStart+(this.playbackPosition-this.loopEnd));else if(this.playbackPosition>=this.sampleData.length-1)return!0}return this.envelope.isComplete}#t(e){if(e>=this.sampleData.length-1)return this.sampleData[this.sampleData.length-1];let t=this.playbackPosition-e;return this.sampleData[e]*(1-t)+this.sampleData[e+1]*t}};var Yo=class extends he{#t;#e;#r;#i;#s;#o=p.None;constructor(e,t){super(e),this.#t=t,this.#e=[],this.#r=new nt(this,e.broadcaster,t.audioUnitBoxAdapter().address),this.#i=new re,this.#s=this.own(new se(e.broadcaster,t.address)),this.ownAll(e.registerProcessor(this),t.box.file.catchupAndSubscribe(r=>this.#o=r.targetVertex.map(({box:s})=>e.soundfontManager.getOrCreate(s.address.uuid))))}introduceBlock(e){this.#r.introduceBlock(e)}setNoteEventSource(e){return this.#r.setNoteEventSource(e)}get noteEventTarget(){return p.wrap(this)}get incoming(){return this}get outgoing(){return this}get uuid(){return this.#t.uuid}get audioOutput(){return this.#i}get adapter(){return this.#t}reset(){this.#r.clear(),this.#s.clear(),this.#e.length=0,this.#i.clear(),this.eventInput.clear()}handleEvent(e){let t=this.#o.flatMap(s=>s.soundfont);if(t.isEmpty())return;let r=t.unwrap();if(Q.isStart(e)){let s=r.presets[this.#t.presetIndex]??r.presets[0];if(Li(s)){console.warn("No preset available");return}let o=0;for(let n of s.zones){let a=Math.round(e.velocity*127);if(this.#n(e.pitch,a,n)){let l=n.instrument.zones;for(let c=0;c<l.length;c++){let d=l[c];this.#n(e.pitch,a,d)&&(this.#e.push(new Qo(e,n,d,r)),o++)}}}}else Q.isStop(e)&&this.#e.forEach(s=>s.event.id===e.id&&s.release())}processAudio(e,t,r){this.#i.clear(t,r);for(let s=this.#e.length-1;s>=0;s--)this.#e[s].processAdd(this.#i,t,r)&&this.#e.splice(s,1)}finishProcess(){this.#i.assertSanity(),this.#s.process(this.#i.getChannel(0),this.#i.getChannel(1))}toString(){return"{SoundfontDevice}"}#n(e,t,r){return this.#a(r.generators[44]?.range,t)&&this.#a(r.generators[43]?.range,e)}#a(e,t){return Ui(e)||t>=e.lo&&t<=e.hi}};var Hn;(e=>e.create=(t,r)=>r.accept({visitAudioBusBox:s=>new hi(t,t.boxAdapters.adapterFor(s,Ve)),visitVaporisateurDeviceBox:s=>new Po(t,t.boxAdapters.adapterFor(s,ei)),visitNanoDeviceBox:s=>new Oo(t,t.boxAdapters.adapterFor(s,ri)),visitTapeDeviceBox:s=>new So(t,t.boxAdapters.adapterFor(s,Jr)),visitPlayfieldDeviceBox:s=>new zo(t,t.boxAdapters.adapterFor(s,Gt)),visitSoundfontDeviceBox:s=>new Yo(t,t.boxAdapters.adapterFor(s,li))}))(Hn||={});var Gn;(e=>e.create=(t,r)=>K(r.accept({visitUnknownMidiEffectDeviceBox:s=>new Go(t,t.boxAdapters.adapterFor(s,ai)),visitArpeggioDeviceBox:s=>new Ro(t,t.boxAdapters.adapterFor(s,Ht)),visitPitchDeviceBox:s=>new Mo(t,t.boxAdapters.adapterFor(s,ti)),visitZeitgeistDeviceBox:s=>new Ho(t,t.boxAdapters.adapterFor(s,oi))}),`Could not create midi-effect for'${r.name}'`))(Gn||={});var Ti;(e=>e.create=(t,r)=>K(r.accept({visitUnknownAudioEffectDeviceBox:s=>new Ii(t,t.boxAdapters.adapterFor(s,ni)),visitStereoToolDeviceBox:s=>new _o(t,t.boxAdapters.adapterFor(s,si)),visitDelayDeviceBox:s=>new No(t,t.boxAdapters.adapterFor(s,xt)),visitReverbDeviceBox:s=>new To(t,t.boxAdapters.adapterFor(s,qr)),visitRevampDeviceBox:s=>new Vo(t,t.boxAdapters.adapterFor(s,zr)),visitModularDeviceBox:s=>new Ii(t,t.boxAdapters.adapterFor(s,zt))}),`Could not create audio-effect for'${r.name}'`))(Ti||={});var Xo=class extends he{#t;#e;#r;#i;#s;#o;#n=p.None;#a=!0;#l=!1;constructor(e,t){super(e),this.#t=t,this.#e=new re,this.#r=Qe.linear(sampleRate),this.#i=Qe.linear(sampleRate),this.#s=this.own(this.bindParameter(t.sendGain)),this.#o=this.own(this.bindParameter(t.sendPan)),this.own(e.registerProcessor(this)),this.readAllParameters()}reset(){this.#e.clear()}get adapter(){return this.#t}setAudioSource(e){return this.#n=p.wrap(e),{terminate:()=>this.#n=p.None}}get audioOutput(){return this.#e}processAudio(e,t,r){if(this.#n.isEmpty())return;if(this.#a){let c=Ae(this.#s.getValue()),d=this.#o.getValue();this.#r.set((1-Math.max(0,d))*c,this.#l),this.#i.set((1+Math.min(0,d))*c,this.#l),this.#a=!1}let s=this.#e.getChannel(0),o=this.#e.getChannel(1),n=this.#n.unwrap(),a=n.getChannel(0),l=n.getChannel(1);if(this.#r.isInterpolating()||this.#i.isInterpolating())for(let c=t;c<r;c++)s[c]=a[c]*this.#r.moveAndGet(),o[c]=l[c]*this.#i.moveAndGet();else{let c=this.#r.get(),d=this.#i.get();for(let m=t;m<r;m++)s[m]=a[m]*c,o[m]=l[m]*d}this.#l=!0}parameterChanged(e){this.#a=!0}};var Zo=class extends he{#t;#e;#r;#i;#s;#o;#n;#a;#l=Qe.linear(sampleRate);#u=Qe.linear(sampleRate);#c=Qe.linear(sampleRate);#d=p.None;#h=!0;#p=!1;constructor(e,t){super(e),this.#t=t,this.#e=new re,this.#r=[new Float32Array(128),new Float32Array(128)],this.#i=this.own(new se(e.broadcaster,this.#t.address)),this.#s=this.own(this.bindParameter(this.#t.namedParameter.volume)),this.#o=this.own(this.bindParameter(this.#t.namedParameter.panning)),this.#n=this.own(this.bindParameter(this.#t.namedParameter.mute)),this.#a=this.own(this.bindParameter(this.#t.namedParameter.solo)),this.ownAll(e.registerProcessor(this),e.mixer.attachChannelStrip(this)),this.readAllParameters()}reset(){this.#i.clear(),this.#e.clear(),this.#r[0].fill(0),this.#r[1].fill(0),this.#p=!1}get isMute(){return this.#n.getValue()}get isSolo(){return this.#a.getValue()}get adapter(){return this.#t}get audioOutput(){return this.#e}handleEvent(e){}processAudio(e,t,r){if(this.#d.isEmpty())return;if(this.#h){let m=this.context.mixer;m.updateSolo();let f=this.isSolo||m.isVirtualSolo(this),y=this.isMute||m.hasChannelSolo()&&!f&&!this.#t.isOutput,B=Ae(this.#s.getValue()),S=this.#o.getValue();this.#l.set((1-Math.max(0,S))*B,this.#p),this.#u.set((1+Math.min(0,S))*B,this.#p),this.#c.set(y?0:1,this.#p),this.#h=!1}let s=this.#d.unwrap(),[o,n]=s.channels(),[a,l]=this.#e.channels(),[c,d]=this.#r;if(this.#l.isInterpolating()||this.#u.isInterpolating()||this.#c.isInterpolating())for(let m=t;m<r;m++){let f=this.#c.moveAndGet(),y=o[m]*this.#l.moveAndGet(),B=n[m]*this.#u.moveAndGet();a[m]=y*f,l[m]=B*f,c[m]=y,d[m]=B}else{let m=this.#l.get(),f=this.#u.get(),y=this.#c.get();for(let B=t;B<r;B++){let S=o[B]*m,R=n[B]*f;c[B]=S,d[B]=R,a[B]=S*y,l[B]=R*y}}this.#i.process(c,d,t,r),this.#p=!0}finishProcess(){this.#e.assertSanity()}parameterChanged(e){e===this.#s?this.requestGainUpdate():e===this.#o?this.requestGainUpdate():e===this.#n?this.requestGainUpdate():e===this.#a&&this.context.mixer.onChannelStripSoloChanged(this)}requestGainUpdate(){this.#h=!0}requestSoloUpdate(){this.#h=!0}setAudioSource(e){return this.#d=p.wrap(e),{terminate:()=>this.#d=p.None}}toString(){return`{${this.constructor.name}}`}};var Jo=class{#t=new I;#e;#r;#i;#s;#o;#n;#a=[];#l=!1;constructor(e,t){this.#e=e,this.#r=t,this.#i=A.newSet(r=>r.adapter.uuid),this.#s=this.#t.own(new Zo(this.#e.context,this.#e.adapter)),this.#o=A.newSet(({device:r})=>r.uuid),this.#n=this.#t.own(new I),this.#t.ownAll(this.#e.adapter.audioEffects.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=Ti.create(this.#e.context,r.box),o=this.#o.add({device:s,subscription:s.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(o,"Could not add.")},onRemove:r=>{this.invalidateWiring();let{device:s,subscription:o}=this.#o.removeByKey(r.uuid);o.terminate(),s.terminate()},onReorder:r=>this.invalidateWiring()}),this.#e.adapter.auxSends.catchupAndSubscribe({onAdd:r=>{this.invalidateWiring();let s=this.#i.add(new Xo(this.#e.context,r));b(s,"Could not add.")},onRemove:({uuid:r})=>{this.invalidateWiring(),this.#i.removeByKey(r).terminate()},onReorder:r=>{}}),this.#e.adapter.output.catchupAndSubscribe(r=>this.invalidateWiring()),this.#e.context.subscribeProcessPhase(r=>{r===0&&this.#l&&(this.#u(),this.#l=!1)}))}get channelStrip(){return this.#s}invalidateWiring(){this.#n.terminate(),this.#l=!0}terminate(){this.#t.terminate(),this.#o.forEach(({device:e})=>e.terminate()),this.#o.clear(),this.#a=[]}toString(){return`{${this.constructor.name}}`}#u(){let e=this.#e.adapter.isOutput,t=this.#e.context,r=this.#e.input(),s=this.#e.adapter.output.adapter.map(n=>t.getAudioUnit(n.deviceHost().uuid).inputAsAudioBus());if(r.isEmpty()||s.isEmpty()&&!e)return;let o=r.unwrap();if(this.#r.includeAudioEffects){w.replace(this.#a,this.#e.adapter.audioEffects.adapters().map(({uuid:n})=>this.#o.get(n).device));for(let n of this.#a)n.adapter().enabledField.getValue()&&(this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n.incoming)),o=n)}if(this.#r.includeSends&&this.#i.forEach(n=>{let a=t.getAudioUnit(n.adapter.targetBus.deviceHost().uuid);this.#n.own(n.setAudioSource(o.audioOutput)),this.#n.own(a.inputAsAudioBus().addAudioSource(n.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,n)),this.#n.own(t.registerEdge(n,a.inputAsAudioBus()))}),this.#n.own(this.#s.setAudioSource(o.audioOutput)),this.#n.own(t.registerEdge(o.outgoing,this.#s)),s.nonEmpty()&&!e){let n=s.unwrap();this.#n.own(n.addAudioSource(this.#s.audioOutput)),this.#n.own(t.registerEdge(this.#s,n))}}};var en=class{#t=new I;#e;#r;#i;#s;#o;constructor(e,t){this.#e=e,this.#r=t,this.#i=Wi.create(268431651),this.#s=new Set,this.#o=new Fr,this.#t.ownAll(this.#e.subscribeProcessPhase(r=>{if(r===1)for(let s of this.#s)s.gate||this.#s.delete(s)}))}get uuid(){return this.#r.uuid}terminate(){this.#t.terminate()}pushRawNoteOn(e,t){this.#s.add({pitch:e,velocity:t,gate:!0,running:p.None})}pushRawNoteOff(e){for(let t of this.#s)if(t.running.isEmpty())this.#s.delete(t);else if(t.pitch===e){t.gate=!1;return}}*processNotes(e,t,r){let s=ye.every(r,5);if(this.#o.nonEmpty()&&(!s||ye.every(r,2)?yield*this.#u(e):yield*this.#c(e,t)),this.#s.size>0)for(let o of this.#s){if(o.running.isEmpty()){let{pitch:n,velocity:a}=o,l=Number.POSITIVE_INFINITY,c=Q.start(e,l,n,a);o.running=p.wrap(c),yield c}o.gate||(this.#s.delete(o),yield Q.stop(o.running.unwrap("raw note never started"),e))}if(s){let o=this.#r.tracks.collection.adapters().filter(n=>n.type===X.Notes&&n.enabled.getValue());for(let n of o)for(let{optClip:a,sectionFrom:l,sectionTo:c}of this.#e.clipSequencing.iterate(n.uuid,e,t))a.isEmpty()?yield*this.#a(n,l,c):yield*this.#n(a.unwrap(),l,c);yield*this.#c(e,t)}}*iterateActiveNotesAt(e,t){if(this.#s.size>0)for(let{pitch:r,velocity:s}of this.#s)yield{type:"note-event",position:e,duration:Number.POSITIVE_INFINITY,pitch:r,velocity:s,cent:0};t||(yield*this.#o.overlapping(e,Me.Comparator))}reset(){this.#o.clear(),this.#s.clear()}toString(){return`{${this.constructor.name}}`}*#n(e,t,r){if(e.optCollection.isEmpty())return;let s=e.optCollection.unwrap(),o=e.duration,n=lt(t,o),a=n+o;r>a?(yield*this.#l(s,t,a,n),yield*this.#l(s,a,r,a)):yield*this.#l(s,t,r,n)}*#a(e,t,r){for(let s of e.regions.collection.iterateRange(t,r)){if(this.#e.ignoresRegion(s.address.uuid)||s.mute||!ae(s,Lt))continue;let o=s.optCollection;if(o.isEmpty())continue;let n=o.unwrap();for(let{resultStart:a,resultEnd:l,rawStart:c}of Ie.locateLoops(s,t,r))yield*this.#l(n,a,l,c)}}*#l(e,t,r,s){let o=t-s,n=r-s;for(let a of e.events.iterateRange(o-e.maxDuration,n)){if(!Me.isOfType(a))continue;let{position:l,duration:c,chance:d,playCount:m,playCurve:f}=a;if(!(d<100&&this.#i.nextDouble(0,100)>d)){if(m>1){let y=Me.inverseCurveFunc((o-l)/c,f),B=Me.inverseCurveFunc((n-l)/c,f),S=Math.floor(y*m),R=S/m;for(;R<B;){if(R>=y){let k=Me.curveFunc(R,f)*c;if(k>=c)break;let L=Me.curveFunc(R+1/m,f)*c,z=Q.startWith(a,l+k+s,L-k);this.#o.addAndRetain({...z}),yield z}R=++S/m}}else if(o<=l&&l<n){let y=Q.startWith(a,l+s);this.#o.addAndRetain({...y}),yield y}}}}*#u(e){for(let t of this.#o.releaseAll())yield Q.stop(t,e)}*#c(e,t){for(let r of this.#o.releaseLinearCompleted(t)){let s=$(r.position+r.duration,e,t);yield Q.stop(r,s)}}};var tn=class{#t=new I;#e;#r;#i;#s;#o=!1;constructor(e){this.#e=e,this.#r=this.#t.own(new en(this.#e.context,this.#e.adapter)),this.#i=A.newSet(({device:t})=>t.uuid),this.#s=this.#t.own(new I),this.#t.ownAll(this.#e.adapter.midiEffects.catchupAndSubscribe({onAdd:t=>{this.invalidateWiring();let r=Gn.create(this.#e.context,t.box),s=this.#i.add({device:r,subscription:r.adapter().enabledField.subscribe(()=>this.invalidateWiring())});b(s,"Could not add.")},onRemove:t=>{this.invalidateWiring();let{device:r,subscription:s}=this.#i.removeByKey(t.uuid);s.terminate(),r.terminate()},onReorder:t=>this.invalidateWiring()}),this.#e.context.subscribeProcessPhase(t=>{t===0&&this.#o&&(this.#n(),this.#o=!1)}))}get noteSequencer(){return this.#r}invalidateWiring(){this.#s.terminate(),this.#o=!0}terminate(){this.#t.terminate()}toString(){return`{${this.constructor.name}}`}#n(){let e=this.#e.input().flatMap(s=>s.noteEventTarget);if(e.isEmpty())return;let t=e.unwrap(),r=this.#r;this.#e.adapter.midiEffects.adapters().map(s=>this.#i.get(s.uuid).device).forEach(s=>{s.adapter().enabledField.getValue()&&(this.#s.ownAll(s.setNoteEventSource(r),this.#e.context.registerEdge(s,t.incoming)),r=s)}),this.#s.own(t.setNoteEventSource(r))}};var rn=class i{static ID=0;#t=i.ID++;#e=new I;#r;#i;#s;#o;#n=p.None;constructor(e,t,r){this.#r=e,this.#i=t,this.#s=this.#e.own(new tn(this)),this.#o=this.#e.own(new Jo(this,r)),this.#e.ownAll(this.#i.input.catchupAndSubscribe(s=>{this.#s.invalidateWiring(),this.#o.invalidateWiring(),this.#n.ifSome(o=>o.terminate()),this.#n=s.getValue().flatMap(o=>p.wrap(Hn.create(e,o.box.box)))}))}input(){return this.#n}inputAsAudioBus(){return er(this.#n.unwrap("No input available"),hi)}audioOutput(){return this.#o.channelStrip.audioOutput}get midiDeviceChain(){return this.#s}get audioDeviceChain(){return this.#o}get context(){return this.#r}get adapter(){return this.#i}terminate(){console.debug(`terminate ${this}`),this.#e.terminate(),this.#n.ifSome(e=>e.terminate()),this.#n=p.None}toString(){return`{${this.constructor.name}(${this.#t})}`}};var sn=class{#t;#e;#r;#i=!1;constructor(){this.#t=A.newSet(e=>e.adapter.uuid),this.#e=new Set,this.#r=new Set}attachChannelStrip(e){return this.#t.add(e),O.many(e.adapter.input.subscribe(()=>this.#s()),e.adapter.output.subscribe(()=>this.#s()),{terminate:()=>{this.#e.delete(e),this.#t.removeByValue(e),this.#s()}})}onChannelStripSoloChanged(e){e.isSolo?this.#e.add(e):this.#e.delete(e),this.#s()}hasChannelSolo(){return this.#e.size>0}isVirtualSolo(e){return this.#r.has(e)}#s(){this.#i||(this.#i=!0,this.#t.forEach(e=>e.requestSoloUpdate()))}updateSolo(){if(!this.#i)return;this.#r.clear();let e=new Set,t=r=>{e.has(r)||(e.add(r),r.adapter.input.getValue().ifSome(s=>{s.type==="bus"&&s.box.input.pointerHub.filter(u.AudioOutput).map(o=>K(o.box.accept({visitAudioUnitBox:({address:{uuid:n}})=>this.#t.get(n),visitAuxSendBox:({audioUnit:{targetVertex:n}})=>this.#t.get(n.unwrap().address.uuid)}),"Could not resolve channel-strip")).forEach(o=>{o.isSolo||this.#r.add(o),t(o)})}))};this.#t.forEach(r=>{r.isSolo&&t(r)}),this.#i=!1}};var Qt;(function(i){let e=typeof self<"u"&&"location"in self&&typeof self.location!==void 0,t=typeof self<"u"&&"navigator"in self&&typeof self.navigator!==void 0;i.isLocalHost=()=>e&&location.host.includes("localhost"),i.isMacOS=()=>t&&navigator.userAgent.includes("Mac OS X"),i.isWindows=()=>t&&navigator.userAgent.includes("Windows"),i.isFirefox=()=>t&&navigator.userAgent.toLowerCase().includes("firefox"),i.isWeb=()=>!i.isTauriApp(),i.isVitest=typeof process<"u"&&process.env?.VITEST==="true",i.isTauriApp=()=>"__TAURI__"in window,i.userAgent=t?navigator.userAgent.replace(/^Mozilla\/[\d.]+\s*/,"").replace(/\bAppleWebKit\/[\d.]+\s*/g,"").replace(/\(KHTML, like Gecko\)\s*/g,"").replace(/\bSafari\/[\d.]+\s*/g,"").replace(/\s+/g," ").trim():"N/A",i.id=()=>{if(!e)return"";let r="__id__",s=localStorage.getItem(r);if(V(s))return s;let o=A.toString(A.generate());return localStorage.setItem(r,o),o}})(Qt||(Qt={}));var el;(function(i){i.encode=async(e,t="gzip")=>{let r=new CompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()},i.decode=async(e,t="gzip")=>{let r=new DecompressionStream(t),s=r.writable.getWriter();return s.write(new Uint8Array(e)),s.close(),new Response(r.readable).arrayBuffer()}})(el||(el={}));var tl;(function(i){i.exportMethod=(s,o)=>r(s,{value:o}),i.exportBoolean=(s,o=!1)=>{let n=new Ce(o);return i.exportAccessor(s,()=>n.getValue(),a=>{let l=!!a;console.debug(`set to ${l}`),n.setValue(l)}),n},i.exportAccessor=(s,o,n=ra)=>r(s,{get:()=>{try{return console.debug(o()),0}catch(a){return console.error(a),1}},set:a=>{try{return n(a),o()}catch(l){return console.error(l),1}},enumerable:!1,configurable:!1});let e=(()=>{try{return self}catch{return{}}})(),t=e.opendaw??={},r=(s,o)=>{let n=s.split("."),a=n.splice(-1)[0],l=t;for(let c of n)l=l[c]??={};Object.defineProperty(l,a,o),console.debug(`Console command 'opendaw.${s}' exported`)}})(tl||(tl={}));var rl;(function(i){i.resolveString=e=>{if(!Li(e)){if(typeof e=="string")return e;if(Array.isArray(e))return e.join(",");if(typeof e=="object"){if(typeof e.exact=="string")return e.exact;if(Array.isArray(e.exact))return e.exact.join(",");if(typeof e.ideal=="string")return e.ideal;if(Array.isArray(e.ideal))return e.ideal.join(",")}}}})(rl||(rl={}));var il;(function(i){i.truncateText=(e,t,r)=>{if(t.length===0)return{text:"",width:0};let s=e.measureText(t).width;if(s<=r)return{text:t,width:s};let o=e.measureText("\u2026").width,n=0,a=t.length|0;for(;n<a;){let c=a+n>>>1;s=e.measureText(t.substring(0,c+1)).width+o,s<=r?n=c+1:a=c}if(n===0)return{text:"",width:0};let l=t.substring(0,n);return{text:l+"\u2026",width:e.measureText(l).width+o}}})(il||(il={}));var sl;(function(i){i.calc=(t,r,s)=>{let o=/([0-9]*\.?[0-9]+)([a-zA-Z%]*)/g,n=t;return n.split(/\+|(?<!\d)-/).flatMap(a=>Array.from(a.matchAll(o))).forEach(([a,l,c])=>{let d=parseFloat(l);if(isNaN(d))return g(`${a} does not contain a number`);if(c==="em")n=n.replaceAll(a,`${d*s}`);else if(c==="%")n=n.replaceAll(a,`${d/100*r}`);else if(c==="px")n=n.replaceAll(a,`${d}`);else return g(`Unknown unit '${c}'`)}),Function(`return ${n}`)()};let e=new Map;i.registerCustomCursor=(t,r)=>e.set(t,r),i.setCursor=(t,r=document)=>{r.documentElement.style.cursor=typeof t=="number"?e.get(t)??"auto":t}})(sl||(sl={}));var ki;(function(i){let e=new Set,t=new Set,r=new Array,s=-1,o=null;i.add=n=>(t.add(n),{terminate:()=>t.delete(n)}),i.once=n=>{e.add(n)},i.start=n=>{let a=()=>{o===n&&((t.size>0||e.size>0)&&(t.forEach(l=>r.push(l)),e.forEach(l=>r.push(l)),e.clear(),r.forEach(l=>l()),r.length=0),s=n.requestAnimationFrame(a))};s=n.requestAnimationFrame(a),o=n,a()},i.terminate=()=>{console.debug("AnimationFrame terminate"),e.clear(),t.clear(),r.length=0,cancelAnimationFrame(s)}})(ki||(ki={}));var Oe=class{static subscribe(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static subscribeAny(e,t,r,s){return e.addEventListener(t,r,s),{terminate:()=>e.removeEventListener(t,r,s)}}static DOUBLE_DOWN_THRESHOLD=200;static subscribeDblDwn=(e,t)=>{let r=0;return this.subscribe(e,"pointerdown",s=>{let o=performance.now();o-r<this.DOUBLE_DOWN_THRESHOLD&&t(s),r=o},{capture:!0})};static PreventDefault=e=>e.preventDefault();static isTextInput=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&V(e.getAttribute("contenteditable"))};var Yt;(function(i){i.isControlKey=({ctrlKey:e,metaKey:t})=>Qt.isMacOS()?t:e,i.isCopyKey=({altKey:e})=>e,i.GlobalShortcut=Object.freeze({isDelete:e=>!Oe.isTextInput(e.target)&&(e.code==="Delete"||e.code==="Backspace"),isSelectAll:e=>i.isControlKey(e)&&!e.shiftKey&&e.code==="KeyA",isDeselectAll:e=>i.isControlKey(e)&&e.shiftKey&&e.code==="KeyA"})})(Yt||(Yt={}));var ol;(function(i){i.attach=(e,t,r)=>{let s=new I;return O.many(s,Oe.subscribe(e,"pointerdown",o=>{if(r?.multiTouch!==!0&&!o.isPrimary||o.buttons!==1||Qt.isMacOS()&&o.ctrlKey)return;let n=t(o);if(n.isEmpty())return;let a=n.unwrap(),l=o.pointerId;o.stopPropagation(),o.stopImmediatePropagation(),e.setPointerCapture(l);let c={clientX:o.clientX,clientY:o.clientY,altKey:o.altKey,shiftKey:o.shiftKey,ctrlKey:Yt.isControlKey(o)};r?.immediate===!0&&a.update(c),r?.permanentUpdates===!0?(s.own(ki.add(()=>a.update(c))),s.own(Oe.subscribe(e,"pointermove",f=>{f.pointerId===l&&(c.clientX=f.clientX,c.clientY=f.clientY,c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f))}))):s.own(Oe.subscribe(e,"pointermove",f=>{f.pointerId===l&&(c.clientX=f.clientX,c.clientY=f.clientY,c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),a.update(c))}));let d=()=>{a.cancel?.call(a),a.finally?.call(a),s.terminate()},m=ea(e,"ownerDocument","defaultView")??self;s.ownAll(Oe.subscribe(e,"pointerup",f=>{f.pointerId===l&&(a.approve?.call(a),a.finally?.call(a),s.terminate())},{capture:!0}),Oe.subscribe(e,"pointercancel",f=>{console.debug(f.type),f.pointerId===l&&(e.releasePointerCapture(l),d())},{capture:!0}),Oe.subscribe(m,"beforeunload",f=>{e.releasePointerCapture(l),d()},{capture:!0}),Oe.subscribe(m,"keydown",f=>{c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),f.key==="Escape"?d():a.update(c)}),Oe.subscribe(m,"keyup",f=>{c.altKey=f.altKey,c.shiftKey=f.shiftKey,c.ctrlKey=Yt.isControlKey(f),a.update(c)})),V(a.abortSignal)&&s.own(Oe.subscribe(a.abortSignal,"abort",()=>{e.releasePointerCapture(l),d()}))}))}})(ol||(ol={}));var nl;(function(i){i.save=async(e,t)=>{if(V(window.showSaveFilePicker)){let r=await window.showSaveFilePicker(t),s=await r.createWritable();return await s.truncate(0),await s.write(e),await s.close(),r.name??"unknown"}else{let r=new Blob([e]),s=URL.createObjectURL(r),o=document.createElement("a");return o.href=s,o.download=t?.suggestedName??"unknown",o.click(),URL.revokeObjectURL(s),t?.suggestedName??"Unknown"}},i.open=async e=>{if(V(window.showOpenFilePicker)){let{status:t,value:r,error:s}=await Mt.tryCatch(window.showOpenFilePicker(e));return t==="rejected"?Promise.reject(s):Promise.all(r.map(o=>o.getFile()))}else return new Promise((t,r)=>{V(e)&&console.warn("FileApi.showOpenFilePicker is emulated in this browser. OpenFilePickerOptions are ignored.");let s=document.createElement("input");s.type="file",s.multiple=e?.multiple??!1,s.style.display="none",s.addEventListener("cancel",async()=>{s.remove(),r(new DOMException("cancel","AbortError"))}),s.addEventListener("change",async o=>{let a=o.target.files;V(a)?t(w.create(l=>K(a.item(l),`No file at index ${l}`),a.length)):r(new DOMException("cancel","AbortError")),s.remove()}),document.body.appendChild(s),s.click()})}})(nl||(nl={}));var al;(function(i){i.parse=e=>{let t=document.createElement("div");if(t.innerHTML=e,t.childElementCount!==1)return g(`Source html has more than one root elements: '${e}'`);let r=t.firstChild;return r instanceof HTMLElement||r instanceof SVGSVGElement?r:g(`Cannot parse to HTMLOrSVGElement from '${e}'`)},i.empty=e=>{for(;e.firstChild!==null;)e.firstChild.remove()},i.query=(e,t=document)=>K(t.querySelector(e)),i.queryAll=(e,t=document)=>Array.from(t.querySelectorAll(e)),i.sanitize=e=>{e.querySelectorAll("script").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(r=>{r.name.toLowerCase().startsWith("on")&&t.removeAttribute(r.name)})})},i.nextID=(()=>{let e=0;return()=>(++e).toString(16).padStart(4,"0")})(),i.adoptStyleSheet=(e,t)=>{b(e.includes("component"),`No 'component' found in: ${e}`);let r=`${t??"C"}${i.nextID()}`,s=new CSSStyleSheet;return s.replaceSync(e.replaceAll("component",`.${r}`)),s.cssRules.length===0?g(`No cssRules found in: ${e}`):(document.adoptedStyleSheets.push(s),r)},i.buildClassList=(...e)=>e.filter(t=>t!==!1&&t!==void 0).join(" "),i.readCssVarColor=(...e)=>{let t=document.createElement("div");document.body.appendChild(t);let r=e.map(s=>(t.style.color=s,qi.parseCssRgbOrRgba(getComputedStyle(t).color)));return t.remove(),r},i.watchResize=(e,t,r)=>{let s=new ResizeObserver(([o],n)=>t(o,n));return s.observe(e,r),{terminate:()=>s.disconnect()}},i.watchIntersection=(e,t,r)=>{let s=new IntersectionObserver(t,r);return s.observe(e),{terminate:()=>s.disconnect()}},i.secureBoundingBox=e=>{let t=e.getBoundingClientRect();if(!yi.isEmpty(t))return t;for(let r of e.children)yi.union(t,i.secureBoundingBox(r));return t},i.unfocus=(e=self)=>{let t=e.document.activeElement;t!==null&&"blur"in t&&typeof t.blur=="function"&&t.blur()},i.selectContent=e=>{let t=document.createRange(),r=window.getSelection();V(r)&&(t.selectNodeContents(e),r.removeAllRanges(),r.addRange(t))},i.unselectContent=e=>{let t=window.getSelection();!V(t)||t.rangeCount===0||e.contains(t.getRangeAt(0).commonAncestorContainer)&&t.removeAllRanges()},i.limitChars=(e,t,r)=>{if(!(t in e))return g(`${t} not found in ${e}`);if(typeof e[t]!="string")return g(`${t} in ${e} is not a string`);if(e[t].length>r)if(e[t]=e[t].substring(0,r),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)e.setSelectionRange(r,r);else{let s=e.ownerDocument,o=s.createRange(),n=s.defaultView?.getSelection();if(!V(n))return;o.selectNodeContents(e),o.collapse(!1),n.removeAllRanges(),n.addRange(o)}},i.EmptyGif="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="})(al||(al={}));var Ek=(()=>{let i={Cmd:"\u2318",Opt:"\u2325",Shift:"\u21E7"},e={Cmd:"Ctrl",Opt:"Alt",Shift:"\u21E7"};return Object.freeze({Mac:i,Win:e,System:Qt.isMacOS()?i:e})})();var ll;(function(i){i.read=async e=>{let t=[];for(;;){let{done:n,value:a}=await e.read();if(n)break;t.push(a)}let r=t.reduce((n,a)=>n+a.length,0),s=new Uint8Array(r),o=0;for(let n of t)s.set(n,o),o+=n.length;return s.buffer}})(ll||(ll={}));var ul;(function(i){i.pathBuilder=()=>new class{#t="";moveTo(e,t){return this.#t+=`M${e.toFixed(3)} ${t.toFixed(3)}`,this}lineTo(e,t){return this.#t+=`L${e.toFixed(3)} ${t.toFixed(3)}`,this}quadratic(e,t,r,s){return this.#t+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)}`,this}quadraticTo(e,t){return this.#t+=`T${e.toFixed(3)} ${t.toFixed(3)}`,this}cubic(e,t,r,s,o,n){return this.#t+=`Q${e.toFixed(3)} ${t.toFixed(3)} ${r.toFixed(3)} ${s.toFixed(3)} ${o.toFixed(3)} ${n.toFixed(3)}`,this}arc(e,t,r,s,o,n,a){return this.#t+=`A${e} ${t} ${r} ${s?1:0} ${o?1:0} ${n.toFixed(3)} ${a.toFixed(3)}`,this}circleSegment(e,t,r,s,o){let n=e+Math.cos(s)*r,a=t+Math.sin(s)*r,l=e+Math.cos(o)*r,c=t+Math.sin(o)*r,d=o-s;for(;d<0;)d+=Math.PI*2;return this.moveTo(n,a).arc(r,r,0,d>Math.PI,!0,l,c)}close(){return this.#t+="Z",this}get(){return this.#t}}})(ul||(ul={}));var cl;(function(i){let e=new Array;i.watchWeak=(r,s)=>{let o=new WeakRef(r),n=s(o);return e.push([o,n]),e.length===1&&t(),r};let t=()=>{console.debug("start weak watching");let r=setInterval(()=>{let s=e.length;for(;--s>=0;){let o=e[s];o[0].deref()===void 0&&(o[1].terminate(),e.splice(s,1),e.length===0&&clearInterval(r))}},1e3)}})(cl||(cl={}));var on=Symbol.for("@openDAW/lib-dom");globalThis[on]?console.debug(`%c${on.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[on]=!0,console.debug(`%c${on.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var vt;(function(i){i[i.Float=0]="Float",i[i.FloatArray=1]="FloatArray",i[i.Integer=2]="Integer",i[i.IntegerArray=3]="IntegerArray",i[i.ByteArray=4]="ByteArray"})(vt||(vt={}));var mi;(function(i){i[i.WRITE=0]="WRITE",i[i.READ=1]="READ"})(mi||(mi={}));var yr;(function(i){i[i.ID=15793935]="ID",i[i.START=15790320]="START",i[i.END=986895]="END"})(yr||(yr={}));var nn=class i{static create(e,t){return new i(e.channel(t))}#t=[];#e=new SharedArrayBuffer(1);#r=new Int8Array(this.#e);#i;#s=pe.create(0);#o=p.None;#n=p.None;#a=-1;#l=-1;#u=!1;#c=!1;constructor(e){this.#i=De.sender(e,({dispatchAndForget:t})=>new class{sendShareLock(r){t(this.sendShareLock,r)}sendUpdateData(r){t(this.sendUpdateData,r)}sendUpdateStructure(r){t(this.sendUpdateStructure,r)}})}flush(){let e=this.#d();if(e.nonEmpty()){this.#c||(this.#i.sendShareLock(this.#e),this.#c=!0),this.#i.sendUpdateStructure(e.unwrap());let t=this.#h();if(this.#s.remaining<t){let r=ut(t),s=new SharedArrayBuffer(r);this.#s=pe.use(s),this.#o=p.wrap(s),this.#i.sendUpdateData(s)}}this.#o.isEmpty()||Atomics.load(this.#r,0)===mi.WRITE&&(this.#p(this.#s),this.#s.position=0,Atomics.store(this.#r,0,mi.READ))}broadcastFloat(e,t){return this.#f(new class{type=vt.Float;address=e;capacity=8;put(r){r.writeFloat(t())}})}broadcastInteger(e,t){return this.#f(new class{type=vt.Integer;address=e;capacity=8;put(r){r.writeInt(t())}})}broadcastFloats(e,t,r){return this.#f(new class{type=vt.FloatArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length);for(let o of t)s.writeFloat(o)}})}broadcastIntegers(e,t,r){return this.#f(new class{type=vt.IntegerArray;address=e;capacity=4+(t.byteLength<<2);put(s){r(),s.writeInt(t.length),t.forEach(o=>s.writeInt(o))}})}broadcastByteArray(e,t,r){return this.#f(new class{type=vt.ByteArray;address=e;capacity=4+t.byteLength;put(s){r(),s.writeInt(t.byteLength),s.writeBytes(t)}})}#d(){if(this.#u){try{this.#n=p.wrap(this.#v())}catch(e){throw e}this.#u=!1}if(this.#n.nonEmpty()){let e=this.#n;return this.#n=p.None,e}return p.None}#h(){return this.#l===-1&&(this.#l=this.#g()+12),this.#l}terminate(){w.clear(this.#t),this.#n=p.None,this.#u=!1,this.#l=0}#p(e){b(!this.#u&&this.#n.isEmpty(),"Cannot flush while update is available");let t=this.#h();b(e.remaining>=t,"Insufficient data"),e.writeInt(this.#a),e.writeInt(yr.START);for(let r of this.#t)r.put(e);e.writeInt(yr.END)}#g(){return this.#t.reduce((e,t)=>e+t.capacity,0)}#f(e){return this.#t.push(e),this.#x(),{terminate:()=>{w.removeOpt(this.#t,e),this.#x()}}}#x(){this.#l=-1,this.#u=!0}#v(){let e=pe.create();e.writeInt(yr.ID),e.writeInt(++this.#a),e.writeInt(this.#t.length);for(let{address:t,type:r}of this.#t)t.write(e),e.writeByte(r);return e.toArrayBuffer()}};var Xt;(function(i){class e{shift;numPeaks;dataOffset;constructor(r,s,o){this.shift=r,this.numPeaks=s,this.dataOffset=o}unitsEachPeak(){return 1<<this.shift}}i.Stage=e,i.unpack=(t,r)=>{switch(r){case 0:return wt.intBitsToFloat(t);case 1:return wt.intBitsToFloat(t>>16);default:return Ge(r)}}})(Xt||(Xt={}));var an=class i{stages;data;numFrames;numChannels;static from(e){b(e.readString()==="PEAKS","Wrong header");let t=e.readInt(),r=[];for(let l=0;l<t;l++){let c=e.readInt(),d=e.readInt(),m=e.readInt();e.readInt(),r[l]=new Xt.Stage(m,d,c)}let s=e.readInt(),o=[];for(let l=0;l<s;l++){let c=new Int8Array(e.readInt());e.readBytes(c),o[l]=new Int32Array(c.buffer)}let n=e.readInt(),a=e.readInt();return new i(r,o,n,a)}static None=new i([],[],0,0);static findBestFit=(e,t=1200)=>{let r=e/t;if(r<=1)return new Uint8Array(0);let s=3,o=Math.floor(Math.log(r)/Math.LN2),n=Math.max(1,Math.floor(o/s));return new Uint8Array(w.create(a=>s*(a+1),n))};constructor(e,t,r,s){this.stages=e,this.data=t,this.numFrames=r,this.numChannels=s}nearest(e){if(this.stages.length===0)return null;let t=Math.floor(Math.log(Math.abs(e))/Math.LN2),r=this.stages.length;for(;--r>-1;)if(t>=this.stages[r].shift)return this.stages[r];return this.stages[0]}toArrayBuffer(){let e=pe.create();e.writeString("PEAKS"),e.writeInt(this.stages.length);for(let t=0;t<this.stages.length;t++){let{dataOffset:r,numPeaks:s,shift:o}=this.stages[t];e.writeInt(r),e.writeInt(s),e.writeInt(o),e.writeInt((1<<o)-1)}e.writeInt(this.data.length);for(let t=0;t<this.data.length;t++){let r=new Int8Array(this.data[t].buffer);e.writeInt(r.length),e.writeBytes(r)}return e.writeInt(this.numFrames),e.writeInt(this.numChannels),e.toArrayBuffer()}toString(){return`{SamplePeaks num-stages: ${this.stages.length}}`}};var hl;(function(i){i.install=r=>De.executor(r.channel("peaks"),new class{async generateAsync(s,o,n,a,l){return e(s,o,n,a,l).toArrayBuffer()}});let e=(r,s,o,n,a)=>{if(o.length!==a)return g(`Invalid numberOfChannels. Expected: ${a}. Got ${o.length}`);class l{min=Number.POSITIVE_INFINITY;max=Number.NEGATIVE_INFINITY;index=0}let c=Ta(),d=s.length,[m,f]=t(s,n),y=w.create(()=>new Int32Array(f),a),B=(1<<m[0].shift)-1,S=a*n,R=0;for(let k=0;k<a;++k){let L=y[k],z=o[k],_=w.create(()=>new l,d),ie=Number.POSITIVE_INFINITY,de=Number.NEGATIVE_INFINITY,ce=0;for(let H=0;H<n;++H){let J=z[H];if(ie=Math.min(J,ie),de=Math.max(J,de),(++ce&B)===0){for(let U=0;U<d;++U){let Z=m[U],ee=_[U];ee.min=Math.min(ee.min,ie),ee.max=Math.max(ee.max,de),((1<<Z.shift)-1&ce)===0&&(L[Z.dataOffset+ee.index++]=i.pack(ee.min,ee.max),ee.min=Number.POSITIVE_INFINITY,ee.max=Number.NEGATIVE_INFINITY)}ie=Number.POSITIVE_INFINITY,de=Number.NEGATIVE_INFINITY}(++R&65535)===0&&r(R/S)}}return r(1),c.lab(`SamplePeaks '${self.constructor.name}'`),new an(m,y,n,a)},t=(r,s)=>{let o=0;return[w.create(a=>{let l=r[a],c=Math.ceil(s/(1<<l)),d=new Xt.Stage(l,c,o);return o+=c,d},r.length),o]};i.pack=(r,s)=>{let o=wt.floatToIntBits(r),n=wt.floatToIntBits(s);return o|n<<16}})(hl||(hl={}));var dl;(function(i){i.renderBlocks=(e,t,r,{u0:s,u1:o,v0:n,v1:a,x0:l,x1:c,y0:d,y1:m})=>{let f=(o-s)/(c-l),y=t.nearest(f);if(y===null)return;let B=(m-d-1)/(a-n),S=y.unitsEachPeak(),R=l-Math.floor(l),k=f/S,L=(s-R*f)/f*k,z=Math.floor(L),_=0,ie=0,de=t.data[r];for(let ce=Math.floor(l);ce<Math.floor(c);ce++){let H=L+k,J=Math.floor(H),U=!1;for(;z<J;){let Ee=de[y.dataOffset+z++];_=Math.min(Xt.unpack(Ee,0),_),ie=Math.max(Xt.unpack(Ee,1),ie),U=!0}let Z=d+Math.floor((_-n)*B),ee=d+Math.floor((ie-n)*B),ke=Math.max(d,Math.min(Z,ee)),_e=Math.min(m,Math.max(Z,ee));if(e.fillRect(ce,ke,1,_e===ke?1:_e-ke),U){let Ee=ie;ie=_,_=Ee}L=H,z=J}}})(dl||(dl={}));var pl;(function(i){i.init=r=>De.executor(r.channel("opfs"),new class{#t=new Map;async write(s,o){await this.#e(s,async()=>{let n=await this.#r(s,{create:!0});try{n.truncate(o.length),n.write(o.buffer,{at:0}),n.flush()}finally{n.close()}})}async read(s){return await this.#e(s,async()=>{let o=await this.#r(s);try{let n=o.getSize(),a=new Uint8Array(n);return o.read(a),a}finally{o.close()}})}async delete(s){await this.#e(s,async()=>{let o=t(s);return o.length===0?this.clear():this.#i(o.slice(0,-1)).then(n=>n.removeEntry(K(o.at(-1)),{recursive:!0}))})}async list(s){let o=t(s),{status:n,value:a}=await Mt.tryCatch(this.#i(o));if(n==="rejected")return w.empty();let l=[];for await(let{name:c,kind:d}of a.values())l.push({name:c,kind:d});return l}async clear(){let s=await navigator.storage.getDirectory();for await(let[o,n]of s.entries())n.kind==="file"?await s.removeEntry(o):n.kind==="directory"&&await s.removeEntry(o,{recursive:!0})}async#e(s,o){let n=this.#t.get(s);n&&await n;let a=()=>g("Lock not acquired"),l=new Promise(c=>a=c);this.#t.set(s,l);try{return await o()}finally{a(),this.#t.get(s)===l&&this.#t.delete(s)}}async#r(s,o){let n=t(s);return await(await(await this.#i(n.slice(0,-1),o)).getFileHandle(K(n.at(-1)),o)).createSyncAccessHandle()}async#i(s,o){let n=await navigator.storage.getDirectory();for(let a of s)n=await n.getDirectoryHandle(a,o);return n}});let t=r=>{let s=r.replace(/^\/+|\/+$/g,"");return s===""?[]:s.split("/")}})(pl||(pl={}));var ln=Symbol.for("@openDAW/lib-fusion");globalThis[ln]?console.debug(`%c${ln.description}%c is already available in ${globalThis.constructor.name}.`,"color: hsl(10, 83%, 60%)","color: inherit"):(globalThis[ln]=!0,console.debug(`%c${ln.description}%c is now available in ${globalThis.constructor.name}.`,"color: hsl(200, 83%, 60%)","color: inherit"));var un=class{#t;#e=new re;#r=[];constructor(e){this.#t=e}process({blocks:e}){e.forEach(({p0:t,p1:r,bpm:s,s0:o,s1:n,flags:a})=>{if(this.#t.metronomeEnabled&&ye.every(a,1))for(let l of St.iterate(t,r,W.Quarter)){b(t<=l&&l<r,`${l} out of bounds (${t}, ${r})`);let c=Math.floor(W.pulsesToSamples(l-t,s,sampleRate));this.#r.push(new Wn(l,o+c))}this.#e.clear(o,n);for(let l=this.#r.length-1;l>=0;l--)this.#r[l].processAdd(this.#e,o,n)&&this.#r.splice(l,1)})}get output(){return this.#e}},Wn=class{#t;#e=0;#r=0;constructor(e,t){b(t>=0&&t<128,`${t} out of bounds`),this.#t=W.toParts(e).beats===0?880:440,this.#r=t}processAdd(e,t,r){let[s,o]=e.channels(),n=Math.floor(.002*sampleRate),a=Math.floor(.05*sampleRate);for(let l=Math.max(this.#r,t);l<r;l++){let c=Math.min(this.#e/n,1-(this.#e-n)/a),d=Math.sin(this.#e/sampleRate*We*this.#t)*.25*c*c;if(s[l]+=d,o[l]+=d,++this.#e>n+a)return!0}return this.#r=0,!1}};var cn=class{#t;#e;#r=!0;#i=!1;#s=null;#o=!1;#n=0;constructor(e,t){this.#t=e,this.#t.timelineBoxAdapter.markerTrack.subscribe(()=>this.#o=!0),this.#t.timelineBoxAdapter.box.bpm.subscribe(()=>this.#i=!0),this.#r=t?.pauseOnLoopDisabled??!1,this.#e=new Hi}setCallback(e,t){return this.#e.add(e,t),O.create(()=>this.#e.remove(e,t))}reset(){this.#i=!1,this.#o=!1,this.#n=0,this.#s=null}process(e){let t=!1,{timeInfo:r,timelineBoxAdapter:{box:s,markerTrack:o}}=this.#t,n=s.bpm.getValue(),a=r.transporting;if(a){let l=[],c=r.position,d=0,m=0,f=r.getLeapStateAndReset();for(;d<128;){if(this.#o||f){this.#o=!1;let H=o.events.lowerEqual(c);(this.#s?.at(0)??null)!==H&&(this.#s=V(H)?[H,0]:null,t=!0)}let y=128-d,B=c+W.samplesToPulses(y,n,sampleRate),S=null,R=Number.POSITIVE_INFINITY;if(o.enabled){let H=Array.from(le.take(o.events.iterateFrom(c),2));if(H.length>0){let[J,U]=H;this.#s===null?J.position>=c&&J.position<B&&(S={type:"marker",prev:J,next:U},R=J.position):V(U)&&U!==this.#s[0]&&J.position<c&&U.position<B&&(S={type:"marker",prev:J,next:U},R=U.position)}}let{isRecording:k,isCountingIn:L}=this.#t.timeInfo,{from:z,to:_,enabled:ie}=s.loopArea;if(ie.getValue()&&!(k||L)||this.#r){let H=_.getValue();c<H&&B>H&&H<R&&(S={type:"loop",target:z.getValue()},R=H)}if(this.#e.keyCount()>0)for(let H of this.#e.keys())c<H&&B>H&&H<R&&(S={type:"callback",position:H,callbacks:this.#e.get(H)},R=H);let ce=!r.isCountingIn;if(S===null){let H=d+y;l.push({index:m++,p0:c,p1:B,s0:d,s1:H,bpm:n,flags:ui.create(a,f,ce,this.#i)}),f=!1,c=B,d=H}else{let H=()=>{if(R>c){let U=d+W.pulsesToSamples(R-c,n,sampleRate)|0;l.push({index:m++,p0:c,p1:R,s0:d,s1:U,bpm:n,flags:ui.create(a,f,ce,this.#i)}),f=!1,c=R,d=U}},J=()=>{if(d<128){let U=d+W.pulsesToSamples(B-c,n,sampleRate)|0;l.push({index:m++,p0:c,p1:R,s0:d,s1:U,bpm:n,flags:ui.create(!1,!1,!1,this.#i)}),d=U}};switch(S.type){case"loop":{H(),this.#r?(this.#t.timeInfo.pause(),J()):(c=S.target,f=!0);break}case"marker":{let{prev:U,next:Z}=S;!V(this.#s)||this.#s[0]!==U?this.#s=[U,0]:++this.#s[1]<U.plays||U.plays===0?(H(),c=U.position,f=!0):this.#s=[Z,0],t=!0;break}case"callback":{H(),S.callbacks.forEach(U=>U());break}}}this.#i=!1}e({blocks:l}),r.advanceTo(c),this.#n=c}else{if(this.#o||r.getLeapStateAndReset()){this.#o=!1;let m=o.events.lowerEqual(r.position);m!==null&&this.#s?.at(0)!==m&&(this.#s=[m,0],t=!0)}let l=this.#n,c=l+W.samplesToPulses(128,n,sampleRate),d={blocks:[{index:0,p0:l,p1:c,s0:0,s1:128,bpm:n,flags:ui.create(!1,!1,!1,!1)}]};e(d),this.#n=c}t&&this.#t.engineToClient.switchMarkerState(V(this.#s)?[this.#s[0].uuid,this.#s[1]]:null)}};var jn=class{constructor(e,t){this.uuid=e;this.engineToClient=t;t.fetchAudio(e).then(r=>this.#e=p.wrap(r))}peaks=p.None;#t={type:"idle"};#e=p.None;get data(){return this.#e}get state(){return this.#t}subscribe(e){return O.Empty}invalidate(){}toString(){return"{AudioLoaderWorklet}"}},hn=class{#t;#e;constructor(e){this.#t=e,this.#e=A.newSet(t=>t.uuid)}record(e){}getOrCreate(e){return this.#e.getOrCreate(e,t=>new jn(t,this.#t))}remove(e){}invalidate(e){}};var dn=class{constructor(e){this.uuid=e}waiting=p.None;playing=p.None},pn=class{#t;#e;#r=[];#i=[];#s=[];constructor(e){this.#t=e,this.#t.subscribeToAllUpdatesImmediate({onUpdate:t=>{if(t.type==="delete"){let r=t.uuid;this.#e.opt(r).ifSome(s=>{s.playing.ifSome(o=>this.#n(o.uuid)),s.playing=p.None,s.waiting=p.None}),this.#e.forEach(s=>{s.playing.nonEmpty()&&A.equals(s.playing.unwrap().uuid,r)&&(s.playing=p.None,this.#n(r));let o=s.waiting.flatMap(gi);o.nonEmpty()&&A.equals(o.unwrap().uuid,r)&&(s.waiting=p.None)})}}}),this.#e=A.newSet(t=>t.uuid)}schedulePlay(e){e.trackBoxAdapter.ifSome(({uuid:t})=>{let r=this.#e.getOrCreate(t,o=>new dn(o));if(r.playing.nonEmpty()&&r.playing.unwrap()===e){console.debug(`${e} is already playing (ignore)`);return}let s=r.waiting.flatMap(o=>o);s.nonEmpty()&&(console.debug("obsolete",s.unwrap()),this.#s.push(s.unwrap().uuid),r.waiting=p.None),console.debug(`schedulePlay(${A.toString(r.uuid)} > ${e})`),w.removeOpt(this.#s,e.uuid),r.waiting=p.wrap(p.wrap(e))})}scheduleStop({uuid:e}){let t=this.#e.getOrCreate(e,s=>new dn(s)),r=t.waiting.flatMap(s=>s);r.nonEmpty()&&(console.debug("obsolete",r.unwrap()),this.#s.push(r.unwrap().uuid),t.waiting=p.None),t.playing.nonEmpty()&&(console.debug(`scheduleStop(${A.toString(e)})`),t.waiting=p.wrap(p.None))}reset(){this.#e.forEach(e=>{e.waiting.ifSome(t=>t.ifSome(r=>this.#s.push(r.uuid))),e.waiting=p.None,e.playing.ifSome(t=>this.#n(t.uuid)),e.playing=p.None}),this.#e.clear()}*iterate(e,t,r){let s=this.#e.getOrNull(e);if(s===null){yield{optClip:p.None,sectionFrom:t,sectionTo:r};return}if(s.waiting.nonEmpty()){let o=s.waiting.unwrap(),n=s.playing.mapOr(l=>l.duration,W.Bar),a=lt(r,n);a>=t?(t<a&&(yield{optClip:s.playing,sectionFrom:t,sectionTo:a}),s.waiting=p.None,s.playing.ifSome(l=>this.#n(l.uuid)),o.nonEmpty()?(s.playing=o,this.#o(o.unwrap().uuid)):s.playing=p.None,yield{optClip:s.playing,sectionFrom:a,sectionTo:r}):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}else if(s.playing.nonEmpty()){let o=s.playing.unwrap();if(o.box.playback.loop.getValue())yield{optClip:s.playing,sectionFrom:t,sectionTo:r};else{let n=lt(t,o.duration)+o.duration;n<=r?(yield{optClip:s.playing,sectionFrom:t,sectionTo:n},s.playing=p.None,this.#n(o.uuid),n<r&&(yield{optClip:p.None,sectionFrom:n,sectionTo:r})):yield{optClip:s.playing,sectionFrom:t,sectionTo:r}}}else yield{optClip:p.None,sectionFrom:t,sectionTo:r}}changes(){if(this.#r.length>0||this.#i.length>0||this.#s.length>0){let e=p.wrap({started:this.#r.slice(),stopped:this.#i.slice(),obsolete:this.#s.slice()});return this.#r.length=0,this.#i.length=0,this.#s.length=0,e}return p.None}terminate(){this.#e.clear(),this.#r.length=0,this.#i.length=0,this.#s.length=0}#o(e){this.#r.push(e)}#n(e){this.#i.push(e)}};var Qn;(e=>e.Default={includeAudioEffects:!0,includeSends:!0})(Qn||={});var Yn=class{constructor(e,t){this.uuid=e;this.engineToClient=t;t.fetchSoundfont(e).then(r=>this.#e=p.wrap(r))}peaks=p.None;#t={type:"idle"};#e=p.None;get soundfont(){return this.#e}get state(){return this.#t}subscribe(e){return O.Empty}invalidate(){}toString(){return"{SoundfontLoaderWorklet}"}},mn=class{#t;#e;constructor(e){this.#t=e,this.#e=A.newSet(t=>t.uuid)}getOrCreate(e){return this.#e.getOrCreate(e,t=>new Yn(t,this.#t))}remove(e){}};var El=!1,fn=class extends AudioWorkletProcessor{#t;#e;#r;#i;#s;#o;#n;#a;#l;#u;#c;#d;#h;#p;#g;#f;#x;#v;#I;#P;#S;#B;#T;#C;#b;#y=p.None;#F=p.None;#R=p.None;#M=!1;#D=!0;#A=!1;#E=0;#w=0;#N=!0;#V=4;constructor({processorOptions:{sab:e,project:t,exportConfiguration:r,options:s}}){super();let{boxGraph:o,mandatoryBoxes:{rootBox:n,timelineBox:a}}=wo.decode(t);this.#t=new I,this.#e=Va.for(this.port),this.#r=o,this.#i=new hs,this.#s=De.sender(this.#e.channel("engine-to-client"),l=>new class{log(c){l.dispatchAndForget(this.log,c)}fetchAudio(c){return l.dispatchAndReturn(this.fetchAudio,c)}fetchSoundfont(c){return l.dispatchAndReturn(this.fetchSoundfont,c)}notifyClipSequenceChanges(c){l.dispatchAndForget(this.notifyClipSequenceChanges,c)}switchMarkerState(c){l.dispatchAndForget(this.switchMarkerState,c)}ready(){l.dispatchAndForget(this.ready)}}),this.#n=new hn(this.#s),this.#a=new mn(this.#s),this.#l=A.newSet(l=>l.adapter.uuid),this.#d=new bo,this.#o=this.#t.own(new po(this)),this.#u=this.#o.adapterFor(n,Zr),this.#c=this.#o.adapterFor(a,it),this.#h=new Zi,this.#p=new Ji(this.#h),this.#g=new q,this.#f=new sn,this.#S=new un(this.#i),this.#B=new cn(this,s),this.#b=A.newSet(l=>l),this.#T=Br.writer(Ya(),e,l=>{let{transporting:c,isCountingIn:d,isRecording:m,position:f}=this.#i;l.position=f,l.playbackTimestamp=this.#w,l.countInBeatsTotal=this.#V,l.countInBeatsRemaining=d?(this.#E-f)/W.Quarter:0,l.isPlaying=c,l.isRecording=m,l.isCountingIn=d}),this.#x=this.#t.own(nn.create(this.#e,"engine-live-data")),this.#I=new Bo(this),this.#P=this.#t.own(new se(this.#x,j.compose(A.Lowest))),this.#v=this.#t.own(new pn(this.#r)),this.#t.ownAll(ka(this.#r,this.#e.channel("engine-sync")),De.executor(this.#e.channel("engine-commands"),{play:()=>{this.#N&&(this.#i.position=this.#w),this.#i.transporting=!0},stop:l=>{(this.#i.isRecording||this.#i.isCountingIn)&&(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.position=this.#N?this.#w:0);let c=this.#i.transporting;this.#i.transporting=!1,this.#i.metronomeEnabled=this.#A,this.#b.clear(),(l||!c)&&this.#O()},setPosition:l=>{this.#i.isRecording||(this.#i.position=this.#w=l)},startRecording:l=>{if(!(this.#i.isRecording||this.#i.isCountingIn))if(!this.#i.transporting&&l){let c=this.#i.position,d=this.#c.box.signature.nominator.getValue(),m=this.#c.box.signature.denominator.getValue();this.#E=lt(c,W.fromSignature(d,m)),this.#i.isCountingIn=!0,this.#i.metronomeEnabled=!0,this.#i.transporting=!0,this.#i.position=this.#E-W.fromSignature(this.#V,m);let f=this.#B.setCallback(this.#E,()=>{this.#i.isCountingIn=!1,this.#i.isRecording=!0,this.#i.metronomeEnabled=this.#A,f.terminate()})}else this.#i.transporting=!0,this.#i.isRecording=!0},stopRecording:()=>{!this.#i.isRecording&&!this.#i.isCountingIn||(this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#A,this.#i.transporting=!1,this.#b.clear())},setMetronomeEnabled:l=>this.#i.metronomeEnabled=this.#A=l,setPlaybackTimestampEnabled:l=>this.#N=l,queryLoadingComplete:()=>Promise.resolve(this.#r.boxes().every(l=>l.accept({visitAudioFileBox:c=>this.#n.getOrCreate(c.address.uuid).data.nonEmpty()&&c.pointerHub.nonEmpty()})??!0)),panic:()=>this.#M=!0,noteSignal:l=>{if(jt.isOn(l)){let{uuid:c,pitch:d,velocity:m}=l;this.optAudioUnit(c).ifSome(f=>f.midiDeviceChain.noteSequencer.pushRawNoteOn(d,m))}else if(jt.isOff(l)){let{uuid:c,pitch:d}=l;this.optAudioUnit(c).ifSome(m=>m.midiDeviceChain.noteSequencer.pushRawNoteOff(d))}},ignoreNoteRegion:l=>this.#b.add(l),scheduleClipPlay:l=>{l.forEach(c=>{let d=this.#r.findBox(c);if(d.isEmpty())console.warn(`Could not scheduleClipPlay. Cannot find clip: '${A.toString(c)}'`);else{let m=eo.for(this.#o,d.unwrap());this.#v.schedulePlay(m)}}),this.#i.transporting=!0},scheduleClipStop:l=>{l.forEach(c=>{let d=this.#r.findBox(c);d.isEmpty()?console.warn(`Could not scheduleClipStop. Cannot find track: '${A.toString(c)}'`):this.#v.scheduleStop(this.#o.adapterFor(d.unwrap(),fe))})},terminate:()=>{this.#R.ifSome(l=>l.terminate()),this.#R=p.None,this.#D=!1,this.#b.clear(),this.#t.terminate()}}),this.#u.audioUnits.catchupAndSubscribe({onAdd:l=>{let c=A.toString(l.uuid),d=V(r?.[c])?r[c]:Qn.Default,m=new rn(this,l,d),f=this.#l.add(m);if(b(f,`Could not add ${m}`),m.adapter.isOutput){b(this.#F.isEmpty(),"Output can only assigned once."),this.#F=p.wrap(m);return}},onRemove:({uuid:l})=>this.#l.removeByKey(l).terminate(),onReorder:at})),this.#C=p.wrap(r).match({none:()=>w.empty(),some:l=>Object.keys(l).map(c=>this.#l.get(A.parse(c)))}),this.#s.ready(),console.log=(...l)=>this.#s.log(l.join(", "))}ignoresRegion(e){return this.#b.hasKey(e)}process(e,t){try{return this.render(e,t)}catch(r){throw this.#s.log(r),r}}render(e,[t]){if(!this.#D)return!1;if(this.#M)return g("Manual Panic");let r=this.#i.metronomeEnabled;this.#g.notify(0),this.#y.isEmpty()&&(this.#p.update(),this.#y=p.wrap(this.#p.sorted().concat()),El&&console.debug(`%cAudio-Graph%c
|
4
4
|
${this.#y.unwrap().map((o,n)=>`${n+1}: ${o}`).join(`
|
5
|
-
`)}`,"color: hsl(200, 83%, 60%)","color: inherit"));let s=this.#y.unwrap();return this.#
|
5
|
+
`)}`,"color: hsl(200, 83%, 60%)","color: inherit"));let s=this.#y.unwrap();return this.#B.process(o=>{s.forEach(n=>n.process(o)),r&&this.#S.process(o)}),this.#C.length===0?(this.#F.unwrap().audioOutput().replaceInto(t),r&&this.#S.output.mixInto(t),this.#P.process(t[0],t[1])):this.#C.forEach((o,n)=>{let[a,l]=o.audioOutput().channels();t[n*2].set(a),t[n*2+1].set(l)}),this.#g.notify(1),this.#v.changes().ifSome(o=>this.#s.notifyClipSequenceChanges(o)),this.#T.tryWrite(),this.#x.flush(),!0}getAudioUnit(e){return this.#l.get(e)}optAudioUnit(e){return this.#l.opt(e)}subscribeProcessPhase(e){return this.#g.subscribe(e)}registerProcessor(e){return this.#h.addVertex(e),this.#y=p.None,{terminate:()=>{this.#h.removeVertex(e),this.#y=p.None}}}registerEdge(e,t){return this.#h.addEdge([e,t]),this.#y=p.None,{terminate:()=>{this.#h.removeEdge([e,t]),this.#y=p.None}}}get boxGraph(){return this.#r}get boxAdapters(){return this.#o}get sampleManager(){return this.#n}get soundfontManager(){return this.#a}get rootBoxAdapter(){return this.#u}get timelineBoxAdapter(){return this.#c}get bpm(){return this.#c.box.bpm.getValue()}get liveStreamBroadcaster(){return this.#x}get liveStreamReceiver(){return g("Only available in main thread")}get parameterFieldAdapters(){return this.#d}get clipSequencing(){return this.#v}get broadcaster(){return this.#x}get updateClock(){return this.#I}get timeInfo(){return this.#i}get mixer(){return this.#f}get engineToClient(){return this.#s}get isMainThread(){return!1}get isAudioContext(){return!0}terminate(){console.debug(`terminate: ${this}`),this.#t.terminate(),this.#l.forEach(e=>e.terminate()),this.#l.clear()}#O(){this.#w=0,this.#i.isRecording=!1,this.#i.isCountingIn=!1,this.#i.metronomeEnabled=this.#A,this.#i.position=0,this.#i.transporting=!1,this.#B.reset(),this.#v.reset(),this.#p.sorted().forEach(e=>e.reset()),this.#P.clear()}};var gn=class extends AudioWorkletProcessor{#t;constructor({processorOptions:e}){super(),this.#t=Ao.writer(e)}process(e){return this.#t.write(e[0]),!0}};registerProcessor("meter-processor",ss);registerProcessor("engine-processor",fn);registerProcessor("recording-processor",gn);
|
6
6
|
//# sourceMappingURL=processors.js.map
|