{"version":3,"file":"media-encoder-host-Ci7IbZFG.js","sources":["../../node_modules/media-encoder-host/build/es2019/worker/worker.js","../../node_modules/media-encoder-host/build/es2019/module.js"],"sourcesContent":["// This is the minified and stringified code of the media-encoder-host-worker package.\nexport const worker = `(()=>{var e={455:function(e,t){!function(e){\"use strict\";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:an)throw new Error(\"Congratulations, you created a collection of unique numbers which uses all available integers!\");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),d=a(i,c),l=t(d);e.addUniqueNumber=l,e.generateUniqueNumber=d}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{\"use strict\";var e=r(455);const t=new WeakMap,n=new WeakMap,o=(r=>{const o=(s=r,{...s,connect:({call:e})=>async()=>{const{port1:r,port2:n}=new MessageChannel,o=await e(\"connect\",{port:r},[r]);return t.set(n,o),n},disconnect:({call:e})=>async r=>{const n=t.get(r);if(void 0===n)throw new Error(\"The given port is not connected.\");await e(\"disconnect\",{portId:n})},isSupported:({call:e})=>()=>e(\"isSupported\")});var s;return t=>{const r=(e=>{if(n.has(e))return n.get(e);const t=new Map;return n.set(e,t),t})(t);t.addEventListener(\"message\",(({data:e})=>{const{id:t}=e;if(null!==t&&r.has(t)){const{reject:n,resolve:o}=r.get(t);r.delete(t),void 0===e.error?o(e.result):n(new Error(e.error.message))}})),(e=>\"function\"==typeof e.start)(t)&&t.start();const s=(n,o=null,s=[])=>new Promise(((a,c)=>{const i=(0,e.generateUniqueNumber)(r);r.set(i,{reject:c,resolve:a}),null===o?t.postMessage({id:i,method:n},s):t.postMessage({id:i,method:n,params:o},s)})),a=(e,r,n=[])=>{t.postMessage({id:null,method:e,params:r},n)};let c={};for(const[e,t]of Object.entries(o))c={...c,[e]:t({call:s,notify:a})};return{...c}}})({characterize:({call:e})=>()=>e(\"characterize\"),encode:({call:e})=>(t,r)=>e(\"encode\",{recordingId:t,timeslice:r}),record:({call:e})=>async(t,r,n)=>{await e(\"record\",{recordingId:t,sampleRate:r,typedArrays:n},n.map((({buffer:e})=>e)))}}),s=-32603,a=-32602,c=-32601,i=(e,t)=>Object.assign(new Error(e),{status:t}),d=e=>i('The handler of the method called \"'.concat(e,'\" returned an unexpected result.'),s),l=(e,t)=>async({data:{id:r,method:n,params:o}})=>{const a=t[n];try{if(void 0===a)throw(e=>i('The requested method called \"'.concat(e,'\" is not supported.'),c))(n);const t=void 0===o?a():a(o);if(void 0===t)throw(e=>i('The handler of the method called \"'.concat(e,'\" returned no required result.'),s))(n);const l=t instanceof Promise?await t:t;if(null===r){if(void 0!==l.result)throw d(n)}else{if(void 0===l.result)throw d(n);const{result:t,transferables:o=[]}=l;e.postMessage({id:r,result:t},o)}}catch(t){const{message:n,status:o=-32603}=t;e.postMessage({error:{code:o,message:n},id:r})}},u=new Map,h=(t,r,n)=>({...r,connect:({port:n})=>{n.start();const o=t(n,r),s=(0,e.generateUniqueNumber)(u);return u.set(s,(()=>{o(),n.close(),u.delete(s)})),{result:s}},disconnect:({portId:e})=>{const t=u.get(e);if(void 0===t)throw(e=>i('The specified parameter called \"portId\" with the given value \"'.concat(e,'\" does not identify a port connected to this worker.'),a))(e);return t(),{result:null}},isSupported:async()=>{if(await new Promise((e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])}))){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),w=(e,t,r=()=>!0)=>{const n=h(w,t,r),o=l(e,n);return e.addEventListener(\"message\",o),()=>e.removeEventListener(\"message\",o)},f=e=>{e.onmessage=null,e.close()},p=new Map,m=new Map,g=((e,t)=>r=>{const n=t.get(r);if(void 0===n)throw new Error(\"There was no encoder stored with the given id.\");e.delete(n),t.delete(r)})(p,m),v=new Map,y=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error(\"There was no instance of an encoder stored with the given id.\");return r})(v),M=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(v,y),E=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise((t=>{o.onmessage=({data:s})=>{0===s.length?(e(o),t(n.encode(r,null))):n.record(r,a,s)}})):n.encode(r,null)})(f,M),b=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error(\"There is no encoder registered which could handle the given mimeType.\")})(p),T=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error('There is already an encoder instance registered with an id called \"'.concat(n,'\".'));const a=r(o),{port1:c,port2:i}=new MessageChannel,d=[a,c,!0,s];return t.set(n,d),c.onmessage=({data:t})=>{0===t.length?(e(c),d[2]=!1):a.record(n,s,t.map((e=>\"number\"==typeof e?new Float32Array(e):e)))},i})(f,v,b),I=((e,t,r)=>async(n,o)=>{const s=r(o),a=await s.characterize(),c=a.toString();if(e.has(c))throw new Error(\"There is already an encoder stored which handles exactly the same mime types.\");if(t.has(n))throw new Error('There is already an encoder registered with an id called \"'.concat(n,'\".'));return e.set(c,[a,s]),t.set(n,c),a})(p,m,o),A=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(y);w(self,{deregister:async({encoderId:e})=>(g(e),{result:null}),encode:async({encoderInstanceId:e,timeslice:t})=>{const r=null===t?await E(e):await A(e,t);return{result:r,transferables:r}},instantiate:({encoderInstanceId:e,mimeType:t,sampleRate:r})=>{const n=T(e,t,r);return{result:n,transferables:[n]}},register:async({encoderId:e,port:t})=>({result:await I(e,t)})})})()})();`; // tslint:disable-line:max-line-length\n//# sourceMappingURL=worker.js.map","import { load as loadWorker } from 'media-encoder-host-broker';\nimport { worker } from './worker/worker';\nconst blob = new Blob([worker], { type: 'application/javascript; charset=utf-8' });\nconst url = URL.createObjectURL(blob);\nconst mediaEncoderHost = loadWorker(url);\nexport const connect = mediaEncoderHost.connect;\nexport const deregister = mediaEncoderHost.deregister;\nexport const disconnect = mediaEncoderHost.disconnect;\nexport const encode = mediaEncoderHost.encode;\nexport const instantiate = mediaEncoderHost.instantiate;\nexport const isSupported = mediaEncoderHost.isSupported;\nexport const register = mediaEncoderHost.register;\nURL.revokeObjectURL(url);\n//# sourceMappingURL=module.js.map"],"names":["worker","blob","url","mediaEncoderHost","loadWorker","encode","instantiate","register"],"mappings":"qYACO,MAAMA,EAAS,q9KCChBC,EAAO,IAAI,KAAK,CAACD,CAAM,EAAG,CAAE,KAAM,wCAAyC,EAC3EE,EAAM,IAAI,gBAAgBD,CAAI,EAC9BE,EAAmBC,EAAWF,CAAG,EAI1BG,EAASF,EAAiB,OAC1BG,EAAcH,EAAiB,YAE/BI,EAAWJ,EAAiB,SACzC,IAAI,gBAAgBD,CAAG","x_google_ignoreList":[0,1]}