UNPKG

@deepgram/sdk

Version:

Isomorphic Javascript client for Deepgram

1 lines 84 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepgram=t():e.deepgram=t()}(self,(()=>(()=>{var e={367:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OnPremClient=t.SelfHostedRestClient=void 0;const s=r(4306),o=r(5096);class i extends o.AbstractRestClient{constructor(){super(...arguments),this.namespace="selfhosted"}listCredentials(e,t=":version/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const r=this.getRequestUrl(t,{projectId:e});return{result:yield this.get(r).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getCredentials(e,t,r=":version/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=this.getRequestUrl(r,{projectId:e,credentialsId:t});return{result:yield this.get(n).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createCredentials(e,t,r=":version/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const n=this.getRequestUrl(r,{projectId:e}),s=JSON.stringify(t);return{result:yield this.post(n,s).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteCredentials(e,t,r=":version/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=this.getRequestUrl(r,{projectId:e,credentialsId:t});return{result:yield this.delete(n).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.SelfHostedRestClient=i,t.OnPremClient=i},398:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakClient=void 0;const n=r(5066),s=r(3712),o=r(4492);class i extends n.AbstractClient{constructor(){super(...arguments),this.namespace="speak"}request(e,t,r=":version/speak"){return new o.SpeakRestClient(this.options).request(e,t,r)}live(e={},t=":version/speak"){return new s.SpeakLiveClient(this.options,e,t)}}t.SpeakClient=i},459:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},472:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthRestClient=void 0;const s=r(4306),o=r(5096);class i extends o.AbstractRestClient{constructor(){super(...arguments),this.namespace="auth"}grantToken(e={},t=":version/auth/grant"){return n(this,void 0,void 0,(function*(){try{const r=this.getRequestUrl(t),n=JSON.stringify(e);return{result:yield this.post(r,n,{headers:{"Content-Type":"application/json"}}).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.AuthRestClient=i},569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},684:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.convertLegacyOptions=t.isDeepgramClientOptions=t.isLiveSchema=t.buildRequestUrl=t.convertProtocolToWs=t.CallbackUrl=t.isFileSource=t.isTextSource=t.isUrlSource=t.resolveHeadersConstructor=t.appendSearchParams=t.applyDefaults=t.stripTrailingSlash=void 0;const s=r(8389),o=n(r(7314)),i=r(5793);function a(e,t){Object.keys(t).forEach((r=>{Array.isArray(t[r])?t[r].forEach((t=>{e.append(r,String(t))})):e.append(r,String(t[r]))}))}t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.applyDefaults=function(e={},t={}){return(0,o.default)(t,e)},t.appendSearchParams=a,t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?s.Headers:Headers,t.isUrlSource=e=>!(!e||!e.url),t.isTextSource=e=>!(!e||!e.text),t.isFileSource=e=>!(!c(e)&&!u(e));const u=e=>null!=e&&Buffer.isBuffer(e),c=e=>null!=e&&!(0,i.isBrowser)()&&"object"==typeof e&&"function"==typeof e.pipe&&"function"==typeof e.read&&"object"==typeof e._readableState;class l extends URL{constructor(){super(...arguments),this.callbackUrl=!0}}t.CallbackUrl=l,t.convertProtocolToWs=e=>e.toLowerCase().replace(/^http/,"ws"),t.buildRequestUrl=(e,t,r)=>{const n=new URL(e,t);return a(n.searchParams,r),n},t.isLiveSchema=function(e){return null!=e&&void 0!==e.interim_results},t.isDeepgramClientOptions=function(e){return null!=e&&void 0!==e.global},t.convertLegacyOptions=e=>{var t,r,n,s,i,a;const u={};return e._experimentalCustomFetch&&(u.global={fetch:{client:e._experimentalCustomFetch}}),(null===(t=(e=(0,o.default)(e,u)).restProxy)||void 0===t?void 0:t.url)&&(u.global={fetch:{options:{proxy:{url:null===(r=e.restProxy)||void 0===r?void 0:r.url}}}}),(null===(n=(e=(0,o.default)(e,u)).global)||void 0===n?void 0:n.url)&&(u.global={fetch:{options:{url:e.global.url}},websocket:{options:{url:e.global.url}}}),(null===(s=(e=(0,o.default)(e,u)).global)||void 0===s?void 0:s.headers)&&(u.global={fetch:{options:{headers:null===(i=e.global)||void 0===i?void 0:i.headers}},websocket:{options:{_nodeOnlyHeaders:null===(a=e.global)||void 0===a?void 0:a.headers}}}),(0,o.default)(e,u)}},740:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractWsClient=t.AbstractLiveClient=void 0;const a=r(5066),u=r(8712),c=r(5793),l=r(4306),d="undefined"!=typeof WebSocket;class h extends a.AbstractClient{constructor(e){super(e),this.conn=null,this.sendBuffer=[],this.reconnect=a.noop;const{key:t,websocket:{options:r,client:n}}=this.namespaceOptions;this.proxy?this.baseUrl=r.proxy.url:this.baseUrl=r.url,this.transport=n||null,r._nodeOnlyHeaders?this.headers=r._nodeOnlyHeaders:this.headers={},"Authorization"in this.headers||(this.accessToken?this.headers.Authorization=`Bearer ${this.accessToken}`:this.headers.Authorization=`Token ${t}`)}connect(e,t){if(this.conn)return;this.reconnect=(r=e)=>{this.connect(r,t)};const n=this.getRequestUrl(t,{},e),s=this.accessToken,i=this.key;if(!s&&!i)throw new Error("No key or access token provided for WebSocket connection.");return this.transport?(this.conn=new this.transport(n,void 0,{headers:this.headers}),void this.setupConnection()):(0,c.isBun)()?(Promise.resolve().then((()=>o(r(3584)))).then((({default:e})=>{this.conn=new e(n,{headers:this.headers}),console.log("Using WS package")})),void this.setupConnection()):d?(this.conn=new WebSocket(n,s?["bearer",s]:["token",i]),void this.setupConnection()):(this.conn=new p(n,void 0,{close:()=>{this.conn=null}}),Promise.resolve().then((()=>o(r(3584)))).then((({default:e})=>{this.conn=new e(n,void 0,{headers:this.headers})})),void this.setupConnection())}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,null!=t?t:""):this.conn.close(),this.conn=null)}connectionState(){switch(this.conn&&this.conn.readyState){case u.SOCKET_STATES.connecting:return u.CONNECTION_STATE.Connecting;case u.SOCKET_STATES.open:return u.CONNECTION_STATE.Open;case u.SOCKET_STATES.closing:return u.CONNECTION_STATE.Closing;default:return u.CONNECTION_STATE.Closed}}getReadyState(){var e,t;return null!==(t=null===(e=this.conn)||void 0===e?void 0:e.readyState)&&void 0!==t?t:u.SOCKET_STATES.closed}isConnected(){return this.connectionState()===u.CONNECTION_STATE.Open}send(e){const t=()=>i(this,void 0,void 0,(function*(){var t;if(e instanceof Blob){if(0===e.size)return void this.log("warn","skipping `send` for zero-byte blob",e);e=yield e.arrayBuffer()}"string"==typeof e||(null==e?void 0:e.byteLength)?null===(t=this.conn)||void 0===t||t.send(e):this.log("warn","skipping `send` for zero-byte payload",e)}));this.isConnected()?t():this.sendBuffer.push(t)}get proxy(){var e;return"proxy"===this.key&&!!(null===(e=this.namespaceOptions.websocket.options.proxy)||void 0===e?void 0:e.url)}extractErrorInformation(e,t){var r;const n={};if(t&&(n.readyState=t.readyState,n.url="string"==typeof t.url?t.url:null===(r=t.url)||void 0===r?void 0:r.toString()),t&&"object"==typeof t){const r=t;if(r._req&&r._req.res&&(n.statusCode=r._req.res.statusCode,r._req.res.headers)){n.responseHeaders=Object.assign({},r._req.res.headers);const e=r._req.res.headers["dg-request-id"]||r._req.res.headers["x-dg-request-id"];e&&(n.requestId=e)}if(e&&"target"in e&&e.target){const t=e.target;t.url&&(n.url=t.url),void 0!==t.readyState&&(n.readyState=t.readyState)}}return n}createEnhancedError(e,t){const r=new l.DeepgramWebSocketError(e.message||"WebSocket connection error",Object.assign({originalEvent:e},t));return Object.assign(Object.assign({},e),{error:r,statusCode:t.statusCode,requestId:t.requestId,responseHeaders:t.responseHeaders,url:t.url,readyState:t.readyState,message:this.buildEnhancedErrorMessage(e,t)})}buildEnhancedErrorMessage(e,t){let r=e.message||"WebSocket connection error";const n=[];if(t.statusCode&&n.push(`Status: ${t.statusCode}`),t.requestId&&n.push(`Request ID: ${t.requestId}`),void 0!==t.readyState){const e=["CONNECTING","OPEN","CLOSING","CLOSED"][t.readyState]||`Unknown(${t.readyState})`;n.push(`Ready State: ${e}`)}return t.url&&n.push(`URL: ${t.url}`),n.length>0&&(r+=` (${n.join(", ")})`),r}setupConnectionEvents(e){this.conn&&(this.conn.onopen=()=>{this.emit(e.Open,this)},this.conn.onclose=t=>{this.emit(e.Close,t)},this.conn.onerror=t=>{const r=this.extractErrorInformation(t,this.conn||void 0),n=this.createEnhancedError(t,r);this.emit(e.Error,n)})}}t.AbstractLiveClient=h,t.AbstractWsClient=h;class p{constructor(e,t,r){this.binaryType="arraybuffer",this.onclose=()=>{},this.onerror=()=>{},this.onmessage=()=>{},this.onopen=()=>{},this.readyState=u.SOCKET_STATES.connecting,this.send=()=>{},this.url=null,this.url=e.toString(),this.close=r.close}}},747:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},753:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},816:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},875:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListenClient=void 0;const n=r(5066),s=r(5357),o=r(6733);class i extends n.AbstractClient{constructor(){super(...arguments),this.namespace="listen"}get prerecorded(){return new o.ListenRestClient(this.options)}live(e={},t=":version/listen"){return new s.ListenLiveClient(this.options,e,t)}}t.ListenClient=i},986:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTTSEvents=void 0,(r=t.LiveTTSEvents||(t.LiveTTSEvents={})).Open="Open",r.Close="Close",r.Error="Error",r.Metadata="Metadata",r.Flushed="Flushed",r.Warning="Warning",r.Audio="Audio",r.Unhandled="Unhandled"},1176:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.AgentEvents=void 0,(r=t.AgentEvents||(t.AgentEvents={})).Open="Open",r.Close="Close",r.Error="Error",r.Audio="Audio",r.Welcome="Welcome",r.SettingsApplied="SettingsApplied",r.ConversationText="ConversationText",r.UserStartedSpeaking="UserStartedSpeaking",r.AgentThinking="AgentThinking",r.FunctionCallRequest="FunctionCallRequest",r.AgentStartedSpeaking="AgentStartedSpeaking",r.AgentAudioDone="AgentAudioDone",r.InjectionRefused="InjectionRefused",r.PromptUpdated="PromptUpdated",r.SpeakUpdated="SpeakUpdated",r.Unhandled="Unhandled"},1221:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1556:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1557:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1749:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1775:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1828:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1901:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2043:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AgentLiveClient=void 0;const n=r(8712),s=r(1176),o=r(740);class i extends o.AbstractLiveClient{constructor(e,t="/:version/agent/converse"){var r,s,o,i;super(e),this.namespace="agent",this.baseUrl=null!==(i=null===(o=null===(s=null===(r=e.agent)||void 0===r?void 0:r.websocket)||void 0===s?void 0:s.options)||void 0===o?void 0:o.url)&&void 0!==i?i:n.DEFAULT_AGENT_URL,this.connect({},t)}setupConnection(){this.setupConnectionEvents({Open:s.AgentEvents.Open,Close:s.AgentEvents.Close,Error:s.AgentEvents.Error}),this.conn&&(this.conn.onmessage=e=>{this.handleMessage(e)})}handleMessage(e){var t,r,n,o,i,a;if("string"==typeof e.data)try{const t=JSON.parse(e.data);this.handleTextMessage(t)}catch(i){this.emit(s.AgentEvents.Error,{event:e,data:(null===(t=e.data)||void 0===t?void 0:t.toString().substring(0,200))+((null===(r=e.data)||void 0===r?void 0:r.toString().length)>200?"...":""),message:"Unable to parse `data` as JSON.",error:i,url:null===(n=this.conn)||void 0===n?void 0:n.url,readyState:null===(o=this.conn)||void 0===o?void 0:o.readyState})}else e.data instanceof Blob?e.data.arrayBuffer().then((e=>{this.handleBinaryMessage(Buffer.from(e))})):e.data instanceof ArrayBuffer?this.handleBinaryMessage(Buffer.from(e.data)):Buffer.isBuffer(e.data)?this.handleBinaryMessage(e.data):(console.log("Received unknown data type",e.data),this.emit(s.AgentEvents.Error,{event:e,message:"Received unknown data type.",url:null===(i=this.conn)||void 0===i?void 0:i.url,readyState:null===(a=this.conn)||void 0===a?void 0:a.readyState,dataType:typeof e.data}))}handleBinaryMessage(e){this.emit(s.AgentEvents.Audio,e)}handleTextMessage(e){e.type in s.AgentEvents?this.emit(e.type,e):this.emit(s.AgentEvents.Unhandled,e)}configure(e){const t=JSON.stringify(Object.assign({type:"Settings"},e));this.send(t)}updatePrompt(e){this.send(JSON.stringify({type:"UpdatePrompt",prompt:e}))}updateSpeak(e){this.send(JSON.stringify({type:"UpdateSpeak",speak:e}))}injectAgentMessage(e){this.send(JSON.stringify({type:"InjectAgentMessage",content:e}))}injectUserMessage(e){this.send(JSON.stringify({type:"InjectUserMessage",content:e}))}functionCallResponse(e){this.send(JSON.stringify(Object.assign({type:"FunctionCallResponse"},e)))}keepAlive(){this.send(JSON.stringify({type:"KeepAlive"}))}}t.AgentLiveClient=i},2171:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),s(r(3075),t),s(r(816),t),s(r(9836),t),s(r(8633),t),s(r(1901),t),s(r(3036),t),s(r(4852),t),s(r(5263),t),s(r(1749),t),s(r(9115),t),s(r(459),t),s(r(6544),t),s(r(8034),t),s(r(9518),t),s(r(8968),t),s(r(2701),t),s(r(8785),t),s(r(5874),t),s(r(9176),t),s(r(8457),t),s(r(3150),t),s(r(1557),t),s(r(4329),t),s(r(9042),t),s(r(6302),t),s(r(4592),t),s(r(8600),t),s(r(7205),t),s(r(747),t),s(r(9475),t),s(r(569),t),s(r(1221),t),s(r(8378),t),s(r(753),t),s(r(1775),t),s(r(2278),t),s(r(7034),t),s(r(4602),t),s(r(7897),t),s(r(1556),t),s(r(6180),t),s(r(1828),t),s(r(8502),t),s(r(4775),t),s(r(4198),t)},2278:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2701:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3036:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3063:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveConnectionState=void 0;const n=r(8712);var s;(s=t.LiveConnectionState||(t.LiveConnectionState={}))[s.CONNECTING=n.SOCKET_STATES.connecting]="CONNECTING",s[s.OPEN=n.SOCKET_STATES.open]="OPEN",s[s.CLOSING=n.SOCKET_STATES.closing]="CLOSING",s[s.CLOSED=n.SOCKET_STATES.closed]="CLOSED"},3075:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3150:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3242:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ReadClient=t.ReadRestClient=void 0;const s=r(684),o=r(4306),i=r(5096);class a extends i.AbstractRestClient{constructor(){super(...arguments),this.namespace="read"}analyzeUrl(e,t,r=":version/read"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `analyzeUrlCallback` or `analyzeTextCallback` instead.");const i=this.getRequestUrl(r,{},Object.assign({},t));return{result:yield this.post(i,n).then((e=>e.json())),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}analyzeText(e,t,r=":version/read"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isTextSource)(e))throw new o.DeepgramError("Unknown source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous requests. Use `analyzeUrlCallback` or `analyzeTextCallback` instead.");const i=this.getRequestUrl(r,{},Object.assign({},t));return{result:yield this.post(i,n).then((e=>e.json())),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}analyzeUrlCallback(e,t,r,i=":version/read"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown source type");n=JSON.stringify(e);const a=this.getRequestUrl(i,{},Object.assign(Object.assign({},r),{callback:t.toString()}));return{result:yield this.post(a,n).then((e=>e.json())),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}analyzeTextCallback(e,t,r,i=":version/read"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isTextSource)(e))throw new o.DeepgramError("Unknown source type");n=JSON.stringify(e);const a=this.getRequestUrl(i,{},Object.assign(Object.assign({},r),{callback:t.toString()}));return{result:yield this.post(a,n,{headers:{"Content-Type":"deepgram/audio+video"}}).then((e=>e.json())),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ReadRestClient=a,t.ReadClient=a},3465:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.srt=t.webvtt=t.Deepgram=t.DeepgramClient=t.createClient=void 0;const i=r(4306),a=o(r(3695));t.DeepgramClient=a.default,t.Deepgram=class{constructor(e,t,r){throw this.apiKey=e,this.apiUrl=t,this.requireSSL=r,new i.DeepgramVersionError}},t.createClient=function(e,t){let r={};return"string"==typeof e||"function"==typeof e?("object"==typeof t&&(r=t),r.key=e):"object"==typeof e&&(r=e),new a.default(r)},s(r(6731),t),s(r(2171),t),s(r(6416),t),s(r(8712),t),s(r(4306),t),s(r(684),t);var u=r(6327);Object.defineProperty(t,"webvtt",{enumerable:!0,get:function(){return u.webvtt}}),Object.defineProperty(t,"srt",{enumerable:!0,get:function(){return u.srt}})},3584:e=>{"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},3695:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(4306),s=r(6731);class o extends s.AbstractClient{get auth(){return new s.AuthRestClient(this.options)}get listen(){return new s.ListenClient(this.options)}get manage(){return new s.ManageClient(this.options)}get models(){return new s.ModelsRestClient(this.options)}get onprem(){return this.selfhosted}get selfhosted(){return new s.SelfHostedRestClient(this.options)}get read(){return new s.ReadClient(this.options)}get speak(){return new s.SpeakClient(this.options)}agent(e="/:version/agent/converse"){return new s.AgentLiveClient(this.options,e)}get transcription(){throw new n.DeepgramVersionError}get projects(){throw new n.DeepgramVersionError}get keys(){throw new n.DeepgramVersionError}get members(){throw new n.DeepgramVersionError}get scopes(){throw new n.DeepgramVersionError}get invitation(){throw new n.DeepgramVersionError}get usage(){throw new n.DeepgramVersionError}get billing(){throw new n.DeepgramVersionError}}t.default=o},3712:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakLiveClient=void 0;const n=r(740),s=r(6416);class o extends n.AbstractLiveClient{constructor(e,t={},r=":version/speak"){super(e),this.namespace="speak",this.connect(t,r)}setupConnection(){this.setupConnectionEvents({Open:s.LiveTTSEvents.Open,Close:s.LiveTTSEvents.Close,Error:s.LiveTTSEvents.Error}),this.conn&&(this.conn.onmessage=e=>{this.handleMessage(e)})}handleTextMessage(e){e.type===s.LiveTTSEvents.Metadata?this.emit(s.LiveTTSEvents.Metadata,e):e.type===s.LiveTTSEvents.Flushed?this.emit(s.LiveTTSEvents.Flushed,e):e.type===s.LiveTTSEvents.Warning?this.emit(s.LiveTTSEvents.Warning,e):this.emit(s.LiveTTSEvents.Unhandled,e)}handleBinaryMessage(e){this.emit(s.LiveTTSEvents.Audio,e)}sendText(e){this.send(JSON.stringify({type:"Speak",text:e}))}flush(){this.send(JSON.stringify({type:"Flush"}))}clear(){this.send(JSON.stringify({type:"Clear"}))}requestClose(){this.send(JSON.stringify({type:"Close"}))}handleMessage(e){var t,r,n,o,i,a;if("string"==typeof e.data)try{const t=JSON.parse(e.data);this.handleTextMessage(t)}catch(i){this.emit(s.LiveTTSEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:i,url:null===(t=this.conn)||void 0===t?void 0:t.url,readyState:null===(r=this.conn)||void 0===r?void 0:r.readyState,data:(null===(n=e.data)||void 0===n?void 0:n.toString().substring(0,200))+((null===(o=e.data)||void 0===o?void 0:o.toString().length)>200?"...":"")})}else e.data instanceof Blob?e.data.arrayBuffer().then((e=>{this.handleBinaryMessage(Buffer.from(e))})):e.data instanceof ArrayBuffer?this.handleBinaryMessage(Buffer.from(e.data)):Buffer.isBuffer(e.data)?this.handleBinaryMessage(e.data):(console.log("Received unknown data type",e.data),this.emit(s.LiveTTSEvents.Error,{event:e,message:"Received unknown data type.",url:null===(i=this.conn)||void 0===i?void 0:i.url,readyState:null===(a=this.conn)||void 0===a?void 0:a.readyState,dataType:typeof e.data}))}}t.SpeakLiveClient=o},4198:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4268:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,s,o){var i=s.prototype;o.utc=function(e){return new s({date:e,utc:!0,args:arguments})},i.utc=function(t){var r=o(this.toDate(),{locale:this.$L,utc:!0});return t?r.add(this.utcOffset(),e):r},i.local=function(){return o(this.toDate(),{locale:this.$L,utc:!1})};var a=i.parse;i.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),a.call(this,e)};var u=i.init;i.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var c=i.utcOffset;i.utcOffset=function(n,s){var o=this.$utils().u;if(o(n))return this.$u?0:o(this.$offset)?c.call(this):this.$offset;if("string"==typeof n&&(n=function(e){void 0===e&&(e="");var n=e.match(t);if(!n)return null;var s=(""+n[0]).match(r)||["-",0,0],o=s[0],i=60*+s[1]+ +s[2];return 0===i?0:"+"===o?i:-i}(n),null===n))return this;var i=Math.abs(n)<=16?60*n:n,a=this;if(s)return a.$offset=i,a.$u=0===n,a;if(0!==n){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(i+u,e)).$offset=i,a.$x.$localOffset=u}else a=this.utc();return a};var l=i.format;i.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,t)},i.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},i.isUTC=function(){return!!this.$u},i.toISOString=function(){return this.toDate().toISOString()},i.toString=function(){return this.toDate().toUTCString()};var d=i.toDate;i.toDate=function(e){return"s"===e&&this.$offset?o(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var h=i.diff;i.diff=function(e,t,r){if(e&&this.$u===e.$u)return h.call(this,e,t,r);var n=this.local(),s=o(e).local();return h.call(n,s,t,r)}}}()},4306:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramWebSocketError=t.DeepgramVersionError=t.DeepgramUnknownError=t.DeepgramApiError=t.isDeepgramError=t.DeepgramError=void 0;class r extends Error{constructor(e){super(e),this.__dgError=!0,this.name="DeepgramError"}}t.DeepgramError=r,t.isDeepgramError=function(e){return"object"==typeof e&&null!==e&&"__dgError"in e},t.DeepgramApiError=class extends r{constructor(e,t){super(e),this.name="DeepgramApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},t.DeepgramUnknownError=class extends r{constructor(e,t){super(e),this.name="DeepgramUnknownError",this.originalError=t}},t.DeepgramVersionError=class extends r{constructor(){super("You are attempting to use an old format for a newer SDK version. Read more here: https://dpgr.am/js-v3"),this.name="DeepgramVersionError"}},t.DeepgramWebSocketError=class extends r{constructor(e,t={}){super(e),this.name="DeepgramWebSocketError",this.originalEvent=t.originalEvent,this.statusCode=t.statusCode,this.requestId=t.requestId,this.responseHeaders=t.responseHeaders,this.url=t.url,this.readyState=t.readyState}toJSON(){return{name:this.name,message:this.message,statusCode:this.statusCode,requestId:this.requestId,responseHeaders:this.responseHeaders,url:this.url,readyState:this.readyState,originalEvent:this.originalEvent?{type:this.originalEvent.type,timeStamp:this.originalEvent.timeStamp}:void 0}}}},4329:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4492:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.SpeakRestClient=void 0;const s=r(4306),o=r(684),i=r(5096);class a extends i.AbstractRestClient{constructor(){super(...arguments),this.namespace="speak"}request(e,t,r=":version/speak"){return n(this,void 0,void 0,(function*(){let n;if(!(0,o.isTextSource)(e))throw new s.DeepgramError("Unknown transcription source type");n=JSON.stringify(e);const i=this.getRequestUrl(r,{},Object.assign({model:"aura-2-thalia-en"},t));return this.result=yield this.post(i,n,{headers:{Accept:"audio/*","Content-Type":"application/json"}}),this}))}getStream(){return n(this,void 0,void 0,(function*(){if(!this.result)throw new s.DeepgramUnknownError("Tried to get stream before making request","");return this.result.body}))}getHeaders(){return n(this,void 0,void 0,(function*(){if(!this.result)throw new s.DeepgramUnknownError("Tried to get headers before making request","");return this.result.headers}))}}t.SpeakRestClient=a},4592:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4602:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4775:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},4852:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5066:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractClient=t.noop=void 0;const n=r(9784),s=r(8712),o=r(4306),i=r(684);t.noop=()=>{};class a extends n.EventEmitter{constructor(e){if(super(),this.factory=void 0,this.key=void 0,this.accessToken=void 0,this.namespace="global",this.version="v1",this.baseUrl=s.DEFAULT_URL,this.logger=t.noop,"function"==typeof e.accessToken?(this.factory=e.accessToken,this.accessToken=this.factory()):this.accessToken=e.accessToken,"function"==typeof e.key?(this.factory=e.key,this.key=this.factory()):this.key=e.key,this.key||this.accessToken||(this.accessToken=process.env.DEEPGRAM_ACCESS_TOKEN,this.accessToken||(this.key=process.env.DEEPGRAM_API_KEY)),!this.key&&!this.accessToken)throw new o.DeepgramError("A deepgram API key or access token is required.");e=(0,i.convertLegacyOptions)(e),this.options=(0,i.applyDefaults)(e,s.DEFAULT_OPTIONS)}v(e="v1"){return this.version=e,this}get namespaceOptions(){const e=(0,i.applyDefaults)(this.options[this.namespace],this.options.global);return Object.assign(Object.assign({},e),{key:this.key})}getRequestUrl(e,t={version:this.version},r){t.version=this.version,e=e.replace(/:(\w+)/g,(function(e,r){return t[r]}));const n=new URL(e,this.baseUrl);return r&&(0,i.appendSearchParams)(n.searchParams,r),n}log(e,t,r){this.logger(e,t,r)}}t.AbstractClient=a},5096:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractRestfulClient=t.AbstractRestClient=void 0;const o=r(4306),i=r(6245),a=r(5066),u=r(5793),c=s(r(7314));class l extends a.AbstractClient{constructor(e){if(super(e),(0,u.isBrowser)()&&!this.proxy)throw new o.DeepgramError("Due to CORS we are unable to support REST-based API calls to our API from the browser. Please consider using a proxy: https://dpgr.am/js-proxy for more information.");const{accessToken:t,key:r,fetch:n}=this;this.fetch=(0,i.fetchWithAuth)({accessToken:t,apiKey:r,customFetch:n}),this.proxy?this.baseUrl=this.namespaceOptions.fetch.options.proxy.url:this.baseUrl=this.namespaceOptions.fetch.options.url}_getErrorMessage(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)}_handleError(e,t){return n(this,void 0,void 0,(function*(){const r=yield(0,i.resolveResponse)();e instanceof r?e.json().then((r=>{t(new o.DeepgramApiError(this._getErrorMessage(r),e.status||500))})).catch((e=>{t(new o.DeepgramUnknownError(this._getErrorMessage(e),e))})):t(new o.DeepgramUnknownError(this._getErrorMessage(e),e))}))}_getRequestOptions(e,t,r){let n={method:e};return n="GET"===e||"DELETE"===e?Object.assign(Object.assign({},n),t):Object.assign(Object.assign({duplex:"half",body:t},n),r),(0,c.default)(this.namespaceOptions.fetch.options,n,{clone:!1})}_handleRequest(e,t,r,s){return n(this,void 0,void 0,(function*(){return new Promise(((n,o)=>{(0,this.fetch)(t,this._getRequestOptions(e,r,s)).then((e=>{if(!e.ok)throw e;n(e)})).catch((e=>this._handleError(e,o)))}))}))}get(e,t){return n(this,void 0,void 0,(function*(){return this._handleRequest("GET",e,t)}))}post(e,t,r){return n(this,void 0,void 0,(function*(){return this._handleRequest("POST",e,t,r)}))}put(e,t,r){return n(this,void 0,void 0,(function*(){return this._handleRequest("PUT",e,t,r)}))}patch(e,t,r){return n(this,void 0,void 0,(function*(){return this._handleRequest("PATCH",e,t,r)}))}delete(e,t){return n(this,void 0,void 0,(function*(){return this._handleRequest("DELETE",e,t)}))}get proxy(){var e;return"proxy"===this.key&&!!(null===(e=this.namespaceOptions.fetch.options.proxy)||void 0===e?void 0:e.url)}}t.AbstractRestClient=l,t.AbstractRestfulClient=l},5263:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},5292:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ModelsRestClient=void 0;const s=r(4306),o=r(5096);class i extends o.AbstractRestClient{constructor(){super(...arguments),this.namespace="models"}getAll(e=":version/models",t={}){return n(this,void 0,void 0,(function*(){try{const r=this.getRequestUrl(e,{},t);return{result:yield this.get(r).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getModel(e,t=":version/models/:modelId"){return n(this,void 0,void 0,(function*(){try{const r=this.getRequestUrl(t,{modelId:e});return{result:yield this.get(r).then((e=>e.json())),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ModelsRestClient=i},5357:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveClient=t.ListenLiveClient=void 0;const n=r(740),s=r(6416),o=r(4306);class i extends n.AbstractLiveClient{constructor(e,t={},r=":version/listen"){var n,s;if(super(e),this.namespace="listen",(null===(n=t.keyterm)||void 0===n?void 0:n.length)&&!(null===(s=t.model)||void 0===s?void 0:s.startsWith("nova-3")))throw new o.DeepgramError("Keyterms are only supported with the Nova 3 models.");this.connect(t,r)}setupConnection(){this.setupConnectionEvents({Open:s.LiveTranscriptionEvents.Open,Close:s.LiveTranscriptionEvents.Close,Error:s.LiveTranscriptionEvents.Error}),this.conn&&(this.conn.onmessage=e=>{var t,r,n,o;try{const t=JSON.parse(e.data.toString());t.type===s.LiveTranscriptionEvents.Metadata?this.emit(s.LiveTranscriptionEvents.Metadata,t):t.type===s.LiveTranscriptionEvents.Transcript?this.emit(s.LiveTranscriptionEvents.Transcript,t):t.type===s.LiveTranscriptionEvents.UtteranceEnd?this.emit(s.LiveTranscriptionEvents.UtteranceEnd,t):t.type===s.LiveTranscriptionEvents.SpeechStarted?this.emit(s.LiveTranscriptionEvents.SpeechStarted,t):this.emit(s.LiveTranscriptionEvents.Unhandled,t)}catch(i){this.emit(s.LiveTranscriptionEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:i,url:null===(t=this.conn)||void 0===t?void 0:t.url,readyState:null===(r=this.conn)||void 0===r?void 0:r.readyState,data:(null===(n=e.data)||void 0===n?void 0:n.toString().substring(0,200))+((null===(o=e.data)||void 0===o?void 0:o.toString().length)>200?"...":"")})}})}configure(e){this.send(JSON.stringify({type:"Configure",processors:e}))}keepAlive(){this.send(JSON.stringify({type:"KeepAlive"}))}finalize(){this.send(JSON.stringify({type:"Finalize"}))}finish(){this.requestClose()}requestClose(){this.send(JSON.stringify({type:"CloseStream"}))}}t.ListenLiveClient=i,t.LiveClient=i},5569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},5793:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isBun=t.isNode=t.isBrowser=t.BROWSER_AGENT=t.BUN_VERSION=t.NODE_VERSION=void 0,t.NODE_VERSION="undefined"!=typeof process&&process.versions&&process.versions.node?process.versions.node:"unknown",t.BUN_VERSION="undefined"!=typeof process&&process.versions&&process.versions.bun?process.versions.bun:"unknown",t.BROWSER_AGENT="undefined"!=typeof window&&window.navigator&&window.navigator.userAgent?window.navigator.userAgent:"unknown",t.isBrowser=()=>"unknown"!==t.BROWSER_AGENT,t.isNode=()=>"unknown"!==t.NODE_VERSION,t.isBun=()=>"unknown"!==t.BUN_VERSION},5874:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},6180:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},6245:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return s(t,e),t},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveResponse=t.fetchWithAuth=t.resolveFetch=void 0;const u=r(684),c=a(r(8389));t.resolveFetch=e=>{let t;return t=e||("undefined"==typeof fetch?c.default:fetch),(...e)=>t(...e)},t.fetchWithAuth=({apiKey:e,customFetch:r,accessToken:n})=>{const s=(0,t.resolveFetch)(r),o=(0,u.resolveHeadersConstructor)();return(t,r)=>i(void 0,void 0,void 0,(function*(){const i=new o(null==r?void 0:r.headers);return i.has("Authorization")||i.set("Authorization",n?`Bearer ${n}`:`Token ${e}`),s(t,Object.assign(Object.assign({},r),{headers:i}))}))},t.resolveResponse=()=>i(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>o(r(8389))))).Response:Response}))},6287:function(e){e.exports=function(){"use strict";var e=6e4,t=36e5,r="millisecond",n="second",s="minute",o="hour",i="day",a="week",u="month",c="quarter",l="year",d="date",h="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"}},y=function(e,t,r){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(r)+e},g={s:y,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),n=Math.floor(r/60),s=r%60;return(t<=0?"+":"-")+y(n,2,"0")+":"+y(s,2,"0")},m:function e(t,r){if(t.date()<r.date())return-e(r,t);var n=12*(r.year()-t.year())+(r.month()-t.month()),s=t.clone().add(n,u),o=r-s<0,i=t.clone().add(n+(o?-1:1),u);return+(-(n+(r-s)/(o?s-i:i-s))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:l,w:a,d:i,D:d,h:o,m:s,s:n,ms:r,Q:c}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},m="en",b={};b[m]=v;var _="$isDayjsObject",w=function(e){return e instanceof S||!(!e||!e[_])},O=function e(t,r,n){var s;if(!t)return m;if("string"==typeof t){var o=t.toLowerCase();b[o]&&(s=o),r&&(b[o]=r,s=o);var i=t.split("-");if(!s&&i.length>1)return e(i[0])}else{var a=t.name;b[a]=t,s=a}return!n&&s&&(m=s),s||!n&&m},E=function(e,t){if(w(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new S(r)},j=g;j.l=O,j.i=w,j.w=function(e,t){return E(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var S=function(){function v(e){this.$L=O(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[_]=!0}var y=v.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(j.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(p);if(n){var s=n[2]-1||0,o=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)):new Date(n[1],s,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return j},y.isValid=function(){return!(this.$d.toString()===h)},y.isSame=function(e,t){var r=E(e);return this.startOf(t)<=r&&r<=this.endOf(t)},y.isAfter=function(e,t){return E(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<E(e)},y.$g=function(e,t,r){return j.u(e)?this[t]:this.set(r,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var r=this,c=!!j.u(t)||t,h=j.p(e),p=function(e,t){var n=j.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return c?n:n.endOf(i)},f=function(e,t){return j.w(r.toDate()[e].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},v=this.$W,y=this.$M,g=this.$D,m="set"+(this.$u?"UTC":"");switch(h){case l:return c?p(1,0):p(31,11);case u:return c?p(1,y):p(0,y+1);case a:var b=this.$locale().weekStart||0,_=(v<b?v+7:v)-b;return p(c?g-_:g+(6-_),y);case i:case d:return f(m+"Hours",0);case o:return f(m+"Minutes",1);case s:return f(m+"Seconds",2);case n:return f(m+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var a,c=j.p(e),h="set"+(this.$u?"UTC":""),p=(a={},a[i]=h+"Date",a[d]=h+"Date",a[u]=h+"Month",a[l]=h+"FullYear",a[o]=h+"Hours",a[s]=h+"Minutes",a[n]=h+"Seconds",a[r]=h+"Milliseconds",a)[c],f=c===i?this.$D+(t-this.$W):t;if(c===u||c===l){var v=this.clone().set(d,1);v.$d[p](f),v.init(),this.$d=v.set(d,Math.min(this.$D,v.daysInMonth())).$d}else p&&this.$d[p](f);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[j.p(e)]()},y.add=function(r,c){var d,h=this;r=Number(r);var p=j.p(c),f=function(e){var t=E(h);return j.w(t.date(t.date()+Math.round(e*r)),h)};if(p===u)return this.set(u,this.$M+r);if(p===l)return this.set(l,this.$y+r);if(p===i)return f(1);if(p===a)return f(7);var v=(d={},d[s]=e,d[o]=t,d[n]=1e3,d)[p]||1,y=this.$d.getTime()+r*v;return j.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||h;var n=e||"YYYY-MM-DDTHH:mm:ssZ",s=j.z(this),o=this.$H,i=this.$m,a=this.$M,u=r.weekdays,c=r.months,l=r.meridiem,d=function(e,r,s,o){return e&&(e[r]||e(t,n))||s[r].slice(0,o)},p=function(e){return j.s(o%12||12,e,"0")},v=l||function(e,t,r){var n=e<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(f,(function(e,n){return n||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return j.s(t.$y,4,"0");case"M":return a+1;case"MM":return j.s(a+1,2,"0");case"MMM":return d(r.monthsShort,a,c,3);case"MMMM":return d(c,a);case"D":return t.$D;case"DD":return j.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return d(r.weekdaysMin,t.$W,u,2);case"ddd":return d(r.weekdaysShort,t.$W,u,3);case"dddd":return u[t.$W];case"H":return String(o);case"HH":return j.s(o,2,"0");case"h":return p(1);case"hh":return p(2);case"a":return v(o,i,!0);case"A":return v(o,i,!1);case"m":return String(i);case"mm":return j.s(i,2,"0");case"s":return String(t.$s);case"ss":return j.s(t.$s,2,"0");case"SSS":return j.s(t.$ms,3,"0");case"Z":return s}return null}(e)||s.replace(":","")}))},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(r,d,h){var p,f=this,v=j.p(d),y=E(r),g=(y.utcOffset()-this.utcOffset())*e,m=this-y,b=function(){return j.m(f,y)};switch(v){case l:p=b()/12;break;case u:p=b();break;case c:p=b()/3;break;case a:p=(m-g)/6048e5;break;case i:p=(m-g)/864e5;break;case o:p=m/t;break;case s:p=m/e;break;case n:p=m/1e3;break;default:p=m}return h?p:j.a(p)},y.daysInMonth=function(){return this.endOf(u).$D},y.$locale=function(){return b[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),n=O(e,t,!0);return n&&(r.$L=n),r},y.clone=function(){return j.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},v}(),T=S.prototype;return E.prototype=T,[["$ms",r],["$s",n],["$m",s],["$H",o],["$W",i],["$M",u],["$y",l],["$D",d]].forEach((function(e){T[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),E.extend=function(e,t){return e.$i||(e(t,S,E),e.$i=!0),E},E.locale=O,E.isDayjs=w,E.unix=function(e){return E(1e3*e)},E.en=b[m],E.Ls=b,E.p={},E}()},6302:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},6327:(e,t,r)=>{"use strict";function n(e){return"transcriptionData"in e}r.r(t),r.d(t,{AssemblyAiConverter:()=>h,DeepgramConverter:()=>l,chunkArray:()=>c,isConverter:()=>n,secondsToTimestamp:()=>u,srt:()=>v,webvtt:()=>f});var s=r(6287),o=r.n(s),i=r(4268),a=r.n(i);function u(e,t="HH:mm:ss.SSS"){return o()(1e3*e).utc().format(t)}function c(e,t){const r=[];for(let n=0;n<e.length;n+=t){const s=e.slice(n,n+t);r.push(s)}return r}o().extend(a());class l{constructor(e){this.transcriptionData=e}getLines(e=8){const{results:t}=this.transcriptionData;let r=[];if(t.utterances)t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words,e)):r.push(t.words)}));else{const n=t.channels[0].alternatives[0].words,s="speaker"in n[0];let o=[],i=0;n.forEach((t=>{var n;s&&t.speaker!==i&&(r.push(o),o=[]),o.length===e&&(r.push(o),o=[]),s&&(i=null!==(n=t.speaker)&&void 0!==n?n:0),o.push(t)})),r.push(o)}return r}getHeaders(){var e,t,r,n,s,o,i,a;const u=[];return u.push("NOTE"),u.push("Transcription provided by Deepgram"),(null===(e=this.transcriptionData.metadata)||void 0===e?void 0:e.request_id)&&u.push(`Request Id: ${null===(t=this.transcriptionData.metadata)||void 0===t?void 0:t.request_id}`),(null===(r=this.transcriptionData.metadata)||void 0===r?void 0:r.created)&&u.push(`Created: ${null===(n=this.transcriptionData.metadata)||void 0===n?void 0:n.created}`),(null===(s=this.transcriptionData.metadata)||void 0===s?void 0:s.duration)&&u.push(`Duration: ${null===(o=this.transcriptionData.metadata)||void 0===o?void 0:o.duration}`),(null===(i=this.transcriptionData.metadata)||void 0===i?void 0:i.channels)&&u.push(`Channels: ${null===(a=this.transcriptionData.metadata)||void 0===a?void 0:a.channels}`),u}}const d=e=>({word:e.text,start:e.start,end:e.end,confidence:e.confidence,punctuated_word:e.text,speaker:e.speaker});class h{constructor(e){this.transcriptionData=e}getLines(e=8){const t=this.transcriptionData;let r=[];return t.utterances?t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words.map((e=>d(e))),e)):r.push(t.words.map((e=>d(e))))})):r.push(...c(t.words.map((e=>d(e))),e)),r}getHeaders(){const e=[];return e.push("NOTE"),e.push("Transcription provided by Assembly AI"),this.transcriptionData.id&&e.push(`Id: ${this.transcriptionData.id}`),this.transcriptionData.audio_duration&&e.push(`Duration: ${this.transcriptionData.audio_duration}`),e}}const p=e=>n(e)?e:new l(e),f=(e,t=8)=>{const r=[];let n=p(e);r.push("WEBVTT"),r.push(""),n.getHeaders&&r.push(n.getHeaders().join("\n")),n.getHeaders&&r.push("");const s=n.getLines(t),o="speaker"in s[0][0];return s.forEach((e=>{const t=e[0],n=e[e.length-1];r.push(`${u(t.start)} --\x3e ${u(n.end)}`);const s=e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" "),i=o?`<v Speaker ${t.speaker}>`:"";r.push(`${i}${s}`),r.push("")})),r.join("\n")},v=(e,t=8)=>{const r=[];let n=p(e).getLines(t);const s="speaker"in n[0][0];let o,i=1;return n.forEach((e=>{r.push((i++).toString());const t=e[0],n=e[e.length-1];r.push(`${u(t.start,"HH:mm:ss,SSS")} --\x3e ${u(n.end,"HH:mm:ss,SSS")}`);const a=e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" "),c=s&&o!==t.speaker?`[Speaker ${t.spe