uneeq-js 3.22.2 → 3.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3.index.js +1 -1
- package/dist/3.index.js.map +1 -1
- package/dist/363.index.js +1 -1
- package/dist/363.index.js.map +1 -1
- package/dist/deepgram-flux-stt.d.ts +11 -0
- package/dist/deepgram-stt.d.ts +11 -0
- package/dist/esm/chunks/{chunk-KD2RTEWK.js → chunk-BA5ZOQIF.js} +2 -2
- package/dist/esm/chunks/deepgram-flux-stt-OPYLDHOY.js +27 -0
- package/dist/esm/chunks/deepgram-stt-43IVLFMT.js +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/index.js +1 -1
- package/dist/turn-flush.d.ts +32 -0
- package/dist/turn-flush.spec.d.ts +1 -0
- package/package.json +1 -1
- package/dist/esm/chunks/deepgram-flux-stt-UEOBOLSX.js +0 -27
- package/dist/esm/chunks/deepgram-stt-MB7254SA.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Ft,b as Nt,c as st,d as gr}from"./chunk-HXVOCQLA.js";var wt=Nt((Vi,ar)=>{"use strict";ar.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var pr=Nt(()=>{});var We=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var yr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Oe={get:(s,e)=>yr(void 0,void 0,void 0,function*(){return typeof s=="function"?s(e):s})};var A=(s,e,o)=>JSON.stringify(s,e,o);function V(s,e){return JSON.parse(s,e)}var oe={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},zt={[oe.Debug]:1,[oe.Info]:2,[oe.Warn]:3,[oe.Error]:4},$e=class{debug(e,...o){console.debug(e,...o)}info(e,...o){console.info(e,...o)}warn(e,...o){console.warn(e,...o)}error(e,...o){console.error(e,...o)}},ye=class{constructor(e){this.level=zt[e.level],this.logger=e.logger,this.silent=e.silent}shouldLog(e){return!this.silent&&this.level<=zt[e]}isDebug(){return this.shouldLog(oe.Debug)}debug(e,...o){this.isDebug()&&this.logger.debug(e,...o)}isInfo(){return this.shouldLog(oe.Info)}info(e,...o){this.isInfo()&&this.logger.info(e,...o)}isWarn(){return this.shouldLog(oe.Warn)}warn(e,...o){this.isWarn()&&this.logger.warn(e,...o)}isError(){return this.shouldLog(oe.Error)}error(e,...o){this.isError()&&this.logger.error(e,...o)}};function Ge(s){var e,o,t;return s==null?wr:s instanceof ye?s:(s=s??{},(e=s.level)!==null&&e!==void 0||(s.level=oe.Info),(o=s.logger)!==null&&o!==void 0||(s.logger=new $e),(t=s.silent)!==null&&t!==void 0||(s.silent=!0),new ye(s))}var wr=new ye({level:oe.Info,logger:new $e,silent:!0});var br={arrayFormat:"indices",encode:!0};function at(s,e){if(s===void 0||s===null)return"";let o=String(s);return e?encodeURIComponent(o):o}function dt(s,e="",o){let t=[];for(let[r,i]of Object.entries(s)){let a=e?`${e}[${r}]`:r;if(i!==void 0)if(Array.isArray(i)){if(i.length===0)continue;let c=o.arrayFormat;if(c==="comma"){let u=o.encode?encodeURIComponent(a):a,d=i.filter(n=>n!=null).map(n=>at(n,o.encode));d.length>0&&t.push(`${u}=${d.join(",")}`)}else for(let u=0;u<i.length;u++){let d=i[u];if(d!==void 0)if(typeof d=="object"&&!Array.isArray(d)&&d!==null){let n=c==="indices"?`${a}[${u}]`:a;t.push(...dt(d,n,o))}else{let n=c==="indices"?`${a}[${u}]`:a,l=o.encode?encodeURIComponent(n):n;t.push(`${l}=${at(d,o.encode)}`)}}}else if(typeof i=="object"&&i!==null){if(Object.keys(i).length===0)continue;t.push(...dt(i,a,o))}else{let c=o.encode?encodeURIComponent(a):a;t.push(`${c}=${at(i,o.encode)}`)}}return t}function te(s,e){return s==null||typeof s!="object"?"":dt(s,"",Object.assign(Object.assign({},br),e)).join("&")}function Wt(s,e){let o=te(e,{arrayFormat:"repeat"});return o?`${s}?${o}`:s}function $t(s){let e={get bodyUsed(){return s.bodyUsed},stream:()=>s.body,arrayBuffer:s.arrayBuffer.bind(s),blob:s.blob.bind(s)};return"bytes"in s&&typeof s.bytes=="function"&&(e.bytes=s.bytes.bind(s)),e}var Rr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function eo(s,e){return Rr(this,void 0,void 0,function*(){switch(e){case"binary-response":return $t(s);case"blob":return yield s.blob();case"arrayBuffer":return yield s.arrayBuffer();case"sse":return s.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:s.status}}:s.body;case"streaming":return s.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:s.status}}:s.body;case"text":return yield s.text()}let o=yield s.text();if(o.length>0)try{return V(o)}catch{return{ok:!1,error:{reason:"non-json",statusCode:s.status,rawBody:o}}}})}var Sr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Gt(s){return Sr(this,void 0,void 0,function*(){var e,o,t;let r=(e=s.headers.get("Content-Type"))===null||e===void 0?void 0:e.toLowerCase();if(r==null||r.length===0)return eo(s);switch(r.indexOf(";")!==-1&&(r=(t=(o=r.split(";")[0])===null||o===void 0?void 0:o.trim())!==null&&t!==void 0?t:""),r){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=yield s.text();return i.length>0?V(i):void 0}default:if(r.startsWith("application/vnd.")&&r.endsWith("+json")){let i=yield s.text();return i.length>0?V(i):void 0}return yield s.text()}})}var Er=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function oo(){return Er(this,void 0,void 0,function*(){return fetch})}var xr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Jt(s){return xr(this,arguments,void 0,function*({body:e,type:o}){return o==="form"?te(e,{arrayFormat:"repeat",encode:!0}):o.includes("json")?A(e):e})}var ce;typeof globalThis.Headers<"u"?ce=globalThis.Headers:ce=class Kt{constructor(e){if(this.headers=new Map,e)if(e instanceof Kt)e.forEach((o,t)=>this.append(t,o));else if(Array.isArray(e))for(let[o,t]of e)if(typeof o=="string"&&typeof t=="string")this.append(o,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[o,t]of Object.entries(e))if(typeof t=="string")this.append(o,t);else throw new TypeError("Header values must be strings")}append(e,o){let t=e.toLowerCase(),r=this.headers.get(t)||[];this.headers.set(t,[...r,o])}delete(e){let o=e.toLowerCase();this.headers.delete(o)}get(e){let o=e.toLowerCase(),t=this.headers.get(o);return t?t.join(", "):null}has(e){let o=e.toLowerCase();return this.headers.has(o)}set(e,o){let t=e.toLowerCase();this.headers.set(t,[o])}forEach(e,o){let t=o?e.bind(o):e;this.headers.forEach((r,i)=>t(r.join(", "),i,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[e,o]of this.headers.entries())yield[e,o.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let e of this.headers.values())yield e.join(", ")}[Symbol.iterator](){return this.entries()}};var kr="timeout";function Vt(s){let e=new AbortController,o=setTimeout(()=>e.abort(kr),s);return{signal:e.signal,abortId:o}}function Yt(...s){let e=s.length===1&&Array.isArray(s[0])?s[0]:s,o=new AbortController;for(let t of e){if(t.aborted){o.abort(t?.reason);break}t.addEventListener("abort",()=>o.abort(t?.reason),{signal:o.signal})}return o.signal}var Pr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Je;function Cr(){if(Je!=null)return Je;try{new Request("http://localhost",{cache:"no-store"}),Je=!0}catch{Je=!1}return Je}var to=(s,e,o,t,r,i,a,c,u,d)=>Pr(void 0,void 0,void 0,function*(){let n=[],l;if(i!=null){let{signal:f,abortId:m}=Vt(i);l=m,n.push(f)}a!=null&&n.push(a);let v=Yt(n),_=yield s(e,Object.assign({method:o,headers:t,body:r,signal:v,credentials:c?"include":void 0,duplex:u},d&&Cr()?{cache:"no-store"}:{}));return l!=null&&clearTimeout(l),_});var lt={headers:new ce,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},ct={headers:new ce,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function ut(s){return{headers:s.headers,redirected:s.redirected,status:s.status,statusText:s.statusText,type:s.type,url:s.url}}var jr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Tr(s){let e=1+Math.random()*.2;return s*e}function Dr(s){let e=1+(Math.random()-.5)*.2;return s*e}function Ar(s,e){let o=s.headers.get("Retry-After");if(o){let r=parseInt(o,10);if(!Number.isNaN(r)&&r>0)return Math.min(r*1e3,6e4);let i=new Date(o);if(!Number.isNaN(i.getTime())){let a=i.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=s.headers.get("X-RateLimit-Reset");if(t){let r=parseInt(t,10);if(!Number.isNaN(r)){let i=r*1e3-Date.now();if(i>0)return Tr(Math.min(i,6e4))}}return Dr(Math.min(1e3*Math.pow(2,e),6e4))}function ro(s){return jr(this,arguments,void 0,function*(e,o=2){let t=yield e();for(let r=0;r<o&&([408,429].includes(t.status)||t.status>=500);++r){let i=Ar(t,r);yield new Promise(a=>setTimeout(a,i)),t=yield e()}return t})}var mt=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Ir=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function ht(s){let e={};for(let[o,t]of s instanceof ce?s.entries():Object.entries(s))Ir.has(o.toLowerCase())?e[o]="[REDACTED]":e[o]=t;return e}var vt=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function Lr(s){if(s==null)return;let e={};for(let[o,t]of Object.entries(s))e[o]=vt.has(o.toLowerCase())?"[REDACTED]":t;return e}function fe(s){let e=s.indexOf("://");if(e===-1)return s;let o=e+3,t=s.indexOf("/",o),r=s.indexOf("?",o),i=s.indexOf("#",o),a=Math.min(t===-1?s.length:t,r===-1?s.length:r,i===-1?s.length:i),c=-1;for(let f=o;f<a;f++)s[f]==="@"&&(c=f);if(c!==-1&&(s=`${s.slice(0,o)}[REDACTED]@${s.slice(c+1)}`),r=s.indexOf("?"),r===-1)return s;i=s.indexOf("#",r);let u=i!==-1?i:s.length,d=s.slice(r+1,u);if(d.length===0)return s;let n=d.toLowerCase();if(!(n.includes("token")||n.includes("key")||n.includes("password")||n.includes("passwd")||n.includes("secret")||n.includes("session")||n.includes("auth")))return s;let v=[],_=d.split("&");for(let f of _){let m=f.indexOf("=");if(m===-1){v.push(f);continue}let h=f.slice(0,m),y=vt.has(h.toLowerCase());if(!y&&h.includes("%"))try{let T=decodeURIComponent(h);y=vt.has(T.toLowerCase())}catch{}v.push(y?`${h}=[REDACTED]`:f)}return s.slice(0,r+1)+v.join("&")+s.slice(u)}function Mr(s){return mt(this,void 0,void 0,function*(){var e;let o=new ce;if(o.set("Accept",s.responseType==="json"?"application/json":s.responseType==="text"?"text/plain":s.responseType==="sse"?"text/event-stream":"*/*"),s.body!==void 0&&s.contentType!=null&&o.set("Content-Type",s.contentType),s.headers==null)return o;for(let[t,r]of Object.entries(s.headers)){let i=yield Oe.get(r,{endpointMetadata:(e=s.endpointMetadata)!==null&&e!==void 0?e:{}});if(typeof i=="string"){o.set(t,i);continue}i!=null&&o.set(t,`${i}`)}return o})}function Br(s){return mt(this,void 0,void 0,function*(){var e,o,t;let r=s.url;s.queryString!=null&&s.queryString.length>0?r=`${r}?${s.queryString}`:r=Wt(s.url,s.queryParameters);let i=yield Jt({body:s.body,type:(e=s.requestType)!==null&&e!==void 0?e:"other"}),a=(o=s.fetchFn)!==null&&o!==void 0?o:yield oo(),c=yield Mr(s),u=Ge(s.logging);if(u.isDebug()){let d={method:s.method,url:fe(r),headers:ht(c),queryParameters:Lr(s.queryParameters),hasBody:i!=null};u.debug("Making HTTP request",d)}try{let d=yield ro(()=>mt(this,void 0,void 0,function*(){return to(a,r,s.method,c,i,s.timeoutMs,s.abortSignal,s.withCredentials,s.duplex,s.responseType==="streaming"||s.responseType==="sse")}),s.maxRetries);if(d.status>=200&&d.status<400){if(u.isDebug()){let l={method:s.method,url:fe(r),statusCode:d.status,responseHeaders:ht(d.headers)};u.debug("HTTP request succeeded",l)}return{ok:!0,body:yield eo(d,s.responseType),headers:d.headers,rawResponse:ut(d)}}else{if(u.isError()){let n={method:s.method,url:fe(r),statusCode:d.status,responseHeaders:ht(Object.fromEntries(d.headers.entries()))};u.error("HTTP request failed with error status",n)}return{ok:!1,error:{reason:"status-code",statusCode:d.status,body:yield Gt(d)},rawResponse:ut(d)}}}catch(d){if(!((t=s.abortSignal)===null||t===void 0)&&t.aborted){if(u.isError()){let n={method:s.method,url:fe(r)};u.error("HTTP request was aborted",n)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:d},rawResponse:lt}}else if(d instanceof Error&&d.name==="AbortError"){if(u.isError()){let n={method:s.method,url:fe(r),timeoutMs:s.timeoutMs};u.error("HTTP request timed out",n)}return{ok:!1,error:{reason:"timeout",cause:d},rawResponse:lt}}else if(d instanceof Error){if(u.isError()){let n={method:s.method,url:fe(r),errorMessage:d.message};u.error("HTTP request failed with error",n)}return{ok:!1,error:{reason:"unknown",errorMessage:d.message,cause:d},rawResponse:ct}}if(u.isError()){let n={method:s.method,url:fe(r),error:A(d)};u.error("HTTP request failed with unknown error",n)}return{ok:!1,error:{reason:"unknown",errorMessage:A(d),cause:d},rawResponse:ct}}})}var k=Br;var Hr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},E=class s extends Promise{constructor(e){super(o=>{o(void 0)}),this.innerPromise=e}static fromFunction(e,...o){return new s(e(...o))}static interceptFunction(e){return(...o)=>s.fromPromise(e(...o))}static fromPromise(e){return new s(e)}static fromExecutor(e){let o=new Promise(e);return new s(o)}static fromResult(e){let o=Promise.resolve(e);return new s(o)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:e})=>e)),this.unwrappedPromise}then(e,o){return this.unwrap().then(e,o)}catch(e){return this.unwrap().catch(e)}finally(e){return this.unwrap().finally(e)}withRawResponse(){return Hr(this,void 0,void 0,function*(){return yield this.innerPromise})}};function no(s,...e){if(!s)return"";if(e.length===0)return s;if(s.includes("://")){let o;try{o=new URL(s)}catch{return Qt(s,...e)}let t=e[e.length-1],r=t?.endsWith("/");for(let i of e){let a=Zt(i);a&&(o.pathname=Xt(o.pathname,a))}return r&&!o.pathname.endsWith("/")&&(o.pathname+="/"),o.toString()}return Qt(s,...e)}function Qt(s,...e){if(e.length===0)return s;let o=s,t=e[e.length-1],r=t?.endsWith("/");for(let i of e){let a=Zt(i);a&&(o=Xt(o,a))}return r&&!o.endsWith("/")&&(o+="/"),o}function Xt(s,e){return s.endsWith("/")?s+e:`${s}/${e}`}function Zt(s){if(!s)return s;let e=0,o=s.length;return s.startsWith("/")&&(e=1),s.endsWith("/")&&(o=s.length-1),e===0&&o===s.length?s:s.slice(e,o)}var Ur=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},g={get:s=>Ur(void 0,void 0,void 0,function*(){return typeof s=="function"?s():s})};var qt=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function _t(s,e,o,t){return qt(this,void 0,void 0,function*(){var r,i,a,c,u,d,n;let l=Ge(o.logging),v,_=e;s instanceof Request?(v=s.url,e==null&&(_={method:s.method,headers:Object.fromEntries(s.headers.entries()),body:s.body,signal:s.signal,credentials:s.credentials,cache:s.cache,redirect:s.redirect,referrer:s.referrer,integrity:s.integrity,mode:s.mode})):v=s instanceof URL?s.toString():s;let f=(r=o.baseUrl!=null?yield g.get(o.baseUrl):void 0)!==null&&r!==void 0?r:o.environment!=null?yield g.get(o.environment):void 0,m;v.startsWith("http://")||v.startsWith("https://")?m=v:f!=null?m=no(f,v):m=v;let h={};if(o.headers!=null)for(let[D,U]of Object.entries(o.headers)){let L=yield Oe.get(U,{endpointMetadata:{}});L!=null&&(h[D.toLowerCase()]=`${L}`)}if(o.getAuthHeaders!=null){let D=yield o.getAuthHeaders();for(let[U,L]of Object.entries(D))h[U.toLowerCase()]=L}if(_?.headers!=null){let D=_.headers instanceof Headers?Object.fromEntries(_.headers.entries()):Array.isArray(_.headers)?Object.fromEntries(_.headers):_.headers;for(let[U,L]of Object.entries(D))L!=null&&(h[U.toLowerCase()]=L)}if(t?.headers!=null)for(let[D,U]of Object.entries(t.headers))h[D.toLowerCase()]=U;let y=(i=_?.method)!==null&&i!==void 0?i:"GET",T=_?.body,S=(a=t?.timeoutInSeconds)!==null&&a!==void 0?a:o.timeoutInSeconds,j=S!=null?S*1e3:void 0,I=(c=t?.maxRetries)!==null&&c!==void 0?c:o.maxRetries,z=(d=(u=t?.abortSignal)!==null&&u!==void 0?u:_?.signal)!==null&&d!==void 0?d:void 0,J=(n=o.fetch)!==null&&n!==void 0?n:yield oo();l.isDebug()&&l.debug("Making passthrough HTTP request",{method:y,url:m,hasBody:T!=null});let W=yield ro(()=>qt(this,void 0,void 0,function*(){return to(J,m,y,h,T??void 0,j,z,_?.credentials==="include",void 0,!1)}),I);return l.isDebug()&&l.debug("Passthrough HTTP request completed",{method:y,url:m,statusCode:W.status}),W})}var io={};st(io,{toBinaryUploadRequest:()=>Fr,toMultipartDataPart:()=>Nr});var Ke=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Fr(s){return Ke(this,void 0,void 0,function*(){let{data:e,filename:o,contentLength:t,contentType:r}=yield pt(s),i={body:e,headers:{}};return o&&(i.headers["Content-Disposition"]=`attachment; filename="${o}"`),r&&(i.headers["Content-Type"]=r),t!=null&&(i.headers["Content-Length"]=t.toString()),i})}function Nr(s){return Ke(this,void 0,void 0,function*(){let{data:e,filename:o,contentType:t}=yield pt(s,{noSniffFileSize:!0});return{data:e,filename:o,contentType:t}})}function pt(s){return Ke(this,arguments,void 0,function*(e,{noSniffFileSize:o}={}){var t,r,i,a,c;if(zr(e))return pt({data:e},{noSniffFileSize:o});if("path"in e){let u=yield import("./fs-TPREOTZZ.js");if(!u?.createReadStream)throw new Error("File path uploads are not supported in this environment.");let d=u.createReadStream(e.path),n=(t=e.contentLength)!==null&&t!==void 0?t:o===!0?void 0:yield Ot(e.path),l=(r=e.filename)!==null&&r!==void 0?r:er(e.path);return{data:d,filename:l,contentType:e.contentType,contentLength:n}}if("data"in e){let u=e.data,d=(i=e.contentLength)!==null&&i!==void 0?i:yield $r(u,{noSniffFileSize:o}),n=(a=e.filename)!==null&&a!==void 0?a:Wr(u);return{data:u,filename:n,contentType:(c=e.contentType)!==null&&c!==void 0?c:Gr(u),contentLength:d}}throw new Error(`Invalid FileUpload of type ${typeof e}: ${JSON.stringify(e)}`)})}function zr(s){return tr(s)||rr(s)||nr(s)||Yr(s)||ft(s)||gt(s)||Kr(s)||Vr(s)}function Ot(s){return Ke(this,void 0,void 0,function*(){var e;try{let o=yield import("./fs-TPREOTZZ.js");return!((e=o?.promises)===null||e===void 0)&&e.stat?(yield o.promises.stat(s)).size:void 0}catch{return}})}function Wr(s){if(Jr(s))return s.name;if(or(s))return er(s.path.toString())}function $r(s){return Ke(this,arguments,void 0,function*(e,{noSniffFileSize:o}={}){if(tr(e))return e.length;if(rr(e)||nr(e))return e.byteLength;if(ft(e)||gt(e))return e.size;if(o!==!0&&or(e))return yield Ot(e.path.toString())})}function Gr(s){if(ft(s)||gt(s))return s.type}function er(s){let e=s.lastIndexOf("/"),o=s.lastIndexOf("\\"),t=Math.max(e,o);return t>=0?s.substring(t+1):s}function Jr(s){return typeof s=="object"&&s!=null&&"name"in s}function or(s){return typeof s=="object"&&s!=null&&"path"in s}function Kr(s){return typeof s=="object"&&s!=null&&("read"in s||"pipe"in s)}function Vr(s){return typeof s=="object"&&s!=null&&"getReader"in s}function tr(s){return typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(s)}function rr(s){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(s)}function nr(s){return typeof ArrayBuffer<"u"&&s instanceof ArrayBuffer}function Yr(s){return typeof Uint8Array<"u"&&s instanceof Uint8Array}function ft(s){return typeof Blob<"u"&&s instanceof Blob}function gt(s){return typeof File<"u"&&s instanceof File}var so={};st(so,{ConsoleLogger:()=>$e,LogLevel:()=>oe,Logger:()=>ye,createLogger:()=>Ge});var Q=Qr();function Qr(){var s,e,o,t,r;if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&((s=globalThis?.navigator)===null||s===void 0?void 0:s.userAgent)==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(((e=self.constructor)===null||e===void 0?void 0:e.name)==="DedicatedWorkerGlobalScope"||((o=self.constructor)===null||o===void 0?void 0:o.name)==="ServiceWorkerGlobalScope"||((t=self.constructor)===null||t===void 0?void 0:t.name)==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let v=typeof process<"u"?process:void 0;return typeof v<"u"&&typeof((r=v.versions)===null||r===void 0?void 0:r.node)=="string"?{type:"node",version:v.versions.node,parsedVersion:Number(v.versions.node.split(".")[0])}:{type:"unknown"}}var p={};st(p,{encodePathParam:()=>ir,join:()=>no,queryBuilder:()=>sr,toQueryString:()=>te});function ir(s){if(s===null)return"null";switch(typeof s){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:s=String(s);break}return encodeURIComponent(s)}function sr(){return new yt}var yt=class{constructor(){this.parts=new Map}add(e,o,t){if(o==null)return this;let r=te({[e]:o},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return r.length>0&&this.parts.set(e,r),this}addMany(e){if(e!=null)for(let[o,t]of Object.entries(e))this.add(o,t);return this}mergeAdditional(e){if(e!=null)for(let[o,t]of Object.entries(e)){if(t==null)continue;let r=te({[o]:t},{arrayFormat:"repeat"});r.length>0&&this.parts.set(o,r)}return this}build(){return[...this.parts.values()].join("&")}};var dr=gr(wt(),1);var ao=class{constructor(e,o){this.target=o,this.type=e}},lo=class extends ao{constructor(e,o){super("error",o),this.message=e.message,this.error=e}},Ve=class extends ao{constructor(e=1e3,o="",t){super("close",t),this.wasClean=!0,this.code=e,this.reason=o}};var Zr=()=>{if(Q.type==="node"||Q.type==="bun"||Q.type==="deno")return dr.WebSocket;if(typeof WebSocket<"u")return WebSocket},qr=s=>typeof s<"u"&&!!s&&s.CLOSING===2,ue={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},B=class s{constructor({url:e,protocols:o,options:t,headers:r,queryParameters:i,abortSignal:a}){this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.CONNECTING=s.CONNECTING,this.OPEN=s.OPEN,this.CLOSING=s.CLOSING,this.CLOSED=s.CLOSED,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleAbort=()=>{if(!this._closeCalled&&(this._debug("abort signal fired"),this._shouldReconnect=!1,this._closeCalled=!0,this._clearTimeouts(),this._ws)){this._removeListeners(),this._ws.addEventListener("error",()=>{});try{this._ws.close(1e3,"aborted"),this._handleClose(new Ve(1e3,"aborted",this))}catch{}}},this._handleOpen=c=>{this._debug("open event");let{minUptime:u=ue.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),u),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(d=>{var n;return(n=this._ws)===null||n===void 0?void 0:n.send(d)}),this._messageQueue=[],this.onopen&&this.onopen(c),this._listeners.open.forEach(d=>this._callEventListener(c,d))},this._handleMessage=c=>{this._debug("message event"),this.onmessage&&this.onmessage(c),this._listeners.message.forEach(u=>this._callEventListener(c,u))},this._handleError=c=>{this._debug("error event",c.message),this._disconnect(void 0,c.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(c),this._debug("exec error listeners"),this._listeners.error.forEach(u=>this._callEventListener(c,u)),this._connect()},this._handleClose=c=>{this._debug("close event"),this._clearTimeouts(),c.code===1e3&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(c),this._listeners.close.forEach(u=>this._callEventListener(c,u))},this._url=e,this._protocols=o,this._options=t??ue,this._headers=r,this._queryParameters=i,this._abortSignal=a,this._abortSignal&&this._abortSignal.addEventListener("abort",this._handleAbort,{once:!0}),this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((o,t)=>(typeof t=="string"?o+=t.length:t instanceof Blob?o+=t.size:o+=t.byteLength,o),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?s.ReadyState.CLOSED:s.ReadyState.CONNECTING}get url(){return this._ws?this._ws.url:""}close(e=1e3,o){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(e,o)}reconnect(e,o){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(e,o),this._connect())}send(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{let{maxEnqueuedMessages:o=ue.maxEnqueuedMessages}=this._options;this._messageQueue.length<o&&(this._debug("enqueue",e),this._messageQueue.push(e))}}addEventListener(e,o){this._listeners[e]&&this._listeners[e].push(o)}dispatchEvent(e){let o=this._listeners[e.type];if(o)for(let t of o)this._callEventListener(e,t);return!0}removeEventListener(e,o){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter(t=>t!==o))}_debug(...e){this._options.debug&&console.log.apply(console,["RWS>",...e])}_getNextDelay(){let{reconnectionDelayGrowFactor:e=ue.reconnectionDelayGrowFactor,minReconnectionDelay:o=ue.minReconnectionDelay,maxReconnectionDelay:t=ue.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=o*Math.pow(e,this._retryCount-1),r>t&&(r=t)),this._debug("next delay",r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextUrl(e){if(typeof e=="string")return Promise.resolve(e);if(typeof e=="function"){let o=e();if(typeof o=="string")return Promise.resolve(o);if(o.then)return o}throw Error("Invalid URL")}_connect(){var e;if(this._connectLock||!this._shouldReconnect)return;if(!((e=this._abortSignal)===null||e===void 0)&&e.aborted){this._debug("connect aborted");return}this._connectLock=!0;let{maxRetries:o=ue.maxRetries,connectionTimeout:t=ue.connectionTimeout,WebSocket:r=Zr()}=this._options;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!qr(r))throw Error("No valid WebSocket class provided");this._wait().then(()=>this._getNextUrl(this._url)).then(i=>{var a;if(this._closeCalled||!((a=this._abortSignal)===null||a===void 0)&&a.aborted){this._connectLock=!1;return}let c={};if(this._headers&&(c.headers=this._headers),this._queryParameters&&Object.keys(this._queryParameters).length>0){let u=te(this._queryParameters,{arrayFormat:"repeat"});u&&(i=`${i}?${u}`)}this._ws=new r(i,this._protocols,c),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)})}_handleTimeout(){this._debug("timeout event"),this._handleError(new lo(Error("TIMEOUT"),this))}_disconnect(e=1e3,o){if(this._clearTimeouts(),!!this._ws){this._removeListeners(),this._ws.addEventListener("error",()=>{});try{this._ws.close(e,o),this._handleClose(new Ve(e,o,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_callEventListener(e,o){"handleEvent"in o?o.handleEvent(e):o(e)}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};B.CONNECTING=0;B.OPEN=1;B.CLOSING=2;B.CLOSED=3;(function(s){s.ReadyState={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}})(B||(B={}));var w=class extends Error{constructor({message:e,statusCode:o,body:t,rawResponse:r,cause:i}){super(Or({message:e,statusCode:o,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=o,this.body=t,this.rawResponse=r,i!=null&&(this.cause=i)}};function Or({message:s,statusCode:e,body:o}){let t=[];return s!=null&&t.push(s),e!=null&&t.push(`Status code: ${e.toString()}`),o!=null&&t.push(`Body: ${A(o,void 0,2)}`),t.join(`
|
|
2
|
-
`)}var Ye=class extends Error{constructor(e,o){super(e),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,o?.cause!=null&&(this.cause=o.cause)}};var en=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},bt="apiKey",Rt="DEEPGRAM_API_KEY",on="Authorization",we=class s{constructor(e){this.options=e}static canCreate(e){var o;return e?.[bt]!=null||((o=process.env)===null||o===void 0?void 0:o[Rt])!=null}getAuthRequest(){return en(this,arguments,void 0,function*({endpointMetadata:e}={}){var o,t;let r=(o=yield g.get(this.options[bt]))!==null&&o!==void 0?o:(t=process.env)===null||t===void 0?void 0:t[Rt];if(r==null)throw new w({message:s.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[on]:r}}})}};(function(s){s.AUTH_SCHEME="ApiKeyAuth",s.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${bt}' when initializing the client, or set the '${Rt}' environment variable`;function e(o){return new s(o)}s.createInstance=e})(we||(we={}));function b(...s){let e={};for(let[o,t]of s.filter(r=>r!=null).flatMap(r=>Object.entries(r))){let r=o.toLowerCase();t!=null?e[r]=t:r in e&&delete e[r]}return e}function he(...s){let e={};for(let[o,t]of s.filter(r=>r!=null).flatMap(r=>Object.entries(r))){let r=o.toLowerCase();t!=null&&(e[r]=t)}return e}function X(s){let e=b({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@deepgram/sdk","X-Fern-SDK-Version":"5.2.1","User-Agent":"@deepgram/sdk/5.2.1","X-Fern-Runtime":Q.type,"X-Fern-Runtime-Version":Q.version},s?.headers);return Object.assign(Object.assign({},s),{logging:so.createLogger(s?.logging),headers:e})}function P(s){var e;let o=X(s),t=tn(o);return(e=o.authProvider)!==null&&e!==void 0||(o.authProvider=new we(t)),o}function tn(s){return Object.assign(Object.assign({},s),{authProvider:new We})}var R={Production:{base:"https://api.deepgram.com",production:"wss://api.deepgram.com",agent:"wss://agent.deepgram.com",agentRest:"https://agent.deepgram.com"}};function C(s,e,o,t){switch(s.reason){case"non-json":throw new w({statusCode:s.statusCode,body:s.rawBody,rawResponse:e});case"body-is-null":throw new w({statusCode:s.statusCode,rawResponse:e});case"timeout":throw new Ye(`Timeout exceeded when calling ${o} ${t}.`,{cause:s.cause});case"unknown":throw new w({message:s.errorMessage,rawResponse:e,cause:s.cause});default:throw new w({message:"Unknown error",rawResponse:e})}}var x=class extends w{constructor(e,o){super({message:"BadRequestError",statusCode:400,body:e,rawResponse:o}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var rn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},co=class{constructor(e={}){this._options=X(e)}list(e){return E.fromPromise(this.__list(e))}__list(e){return rn(this,void 0,void 0,function*(){var o,t,r,i,a,c,u,d,n,l;let v=b((o=this._options)===null||o===void 0?void 0:o.headers,e?.headers),_=yield((t=this._options.fetcher)!==null&&t!==void 0?t:k)({url:p.join((r=yield g.get(this._options.baseUrl))!==null&&r!==void 0?r:((i=yield g.get(this._options.environment))!==null&&i!==void 0?i:R.Production).agentRest,"v1/agent/settings/think/models"),method:"GET",headers:v,queryString:p.queryBuilder().mergeAdditional(e?.queryParams).build(),timeoutMs:((u=(a=e?.timeoutInSeconds)!==null&&a!==void 0?a:(c=this._options)===null||c===void 0?void 0:c.timeoutInSeconds)!==null&&u!==void 0?u:60)*1e3,maxRetries:(d=e?.maxRetries)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.maxRetries,abortSignal:e?.abortSignal,fetchFn:(l=this._options)===null||l===void 0?void 0:l.fetch,logging:this._options.logging});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")throw _.error.statusCode===400?new x(_.error.body,_.rawResponse):new w({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse});return C(_.error,_.rawResponse,"GET","/v1/agent/settings/think/models")})}};var uo=class{constructor(e={}){this._options=X(e)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new co(this._options)}};var ho=class{constructor(e={}){this._options=X(e)}get think(){var e;return(e=this._think)!==null&&e!==void 0?e:this._think=new uo(this._options)}};var nn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},be=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendSettings(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdateSpeak(e){this.assertSocketIsOpen(),this.sendJson(e)}sendInjectUserMessage(e){this.assertSocketIsOpen(),this.sendJson(e)}sendInjectAgentMessage(e){this.assertSocketIsOpen(),this.sendJson(e)}sendFunctionCallResponse(e){this.assertSocketIsOpen(),this.sendJson(e)}sendKeepAlive(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdatePrompt(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdateThink(e){this.assertSocketIsOpen(),this.sendJson(e)}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return nn(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var sn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Re=class{constructor(e={}){this._options=X(e)}get settings(){var e;return(e=this._settings)!==null&&e!==void 0?e:this._settings=new ho(this._options)}connect(e){return sn(this,void 0,void 0,function*(){var o,t,r;let{protocols:i,queryParams:a,headers:c,debug:u,reconnectAttempts:d,connectionTimeoutInSeconds:n,abortSignal:l}=e,v=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),c),_=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).agent,"/v1/agent/converse"),protocols:i??[],queryParameters:a??{},headers:v,options:{debug:u??!1,maxRetries:d??30,connectionTimeout:n!=null?n*1e3:void 0},abortSignal:l});return new be({socket:_})})}};var Se=class{constructor(e={}){this._options=X(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Re(this._options)}};var an=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},mo=class{constructor(e={}){this._options=P(e)}grant(e={},o){return E.fromPromise(this.__grant(e,o))}__grant(){return an(this,arguments,void 0,function*(e={},o){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/auth/grant"),method:"POST",headers:f,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:e,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"POST","/v1/auth/grant")})}};var vo=class{constructor(e={}){this._options=P(e)}get tokens(){var e;return(e=this._tokens)!==null&&e!==void 0?e:this._tokens=new mo(this._options)}};var _o=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new vo(this._options)}};var lr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},dn=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},po=class{constructor(e={}){this._options=P(e)}transcribeUrl(e,o){return E.fromPromise(this.__transcribeUrl(e,o))}__transcribeUrl(e,o){return lr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,extra:m,sentiment:h,summarize:y,tag:T,topics:S,custom_topic:j,custom_topic_mode:I,intents:z,custom_intent:J,custom_intent_mode:W,detect_entities:D,detect_language:U,diarize:L,diarize_model:N,dictation:$,encoding:O,filler_words:se,keyterm:ee,keywords:re,language:me,measurements:ve,model:ne,multichannel:ie,numerals:ae,paragraphs:_e,profanity_filter:de,punctuate:le,redact:pe,replace:Ae,search:Ie,smart_format:Le,utterances:Me,utt_split:Be,version:ge,mip_opt_out:He}=e,Ue=dn(e,["callback","callback_method","extra","sentiment","summarize","tag","topics","custom_topic","custom_topic_mode","intents","custom_intent","custom_intent_mode","detect_entities","detect_language","diarize","diarize_model","dictation","encoding","filler_words","keyterm","keywords","language","measurements","model","multichannel","numerals","paragraphs","profanity_filter","punctuate","redact","replace","search","smart_format","utterances","utt_split","version","mip_opt_out"]),Fe={callback:_,callback_method:f??void 0,extra:m,sentiment:h,summarize:y??void 0,tag:T,topics:S,custom_topic:j,custom_topic_mode:I??void 0,intents:z,custom_intent:J,custom_intent_mode:W??void 0,detect_entities:D,detect_language:U,diarize:L,diarize_model:N??void 0,dictation:$,encoding:O??void 0,filler_words:se,keyterm:ee,keywords:re,language:me,measurements:ve,model:ne??void 0,multichannel:ie,numerals:ae,paragraphs:_e,profanity_filter:de,punctuate:le,redact:pe,replace:Ae,search:Ie,smart_format:Le,utterances:Me,utt_split:Be,version:ge??void 0,mip_opt_out:He},Ne=yield this._options.authProvider.getAuthRequest(),ze=b(Ne.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),K=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/listen"),method:"POST",headers:ze,contentType:"application/json",queryString:p.queryBuilder().addMany(Fe).mergeAdditional(o?.queryParams).build(),requestType:"json",body:Ue,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(K.ok)return{data:K.body,rawResponse:K.rawResponse};if(K.error.reason==="status-code")throw K.error.statusCode===400?new x(K.error.body,K.rawResponse):new w({statusCode:K.error.statusCode,body:K.error.body,rawResponse:K.rawResponse});return C(K.error,K.rawResponse,"POST","/v1/listen")})}transcribeFile(e,o,t){return E.fromPromise(this.__transcribeFile(e,o,t))}__transcribeFile(e,o,t){return lr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f={callback:o.callback,callback_method:o.callback_method!=null?o.callback_method:void 0,extra:o.extra,sentiment:o.sentiment,summarize:o.summarize!=null?o.summarize:void 0,tag:o.tag,topics:o.topics,custom_topic:o.custom_topic,custom_topic_mode:o.custom_topic_mode!=null?o.custom_topic_mode:void 0,intents:o.intents,custom_intent:o.custom_intent,custom_intent_mode:o.custom_intent_mode!=null?o.custom_intent_mode:void 0,detect_entities:o.detect_entities,detect_language:o.detect_language,diarize:o.diarize,diarize_model:o.diarize_model!=null?o.diarize_model:void 0,dictation:o.dictation,encoding:o.encoding!=null?o.encoding:void 0,filler_words:o.filler_words,keyterm:o.keyterm,keywords:o.keywords,language:o.language,measurements:o.measurements,model:o.model!=null?o.model:void 0,multichannel:o.multichannel,numerals:o.numerals,paragraphs:o.paragraphs,profanity_filter:o.profanity_filter,punctuate:o.punctuate,redact:o.redact,replace:o.replace,search:o.search,smart_format:o.smart_format,utterances:o.utterances,utt_split:o.utt_split,version:o.version!=null?o.version:void 0,mip_opt_out:o.mip_opt_out},m=yield io.toBinaryUploadRequest(e),h=yield this._options.authProvider.getAuthRequest(),y=b(h.headers,(r=this._options)===null||r===void 0?void 0:r.headers,m.headers,t?.headers),T=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,"v1/listen"),method:"POST",headers:y,contentType:"application/octet-stream",queryString:p.queryBuilder().addMany(f).mergeAdditional(t?.queryParams).build(),requestType:"bytes",duplex:"half",body:m.body,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(T.ok)return{data:T.body,rawResponse:T.rawResponse};if(T.error.reason==="status-code")throw T.error.statusCode===400?new x(T.error.body,T.rawResponse):new w({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse});return C(T.error,T.rawResponse,"POST","/v1/listen")})}};var ln=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Ee=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}sendFinalize(e){this.assertSocketIsOpen(),this.sendJson(e)}sendCloseStream(e){this.assertSocketIsOpen(),this.sendJson(e)}sendKeepAlive(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return ln(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var cn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},xe=class{constructor(e={}){this._options=P(e)}get media(){var e;return(e=this._media)!==null&&e!==void 0?e:this._media=new po(this._options)}connect(e){return cn(this,void 0,void 0,function*(){var o,t,r;let{callback:i,callback_method:a,channels:c,detect_entities:u,diarize:d,dictation:n,encoding:l,endpointing:v,extra:_,interim_results:f,keyterm:m,keywords:h,language:y,mip_opt_out:T,model:S,multichannel:j,numerals:I,profanity_filter:z,punctuate:J,redact:W,replace:D,sample_rate:U,search:L,smart_format:N,tag:$,utterance_end_ms:O,vad_events:se,version:ee,protocols:re,queryParams:me,headers:ve,debug:ne,reconnectAttempts:ie,connectionTimeoutInSeconds:ae,abortSignal:_e}=e,de={callback:i!=null?typeof i=="string"?i:A(i):void 0,callback_method:a??void 0,channels:c!=null?typeof c=="string"?c:A(c):void 0,detect_entities:u??void 0,diarize:d??void 0,dictation:n??void 0,encoding:l??void 0,endpointing:v!=null?typeof v=="string"?v:A(v):void 0,extra:_!=null?typeof _=="string"?_:A(_):void 0,interim_results:f??void 0,keyterm:m!=null?typeof m=="string"?m:A(m):void 0,keywords:h!=null?typeof h=="string"?h:A(h):void 0,language:y!=null?typeof y=="string"?y:A(y):void 0,mip_opt_out:T!=null?typeof T=="string"?T:A(T):void 0,model:S,multichannel:j??void 0,numerals:I??void 0,profanity_filter:z??void 0,punctuate:J??void 0,redact:W??void 0,replace:D!=null?typeof D=="string"?D:A(D):void 0,sample_rate:U!=null?typeof U=="string"?U:A(U):void 0,search:L!=null?typeof L=="string"?L:A(L):void 0,smart_format:N??void 0,tag:$!=null?typeof $=="string"?$:A($):void 0,utterance_end_ms:O!=null?typeof O=="string"?O:A(O):void 0,vad_events:se??void 0,version:ee!=null?typeof ee=="string"?ee:A(ee):void 0},le=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),ve),pe=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v1/listen"),protocols:re??[],queryParameters:Object.assign(Object.assign({},de),me),headers:le,options:{debug:ne??!1,maxRetries:ie??30,connectionTimeout:ae!=null?ae*1e3:void 0},abortSignal:_e});return new Ee({socket:pe})})}};var un=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},ke=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}sendCloseStream(e){this.assertSocketIsOpen(),this.sendJson(e)}sendConfigure(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return un(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var hn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Pe=class{constructor(e={}){this._options=X(e)}connect(e){return hn(this,void 0,void 0,function*(){var o,t,r;let{model:i,encoding:a,sample_rate:c,eager_eot_threshold:u,eot_threshold:d,eot_timeout_ms:n,keyterm:l,language_hint:v,mip_opt_out:_,tag:f,protocols:m,queryParams:h,headers:y,debug:T,reconnectAttempts:S,connectionTimeoutInSeconds:j,abortSignal:I}=e,z={model:i,encoding:a??void 0,sample_rate:c!=null?typeof c=="string"?c:A(c):void 0,eager_eot_threshold:u!=null?typeof u=="string"?u:A(u):void 0,eot_threshold:d!=null?typeof d=="string"?d:A(d):void 0,eot_timeout_ms:n!=null?typeof n=="string"?n:A(n):void 0,keyterm:Array.isArray(l)?l.map(D=>typeof D=="string"?D:A(D)):l!=null?typeof l=="string"?l:A(l):void 0,language_hint:Array.isArray(v)?v.map(D=>typeof D=="string"?D:A(D)):v!=null?typeof v=="string"?v:A(v):void 0,mip_opt_out:_!=null?typeof _=="string"?_:A(_):void 0,tag:f!=null?typeof f=="string"?f:A(f):void 0},J=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),y),W=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v2/listen"),protocols:m??[],queryParameters:Object.assign(Object.assign({},z),h),headers:J,options:{debug:T??!1,maxRetries:S??30,connectionTimeout:j!=null?j*1e3:void 0},abortSignal:I});return new ke({socket:W})})}};var Ce=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new xe(this._options)}get v2(){var e;return(e=this._v2)!==null&&e!==void 0?e:this._v2=new Pe(this._options)}};var cr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},fo=class{constructor(e={}){this._options=P(e)}list(e={},o){return E.fromPromise(this.__list(e,o))}__list(){return cr(this,arguments,void 0,function*(e={},o){var t,r,i,a,c,u,d,n,l,v;let{include_outdated:_}=e,f={include_outdated:_},m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),y=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/models"),method:"GET",headers:h,queryString:p.queryBuilder().addMany(f).mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"GET","/v1/models")})}get(e,o){return E.fromPromise(this.__get(e,o))}__get(e,o){return cr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/models/${p.encodePathParam(e)}`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/models/{model_id}")})}};var ur=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},go=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return ur(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/balances`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/balances")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return ur(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/balances/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/balances/{balance_id}")})}};var mn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},yo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return mn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,accessor:y,deployment:T,tag:S,line_item:j,grouping:I}=t,z={start:m,end:h,accessor:y,deployment:T??void 0,tag:S,line_item:j,grouping:Array.isArray(I)?I.map(U=>U):I??void 0},J=yield this._options.authProvider.getAuthRequest(),W=b(J.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),D=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/billing/breakdown`),method:"GET",headers:W,queryString:p.queryBuilder().addMany(z).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(D.ok)return{data:D.body,rawResponse:D.rawResponse};if(D.error.reason==="status-code")throw D.error.statusCode===400?new x(D.error.body,D.rawResponse):new w({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse});return C(D.error,D.rawResponse,"GET","/v1/projects/{project_id}/billing/breakdown")})}};var vn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},wo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return vn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h}=t,y={start:m,end:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/billing/fields`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}/billing/fields")})}};var _n=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},bo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return _n(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{limit:m}=t,h={limit:m},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/purchases`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/purchases")})}};var Ro=class{constructor(e={}){this._options=P(e)}get balances(){var e;return(e=this._balances)!==null&&e!==void 0?e:this._balances=new go(this._options)}get breakdown(){var e;return(e=this._breakdown)!==null&&e!==void 0?e:this._breakdown=new yo(this._options)}get fields(){var e;return(e=this._fields)!==null&&e!==void 0?e:this._fields=new wo(this._options)}get purchases(){var e;return(e=this._purchases)!==null&&e!==void 0?e:this._purchases=new bo(this._options)}};var So=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Eo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return So(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{status:m}=t,h={status:m??void 0},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/keys`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/keys")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/keys")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/keys/{key_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/keys/{key_id}")})}};var St=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},xo=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return St(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/invites")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return St(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/invites")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return St(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/invites/{email}")})}};var hr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},ko=class{constructor(e={}){this._options=P(e)}list(e,o,t){return E.fromPromise(this.__list(e,o,t))}__list(e,o,t){return hr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}/scopes`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/members/{member_id}/scopes")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return hr(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}/scopes`),method:"PUT",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PUT","/v1/projects/{project_id}/members/{member_id}/scopes")})}};var mr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Po=class{constructor(e={}){this._options=P(e)}get invites(){var e;return(e=this._invites)!==null&&e!==void 0?e:this._invites=new xo(this._options)}get scopes(){var e;return(e=this._scopes)!==null&&e!==void 0?e:this._scopes=new ko(this._options)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return mr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/members")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return mr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/members/{member_id}")})}};var vr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Co=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return vr(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{include_outdated:m}=t,h={include_outdated:m},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/models`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/models")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return vr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/models/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/models/{model_id}")})}};var _r=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},jo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return _r(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,limit:y,page:T,accessor:S,request_id:j,deployment:I,endpoint:z,method:J,status:W}=t,D={start:m??void 0,end:h??void 0,limit:y,page:T,accessor:S,request_id:j,deployment:I??void 0,endpoint:z??void 0,method:J??void 0,status:W??void 0},U=yield this._options.authProvider.getAuthRequest(),L=b(U.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),N=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/requests`),method:"GET",headers:L,queryString:p.queryBuilder().addMany(D).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(N.ok)return{data:N.body,rawResponse:N.rawResponse};if(N.error.reason==="status-code")throw N.error.statusCode===400?new x(N.error.body,N.rawResponse):new w({statusCode:N.error.statusCode,body:N.error.body,rawResponse:N.rawResponse});return C(N.error,N.rawResponse,"GET","/v1/projects/{project_id}/requests")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return _r(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/requests/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/requests/{request_id}")})}};var pn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},To=class{constructor(e={}){this._options=P(e)}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return pn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,grouping:y,accessor:T,alternatives:S,callback_method:j,callback:I,channels:z,custom_intent_mode:J,custom_intent:W,custom_topic_mode:D,custom_topic:U,deployment:L,detect_entities:N,detect_language:$,diarize:O,dictation:se,encoding:ee,endpoint:re,extra:me,filler_words:ve,intents:ne,keyterm:ie,keywords:ae,language:_e,measurements:de,method:le,model:pe,multichannel:Ae,numerals:Ie,paragraphs:Le,profanity_filter:Me,punctuate:Be,redact:ge,replace:He,sample_rate:Ue,search:Fe,sentiment:Ne,smart_format:ze,summarize:K,tag:Oo,topics:et,utt_split:ot,utterances:tt,version:rt}=t,nt={start:m,end:h,grouping:y??void 0,accessor:T,alternatives:S,callback_method:j,callback:I,channels:z,custom_intent_mode:J,custom_intent:W,custom_topic_mode:D,custom_topic:U,deployment:L??void 0,detect_entities:N,detect_language:$,diarize:O,dictation:se,encoding:ee,endpoint:re??void 0,extra:me,filler_words:ve,intents:ne,keyterm:ie,keywords:ae,language:_e,measurements:de,method:le??void 0,model:pe,multichannel:Ae,numerals:Ie,paragraphs:Le,profanity_filter:Me,punctuate:Be,redact:ge,replace:He,sample_rate:Ue,search:Fe,sentiment:Ne,smart_format:ze,summarize:K,tag:Oo,topics:et,utt_split:ot,utterances:tt,version:rt},it=yield this._options.authProvider.getAuthRequest(),Y=b(it.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),q=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage/breakdown`),method:"GET",headers:Y,queryString:p.queryBuilder().addMany(nt).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(q.ok)return{data:q.body,rawResponse:q.rawResponse};if(q.error.reason==="status-code")throw q.error.statusCode===400?new x(q.error.body,q.rawResponse):new w({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse});return C(q.error,q.rawResponse,"GET","/v1/projects/{project_id}/usage/breakdown")})}};var fn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Do=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return fn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h}=t,y={start:m,end:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage/fields`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}/usage/fields")})}};var gn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Ao=class{constructor(e={}){this._options=P(e)}get breakdown(){var e;return(e=this._breakdown)!==null&&e!==void 0?e:this._breakdown=new To(this._options)}get fields(){var e;return(e=this._fields)!==null&&e!==void 0?e:this._fields=new Do(this._options)}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return gn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,accessor:y,alternatives:T,callback_method:S,callback:j,channels:I,custom_intent_mode:z,custom_intent:J,custom_topic_mode:W,custom_topic:D,deployment:U,detect_entities:L,detect_language:N,diarize:$,dictation:O,encoding:se,endpoint:ee,extra:re,filler_words:me,intents:ve,keyterm:ne,keywords:ie,language:ae,measurements:_e,method:de,model:le,multichannel:pe,numerals:Ae,paragraphs:Ie,profanity_filter:Le,punctuate:Me,redact:Be,replace:ge,sample_rate:He,search:Ue,sentiment:Fe,smart_format:Ne,summarize:ze,tag:K,topics:Oo,utt_split:et,utterances:ot,version:tt}=t,rt={start:m,end:h,accessor:y,alternatives:T,callback_method:S,callback:j,channels:I,custom_intent_mode:z,custom_intent:J,custom_topic_mode:W,custom_topic:D,deployment:U??void 0,detect_entities:L,detect_language:N,diarize:$,dictation:O,encoding:se,endpoint:ee??void 0,extra:re,filler_words:me,intents:ve,keyterm:ne,keywords:ie,language:ae,measurements:_e,method:de??void 0,model:le,multichannel:pe,numerals:Ae,paragraphs:Ie,profanity_filter:Le,punctuate:Me,redact:Be,replace:ge,sample_rate:He,search:Ue,sentiment:Fe,smart_format:Ne,summarize:ze,tag:K,topics:Oo,utt_split:et,utterances:ot,version:tt},nt=yield this._options.authProvider.getAuthRequest(),it=b(nt.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),Y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage`),method:"GET",headers:it,queryString:p.queryBuilder().addMany(rt).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(Y.ok)return{data:Y.body,rawResponse:Y.rawResponse};if(Y.error.reason==="status-code")throw Y.error.statusCode===400?new x(Y.error.body,Y.rawResponse):new w({statusCode:Y.error.statusCode,body:Y.error.body,rawResponse:Y.rawResponse});return C(Y.error,Y.rawResponse,"GET","/v1/projects/{project_id}/usage")})}};var Qe=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Io=class{constructor(e={}){this._options=P(e)}get keys(){var e;return(e=this._keys)!==null&&e!==void 0?e:this._keys=new Eo(this._options)}get members(){var e;return(e=this._members)!==null&&e!==void 0?e:this._members=new Po(this._options)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new Co(this._options)}get requests(){var e;return(e=this._requests)!==null&&e!==void 0?e:this._requests=new jo(this._options)}get usage(){var e;return(e=this._usage)!==null&&e!==void 0?e:this._usage=new Ao(this._options)}get billing(){var e;return(e=this._billing)!==null&&e!==void 0?e:this._billing=new Ro(this._options)}list(e){return E.fromPromise(this.__list(e))}__list(e){return Qe(this,void 0,void 0,function*(){var o,t,r,i,a,c,u,d,n,l;let v=yield this._options.authProvider.getAuthRequest(),_=b(v.headers,(o=this._options)===null||o===void 0?void 0:o.headers,e?.headers),f=yield((t=this._options.fetcher)!==null&&t!==void 0?t:k)({url:p.join((r=yield g.get(this._options.baseUrl))!==null&&r!==void 0?r:((i=yield g.get(this._options.environment))!==null&&i!==void 0?i:R.Production).base,"v1/projects"),method:"GET",headers:_,queryString:p.queryBuilder().mergeAdditional(e?.queryParams).build(),timeoutMs:((u=(a=e?.timeoutInSeconds)!==null&&a!==void 0?a:(c=this._options)===null||c===void 0?void 0:c.timeoutInSeconds)!==null&&u!==void 0?u:60)*1e3,maxRetries:(d=e?.maxRetries)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.maxRetries,abortSignal:e?.abortSignal,fetchFn:(l=this._options)===null||l===void 0?void 0:l.fetch,logging:this._options.logging});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")throw f.error.statusCode===400?new x(f.error.body,f.rawResponse):new w({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse});return C(f.error,f.rawResponse,"GET","/v1/projects")})}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return Qe(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{limit:m,page:h}=t,y={limit:m,page:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}")})}delete(e,o){return E.fromPromise(this.__delete(e,o))}__delete(e,o){return Qe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}`),method:"DELETE",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"DELETE","/v1/projects/{project_id}")})}update(e,o={},t){return E.fromPromise(this.__update(e,o,t))}__update(e){return Qe(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}`),method:"PATCH",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PATCH","/v1/projects/{project_id}")})}leave(e,o){return E.fromPromise(this.__leave(e,o))}__leave(e,o){return Qe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/leave`),method:"DELETE",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"DELETE","/v1/projects/{project_id}/leave")})}};var Lo=class{constructor(e={}){this._options=P(e)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new fo(this._options)}get projects(){var e;return(e=this._projects)!==null&&e!==void 0?e:this._projects=new Io(this._options)}};var Mo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Lo(this._options)}};var yn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Bo=class{constructor(e={}){this._options=P(e)}analyze(e,o){return E.fromPromise(this.__analyze(e,o))}__analyze(e,o){return yn(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,sentiment:m,summarize:h,tag:y,topics:T,custom_topic:S,custom_topic_mode:j,intents:I,custom_intent:z,custom_intent_mode:J,language:W,body:D}=e,U={callback:_,callback_method:f??void 0,sentiment:m,summarize:h??void 0,tag:y,topics:T,custom_topic:S,custom_topic_mode:j??void 0,intents:I,custom_intent:z,custom_intent_mode:J??void 0,language:W},L=yield this._options.authProvider.getAuthRequest(),N=b(L.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),$=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/read"),method:"POST",headers:N,contentType:"application/json",queryString:p.queryBuilder().addMany(U).mergeAdditional(o?.queryParams).build(),requestType:"json",body:D,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if($.ok)return{data:$.body,rawResponse:$.rawResponse};if($.error.reason==="status-code")throw $.error.statusCode===400?new x($.error.body,$.rawResponse):new w({statusCode:$.error.statusCode,body:$.error.body,rawResponse:$.rawResponse});return C($.error,$.rawResponse,"POST","/v1/read")})}};var Ho=class{constructor(e={}){this._options=P(e)}get text(){var e;return(e=this._text)!==null&&e!==void 0?e:this._text=new Bo(this._options)}};var Uo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Ho(this._options)}};var Fo=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},wn=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},No=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Fo(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/self-hosted/distribution/credentials")})}create(e,o={},t){return E.fromPromise(this.__create(e,o,t))}__create(e){return Fo(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{scopes:m,provider:h}=t,y=wn(t,["scopes","provider"]),T={scopes:Array.isArray(m)?m.map(z=>z):m??void 0,provider:h??void 0},S=yield this._options.authProvider.getAuthRequest(),j=b(S.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),I=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/self-hosted/distribution/credentials`),method:"POST",headers:j,contentType:"application/json",queryString:p.queryBuilder().addMany(T).mergeAdditional(r?.queryParams).build(),requestType:"json",body:y,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(I.ok)return{data:I.body,rawResponse:I.rawResponse};if(I.error.reason==="status-code")throw I.error.statusCode===400?new x(I.error.body,I.rawResponse):new w({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse});return C(I.error,I.rawResponse,"POST","/v1/projects/{project_id}/self-hosted/distribution/credentials")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Fo(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/self-hosted/distribution/credentials/{distribution_credentials_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Fo(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/self-hosted/distribution/credentials/{distribution_credentials_id}")})}};var zo=class{constructor(e={}){this._options=P(e)}get distributionCredentials(){var e;return(e=this._distributionCredentials)!==null&&e!==void 0?e:this._distributionCredentials=new No(this._options)}};var Wo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new zo(this._options)}};var bn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Rn=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},$o=class{constructor(e={}){this._options=P(e)}generate(e,o){return E.fromPromise(this.__generate(e,o))}__generate(e,o){return bn(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,mip_opt_out:m,tag:h,bit_rate:y,container:T,encoding:S,model:j,sample_rate:I,speed:z}=e,J=Rn(e,["callback","callback_method","mip_opt_out","tag","bit_rate","container","encoding","model","sample_rate","speed"]),W={callback:_,callback_method:f??void 0,mip_opt_out:m,tag:h,bit_rate:y,container:T??void 0,encoding:S??void 0,model:j??void 0,sample_rate:I,speed:z},D=yield this._options.authProvider.getAuthRequest(),U=b(D.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),L=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/speak"),method:"POST",headers:U,contentType:"application/json",queryString:p.queryBuilder().addMany(W).mergeAdditional(o?.queryParams).build(),requestType:"json",body:J,responseType:"binary-response",timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(L.ok)return{data:L.body,rawResponse:L.rawResponse};if(L.error.reason==="status-code")throw L.error.statusCode===400?new x(L.error.body,L.rawResponse):new w({statusCode:L.error.statusCode,body:L.error.body,rawResponse:L.rawResponse});return C(L.error,L.rawResponse,"POST","/v1/speak")})}};var Sn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},je=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendText(e){this.assertSocketIsOpen(),this.sendJson(e)}sendFlush(e){this.assertSocketIsOpen(),this.sendJson(e)}sendClear(e){this.assertSocketIsOpen(),this.sendJson(e)}sendClose(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return Sn(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var En=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Te=class{constructor(e={}){this._options=P(e)}get audio(){var e;return(e=this._audio)!==null&&e!==void 0?e:this._audio=new $o(this._options)}connect(e){return En(this,void 0,void 0,function*(){var o,t,r;let{encoding:i,mip_opt_out:a,model:c,sample_rate:u,speed:d,protocols:n,queryParams:l,headers:v,debug:_,reconnectAttempts:f,connectionTimeoutInSeconds:m,abortSignal:h}=e,y={encoding:i??void 0,mip_opt_out:a!=null?typeof a=="string"?a:A(a):void 0,model:c??void 0,sample_rate:u??void 0,speed:d},T=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),v),S=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v1/speak"),protocols:n??[],queryParameters:Object.assign(Object.assign({},y),l),headers:T,options:{debug:_??!1,maxRetries:f??30,connectionTimeout:m!=null?m*1e3:void 0},abortSignal:h});return new je({socket:S})})}};var De=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Te(this._options)}};var Xe=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Go=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Xe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/agents")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/agents")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/agents/{agent_id}")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return Xe(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"PUT",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PUT","/v1/projects/{project_id}/agents/{agent_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/agents/{agent_id}")})}};var Ze=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Jo=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Ze(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/agent-variables")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/agent-variables")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/agent-variables/{variable_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/agent-variables/{variable_id}")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return Ze(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"PATCH",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PATCH","/v1/projects/{project_id}/agent-variables/{variable_id}")})}};var Ko=class{constructor(e={}){this._options=P(e)}get configurations(){var e;return(e=this._configurations)!==null&&e!==void 0?e:this._configurations=new Go(this._options)}get variables(){var e;return(e=this._variables)!==null&&e!==void 0?e:this._variables=new Jo(this._options)}};var Et=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Vo=class{constructor(e={}){this._options=P(e)}get agent(){var e;return(e=this._agent)!==null&&e!==void 0?e:this._agent=new Se(this._options)}get auth(){var e;return(e=this._auth)!==null&&e!==void 0?e:this._auth=new _o(this._options)}get listen(){var e;return(e=this._listen)!==null&&e!==void 0?e:this._listen=new Ce(this._options)}get manage(){var e;return(e=this._manage)!==null&&e!==void 0?e:this._manage=new Mo(this._options)}get read(){var e;return(e=this._read)!==null&&e!==void 0?e:this._read=new Uo(this._options)}get selfHosted(){var e;return(e=this._selfHosted)!==null&&e!==void 0?e:this._selfHosted=new Wo(this._options)}get speak(){var e;return(e=this._speak)!==null&&e!==void 0?e:this._speak=new De(this._options)}get voiceAgent(){var e;return(e=this._voiceAgent)!==null&&e!==void 0?e:this._voiceAgent=new Ko(this._options)}fetch(e,o,t){return Et(this,void 0,void 0,function*(){var r;return _t(e,o,{baseUrl:(r=this._options.baseUrl)!==null&&r!==void 0?r:(()=>Et(this,void 0,void 0,function*(){var i;let a=yield g.get(this._options.environment);return typeof a=="string"?a:(i=a?.base)!==null&&i!==void 0?i:R.Production.base})),headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:()=>Et(this,void 0,void 0,function*(){return(yield this._options.authProvider.getAuthRequest()).headers})},t)})}};var Z=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},xn=1e4,kn=new Set(["Authorization","headers","debug","reconnectAttempts","connectionTimeoutInSeconds","abortSignal","queryParams"]),qe,fr=!1;function Pn(){return Z(this,void 0,void 0,function*(){var s;if(!fr){fr=!0;try{if(typeof Ft<"u"){let e=wt();qe=e.WebSocket||e.default||e}else if(typeof process<"u"&&(!((s=process.versions)===null||s===void 0)&&s.node)){let o=yield new Function("specifier","return import(specifier)")("ws");qe=o.WebSocket||o.default||o}}catch{qe=void 0}}})}function Cn(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();if(Q.type==="node")try{return pr().randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}var xt=class{constructor(e){this.originalProvider=e}getAuthRequest(e){return Z(this,void 0,void 0,function*(){var o,t;let r=yield this.originalProvider.getAuthRequest(e),i=((o=r.headers)===null||o===void 0?void 0:o.Authorization)||((t=r.headers)===null||t===void 0?void 0:t.authorization);return i&&typeof i=="string"&&!i.startsWith("Bearer ")&&!i.startsWith("Token ")&&!i.startsWith("token ")?{headers:Object.assign(Object.assign({},r.headers),{Authorization:`Token ${i}`})}:r})}},kt=class{constructor(e,o){this.originalProvider=e,this.accessToken=o}getAuthRequest(e){return Z(this,void 0,void 0,function*(){var o,t;let r=(o=yield g.get(this.accessToken))!==null&&o!==void 0?o:(t=process.env)===null||t===void 0?void 0:t.DEEPGRAM_ACCESS_TOKEN;return r!=null?{headers:{Authorization:`Bearer ${r}`}}:this.originalProvider.getAuthRequest(e)})}},Pt=class extends Vo{constructor(e={}){let o=Cn(),t=Object.assign(Object.assign({},e),{headers:Object.assign(Object.assign({},e.headers),{"x-deepgram-session-id":o})});super(t),this._sessionId=o,this._options.authProvider=new xt(this._options.authProvider),e.accessToken!=null&&(this._options.authProvider=new kt(this._options.authProvider,e.accessToken))}get sessionId(){return this._sessionId}get agent(){return this._customAgent||(this._customAgent=new Ct(this._options)),this._customAgent}get listen(){return this._customListen||(this._customListen=new jt(this._options)),this._customListen}get speak(){return this._customSpeak||(this._customSpeak=new Tt(this._options)),this._customSpeak}},Ct=class extends Se{get v1(){return new Dt(this._options)}},jt=class extends Ce{get v1(){return new It(this._options)}get v2(){return new Mt(this._options)}},Tt=class extends De{get v1(){return new Ht(this._options)}};function jn(s){return Z(this,void 0,void 0,function*(){let e={};for(let[o,t]of Object.entries(s)){if(t==null)continue;let r=yield g.get(t);r!=null&&(e[o]=r)}return e})}function Yo(s){let e={};for(let[o,t]of Object.entries(s))!kn.has(o)&&t!=null&&(e[o]=t);return s.queryParams!=null&&typeof s.queryParams=="object"&&Object.assign(e,s.queryParams),e}function Tn(s){let e={},o=Q.type==="browser"||Q.type==="web-worker",t=s["x-deepgram-session-id"]||s["X-Deepgram-Session-Id"];if(Q.type==="node"&&qe)e.WebSocket=qe,e.headers=s;else if(o){let r=s.Authorization||s.authorization,i=Object.assign({},s);delete i.Authorization,delete i.authorization,delete i["x-deepgram-session-id"],delete i["X-Deepgram-Session-Id"],e.headers=i;let a=[];if(r&&typeof r=="string")if(r.startsWith("Token ")){let c=r.substring(6);a.push("token",c)}else if(r.startsWith("Bearer ")){let c=r.substring(7);a.push("bearer",c)}else a.push(r);t&&typeof t=="string"&&a.push("x-deepgram-session-id",t),a.length>0&&(e.protocols=a)}else e.headers=s;return e}function Qo(s,e){var o;let t=i=>{var a,c,u;if(typeof i.data=="string")try{let d=V(i.data);(a=e.message)===null||a===void 0||a.call(e,d)}catch{(c=e.message)===null||c===void 0||c.call(e,i.data)}else(u=e.message)===null||u===void 0||u.call(e,i.data)},r=s;return!((o=r._listeners)===null||o===void 0)&&o.message&&r._listeners.message.forEach(i=>{s.removeEventListener("message",i)}),s.addEventListener("message",t),t}function Xo(s,e){e.handleOpen&&s.removeEventListener("open",e.handleOpen),e.handleMessage&&s.removeEventListener("message",e.handleMessage),e.handleClose&&s.removeEventListener("close",e.handleClose),e.handleError&&s.removeEventListener("error",e.handleError)}function Zo(s){s.readyState===s.CLOSED&&(s._connectLock=!1,s._shouldReconnect=!0)}function qo(s){return Z(this,arguments,void 0,function*({options:e,urlPath:o,environmentKey:t,queryParams:r,headers:i,debug:a,reconnectAttempts:c,connectionTimeoutInSeconds:u,abortSignal:d}){var n,l,v,_,f,m;yield Pn();let h=yield(n=e.authProvider)===null||n===void 0?void 0:n.getAuthRequest(),y=b((l=e.headers)!==null&&l!==void 0?l:{},(v=h?.headers)!==null&&v!==void 0?v:{},i),T=yield jn(y),S=Tn(T),j=(_=yield g.get(e.baseUrl))!==null&&_!==void 0?_:((f=yield g.get(e.environment))!==null&&f!==void 0?f:R.Production)[t];return new B({url:p.join(j,o),protocols:(m=S.protocols)!==null&&m!==void 0?m:[],queryParameters:r,headers:S.headers,options:{WebSocket:S.WebSocket,debug:a??!1,maxRetries:c??30,startClosed:!0,connectionTimeout:u!=null?u*1e3:xn},abortSignal:d})})}var Dt=class extends Re{connect(){return Z(this,arguments,void 0,function*(e={}){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/agent/converse",environmentKey:"agent",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new At({socket:c})})}createConnection(){return Z(this,arguments,void 0,function*(e={}){return this.connect(e)})}},At=class extends be{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}},It=class extends xe{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/listen",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Lt({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Lt=class extends Ee{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}},Mt=class extends Pe{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v2/listen",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Bt({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Bt=class extends ke{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}ping(e){let o=this.socket._ws;if(!o)throw new Error("WebSocket is not connected. Call connect() and waitForOpen() first.");if(o.readyState!==o.OPEN)throw new Error("WebSocket is not in OPEN state.");if(Q.type==="node"&&typeof o.ping=="function")o.ping(e);else throw new Error("WebSocket ping is not supported in browser environments. Browser WebSocket connections handle ping/pong automatically. If you need keepalive in the browser, consider sending periodic audio data or using a timer.")}},Ht=class extends Te{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/speak",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Ut({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Ut=class extends je{constructor(e){super(e);let o=this;o.handleMessage&&this.socket.removeEventListener("message",o.handleMessage),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}};export{Pt as a};
|
|
1
|
+
import{a as Nt,b as zt,c as st,d as wr,f as at}from"./chunk-HXVOCQLA.js";var bt=zt((Qi,dr)=>{"use strict";dr.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var fr=zt(()=>{});var We=class{getAuthRequest(){return Promise.resolve({headers:{}})}};var br=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Oe={get:(s,e)=>br(void 0,void 0,void 0,function*(){return typeof s=="function"?s(e):s})};var A=(s,e,o)=>JSON.stringify(s,e,o);function V(s,e){return JSON.parse(s,e)}var oe={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Wt={[oe.Debug]:1,[oe.Info]:2,[oe.Warn]:3,[oe.Error]:4},$e=class{debug(e,...o){console.debug(e,...o)}info(e,...o){console.info(e,...o)}warn(e,...o){console.warn(e,...o)}error(e,...o){console.error(e,...o)}},ye=class{constructor(e){this.level=Wt[e.level],this.logger=e.logger,this.silent=e.silent}shouldLog(e){return!this.silent&&this.level<=Wt[e]}isDebug(){return this.shouldLog(oe.Debug)}debug(e,...o){this.isDebug()&&this.logger.debug(e,...o)}isInfo(){return this.shouldLog(oe.Info)}info(e,...o){this.isInfo()&&this.logger.info(e,...o)}isWarn(){return this.shouldLog(oe.Warn)}warn(e,...o){this.isWarn()&&this.logger.warn(e,...o)}isError(){return this.shouldLog(oe.Error)}error(e,...o){this.isError()&&this.logger.error(e,...o)}};function Ge(s){var e,o,t;return s==null?Rr:s instanceof ye?s:(s=s??{},(e=s.level)!==null&&e!==void 0||(s.level=oe.Info),(o=s.logger)!==null&&o!==void 0||(s.logger=new $e),(t=s.silent)!==null&&t!==void 0||(s.silent=!0),new ye(s))}var Rr=new ye({level:oe.Info,logger:new $e,silent:!0});var Sr={arrayFormat:"indices",encode:!0};function dt(s,e){if(s===void 0||s===null)return"";let o=String(s);return e?encodeURIComponent(o):o}function lt(s,e="",o){let t=[];for(let[r,i]of Object.entries(s)){let a=e?`${e}[${r}]`:r;if(i!==void 0)if(Array.isArray(i)){if(i.length===0)continue;let c=o.arrayFormat;if(c==="comma"){let u=o.encode?encodeURIComponent(a):a,d=i.filter(n=>n!=null).map(n=>dt(n,o.encode));d.length>0&&t.push(`${u}=${d.join(",")}`)}else for(let u=0;u<i.length;u++){let d=i[u];if(d!==void 0)if(typeof d=="object"&&!Array.isArray(d)&&d!==null){let n=c==="indices"?`${a}[${u}]`:a;t.push(...lt(d,n,o))}else{let n=c==="indices"?`${a}[${u}]`:a,l=o.encode?encodeURIComponent(n):n;t.push(`${l}=${dt(d,o.encode)}`)}}}else if(typeof i=="object"&&i!==null){if(Object.keys(i).length===0)continue;t.push(...lt(i,a,o))}else{let c=o.encode?encodeURIComponent(a):a;t.push(`${c}=${dt(i,o.encode)}`)}}return t}function te(s,e){return s==null||typeof s!="object"?"":lt(s,"",Object.assign(Object.assign({},Sr),e)).join("&")}function $t(s,e){let o=te(e,{arrayFormat:"repeat"});return o?`${s}?${o}`:s}function Gt(s){let e={get bodyUsed(){return s.bodyUsed},stream:()=>s.body,arrayBuffer:s.arrayBuffer.bind(s),blob:s.blob.bind(s)};return"bytes"in s&&typeof s.bytes=="function"&&(e.bytes=s.bytes.bind(s)),e}var Er=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function eo(s,e){return Er(this,void 0,void 0,function*(){switch(e){case"binary-response":return Gt(s);case"blob":return yield s.blob();case"arrayBuffer":return yield s.arrayBuffer();case"sse":return s.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:s.status}}:s.body;case"streaming":return s.body==null?{ok:!1,error:{reason:"body-is-null",statusCode:s.status}}:s.body;case"text":return yield s.text()}let o=yield s.text();if(o.length>0)try{return V(o)}catch{return{ok:!1,error:{reason:"non-json",statusCode:s.status,rawBody:o}}}})}var xr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Jt(s){return xr(this,void 0,void 0,function*(){var e,o,t;let r=(e=s.headers.get("Content-Type"))===null||e===void 0?void 0:e.toLowerCase();if(r==null||r.length===0)return eo(s);switch(r.indexOf(";")!==-1&&(r=(t=(o=r.split(";")[0])===null||o===void 0?void 0:o.trim())!==null&&t!==void 0?t:""),r){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":{let i=yield s.text();return i.length>0?V(i):void 0}default:if(r.startsWith("application/vnd.")&&r.endsWith("+json")){let i=yield s.text();return i.length>0?V(i):void 0}return yield s.text()}})}var kr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function oo(){return kr(this,void 0,void 0,function*(){return fetch})}var Pr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Kt(s){return Pr(this,arguments,void 0,function*({body:e,type:o}){return o==="form"?te(e,{arrayFormat:"repeat",encode:!0}):o.includes("json")?A(e):e})}var ce;typeof globalThis.Headers<"u"?ce=globalThis.Headers:ce=class Vt{constructor(e){if(this.headers=new Map,e)if(e instanceof Vt)e.forEach((o,t)=>this.append(t,o));else if(Array.isArray(e))for(let[o,t]of e)if(typeof o=="string"&&typeof t=="string")this.append(o,t);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[o,t]of Object.entries(e))if(typeof t=="string")this.append(o,t);else throw new TypeError("Header values must be strings")}append(e,o){let t=e.toLowerCase(),r=this.headers.get(t)||[];this.headers.set(t,[...r,o])}delete(e){let o=e.toLowerCase();this.headers.delete(o)}get(e){let o=e.toLowerCase(),t=this.headers.get(o);return t?t.join(", "):null}has(e){let o=e.toLowerCase();return this.headers.has(o)}set(e,o){let t=e.toLowerCase();this.headers.set(t,[o])}forEach(e,o){let t=o?e.bind(o):e;this.headers.forEach((r,i)=>t(r.join(", "),i,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[e,o]of this.headers.entries())yield[e,o.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let e of this.headers.values())yield e.join(", ")}[Symbol.iterator](){return this.entries()}};var Cr="timeout";function Yt(s){let e=new AbortController,o=setTimeout(()=>e.abort(Cr),s);return{signal:e.signal,abortId:o}}function Qt(...s){let e=s.length===1&&Array.isArray(s[0])?s[0]:s,o=new AbortController;for(let t of e){if(t.aborted){o.abort(t?.reason);break}t.addEventListener("abort",()=>o.abort(t?.reason),{signal:o.signal})}return o.signal}var jr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Je;function Tr(){if(Je!=null)return Je;try{new Request("http://localhost",{cache:"no-store"}),Je=!0}catch{Je=!1}return Je}var to=(s,e,o,t,r,i,a,c,u,d)=>jr(void 0,void 0,void 0,function*(){let n=[],l;if(i!=null){let{signal:f,abortId:m}=Yt(i);l=m,n.push(f)}a!=null&&n.push(a);let v=Qt(n),_=yield s(e,Object.assign({method:o,headers:t,body:r,signal:v,credentials:c?"include":void 0,duplex:u},d&&Tr()?{cache:"no-store"}:{}));return l!=null&&clearTimeout(l),_});var ct={headers:new ce,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},ut={headers:new ce,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function ht(s){return{headers:s.headers,redirected:s.redirected,status:s.status,statusText:s.statusText,type:s.type,url:s.url}}var Dr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function Ar(s){let e=1+Math.random()*.2;return s*e}function Ir(s){let e=1+(Math.random()-.5)*.2;return s*e}function Lr(s,e){let o=s.headers.get("Retry-After");if(o){let r=parseInt(o,10);if(!Number.isNaN(r)&&r>0)return Math.min(r*1e3,6e4);let i=new Date(o);if(!Number.isNaN(i.getTime())){let a=i.getTime()-Date.now();if(a>0)return Math.min(Math.max(a,0),6e4)}}let t=s.headers.get("X-RateLimit-Reset");if(t){let r=parseInt(t,10);if(!Number.isNaN(r)){let i=r*1e3-Date.now();if(i>0)return Ar(Math.min(i,6e4))}}return Ir(Math.min(1e3*Math.pow(2,e),6e4))}function ro(s){return Dr(this,arguments,void 0,function*(e,o=2){let t=yield e();for(let r=0;r<o&&([408,429].includes(t.status)||t.status>=500);++r){let i=Lr(t,r);yield new Promise(a=>setTimeout(a,i)),t=yield e()}return t})}var vt=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Mr=new Set(["authorization","www-authenticate","x-api-key","api-key","apikey","x-api-token","x-auth-token","auth-token","cookie","set-cookie","proxy-authorization","proxy-authenticate","x-csrf-token","x-xsrf-token","x-session-token","x-access-token"]);function mt(s){let e={};for(let[o,t]of s instanceof ce?s.entries():Object.entries(s))Mr.has(o.toLowerCase())?e[o]="[REDACTED]":e[o]=t;return e}var _t=new Set(["api_key","api-key","apikey","token","access_token","access-token","auth_token","auth-token","password","passwd","secret","api_secret","api-secret","apisecret","key","session","session_id","session-id"]);function Br(s){if(s==null)return;let e={};for(let[o,t]of Object.entries(s))e[o]=_t.has(o.toLowerCase())?"[REDACTED]":t;return e}function fe(s){let e=s.indexOf("://");if(e===-1)return s;let o=e+3,t=s.indexOf("/",o),r=s.indexOf("?",o),i=s.indexOf("#",o),a=Math.min(t===-1?s.length:t,r===-1?s.length:r,i===-1?s.length:i),c=-1;for(let f=o;f<a;f++)s[f]==="@"&&(c=f);if(c!==-1&&(s=`${s.slice(0,o)}[REDACTED]@${s.slice(c+1)}`),r=s.indexOf("?"),r===-1)return s;i=s.indexOf("#",r);let u=i!==-1?i:s.length,d=s.slice(r+1,u);if(d.length===0)return s;let n=d.toLowerCase();if(!(n.includes("token")||n.includes("key")||n.includes("password")||n.includes("passwd")||n.includes("secret")||n.includes("session")||n.includes("auth")))return s;let v=[],_=d.split("&");for(let f of _){let m=f.indexOf("=");if(m===-1){v.push(f);continue}let h=f.slice(0,m),y=_t.has(h.toLowerCase());if(!y&&h.includes("%"))try{let T=decodeURIComponent(h);y=_t.has(T.toLowerCase())}catch{}v.push(y?`${h}=[REDACTED]`:f)}return s.slice(0,r+1)+v.join("&")+s.slice(u)}function Hr(s){return vt(this,void 0,void 0,function*(){var e;let o=new ce;if(o.set("Accept",s.responseType==="json"?"application/json":s.responseType==="text"?"text/plain":s.responseType==="sse"?"text/event-stream":"*/*"),s.body!==void 0&&s.contentType!=null&&o.set("Content-Type",s.contentType),s.headers==null)return o;for(let[t,r]of Object.entries(s.headers)){let i=yield Oe.get(r,{endpointMetadata:(e=s.endpointMetadata)!==null&&e!==void 0?e:{}});if(typeof i=="string"){o.set(t,i);continue}i!=null&&o.set(t,`${i}`)}return o})}function Ur(s){return vt(this,void 0,void 0,function*(){var e,o,t;let r=s.url;s.queryString!=null&&s.queryString.length>0?r=`${r}?${s.queryString}`:r=$t(s.url,s.queryParameters);let i=yield Kt({body:s.body,type:(e=s.requestType)!==null&&e!==void 0?e:"other"}),a=(o=s.fetchFn)!==null&&o!==void 0?o:yield oo(),c=yield Hr(s),u=Ge(s.logging);if(u.isDebug()){let d={method:s.method,url:fe(r),headers:mt(c),queryParameters:Br(s.queryParameters),hasBody:i!=null};u.debug("Making HTTP request",d)}try{let d=yield ro(()=>vt(this,void 0,void 0,function*(){return to(a,r,s.method,c,i,s.timeoutMs,s.abortSignal,s.withCredentials,s.duplex,s.responseType==="streaming"||s.responseType==="sse")}),s.maxRetries);if(d.status>=200&&d.status<400){if(u.isDebug()){let l={method:s.method,url:fe(r),statusCode:d.status,responseHeaders:mt(d.headers)};u.debug("HTTP request succeeded",l)}return{ok:!0,body:yield eo(d,s.responseType),headers:d.headers,rawResponse:ht(d)}}else{if(u.isError()){let n={method:s.method,url:fe(r),statusCode:d.status,responseHeaders:mt(Object.fromEntries(d.headers.entries()))};u.error("HTTP request failed with error status",n)}return{ok:!1,error:{reason:"status-code",statusCode:d.status,body:yield Jt(d)},rawResponse:ht(d)}}}catch(d){if(!((t=s.abortSignal)===null||t===void 0)&&t.aborted){if(u.isError()){let n={method:s.method,url:fe(r)};u.error("HTTP request was aborted",n)}return{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request",cause:d},rawResponse:ct}}else if(d instanceof Error&&d.name==="AbortError"){if(u.isError()){let n={method:s.method,url:fe(r),timeoutMs:s.timeoutMs};u.error("HTTP request timed out",n)}return{ok:!1,error:{reason:"timeout",cause:d},rawResponse:ct}}else if(d instanceof Error){if(u.isError()){let n={method:s.method,url:fe(r),errorMessage:d.message};u.error("HTTP request failed with error",n)}return{ok:!1,error:{reason:"unknown",errorMessage:d.message,cause:d},rawResponse:ut}}if(u.isError()){let n={method:s.method,url:fe(r),error:A(d)};u.error("HTTP request failed with unknown error",n)}return{ok:!1,error:{reason:"unknown",errorMessage:A(d),cause:d},rawResponse:ut}}})}var k=Ur;var Fr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},E=class s extends Promise{constructor(e){super(o=>{o(void 0)}),this.innerPromise=e}static fromFunction(e,...o){return new s(e(...o))}static interceptFunction(e){return(...o)=>s.fromPromise(e(...o))}static fromPromise(e){return new s(e)}static fromExecutor(e){let o=new Promise(e);return new s(o)}static fromResult(e){let o=Promise.resolve(e);return new s(o)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:e})=>e)),this.unwrappedPromise}then(e,o){return this.unwrap().then(e,o)}catch(e){return this.unwrap().catch(e)}finally(e){return this.unwrap().finally(e)}withRawResponse(){return Fr(this,void 0,void 0,function*(){return yield this.innerPromise})}};function no(s,...e){if(!s)return"";if(e.length===0)return s;if(s.includes("://")){let o;try{o=new URL(s)}catch{return Xt(s,...e)}let t=e[e.length-1],r=t?.endsWith("/");for(let i of e){let a=qt(i);a&&(o.pathname=Zt(o.pathname,a))}return r&&!o.pathname.endsWith("/")&&(o.pathname+="/"),o.toString()}return Xt(s,...e)}function Xt(s,...e){if(e.length===0)return s;let o=s,t=e[e.length-1],r=t?.endsWith("/");for(let i of e){let a=qt(i);a&&(o=Zt(o,a))}return r&&!o.endsWith("/")&&(o+="/"),o}function Zt(s,e){return s.endsWith("/")?s+e:`${s}/${e}`}function qt(s){if(!s)return s;let e=0,o=s.length;return s.startsWith("/")&&(e=1),s.endsWith("/")&&(o=s.length-1),e===0&&o===s.length?s:s.slice(e,o)}var Nr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},g={get:s=>Nr(void 0,void 0,void 0,function*(){return typeof s=="function"?s():s})};var Ot=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function pt(s,e,o,t){return Ot(this,void 0,void 0,function*(){var r,i,a,c,u,d,n;let l=Ge(o.logging),v,_=e;s instanceof Request?(v=s.url,e==null&&(_={method:s.method,headers:Object.fromEntries(s.headers.entries()),body:s.body,signal:s.signal,credentials:s.credentials,cache:s.cache,redirect:s.redirect,referrer:s.referrer,integrity:s.integrity,mode:s.mode})):v=s instanceof URL?s.toString():s;let f=(r=o.baseUrl!=null?yield g.get(o.baseUrl):void 0)!==null&&r!==void 0?r:o.environment!=null?yield g.get(o.environment):void 0,m;v.startsWith("http://")||v.startsWith("https://")?m=v:f!=null?m=no(f,v):m=v;let h={};if(o.headers!=null)for(let[D,U]of Object.entries(o.headers)){let L=yield Oe.get(U,{endpointMetadata:{}});L!=null&&(h[D.toLowerCase()]=`${L}`)}if(o.getAuthHeaders!=null){let D=yield o.getAuthHeaders();for(let[U,L]of Object.entries(D))h[U.toLowerCase()]=L}if(_?.headers!=null){let D=_.headers instanceof Headers?Object.fromEntries(_.headers.entries()):Array.isArray(_.headers)?Object.fromEntries(_.headers):_.headers;for(let[U,L]of Object.entries(D))L!=null&&(h[U.toLowerCase()]=L)}if(t?.headers!=null)for(let[D,U]of Object.entries(t.headers))h[D.toLowerCase()]=U;let y=(i=_?.method)!==null&&i!==void 0?i:"GET",T=_?.body,S=(a=t?.timeoutInSeconds)!==null&&a!==void 0?a:o.timeoutInSeconds,j=S!=null?S*1e3:void 0,I=(c=t?.maxRetries)!==null&&c!==void 0?c:o.maxRetries,z=(d=(u=t?.abortSignal)!==null&&u!==void 0?u:_?.signal)!==null&&d!==void 0?d:void 0,J=(n=o.fetch)!==null&&n!==void 0?n:yield oo();l.isDebug()&&l.debug("Making passthrough HTTP request",{method:y,url:m,hasBody:T!=null});let W=yield ro(()=>Ot(this,void 0,void 0,function*(){return to(J,m,y,h,T??void 0,j,z,_?.credentials==="include",void 0,!1)}),I);return l.isDebug()&&l.debug("Passthrough HTTP request completed",{method:y,url:m,statusCode:W.status}),W})}var io={};st(io,{toBinaryUploadRequest:()=>zr,toMultipartDataPart:()=>Wr});var Ke=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})};function zr(s){return Ke(this,void 0,void 0,function*(){let{data:e,filename:o,contentLength:t,contentType:r}=yield ft(s),i={body:e,headers:{}};return o&&(i.headers["Content-Disposition"]=`attachment; filename="${o}"`),r&&(i.headers["Content-Type"]=r),t!=null&&(i.headers["Content-Length"]=t.toString()),i})}function Wr(s){return Ke(this,void 0,void 0,function*(){let{data:e,filename:o,contentType:t}=yield ft(s,{noSniffFileSize:!0});return{data:e,filename:o,contentType:t}})}function ft(s){return Ke(this,arguments,void 0,function*(e,{noSniffFileSize:o}={}){var t,r,i,a,c;if($r(e))return ft({data:e},{noSniffFileSize:o});if("path"in e){let u=yield import("./fs-TPREOTZZ.js");if(!u?.createReadStream)throw new Error("File path uploads are not supported in this environment.");let d=u.createReadStream(e.path),n=(t=e.contentLength)!==null&&t!==void 0?t:o===!0?void 0:yield er(e.path),l=(r=e.filename)!==null&&r!==void 0?r:or(e.path);return{data:d,filename:l,contentType:e.contentType,contentLength:n}}if("data"in e){let u=e.data,d=(i=e.contentLength)!==null&&i!==void 0?i:yield Jr(u,{noSniffFileSize:o}),n=(a=e.filename)!==null&&a!==void 0?a:Gr(u);return{data:u,filename:n,contentType:(c=e.contentType)!==null&&c!==void 0?c:Kr(u),contentLength:d}}throw new Error(`Invalid FileUpload of type ${typeof e}: ${JSON.stringify(e)}`)})}function $r(s){return rr(s)||nr(s)||ir(s)||Xr(s)||gt(s)||yt(s)||Yr(s)||Qr(s)}function er(s){return Ke(this,void 0,void 0,function*(){var e;try{let o=yield import("./fs-TPREOTZZ.js");return!((e=o?.promises)===null||e===void 0)&&e.stat?(yield o.promises.stat(s)).size:void 0}catch{return}})}function Gr(s){if(Vr(s))return s.name;if(tr(s))return or(s.path.toString())}function Jr(s){return Ke(this,arguments,void 0,function*(e,{noSniffFileSize:o}={}){if(rr(e))return e.length;if(nr(e)||ir(e))return e.byteLength;if(gt(e)||yt(e))return e.size;if(o!==!0&&tr(e))return yield er(e.path.toString())})}function Kr(s){if(gt(s)||yt(s))return s.type}function or(s){let e=s.lastIndexOf("/"),o=s.lastIndexOf("\\"),t=Math.max(e,o);return t>=0?s.substring(t+1):s}function Vr(s){return typeof s=="object"&&s!=null&&"name"in s}function tr(s){return typeof s=="object"&&s!=null&&"path"in s}function Yr(s){return typeof s=="object"&&s!=null&&("read"in s||"pipe"in s)}function Qr(s){return typeof s=="object"&&s!=null&&"getReader"in s}function rr(s){return typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(s)}function nr(s){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(s)}function ir(s){return typeof ArrayBuffer<"u"&&s instanceof ArrayBuffer}function Xr(s){return typeof Uint8Array<"u"&&s instanceof Uint8Array}function gt(s){return typeof Blob<"u"&&s instanceof Blob}function yt(s){return typeof File<"u"&&s instanceof File}var so={};st(so,{ConsoleLogger:()=>$e,LogLevel:()=>oe,Logger:()=>ye,createLogger:()=>Ge});var Q=Zr();function Zr(){var s,e,o,t,r;if(typeof window<"u"&&typeof window.document<"u")return{type:"browser",version:window.navigator.userAgent};if(typeof globalThis<"u"&&((s=globalThis?.navigator)===null||s===void 0?void 0:s.userAgent)==="Cloudflare-Workers")return{type:"workerd"};if(typeof EdgeRuntime=="string")return{type:"edge-runtime"};if(typeof self=="object"&&typeof self?.importScripts=="function"&&(((e=self.constructor)===null||e===void 0?void 0:e.name)==="DedicatedWorkerGlobalScope"||((o=self.constructor)===null||o===void 0?void 0:o.name)==="ServiceWorkerGlobalScope"||((t=self.constructor)===null||t===void 0?void 0:t.name)==="SharedWorkerGlobalScope"))return{type:"web-worker"};if(typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u")return{type:"deno",version:Deno.version.deno};if(typeof Bun<"u"&&typeof Bun.version<"u")return{type:"bun",version:Bun.version};if(typeof navigator<"u"&&navigator?.product==="ReactNative")return{type:"react-native"};let v=typeof process<"u"?process:void 0;return typeof v<"u"&&typeof((r=v.versions)===null||r===void 0?void 0:r.node)=="string"?{type:"node",version:v.versions.node,parsedVersion:Number(v.versions.node.split(".")[0])}:{type:"unknown"}}var p={};st(p,{encodePathParam:()=>sr,join:()=>no,queryBuilder:()=>ar,toQueryString:()=>te});function sr(s){if(s===null)return"null";switch(typeof s){case"undefined":return"undefined";case"string":case"number":case"boolean":break;default:s=String(s);break}return encodeURIComponent(s)}function ar(){return new wt}var wt=class{constructor(){this.parts=new Map}add(e,o,t){if(o==null)return this;let r=te({[e]:o},{arrayFormat:t?.style==="comma"?"comma":"repeat"});return r.length>0&&this.parts.set(e,r),this}addMany(e){if(e!=null)for(let[o,t]of Object.entries(e))this.add(o,t);return this}mergeAdditional(e){if(e!=null)for(let[o,t]of Object.entries(e)){if(t==null)continue;let r=te({[o]:t},{arrayFormat:"repeat"});r.length>0&&this.parts.set(o,r)}return this}build(){return[...this.parts.values()].join("&")}};var lr=wr(bt(),1);var ao=class{constructor(e,o){this.target=o,this.type=e}},lo=class extends ao{constructor(e,o){super("error",o),this.message=e.message,this.error=e}},Ve=class extends ao{constructor(e=1e3,o="",t){super("close",t),this.wasClean=!0,this.code=e,this.reason=o}};var Or=()=>{if(Q.type==="node"||Q.type==="bun"||Q.type==="deno")return lr.WebSocket;if(typeof WebSocket<"u")return WebSocket},en=s=>typeof s<"u"&&!!s&&s.CLOSING===2,ue={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},B=class s{constructor({url:e,protocols:o,options:t,headers:r,queryParameters:i,abortSignal:a}){this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.CONNECTING=s.CONNECTING,this.OPEN=s.OPEN,this.CLOSING=s.CLOSING,this.CLOSED=s.CLOSED,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleAbort=()=>{if(!this._closeCalled&&(this._debug("abort signal fired"),this._shouldReconnect=!1,this._closeCalled=!0,this._clearTimeouts(),this._ws)){this._removeListeners(),this._ws.addEventListener("error",()=>{});try{this._ws.close(1e3,"aborted"),this._handleClose(new Ve(1e3,"aborted",this))}catch{}}},this._handleOpen=c=>{this._debug("open event");let{minUptime:u=ue.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),u),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(d=>{var n;return(n=this._ws)===null||n===void 0?void 0:n.send(d)}),this._messageQueue=[],this.onopen&&this.onopen(c),this._listeners.open.forEach(d=>this._callEventListener(c,d))},this._handleMessage=c=>{this._debug("message event"),this.onmessage&&this.onmessage(c),this._listeners.message.forEach(u=>this._callEventListener(c,u))},this._handleError=c=>{this._debug("error event",c.message),this._disconnect(void 0,c.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(c),this._debug("exec error listeners"),this._listeners.error.forEach(u=>this._callEventListener(c,u)),this._connect()},this._handleClose=c=>{this._debug("close event"),this._clearTimeouts(),c.code===1e3&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(c),this._listeners.close.forEach(u=>this._callEventListener(c,u))},this._url=e,this._protocols=o,this._options=t??ue,this._headers=r,this._queryParameters=i,this._abortSignal=a,this._abortSignal&&this._abortSignal.addEventListener("abort",this._handleAbort,{once:!0}),this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((o,t)=>(typeof t=="string"?o+=t.length:t instanceof Blob?o+=t.size:o+=t.byteLength,o),0)+(this._ws?this._ws.bufferedAmount:0)}get extensions(){return this._ws?this._ws.extensions:""}get protocol(){return this._ws?this._ws.protocol:""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?s.ReadyState.CLOSED:s.ReadyState.CONNECTING}get url(){return this._ws?this._ws.url:""}close(e=1e3,o){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(e,o)}reconnect(e,o){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(e,o),this._connect())}send(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",e),this._ws.send(e);else{let{maxEnqueuedMessages:o=ue.maxEnqueuedMessages}=this._options;this._messageQueue.length<o&&(this._debug("enqueue",e),this._messageQueue.push(e))}}addEventListener(e,o){this._listeners[e]&&this._listeners[e].push(o)}dispatchEvent(e){let o=this._listeners[e.type];if(o)for(let t of o)this._callEventListener(e,t);return!0}removeEventListener(e,o){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter(t=>t!==o))}_debug(...e){this._options.debug&&console.log.apply(console,["RWS>",...e])}_getNextDelay(){let{reconnectionDelayGrowFactor:e=ue.reconnectionDelayGrowFactor,minReconnectionDelay:o=ue.minReconnectionDelay,maxReconnectionDelay:t=ue.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=o*Math.pow(e,this._retryCount-1),r>t&&(r=t)),this._debug("next delay",r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_getNextUrl(e){if(typeof e=="string")return Promise.resolve(e);if(typeof e=="function"){let o=e();if(typeof o=="string")return Promise.resolve(o);if(o.then)return o}throw Error("Invalid URL")}_connect(){var e;if(this._connectLock||!this._shouldReconnect)return;if(!((e=this._abortSignal)===null||e===void 0)&&e.aborted){this._debug("connect aborted");return}this._connectLock=!0;let{maxRetries:o=ue.maxRetries,connectionTimeout:t=ue.connectionTimeout,WebSocket:r=Or()}=this._options;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!en(r))throw Error("No valid WebSocket class provided");this._wait().then(()=>this._getNextUrl(this._url)).then(i=>{var a;if(this._closeCalled||!((a=this._abortSignal)===null||a===void 0)&&a.aborted){this._connectLock=!1;return}let c={};if(this._headers&&(c.headers=this._headers),this._queryParameters&&Object.keys(this._queryParameters).length>0){let u=te(this._queryParameters,{arrayFormat:"repeat"});u&&(i=`${i}?${u}`)}this._ws=new r(i,this._protocols,c),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)})}_handleTimeout(){this._debug("timeout event"),this._handleError(new lo(Error("TIMEOUT"),this))}_disconnect(e=1e3,o){if(this._clearTimeouts(),!!this._ws){this._removeListeners(),this._ws.addEventListener("error",()=>{});try{this._ws.close(e,o),this._handleClose(new Ve(e,o,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_callEventListener(e,o){"handleEvent"in o?o.handleEvent(e):o(e)}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}};B.CONNECTING=0;B.OPEN=1;B.CLOSING=2;B.CLOSED=3;(function(s){s.ReadyState={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}})(B||(B={}));var w=class extends Error{constructor({message:e,statusCode:o,body:t,rawResponse:r,cause:i}){super(on({message:e,statusCode:o,body:t})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=o,this.body=t,this.rawResponse=r,i!=null&&(this.cause=i)}};function on({message:s,statusCode:e,body:o}){let t=[];return s!=null&&t.push(s),e!=null&&t.push(`Status code: ${e.toString()}`),o!=null&&t.push(`Body: ${A(o,void 0,2)}`),t.join(`
|
|
2
|
+
`)}var Ye=class extends Error{constructor(e,o){super(e),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,o?.cause!=null&&(this.cause=o.cause)}};var tn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Rt="apiKey",St="DEEPGRAM_API_KEY",rn="Authorization",we=class s{constructor(e){this.options=e}static canCreate(e){var o;return e?.[Rt]!=null||((o=process.env)===null||o===void 0?void 0:o[St])!=null}getAuthRequest(){return tn(this,arguments,void 0,function*({endpointMetadata:e}={}){var o,t;let r=(o=yield g.get(this.options[Rt]))!==null&&o!==void 0?o:(t=process.env)===null||t===void 0?void 0:t[St];if(r==null)throw new w({message:s.AUTH_CONFIG_ERROR_MESSAGE});return{headers:{[rn]:r}}})}};(function(s){s.AUTH_SCHEME="ApiKeyAuth",s.AUTH_CONFIG_ERROR_MESSAGE=`Please provide '${Rt}' when initializing the client, or set the '${St}' environment variable`;function e(o){return new s(o)}s.createInstance=e})(we||(we={}));function b(...s){let e={};for(let[o,t]of s.filter(r=>r!=null).flatMap(r=>Object.entries(r))){let r=o.toLowerCase();t!=null?e[r]=t:r in e&&delete e[r]}return e}function he(...s){let e={};for(let[o,t]of s.filter(r=>r!=null).flatMap(r=>Object.entries(r))){let r=o.toLowerCase();t!=null&&(e[r]=t)}return e}function X(s){let e=b({"X-Fern-Language":"JavaScript","X-Fern-SDK-Name":"@deepgram/sdk","X-Fern-SDK-Version":"5.2.1","User-Agent":"@deepgram/sdk/5.2.1","X-Fern-Runtime":Q.type,"X-Fern-Runtime-Version":Q.version},s?.headers);return Object.assign(Object.assign({},s),{logging:so.createLogger(s?.logging),headers:e})}function P(s){var e;let o=X(s),t=nn(o);return(e=o.authProvider)!==null&&e!==void 0||(o.authProvider=new we(t)),o}function nn(s){return Object.assign(Object.assign({},s),{authProvider:new We})}var R={Production:{base:"https://api.deepgram.com",production:"wss://api.deepgram.com",agent:"wss://agent.deepgram.com",agentRest:"https://agent.deepgram.com"}};function C(s,e,o,t){switch(s.reason){case"non-json":throw new w({statusCode:s.statusCode,body:s.rawBody,rawResponse:e});case"body-is-null":throw new w({statusCode:s.statusCode,rawResponse:e});case"timeout":throw new Ye(`Timeout exceeded when calling ${o} ${t}.`,{cause:s.cause});case"unknown":throw new w({message:s.errorMessage,rawResponse:e,cause:s.cause});default:throw new w({message:"Unknown error",rawResponse:e})}}var x=class extends w{constructor(e,o){super({message:"BadRequestError",statusCode:400,body:e,rawResponse:o}),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var sn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},co=class{constructor(e={}){this._options=X(e)}list(e){return E.fromPromise(this.__list(e))}__list(e){return sn(this,void 0,void 0,function*(){var o,t,r,i,a,c,u,d,n,l;let v=b((o=this._options)===null||o===void 0?void 0:o.headers,e?.headers),_=yield((t=this._options.fetcher)!==null&&t!==void 0?t:k)({url:p.join((r=yield g.get(this._options.baseUrl))!==null&&r!==void 0?r:((i=yield g.get(this._options.environment))!==null&&i!==void 0?i:R.Production).agentRest,"v1/agent/settings/think/models"),method:"GET",headers:v,queryString:p.queryBuilder().mergeAdditional(e?.queryParams).build(),timeoutMs:((u=(a=e?.timeoutInSeconds)!==null&&a!==void 0?a:(c=this._options)===null||c===void 0?void 0:c.timeoutInSeconds)!==null&&u!==void 0?u:60)*1e3,maxRetries:(d=e?.maxRetries)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.maxRetries,abortSignal:e?.abortSignal,fetchFn:(l=this._options)===null||l===void 0?void 0:l.fetch,logging:this._options.logging});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")throw _.error.statusCode===400?new x(_.error.body,_.rawResponse):new w({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse});return C(_.error,_.rawResponse,"GET","/v1/agent/settings/think/models")})}};var uo=class{constructor(e={}){this._options=X(e)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new co(this._options)}};var ho=class{constructor(e={}){this._options=X(e)}get think(){var e;return(e=this._think)!==null&&e!==void 0?e:this._think=new uo(this._options)}};var an=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},be=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendSettings(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdateSpeak(e){this.assertSocketIsOpen(),this.sendJson(e)}sendInjectUserMessage(e){this.assertSocketIsOpen(),this.sendJson(e)}sendInjectAgentMessage(e){this.assertSocketIsOpen(),this.sendJson(e)}sendFunctionCallResponse(e){this.assertSocketIsOpen(),this.sendJson(e)}sendKeepAlive(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdatePrompt(e){this.assertSocketIsOpen(),this.sendJson(e)}sendUpdateThink(e){this.assertSocketIsOpen(),this.sendJson(e)}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return an(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var dn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Re=class{constructor(e={}){this._options=X(e)}get settings(){var e;return(e=this._settings)!==null&&e!==void 0?e:this._settings=new ho(this._options)}connect(e){return dn(this,void 0,void 0,function*(){var o,t,r;let{protocols:i,queryParams:a,headers:c,debug:u,reconnectAttempts:d,connectionTimeoutInSeconds:n,abortSignal:l}=e,v=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),c),_=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).agent,"/v1/agent/converse"),protocols:i??[],queryParameters:a??{},headers:v,options:{debug:u??!1,maxRetries:d??30,connectionTimeout:n!=null?n*1e3:void 0},abortSignal:l});return new be({socket:_})})}};var Se=class{constructor(e={}){this._options=X(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Re(this._options)}};var ln=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},mo=class{constructor(e={}){this._options=P(e)}grant(e={},o){return E.fromPromise(this.__grant(e,o))}__grant(){return ln(this,arguments,void 0,function*(e={},o){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/auth/grant"),method:"POST",headers:f,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),requestType:"json",body:e,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"POST","/v1/auth/grant")})}};var vo=class{constructor(e={}){this._options=P(e)}get tokens(){var e;return(e=this._tokens)!==null&&e!==void 0?e:this._tokens=new mo(this._options)}};var _o=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new vo(this._options)}};var cr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},cn=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},po=class{constructor(e={}){this._options=P(e)}transcribeUrl(e,o){return E.fromPromise(this.__transcribeUrl(e,o))}__transcribeUrl(e,o){return cr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,extra:m,sentiment:h,summarize:y,tag:T,topics:S,custom_topic:j,custom_topic_mode:I,intents:z,custom_intent:J,custom_intent_mode:W,detect_entities:D,detect_language:U,diarize:L,diarize_model:N,dictation:$,encoding:O,filler_words:se,keyterm:ee,keywords:re,language:me,measurements:ve,model:ne,multichannel:ie,numerals:ae,paragraphs:_e,profanity_filter:de,punctuate:le,redact:pe,replace:Ae,search:Ie,smart_format:Le,utterances:Me,utt_split:Be,version:ge,mip_opt_out:He}=e,Ue=cn(e,["callback","callback_method","extra","sentiment","summarize","tag","topics","custom_topic","custom_topic_mode","intents","custom_intent","custom_intent_mode","detect_entities","detect_language","diarize","diarize_model","dictation","encoding","filler_words","keyterm","keywords","language","measurements","model","multichannel","numerals","paragraphs","profanity_filter","punctuate","redact","replace","search","smart_format","utterances","utt_split","version","mip_opt_out"]),Fe={callback:_,callback_method:f??void 0,extra:m,sentiment:h,summarize:y??void 0,tag:T,topics:S,custom_topic:j,custom_topic_mode:I??void 0,intents:z,custom_intent:J,custom_intent_mode:W??void 0,detect_entities:D,detect_language:U,diarize:L,diarize_model:N??void 0,dictation:$,encoding:O??void 0,filler_words:se,keyterm:ee,keywords:re,language:me,measurements:ve,model:ne??void 0,multichannel:ie,numerals:ae,paragraphs:_e,profanity_filter:de,punctuate:le,redact:pe,replace:Ae,search:Ie,smart_format:Le,utterances:Me,utt_split:Be,version:ge??void 0,mip_opt_out:He},Ne=yield this._options.authProvider.getAuthRequest(),ze=b(Ne.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),K=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/listen"),method:"POST",headers:ze,contentType:"application/json",queryString:p.queryBuilder().addMany(Fe).mergeAdditional(o?.queryParams).build(),requestType:"json",body:Ue,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(K.ok)return{data:K.body,rawResponse:K.rawResponse};if(K.error.reason==="status-code")throw K.error.statusCode===400?new x(K.error.body,K.rawResponse):new w({statusCode:K.error.statusCode,body:K.error.body,rawResponse:K.rawResponse});return C(K.error,K.rawResponse,"POST","/v1/listen")})}transcribeFile(e,o,t){return E.fromPromise(this.__transcribeFile(e,o,t))}__transcribeFile(e,o,t){return cr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f={callback:o.callback,callback_method:o.callback_method!=null?o.callback_method:void 0,extra:o.extra,sentiment:o.sentiment,summarize:o.summarize!=null?o.summarize:void 0,tag:o.tag,topics:o.topics,custom_topic:o.custom_topic,custom_topic_mode:o.custom_topic_mode!=null?o.custom_topic_mode:void 0,intents:o.intents,custom_intent:o.custom_intent,custom_intent_mode:o.custom_intent_mode!=null?o.custom_intent_mode:void 0,detect_entities:o.detect_entities,detect_language:o.detect_language,diarize:o.diarize,diarize_model:o.diarize_model!=null?o.diarize_model:void 0,dictation:o.dictation,encoding:o.encoding!=null?o.encoding:void 0,filler_words:o.filler_words,keyterm:o.keyterm,keywords:o.keywords,language:o.language,measurements:o.measurements,model:o.model!=null?o.model:void 0,multichannel:o.multichannel,numerals:o.numerals,paragraphs:o.paragraphs,profanity_filter:o.profanity_filter,punctuate:o.punctuate,redact:o.redact,replace:o.replace,search:o.search,smart_format:o.smart_format,utterances:o.utterances,utt_split:o.utt_split,version:o.version!=null?o.version:void 0,mip_opt_out:o.mip_opt_out},m=yield io.toBinaryUploadRequest(e),h=yield this._options.authProvider.getAuthRequest(),y=b(h.headers,(r=this._options)===null||r===void 0?void 0:r.headers,m.headers,t?.headers),T=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,"v1/listen"),method:"POST",headers:y,contentType:"application/octet-stream",queryString:p.queryBuilder().addMany(f).mergeAdditional(t?.queryParams).build(),requestType:"bytes",duplex:"half",body:m.body,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(T.ok)return{data:T.body,rawResponse:T.rawResponse};if(T.error.reason==="status-code")throw T.error.statusCode===400?new x(T.error.body,T.rawResponse):new w({statusCode:T.error.statusCode,body:T.error.body,rawResponse:T.rawResponse});return C(T.error,T.rawResponse,"POST","/v1/listen")})}};var un=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Ee=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}sendFinalize(e){this.assertSocketIsOpen(),this.sendJson(e)}sendCloseStream(e){this.assertSocketIsOpen(),this.sendJson(e)}sendKeepAlive(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return un(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var hn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},xe=class{constructor(e={}){this._options=P(e)}get media(){var e;return(e=this._media)!==null&&e!==void 0?e:this._media=new po(this._options)}connect(e){return hn(this,void 0,void 0,function*(){var o,t,r;let{callback:i,callback_method:a,channels:c,detect_entities:u,diarize:d,dictation:n,encoding:l,endpointing:v,extra:_,interim_results:f,keyterm:m,keywords:h,language:y,mip_opt_out:T,model:S,multichannel:j,numerals:I,profanity_filter:z,punctuate:J,redact:W,replace:D,sample_rate:U,search:L,smart_format:N,tag:$,utterance_end_ms:O,vad_events:se,version:ee,protocols:re,queryParams:me,headers:ve,debug:ne,reconnectAttempts:ie,connectionTimeoutInSeconds:ae,abortSignal:_e}=e,de={callback:i!=null?typeof i=="string"?i:A(i):void 0,callback_method:a??void 0,channels:c!=null?typeof c=="string"?c:A(c):void 0,detect_entities:u??void 0,diarize:d??void 0,dictation:n??void 0,encoding:l??void 0,endpointing:v!=null?typeof v=="string"?v:A(v):void 0,extra:_!=null?typeof _=="string"?_:A(_):void 0,interim_results:f??void 0,keyterm:m!=null?typeof m=="string"?m:A(m):void 0,keywords:h!=null?typeof h=="string"?h:A(h):void 0,language:y!=null?typeof y=="string"?y:A(y):void 0,mip_opt_out:T!=null?typeof T=="string"?T:A(T):void 0,model:S,multichannel:j??void 0,numerals:I??void 0,profanity_filter:z??void 0,punctuate:J??void 0,redact:W??void 0,replace:D!=null?typeof D=="string"?D:A(D):void 0,sample_rate:U!=null?typeof U=="string"?U:A(U):void 0,search:L!=null?typeof L=="string"?L:A(L):void 0,smart_format:N??void 0,tag:$!=null?typeof $=="string"?$:A($):void 0,utterance_end_ms:O!=null?typeof O=="string"?O:A(O):void 0,vad_events:se??void 0,version:ee!=null?typeof ee=="string"?ee:A(ee):void 0},le=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),ve),pe=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v1/listen"),protocols:re??[],queryParameters:Object.assign(Object.assign({},de),me),headers:le,options:{debug:ne??!1,maxRetries:ie??30,connectionTimeout:ae!=null?ae*1e3:void 0},abortSignal:_e});return new Ee({socket:pe})})}};var mn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},ke=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendMedia(e){this.assertSocketIsOpen(),this.sendBinary(e)}sendCloseStream(e){this.assertSocketIsOpen(),this.sendJson(e)}sendConfigure(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return mn(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var vn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Pe=class{constructor(e={}){this._options=X(e)}connect(e){return vn(this,void 0,void 0,function*(){var o,t,r;let{model:i,encoding:a,sample_rate:c,eager_eot_threshold:u,eot_threshold:d,eot_timeout_ms:n,keyterm:l,language_hint:v,mip_opt_out:_,tag:f,protocols:m,queryParams:h,headers:y,debug:T,reconnectAttempts:S,connectionTimeoutInSeconds:j,abortSignal:I}=e,z={model:i,encoding:a??void 0,sample_rate:c!=null?typeof c=="string"?c:A(c):void 0,eager_eot_threshold:u!=null?typeof u=="string"?u:A(u):void 0,eot_threshold:d!=null?typeof d=="string"?d:A(d):void 0,eot_timeout_ms:n!=null?typeof n=="string"?n:A(n):void 0,keyterm:Array.isArray(l)?l.map(D=>typeof D=="string"?D:A(D)):l!=null?typeof l=="string"?l:A(l):void 0,language_hint:Array.isArray(v)?v.map(D=>typeof D=="string"?D:A(D)):v!=null?typeof v=="string"?v:A(v):void 0,mip_opt_out:_!=null?typeof _=="string"?_:A(_):void 0,tag:f!=null?typeof f=="string"?f:A(f):void 0},J=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),y),W=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v2/listen"),protocols:m??[],queryParameters:Object.assign(Object.assign({},z),h),headers:J,options:{debug:T??!1,maxRetries:S??30,connectionTimeout:j!=null?j*1e3:void 0},abortSignal:I});return new ke({socket:W})})}};var Ce=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new xe(this._options)}get v2(){var e;return(e=this._v2)!==null&&e!==void 0?e:this._v2=new Pe(this._options)}};var ur=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},fo=class{constructor(e={}){this._options=P(e)}list(e={},o){return E.fromPromise(this.__list(e,o))}__list(){return ur(this,arguments,void 0,function*(e={},o){var t,r,i,a,c,u,d,n,l,v;let{include_outdated:_}=e,f={include_outdated:_},m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),y=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/models"),method:"GET",headers:h,queryString:p.queryBuilder().addMany(f).mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"GET","/v1/models")})}get(e,o){return E.fromPromise(this.__get(e,o))}__get(e,o){return ur(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/models/${p.encodePathParam(e)}`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/models/{model_id}")})}};var hr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},go=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return hr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/balances`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/balances")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return hr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/balances/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/balances/{balance_id}")})}};var _n=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},yo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return _n(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,accessor:y,deployment:T,tag:S,line_item:j,grouping:I}=t,z={start:m,end:h,accessor:y,deployment:T??void 0,tag:S,line_item:j,grouping:Array.isArray(I)?I.map(U=>U):I??void 0},J=yield this._options.authProvider.getAuthRequest(),W=b(J.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),D=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/billing/breakdown`),method:"GET",headers:W,queryString:p.queryBuilder().addMany(z).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(D.ok)return{data:D.body,rawResponse:D.rawResponse};if(D.error.reason==="status-code")throw D.error.statusCode===400?new x(D.error.body,D.rawResponse):new w({statusCode:D.error.statusCode,body:D.error.body,rawResponse:D.rawResponse});return C(D.error,D.rawResponse,"GET","/v1/projects/{project_id}/billing/breakdown")})}};var pn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},wo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return pn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h}=t,y={start:m,end:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/billing/fields`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}/billing/fields")})}};var fn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},bo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return fn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{limit:m}=t,h={limit:m},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/purchases`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/purchases")})}};var Ro=class{constructor(e={}){this._options=P(e)}get balances(){var e;return(e=this._balances)!==null&&e!==void 0?e:this._balances=new go(this._options)}get breakdown(){var e;return(e=this._breakdown)!==null&&e!==void 0?e:this._breakdown=new yo(this._options)}get fields(){var e;return(e=this._fields)!==null&&e!==void 0?e:this._fields=new wo(this._options)}get purchases(){var e;return(e=this._purchases)!==null&&e!==void 0?e:this._purchases=new bo(this._options)}};var So=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Eo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return So(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{status:m}=t,h={status:m??void 0},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/keys`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/keys")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/keys")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/keys/{key_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return So(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/keys/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/keys/{key_id}")})}};var Et=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},xo=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Et(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/invites")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return Et(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/invites")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Et(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/invites/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/invites/{email}")})}};var mr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},ko=class{constructor(e={}){this._options=P(e)}list(e,o,t){return E.fromPromise(this.__list(e,o,t))}__list(e,o,t){return mr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}/scopes`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/members/{member_id}/scopes")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return mr(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}/scopes`),method:"PUT",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PUT","/v1/projects/{project_id}/members/{member_id}/scopes")})}};var vr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Po=class{constructor(e={}){this._options=P(e)}get invites(){var e;return(e=this._invites)!==null&&e!==void 0?e:this._invites=new xo(this._options)}get scopes(){var e;return(e=this._scopes)!==null&&e!==void 0?e:this._scopes=new ko(this._options)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return vr(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/members")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return vr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/members/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/members/{member_id}")})}};var _r=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Co=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return _r(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{include_outdated:m}=t,h={include_outdated:m},y=yield this._options.authProvider.getAuthRequest(),T=b(y.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),S=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/models`),method:"GET",headers:T,queryString:p.queryBuilder().addMany(h).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(S.ok)return{data:S.body,rawResponse:S.rawResponse};if(S.error.reason==="status-code")throw S.error.statusCode===400?new x(S.error.body,S.rawResponse):new w({statusCode:S.error.statusCode,body:S.error.body,rawResponse:S.rawResponse});return C(S.error,S.rawResponse,"GET","/v1/projects/{project_id}/models")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return _r(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/models/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/models/{model_id}")})}};var pr=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},jo=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return pr(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,limit:y,page:T,accessor:S,request_id:j,deployment:I,endpoint:z,method:J,status:W}=t,D={start:m??void 0,end:h??void 0,limit:y,page:T,accessor:S,request_id:j,deployment:I??void 0,endpoint:z??void 0,method:J??void 0,status:W??void 0},U=yield this._options.authProvider.getAuthRequest(),L=b(U.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),N=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/requests`),method:"GET",headers:L,queryString:p.queryBuilder().addMany(D).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(N.ok)return{data:N.body,rawResponse:N.rawResponse};if(N.error.reason==="status-code")throw N.error.statusCode===400?new x(N.error.body,N.rawResponse):new w({statusCode:N.error.statusCode,body:N.error.body,rawResponse:N.rawResponse});return C(N.error,N.rawResponse,"GET","/v1/projects/{project_id}/requests")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return pr(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/requests/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/requests/{request_id}")})}};var gn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},To=class{constructor(e={}){this._options=P(e)}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return gn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,grouping:y,accessor:T,alternatives:S,callback_method:j,callback:I,channels:z,custom_intent_mode:J,custom_intent:W,custom_topic_mode:D,custom_topic:U,deployment:L,detect_entities:N,detect_language:$,diarize:O,dictation:se,encoding:ee,endpoint:re,extra:me,filler_words:ve,intents:ne,keyterm:ie,keywords:ae,language:_e,measurements:de,method:le,model:pe,multichannel:Ae,numerals:Ie,paragraphs:Le,profanity_filter:Me,punctuate:Be,redact:ge,replace:He,sample_rate:Ue,search:Fe,sentiment:Ne,smart_format:ze,summarize:K,tag:Oo,topics:et,utt_split:ot,utterances:tt,version:rt}=t,nt={start:m,end:h,grouping:y??void 0,accessor:T,alternatives:S,callback_method:j,callback:I,channels:z,custom_intent_mode:J,custom_intent:W,custom_topic_mode:D,custom_topic:U,deployment:L??void 0,detect_entities:N,detect_language:$,diarize:O,dictation:se,encoding:ee,endpoint:re??void 0,extra:me,filler_words:ve,intents:ne,keyterm:ie,keywords:ae,language:_e,measurements:de,method:le??void 0,model:pe,multichannel:Ae,numerals:Ie,paragraphs:Le,profanity_filter:Me,punctuate:Be,redact:ge,replace:He,sample_rate:Ue,search:Fe,sentiment:Ne,smart_format:ze,summarize:K,tag:Oo,topics:et,utt_split:ot,utterances:tt,version:rt},it=yield this._options.authProvider.getAuthRequest(),Y=b(it.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),q=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage/breakdown`),method:"GET",headers:Y,queryString:p.queryBuilder().addMany(nt).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(q.ok)return{data:q.body,rawResponse:q.rawResponse};if(q.error.reason==="status-code")throw q.error.statusCode===400?new x(q.error.body,q.rawResponse):new w({statusCode:q.error.statusCode,body:q.error.body,rawResponse:q.rawResponse});return C(q.error,q.rawResponse,"GET","/v1/projects/{project_id}/usage/breakdown")})}};var yn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Do=class{constructor(e={}){this._options=P(e)}list(e,o={},t){return E.fromPromise(this.__list(e,o,t))}__list(e){return yn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h}=t,y={start:m,end:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage/fields`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}/usage/fields")})}};var wn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Ao=class{constructor(e={}){this._options=P(e)}get breakdown(){var e;return(e=this._breakdown)!==null&&e!==void 0?e:this._breakdown=new To(this._options)}get fields(){var e;return(e=this._fields)!==null&&e!==void 0?e:this._fields=new Do(this._options)}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return wn(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{start:m,end:h,accessor:y,alternatives:T,callback_method:S,callback:j,channels:I,custom_intent_mode:z,custom_intent:J,custom_topic_mode:W,custom_topic:D,deployment:U,detect_entities:L,detect_language:N,diarize:$,dictation:O,encoding:se,endpoint:ee,extra:re,filler_words:me,intents:ve,keyterm:ne,keywords:ie,language:ae,measurements:_e,method:de,model:le,multichannel:pe,numerals:Ae,paragraphs:Ie,profanity_filter:Le,punctuate:Me,redact:Be,replace:ge,sample_rate:He,search:Ue,sentiment:Fe,smart_format:Ne,summarize:ze,tag:K,topics:Oo,utt_split:et,utterances:ot,version:tt}=t,rt={start:m,end:h,accessor:y,alternatives:T,callback_method:S,callback:j,channels:I,custom_intent_mode:z,custom_intent:J,custom_topic_mode:W,custom_topic:D,deployment:U??void 0,detect_entities:L,detect_language:N,diarize:$,dictation:O,encoding:se,endpoint:ee??void 0,extra:re,filler_words:me,intents:ve,keyterm:ne,keywords:ie,language:ae,measurements:_e,method:de??void 0,model:le,multichannel:pe,numerals:Ae,paragraphs:Ie,profanity_filter:Le,punctuate:Me,redact:Be,replace:ge,sample_rate:He,search:Ue,sentiment:Fe,smart_format:Ne,summarize:ze,tag:K,topics:Oo,utt_split:et,utterances:ot,version:tt},nt=yield this._options.authProvider.getAuthRequest(),it=b(nt.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),Y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/usage`),method:"GET",headers:it,queryString:p.queryBuilder().addMany(rt).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(Y.ok)return{data:Y.body,rawResponse:Y.rawResponse};if(Y.error.reason==="status-code")throw Y.error.statusCode===400?new x(Y.error.body,Y.rawResponse):new w({statusCode:Y.error.statusCode,body:Y.error.body,rawResponse:Y.rawResponse});return C(Y.error,Y.rawResponse,"GET","/v1/projects/{project_id}/usage")})}};var Qe=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Io=class{constructor(e={}){this._options=P(e)}get keys(){var e;return(e=this._keys)!==null&&e!==void 0?e:this._keys=new Eo(this._options)}get members(){var e;return(e=this._members)!==null&&e!==void 0?e:this._members=new Po(this._options)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new Co(this._options)}get requests(){var e;return(e=this._requests)!==null&&e!==void 0?e:this._requests=new jo(this._options)}get usage(){var e;return(e=this._usage)!==null&&e!==void 0?e:this._usage=new Ao(this._options)}get billing(){var e;return(e=this._billing)!==null&&e!==void 0?e:this._billing=new Ro(this._options)}list(e){return E.fromPromise(this.__list(e))}__list(e){return Qe(this,void 0,void 0,function*(){var o,t,r,i,a,c,u,d,n,l;let v=yield this._options.authProvider.getAuthRequest(),_=b(v.headers,(o=this._options)===null||o===void 0?void 0:o.headers,e?.headers),f=yield((t=this._options.fetcher)!==null&&t!==void 0?t:k)({url:p.join((r=yield g.get(this._options.baseUrl))!==null&&r!==void 0?r:((i=yield g.get(this._options.environment))!==null&&i!==void 0?i:R.Production).base,"v1/projects"),method:"GET",headers:_,queryString:p.queryBuilder().mergeAdditional(e?.queryParams).build(),timeoutMs:((u=(a=e?.timeoutInSeconds)!==null&&a!==void 0?a:(c=this._options)===null||c===void 0?void 0:c.timeoutInSeconds)!==null&&u!==void 0?u:60)*1e3,maxRetries:(d=e?.maxRetries)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.maxRetries,abortSignal:e?.abortSignal,fetchFn:(l=this._options)===null||l===void 0?void 0:l.fetch,logging:this._options.logging});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")throw f.error.statusCode===400?new x(f.error.body,f.rawResponse):new w({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse});return C(f.error,f.rawResponse,"GET","/v1/projects")})}get(e,o={},t){return E.fromPromise(this.__get(e,o,t))}__get(e){return Qe(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{limit:m,page:h}=t,y={limit:m,page:h},T=yield this._options.authProvider.getAuthRequest(),S=b(T.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),j=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}`),method:"GET",headers:S,queryString:p.queryBuilder().addMany(y).mergeAdditional(r?.queryParams).build(),timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(j.ok)return{data:j.body,rawResponse:j.rawResponse};if(j.error.reason==="status-code")throw j.error.statusCode===400?new x(j.error.body,j.rawResponse):new w({statusCode:j.error.statusCode,body:j.error.body,rawResponse:j.rawResponse});return C(j.error,j.rawResponse,"GET","/v1/projects/{project_id}")})}delete(e,o){return E.fromPromise(this.__delete(e,o))}__delete(e,o){return Qe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}`),method:"DELETE",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"DELETE","/v1/projects/{project_id}")})}update(e,o={},t){return E.fromPromise(this.__update(e,o,t))}__update(e){return Qe(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}`),method:"PATCH",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PATCH","/v1/projects/{project_id}")})}leave(e,o){return E.fromPromise(this.__leave(e,o))}__leave(e,o){return Qe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/leave`),method:"DELETE",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"DELETE","/v1/projects/{project_id}/leave")})}};var Lo=class{constructor(e={}){this._options=P(e)}get models(){var e;return(e=this._models)!==null&&e!==void 0?e:this._models=new fo(this._options)}get projects(){var e;return(e=this._projects)!==null&&e!==void 0?e:this._projects=new Io(this._options)}};var Mo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Lo(this._options)}};var bn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Bo=class{constructor(e={}){this._options=P(e)}analyze(e,o){return E.fromPromise(this.__analyze(e,o))}__analyze(e,o){return bn(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,sentiment:m,summarize:h,tag:y,topics:T,custom_topic:S,custom_topic_mode:j,intents:I,custom_intent:z,custom_intent_mode:J,language:W,body:D}=e,U={callback:_,callback_method:f??void 0,sentiment:m,summarize:h??void 0,tag:y,topics:T,custom_topic:S,custom_topic_mode:j??void 0,intents:I,custom_intent:z,custom_intent_mode:J??void 0,language:W},L=yield this._options.authProvider.getAuthRequest(),N=b(L.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),$=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/read"),method:"POST",headers:N,contentType:"application/json",queryString:p.queryBuilder().addMany(U).mergeAdditional(o?.queryParams).build(),requestType:"json",body:D,timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if($.ok)return{data:$.body,rawResponse:$.rawResponse};if($.error.reason==="status-code")throw $.error.statusCode===400?new x($.error.body,$.rawResponse):new w({statusCode:$.error.statusCode,body:$.error.body,rawResponse:$.rawResponse});return C($.error,$.rawResponse,"POST","/v1/read")})}};var Ho=class{constructor(e={}){this._options=P(e)}get text(){var e;return(e=this._text)!==null&&e!==void 0?e:this._text=new Bo(this._options)}};var Uo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Ho(this._options)}};var Fo=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Rn=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},No=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Fo(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/self-hosted/distribution/credentials")})}create(e,o={},t){return E.fromPromise(this.__create(e,o,t))}__create(e){return Fo(this,arguments,void 0,function*(o,t={},r){var i,a,c,u,d,n,l,v,_,f;let{scopes:m,provider:h}=t,y=Rn(t,["scopes","provider"]),T={scopes:Array.isArray(m)?m.map(z=>z):m??void 0,provider:h??void 0},S=yield this._options.authProvider.getAuthRequest(),j=b(S.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),I=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(o)}/self-hosted/distribution/credentials`),method:"POST",headers:j,contentType:"application/json",queryString:p.queryBuilder().addMany(T).mergeAdditional(r?.queryParams).build(),requestType:"json",body:y,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(I.ok)return{data:I.body,rawResponse:I.rawResponse};if(I.error.reason==="status-code")throw I.error.statusCode===400?new x(I.error.body,I.rawResponse):new w({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse});return C(I.error,I.rawResponse,"POST","/v1/projects/{project_id}/self-hosted/distribution/credentials")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Fo(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/self-hosted/distribution/credentials/{distribution_credentials_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Fo(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/self-hosted/distribution/credentials/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/self-hosted/distribution/credentials/{distribution_credentials_id}")})}};var zo=class{constructor(e={}){this._options=P(e)}get distributionCredentials(){var e;return(e=this._distributionCredentials)!==null&&e!==void 0?e:this._distributionCredentials=new No(this._options)}};var Wo=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new zo(this._options)}};var Sn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},En=function(s,e){var o={};for(var t in s)Object.prototype.hasOwnProperty.call(s,t)&&e.indexOf(t)<0&&(o[t]=s[t]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,t=Object.getOwnPropertySymbols(s);r<t.length;r++)e.indexOf(t[r])<0&&Object.prototype.propertyIsEnumerable.call(s,t[r])&&(o[t[r]]=s[t[r]]);return o},$o=class{constructor(e={}){this._options=P(e)}generate(e,o){return E.fromPromise(this.__generate(e,o))}__generate(e,o){return Sn(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let{callback:_,callback_method:f,mip_opt_out:m,tag:h,bit_rate:y,container:T,encoding:S,model:j,sample_rate:I,speed:z}=e,J=En(e,["callback","callback_method","mip_opt_out","tag","bit_rate","container","encoding","model","sample_rate","speed"]),W={callback:_,callback_method:f??void 0,mip_opt_out:m,tag:h,bit_rate:y,container:T??void 0,encoding:S??void 0,model:j??void 0,sample_rate:I,speed:z},D=yield this._options.authProvider.getAuthRequest(),U=b(D.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),L=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,"v1/speak"),method:"POST",headers:U,contentType:"application/json",queryString:p.queryBuilder().addMany(W).mergeAdditional(o?.queryParams).build(),requestType:"json",body:J,responseType:"binary-response",timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(L.ok)return{data:L.body,rawResponse:L.rawResponse};if(L.error.reason==="status-code")throw L.error.statusCode===400?new x(L.error.body,L.rawResponse):new w({statusCode:L.error.statusCode,body:L.error.body,rawResponse:L.rawResponse});return C(L.error,L.rawResponse,"POST","/v1/speak")})}};var xn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},je=class{constructor(e){this.eventHandlers={},this.handleOpen=()=>{var o,t;(t=(o=this.eventHandlers).open)===null||t===void 0||t.call(o)},this.handleMessage=o=>{var t,r;let i=V(o.data);(r=(t=this.eventHandlers).message)===null||r===void 0||r.call(t,i)},this.handleClose=o=>{var t,r;(r=(t=this.eventHandlers).close)===null||r===void 0||r.call(t,o)},this.handleError=o=>{var t,r;let i=o.message;(r=(t=this.eventHandlers).error)===null||r===void 0||r.call(t,new Error(i))},this.socket=e.socket,this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError)}get readyState(){return this.socket.readyState}on(e,o){this.eventHandlers[e]=o}sendText(e){this.assertSocketIsOpen(),this.sendJson(e)}sendFlush(e){this.assertSocketIsOpen(),this.sendJson(e)}sendClear(e){this.assertSocketIsOpen(),this.sendJson(e)}sendClose(e){this.assertSocketIsOpen(),this.sendJson(e)}connect(){return this.socket.reconnect(),this.socket.addEventListener("open",this.handleOpen),this.socket.addEventListener("message",this.handleMessage),this.socket.addEventListener("close",this.handleClose),this.socket.addEventListener("error",this.handleError),this}close(){this.socket.close(),this.handleClose({code:1e3}),this.socket.removeEventListener("open",this.handleOpen),this.socket.removeEventListener("message",this.handleMessage),this.socket.removeEventListener("close",this.handleClose),this.socket.removeEventListener("error",this.handleError)}waitForOpen(){return xn(this,void 0,void 0,function*(){return this.socket.readyState===B.ReadyState.OPEN?this.socket:new Promise((e,o)=>{this.socket.addEventListener("open",()=>{e(this.socket)}),this.socket.addEventListener("error",t=>{o(t)})})})}assertSocketIsOpen(){if(!this.socket)throw new Error("Socket is not connected.");if(this.socket.readyState!==B.ReadyState.OPEN)throw new Error("Socket is not open.")}sendBinary(e){this.socket.send(e)}sendJson(e){let o=A(e);this.socket.send(o)}};var kn=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Te=class{constructor(e={}){this._options=P(e)}get audio(){var e;return(e=this._audio)!==null&&e!==void 0?e:this._audio=new $o(this._options)}connect(e){return kn(this,void 0,void 0,function*(){var o,t,r;let{encoding:i,mip_opt_out:a,model:c,sample_rate:u,speed:d,protocols:n,queryParams:l,headers:v,debug:_,reconnectAttempts:f,connectionTimeoutInSeconds:m,abortSignal:h}=e,y={encoding:i??void 0,mip_opt_out:a!=null?typeof a=="string"?a:A(a):void 0,model:c??void 0,sample_rate:u??void 0,speed:d},T=b((o=this._options)===null||o===void 0?void 0:o.headers,he({Authorization:e.Authorization}),v),S=new B({url:p.join((t=yield g.get(this._options.baseUrl))!==null&&t!==void 0?t:((r=yield g.get(this._options.environment))!==null&&r!==void 0?r:R.Production).production,"/v1/speak"),protocols:n??[],queryParameters:Object.assign(Object.assign({},y),l),headers:T,options:{debug:_??!1,maxRetries:f??30,connectionTimeout:m!=null?m*1e3:void 0},abortSignal:h});return new je({socket:S})})}};var De=class{constructor(e={}){this._options=P(e)}get v1(){var e;return(e=this._v1)!==null&&e!==void 0?e:this._v1=new Te(this._options)}};var Xe=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Go=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Xe(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/agents")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/agents")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/agents/{agent_id}")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return Xe(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"PUT",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PUT","/v1/projects/{project_id}/agents/{agent_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Xe(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agents/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/agents/{agent_id}")})}};var Ze=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Jo=class{constructor(e={}){this._options=P(e)}list(e,o){return E.fromPromise(this.__list(e,o))}__list(e,o){return Ze(this,void 0,void 0,function*(){var t,r,i,a,c,u,d,n,l,v;let _=yield this._options.authProvider.getAuthRequest(),f=b(_.headers,(t=this._options)===null||t===void 0?void 0:t.headers,o?.headers),m=yield((r=this._options.fetcher)!==null&&r!==void 0?r:k)({url:p.join((i=yield g.get(this._options.baseUrl))!==null&&i!==void 0?i:((a=yield g.get(this._options.environment))!==null&&a!==void 0?a:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables`),method:"GET",headers:f,queryString:p.queryBuilder().mergeAdditional(o?.queryParams).build(),timeoutMs:((d=(c=o?.timeoutInSeconds)!==null&&c!==void 0?c:(u=this._options)===null||u===void 0?void 0:u.timeoutInSeconds)!==null&&d!==void 0?d:60)*1e3,maxRetries:(n=o?.maxRetries)!==null&&n!==void 0?n:(l=this._options)===null||l===void 0?void 0:l.maxRetries,abortSignal:o?.abortSignal,fetchFn:(v=this._options)===null||v===void 0?void 0:v.fetch,logging:this._options.logging});if(m.ok)return{data:m.body,rawResponse:m.rawResponse};if(m.error.reason==="status-code")throw m.error.statusCode===400?new x(m.error.body,m.rawResponse):new w({statusCode:m.error.statusCode,body:m.error.body,rawResponse:m.rawResponse});return C(m.error,m.rawResponse,"GET","/v1/projects/{project_id}/agent-variables")})}create(e,o,t){return E.fromPromise(this.__create(e,o,t))}__create(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables`),method:"POST",headers:m,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),requestType:"json",body:o,timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"POST","/v1/projects/{project_id}/agent-variables")})}get(e,o,t){return E.fromPromise(this.__get(e,o,t))}__get(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"GET",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"GET","/v1/projects/{project_id}/agent-variables/{variable_id}")})}delete(e,o,t){return E.fromPromise(this.__delete(e,o,t))}__delete(e,o,t){return Ze(this,void 0,void 0,function*(){var r,i,a,c,u,d,n,l,v,_;let f=yield this._options.authProvider.getAuthRequest(),m=b(f.headers,(r=this._options)===null||r===void 0?void 0:r.headers,t?.headers),h=yield((i=this._options.fetcher)!==null&&i!==void 0?i:k)({url:p.join((a=yield g.get(this._options.baseUrl))!==null&&a!==void 0?a:((c=yield g.get(this._options.environment))!==null&&c!==void 0?c:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"DELETE",headers:m,queryString:p.queryBuilder().mergeAdditional(t?.queryParams).build(),timeoutMs:((n=(u=t?.timeoutInSeconds)!==null&&u!==void 0?u:(d=this._options)===null||d===void 0?void 0:d.timeoutInSeconds)!==null&&n!==void 0?n:60)*1e3,maxRetries:(l=t?.maxRetries)!==null&&l!==void 0?l:(v=this._options)===null||v===void 0?void 0:v.maxRetries,abortSignal:t?.abortSignal,fetchFn:(_=this._options)===null||_===void 0?void 0:_.fetch,logging:this._options.logging});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")throw h.error.statusCode===400?new x(h.error.body,h.rawResponse):new w({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse});return C(h.error,h.rawResponse,"DELETE","/v1/projects/{project_id}/agent-variables/{variable_id}")})}update(e,o,t,r){return E.fromPromise(this.__update(e,o,t,r))}__update(e,o,t,r){return Ze(this,void 0,void 0,function*(){var i,a,c,u,d,n,l,v,_,f;let m=yield this._options.authProvider.getAuthRequest(),h=b(m.headers,(i=this._options)===null||i===void 0?void 0:i.headers,r?.headers),y=yield((a=this._options.fetcher)!==null&&a!==void 0?a:k)({url:p.join((c=yield g.get(this._options.baseUrl))!==null&&c!==void 0?c:((u=yield g.get(this._options.environment))!==null&&u!==void 0?u:R.Production).base,`v1/projects/${p.encodePathParam(e)}/agent-variables/${p.encodePathParam(o)}`),method:"PATCH",headers:h,contentType:"application/json",queryString:p.queryBuilder().mergeAdditional(r?.queryParams).build(),requestType:"json",body:t,timeoutMs:((l=(d=r?.timeoutInSeconds)!==null&&d!==void 0?d:(n=this._options)===null||n===void 0?void 0:n.timeoutInSeconds)!==null&&l!==void 0?l:60)*1e3,maxRetries:(v=r?.maxRetries)!==null&&v!==void 0?v:(_=this._options)===null||_===void 0?void 0:_.maxRetries,abortSignal:r?.abortSignal,fetchFn:(f=this._options)===null||f===void 0?void 0:f.fetch,logging:this._options.logging});if(y.ok)return{data:y.body,rawResponse:y.rawResponse};if(y.error.reason==="status-code")throw y.error.statusCode===400?new x(y.error.body,y.rawResponse):new w({statusCode:y.error.statusCode,body:y.error.body,rawResponse:y.rawResponse});return C(y.error,y.rawResponse,"PATCH","/v1/projects/{project_id}/agent-variables/{variable_id}")})}};var Ko=class{constructor(e={}){this._options=P(e)}get configurations(){var e;return(e=this._configurations)!==null&&e!==void 0?e:this._configurations=new Go(this._options)}get variables(){var e;return(e=this._variables)!==null&&e!==void 0?e:this._variables=new Jo(this._options)}};var xt=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Vo=class{constructor(e={}){this._options=P(e)}get agent(){var e;return(e=this._agent)!==null&&e!==void 0?e:this._agent=new Se(this._options)}get auth(){var e;return(e=this._auth)!==null&&e!==void 0?e:this._auth=new _o(this._options)}get listen(){var e;return(e=this._listen)!==null&&e!==void 0?e:this._listen=new Ce(this._options)}get manage(){var e;return(e=this._manage)!==null&&e!==void 0?e:this._manage=new Mo(this._options)}get read(){var e;return(e=this._read)!==null&&e!==void 0?e:this._read=new Uo(this._options)}get selfHosted(){var e;return(e=this._selfHosted)!==null&&e!==void 0?e:this._selfHosted=new Wo(this._options)}get speak(){var e;return(e=this._speak)!==null&&e!==void 0?e:this._speak=new De(this._options)}get voiceAgent(){var e;return(e=this._voiceAgent)!==null&&e!==void 0?e:this._voiceAgent=new Ko(this._options)}fetch(e,o,t){return xt(this,void 0,void 0,function*(){var r;return pt(e,o,{baseUrl:(r=this._options.baseUrl)!==null&&r!==void 0?r:(()=>xt(this,void 0,void 0,function*(){var i;let a=yield g.get(this._options.environment);return typeof a=="string"?a:(i=a?.base)!==null&&i!==void 0?i:R.Production.base})),headers:this._options.headers,timeoutInSeconds:this._options.timeoutInSeconds,maxRetries:this._options.maxRetries,fetch:this._options.fetch,logging:this._options.logging,getAuthHeaders:()=>xt(this,void 0,void 0,function*(){return(yield this._options.authProvider.getAuthRequest()).headers})},t)})}};var Z=function(s,e,o,t){function r(i){return i instanceof o?i:new o(function(a){a(i)})}return new(o||(o=Promise))(function(i,a){function c(n){try{d(t.next(n))}catch(l){a(l)}}function u(n){try{d(t.throw(n))}catch(l){a(l)}}function d(n){n.done?i(n.value):r(n.value).then(c,u)}d((t=t.apply(s,e||[])).next())})},Pn=1e4,Cn=new Set(["Authorization","headers","debug","reconnectAttempts","connectionTimeoutInSeconds","abortSignal","queryParams"]),qe,gr=!1;function jn(){return Z(this,void 0,void 0,function*(){var s;if(!gr){gr=!0;try{if(typeof Nt<"u"){let e=bt();qe=e.WebSocket||e.default||e}else if(typeof process<"u"&&(!((s=process.versions)===null||s===void 0)&&s.node)){let o=yield new Function("specifier","return import(specifier)")("ws");qe=o.WebSocket||o.default||o}}catch{qe=void 0}}})}function Tn(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();if(Q.type==="node")try{return fr().randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{let e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}var kt=class{constructor(e){this.originalProvider=e}getAuthRequest(e){return Z(this,void 0,void 0,function*(){var o,t;let r=yield this.originalProvider.getAuthRequest(e),i=((o=r.headers)===null||o===void 0?void 0:o.Authorization)||((t=r.headers)===null||t===void 0?void 0:t.authorization);return i&&typeof i=="string"&&!i.startsWith("Bearer ")&&!i.startsWith("Token ")&&!i.startsWith("token ")?{headers:Object.assign(Object.assign({},r.headers),{Authorization:`Token ${i}`})}:r})}},Pt=class{constructor(e,o){this.originalProvider=e,this.accessToken=o}getAuthRequest(e){return Z(this,void 0,void 0,function*(){var o,t;let r=(o=yield g.get(this.accessToken))!==null&&o!==void 0?o:(t=process.env)===null||t===void 0?void 0:t.DEEPGRAM_ACCESS_TOKEN;return r!=null?{headers:{Authorization:`Bearer ${r}`}}:this.originalProvider.getAuthRequest(e)})}},Ct=class extends Vo{constructor(e={}){let o=Tn(),t=Object.assign(Object.assign({},e),{headers:Object.assign(Object.assign({},e.headers),{"x-deepgram-session-id":o})});super(t),this._sessionId=o,this._options.authProvider=new kt(this._options.authProvider),e.accessToken!=null&&(this._options.authProvider=new Pt(this._options.authProvider,e.accessToken))}get sessionId(){return this._sessionId}get agent(){return this._customAgent||(this._customAgent=new jt(this._options)),this._customAgent}get listen(){return this._customListen||(this._customListen=new Tt(this._options)),this._customListen}get speak(){return this._customSpeak||(this._customSpeak=new Dt(this._options)),this._customSpeak}},jt=class extends Se{get v1(){return new At(this._options)}},Tt=class extends Ce{get v1(){return new Lt(this._options)}get v2(){return new Bt(this._options)}},Dt=class extends De{get v1(){return new Ut(this._options)}};function Dn(s){return Z(this,void 0,void 0,function*(){let e={};for(let[o,t]of Object.entries(s)){if(t==null)continue;let r=yield g.get(t);r!=null&&(e[o]=r)}return e})}function Yo(s){let e={};for(let[o,t]of Object.entries(s))!Cn.has(o)&&t!=null&&(e[o]=t);return s.queryParams!=null&&typeof s.queryParams=="object"&&Object.assign(e,s.queryParams),e}function An(s){let e={},o=Q.type==="browser"||Q.type==="web-worker",t=s["x-deepgram-session-id"]||s["X-Deepgram-Session-Id"];if(Q.type==="node"&&qe)e.WebSocket=qe,e.headers=s;else if(o){let r=s.Authorization||s.authorization,i=Object.assign({},s);delete i.Authorization,delete i.authorization,delete i["x-deepgram-session-id"],delete i["X-Deepgram-Session-Id"],e.headers=i;let a=[];if(r&&typeof r=="string")if(r.startsWith("Token ")){let c=r.substring(6);a.push("token",c)}else if(r.startsWith("Bearer ")){let c=r.substring(7);a.push("bearer",c)}else a.push(r);t&&typeof t=="string"&&a.push("x-deepgram-session-id",t),a.length>0&&(e.protocols=a)}else e.headers=s;return e}function Qo(s,e){var o;let t=i=>{var a,c,u;if(typeof i.data=="string")try{let d=V(i.data);(a=e.message)===null||a===void 0||a.call(e,d)}catch{(c=e.message)===null||c===void 0||c.call(e,i.data)}else(u=e.message)===null||u===void 0||u.call(e,i.data)},r=s;return!((o=r._listeners)===null||o===void 0)&&o.message&&r._listeners.message.forEach(i=>{s.removeEventListener("message",i)}),s.addEventListener("message",t),t}function Xo(s,e){e.handleOpen&&s.removeEventListener("open",e.handleOpen),e.handleMessage&&s.removeEventListener("message",e.handleMessage),e.handleClose&&s.removeEventListener("close",e.handleClose),e.handleError&&s.removeEventListener("error",e.handleError)}function Zo(s){s.readyState===s.CLOSED&&(s._connectLock=!1,s._shouldReconnect=!0)}function qo(s){return Z(this,arguments,void 0,function*({options:e,urlPath:o,environmentKey:t,queryParams:r,headers:i,debug:a,reconnectAttempts:c,connectionTimeoutInSeconds:u,abortSignal:d}){var n,l,v,_,f,m;yield jn();let h=yield(n=e.authProvider)===null||n===void 0?void 0:n.getAuthRequest(),y=b((l=e.headers)!==null&&l!==void 0?l:{},(v=h?.headers)!==null&&v!==void 0?v:{},i),T=yield Dn(y),S=An(T),j=(_=yield g.get(e.baseUrl))!==null&&_!==void 0?_:((f=yield g.get(e.environment))!==null&&f!==void 0?f:R.Production)[t];return new B({url:p.join(j,o),protocols:(m=S.protocols)!==null&&m!==void 0?m:[],queryParameters:r,headers:S.headers,options:{WebSocket:S.WebSocket,debug:a??!1,maxRetries:c??30,startClosed:!0,connectionTimeout:u!=null?u*1e3:Pn},abortSignal:d})})}var At=class extends Re{connect(){return Z(this,arguments,void 0,function*(e={}){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/agent/converse",environmentKey:"agent",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new It({socket:c})})}createConnection(){return Z(this,arguments,void 0,function*(e={}){return this.connect(e)})}},It=class extends be{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}},Lt=class extends xe{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/listen",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Mt({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Mt=class extends Ee{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}},Bt=class extends Pe{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v2/listen",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Ht({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Ht=class extends ke{constructor(e){super(e),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}ping(e){let o=this.socket._ws;if(!o)throw new Error("WebSocket is not connected. Call connect() and waitForOpen() first.");if(o.readyState!==o.OPEN)throw new Error("WebSocket is not in OPEN state.");if(Q.type==="node"&&typeof o.ping=="function")o.ping(e);else throw new Error("WebSocket ping is not supported in browser environments. Browser WebSocket connections handle ping/pong automatically. If you need keepalive in the browser, consider sending periodic audio data or using a timer.")}},Ut=class extends Te{connect(e){return Z(this,void 0,void 0,function*(){let{headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a}=e,c=yield qo({options:this._options,urlPath:"/v1/speak",environmentKey:"production",queryParams:Yo(e),headers:o,debug:t,reconnectAttempts:r,connectionTimeoutInSeconds:i,abortSignal:a});return new Ft({socket:c})})}createConnection(e){return Z(this,void 0,void 0,function*(){return this.connect(e)})}},Ft=class extends je{constructor(e){super(e);let o=this;o.handleMessage&&this.socket.removeEventListener("message",o.handleMessage),this.setupBinaryHandling()}setupBinaryHandling(){this.binaryAwareHandler=Qo(this.socket,this.eventHandlers)}connect(){let e=this;return Xo(this.socket,{handleOpen:e.handleOpen,handleMessage:e.handleMessage,handleClose:e.handleClose,handleError:e.handleError}),Zo(this.socket),super.connect(),this.setupBinaryHandling(),this}};var yr=class{constructor(e){this.logPrefix=e}logPrefix;resolveRun=null;promise=null;timeoutId=null;intervalId=null;get inFlight(){return this.promise}get active(){return this.resolveRun!==null}begin(e){return at.info(`${this.logPrefix} Pause during an open turn \u2014 flushing for up to ${e.deadlineMs}ms`),this.promise=new Promise(o=>{this.resolveRun=o,e.onBegin?.(),e.onTick&&e.tickIntervalMs&&(this.intervalId=setInterval(e.onTick,e.tickIntervalMs)),this.timeoutId=setTimeout(()=>{at.warn(`${this.logPrefix} Flush deadline reached with no commit \u2014 pausing anyway`),this.settle(!0)},e.deadlineMs)}),this.promise}settle(e){if(!this.resolveRun)return;this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null);let o=this.resolveRun;this.resolveRun=null,this.promise=null,o(e)}};export{Ct as a,yr as b};
|