@doc.e.dub/csound-browser
Version:
[](https://www.npmjs.com/package/@csound/browser) [](h
1 lines • 3.81 MB
JavaScript
var Csound=function(A){"use strict";let t=window;function e(A){return"undefined"!=typeof AudioWorkletGlobalScope?function(A){var t=String(A).replace(/[=]+$/,"");t.length%4==1&&console.error("'atob' failed: The string to be decoded is not correctly encoded.");for(var e,n,i=0,o=0,r="";n=t.charAt(o++);~n&&(e=i%4?64*e+n:n,i++%4)?r+=String.fromCharCode(255&e>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return r}(A):window.atob(A)}const n=Symbol("Comlink.proxy"),i=Symbol("Comlink.endpoint"),o=Symbol("Comlink.releaseProxy"),r=Symbol("Comlink.thrown"),Q=A=>"object"==typeof A&&null!==A||"function"==typeof A,B=new Map([["proxy",{canHandle:A=>Q(A)&&A[n],serialize(A){const{port1:t,port2:e}=new MessageChannel;return a(A,t),[e,[e]]},deserialize:A=>(A.start(),l(A))}],["throw",{canHandle:A=>Q(A)&&r in A,serialize({value:A}){let t;return t=A instanceof Error?{isError:!0,value:{message:A.message,name:A.name,stack:A.stack}}:{isError:!1,value:A},[t,[]]},deserialize(A){if(A.isError)throw Object.assign(new Error(A.value.message),A.value);throw A.value}}]]);function a(A,t=self){t.addEventListener("message",(function e(i){if(!i||!i.data)return;const{id:o,type:Q,path:B}=Object.assign({path:[]},i.data),l=(i.data.argumentList||[]).map(C);let g;try{const t=B.slice(0,-1).reduce(((A,t)=>A[t]),A),e=B.reduce(((A,t)=>A[t]),A);switch(Q){case 0:g=e;break;case 1:t[B.slice(-1)[0]]=C(i.data.value),g=!0;break;case 2:g=e.apply(t,l);break;case 3:g=function(A){return Object.assign(A,{[n]:!0})}(new e(...l));break;case 4:{const{port1:t,port2:e}=new MessageChannel;a(A,e),g=E(t,[t])}break;case 5:g=void 0}}catch(A){g={value:A,[r]:0}}Promise.resolve(g).catch((A=>({value:A,[r]:0}))).then((A=>{const[n,i]=h(A);t.postMessage(Object.assign(Object.assign({},n),{id:o}),i),5===Q&&(t.removeEventListener("message",e),s(t))}))})),t.start&&t.start()}function s(A){(function(A){return"MessagePort"===A.constructor.name})(A)&&A.close()}function l(A,t){return I(A,[],t)}function g(A){if(A)throw new Error("Proxy has been released and is not useable")}function I(A,t=[],e=function(){}){let n=!1;const r=new Proxy(e,{get(e,i){if(g(n),i===o)return()=>u(A,{type:5,path:t.map((A=>A.toString()))}).then((()=>{s(A),n=!0}));if("then"===i){if(0===t.length)return{then:()=>r};const e=u(A,{type:0,path:t.map((A=>A.toString()))}).then(C);return e.then.bind(e)}return I(A,[...t,i])},set(e,i,o){g(n);const[r,Q]=h(o);return u(A,{type:1,path:[...t,i].map((A=>A.toString())),value:r},Q).then(C)},apply(e,o,r){g(n);const Q=t[t.length-1];if(Q===i)return u(A,{type:4}).then(C);if("bind"===Q)return I(A,t.slice(0,-1));const[B,a]=c(r);return u(A,{type:2,path:t.map((A=>A.toString())),argumentList:B},a).then(C)},construct(e,i){g(n);const[o,r]=c(i);return u(A,{type:3,path:t.map((A=>A.toString())),argumentList:o},r).then(C)}});return r}function c(A){const t=A.map(h);return[t.map((A=>A[0])),(e=t.map((A=>A[1])),Array.prototype.concat.apply([],e))];var e}const d=new WeakMap;function E(A,t){return d.set(A,t),A}function h(A){for(const[t,e]of B)if(e.canHandle(A)){const[n,i]=e.serialize(A);return[{type:3,name:t,value:n},i]}return[{type:0,value:A},d.get(A)||[]]}function C(A){switch(A.type){case 3:return B.get(A.name).deserialize(A.value);case 0:return A.value}}function u(A,t,e){return new Promise((n=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");A.addEventListener("message",(function t(e){e.data&&e.data.id&&e.data.id===i&&(A.removeEventListener("message",t),n(e.data))})),A.start&&A.start(),A.postMessage(Object.assign({id:i},t),e)}))}function F(A){return null!=A&&"object"==typeof A&&!0===A["@@functional/placeholder"]}function U(A){return function t(e){return 0===arguments.length||F(e)?t:A.apply(this,arguments)}}function p(A){return function t(e,n){switch(arguments.length){case 0:return t;case 1:return F(e)?t:U((function(t){return A(e,t)}));default:return F(e)&&F(n)?t:F(e)?U((function(t){return A(t,n)})):F(n)?U((function(t){return A(e,t)})):A(e,n)}}}function m(A,t){switch(A){case 0:return function(){return t.apply(this,arguments)};case 1:return function(A){return t.apply(this,arguments)};case 2:return function(A,e){return t.apply(this,arguments)};case 3:return function(A,e,n){return t.apply(this,arguments)};case 4:return function(A,e,n,i){return t.apply(this,arguments)};case 5:return function(A,e,n,i,o){return t.apply(this,arguments)};case 6:return function(A,e,n,i,o,r){return t.apply(this,arguments)};case 7:return function(A,e,n,i,o,r,Q){return t.apply(this,arguments)};case 8:return function(A,e,n,i,o,r,Q,B){return t.apply(this,arguments)};case 9:return function(A,e,n,i,o,r,Q,B,a){return t.apply(this,arguments)};case 10:return function(A,e,n,i,o,r,Q,B,a,s){return t.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function Z(A,t,e){return function(){for(var n=[],i=0,o=A,r=0;r<t.length||i<arguments.length;){var Q;r<t.length&&(!F(t[r])||i>=arguments.length)?Q=t[r]:(Q=arguments[i],i+=1),n[r]=Q,F(Q)||(o-=1),r+=1}return o<=0?e.apply(this,n):m(o,Z(A,n,e))}}var R=p((function(A,t){return 1===A?U(t):m(A,Z(A,[],t))}));function b(A){return function t(e,n,i){switch(arguments.length){case 0:return t;case 1:return F(e)?t:p((function(t,n){return A(e,t,n)}));case 2:return F(e)&&F(n)?t:F(e)?p((function(t,e){return A(t,n,e)})):F(n)?p((function(t,n){return A(e,t,n)})):U((function(t){return A(e,n,t)}));default:return F(e)&&F(n)&&F(i)?t:F(e)&&F(n)?p((function(t,e){return A(t,e,i)})):F(e)&&F(i)?p((function(t,e){return A(t,n,e)})):F(n)&&F(i)?p((function(t,n){return A(e,t,n)})):F(e)?U((function(t){return A(t,n,i)})):F(n)?U((function(t){return A(e,t,i)})):F(i)?U((function(t){return A(e,n,t)})):A(e,n,i)}}}var f=Array.isArray||function(A){return null!=A&&A.length>=0&&"[object Array]"===Object.prototype.toString.call(A)};function y(A){return null!=A&&"function"==typeof A["@@transducer/step"]}function S(A,t,e){return function(){if(0===arguments.length)return e();var n=Array.prototype.slice.call(arguments,0),i=n.pop();if(!f(i)){for(var o=0;o<A.length;){if("function"==typeof i[A[o]])return i[A[o]].apply(i,n);o+=1}if(y(i)){var r=t.apply(null,n);return r(i)}}return e.apply(this,arguments)}}var V=function(){return this.xf["@@transducer/init"]()},N=function(A){return this.xf["@@transducer/result"](A)};function G(A){return"[object String]"===Object.prototype.toString.call(A)}var W=U((function(A){return!!f(A)||!!A&&("object"==typeof A&&(!G(A)&&(1===A.nodeType?!!A.length:0===A.length||A.length>0&&(A.hasOwnProperty(0)&&A.hasOwnProperty(A.length-1)))))})),J=function(){function A(A){this.f=A}return A.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},A.prototype["@@transducer/result"]=function(A){return A},A.prototype["@@transducer/step"]=function(A,t){return this.f(A,t)},A}();var k=p((function(A,t){return m(A.length,(function(){return A.apply(t,arguments)}))}));function Y(A,t,e){for(var n=e.next();!n.done;){if((t=A["@@transducer/step"](t,n.value))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n=e.next()}return A["@@transducer/result"](t)}function w(A,t,e,n){return A["@@transducer/result"](e[n](k(A["@@transducer/step"],A),t))}var D="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function M(A,t,e){if("function"==typeof A&&(A=function(A){return new J(A)}(A)),W(e))return function(A,t,e){for(var n=0,i=e.length;n<i;){if((t=A["@@transducer/step"](t,e[n]))&&t["@@transducer/reduced"]){t=t["@@transducer/value"];break}n+=1}return A["@@transducer/result"](t)}(A,t,e);if("function"==typeof e["fantasy-land/reduce"])return w(A,t,e,"fantasy-land/reduce");if(null!=e[D])return Y(A,t,e[D]());if("function"==typeof e.next)return Y(A,t,e);if("function"==typeof e.reduce)return w(A,t,e,"reduce");throw new TypeError("reduce: list must be array or iterable")}function T(A,t){return Object.prototype.hasOwnProperty.call(t,A)}var X=Object.prototype.toString,L=function(){return"[object Arguments]"===X.call(arguments)?function(A){return"[object Arguments]"===X.call(A)}:function(A){return T("callee",A)}}(),x=!{toString:null}.propertyIsEnumerable("toString"),v=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],K=function(){return arguments.propertyIsEnumerable("length")}(),j=function(A,t){for(var e=0;e<A.length;){if(A[e]===t)return!0;e+=1}return!1},H="function"!=typeof Object.keys||K?U((function(A){if(Object(A)!==A)return[];var t,e,n=[],i=K&&L(A);for(t in A)!T(t,A)||i&&"length"===t||(n[n.length]=t);if(x)for(e=v.length-1;e>=0;)T(t=v[e],A)&&!j(n,t)&&(n[n.length]=t),e-=1;return n})):U((function(A){return Object(A)!==A?[]:Object.keys(A)})),O=b(M),z=b((function(A,t,e){var n={};for(var i in e)n[i]=e[i];return n[A]=t,n})),P=U((function(A){return R(A.length,A)})),q=U((function(A){return null===A?"Null":void 0===A?"Undefined":Object.prototype.toString.call(A).slice(8,-1)}));function _(A){for(var t,e=[];!(t=A.next()).done;)e.push(t.value);return e}function $(A,t,e){for(var n=0,i=e.length;n<i;){if(A(t,e[n]))return!0;n+=1}return!1}var AA="function"==typeof Object.is?Object.is:function(A,t){return A===t?0!==A||1/A==1/t:A!=A&&t!=t};function tA(A,t,e,n){var i=_(A);function o(A,t){return eA(A,t,e.slice(),n.slice())}return!$((function(A,t){return!$(o,t,A)}),_(t),i)}function eA(A,t,e,n){if(AA(A,t))return!0;var i,o,r=q(A);if(r!==q(t))return!1;if(null==A||null==t)return!1;if("function"==typeof A["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof A["fantasy-land/equals"]&&A["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](A);if("function"==typeof A.equals||"function"==typeof t.equals)return"function"==typeof A.equals&&A.equals(t)&&"function"==typeof t.equals&&t.equals(A);switch(r){case"Arguments":case"Array":case"Object":if("function"==typeof A.constructor&&"Promise"===(i=A.constructor,null==(o=String(i).match(/^function (\w*)/))?"":o[1]))return A===t;break;case"Boolean":case"Number":case"String":if(typeof A!=typeof t||!AA(A.valueOf(),t.valueOf()))return!1;break;case"Date":if(!AA(A.valueOf(),t.valueOf()))return!1;break;case"Error":return A.name===t.name&&A.message===t.message;case"RegExp":if(A.source!==t.source||A.global!==t.global||A.ignoreCase!==t.ignoreCase||A.multiline!==t.multiline||A.sticky!==t.sticky||A.unicode!==t.unicode)return!1}for(var Q=e.length-1;Q>=0;){if(e[Q]===A)return n[Q]===t;Q-=1}switch(r){case"Map":return A.size===t.size&&tA(A.entries(),t.entries(),e.concat([A]),n.concat([t]));case"Set":return A.size===t.size&&tA(A.values(),t.values(),e.concat([A]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var B=H(A);if(B.length!==H(t).length)return!1;var a=e.concat([A]),s=n.concat([t]);for(Q=B.length-1;Q>=0;){var l=B[Q];if(!T(l,t)||!eA(t[l],A[l],a,s))return!1;Q-=1}return!0}var nA=p((function(A,t){return eA(A,t,[],[])}));function iA(A,t){return function(A,t,e){var n,i;if("function"==typeof A.indexOf)switch(typeof t){case"number":if(0===t){for(n=1/t;e<A.length;){if(0===(i=A[e])&&1/i===n)return e;e+=1}return-1}if(t!=t){for(;e<A.length;){if("number"==typeof(i=A[e])&&i!=i)return e;e+=1}return-1}return A.indexOf(t,e);case"string":case"boolean":case"function":case"undefined":return A.indexOf(t,e);case"object":if(null===t)return A.indexOf(t,e)}for(;e<A.length;){if(nA(A[e],t))return e;e+=1}return-1}(t,A,0)>=0}function oA(A){return"[object Object]"===Object.prototype.toString.call(A)}var rA=function(){function A(A,t){this.xf=t,this.f=A}return A.prototype["@@transducer/init"]=V,A.prototype["@@transducer/result"]=N,A.prototype["@@transducer/step"]=function(A,t){return this.f(t)?this.xf["@@transducer/step"](A,t):A},A}(),QA=p(S(["filter"],p((function(A,t){return new rA(A,t)})),(function(A,t){return oA(t)?M((function(e,n){return A(t[n])&&(e[n]=t[n]),e}),{},H(t)):function(A,t){for(var e=0,n=t.length,i=[];e<n;)A(t[e])&&(i[i.length]=t[e]),e+=1;return i}(A,t)}))),BA=p((function(A,t){return QA((e=A,function(){return!e.apply(this,arguments)}),t);var e})),aA=function(){function A(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}return A.prototype.add=function(A){return!sA(A,!0,this)},A.prototype.has=function(A){return sA(A,!1,this)},A}();function sA(A,t,e){var n,i=typeof A;switch(i){case"string":case"number":return 0===A&&1/A==-1/0?!!e._items["-0"]||(t&&(e._items["-0"]=!0),!1):null!==e._nativeSet?t?(n=e._nativeSet.size,e._nativeSet.add(A),e._nativeSet.size===n):e._nativeSet.has(A):i in e._items?A in e._items[i]||(t&&(e._items[i][A]=!0),!1):(t&&(e._items[i]={},e._items[i][A]=!0),!1);case"boolean":if(i in e._items){var o=A?1:0;return!!e._items[i][o]||(t&&(e._items[i][o]=!0),!1)}return t&&(e._items[i]=A?[!1,!0]:[!0,!1]),!1;case"function":return null!==e._nativeSet?t?(n=e._nativeSet.size,e._nativeSet.add(A),e._nativeSet.size===n):e._nativeSet.has(A):i in e._items?!!iA(A,e._items[i])||(t&&e._items[i].push(A),!1):(t&&(e._items[i]=[A]),!1);case"undefined":return!!e._items[i]||(t&&(e._items[i]=!0),!1);case"object":if(null===A)return!!e._items.null||(t&&(e._items.null=!0),!1);default:return(i=Object.prototype.toString.call(A))in e._items?!!iA(A,e._items[i])||(t&&e._items[i].push(A),!1):(t&&(e._items[i]=[A]),!1)}}var lA=p((function(A,t){for(var e=[],n=0,i=A.length,o=t.length,r=new aA,Q=0;Q<o;Q+=1)r.add(t[Q]);for(;n<i;)r.add(A[n])&&(e[e.length]=A[n]),n+=1;return e})),gA=U((function(A){return null!=A&&"function"==typeof A["fantasy-land/empty"]?A["fantasy-land/empty"]():null!=A&&null!=A.constructor&&"function"==typeof A.constructor["fantasy-land/empty"]?A.constructor["fantasy-land/empty"]():null!=A&&"function"==typeof A.empty?A.empty():null!=A&&null!=A.constructor&&"function"==typeof A.constructor.empty?A.constructor.empty():f(A)?[]:G(A)?"":oA(A)?{}:L(A)?function(){return arguments}():void 0})),IA=U((function(A){return null!=A&&nA(A,gA(A))}));function cA(A){return"[object Number]"===Object.prototype.toString.call(A)}var dA=p((function(A,t){if(!cA(A)||!cA(t))throw new TypeError("Both arguments to range must be numbers");for(var e=[],n=A;n<t;)e.push(n),n+=1;return e}));const EA=A=>()=>A.exports.csoundCreateWasi();EA.toString=()=>"create = async () => undefined;";const hA=A=>t=>A.exports.csoundDestroy(t);hA.toString=()=>"destroy = async () => undefined;";const CA=A=>()=>A.exports.csoundGetAPIVersion();CA.toString=()=>"getAPIVersion = async () => Number;";const uA=A=>()=>A.exports.csoundGetVersion();uA.toString=()=>"getVersion = async () => Number;";const FA=A=>(t,e)=>A.exports.csoundInitialize(e);FA.toString=()=>"initialize = async () => Number;";const UA=new TextDecoder("utf-8"),pA=new TextEncoder("utf-8"),mA=A=>UA.decode(A),ZA=A=>{const t=A.indexOf("\0");return t>-1?A.substr(0,t):A},RA=(A,t)=>{A.exports.freeStringMem(t)},bA=(A,t)=>{if("string"!=typeof t)return void console.error("Expected string but got",typeof t);const e=pA.encode(t),n=A.exports.allocStringMem(e.length),{buffer:i}=A.exports.memory;return new Uint8Array(i,n,e.length+1).set(e),n},fA=A=>(t,e)=>A.exports.csoundParseOrc(t,e);fA.toString=()=>"parseOrc = async (orchestra) => Object;";const yA=A=>(t,e)=>A.exports.csoundCompileTree(t,e);yA.toString=()=>"compileTree = async (tree) => Number;";const SA=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundCompileOrc(t,n);return RA(A,n),i};SA.toString=()=>"compileOrc = async (orchestra) => Number;";const VA=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundEvalCode(t,n);return RA(A,n),i};VA.toString=()=>"csoundEvalCode = async (orchestra) => Number;";const NA=A=>t=>A.exports.csoundStartWasi(t);NA.toString=()=>"start = async () => Number;";const GA=A=>(t,e)=>{const n=/^\//i.test(e)?`/sandbox${e}`:`/sandbox/${e}`,i=bA(A,n),o=A.exports.csoundCompileCsd(t,i);return RA(A,i),o};GA.toString=()=>"compileCsd = async (path) => Number;";const WA=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundCompileCsdText(t,n);return RA(A,n),i};WA.toString=()=>"compileCsdText = async (csoundDocument) => Number;";const JA=A=>t=>A.exports.csoundPerform(t);JA.toString=()=>"perform = async () => Number;";const kA=A=>t=>A.exports.csoundPerformKsmpsWasi(t);kA.toString=()=>"performKsmps = async (csound) => Number;";const YA=A=>t=>A.exports.csoundPerformBuffer(t);YA.toString=()=>"performBuffer = async (csound) => Number;";const wA=A=>t=>A.exports.csoundStop(t);wA.toString=()=>"stop = async () => undefined;";const DA=A=>t=>A.exports.csoundCleanup(t);DA.toString=()=>"cleanup = async () => Number;";const MA=A=>t=>A.exports.csoundResetWasi(t);MA.toString=()=>"reset = async () => Number;";const TA={int:4,MYFLT:4,char:1},XA=A=>A.reduce(((A,[t,e,...n])=>A+("char"===e?TA[e]*n[0]:TA[e])),0),LA=(A,t)=>{const[e]=A.reduce((([A,e],[n,i,...o])=>{const r="char"===i?TA[i]*o[0]:TA[i],Q="char"===i?ZA(mA(t.subarray(e,r)))||"":t[e];return A[n]=Q,[A,e+r]}),[{},0]);return e},xA=[["debug_mode","int"],["buffer_frames","int"],["hardware_buffer_frames","int"],["displays","int"],["ascii_graphs","int"],["postscript_graphs","int"],["message_level","int"],["tempo","int"],["ring_bell","int"],["use_cscore","int"],["terminate_on_midi","int"],["heartbeat","int"],["defer_gen01_load","int"],["midi_key","int"],["midi_key_cps","int"],["midi_key_oct","int"],["midi_key_pch","int"],["midi_velocity","int"],["midi_velocity_amp","int"],["no_default_paths","int"],["number_of_threads","int"],["syntax_check_only","int"],["csd_line_counts","int"],["compute_weights","int"],["realtime_mode","int"],["sample_accurate","int"],["sample_rate_override","MYFLT"],["control_rate_override","MYFLT"],["nchnls_override","int"],["nchnls_i_override","int"],["e0dbfs_override","MYFLT"],["daemon","int"],["ksmps_override","int"],["FFT_library","int"]],vA=[["device_name","char",64],["interface_name","char",64],["device_id","char",64],["midi_module","char",64],["isOutput","int"]],KA=P(((A,t)=>A.exports.csoundGetSr(t)));KA.toString=()=>"getSr = async () => Number;";const jA=P(((A,t)=>A.exports.csoundGetKr(t)));jA.toString=()=>"getKr = async () => Number;";const HA=P(((A,t)=>A.exports.csoundGetKsmps(t)));HA.toString=()=>"getKsmps = async () => Number;";const OA=P(((A,t)=>A.exports.csoundGetNchnls(t)));OA.toString=()=>"getNchnls = async () => Number;";const zA=P(((A,t)=>A.exports.csoundGetNchnlsInput(t)));zA.toString=()=>"getNchnlsInput = async () => Number;";const PA=P(((A,t)=>A.exports.csoundGet0dBFS(t)));PA.toString=()=>"get0dBFS = async () => Number;";const qA=P(((A,t)=>A.exports.csoundGetA4(t)));qA.toString=()=>"getA4 = async () => Number;";const _A=P(((A,t)=>A.exports.csoundGetCurrentTimeSamples(t)));_A.toString=()=>"getCurrentTimeSamples = async () => Number;";const $A=P(((A,t)=>A.exports.csoundGetSizeOfMYFLT(t)));$A.toString=()=>"getSizeOfMYFLT = async () => Number;";const At=P(((A,t,e)=>{const n=bA(A,e),i=A.exports.csoundSetOption(t,n);return RA(A,n),i}));At.toString=()=>"setOption = async (option) => Number;";const tt=P(((A,t,e)=>{A.exports.csoundSetParams(t,e)}));tt.toString=()=>"setParams = async (csoundParams) => undefined;";const et=P(((A,t)=>{const{buffer:e}=A.exports.memory,n=XA(xA),i=A.exports.allocCsoundParamsStruct(),o=new Uint8Array(e,i,n);A.exports.csoundGetParams(t,i);const r=LA(xA,o);return A.exports.freeCsoundParams(i),r}));et.toString=()=>"getParams = async () => CSOUND_PARAMS;";const nt=P(((A,t)=>A.exports.csoundGetDebug(t)));nt.toString=()=>"getDebug = async () => Number;";const it=P(((A,t,e)=>{A.exports.csoundSetDebug(t,e)}));it.toString=()=>"setDebug = async (number) => undefined;";const ot=A=>t=>A.exports.csoundGetInputBufferSize(t);ot.toString=()=>"getInputBufferSize = async () => Number;";const rt=A=>t=>A.exports.csoundGetOutputBufferSize(t);rt.toString=()=>"getOutputBufferSize = async () => Number;";const Qt=A=>t=>A.exports.csoundGetInputBuffer(t);Qt.toString=()=>"getInputBuffer = async () => Number;";const Bt=A=>t=>A.exports.csoundGetOutputBuffer(t);Bt.toString=()=>"getOutputBuffer = async () => Number;";const at=A=>t=>A.exports.csoundGetSpin(t);at.toString=()=>"getSpin = async (csound) => Number;";const st=A=>t=>A.exports.csoundGetSpout(t);st.toString=()=>"getSpout = async () => Number;";const lt=A=>(t,e)=>{const{buffer:n}=A.exports.memory,i=A.exports.csoundGetMIDIDevList(t,void 0,e?1:0);if(0===i)return[];const o=XA(vA),r=A.exports.allocCsMidiDeviceStruct(i);A.exports.csoundGetMIDIDevList(t,r,e?1:0);const Q=new Uint8Array(n,r,o*i),B=dA(0,i).map((A=>LA(vA,Q.subarray(A*o,o))));return A.exports.freeCsMidiDeviceStruct(r),B};lt.toString=()=>"getMIDIDevList = async (isOutput) => Object;";const gt=A=>t=>{const{buffer:e}=A.exports.memory,n=A.exports.getRtMidiName(t),i=new Uint8Array(e,n,128);return ZA(mA(i))||""};gt.toString=()=>"getRtMidiName = async () => String;";const It=A=>(t,e,n,i)=>{A.exports.pushMidiMessage(t,e,n,i)};It.toString=()=>"midiMessage = async (status, data1, data2) => undefined;";const ct=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundInputMessage(t,n);return RA(A,n),i};ct.toString=()=>"inputMessage = async (scoreEvent) => Number;";const dt=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundInputMessageAsync(t,n);return RA(A,n),i};dt.toString=()=>"inputMessageAsync = async (scoreEvent) => Number;";const Et=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundGetControlChannelWasi(t,n);return RA(A,n),i};Et.toString=()=>"getControlChannel = async (channelName) => Number;";const ht=A=>(t,e,n)=>{const i=bA(A,e);A.exports.csoundSetControlChannel(t,i,n),RA(A,i)};ht.toString=()=>"setControlChannel = async (channelName, value) => void;";const Ct=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundGetStringChannelWasi(t,n),o=((A,t)=>{const{buffer:e}=A.exports.memory,n=new Uint8Array(e,t),i=mA(n);return ZA(i)})(A,i);return RA(A,n),RA(A,i),o};Ct.toString=()=>"getStringChannel = async (channelName) => String;";const ut=A=>(t,e,n)=>{const i=bA(A,e),o=bA(A,n);A.exports.csoundSetStringChannel(t,i,o),RA(A,i),RA(A,o)};ut.toString=()=>"setStringChannel = async (channelName, value) => void;";const Ft=A=>t=>{const{buffer:e}=A.exports.memory,n=A.exports.csoundGetOutputName(t),i=new Uint8Array(e,n,64);return ZA(mA(i))||""};Ft.toString=()=>"getOutputName = async () => String;";const Ut=A=>t=>{const{buffer:e}=A.exports.memory,n=A.exports.csoundGetInputName(t),i=new Uint8Array(e,n,64);return ZA(mA(i))||""};Ut.toString=()=>"getInputName = async (csound) => String;";const pt=A=>(t,e,n)=>{const i=bA(A,e),o=bA(A,n),r=A.exports.csoundAppendEnv(t,i,o);return RA(A,i),RA(A,o),r};pt.toString=()=>"appendEnv = async (csound, variable, value) => Number;";const mt=A=>t=>A.exports.csoundIsScorePending(t);mt.toString=()=>"isScorePending = async () => Number;";const Zt=A=>(t,e)=>A.exports.csoundSetScorePending(t,e);Zt.toString=()=>"setScorePending = async (pending) => Number;";const Rt=A=>(t,e)=>{const n=bA(A,e),i=A.exports.csoundReadScore(t,n);return RA(A,n),i};Rt.toString=()=>"readScore = async (score) => Number;";const bt=A=>t=>A.exports.csoundGetScoreTime(t);bt.toString=()=>"getScoreTime = async () => Number;";const ft=A=>t=>A.exports.csoundGetScoreOffsetSeconds(t);ft.toString=()=>"getScoreOffsetSeconds = async () => Number;";const yt=A=>(t,e)=>A.exports.csoundSetScoreOffsetSeconds(t,e);yt.toString=()=>"setScoreOffsetSeconds = async () => Number;";const St=A=>t=>A.exports.csoundRewindScore(t);St.toString=()=>"rewindScore = async () => undefined;";const Vt=A=>(t,e)=>A.exports.csoundTableLength(t,e);Vt.toString=()=>"tableLength = async (tableNum) => Number;";const Nt=A=>(t,e,n)=>A.exports.csoundTableGet(t,e,n);Nt.toString=()=>"tableGet = async (tableNum, tableIndex) => Number;";const Gt=A=>(t,e,n,i)=>A.exports.csoundTableSet(t,e,n,i);Gt.toString=()=>"tableSet = async (tableNum, tableIndex, value) => undefined;";const Wt=A=>(t,e,n)=>{const i=A.exports.allocFloatArray(n.length);new Float64Array(A.exports.memory.buffer,i,n.length).set(n),A.exports.csoundTableCopyIn(t,e,i),A.exports.freeFloatArrayMem(i)};Wt.toString=()=>"tableCopyIn = async (tableNum, float64Array) => undefined;";const Jt=A=>(t,e)=>{const n=A.exports.csoundTableLength(t,e);if(n>0){const i=A.exports.allocFloatArray(n);A.exports.csoundTableCopyOut(t,e,i);const{buffer:o}=A.exports.memory,r=new Float64Array(o,i,n);return A.exports.freeFloatArrayMem(i),Float64Array.from(r)}};Jt.toString=()=>"tableCopyOut = async (tableNum) => ?Float64Array;";const kt=Jt;kt.toString=Jt.toString;const Yt=A=>(t,e)=>{const n=A.exports.allocFloatArray(1024);A.exports.csoundGetTableArgs(t,n,e);const{buffer:i}=A.exports.memory,o=new Float64Array(i,n,1024);return A.exports.freeFloatArrayMem(n),o};Yt.toString=()=>"getTableArgs = async (tableNum) => ?Float64Array;";const wt=A=>(t,e)=>A.exports.csoundIsNamedGEN(t,e);wt.toString=()=>"isNamedGEN = async (tableNum) => number;";const Dt=A=>(t,e)=>{const n=A.exports.csoundIsNamedGEN(t,e);if(n>0){const i=A.exports.allocStringMem(n);A.exports.csoundGetNamedGEN(t,i,e,n);const{buffer:o}=A.exports.memory,r=new Uint8Array(o,i,n);return mA(r)}};Dt.toString=()=>"getNamedGEN = async (tableNum) => ?string;";const Mt={csoundCreate:EA,csoundDestroy:hA,csoundGetAPIVersion:CA,csoundGetVersion:uA,csoundInitialize:FA,csoundParseOrc:fA,csoundCompileTree:yA,csoundCompileOrc:SA,csoundEvalCode:VA,csoundStart:NA,csoundCompileCsd:GA,csoundCompileCsdText:WA,csoundPerform:JA,csoundPerformKsmps:kA,csoundPerformBuffer:YA,csoundStop:wA,csoundCleanup:DA,csoundReset:MA,csoundGetSr:KA,csoundGetKr:jA,csoundGetKsmps:HA,csoundGetNchnls:OA,csoundGetNchnlsInput:zA,csoundGet0dBFS:PA,csoundGetA4:qA,csoundGetCurrentTimeSamples:_A,csoundGetSizeOfMYFLT:$A,csoundSetOption:At,csoundSetParams:tt,csoundGetParams:et,csoundGetDebug:nt,csoundSetDebug:it,csoundGetInputBufferSize:ot,csoundGetOutputBufferSize:rt,csoundGetInputBuffer:Qt,csoundGetOutputBuffer:Bt,csoundGetSpin:at,csoundGetSpout:st,csoundGetMIDIDevList:lt,csoundSetMidiCallbacks:A=>t=>{A.exports.csoundSetMidiCallbacks(t)},csoundGetRtMidiName:gt,csoundGetMidiOutFileName:A=>t=>{const{buffer:e}=A.exports.memory,n=A.exports.getMidiOutFileName(t),i=new Uint8Array(e,n,128);return n&&n.length>0&&RA(n),ZA(mA(i))||""},csoundPushMidiMessage:It,_isRequestingRtMidiInput:A=>t=>A.exports.isRequestingRtMidiInput(t),csoundInputMessage:ct,csoundInputMessageAsync:dt,csoundGetControlChannel:Et,csoundSetControlChannel:ht,csoundGetStringChannel:Ct,csoundSetStringChannel:ut,csoundGetInputName:Ut,csoundGetOutputName:Ft,csoundAppendEnv:pt,csoundShouldDaemonize:A=>t=>A.exports.csoundShouldDaemonize(t),csoundIsScorePending:mt,csoundSetScorePending:Zt,csoundReadScore:Rt,csoundGetScoreTime:bt,csoundGetScoreOffsetSeconds:ft,csoundSetScoreOffsetSeconds:yt,csoundRewindScore:St,csoundTableLength:Vt,csoundTableGet:Nt,csoundTableSet:Gt,csoundTableCopyIn:Wt,csoundTableCopyOut:Jt,csoundGetTable:kt,csoundGetTableArgs:Yt,csoundIsNamedGEN:wt,csoundGetNamedGEN:Dt};var Tt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{};function Xt(A){if(A.__esModule)return A;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(A).forEach((function(e){var n=Object.getOwnPropertyDescriptor(A,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:function(){return A[e]}})})),t}function Lt(A){var t={exports:{}};return A(t,t.exports),t.exports}var xt=Object.defineProperty({constants:{O_RDONLY:0,O_WRONLY:1,O_RDWR:2,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,UV_FS_COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_EXCL:1,COPYFILE_FICLONE:2,COPYFILE_FICLONE_FORCE:4}},"__esModule",{value:!0}),vt=Lt((function(A,t){"function"==typeof BigInt?t.default=BigInt:t.default=function(){throw new Error("BigInt is not supported in this environment.")}})),Kt=xt.constants.S_IFMT,jt=xt.constants.S_IFDIR,Ht=xt.constants.S_IFREG,Ot=xt.constants.S_IFBLK,zt=xt.constants.S_IFCHR,Pt=xt.constants.S_IFLNK,qt=xt.constants.S_IFIFO,_t=xt.constants.S_IFSOCK,$t=function(){function A(){}return A.build=function(t,e){void 0===e&&(e=!1);var n=new A,i=t.uid,o=t.gid,r=t.atime,Q=t.mtime,B=t.ctime,a=e?vt.default:function(A){return A};n.uid=a(i),n.gid=a(o),n.rdev=a(0),n.blksize=a(4096),n.ino=a(t.ino),n.size=a(t.getSize()),n.blocks=a(1),n.atime=r,n.mtime=Q,n.ctime=B,n.birthtime=B,n.atimeMs=a(r.getTime()),n.mtimeMs=a(Q.getTime());var s=a(B.getTime());return n.ctimeMs=s,n.birthtimeMs=s,n.dev=a(0),n.mode=a(t.mode),n.nlink=a(t.nlink),n},A.prototype._checkModeProperty=function(A){return(Number(this.mode)&Kt)===A},A.prototype.isDirectory=function(){return this._checkModeProperty(jt)},A.prototype.isFile=function(){return this._checkModeProperty(Ht)},A.prototype.isBlockDevice=function(){return this._checkModeProperty(Ot)},A.prototype.isCharacterDevice=function(){return this._checkModeProperty(zt)},A.prototype.isSymbolicLink=function(){return this._checkModeProperty(Pt)},A.prototype.isFIFO=function(){return this._checkModeProperty(qt)},A.prototype.isSocket=function(){return this._checkModeProperty(_t)},A}(),Ae=$t,te=$t,ee=Object.defineProperty({Stats:Ae,default:te},"__esModule",{value:!0}),ne=void 0!==t?t:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},ie=[],oe=[],re="undefined"!=typeof Uint8Array?Uint8Array:Array,Qe=!1;function Be(){Qe=!0;for(var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=A.length;t<e;++t)ie[t]=A[t],oe[A.charCodeAt(t)]=t;oe["-".charCodeAt(0)]=62,oe["_".charCodeAt(0)]=63}function ae(A,t,e){for(var n,i,o=[],r=t;r<e;r+=3)n=(A[r]<<16)+(A[r+1]<<8)+A[r+2],o.push(ie[(i=n)>>18&63]+ie[i>>12&63]+ie[i>>6&63]+ie[63&i]);return o.join("")}function se(A){var t;Qe||Be();for(var e=A.length,n=e%3,i="",o=[],r=16383,Q=0,B=e-n;Q<B;Q+=r)o.push(ae(A,Q,Q+r>B?B:Q+r));return 1===n?(t=A[e-1],i+=ie[t>>2],i+=ie[t<<4&63],i+="=="):2===n&&(t=(A[e-2]<<8)+A[e-1],i+=ie[t>>10],i+=ie[t>>4&63],i+=ie[t<<2&63],i+="="),o.push(i),o.join("")}function le(A,t,e,n,i){var o,r,Q=8*i-n-1,B=(1<<Q)-1,a=B>>1,s=-7,l=e?i-1:0,g=e?-1:1,I=A[t+l];for(l+=g,o=I&(1<<-s)-1,I>>=-s,s+=Q;s>0;o=256*o+A[t+l],l+=g,s-=8);for(r=o&(1<<-s)-1,o>>=-s,s+=n;s>0;r=256*r+A[t+l],l+=g,s-=8);if(0===o)o=1-a;else{if(o===B)return r?NaN:1/0*(I?-1:1);r+=Math.pow(2,n),o-=a}return(I?-1:1)*r*Math.pow(2,o-n)}function ge(A,t,e,n,i,o){var r,Q,B,a=8*o-i-1,s=(1<<a)-1,l=s>>1,g=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,I=n?0:o-1,c=n?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(Q=isNaN(t)?1:0,r=s):(r=Math.floor(Math.log(t)/Math.LN2),t*(B=Math.pow(2,-r))<1&&(r--,B*=2),(t+=r+l>=1?g/B:g*Math.pow(2,1-l))*B>=2&&(r++,B/=2),r+l>=s?(Q=0,r=s):r+l>=1?(Q=(t*B-1)*Math.pow(2,i),r+=l):(Q=t*Math.pow(2,l-1)*Math.pow(2,i),r=0));i>=8;A[e+I]=255&Q,I+=c,Q/=256,i-=8);for(r=r<<i|Q,a+=i;a>0;A[e+I]=255&r,I+=c,r/=256,a-=8);A[e+I-c]|=128*d}var Ie={}.toString,ce=Array.isArray||function(A){return"[object Array]"==Ie.call(A)};Ce.TYPED_ARRAY_SUPPORT=void 0===ne.TYPED_ARRAY_SUPPORT||ne.TYPED_ARRAY_SUPPORT;var de=Ee();function Ee(){return Ce.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function he(A,t){if(Ee()<t)throw new RangeError("Invalid typed array length");return Ce.TYPED_ARRAY_SUPPORT?(A=new Uint8Array(t)).__proto__=Ce.prototype:(null===A&&(A=new Ce(t)),A.length=t),A}function Ce(A,t,e){if(!(Ce.TYPED_ARRAY_SUPPORT||this instanceof Ce))return new Ce(A,t,e);if("number"==typeof A){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Ue(this,A)}return ue(this,A,t,e)}function ue(A,t,e,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(A,t,e,n){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");t=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n);Ce.TYPED_ARRAY_SUPPORT?(A=t).__proto__=Ce.prototype:A=pe(A,t);return A}(A,t,e,n):"string"==typeof t?function(A,t,e){"string"==typeof e&&""!==e||(e="utf8");if(!Ce.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|Re(t,e),i=(A=he(A,n)).write(t,e);i!==n&&(A=A.slice(0,i));return A}(A,t,e):function(A,t){if(Ze(t)){var e=0|me(t.length);return 0===(A=he(A,e)).length||t.copy(A,0,0,e),A}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?he(A,0):pe(A,t);if("Buffer"===t.type&&ce(t.data))return pe(A,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(A,t)}function Fe(A){if("number"!=typeof A)throw new TypeError('"size" argument must be a number');if(A<0)throw new RangeError('"size" argument must not be negative')}function Ue(A,t){if(Fe(t),A=he(A,t<0?0:0|me(t)),!Ce.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)A[e]=0;return A}function pe(A,t){var e=t.length<0?0:0|me(t.length);A=he(A,e);for(var n=0;n<e;n+=1)A[n]=255&t[n];return A}function me(A){if(A>=Ee())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ee().toString(16)+" bytes");return 0|A}function Ze(A){return!(null==A||!A._isBuffer)}function Re(A,t){if(Ze(A))return A.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(A)||A instanceof ArrayBuffer))return A.byteLength;"string"!=typeof A&&(A=""+A);var e=A.length;if(0===e)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return _e(A).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return $e(A).length;default:if(n)return _e(A).length;t=(""+t).toLowerCase(),n=!0}}function be(A,t,e){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(A||(A="utf8");;)switch(A){case"hex":return Xe(this,t,e);case"utf8":case"utf-8":return we(this,t,e);case"ascii":return Me(this,t,e);case"latin1":case"binary":return Te(this,t,e);case"base64":return Ye(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Le(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+A);A=(A+"").toLowerCase(),n=!0}}function fe(A,t,e){var n=A[t];A[t]=A[e],A[e]=n}function ye(A,t,e,n,i){if(0===A.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:A.length-1),e<0&&(e=A.length+e),e>=A.length){if(i)return-1;e=A.length-1}else if(e<0){if(!i)return-1;e=0}if("string"==typeof t&&(t=Ce.from(t,n)),Ze(t))return 0===t.length?-1:Se(A,t,e,n,i);if("number"==typeof t)return t&=255,Ce.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(A,t,e):Uint8Array.prototype.lastIndexOf.call(A,t,e):Se(A,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Se(A,t,e,n,i){var o,r=1,Q=A.length,B=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(A.length<2||t.length<2)return-1;r=2,Q/=2,B/=2,e/=2}function a(A,t){return 1===r?A[t]:A.readUInt16BE(t*r)}if(i){var s=-1;for(o=e;o<Q;o++)if(a(A,o)===a(t,-1===s?0:o-s)){if(-1===s&&(s=o),o-s+1===B)return s*r}else-1!==s&&(o-=o-s),s=-1}else for(e+B>Q&&(e=Q-B),o=e;o>=0;o--){for(var l=!0,g=0;g<B;g++)if(a(A,o+g)!==a(t,g)){l=!1;break}if(l)return o}return-1}function Ve(A,t,e,n){e=Number(e)||0;var i=A.length-e;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var r=0;r<n;++r){var Q=parseInt(t.substr(2*r,2),16);if(isNaN(Q))return r;A[e+r]=Q}return r}function Ne(A,t,e,n){return An(_e(t,A.length-e),A,e,n)}function Ge(A,t,e,n){return An(function(A){for(var t=[],e=0;e<A.length;++e)t.push(255&A.charCodeAt(e));return t}(t),A,e,n)}function We(A,t,e,n){return Ge(A,t,e,n)}function Je(A,t,e,n){return An($e(t),A,e,n)}function ke(A,t,e,n){return An(function(A,t){for(var e,n,i,o=[],r=0;r<A.length&&!((t-=2)<0);++r)n=(e=A.charCodeAt(r))>>8,i=e%256,o.push(i),o.push(n);return o}(t,A.length-e),A,e,n)}function Ye(A,t,e){return 0===t&&e===A.length?se(A):se(A.slice(t,e))}function we(A,t,e){e=Math.min(A.length,e);for(var n=[],i=t;i<e;){var o,r,Q,B,a=A[i],s=null,l=a>239?4:a>223?3:a>191?2:1;if(i+l<=e)switch(l){case 1:a<128&&(s=a);break;case 2:128==(192&(o=A[i+1]))&&(B=(31&a)<<6|63&o)>127&&(s=B);break;case 3:o=A[i+1],r=A[i+2],128==(192&o)&&128==(192&r)&&(B=(15&a)<<12|(63&o)<<6|63&r)>2047&&(B<55296||B>57343)&&(s=B);break;case 4:o=A[i+1],r=A[i+2],Q=A[i+3],128==(192&o)&&128==(192&r)&&128==(192&Q)&&(B=(15&a)<<18|(63&o)<<12|(63&r)<<6|63&Q)>65535&&B<1114112&&(s=B)}null===s?(s=65533,l=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|1023&s),n.push(s),i+=l}return function(A){var t=A.length;if(t<=De)return String.fromCharCode.apply(String,A);var e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,A.slice(n,n+=De));return e}(n)}Ce.poolSize=8192,Ce._augment=function(A){return A.__proto__=Ce.prototype,A},Ce.from=function(A,t,e){return ue(null,A,t,e)},Ce.TYPED_ARRAY_SUPPORT&&(Ce.prototype.__proto__=Uint8Array.prototype,Ce.__proto__=Uint8Array),Ce.alloc=function(A,t,e){return function(A,t,e,n){return Fe(t),t<=0?he(A,t):void 0!==e?"string"==typeof n?he(A,t).fill(e,n):he(A,t).fill(e):he(A,t)}(null,A,t,e)},Ce.allocUnsafe=function(A){return Ue(null,A)},Ce.allocUnsafeSlow=function(A){return Ue(null,A)},Ce.isBuffer=tn,Ce.compare=function(A,t){if(!Ze(A)||!Ze(t))throw new TypeError("Arguments must be Buffers");if(A===t)return 0;for(var e=A.length,n=t.length,i=0,o=Math.min(e,n);i<o;++i)if(A[i]!==t[i]){e=A[i],n=t[i];break}return e<n?-1:n<e?1:0},Ce.isEncoding=function(A){switch(String(A).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ce.concat=function(A,t){if(!ce(A))throw new TypeError('"list" argument must be an Array of Buffers');if(0===A.length)return Ce.alloc(0);var e;if(void 0===t)for(t=0,e=0;e<A.length;++e)t+=A[e].length;var n=Ce.allocUnsafe(t),i=0;for(e=0;e<A.length;++e){var o=A[e];if(!Ze(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Ce.byteLength=Re,Ce.prototype._isBuffer=!0,Ce.prototype.swap16=function(){var A=this.length;if(A%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<A;t+=2)fe(this,t,t+1);return this},Ce.prototype.swap32=function(){var A=this.length;if(A%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<A;t+=4)fe(this,t,t+3),fe(this,t+1,t+2);return this},Ce.prototype.swap64=function(){var A=this.length;if(A%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<A;t+=8)fe(this,t,t+7),fe(this,t+1,t+6),fe(this,t+2,t+5),fe(this,t+3,t+4);return this},Ce.prototype.toString=function(){var A=0|this.length;return 0===A?"":0===arguments.length?we(this,0,A):be.apply(this,arguments)},Ce.prototype.equals=function(A){if(!Ze(A))throw new TypeError("Argument must be a Buffer");return this===A||0===Ce.compare(this,A)},Ce.prototype.inspect=function(){var A="";return this.length>0&&(A=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(A+=" ... ")),"<Buffer "+A+">"},Ce.prototype.compare=function(A,t,e,n,i){if(!Ze(A))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===e&&(e=A?A.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||e>A.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=e)return 0;if(n>=i)return-1;if(t>=e)return 1;if(this===A)return 0;for(var o=(i>>>=0)-(n>>>=0),r=(e>>>=0)-(t>>>=0),Q=Math.min(o,r),B=this.slice(n,i),a=A.slice(t,e),s=0;s<Q;++s)if(B[s]!==a[s]){o=B[s],r=a[s];break}return o<r?-1:r<o?1:0},Ce.prototype.includes=function(A,t,e){return-1!==this.indexOf(A,t,e)},Ce.prototype.indexOf=function(A,t,e){return ye(this,A,t,e,!0)},Ce.prototype.lastIndexOf=function(A,t,e){return ye(this,A,t,e,!1)},Ce.prototype.write=function(A,t,e,n){if(void 0===t)n="utf8",e=this.length,t=0;else if(void 0===e&&"string"==typeof t)n=t,e=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-t;if((void 0===e||e>i)&&(e=i),A.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ve(this,A,t,e);case"utf8":case"utf-8":return Ne(this,A,t,e);case"ascii":return Ge(this,A,t,e);case"latin1":case"binary":return We(this,A,t,e);case"base64":return Je(this,A,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ke(this,A,t,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Ce.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var De=4096;function Me(A,t,e){var n="";e=Math.min(A.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(127&A[i]);return n}function Te(A,t,e){var n="";e=Math.min(A.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(A[i]);return n}function Xe(A,t,e){var n=A.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=t;o<e;++o)i+=qe(A[o]);return i}function Le(A,t,e){for(var n=A.slice(t,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function xe(A,t,e){if(A%1!=0||A<0)throw new RangeError("offset is not uint");if(A+t>e)throw new RangeError("Trying to access beyond buffer length")}function ve(A,t,e,n,i,o){if(!Ze(A))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>A.length)throw new RangeError("Index out of range")}function Ke(A,t,e,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(A.length-e,2);i<o;++i)A[e+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function je(A,t,e,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(A.length-e,4);i<o;++i)A[e+i]=t>>>8*(n?i:3-i)&255}function He(A,t,e,n,i,o){if(e+n>A.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Oe(A,t,e,n,i){return i||He(A,0,e,4),ge(A,t,e,n,23,4),e+4}function ze(A,t,e,n,i){return i||He(A,0,e,8),ge(A,t,e,n,52,8),e+8}Ce.prototype.slice=function(A,t){var e,n=this.length;if((A=~~A)<0?(A+=n)<0&&(A=0):A>n&&(A=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<A&&(t=A),Ce.TYPED_ARRAY_SUPPORT)(e=this.subarray(A,t)).__proto__=Ce.prototype;else{var i=t-A;e=new Ce(i,void 0);for(var o=0;o<i;++o)e[o]=this[o+A]}return e},Ce.prototype.readUIntLE=function(A,t,e){A|=0,t|=0,e||xe(A,t,this.length);for(var n=this[A],i=1,o=0;++o<t&&(i*=256);)n+=this[A+o]*i;return n},Ce.prototype.readUIntBE=function(A,t,e){A|=0,t|=0,e||xe(A,t,this.length);for(var n=this[A+--t],i=1;t>0&&(i*=256);)n+=this[A+--t]*i;return n},Ce.prototype.readUInt8=function(A,t){return t||xe(A,1,this.length),this[A]},Ce.prototype.readUInt16LE=function(A,t){return t||xe(A,2,this.length),this[A]|this[A+1]<<8},Ce.prototype.readUInt16BE=function(A,t){return t||xe(A,2,this.length),this[A]<<8|this[A+1]},Ce.prototype.readUInt32LE=function(A,t){return t||xe(A,4,this.length),(this[A]|this[A+1]<<8|this[A+2]<<16)+16777216*this[A+3]},Ce.prototype.readUInt32BE=function(A,t){return t||xe(A,4,this.length),16777216*this[A]+(this[A+1]<<16|this[A+2]<<8|this[A+3])},Ce.prototype.readIntLE=function(A,t,e){A|=0,t|=0,e||xe(A,t,this.length);for(var n=this[A],i=1,o=0;++o<t&&(i*=256);)n+=this[A+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},Ce.prototype.readIntBE=function(A,t,e){A|=0,t|=0,e||xe(A,t,this.length);for(var n=t,i=1,o=this[A+--n];n>0&&(i*=256);)o+=this[A+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Ce.prototype.readInt8=function(A,t){return t||xe(A,1,this.length),128&this[A]?-1*(255-this[A]+1):this[A]},Ce.prototype.readInt16LE=function(A,t){t||xe(A,2,this.length);var e=this[A]|this[A+1]<<8;return 32768&e?4294901760|e:e},Ce.prototype.readInt16BE=function(A,t){t||xe(A,2,this.length);var e=this[A+1]|this[A]<<8;return 32768&e?4294901760|e:e},Ce.prototype.readInt32LE=function(A,t){return t||xe(A,4,this.length),this[A]|this[A+1]<<8|this[A+2]<<16|this[A+3]<<24},Ce.prototype.readInt32BE=function(A,t){return t||xe(A,4,this.length),this[A]<<24|this[A+1]<<16|this[A+2]<<8|this[A+3]},Ce.prototype.readFloatLE=function(A,t){return t||xe(A,4,this.length),le(this,A,!0,23,4)},Ce.prototype.readFloatBE=function(A,t){return t||xe(A,4,this.length),le(this,A,!1,23,4)},Ce.prototype.readDoubleLE=function(A,t){return t||xe(A,8,this.length),le(this,A,!0,52,8)},Ce.prototype.readDoubleBE=function(A,t){return t||xe(A,8,this.length),le(this,A,!1,52,8)},Ce.prototype.writeUIntLE=function(A,t,e,n){(A=+A,t|=0,e|=0,n)||ve(this,A,t,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[t]=255&A;++o<e&&(i*=256);)this[t+o]=A/i&255;return t+e},Ce.prototype.writeUIntBE=function(A,t,e,n){(A=+A,t|=0,e|=0,n)||ve(this,A,t,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[t+i]=255&A;--i>=0&&(o*=256);)this[t+i]=A/o&255;return t+e},Ce.prototype.writeUInt8=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,1,255,0),Ce.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),this[t]=255&A,t+1},Ce.prototype.writeUInt16LE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,2,65535,0),Ce.TYPED_ARRAY_SUPPORT?(this[t]=255&A,this[t+1]=A>>>8):Ke(this,A,t,!0),t+2},Ce.prototype.writeUInt16BE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,2,65535,0),Ce.TYPED_ARRAY_SUPPORT?(this[t]=A>>>8,this[t+1]=255&A):Ke(this,A,t,!1),t+2},Ce.prototype.writeUInt32LE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,4,4294967295,0),Ce.TYPED_ARRAY_SUPPORT?(this[t+3]=A>>>24,this[t+2]=A>>>16,this[t+1]=A>>>8,this[t]=255&A):je(this,A,t,!0),t+4},Ce.prototype.writeUInt32BE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,4,4294967295,0),Ce.TYPED_ARRAY_SUPPORT?(this[t]=A>>>24,this[t+1]=A>>>16,this[t+2]=A>>>8,this[t+3]=255&A):je(this,A,t,!1),t+4},Ce.prototype.writeIntLE=function(A,t,e,n){if(A=+A,t|=0,!n){var i=Math.pow(2,8*e-1);ve(this,A,t,e,i-1,-i)}var o=0,r=1,Q=0;for(this[t]=255&A;++o<e&&(r*=256);)A<0&&0===Q&&0!==this[t+o-1]&&(Q=1),this[t+o]=(A/r>>0)-Q&255;return t+e},Ce.prototype.writeIntBE=function(A,t,e,n){if(A=+A,t|=0,!n){var i=Math.pow(2,8*e-1);ve(this,A,t,e,i-1,-i)}var o=e-1,r=1,Q=0;for(this[t+o]=255&A;--o>=0&&(r*=256);)A<0&&0===Q&&0!==this[t+o+1]&&(Q=1),this[t+o]=(A/r>>0)-Q&255;return t+e},Ce.prototype.writeInt8=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,1,127,-128),Ce.TYPED_ARRAY_SUPPORT||(A=Math.floor(A)),A<0&&(A=255+A+1),this[t]=255&A,t+1},Ce.prototype.writeInt16LE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,2,32767,-32768),Ce.TYPED_ARRAY_SUPPORT?(this[t]=255&A,this[t+1]=A>>>8):Ke(this,A,t,!0),t+2},Ce.prototype.writeInt16BE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,2,32767,-32768),Ce.TYPED_ARRAY_SUPPORT?(this[t]=A>>>8,this[t+1]=255&A):Ke(this,A,t,!1),t+2},Ce.prototype.writeInt32LE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,4,2147483647,-2147483648),Ce.TYPED_ARRAY_SUPPORT?(this[t]=255&A,this[t+1]=A>>>8,this[t+2]=A>>>16,this[t+3]=A>>>24):je(this,A,t,!0),t+4},Ce.prototype.writeInt32BE=function(A,t,e){return A=+A,t|=0,e||ve(this,A,t,4,2147483647,-2147483648),A<0&&(A=4294967295+A+1),Ce.TYPED_ARRAY_SUPPORT?(this[t]=A>>>24,this[t+1]=A>>>16,this[t+2]=A>>>8,this[t+3]=255&A):je(this,A,t,!1),t+4},Ce.prototype.writeFloatLE=function(A,t,e){return Oe(this,A,t,!0,e)},Ce.prototype.writeFloatBE=function(A,t,e){return Oe(this,A,t,!1,e)},Ce.prototype.writeDoubleLE=function(A,t,e){return ze(this,A,t,!0,e)},Ce.prototype.writeDoubleBE=function(A,t,e){return ze(this,A,t,!1,e)},Ce.prototype.copy=function(A,t,e,n){if(e||(e=0),n||0===n||(n=this.length),t>=A.length&&(t=A.length),t||(t=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===A.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),A.length-t<n-e&&(n=A.length-t+e);var i,o=n-e;if(this===A&&e<t&&t<n)for(i=o-1;i>=0;--i)A[i+t]=this[i+e];else if(o<1e3||!Ce.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)A[i+t]=this[i+e];else Uint8Array.prototype.set.call(A,this.subarray(e,e+o),t);return o},Ce.prototype.fill=function(A,t,e,n){if("string"==typeof A){if("string"==typeof t?(n=t,t=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===A.length){var i=A.charCodeAt(0);i<256&&(A=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Ce.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof A&&(A&=255);if(t<0||this.length<t||this.length<e)throw new RangeError("Out of range index");if(e<=t)return this;var o;if(t>>>=0,e=void 0===e?this.length:e>>>0,A||(A=0),"number"==typeof A)for(o=t;o<e;++o)this[o]=A;else{var r=Ze(A)?A:_e(new Ce(A,n).toString()),Q=r.length;for(o=0;o<e-t;++o)this[o+t]=r[o%Q]}return this};var Pe=/[^+\/0-9A-Za-z-_]/g;function qe(A){return A<16?"0"+A.toString(16):A.toString(16)}function _e(A,t){var e;t=t||1/0;for(var n=A.length,i=null,o=[],r=0;r<n;++r){if((e=A.charCodeAt(r))>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(r+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(t-=3)>