testaugnitoambientsdk2 2.1.72 → 2.1.73

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/README.md CHANGED
@@ -155,38 +155,32 @@ Now all you have to do is toggle the status when you want to start/stop or pause
155
155
 
156
156
  ```js
157
157
  /**
158
- * @param filetype Type of file being uploaded, wav, mp3, etc. Ex: "filetype=wav"
158
+ * @param filetype Type of file being uploaded, wav, mp3, etc. Ex: filetype=wav
159
159
  * @param noteparams Qualifiers to determine the type of clinical note to be generated for that audio file. Values for Region, NoteType and Gender can be obtained from getNoteParams(). Speciality and Visit Type can be set to the ConfigID returned by getUserConfiguration(). Region, Gender, Patient age in months and Template Id params are optional. Sample noteparams available in example below
160
160
  * @param jobName, optional, a title for the note generated
161
161
  * @param jobId, optional, to be set if reconnecting to paused job id to continue recording the note
162
162
  * @param recordedDuration, optional, set recorded duration of previous paused job id if reconnecting to it
163
- * @param parentJobId, optional, to be set when resuming a recording as a continuation of a previous job; the previous job's id is passed here
164
- * @param inheritParentConfig, optional, set to true to inherit the note configuration (noteparams) from the parent job when resuming
165
163
  */
166
164
 
167
165
  // Toggles the start/stop recording
168
- await augnitoAmbient.toggleListening(
166
+ augnitoAmbient.toggleListening(
169
167
  filetype:string,
170
168
  noteparams:string,
171
169
  jobName?: string,
172
170
  jobId?: string,
173
- recordedDuration?: number,
174
- parentJobId?: string,
175
- inheritParentConfig?: boolean
171
+ recordedDuration?: number
176
172
  );
177
- example: await augnitoAmbient.toggleListening("wav",`{"Region": 1, "Speciality": 11, "NoteType": 1, "VisitType":29, "Gender": 0, "PatientAge":231, "TemplateIdSoapNote":1}`)
173
+ example: augnitoAmbient.toggleListening("wav",`{"Region": 1, "Speciality": 11, "NoteType": 1, "VisitType":29, "Gender": 0, "PatientAge":231, "TemplateIdSoapNote":1}`)
178
174
 
179
175
  //Toggles the Pause/Resume recording
180
- await augnitoAmbient.togglePauseResumeListening(
176
+ augnitoAmbient.togglePauseResumeListening(
181
177
  filetype: string,
182
178
  noteparams: string,
183
179
  jobName?: string,
184
180
  jobId?: string,
185
- recordedDuration?: number,
186
- parentJobId?: string,
187
- inheritParentConfig?: boolean
181
+ recordedDuration?: number
188
182
  );
189
- example: await augnitoAmbient.togglePauseResumeListening("wav",`{"Region": 1, "Speciality": 11, "NoteType": 1, "VisitType":29, "Gender": 0}`)
183
+ example: augnitoAmbient.togglePauseResumeListening("wav",`{"Region": 1, "Speciality": 11, "NoteType": 1, "VisitType":29, "Gender": 0}`)
190
184
  ```
191
185
 
192
186
  ### Callbacks
@@ -320,18 +314,6 @@ function getStatusMessage(status: string): string {
320
314
 
321
315
  ---
322
316
 
323
- #### `onMicRecoveredAfterUnplugged`
324
-
325
- > Fired when a previously unplugged microphone or any other microphone is detected and ready to use. Use this to automatically resume recording or to notify the user that the microphone is available again after an `SDK08` error.
326
-
327
- ```ts
328
- augnitoAmbient.onMicRecoveredAfterUnplugged = () => {
329
- console.log("Microphone reconnected and ready.");
330
- };
331
- ```
332
-
333
- ---
334
-
335
317
  ### Socket Errors
336
318
 
337
319
  Below Errors with Error Codes and Error Messages will be returned on the onError callback for toggleListening/togglePauseResumeListening
@@ -363,12 +345,11 @@ Get all Jobs (SOAP notes and other clinical notes) created within the doctor (us
363
345
  /**
364
346
  * @param PageSize a number, to fetch specified number of notes as a page for each request
365
347
  * @param PageID is optional parameter, a string value, When PageID is not given, first set of notes is retrieved according to the specified PageSize. To fetch next set of notes send the PageIDNext received as part of response from the previous getAllNotes call
366
- * @param Collapse optional boolean, when set to true (default) child jobs created via resume are collapsed under their parent job in the listing; set to false to list all jobs individually
367
348
  * @returns list of notes for the user on success else fail response
368
349
  */
369
350
 
370
351
  try {
371
- const JobList = await augnitoAmbient.getAllNotes(PageSize: number, PageID?: string, Collapse?: boolean);
352
+ const JobList = await augnitoAmbient.getAllNotes(PageSize: number, PageID?: string);
372
353
  } catch (err) {
373
354
  if (err instanceof HttpCodedError) {
374
355
  console.log(err.code, err.message);
@@ -443,11 +424,10 @@ Allows you to build a capability for the user (doctor) to delete one or more not
443
424
  ```js
444
425
  /**
445
426
  * @param JobIds array of jobid string values, to delete one or more notes
446
- * @param DeleteParent optional boolean, when set to true deletes the parent job along with all its associated child (resumed) jobs
447
427
  * @returns success response on successful delete of notes else fail response
448
428
  */
449
429
  try {
450
- const result = await augnitoAmbient.deleteNotes(JobIds: string[], DeleteParent?: boolean)
430
+ const result = await augnitoAmbient.deleteNotes(JobIds: string[])
451
431
  } catch (err) {
452
432
  if (err instanceof HttpCodedError) {
453
433
  console.log(err.code, err.message);
@@ -795,4 +775,3 @@ General SDK errors returned in onError callback are as below
795
775
  | SDK12 | Internet is not available. Try again later. | Action can not be performed. No internet connectivity. Reach out to your IT team. | Received from SDK when internet is not available at the time of specific recording related actions are triggered |
796
776
  | SDK13 | Automatic Transcription is not enabled for the organisation | Transcript can not be generated. Please reach out to your IT team. | Received when fetchTranscriptionForNote is called and the feature is not enabled for the user |
797
777
  | SDK14 | Feedback is not enabled. Please contact administrator for more details. | Feedback can not be submitted. Please reach out to your IT team. | Received when sendFeedback is called and the feature is not enabled for the user |
798
- | SDK15 | Resume job is not enabled for the organisation | Resume recording is not available. Please reach out to your IT team. | Received when `parentJobId` is passed to `toggleListening` or `togglePauseResumeListening` but the resume recording feature is not enabled for the organisation |
@@ -52,7 +52,7 @@ export declare class AugnitoAmbient {
52
52
  * @param PageID is optional parameter, send start page id to fetch
53
53
  * @returns list of notes for the user
54
54
  */
55
- getAllNotes(PageSize: number, PageID?: string, Collapse?: boolean): Promise<any>;
55
+ getAllNotes(PageSize: number, PageID?: string): Promise<any>;
56
56
  /**
57
57
  * @param JobId to retrieve output for a specific audio file
58
58
  * @returns JSON object contains both Transcript and Note on sucess else fail resonse
@@ -69,14 +69,14 @@ export declare class AugnitoAmbient {
69
69
  * @param noteparams Qualifiers to determine the type of clinical note to be generated for that audio file.
70
70
  * @returns Callback triggers to reurn the Job id on meta message
71
71
  */
72
- toggleListening(_filetype: string, _noteparams: string, jobName?: string, jobId?: string, recordedDuration?: number, parentJobId?: string, inheritParentConfig?: boolean): Promise<void>;
72
+ toggleListening(_filetype: string, _noteparams: string, jobName?: string, jobId?: string, recordedDuration?: number): void;
73
73
  /**
74
74
  * Method called to pause or resume audio recording accordingly
75
75
  * @param filetype Type of file being uploaded, wav, mp3, etc. Ex: “filetype=wav“
76
76
  * @param noteparams Qualifiers to determine the type of clinical note to be generated for that audio file.
77
77
  * @returns Callback triggers to reurn the Job id on meta message
78
78
  */
79
- togglePauseResumeListening(_filetype: string, _noteparams: string, jobName?: string, jobId?: string, recordedDuration?: number, parentJobId?: string, inheritParentConfig?: boolean): Promise<void>;
79
+ togglePauseResumeListening(_filetype: string, _noteparams: string, jobName?: string, jobId?: string, recordedDuration?: number): void;
80
80
  /**
81
81
  * Method called to start audio recording
82
82
  */
@@ -89,7 +89,7 @@ export declare class AugnitoAmbient {
89
89
  * @param JobIds to delete one or more notes
90
90
  * @returns success response on successful delete of notes else fail response
91
91
  */
92
- deleteNotes(JobIds: string[], DeleteParent?: boolean): Promise<any>;
92
+ deleteNotes(JobIds: string[]): Promise<any>;
93
93
  /**
94
94
  * @param JobId to rename note title
95
95
  * @param NewJobName new title for the note
@@ -7,10 +7,10 @@ export declare class AmbientRestAPI extends BaseAPI {
7
7
  constructor(_config: AmbientConfig);
8
8
  private getURL;
9
9
  GetNoteParams(): Promise<any>;
10
- ListJobs(_pageSize: number, _pageId?: string, _collapse?: boolean): Promise<any>;
10
+ ListJobs(_pageSize: number, _pageId?: string): Promise<any>;
11
11
  FetchJob(_jobId: string): Promise<any>;
12
12
  SendFinalNote(_jobId: string, _noteDate: string): Promise<any>;
13
- DeleteNotes(_jobIds: string[], _deleteParent?: boolean): Promise<any>;
13
+ DeleteNotes(_jobIds: string[]): Promise<any>;
14
14
  RenameNoteTitle(_jobId: string, _newJobName: string): Promise<any>;
15
15
  DownloadNotePDF(_jobId: string, _noteType: NoteTypeConfig, _specialityId: number, _language?: string, _personnelInfo?: string, _regenerateNote?: boolean): Promise<any>;
16
16
  EndJob(_jobId: string): Promise<any>;
@@ -1 +1 @@
1
- function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"wssBaseURL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMetaEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.wssBaseURL=`wss://${e.server}/ambient/v1/stream-job`}prepareWSSURL(e,t,n,i,r,o){let s=this.wssBaseURL;return s+=`?filetype=${e}`,s+=`&noteparams=${t}`,s+=`&subscriptioncode=${this._config.subscriptionCode}`,s+=`&accesskey=${this._config.accessKey}`,s+=`&usertag=${this._config.userTag}`,n&&""!==n&&(s+=`&filename=${n}`),i&&""!==i&&(s+=`&jobid=${i}`),r&&""!==r&&(s+=`&parentjobid=${r}`),void 0!==o&&(s+=`&inheritparentconfig=${o}`),s}}class n{constructor(){}static get Against(){return n.instance||(n.instance=new n),n.instance}NullOrUndefined(e,t){if(null===e)throw new TypeError(`${t} is null`);if(void 0===e)throw new TypeError(`${t} is undefined`);return e}NullOrEmpty(e,t){if(!(e=n.Against.NullOrUndefined(e,t)))throw new TypeError(`${t} is empty`);return e}}var i,r,o,s,a;!function(e){e[e.SPECIALITY=1]="SPECIALITY",e[e.VISIT_TYPE=2]="VISIT_TYPE",e[e.NOTE_TYPE=3]="NOTE_TYPE",e[e.CLINICAL_CODE=4]="CLINICAL_CODE",e[e.LANGUAGE=5]="LANGUAGE",e[e.CDIVersion=7]="CDIVersion"}(i||(i={})),function(e){e[e.SoapNote=1]="SoapNote",e[e.PatientNote=2]="PatientNote",e[e.ReferralNote=3]="ReferralNote",e[e.ConsultationSummary=4]="ConsultationSummary",e[e.CDISuggestions=102]="CDISuggestions"}(r||(r={})),function(e){e.AUTH01="AUTH01",e.AUTH02="AUTH02",e.WSAUTH01="WSAUTH01",e.WSAUTH02="WSAUTH02",e.WSAUTH03="WSAUTH03",e.WSAUTH04="WSAUTH04",e.WSJOB01="WSJOB01",e.WSJOB02="WSJOB02",e.WSJOB03="WSJOB03",e.WSJOB04="WSJOB04",e.WSJOB05="WSJOB05",e.WSACC01="WSACC01",e.WSAUD01="WSAUD01",e.SDK01="SDK01",e.SDK02="SDK02",e.SDK03="SDK03",e.SDK04="SDK04",e.SDK05="SDK05",e.SDK06="SDK06",e.SDK07="SDK07",e.SDK08="SDK08",e.SDK12="SDK12",e.SDK13="SDK13",e.SDK14="SDK14",e.SDK15="SDK15",e.ERRUNKNOWN="ERRUNKNOWN"}(o||(o={}));class c extends Error{constructor(e,t){super(e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t,this.name="HttpCodedError",Object.setPrototypeOf(this,c.prototype)}}!function(e){e.Detailed="Detailed",e.Concise="Concise"}(s||(s={})),function(e){e.DashFormat="Dash-format",e.Paragraph="Paragraph"}(a||(a={}));class u{makePostRequest(t,n){return e(this,void 0,void 0,function*(){try{const i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const t=yield i.text();var e=JSON.parse(t);throw new c(e.message,e.code.toString())}return yield i.json()}catch(e){throw e}})}makePatchRequest(t,n){return e(this,void 0,void 0,function*(){try{const i=yield fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const t=yield i.text();var e=JSON.parse(t);throw new c(e.message,i.status.toString())}return yield i.json()}catch(e){throw e instanceof c?e:new c("500",e.message||"Unexpected error")}})}}class l extends u{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._baseUrl=`https://${e.server}/ambient/v1`}getURL(e){return`${this._baseUrl}${e}`}GetNoteParams(){return e(this,void 0,void 0,function*(){const e=this.getURL("/note-params"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}ListJobs(t,i,r){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Page Size");const e=this.getURL("/list-jobs"),o={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,PageSize:t,PageID:i,Collapse:r};return yield this.makePostRequest(e,o)})}FetchJob(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/fetch-job"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}SendFinalNote(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Note Data");const e=this.getURL("/send-final-note"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,SoapData:i};return yield this.makePostRequest(e,r)})}DeleteNotes(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/delete-job"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobIDs:t,DeleteParent:i};return yield this.makePostRequest(e,r)})}RenameNoteTitle(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Job Name");const e=this.getURL("/rename-job"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,JobName:i};return yield this.makePostRequest(e,r)})}DownloadNotePDF(t,i,r,o,s,a){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/download-pdf");var c=s;c&&""!=c||(c='{"PatientName":"","PatientID":"","Age":"","Gender":"","ReceivingDoctor":"","DoctorName":"","DoctorDesignation":"","DoctorEmail":""}');const u={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NoteType:i,Language:null!=o?o:"English",SpecialityID:r,Regenerate:null!=a&&a,PersonnelInfo:c};return yield this.makePostRequest(e,u)})}EndJob(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/end-job"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}UpdatePatientContext(t,i,r){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Patient Context");const e=this.getURL("/patient-context"),o={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NewContext:i,Replace:r};return yield this.makePostRequest(e,o)})}GenerateSuggestions(t,i,r,o,s,a){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");var e=this.getURL("/cdi");a&&2===a&&(e=this.getURL("/cdi").replace("/v1","/v2"));const c={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,Regenerate:i,SoapData:r,PatientContext:o,Codes:s};return yield this.makePostRequest(e,c)})}ModifyGeneratedNote(t,i,r){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/modify-note"),o={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NoteType:i,NewNote:null!=r?r:""};return yield this.makePostRequest(e,o)})}FetchTranscription(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/fetch-transcript"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}SendFeedback(t,i,r,o){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrUndefined(i,"Rating");const e=this.getURL("/feedback").replace("/v1","/v2"),s={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,Rating:i,FeedBack:null!=r?r:"",Type:null!=o?o:""};return yield this.makePostRequest(e,s)})}}class d{static log(e,t){const n=null!=t?t:this.defaultTag;console.log(`${n}:`,e)}static error(e,t){const n=null!=t?t:this.defaultTag;console.error(`${n}:`,e)}}function h(){h=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,i){var o=t&&t.prototype instanceof m?t:m,s=Object.create(o.prototype),a=new _(i||[]);return r(s,"_invoke",{value:w(e,n,a)}),s}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",g="suspendedYield",p="executing",v="completed",b={};function m(){}function y(){}function S(){}var C={};u(C,s,function(){return this});var k=Object.getPrototypeOf,E=k&&k(k(O([])));E&&E!==n&&i.call(E,s)&&(C=E);var I=S.prototype=m.prototype=Object.create(C);function A(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function R(e,t){function n(r,o,s,a){var c=d(e[r],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&i.call(l,"__await")?t.resolve(l.__await).then(function(e){n("next",e,s,a)},function(e){n("throw",e,s,a)}):t.resolve(l).then(function(e){u.value=e,s(u)},function(e){return n("throw",e,s,a)})}a(c.arg)}var o;r(this,"_invoke",{value:function(e,i){function r(){return new t(function(t,r){n(e,i,t,r)})}return o=o?o.then(r,r):r()}})}function w(t,n,i){var r=f;return function(o,s){if(r===p)throw Error("Generator is already running");if(r===v){if("throw"===o)throw s;return{value:e,done:!0}}for(i.method=o,i.arg=s;;){var a=i.delegate;if(a){var c=P(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=p;var u=d(t,n,i);if("normal"===u.type){if(r=i.done?v:g,u.arg===b)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(r=v,i.method="throw",i.arg=u.arg)}}}function P(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var o=d(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=S,r(I,"constructor",{value:S,configurable:!0}),r(S,"constructor",{value:y,configurable:!0}),y.displayName=u(S,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,u(e,c,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},A(R.prototype),u(R.prototype,a,function(){return this}),t.AsyncIterator=R,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var s=new R(l(e,n,i,r),o);return t.isGeneratorFunction(n)?s:s.next().then(function(e){return e.done?e.value:s.next()})},A(I),u(I,c,"Generator"),u(I,s,function(){return this}),u(I,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=O,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var c=i.call(s,"catchLoc"),u=i.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;T(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:O(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},t}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function g(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){g(o,i,r,s,a,"next",e)}function a(e){g(o,i,r,s,a,"throw",e)}s(void 0)})}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function m(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function S(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}Object.defineProperty(d,"defaultTag",{enumerable:!0,configurable:!0,writable:!0,value:"AugnitoAmbientSDK"});var C="DONE",k="PAUSESOCKET",E="RESUMESOCKET",I="INTENT_START_STREAM",A="CLOSE",R=m(function e(t,n,i,r,o,s,a,c,u,l,d,h,f){v(this,e),this.worker,this.onFinalResultCallback=o,this.onErrorCallback=a,this.onPartialResultCallback=s,this.onSessionEventCallback=c,this.onOtherResultsCallback=u,this.onSpeechResponseCallback=l,this.onJobStatusCallback=d,this.packetSeqId=0,this.audioDuration=0,this.shouldSendAudioDataSequence=r,this.heavyOp,this.idleLoop,this.lastSent,this.enableLogs=t,this.eosMessage=n||"EOS",this.socketTimeoutInterval=i||1e4,this.bufferSizeInterval=h,this.switchToRegularSpeech=f},[{key:"Start",value:function(e,t,n){var i=this;this.audioDuration=e;var r="\n (() => {\n (".concat(w.toString(),")(").concat(JSON.stringify(C),", ").concat(JSON.stringify(this.eosMessage),", ").concat(JSON.stringify(A),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(this.socketTimeoutInterval),", ").concat(JSON.stringify(12e4),", ").concat(JSON.stringify(1e3),", ").concat(JSON.stringify(100),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(t),", ").concat(JSON.stringify(this.enableLogs),", ").concat(JSON.stringify(this.shouldSendAudioDataSequence),",").concat(JSON.stringify(k),", ").concat(JSON.stringify(E),", ").concat(JSON.stringify(I),", ").concat(JSON.stringify(this.switchToRegularSpeech),", ").concat(JSON.stringify(n),", ").concat(JSON.stringify(this.heavyOp),");\n })();\n");this.worker=new Worker(URL.createObjectURL(new Blob([r],{type:"application/javascript"}))),this.worker.onmessage=function(e){i.enableLogs&&console.log("Augnito [MAIN]: "+JSON.stringify(e.data));var t=e.data;"final"==t.type?i.onFinalResultCallback(t.data):"partial"==t.type?i.onPartialResultCallback(t.data):"meta"==t.type?i.onSessionEventCallback(t.data):"error"==t.type?i.onErrorCallback(t.data):"other"==t.type?i.onOtherResultsCallback(t.data):"jobstatus"==t.type?i.onJobStatusCallback(t.data.status):"speechResponse"==t.type&&i.onSpeechResponseCallback(t.data)}}},{key:"createAudioPacketHeader",value:function(e){this.audioDuration>0&&(this.packetSeqId=Math.ceil(this.audioDuration/this.bufferSizeInterval)+2,this.audioDuration=0),this.packetSeqId++;for(var t=new ArrayBuffer(16),n=new DataView(t),i=0;i<4;i++)n.setUint8(i,"@BSR".charCodeAt(i));return n.setBigInt64(4,BigInt(this.packetSeqId),!1),n.setUint8(12,e?1:0),t}},{key:"appendAudioData",value:function(e,t){var n=e.byteLength+t.byteLength,i=new ArrayBuffer(n),r=new Uint8Array(i);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),i}},{key:"Send",value:function(e){var t;if(this.lastSent=+new Date,e===A)null===(t=this.worker)||void 0===t||t.postMessage(A);else if(e===C)if(this.shouldSendAudioDataSequence){var n,i=this.createAudioPacketHeader(!0);null===(n=this.worker)||void 0===n||n.postMessage(i)}else{var r;null===(r=this.worker)||void 0===r||r.postMessage(C)}else if(e==k){var o;null===(o=this.worker)||void 0===o||o.postMessage(k)}else if(e==E){var s;null===(s=this.worker)||void 0===s||s.postMessage(E)}else if(e==I){var a;null===(a=this.worker)||void 0===a||a.postMessage(I)}else if(e===this.eosMessage){var c;this.shouldSendAudioDataSequence||null===(c=this.worker)||void 0===c||c.postMessage(e)}else{var u,l=[];this.shouldSendAudioDataSequence?(i=this.createAudioPacketHeader(!1),l=this.appendAudioData(i,e)):l=e,void 0!==l&&(null===(u=this.worker)||void 0===u||u.postMessage(l,[l]))}}},{key:"HeavyOp",set:function(e){this.heavyOp=e}}]);function w(e,t,n,i,r,o,s,a,c,u,l,d,h,f,g,p,v,b){var m,y,S,C,k,E,I,A,R,w=[],P=[],D=!1,T=[],_=!1,O=!1,x=!1,N="",U=v;function L(){m=+new Date,(E=""!=N?new WebSocket(u+"&jobid="+N):new WebSocket(u)).onopen=function(e){l&&console.log("Augnito: WebSocket connection established - "+JSON.stringify(e)),T.length>0&&(O=!0)},E.onmessage=function(e){l&&console.log("Augnito: Message from server - "+JSON.stringify(e.data)),S=+new Date,function(e){try{if("PING"===e.data)C=+new Date,self.postMessage({type:"ping",data:e.data});else{var t=JSON.parse(e.data);if(l&&console.log("Augnito [WORKER]: "+JSON.stringify(t)),"meta"==t.Type){t.JobID&&(N=t.JobID,console.log("Augnito JobID:",N)),self.postMessage({type:"meta",data:e.data});var n=JSON.parse(e.data);x=!(!n.Event||"INVALID_AUTH_CREDENTIALS"!==n.Event.Type)}else if(t.Result&&t.Result.Final){var i=JSON.stringify(t.Result);b&&(i=b(JSON.stringify(t.Result)),console.log(i)),self.postMessage({type:"final",data:i})}else t.Result&&!t.Result.Final?self.postMessage({type:"partial",data:t.Result.Transcript}):"ACK"==t.Type?(T=T.filter(function(e){return e.packetNumber>t.Index}),"RECEIVED_EOS"===t.Data.toUpperCase()&&(_=!0,clearInterval(R)),self.postMessage({type:"other",data:e.data})):"ERROR"==t.Type?("Timeout exceeded"==t.Data&&(_=!0,K()),self.postMessage({type:"error",data:e.data})):"STATUS"==t.Type?self.postMessage({type:"jobstatus",data:{status:e.data}}):self.postMessage({type:"speechResponse",data:e.data})}}catch(e){self.postMessage({type:"error",data:"invalid response"})}}(e)},E.onerror=function(e){console.error("WebSocket error: ",e),self.postMessage({type:"error",data:JSON.stringify(e)})},E.onclose=function(e){l&&console.log("Augnito: WebSocket connection closed - "+JSON.stringify(e)),K()},y=+new Date,S=y,C=+new Date}function M(e){if(E&&E.readyState===WebSocket.OPEN){E.send(e);var n=+new Date;return y<=S&&(S=n-1),y=n,!0}return e===t?(l&&console.warn("Gulping ".concat(t," as socket seems already closed...")),K(),!0):(+new Date-m>i&&!x&&L(),!1)}function J(e){w.push(e)}function K(){_&&(console.log("Augnito: Cleaning up worker resources..."),clearInterval(I),clearInterval(A),clearInterval(R),w=[],T=[],self.close())}L(),I=setInterval(function(){if(O){for(var e=0;e<T.length;e++){if(!M(T[e].packetData))break}O=!1}else for(;w.length>0;){var t=w.shift();if(!M(t)){w.unshift(t);break}if(d){if(!(t instanceof ArrayBuffer))continue;var n=new DataView(t),i={packetNumber:Number(n.getBigInt64(4)),packetData:t};T.push(i)}}},a),A=setInterval(function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;(p?y>S&&e-S>r:e-C>r)&&(l&&console.error("No data received since more than ".concat(r/1e3," secs, closing time...")),E.close())}},s),R=setInterval(function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;y&&e-y>o&&(l&&console.warn("No data sent since more than ".concat(o/1e3," secs, closing time...")),E.close())}},c),self.onmessage=function(i){if(i.data===n)N="",_=!0,x=!0,E.close();else if(i.data===e)J(t),N="",l&&console.log("Augnito: Worker received DONE, time to terminate..."),_=!0;else if(i.data===h)U=!0;else if(i.data===g)D=!0;else if(i.data===f){if(k instanceof ArrayBuffer&&J(k),P.length>0)for(var r=0;r<P.length;r++)J(P[r]);P=[],D=!1,U=!1,k=[]}else U&&!D?k=i.data:U&&D?P.push(i.data):J(i.data)}}var P,D,T,_,O,x,N,U,L,M,J=m(function e(t,n,i,r,o,s,a,c,u,l,d,h,f,g,p,b,m,y,S,C,k,E,I,A,w,P){v(this,e),this.audioContext,this.audioStream,this.executor=new R(n,s,a,c,m,y,S,k,E,I,w,r,h),this.executor.HeavyOp=b,this.source,this.processorNode,this.isPaused=!1,this.isStreaming=!1,this.audioData=[],this.isDebug=i,this.enableLogs=n,this.onStateChanged=C,this.onIntensity=A,this.onError=S,this.bufferSizeInterval=r,this.pausedBufferInterval=null!=o?o:1,this.shouldReadIntensity=d,this.closeSocketWithoutEOS=!1,this.shouldPreIntialiseRecorder=null!=l&&l,this.echoCancellation=f,this.noiseSuppression=g,this.autoGainControl=p,this.micNeedsRecovery=!1,this.trackEndedHandler=null,this.isRecovering=!1,this._micReadyFired=!1,this._micReadyFiredOnFirstRecovery=!1,this._deviceChangeHandling=!1,this.currentWsUrl="",this.currentDuration=0,this.deviceChangeHandler=null,this.onMicReady=P,this._originalDeviceId=null,this._originalDeviceLabel=null,this.shouldPreIntialiseRecorder&&this.InitialiseMediaStream(u,t)},[{key:"InitialiseMediaStream",value:(M=p(h().mark(function e(t,n){var i=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentDuration=t,this.currentWsUrl=n,e.next=4,this.createMediaStreamSourceNode();case 4:if(this.source){e.next=7;break}return console.error("Error: unable to create source node"),e.abrupt("return",!1);case 7:return e.next=9,this.createProcessorNode();case 9:if(this.processorNode){e.next=12;break}return console.error("Error: unable to create processor node"),e.abrupt("return",!1);case 12:this.source.connect(this.processorNode).connect(this.audioContext.destination),this.log("AudioContext Sample Rate: "+this.audioContext.sampleRate),""!==n&&this.executor.Start(t,n,this.shouldPreIntialiseRecorder),this.deviceChangeHandler||(this.deviceChangeHandler=p(h().mark(function e(){var t,n,r,o,s,a,c;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i._deviceChangeHandling){e.next=2;break}return e.abrupt("return");case 2:if(i._deviceChangeHandling=!0,e.prev=3,(s=null===(t=i.audioStream)||void 0===t||null===(n=t.getAudioTracks)||void 0===n?void 0:n.call(t)[0])&&"ended"!==s.readyState){e.next=11;break}return i.micNeedsRecovery=!0,e.next=10,i.recoverAudioGraph();case 10:return e.abrupt("return");case 11:return a=null!==(r=null===(o=s.getSettings)||void 0===o||null===(o=o.call(s))||void 0===o?void 0:o.deviceId)&&void 0!==r?r:s.label,i.log('Device change detected. Probing current device: "'.concat(s.label,'"')),e.next=15,K(a);case 15:if(e.sent){e.next=27;break}return i.log('Current device "'.concat(s.label,'" appears silent/virtual. Searching for a real input device...')),i.micNeedsRecovery=!0,e.next=21,W(a,i.enableLogs);case 21:return(c=e.sent)?i._preferredDeviceId=c:(i.log("No active audio input device found after device change"),i._preferredDeviceId=null),e.next=25,i.recoverAudioGraph();case 25:e.next=28;break;case 27:i.log('Current device "'.concat(s.label,'" is producing audio — no switch needed'));case 28:return e.prev=28,i._deviceChangeHandling=!1,e.finish(28);case 31:case"end":return e.stop()}},e,null,[[3,,28,31]])})),navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler));case 16:case"end":return e.stop()}},e,this)})),function(e,t){return M.apply(this,arguments)})},{key:"StartStream",value:(L=p(h().mark(function e(t,n){var i,r;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log("New stream started..."),this.shouldPreIntialiseRecorder&&this.source){e.next=6;break}return e.next=4,this.InitialiseMediaStream(t,n,!1);case 4:e.next=7;break;case 6:this.shouldPreIntialiseRecorder&&this.executor.Send(E);case 7:if(!this.IsMicrophoneMuted){e.next=15;break}if(!this.audioContext||"running"!=this.audioContext.state){e.next=11;break}return e.next=11,this.audioContext.suspend();case 11:return null===(i=this.audioStream)||void 0===i||null===(r=i.getTracks)||void 0===r||null===(r=r.call(i))||void 0===r||r.forEach(function(e){try{e.stop()}catch(e){}}),this.executor.Send(A),this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return",!1);case 15:return this.onStateChanged(!0),this.isStreaming=!0,e.abrupt("return",!0);case 18:case"end":return e.stop()}},e,this)})),function(e,t){return L.apply(this,arguments)})},{key:"createBufferedSourceNode",value:(U=p(h().mark(function e(){var t;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadAudio();case 2:if(t=e.sent){e.next=6;break}return console.error("Error: unable to create audio buffer"),e.abrupt("return");case 6:this.source=this.audioContext.createBufferSource(),this.source.buffer=t,this.source.loop=!0,this.source.start();case 10:case"end":return e.stop()}},e,this)})),function(){return U.apply(this,arguments)})},{key:"createMediaStreamSourceNode",value:(N=p(h().mark(function e(){var t,n,i,r,o,s,a,c,u=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r={channelCount:1,noiseSuppression:void 0!==this.noiseSuppression&&this.noiseSuppression},void 0!==this.echoCancellation&&(r.echoCancellation=this.echoCancellation,r.googEchoCancellation=this.echoCancellation),void 0!==this.noiseSuppression&&(r.googNoiseSuppression=this.noiseSuppression),void 0!==this.autoGainControl&&(r.autoGainControl=this.autoGainControl,r.googAutoGainControl=this.autoGainControl),this._preferredDeviceId&&(r.deviceId={exact:this._preferredDeviceId}),e.next=8,navigator.mediaDevices.getUserMedia({audio:r});case 8:this.audioStream=e.sent,this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=new AudioContext),this.source=this.audioContext.createMediaStreamSource(this.audioStream),o=this.audioStream.getAudioTracks()[0],s=null!==(t=null===(n=o.getSettings)||void 0===n||null===(n=n.call(o))||void 0===n?void 0:n.deviceId)&&void 0!==t?t:"",a=null!==(i=o.label)&&void 0!==i?i:"",this._originalDeviceId||(this._originalDeviceId=s,this._originalDeviceLabel=a),this.trackEndedHandler&&(this.trackEndedHandler=null),this.trackEndedHandler=function(){u.micNeedsRecovery=!0,u.onError(JSON.stringify({Type:"ERROR",Data:"Audio track ended. Possibly the mic was unplugged."}))},o.addEventListener("ended",this.trackEndedHandler),e.next=25;break;case 20:e.prev=20,e.t0=e.catch(0),c="","NotAllowedError"==e.t0.name?c="Mic permission denied":"NotFoundError"===e.t0.name?c="No suitable media device found":"NotReadableError"===e.t0.name&&(c="Microphone is being used by another application"),this.onError(JSON.stringify({Type:"ERROR",Data:c}));case 25:case"end":return e.stop()}},e,this,[[0,20]])})),function(){return N.apply(this,arguments)})},{key:"loadAudio",value:(x=p(h().mark(function e(){var t,n,i;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("./radiology_speed_test.wav");case 3:return t=e.sent,e.next=6,t.arrayBuffer();case 6:return n=e.sent,e.next=9,this.audioContext.decodeAudioData(n);case 9:return i=e.sent,e.abrupt("return",i);case 13:return e.prev=13,e.t0=e.catch(0),console.error("Unable to fetch the audio file. Error: ".concat(e.t0.message)),e.abrupt("return",null);case 17:case"end":return e.stop()}},e,this,[[0,13]])})),function(){return x.apply(this,arguments)})},{key:"createProcessorNode",value:(O=p(h().mark(function e(){var t,n=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.audioContext.audioWorklet.addModule("data:application/javascript,".concat(encodeURIComponent('class MyAudioWorkletProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.accumulator = [];\n this.pauseSocketStreaming = false;\n this.sampleVal = 0;\n this.sampleSize = 0;\n this.intensityFrameCount = 0;\n this.reset();\n this.isProcessing = true;\n // message received from main-thread\n this.port.onmessage = (e) => {\n console.log("Augnito: Worklet received event - ", e.data);\n if (this.sampleSize > 0) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n }\n \n if (e.data == "PAUSE" || e.data == "STOP" || e.data == "PAUSESOCKET") {\n // append silence to get last word ASR.\n const silenceSize = 16000 * 2;\n for (let i = 0; i < silenceSize; i++) {\n this.accumulator.push(0.0003 * 0x7fff); // Push low-level noise instead of absolute silence to help ASR finalise\n }\n }\n this.send();\n this.reset();\n if (e.data == "STOP") {\n // message sent to main-thread\n this.port.postMessage({type:"DONE", value:"DONE"});\n this.isProcessing = false;\n \n }\n if(e.data == "PAUSESOCKET"){\n this.pauseSocketStreaming = true;\n this.port.postMessage("PAUSESOCKET");\n } else if(e.data == "RESUMESOCKET"){\n this.pauseSocketStreaming = false;\n } \n };\n }\n\n static get parameterDescriptors() {\n return [\n {\n name: "sampleRate",\n defaultValue: 16000,\n minValue: 16000,\n maxValue: 6 * 16000,\n },\n {\n name: "bufferSizeInterval",\n defaultValue: 1,\n minValue: 1,\n maxValue: 100,\n },\n {\n name: "pausedBufferInterval",\n defaultValue: 1,\n minValue: 0,\n maxValue: 100,\n },\n {\n name: "shouldReadIntensity",\n defaultValue: false,\n minValue: 0,\n maxValue: 1,\n },\n ];\n }\n\n // 128 frames\n process(inputList, outputList, params) {\n const input = inputList[0];\n if (input && input.length && input[0].length) {\n const channelData = input[0];\n const output = outputList[0];\n const inputSampleRate = params.sampleRate[0];\n const sampleRatio = inputSampleRate / 16000\n const bufferSizeInterval = params["bufferSizeInterval"][0];\n const pausedBufferInterval = params["pausedBufferInterval"][0];\n const shouldReadIntensity = params["shouldReadIntensity"][0];\n\n let sumSquares = 0; // For intensity\n let sampleCount = 0;\n\n // console.log("BufferSizeInterval", bufferSizeInterval);\n // Jackpot\n input[0].forEach((float32Element, index) => {\n const int16Element = Math.min(1, Math.max(-1, float32Element)) * 0x7fff;\n this.sampleVal += int16Element;\n this.sampleSize += 1;\n // Accumulate for intensity (RMS)\n sumSquares += float32Element * float32Element;\n sampleCount++;\n \n\n if (this.sampleSize >= sampleRatio) {\n const fraction = this.sampleSize - sampleRatio \n this.sampleVal -= fraction * int16Element;\n\n this.accumulator.push(this.sampleVal / sampleRatio);\n \n this.sampleVal = fraction * int16Element;\n this.sampleSize = fraction;\n }\n\n // Comment this when streaming microphone audio\n // output[0][index] = float32Element;\n });\n if(this.pauseSocketStreaming){\n if (this.accumulator.length >= 125 * 128 * pausedBufferInterval) {\n this.send();\n }\n } else{\n if (this.accumulator.length >= 125 * 128 * bufferSizeInterval) {\n this.send();\n }\n }\n if(shouldReadIntensity){\n \n // Throttled intensity post\n this.intensityFrameCount = (this.intensityFrameCount || 0) + 1;\n if (this.intensityFrameCount >= 15 && sampleCount > 0) {\n const rms = Math.sqrt(sumSquares / sampleCount);\n const normalized = Math.min(1, rms); // [0–1] scale\n this.port.postMessage({ type: \'intensity\', value: normalized });\n this.intensityFrameCount = 0;\n }\n }\n }\n return this.isProcessing;\n }\n\n send() {\n if (this.accumulator.length == 0) return;\n const audioData = new Int16Array(this.accumulator);\n // message sent to main-thread - transferrable\n this.port.postMessage({ type: \'audioData\', value: audioData.buffer }, [audioData.buffer]);\n this.accumulator = [];\n }\n\n reset() {\n this.sampleVal = 0;\n this.sampleSize = 0;\n }\n}\n\nregisterProcessor("worklet-processor", MyAudioWorkletProcessor);')));case 3:this.processorNode=new AudioWorkletNode(this.audioContext,"worklet-processor"),this.processorNode.parameters.get("sampleRate").setValueAtTime(this.audioContext.sampleRate,this.audioContext.currentTime),this.processorNode.parameters.get("bufferSizeInterval").setValueAtTime(this.bufferSizeInterval,this.audioContext.currentTime),this.processorNode.parameters.get("pausedBufferInterval").setValueAtTime(this.pausedBufferInterval,this.audioContext.currentTime),this.processorNode.parameters.get("shouldReadIntensity").setValueAtTime(null!==(t=this.shouldReadIntensity)&&void 0!==t&&t,this.audioContext.currentTime),this.processorNode.port.onmessage=function(e){var t=e.data,i=t.type,r=t.value;if(i==C)n.log("Worklet processing done, clearing resources..."),n.isDebug&&n.saveAudio(),n.cleanup();else if(e.data==k)n.executor.Send(k);else{var o;"intensity"===i?null===(o=n.onIntensity)||void 0===o||o.call(n,r):"audioData"===i&&n.isDebug&&new Int16Array(r).forEach(function(e){n.audioData.length<=288e5&&n.audioData.push(e)})}n.executor&&(n.closeSocketWithoutEOS?(n.executor.Send(A),n.closeSocketWithoutEOS=!1):"intensity"!==i&&n.executor.Send(r))},e.next=18;break;case 15:e.prev=15,e.t0=e.catch(0),console.error("Error: Unable to create worklet node: ",e.t0);case 18:case"end":return e.stop()}},e,this,[[0,15]])})),function(){return O.apply(this,arguments)})},{key:"PauseStream",value:(_=p(h().mark(function e(){return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!=this.audioContext.state){e.next=9;break}if(this.shouldPreIntialiseRecorder){e.next=8;break}return e.next=4,this.audioContext.suspend();case 4:this.log("Stream paused..."),this.processorNode.port.postMessage("PAUSE"),e.next=9;break;case 8:this.processorNode.port.postMessage(k);case 9:this.onStateChanged(!1),this.isPaused=!0,this.isStreaming=!1;case 12:case"end":return e.stop()}},e,this)})),function(){return _.apply(this,arguments)})},{key:"ResumeStream",value:(T=p(h().mark(function e(){var t,n,i;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((i=null===(t=this.audioStream)||void 0===t||null===(n=t.getAudioTracks)||void 0===n?void 0:n.call(t)[0])&&"ended"!==i.readyState&&!this.micNeedsRecovery){e.next=5;break}return e.next=5,this.recoverAudioGraph();case 5:if(!this.IsMicrophoneMuted){e.next=11;break}if(!this.audioContext||"running"!==this.audioContext.state){e.next=9;break}return e.next=9,this.audioContext.suspend();case 9:return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return");case 11:if(!this.shouldPreIntialiseRecorder){e.next=16;break}this.processorNode.port.postMessage(E),this.executor.Send(E),e.next=20;break;case 16:if("suspended"!==this.audioContext.state){e.next=19;break}return e.next=19,this.audioContext.resume();case 19:this.log("Stream resumed...");case 20:this.onStateChanged(!0),this.isPaused=!1,this.isStreaming=!0;case 23:case"end":return e.stop()}},e,this)})),function(){return T.apply(this,arguments)})},{key:"IsPaused",get:function(){return this.isPaused}},{key:"IsStreaming",get:function(){return this.isStreaming}},{key:"IsMicrophoneMuted",get:function(){var e,t,n=null===(e=this.audioStream)||void 0===e||null===(t=e.getAudioTracks)||void 0===t?void 0:t.call(e)[0];return!n||n.muted||"ended"===n.readyState}},{key:"StopStream",value:(D=p(h().mark(function e(t){var n,i,r,o,s,a,c,u;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("suspended"===(null===(n=this.audioContext)||void 0===n?void 0:n.state)){e.next=4;break}return e.next=3,null===(c=this.audioContext)||void 0===c?void 0:c.suspend();case 3:this.onStateChanged(!1);case 4:this.log("Stream stopped..."),this.isStreaming=!1,this.isPaused=!1,this.closeSocketWithoutEOS=!t,this.deviceChangeHandler&&(navigator.mediaDevices.removeEventListener("devicechange",this.deviceChangeHandler),this.deviceChangeHandler=null),(u=null===(i=this.audioStream)||void 0===i||null===(r=i.getAudioTracks)||void 0===r?void 0:r.call(i)[0])&&this.trackEndedHandler&&u.removeEventListener("ended",this.trackEndedHandler),this.trackEndedHandler=null,null===(o=this.audioStream)||void 0===o||null===(s=o.getTracks)||void 0===s||null===(s=s.call(o))||void 0===s||s.forEach(function(e){try{e.stop()}catch(e){}}),null===(a=this.processorNode)||void 0===a||null===(a=a.port)||void 0===a||a.postMessage("STOP");case 14:case"end":return e.stop()}},e,this)})),function(e){return D.apply(this,arguments)})},{key:"recoverAudioGraph",value:(P=p(h().mark(function e(){var t,n,i,r,o,s,a,c,u,l,d,f,g,p=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRecovering){e.next=2;break}return e.abrupt("return");case 2:this.isRecovering=!0,e.prev=3,null===(t=this.audioStream)||void 0===t||null===(t=t.getTracks())||void 0===t||t.forEach(function(e){try{e.stop()}catch(e){}});try{null===(s=this.source)||void 0===s||s.disconnect()}catch(e){}try{null===(a=this.processorNode)||void 0===a||a.disconnect()}catch(e){}return e.next=9,this.createMediaStreamSourceNode();case 9:if(this.source){e.next=11;break}throw new Error("Failed to recreate source");case 11:if(this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=new AudioContext),"suspended"!==this.audioContext.state){e.next=15;break}return e.next=15,this.audioContext.resume();case 15:return e.next=17,this.createProcessorNode();case 17:if(this.source.connect(this.processorNode).connect(this.audioContext.destination),this.isStreaming&&!this.isPaused){e.next=22;break}if("running"!==this.audioContext.state){e.next=22;break}return e.next=22,this.audioContext.suspend();case 22:return this.micNeedsRecovery=!1,c=null===(n=this.audioStream)||void 0===n||null===(i=n.getAudioTracks)||void 0===i?void 0:i.call(n)[0],u=null!==(r=null==c||null===(o=c.getSettings)||void 0===o||null===(o=o.call(c))||void 0===o?void 0:o.deviceId)&&void 0!==r?r:"",l=c&&"live"===c.readyState,e.next=28,navigator.mediaDevices.enumerateDevices();case 28:d=e.sent,f=d.some(function(e){return"audioinput"===e.kind&&e.label&&e.label===p._originalDeviceLabel}),g=u&&l,console.log("Original device present:",f),console.log("Active:",g),!this.isPaused||this.IsMicrophoneMuted&&!f||this.onMicReady&&!this._micReadyFiredOnFirstRecovery&&(this._micReadyFiredOnFirstRecovery=!0,this.onMicReady()),this.log("Audio graph recovery completed"),e.next=40;break;case 37:e.prev=37,e.t0=e.catch(3),console.error("Recovery failed",e.t0);case 40:return e.prev=40,this.isRecovering=!1,e.finish(40);case 43:case"end":return e.stop()}},e,this,[[3,37,40,43]])})),function(){return P.apply(this,arguments)})},{key:"IntentStartStream",value:function(){this.executor.Send("INTENT_START_STREAM")}},{key:"cleanup",value:function(){var e;null===(e=this.audioStream)||void 0===e||null===(e=e.getTracks())||void 0===e||e.forEach(function(e){try{e.stop()}catch(e){}}),this.source.disconnect(),this.processorNode.disconnect(),this.processorNode.port.close(),this.audioContext.close(),this.audioData=[]}},{key:"saveAudio",value:function(){var e=this.encodeWAV(),t=URL.createObjectURL(new Blob([e],{type:"audio/wav"}));this.log("Download Recording: ".concat(t))}},{key:"getBlob",value:function(){var e=this.encodeWAV();return new Blob([e],{type:"audio/wav"})}},{key:"encodeWAV",value:function(){var e=new DataView(new ArrayBuffer(2*this.audioData.length));this.audioData.forEach(function(t,n){e.setInt16(2*n,t,!0)});var t=e.buffer.byteLength,n=44+t,i=new DataView(new ArrayBuffer(n));i.setUint32(0,1380533830,!1),i.setUint32(4,n-8,!0),i.setUint32(8,1463899717,!1),i.setUint32(12,1718449184,!1),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,16e3,!0),i.setUint32(28,32e3,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),i.setUint32(36,1684108385,!1),i.setUint32(40,t,!0);for(var r=0;r<t;r++)i.setInt8(44+r,e.getInt8(r));return i}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);console.log(t+"\n")}}}]);function K(e){return j.apply(this,arguments)}function j(){return j=p(h().mark(function e(t){var n,i,r,o,s,a,c,u,l,d=arguments;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=d.length>1&&void 0!==d[1]?d[1]:350,i=d.length>2&&void 0!==d[2]?d[2]:.01,r=null,o=null,e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:t},channelCount:1}});case 7:return r=e.sent,o=new AudioContext,s=o.createMediaStreamSource(r),(a=o.createAnalyser()).fftSize=256,s.connect(a),c=a.frequencyBinCount,u=new Float32Array(c),e.next=17,new Promise(function(e){var t=0,r=performance.now();requestAnimationFrame(function o(){a.getFloatTimeDomainData(u);for(var s=0,l=0;l<c;l++)s+=u[l]*u[l];var d=Math.sqrt(s/c);d>t&&(t=d),performance.now()-r<n?requestAnimationFrame(o):e(t>i)})});case 17:return e.abrupt("return",e.sent);case 20:return e.prev=20,e.t0=e.catch(4),e.abrupt("return",!1);case 23:return e.prev=23,null===(l=r)||void 0===l||l.getTracks().forEach(function(e){return e.stop()}),o&&"closed"!==o.state&&o.close().catch(function(){}),e.finish(23);case 27:case"end":return e.stop()}},e,null,[[4,20,23,27]])})),j.apply(this,arguments)}function W(e){return F.apply(this,arguments)}function F(){return(F=p(h().mark(function e(t){var n,i,r,o,s;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,navigator.mediaDevices.enumerateDevices();case 4:n=e.sent,e.next=10;break;case 7:return e.prev=7,e.t0=e.catch(1),e.abrupt("return",null);case 10:i=n.filter(function(e){return"audioinput"===e.kind&&e.deviceId!==t}),r=S(i),e.prev=12,r.s();case 14:if((o=r.n()).done){e.next=23;break}return s=o.value,e.next=18,K(s.deviceId);case 18:if(!e.sent){e.next=21;break}return e.abrupt("return",s.deviceId);case 21:e.next=14;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(12),r.e(e.t1);case 28:return e.prev=28,r.f(),e.finish(28);case 31:return e.abrupt("return",null);case 32:case"end":return e.stop()}},e,null,[[1,7],[12,25,28,31]])}))).apply(this,arguments)}var G=function(){function e(){var t,n,i,r,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serverURL:"",enableLogs:!1,isDebug:!1,bufferInterval:1,pausedBufferInterval:1,EOS_Message:void 0,socketTimeoutInterval:void 0,shouldSendAudioDataSequence:!1,reconnectAudioDuration:0,shouldPreIntialiseRecorder:!1,shouldReadIntensity:!1,debounceDelay:300,switchToRegularSpeechProfile:!1,echoCancellation:void 0,noiseSuppression:void 0,autoGainControl:void 0},s=arguments.length>1?arguments[1]:void 0;if(v(this,e),e.instance)return e.instance;this.WebsocketURL=null!==(t=o.serverURL)&&void 0!==t?t:"",this.enableLogs=o.enableLogs,this.isDebug=o.isDebug,this.streamer=null,this.streamerNotStarted=!1,this.isStreamerStarting=!1,this.pendingStartStream=!1,this.heavyOp=s,this.bufferInterval=o.bufferInterval,this.pausedBufferInterval=o.pausedBufferInterval,this.eosMessage=o.EOS_Message,this.socketTimeoutInterval=o.socketTimeoutInterval,this.shouldSendAudioDataSequence=o.shouldSendAudioDataSequence,this.reconnectAudioDuration=null!==(n=o.reconnectAudioDuration)&&void 0!==n?n:0,this.shouldPreIntialiseRecorder=o.shouldPreIntialiseRecorder,this.switchToRegularSpeechProfile=null!==(i=o.switchToRegularSpeechProfile)&&void 0!==i&&i,this._echoCancellation=o.echoCancellation,this._noiseSuppression=o.noiseSuppression,this._autoGainControl=o.autoGainControl,this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0),this.shouldReadIntensity=o.shouldReadIntensity,this.delay=null!==(r=o.debounceDelay)&&void 0!==r?r:300,this.toggleStartStopAudioStream=B(this.toggleStartStopAudioStream.bind(this),this.delay),this.togglePauseResumeAudioStream=B(this.togglePauseResumeAudioStream.bind(this),this.delay),this.needsDispose=!1,e.instance=this}return m(e,[{key:"echoCancellation",get:function(){return this._echoCancellation},set:function(e){this._echoCancellation=e,this.streamer&&(this.streamer.echoCancellation=e)}},{key:"noiseSuppression",get:function(){return this._noiseSuppression},set:function(e){this._noiseSuppression=e,this.streamer&&(this.streamer.noiseSuppression=e)}},{key:"autoGainControl",get:function(){return this._autoGainControl},set:function(e){this._autoGainControl=e,this.streamer&&(this.streamer.autoGainControl=e)}},{key:"initialiseStreamer",value:function(){this.streamer=new J(this.WebsocketURL,this.enableLogs,this.isDebug,this.bufferInterval,this.pausedBufferInterval,this.eosMessage,this.socketTimeoutInterval,this.shouldSendAudioDataSequence,this.reconnectAudioDuration,this.shouldPreIntialiseRecorder,this.shouldReadIntensity,this.switchToRegularSpeechProfile,this._echoCancellation,this._noiseSuppression,this._autoGainControl,this.heavyOp,this.onFinalResultCallback.bind(this),this.onPartialResultCallback.bind(this),this.onErrorCallback.bind(this),this.onStateChangedCallback.bind(this),this.onSessionEventCallback.bind(this),this.onOtherResultCallback.bind(this),this.onSpeechResponseCallback.bind(this),this.onIntensityCallback.bind(this),this.onJobStatusCallback.bind(this),this.onMicReadyCallback.bind(this))}},{key:"updateIntentStartStream",value:function(){var e;this.pendingStartStream=!0,null===(e=this.streamer)||void 0===e||e.IntentStartStream()}},{key:"togglePauseResumeAudioStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;!this.streamer||this.streamerNotStarted?(t&&(this.WebsocketURL=t),this.startAudio(e)):this.streamer.IsPaused?this.resumeAudio():this.pauseAudio()}},{key:"toggleStartStopAudioStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;!this.streamer||this.streamerNotStarted?(t&&(this.WebsocketURL=t),this.startAudio(e)):this.stopAudio()}},{key:"startAudio",value:(t=p(h().mark(function e(t){return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isStreamerStarting){e.next=2;break}return e.abrupt("return");case 2:return this.isStreamerStarting=!0,this.shouldPreIntialiseRecorder&&this.streamer||this.initialiseStreamer(),e.prev=4,e.next=7,this.streamer.StartStream(t,this.WebsocketURL);case 7:e.sent?(this.streamerNotStarted=!1,this.log("Stream Started...")):this.streamer=null;case 9:return e.prev=9,this.isStreamerStarting=!1,e.finish(9);case 12:case"end":return e.stop()}},e,this,[[4,,9,12]])})),function(e){return t.apply(this,arguments)})},{key:"pauseAudio",value:function(){this.streamer.PauseStream(),this.log("Stream Paused...")}},{key:"resumeAudio",value:function(){this.streamer.ResumeStream(),this.enableLogs&&this.log("Stream Resumed...")}},{key:"stopAudio",value:function(){var e,t,n=this,i=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(null!==(e=this.streamer)&&void 0!==e&&e.IsStreaming||r)&&(null===(t=this.streamer)||void 0===t||t.StopStream(i),this.streamer=null,this.log("Stream Stopped..."),this.shouldPreIntialiseRecorder&&setTimeout(function(){n.needsDispose?n.needsDispose=!1:(n.initialiseStreamer(),n.streamerNotStarted=!0)},500))}},{key:"getBlob",value:function(){var e=this.streamer.getBlob();return this.log("Blob Sent..."),e}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);this.showLogCallback(t+"\n")}}},{key:"dispose",value:function(){var t;this.needsDispose=!0,null===(t=this.streamer)||void 0===t||t.StopStream(!1),this.streamer=null,e.instance=null}},{key:"onSessionEventCallback",value:function(e){this.onSessionEvent&&this.onSessionEvent(e)}},{key:"onStateChangedCallback",value:function(e){this.onStateChanged&&this.onStateChanged(e)}},{key:"onIntensityCallback",value:function(e){this.onIntensity&&this.onIntensity(e)}},{key:"onErrorCallback",value:function(e){this.onError&&this.onError(e)}},{key:"onPartialResultCallback",value:function(e){this.onPartialResult&&this.onPartialResult(e)}},{key:"onFinalResultCallback",value:function(e){this.onFinalResult&&this.onFinalResult(e)}},{key:"onOtherResultCallback",value:function(e){this.onOtherResults&&this.onOtherResults(e)}},{key:"onSpeechResponseCallback",value:function(e){this.onSpeechResponse&&this.onSpeechResponse(e)}},{key:"onJobStatusCallback",value:function(e){this.onJobStatus&&this.onJobStatus(e)}},{key:"onMicReadyCallback",value:function(){this.onMicReady&&this.onMicReady()}},{key:"showLogCallback",value:function(e){this.showLog&&this.showLog(e)}}]);var t}();function B(e,t){var n;return function(){for(var i=this,r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(function(){return e.apply(i,o)},t)}}class H extends u{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._baseUrl=`https://${e.server}/pace/v1/sdk`}getURL(e){return`${this._baseUrl}${e}`}getNoteParams(){return e(this,void 0,void 0,function*(){const e=this.getURL("/noteparams"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}getSettingsConfigMaster(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/configmaster"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}getOrgConfigMapping(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/configmapping").replace("/v1","/v2"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}getUserConfigSettings(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/userconfigmapping"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}updateUserConfig(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/userconfigmapping"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,UserConfigMapping:t};return yield this.makePatchRequest(e,n)})}getUserPreferences(){return e(this,void 0,void 0,function*(){const e=this.getURL("/getuserpreferences"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}updateUserPreference(t,n,i,r,o,s){return e(this,void 0,void 0,function*(){const e=this.getURL("/postuserpreferences"),a={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,UserPreferences:{AutomaticallyGenerateTranscript:t,PreferredTranscriptionLanguage:n,HighlightMedicalTerms:i,DisplayPatientContext:r,NoteOutputStyle:o,NoteOutputVerbosity:s}};return yield this.makePostRequest(e,a)})}}const V="Invalid user details, please check again",q="Subscription is not valid.",z="invalid request. Please make sure AccessKey, SubscriptionCode and UserTag is sent along with the request",$="Active seat is not available for user",Y="Unable to fetch account details, please try again.",Q="Unable to fetch job details, please try again.",X="Job not reconnectable",Z="Timeout exceeded",ee="Rate Limit Exceeded, Please try again in sometime!",te="Audio Signal is power very LOW, Mic might be muted",ne="Job Id is empty",ie="Page Size is undefined",re="Note Data is empty",oe="Job Name is empty",se="Patient Context is empty",ae="Mic permission denied",ce="Microphone is muted",ue="Audio track ended. Possibly the mic was unplugged",le="Internet is not available. Try again later.",de="Feedback is not enabled. Please contact administrator for more details.",he="Automatic Transcription is not enabled for the organisation",fe="Resume job is not enabled for the organisation";class ge{static isBrowserOnline(){return"undefined"!=typeof navigator&&!0===navigator.onLine}static isValidHttpUrl(e){if("string"!=typeof e||e.length>2048)return!1;try{const t=new URL(e);return("http:"===t.protocol||"https:"===t.protocol)&&(!t.username&&!t.password)}catch(e){return!1}}static hasInternetConnection(){return e(this,arguments,void 0,function*(e={url:null,timeoutMs:null}){var t=e.url||ge.DEFAULT_URL;const n=e.timeoutMs||ge.DEFAULT_TIMEOUT;if(!ge.isBrowserOnline())return!1;ge.isValidHttpUrl(t)||(t=ge.DEFAULT_URL);const i=new AbortController,r=setTimeout(()=>i.abort(),n);try{return yield fetch(t,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:i.signal}),!0}catch(e){return!1}finally{clearTimeout(r)}})}static isOnline(t){return e(this,void 0,void 0,function*(){return ge.hasInternetConnection(t)})}}Object.defineProperty(ge,"DEFAULT_URL",{enumerable:!0,configurable:!0,writable:!0,value:"https://www.google.com/favicon.ico"}),Object.defineProperty(ge,"DEFAULT_TIMEOUT",{enumerable:!0,configurable:!0,writable:!0,value:5e3});class pe{constructor(e){Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"Augnito-Ambient"}),Object.defineProperty(this,"_ambientRestAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ambientPaceAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableLog",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shouldReadAudioIntensity",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"recorderIns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"forceStopAudio",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isRecording",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"echoCancellation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"noiseSuppression",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoGainControl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onJobCreated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStateChanged",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onOtherResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onIntensityValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onIdleMic",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onSoapNoteGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onTranscriptGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onCodesGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onJobStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMicRecoveredAfterUnplugged",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ambientRestAPI=new l(this.validateConfig(e)),this._ambientPaceAPI=new H(e),this.config=this.createSocketConfig(e),this.enableLog=e.enableLogs,this.shouldReadAudioIntensity=e.shouldReadAudioIntensity,this.echoCancellation=e.echoCancellation,this.noiseSuppression=e.noiseSuppression,this.autoGainControl=e.autoGainControl}initRecorder(e){var t,n,i,r,o;this.recorderIns=new G({serverURL:e,enableLogs:null!==(t=this.enableLog)&&void 0!==t&&t,isDebug:null!==(n=this.enableLog)&&void 0!==n&&n,bufferInterval:15,EOS_Message:'{"JobAction": "EOS","Status": 0,"Type": "meta"}',socketTimeoutInterval:2e4,shouldSendAudioDataSequence:!0,shouldReadIntensity:this.shouldReadAudioIntensity,echoCancellation:this.echoCancellation,noiseSuppression:this.noiseSuppression,autoGainControl:this.autoGainControl}),this.recorderIns.echoCancellation=null!==(i=this.echoCancellation)&&void 0!==i&&i,this.recorderIns.noiseSuppression=null!==(r=this.noiseSuppression)&&void 0!==r&&r,this.recorderIns.autoGainControl=null!==(o=this.autoGainControl)&&void 0!==o&&o,this.recorderIns.onError=this.onErrorCallback.bind(this),this.recorderIns.onStateChanged=this.onStateChangeCallback.bind(this),this.recorderIns.onSessionEvent=this.onSessionEventCallback.bind(this),this.recorderIns.onOtherResults=this.onOtherResultsCallback.bind(this),this.recorderIns.onIntensity=this.onIntensityCallback.bind(this),this.recorderIns.onSpeechResponse=this.onSpeechResponseCallback.bind(this),this.recorderIns.onJobStatus=this.onJobStatusEventCallback.bind(this),this.recorderIns.onMicReady=this.onMicRecoveredAfterUnpluggedCallback.bind(this)}getNoteParams(){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getNoteParams();if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getAllNotes(t,n,i){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.ListJobs(t,n,null==i||i);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getSummarizedNote(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.FetchJob(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}sendSummarizedNote(t,n){return e(this,void 0,void 0,function*(){try{return this._ambientRestAPI?yield this._ambientRestAPI.SendFinalNote(t,n):void d.error("SDK not initialized",this._logTag)}catch(e){this.handleException(e)}})}toggleListening(t,n,r,o,s,a,c){return e(this,void 0,void 0,function*(){var e,u;if(void 0!==a&&""!==a.trim()){var l=yield this._ambientPaceAPI.getOrgConfigMapping(i.CDIVersion);if((null==l?void 0:l.Items)&&l.Items.length>0&&l.Items[0].Settings)if(!l.Items[0].Settings.find(e=>300===e.ID))return void this.onErrorCallback(fe)}var d=(null===(e=this.config)||void 0===e?void 0:e.prepareWSSURL(t,n,r,o,a,c))||"";this.recorderIns||this.initRecorder(d),null===(u=this.recorderIns)||void 0===u||u.toggleStartStopAudioStream(s,d)})}togglePauseResumeListening(t,n,r,o,s,a,c){return e(this,void 0,void 0,function*(){var e,u;if(void 0!==a&&""!==a.trim()){var l=yield this._ambientPaceAPI.getOrgConfigMapping(i.CDIVersion);if((null==l?void 0:l.Items)&&l.Items.length>0&&l.Items[0].Settings)if(!l.Items[0].Settings.find(e=>300===e.ID))return void this.onErrorCallback(fe)}var d=(null===(e=this.config)||void 0===e?void 0:e.prepareWSSURL(t,n,r,o,a,c))||"";this.recorderIns||this.initRecorder(d),null===(u=this.recorderIns)||void 0===u||u.togglePauseResumeAudioStream(s,d)})}startListening(){var e;null===(e=this.recorderIns)||void 0===e||e.startAudio()}stopListening(){var e;null===(e=this.recorderIns)||void 0===e||e.stopAudio(!0,!0)}deleteNotes(t,n){return e(this,void 0,void 0,function*(){var e;try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var i=yield this._ambientRestAPI.DeleteNotes(t,n);if(i){if(200===i.Status)return null===(e=this.recorderIns)||void 0===e||e.stopAudio(!1,!0),i;this.onErrorCallback(i.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}renameNoteTitle(t,n){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.RenameNoteTitle(t,n);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getNotePDF(t,n,i,r,o,s){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.DownloadNotePDF(t,n,i,r,o,s);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}endPausedJob(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.EndJob(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}generateCDISuggestions(t,n,r,o,s){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=1,a=yield this._ambientPaceAPI.getOrgConfigMapping(i.CDIVersion);if((null==a?void 0:a.Items)&&a.Items.length>0&&a.Items[0].Settings){var c=a.Items[0].Settings.find(e=>209===e.ID);c&&(e=Number.parseInt(c.ConfigValue))}var u=yield this._ambientRestAPI.GenerateSuggestions(t,n,r,s,o,e);if(u){if(200===u.Status)return u;this.onErrorCallback(u.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updatePatientContext(t,n,i){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.UpdatePatientContext(t,n,i);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}modifyGeneratedNote(t,n,i){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.ModifyGeneratedNote(t,n,i);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}fetchTranscriptionForNote(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);if((yield this._ambientPaceAPI.getUserPreferences()).Items[0].AutomaticTranscriptionEnabledForOrg){var e=yield this._ambientRestAPI.FetchTranscription(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}else this.onErrorCallback(he)}catch(e){this.handleException(e)}})}sendFeedback(t,n,i,r){return e(this,void 0,void 0,function*(){var e,o;try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var s=yield this._ambientPaceAPI.getUserPreferences();if((null===(e=s.Items[0])||void 0===e?void 0:e.FeedbackEnabledForOrg)&&(null===(o=s.Items[0])||void 0===o?void 0:o.FeedbackEnabled)){var a=yield this._ambientRestAPI.SendFeedback(t,n,null!=i?i:"",null!=r?r:"SOAPFeedBack");if(a){if(200===a.Status)return a;this.onErrorCallback(a.ServerMessage)}else this.onErrorCallback("Unknown Error!")}else this.onErrorCallback(de)}catch(e){this.handleException(e)}})}getUserConfiguration(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getUserConfigSettings(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updateUserConfiguration(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.updateUserConfig(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getUserPreferenceSettings(){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getUserPreferences();if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updateUserPreferenceSettings(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,c;try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var u=yield this._ambientPaceAPI.updateUserPreference(null!==(e=t.AutomaticallyGenerateTranscript)&&void 0!==e&&e,null!==(n=t.PreferredTranscriptionLanguage)&&void 0!==n?n:"English",null!==(i=t.HighlightMedicalTerms)&&void 0!==i&&i,null!==(r=t.DisplayPatientContext)&&void 0!==r&&r,null!==(o=t.NoteOutputStyle)&&void 0!==o?o:a.DashFormat,null!==(c=t.NoteOutputVerbosity)&&void 0!==c?c:s.Detailed);if(u){if(200===u.Status)return u;this.onErrorCallback(u.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}isInternetAvailable(t){return e(this,void 0,void 0,function*(){const e=yield ge.isOnline(t);return e||this.onErrorCallback(le),e})}onEventCallback(e){this.onJobCreated&&this.onJobCreated(e)}onStateChangeCallback(e){var t;if(this.forceStopAudio)return null===(t=this.recorderIns)||void 0===t||t.stopAudio(!1,!0),void(this.forceStopAudio=!1);this._isRecording=e,this.onStateChanged&&this.onStateChanged(e)}handleException(e){if(e instanceof TypeError)this.onErrorCallback(e.message);else{if(e instanceof c)throw e;d.error(e.message,this._logTag)}}onErrorCallback(e,t){var n,i,r,s,a,c,u,l,h,f,g,p,v,b,m,y,S={ErrorCode:null!=t?t:o.ERRUNKNOWN,ErrorMessage:e};try{var C=JSON.parse(e);S.ErrorMessage=C.Data,C.Data===Z?(this.stopListening(),d.error("Recording time limit exceeded",this._logTag),S.ErrorCode=o.WSJOB05):C.Data===V?(this._isRecording?null===(n=this.recorderIns)||void 0===n||n.stopAudio(!1,!0):this.forceStopAudio=!0,S.ErrorCode=o.WSAUTH03):C.Data.includes(Y)?S.ErrorCode=o.WSAUTH04:C.Data.includes(Q)?S.ErrorCode=o.WSJOB01:C.Data.includes(X)?S.ErrorCode=o.WSJOB02:C.Data.includes(ee)?S.ErrorCode=o.WSACC01:C.Data.includes(te)&&(S.ErrorCode=o.WSAUD01)}catch(e){}(null===(i=S.ErrorMessage)||void 0===i?void 0:i.includes(ne))?S.ErrorCode=o.SDK01:(null===(r=S.ErrorMessage)||void 0===r?void 0:r.includes(ie))?S.ErrorCode=o.SDK02:(null===(s=S.ErrorMessage)||void 0===s?void 0:s.includes(re))?S.ErrorCode=o.SDK03:(null===(a=S.ErrorMessage)||void 0===a?void 0:a.includes(oe))?S.ErrorCode=o.SDK04:(null===(c=S.ErrorMessage)||void 0===c?void 0:c.includes(se))?S.ErrorCode=o.SDK05:(null===(u=S.ErrorMessage)||void 0===u?void 0:u.includes(ae))?S.ErrorCode=o.SDK06:(null===(l=S.ErrorMessage)||void 0===l?void 0:l.includes(ce))?S.ErrorCode=o.SDK07:(null===(h=S.ErrorMessage)||void 0===h?void 0:h.includes(ue))?S.ErrorCode=o.SDK08:(null===(f=S.ErrorMessage)||void 0===f?void 0:f.includes(q))||(null===(g=S.ErrorMessage)||void 0===g?void 0:g.includes(z))?S.ErrorCode=o.AUTH01:(null===(p=S.ErrorMessage)||void 0===p?void 0:p.includes($))?S.ErrorCode=o.AUTH02:(null===(v=S.ErrorMessage)||void 0===v?void 0:v.includes(le))?S.ErrorCode=o.SDK12:(null===(b=S.ErrorMessage)||void 0===b?void 0:b.includes(he))?S.ErrorCode=o.SDK13:(null===(m=S.ErrorMessage)||void 0===m?void 0:m.includes(de))?S.ErrorCode=o.SDK14:(null===(y=S.ErrorMessage)||void 0===y?void 0:y.includes(fe))&&(S.ErrorCode=o.SDK15),this.onError&&this.onError(S)}onOtherResultsCallback(e){this.onOtherResult&&this.onOtherResult(e)}onIntensityCallback(e){this.onIntensityValue&&this.onIntensityValue(e)}onIdleMicCallback(){this.onIdleMic&&this.onIdleMic()}onSpeechResponseCallback(e){var t=JSON.parse(e);"note"===t.Type.toLowerCase()&&this.onSoapNoteGenerated?this.onSoapNoteGenerated(t.Data):"transcript"===t.Type.toLowerCase()&&this.onTranscriptGenerated?this.onTranscriptGenerated(t.Data):"codes"===t.Type.toLowerCase()&&this.onCodesGenerated&&this.onCodesGenerated(t.Data)}onJobStatusEventCallback(e){this.onJobStatus&&this.onJobStatus(e)}onMicRecoveredAfterUnpluggedCallback(){this.onMicRecoveredAfterUnplugged&&this.onMicRecoveredAfterUnplugged()}onSessionEventCallback(e){var t;if(!e)return;let n;try{n="string"==typeof e?JSON.parse(e):e}catch(e){return void d.error(`Error parsing session event data: ${e}`,this._logTag)}if(!n||!("Type"in n))return;if("meta"===n.Type.toLowerCase()&&(null===(t=this.config)||void 0===t?void 0:t.onMetaEvent)){if(!n.JobID)return void d.error("JobID is missing in meta event",this._logTag);this.config.onMetaEvent(n.JobID)}else"error"===n.Type.toLowerCase()&&n.Data&&this.onErrorCallback(n.Data);if("object"!=typeof n.Event||null===n.Event)return;const{Type:i,Value:r}=n.Event;i&&("SESSION_CREATED"===i&&r?d.log(`session Token ${r}`,this._logTag):"SERVICE_DOWN"===i?d.error(i,this._logTag):"NO_DICTATION_STOP_MIC"===i?(d.log("NO_DICTATION_STOP_MIC",this._logTag),this.onIdleMicCallback()):"INVALID_AUTH_CREDENTIALS"===i?d.error("INVALID_AUTH_CREDENTIALS",this._logTag):"LOW_BANDWIDTH"===i&&d.log("LOW_BANDWIDTH: Check internet connection",this._logTag))}validateConfig(e){return n.Against.NullOrEmpty(e.server,"Server"),n.Against.NullOrEmpty(e.subscriptionCode,"SubscriptionCode"),n.Against.NullOrEmpty(e.accessKey,"AccessKey"),n.Against.NullOrEmpty(e.userTag,"UserTag"),e}createSocketConfig(e){const n=new t(e);return n.onError=this.onErrorCallback.bind(this),n.onMetaEvent=this.onEventCallback.bind(this),n}}export{pe as AugnitoAmbient,o as ErrorCodes,c as HttpCodedError,a as NoteOutputStyleConfig,r as NoteTypeConfig,s as NoteVerbosityConfig,i as SettingsConfigType};
1
+ function e(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}c((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class t{constructor(e){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"wssBaseURL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMetaEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.wssBaseURL=`wss://${e.server}/ambient/v1/stream-job`}prepareWSSURL(e,t,n,i){let r=this.wssBaseURL;return r+=`?filetype=${e}`,r+=`&noteparams=${t}`,r+=`&subscriptioncode=${this._config.subscriptionCode}`,r+=`&accesskey=${this._config.accessKey}`,r+=`&usertag=${this._config.userTag}`,n&&""!==n&&(r+=`&filename=${n}`),i&&""!==i&&(r+=`&jobid=${i}`),r}}class n{constructor(){}static get Against(){return n.instance||(n.instance=new n),n.instance}NullOrUndefined(e,t){if(null===e)throw new TypeError(`${t} is null`);if(void 0===e)throw new TypeError(`${t} is undefined`);return e}NullOrEmpty(e,t){if(!(e=n.Against.NullOrUndefined(e,t)))throw new TypeError(`${t} is empty`);return e}}var i,r,o,s,a;!function(e){e[e.SPECIALITY=1]="SPECIALITY",e[e.VISIT_TYPE=2]="VISIT_TYPE",e[e.NOTE_TYPE=3]="NOTE_TYPE",e[e.CLINICAL_CODE=4]="CLINICAL_CODE",e[e.LANGUAGE=5]="LANGUAGE",e[e.CDIVersion=7]="CDIVersion"}(i||(i={})),function(e){e[e.SoapNote=1]="SoapNote",e[e.PatientNote=2]="PatientNote",e[e.ReferralNote=3]="ReferralNote",e[e.ConsultationSummary=4]="ConsultationSummary",e[e.CDISuggestions=102]="CDISuggestions"}(r||(r={})),function(e){e.AUTH01="AUTH01",e.AUTH02="AUTH02",e.WSAUTH01="WSAUTH01",e.WSAUTH02="WSAUTH02",e.WSAUTH03="WSAUTH03",e.WSAUTH04="WSAUTH04",e.WSJOB01="WSJOB01",e.WSJOB02="WSJOB02",e.WSJOB03="WSJOB03",e.WSJOB04="WSJOB04",e.WSJOB05="WSJOB05",e.WSACC01="WSACC01",e.WSAUD01="WSAUD01",e.SDK01="SDK01",e.SDK02="SDK02",e.SDK03="SDK03",e.SDK04="SDK04",e.SDK05="SDK05",e.SDK06="SDK06",e.SDK07="SDK07",e.SDK08="SDK08",e.SDK12="SDK12",e.SDK13="SDK13",e.SDK14="SDK14",e.ERRUNKNOWN="ERRUNKNOWN"}(o||(o={}));class c extends Error{constructor(e,t){super(e),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t,this.name="HttpCodedError",Object.setPrototypeOf(this,c.prototype)}}!function(e){e.Detailed="Detailed",e.Concise="Concise"}(s||(s={})),function(e){e.DashFormat="Dash-format",e.Paragraph="Paragraph"}(a||(a={}));class u{makePostRequest(t,n){return e(this,void 0,void 0,function*(){try{const i=yield fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const t=yield i.text();var e=JSON.parse(t);throw new c(e.message,e.code.toString())}return yield i.json()}catch(e){throw e}})}makePatchRequest(t,n){return e(this,void 0,void 0,function*(){try{const i=yield fetch(t,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const t=yield i.text();var e=JSON.parse(t);throw new c(e.message,i.status.toString())}return yield i.json()}catch(e){throw e instanceof c?e:new c("500",e.message||"Unexpected error")}})}}class l extends u{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._baseUrl=`https://${e.server}/ambient/v1`}getURL(e){return`${this._baseUrl}${e}`}GetNoteParams(){return e(this,void 0,void 0,function*(){const e=this.getURL("/note-params"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}ListJobs(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Page Size");const e=this.getURL("/list-jobs"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,PageSize:t,PageID:i};return yield this.makePostRequest(e,r)})}FetchJob(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/fetch-job"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}SendFinalNote(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Note Data");const e=this.getURL("/send-final-note"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,SoapData:i};return yield this.makePostRequest(e,r)})}DeleteNotes(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/delete-job"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobIDs:t};return yield this.makePostRequest(e,i)})}RenameNoteTitle(t,i){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Job Name");const e=this.getURL("/rename-job"),r={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,JobName:i};return yield this.makePostRequest(e,r)})}DownloadNotePDF(t,i,r,o,s,a){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/download-pdf");var c=s;c&&""!=c||(c='{"PatientName":"","PatientID":"","Age":"","Gender":"","ReceivingDoctor":"","DoctorName":"","DoctorDesignation":"","DoctorEmail":""}');const u={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NoteType:i,Language:null!=o?o:"English",SpecialityID:r,Regenerate:null!=a&&a,PersonnelInfo:c};return yield this.makePostRequest(e,u)})}EndJob(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/end-job"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}UpdatePatientContext(t,i,r){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrEmpty(i,"Patient Context");const e=this.getURL("/patient-context"),o={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NewContext:i,Replace:r};return yield this.makePostRequest(e,o)})}GenerateSuggestions(t,i,r,o,s,a){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");var e=this.getURL("/cdi");a&&2===a&&(e=this.getURL("/cdi").replace("/v1","/v2"));const c={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,Regenerate:i,SoapData:r,PatientContext:o,Codes:s};return yield this.makePostRequest(e,c)})}ModifyGeneratedNote(t,i,r){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/modify-note"),o={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,NoteType:i,NewNote:null!=r?r:""};return yield this.makePostRequest(e,o)})}FetchTranscription(t){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id");const e=this.getURL("/fetch-transcript"),i={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t};return yield this.makePostRequest(e,i)})}SendFeedback(t,i,r,o){return e(this,void 0,void 0,function*(){n.Against.NullOrEmpty(t,"Job Id"),n.Against.NullOrUndefined(i,"Rating");const e=this.getURL("/feedback").replace("/v1","/v2"),s={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,JobID:t,Rating:i,FeedBack:null!=r?r:"",Type:null!=o?o:""};return yield this.makePostRequest(e,s)})}}class d{static log(e,t){const n=null!=t?t:this.defaultTag;console.log(`${n}:`,e)}static error(e,t){const n=null!=t?t:this.defaultTag;console.error(`${n}:`,e)}}function h(){h=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,i){var o=t&&t.prototype instanceof m?t:m,s=Object.create(o.prototype),a=new _(i||[]);return r(s,"_invoke",{value:w(e,n,a)}),s}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",g="executing",v="completed",b={};function m(){}function y(){}function S(){}var C={};u(C,s,function(){return this});var k=Object.getPrototypeOf,E=k&&k(k(O([])));E&&E!==n&&i.call(E,s)&&(C=E);var A=S.prototype=m.prototype=Object.create(C);function I(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function R(e,t){function n(r,o,s,a){var c=d(e[r],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&i.call(l,"__await")?t.resolve(l.__await).then(function(e){n("next",e,s,a)},function(e){n("throw",e,s,a)}):t.resolve(l).then(function(e){u.value=e,s(u)},function(e){return n("throw",e,s,a)})}a(c.arg)}var o;r(this,"_invoke",{value:function(e,i){function r(){return new t(function(t,r){n(e,i,t,r)})}return o=o?o.then(r,r):r()}})}function w(t,n,i){var r=f;return function(o,s){if(r===g)throw Error("Generator is already running");if(r===v){if("throw"===o)throw s;return{value:e,done:!0}}for(i.method=o,i.arg=s;;){var a=i.delegate;if(a){var c=P(a,i);if(c){if(c===b)continue;return c}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(r===f)throw r=v,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r=g;var u=d(t,n,i);if("normal"===u.type){if(r=i.done?v:p,u.arg===b)continue;return{value:u.arg,done:i.done}}"throw"===u.type&&(r=v,i.method="throw",i.arg=u.arg)}}}function P(t,n){var i=n.method,r=t.iterator[i];if(r===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,P(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),b;var o=d(r,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,b;var s=o.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,b):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[s];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function n(){for(;++r<t.length;)if(i.call(t,r))return n.value=t[r],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=S,r(A,"constructor",{value:S,configurable:!0}),r(S,"constructor",{value:y,configurable:!0}),y.displayName=u(S,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,S):(e.__proto__=S,u(e,c,"GeneratorFunction")),e.prototype=Object.create(A),e},t.awrap=function(e){return{__await:e}},I(R.prototype),u(R.prototype,a,function(){return this}),t.AsyncIterator=R,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var s=new R(l(e,n,i,r),o);return t.isGeneratorFunction(n)?s:s.next().then(function(e){return e.done?e.value:s.next()})},I(A),u(A,c,"Generator"),u(A,s,function(){return this}),u(A,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),n=[];for(var i in t)n.push(i);return n.reverse(),function e(){for(;n.length;){var i=n.pop();if(i in t)return e.value=i,e.done=!1,e}return e.done=!0,e}},t.values=O,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var n in this)"t"===n.charAt(0)&&i.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function r(i,r){return a.type="throw",a.arg=t,n.next=i,r&&(n.method="next",n.arg=e),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var c=i.call(s,"catchLoc"),u=i.call(s,"finallyLoc");if(c&&u){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(c){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var o=r;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;D(n)}return r}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:O(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),b}},t}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function p(e,t,n,i,r,o,s){try{var a=e[o](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(i,r)}function g(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function s(e){p(o,i,r,s,a,"next",e)}function a(e){p(o,i,r,s,a,"throw",e)}s(void 0)})}}function v(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,f(i.key),i)}}function m(e,t,n){return t&&b(e.prototype,t),n&&b(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function S(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,o=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}Object.defineProperty(d,"defaultTag",{enumerable:!0,configurable:!0,writable:!0,value:"AugnitoAmbientSDK"});var C="DONE",k="PAUSESOCKET",E="RESUMESOCKET",A="INTENT_START_STREAM",I="CLOSE",R=m(function e(t,n,i,r,o,s,a,c,u,l,d,h,f){v(this,e),this.worker,this.onFinalResultCallback=o,this.onErrorCallback=a,this.onPartialResultCallback=s,this.onSessionEventCallback=c,this.onOtherResultsCallback=u,this.onSpeechResponseCallback=l,this.onJobStatusCallback=d,this.packetSeqId=0,this.audioDuration=0,this.shouldSendAudioDataSequence=r,this.heavyOp,this.idleLoop,this.lastSent,this.enableLogs=t,this.eosMessage=n||"EOS",this.socketTimeoutInterval=i||1e4,this.bufferSizeInterval=h,this.switchToRegularSpeech=f},[{key:"Start",value:function(e,t,n){var i=this;this.audioDuration=e;var r="\n (() => {\n (".concat(w.toString(),")(").concat(JSON.stringify(C),", ").concat(JSON.stringify(this.eosMessage),", ").concat(JSON.stringify(I),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(this.socketTimeoutInterval),", ").concat(JSON.stringify(12e4),", ").concat(JSON.stringify(1e3),", ").concat(JSON.stringify(100),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(t),", ").concat(JSON.stringify(this.enableLogs),", ").concat(JSON.stringify(this.shouldSendAudioDataSequence),",").concat(JSON.stringify(k),", ").concat(JSON.stringify(E),", ").concat(JSON.stringify(A),", ").concat(JSON.stringify(this.switchToRegularSpeech),", ").concat(JSON.stringify(n),", ").concat(JSON.stringify(this.heavyOp),");\n })();\n");this.worker=new Worker(URL.createObjectURL(new Blob([r],{type:"application/javascript"}))),this.worker.onmessage=function(e){i.enableLogs&&console.log("Augnito [MAIN]: "+JSON.stringify(e.data));var t=e.data;"final"==t.type?i.onFinalResultCallback(t.data):"partial"==t.type?i.onPartialResultCallback(t.data):"meta"==t.type?i.onSessionEventCallback(t.data):"error"==t.type?i.onErrorCallback(t.data):"other"==t.type?i.onOtherResultsCallback(t.data):"jobstatus"==t.type?i.onJobStatusCallback(t.data.status):"speechResponse"==t.type&&i.onSpeechResponseCallback(t.data)}}},{key:"createAudioPacketHeader",value:function(e){this.audioDuration>0&&(this.packetSeqId=Math.ceil(this.audioDuration/this.bufferSizeInterval)+2,this.audioDuration=0),this.packetSeqId++;for(var t=new ArrayBuffer(16),n=new DataView(t),i=0;i<4;i++)n.setUint8(i,"@BSR".charCodeAt(i));return n.setBigInt64(4,BigInt(this.packetSeqId),!1),n.setUint8(12,e?1:0),t}},{key:"appendAudioData",value:function(e,t){var n=e.byteLength+t.byteLength,i=new ArrayBuffer(n),r=new Uint8Array(i);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),i}},{key:"Send",value:function(e){var t;if(this.lastSent=+new Date,e===I)null===(t=this.worker)||void 0===t||t.postMessage(I);else if(e===C)if(this.shouldSendAudioDataSequence){var n,i=this.createAudioPacketHeader(!0);null===(n=this.worker)||void 0===n||n.postMessage(i)}else{var r;null===(r=this.worker)||void 0===r||r.postMessage(C)}else if(e==k){var o;null===(o=this.worker)||void 0===o||o.postMessage(k)}else if(e==E){var s;null===(s=this.worker)||void 0===s||s.postMessage(E)}else if(e==A){var a;null===(a=this.worker)||void 0===a||a.postMessage(A)}else if(e===this.eosMessage){var c;this.shouldSendAudioDataSequence||null===(c=this.worker)||void 0===c||c.postMessage(e)}else{var u,l=[];this.shouldSendAudioDataSequence?(i=this.createAudioPacketHeader(!1),l=this.appendAudioData(i,e)):l=e,void 0!==l&&(null===(u=this.worker)||void 0===u||u.postMessage(l,[l]))}}},{key:"HeavyOp",set:function(e){this.heavyOp=e}}]);function w(e,t,n,i,r,o,s,a,c,u,l,d,h,f,p,g,v,b){var m,y,S,C,k,E,A,I,R,w=[],P=[],T=!1,D=[],_=!1,O=!1,x=!1,N="",U=v;function L(){m=+new Date,(E=""!=N?new WebSocket(u+"&jobid="+N):new WebSocket(u)).onopen=function(e){l&&console.log("Augnito: WebSocket connection established - "+JSON.stringify(e)),D.length>0&&(O=!0)},E.onmessage=function(e){l&&console.log("Augnito: Message from server - "+JSON.stringify(e.data)),S=+new Date,function(e){try{if("PING"===e.data)C=+new Date,self.postMessage({type:"ping",data:e.data});else{var t=JSON.parse(e.data);if(l&&console.log("Augnito [WORKER]: "+JSON.stringify(t)),"meta"==t.Type){t.JobID&&(N=t.JobID,console.log("Augnito JobID:",N)),self.postMessage({type:"meta",data:e.data});var n=JSON.parse(e.data);x=!(!n.Event||"INVALID_AUTH_CREDENTIALS"!==n.Event.Type)}else if(t.Result&&t.Result.Final){var i=JSON.stringify(t.Result);b&&(i=b(JSON.stringify(t.Result)),console.log(i)),self.postMessage({type:"final",data:i})}else t.Result&&!t.Result.Final?self.postMessage({type:"partial",data:t.Result.Transcript}):"ACK"==t.Type?(D=D.filter(function(e){return e.packetNumber>t.Index}),"RECEIVED_EOS"===t.Data.toUpperCase()&&(_=!0,clearInterval(R)),self.postMessage({type:"other",data:e.data})):"ERROR"==t.Type?("Timeout exceeded"==t.Data&&(_=!0,K()),self.postMessage({type:"error",data:e.data})):"STATUS"==t.Type?self.postMessage({type:"jobstatus",data:{status:e.data}}):self.postMessage({type:"speechResponse",data:e.data})}}catch(e){self.postMessage({type:"error",data:"invalid response"})}}(e)},E.onerror=function(e){console.error("WebSocket error: ",e),self.postMessage({type:"error",data:JSON.stringify(e)})},E.onclose=function(e){l&&console.log("Augnito: WebSocket connection closed - "+JSON.stringify(e)),K()},y=+new Date,S=y,C=+new Date}function M(e){if(E&&E.readyState===WebSocket.OPEN){E.send(e);var n=+new Date;return y<=S&&(S=n-1),y=n,!0}return e===t?(l&&console.warn("Gulping ".concat(t," as socket seems already closed...")),K(),!0):(+new Date-m>i&&!x&&L(),!1)}function J(e){w.push(e)}function K(){_&&(console.log("Augnito: Cleaning up worker resources..."),clearInterval(A),clearInterval(I),clearInterval(R),w=[],D=[],self.close())}L(),A=setInterval(function(){if(O){for(var e=0;e<D.length;e++){if(!M(D[e].packetData))break}O=!1}else for(;w.length>0;){var t=w.shift();if(!M(t)){w.unshift(t);break}if(d){if(!(t instanceof ArrayBuffer))continue;var n=new DataView(t),i={packetNumber:Number(n.getBigInt64(4)),packetData:t};D.push(i)}}},a),I=setInterval(function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;(g?y>S&&e-S>r:e-C>r)&&(l&&console.error("No data received since more than ".concat(r/1e3," secs, closing time...")),E.close())}},s),R=setInterval(function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;y&&e-y>o&&(l&&console.warn("No data sent since more than ".concat(o/1e3," secs, closing time...")),E.close())}},c),self.onmessage=function(i){if(i.data===n)N="",_=!0,x=!0,E.close();else if(i.data===e)J(t),N="",l&&console.log("Augnito: Worker received DONE, time to terminate..."),_=!0;else if(i.data===h)U=!0;else if(i.data===p)T=!0;else if(i.data===f){if(k instanceof ArrayBuffer&&J(k),P.length>0)for(var r=0;r<P.length;r++)J(P[r]);P=[],T=!1,U=!1,k=[]}else U&&!T?k=i.data:U&&T?P.push(i.data):J(i.data)}}var P,T,D,_,O,x,N,U,L,M,J=m(function e(t,n,i,r,o,s,a,c,u,l,d,h,f,p,g,b,m,y,S,C,k,E,A,I,w,P){v(this,e),this.audioContext,this.audioStream,this.executor=new R(n,s,a,c,m,y,S,k,E,A,w,r,h),this.executor.HeavyOp=b,this.source,this.processorNode,this.isPaused=!1,this.isStreaming=!1,this.audioData=[],this.isDebug=i,this.enableLogs=n,this.onStateChanged=C,this.onIntensity=I,this.onError=S,this.bufferSizeInterval=r,this.pausedBufferInterval=null!=o?o:1,this.shouldReadIntensity=d,this.closeSocketWithoutEOS=!1,this.shouldPreIntialiseRecorder=null!=l&&l,this.echoCancellation=f,this.noiseSuppression=p,this.autoGainControl=g,this.micNeedsRecovery=!1,this.trackEndedHandler=null,this.isRecovering=!1,this._micReadyFired=!1,this._micReadyFiredOnFirstRecovery=!1,this._deviceChangeHandling=!1,this.currentWsUrl="",this.currentDuration=0,this.deviceChangeHandler=null,this.onMicReady=P,this._originalDeviceId=null,this._originalDeviceLabel=null,this.shouldPreIntialiseRecorder&&this.InitialiseMediaStream(u,t)},[{key:"InitialiseMediaStream",value:(M=g(h().mark(function e(t,n){var i=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return this.currentDuration=t,this.currentWsUrl=n,e.next=4,this.createMediaStreamSourceNode();case 4:if(this.source){e.next=7;break}return console.error("Error: unable to create source node"),e.abrupt("return",!1);case 7:return e.next=9,this.createProcessorNode();case 9:if(this.processorNode){e.next=12;break}return console.error("Error: unable to create processor node"),e.abrupt("return",!1);case 12:this.source.connect(this.processorNode).connect(this.audioContext.destination),this.log("AudioContext Sample Rate: "+this.audioContext.sampleRate),""!==n&&this.executor.Start(t,n,this.shouldPreIntialiseRecorder),this.deviceChangeHandler||(this.deviceChangeHandler=g(h().mark(function e(){var t,n,r,o,s,a,c;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!i._deviceChangeHandling){e.next=2;break}return e.abrupt("return");case 2:if(i._deviceChangeHandling=!0,e.prev=3,(s=null===(t=i.audioStream)||void 0===t||null===(n=t.getAudioTracks)||void 0===n?void 0:n.call(t)[0])&&"ended"!==s.readyState){e.next=11;break}return i.micNeedsRecovery=!0,e.next=10,i.recoverAudioGraph();case 10:return e.abrupt("return");case 11:return a=null!==(r=null===(o=s.getSettings)||void 0===o||null===(o=o.call(s))||void 0===o?void 0:o.deviceId)&&void 0!==r?r:s.label,i.log('Device change detected. Probing current device: "'.concat(s.label,'"')),e.next=15,K(a);case 15:if(e.sent){e.next=27;break}return i.log('Current device "'.concat(s.label,'" appears silent/virtual. Searching for a real input device...')),i.micNeedsRecovery=!0,e.next=21,W(a,i.enableLogs);case 21:return(c=e.sent)?i._preferredDeviceId=c:(i.log("No active audio input device found after device change"),i._preferredDeviceId=null),e.next=25,i.recoverAudioGraph();case 25:e.next=28;break;case 27:i.log('Current device "'.concat(s.label,'" is producing audio — no switch needed'));case 28:return e.prev=28,i._deviceChangeHandling=!1,e.finish(28);case 31:case"end":return e.stop()}},e,null,[[3,,28,31]])})),navigator.mediaDevices.addEventListener("devicechange",this.deviceChangeHandler));case 16:case"end":return e.stop()}},e,this)})),function(e,t){return M.apply(this,arguments)})},{key:"StartStream",value:(L=g(h().mark(function e(t,n){var i,r;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log("New stream started..."),this.shouldPreIntialiseRecorder&&this.source){e.next=6;break}return e.next=4,this.InitialiseMediaStream(t,n,!1);case 4:e.next=7;break;case 6:this.shouldPreIntialiseRecorder&&this.executor.Send(E);case 7:if(!this.IsMicrophoneMuted){e.next=15;break}if(!this.audioContext||"running"!=this.audioContext.state){e.next=11;break}return e.next=11,this.audioContext.suspend();case 11:return null===(i=this.audioStream)||void 0===i||null===(r=i.getTracks)||void 0===r||null===(r=r.call(i))||void 0===r||r.forEach(function(e){try{e.stop()}catch(e){}}),this.executor.Send(I),this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return",!1);case 15:return this.onStateChanged(!0),this.isStreaming=!0,e.abrupt("return",!0);case 18:case"end":return e.stop()}},e,this)})),function(e,t){return L.apply(this,arguments)})},{key:"createBufferedSourceNode",value:(U=g(h().mark(function e(){var t;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.loadAudio();case 2:if(t=e.sent){e.next=6;break}return console.error("Error: unable to create audio buffer"),e.abrupt("return");case 6:this.source=this.audioContext.createBufferSource(),this.source.buffer=t,this.source.loop=!0,this.source.start();case 10:case"end":return e.stop()}},e,this)})),function(){return U.apply(this,arguments)})},{key:"createMediaStreamSourceNode",value:(N=g(h().mark(function e(){var t,n,i,r,o,s,a,c,u=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r={channelCount:1,noiseSuppression:void 0!==this.noiseSuppression&&this.noiseSuppression},void 0!==this.echoCancellation&&(r.echoCancellation=this.echoCancellation,r.googEchoCancellation=this.echoCancellation),void 0!==this.noiseSuppression&&(r.googNoiseSuppression=this.noiseSuppression),void 0!==this.autoGainControl&&(r.autoGainControl=this.autoGainControl,r.googAutoGainControl=this.autoGainControl),this._preferredDeviceId&&(r.deviceId={exact:this._preferredDeviceId}),e.next=8,navigator.mediaDevices.getUserMedia({audio:r});case 8:this.audioStream=e.sent,this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=new AudioContext),this.source=this.audioContext.createMediaStreamSource(this.audioStream),o=this.audioStream.getAudioTracks()[0],s=null!==(t=null===(n=o.getSettings)||void 0===n||null===(n=n.call(o))||void 0===n?void 0:n.deviceId)&&void 0!==t?t:"",a=null!==(i=o.label)&&void 0!==i?i:"",this._originalDeviceId||(this._originalDeviceId=s,this._originalDeviceLabel=a),this.trackEndedHandler&&(this.trackEndedHandler=null),this.trackEndedHandler=function(){u.micNeedsRecovery=!0,u.onError(JSON.stringify({Type:"ERROR",Data:"Audio track ended. Possibly the mic was unplugged."}))},o.addEventListener("ended",this.trackEndedHandler),e.next=25;break;case 20:e.prev=20,e.t0=e.catch(0),c="","NotAllowedError"==e.t0.name?c="Mic permission denied":"NotFoundError"===e.t0.name?c="No suitable media device found":"NotReadableError"===e.t0.name&&(c="Microphone is being used by another application"),this.onError(JSON.stringify({Type:"ERROR",Data:c}));case 25:case"end":return e.stop()}},e,this,[[0,20]])})),function(){return N.apply(this,arguments)})},{key:"loadAudio",value:(x=g(h().mark(function e(){var t,n,i;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("./radiology_speed_test.wav");case 3:return t=e.sent,e.next=6,t.arrayBuffer();case 6:return n=e.sent,e.next=9,this.audioContext.decodeAudioData(n);case 9:return i=e.sent,e.abrupt("return",i);case 13:return e.prev=13,e.t0=e.catch(0),console.error("Unable to fetch the audio file. Error: ".concat(e.t0.message)),e.abrupt("return",null);case 17:case"end":return e.stop()}},e,this,[[0,13]])})),function(){return x.apply(this,arguments)})},{key:"createProcessorNode",value:(O=g(h().mark(function e(){var t,n=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.audioContext.audioWorklet.addModule("data:application/javascript,".concat(encodeURIComponent('class MyAudioWorkletProcessor extends AudioWorkletProcessor {\n constructor() {\n super();\n this.accumulator = [];\n this.pauseSocketStreaming = false;\n this.sampleVal = 0;\n this.sampleSize = 0;\n this.intensityFrameCount = 0;\n this.reset();\n this.isProcessing = true;\n // message received from main-thread\n this.port.onmessage = (e) => {\n console.log("Augnito: Worklet received event - ", e.data);\n if (this.sampleSize > 0) {\n this.accumulator.push(this.sampleVal / this.sampleSize);\n }\n \n if (e.data == "PAUSE" || e.data == "STOP" || e.data == "PAUSESOCKET") {\n // append silence to get last word ASR.\n const silenceSize = 16000 * 2;\n for (let i = 0; i < silenceSize; i++) {\n this.accumulator.push(0.0003 * 0x7fff); // Push low-level noise instead of absolute silence to help ASR finalise\n }\n }\n this.send();\n this.reset();\n if (e.data == "STOP") {\n // message sent to main-thread\n this.port.postMessage({type:"DONE", value:"DONE"});\n this.isProcessing = false;\n \n }\n if(e.data == "PAUSESOCKET"){\n this.pauseSocketStreaming = true;\n this.port.postMessage("PAUSESOCKET");\n } else if(e.data == "RESUMESOCKET"){\n this.pauseSocketStreaming = false;\n } \n };\n }\n\n static get parameterDescriptors() {\n return [\n {\n name: "sampleRate",\n defaultValue: 16000,\n minValue: 16000,\n maxValue: 6 * 16000,\n },\n {\n name: "bufferSizeInterval",\n defaultValue: 1,\n minValue: 1,\n maxValue: 100,\n },\n {\n name: "pausedBufferInterval",\n defaultValue: 1,\n minValue: 0,\n maxValue: 100,\n },\n {\n name: "shouldReadIntensity",\n defaultValue: false,\n minValue: 0,\n maxValue: 1,\n },\n ];\n }\n\n // 128 frames\n process(inputList, outputList, params) {\n const input = inputList[0];\n if (input && input.length && input[0].length) {\n const channelData = input[0];\n const output = outputList[0];\n const inputSampleRate = params.sampleRate[0];\n const sampleRatio = inputSampleRate / 16000\n const bufferSizeInterval = params["bufferSizeInterval"][0];\n const pausedBufferInterval = params["pausedBufferInterval"][0];\n const shouldReadIntensity = params["shouldReadIntensity"][0];\n\n let sumSquares = 0; // For intensity\n let sampleCount = 0;\n\n // console.log("BufferSizeInterval", bufferSizeInterval);\n // Jackpot\n input[0].forEach((float32Element, index) => {\n const int16Element = Math.min(1, Math.max(-1, float32Element)) * 0x7fff;\n this.sampleVal += int16Element;\n this.sampleSize += 1;\n // Accumulate for intensity (RMS)\n sumSquares += float32Element * float32Element;\n sampleCount++;\n \n\n if (this.sampleSize >= sampleRatio) {\n const fraction = this.sampleSize - sampleRatio \n this.sampleVal -= fraction * int16Element;\n\n this.accumulator.push(this.sampleVal / sampleRatio);\n \n this.sampleVal = fraction * int16Element;\n this.sampleSize = fraction;\n }\n\n // Comment this when streaming microphone audio\n // output[0][index] = float32Element;\n });\n if(this.pauseSocketStreaming){\n if (this.accumulator.length >= 125 * 128 * pausedBufferInterval) {\n this.send();\n }\n } else{\n if (this.accumulator.length >= 125 * 128 * bufferSizeInterval) {\n this.send();\n }\n }\n if(shouldReadIntensity){\n \n // Throttled intensity post\n this.intensityFrameCount = (this.intensityFrameCount || 0) + 1;\n if (this.intensityFrameCount >= 15 && sampleCount > 0) {\n const rms = Math.sqrt(sumSquares / sampleCount);\n const normalized = Math.min(1, rms); // [0–1] scale\n this.port.postMessage({ type: \'intensity\', value: normalized });\n this.intensityFrameCount = 0;\n }\n }\n }\n return this.isProcessing;\n }\n\n send() {\n if (this.accumulator.length == 0) return;\n const audioData = new Int16Array(this.accumulator);\n // message sent to main-thread - transferrable\n this.port.postMessage({ type: \'audioData\', value: audioData.buffer }, [audioData.buffer]);\n this.accumulator = [];\n }\n\n reset() {\n this.sampleVal = 0;\n this.sampleSize = 0;\n }\n}\n\nregisterProcessor("worklet-processor", MyAudioWorkletProcessor);')));case 3:this.processorNode=new AudioWorkletNode(this.audioContext,"worklet-processor"),this.processorNode.parameters.get("sampleRate").setValueAtTime(this.audioContext.sampleRate,this.audioContext.currentTime),this.processorNode.parameters.get("bufferSizeInterval").setValueAtTime(this.bufferSizeInterval,this.audioContext.currentTime),this.processorNode.parameters.get("pausedBufferInterval").setValueAtTime(this.pausedBufferInterval,this.audioContext.currentTime),this.processorNode.parameters.get("shouldReadIntensity").setValueAtTime(null!==(t=this.shouldReadIntensity)&&void 0!==t&&t,this.audioContext.currentTime),this.processorNode.port.onmessage=function(e){var t=e.data,i=t.type,r=t.value;if(i==C)n.log("Worklet processing done, clearing resources..."),n.isDebug&&n.saveAudio(),n.cleanup();else if(e.data==k)n.executor.Send(k);else{var o;"intensity"===i?null===(o=n.onIntensity)||void 0===o||o.call(n,r):"audioData"===i&&n.isDebug&&new Int16Array(r).forEach(function(e){n.audioData.length<=288e5&&n.audioData.push(e)})}n.executor&&(n.closeSocketWithoutEOS?(n.executor.Send(I),n.closeSocketWithoutEOS=!1):"intensity"!==i&&n.executor.Send(r))},e.next=18;break;case 15:e.prev=15,e.t0=e.catch(0),console.error("Error: Unable to create worklet node: ",e.t0);case 18:case"end":return e.stop()}},e,this,[[0,15]])})),function(){return O.apply(this,arguments)})},{key:"PauseStream",value:(_=g(h().mark(function e(){return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!=this.audioContext.state){e.next=9;break}if(this.shouldPreIntialiseRecorder){e.next=8;break}return e.next=4,this.audioContext.suspend();case 4:this.log("Stream paused..."),this.processorNode.port.postMessage("PAUSE"),e.next=9;break;case 8:this.processorNode.port.postMessage(k);case 9:this.onStateChanged(!1),this.isPaused=!0,this.isStreaming=!1;case 12:case"end":return e.stop()}},e,this)})),function(){return _.apply(this,arguments)})},{key:"ResumeStream",value:(D=g(h().mark(function e(){var t,n,i;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if((i=null===(t=this.audioStream)||void 0===t||null===(n=t.getAudioTracks)||void 0===n?void 0:n.call(t)[0])&&"ended"!==i.readyState&&!this.micNeedsRecovery){e.next=5;break}return e.next=5,this.recoverAudioGraph();case 5:if(!this.IsMicrophoneMuted){e.next=11;break}if(!this.audioContext||"running"!==this.audioContext.state){e.next=9;break}return e.next=9,this.audioContext.suspend();case 9:return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return");case 11:if(!this.shouldPreIntialiseRecorder){e.next=16;break}this.processorNode.port.postMessage(E),this.executor.Send(E),e.next=20;break;case 16:if("suspended"!==this.audioContext.state){e.next=19;break}return e.next=19,this.audioContext.resume();case 19:this.log("Stream resumed...");case 20:this.onStateChanged(!0),this.isPaused=!1,this.isStreaming=!0;case 23:case"end":return e.stop()}},e,this)})),function(){return D.apply(this,arguments)})},{key:"IsPaused",get:function(){return this.isPaused}},{key:"IsStreaming",get:function(){return this.isStreaming}},{key:"IsMicrophoneMuted",get:function(){var e,t,n=null===(e=this.audioStream)||void 0===e||null===(t=e.getAudioTracks)||void 0===t?void 0:t.call(e)[0];return!n||n.muted||"ended"===n.readyState}},{key:"StopStream",value:(T=g(h().mark(function e(t){var n,i,r,o,s,a,c,u;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if("suspended"===(null===(n=this.audioContext)||void 0===n?void 0:n.state)){e.next=4;break}return e.next=3,null===(c=this.audioContext)||void 0===c?void 0:c.suspend();case 3:this.onStateChanged(!1);case 4:this.log("Stream stopped..."),this.isStreaming=!1,this.isPaused=!1,this.closeSocketWithoutEOS=!t,this.deviceChangeHandler&&(navigator.mediaDevices.removeEventListener("devicechange",this.deviceChangeHandler),this.deviceChangeHandler=null),(u=null===(i=this.audioStream)||void 0===i||null===(r=i.getAudioTracks)||void 0===r?void 0:r.call(i)[0])&&this.trackEndedHandler&&u.removeEventListener("ended",this.trackEndedHandler),this.trackEndedHandler=null,null===(o=this.audioStream)||void 0===o||null===(s=o.getTracks)||void 0===s||null===(s=s.call(o))||void 0===s||s.forEach(function(e){try{e.stop()}catch(e){}}),null===(a=this.processorNode)||void 0===a||null===(a=a.port)||void 0===a||a.postMessage("STOP");case 14:case"end":return e.stop()}},e,this)})),function(e){return T.apply(this,arguments)})},{key:"recoverAudioGraph",value:(P=g(h().mark(function e(){var t,n,i,r,o,s,a,c,u,l,d,f,p,g=this;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isRecovering){e.next=2;break}return e.abrupt("return");case 2:this.isRecovering=!0,e.prev=3,null===(t=this.audioStream)||void 0===t||null===(t=t.getTracks())||void 0===t||t.forEach(function(e){try{e.stop()}catch(e){}});try{null===(s=this.source)||void 0===s||s.disconnect()}catch(e){}try{null===(a=this.processorNode)||void 0===a||a.disconnect()}catch(e){}return e.next=9,this.createMediaStreamSourceNode();case 9:if(this.source){e.next=11;break}throw new Error("Failed to recreate source");case 11:if(this.audioContext&&"closed"!==this.audioContext.state||(this.audioContext=new AudioContext),"suspended"!==this.audioContext.state){e.next=15;break}return e.next=15,this.audioContext.resume();case 15:return e.next=17,this.createProcessorNode();case 17:if(this.source.connect(this.processorNode).connect(this.audioContext.destination),this.isStreaming&&!this.isPaused){e.next=22;break}if("running"!==this.audioContext.state){e.next=22;break}return e.next=22,this.audioContext.suspend();case 22:return this.micNeedsRecovery=!1,c=null===(n=this.audioStream)||void 0===n||null===(i=n.getAudioTracks)||void 0===i?void 0:i.call(n)[0],u=null!==(r=null==c||null===(o=c.getSettings)||void 0===o||null===(o=o.call(c))||void 0===o?void 0:o.deviceId)&&void 0!==r?r:"",l=c&&"live"===c.readyState,e.next=28,navigator.mediaDevices.enumerateDevices();case 28:d=e.sent,f=d.some(function(e){return"audioinput"===e.kind&&e.label&&e.label===g._originalDeviceLabel}),p=u&&l,console.log("Original device present:",f),console.log("Active:",p),!this.isPaused||this.IsMicrophoneMuted&&!f||this.onMicReady&&!this._micReadyFiredOnFirstRecovery&&(this._micReadyFiredOnFirstRecovery=!0,this.onMicReady()),this.log("Audio graph recovery completed"),e.next=40;break;case 37:e.prev=37,e.t0=e.catch(3),console.error("Recovery failed",e.t0);case 40:return e.prev=40,this.isRecovering=!1,e.finish(40);case 43:case"end":return e.stop()}},e,this,[[3,37,40,43]])})),function(){return P.apply(this,arguments)})},{key:"IntentStartStream",value:function(){this.executor.Send("INTENT_START_STREAM")}},{key:"cleanup",value:function(){var e;null===(e=this.audioStream)||void 0===e||null===(e=e.getTracks())||void 0===e||e.forEach(function(e){try{e.stop()}catch(e){}}),this.source.disconnect(),this.processorNode.disconnect(),this.processorNode.port.close(),this.audioContext.close(),this.audioData=[]}},{key:"saveAudio",value:function(){var e=this.encodeWAV(),t=URL.createObjectURL(new Blob([e],{type:"audio/wav"}));this.log("Download Recording: ".concat(t))}},{key:"getBlob",value:function(){var e=this.encodeWAV();return new Blob([e],{type:"audio/wav"})}},{key:"encodeWAV",value:function(){var e=new DataView(new ArrayBuffer(2*this.audioData.length));this.audioData.forEach(function(t,n){e.setInt16(2*n,t,!0)});var t=e.buffer.byteLength,n=44+t,i=new DataView(new ArrayBuffer(n));i.setUint32(0,1380533830,!1),i.setUint32(4,n-8,!0),i.setUint32(8,1463899717,!1),i.setUint32(12,1718449184,!1),i.setUint32(16,16,!0),i.setUint16(20,1,!0),i.setUint16(22,1,!0),i.setUint32(24,16e3,!0),i.setUint32(28,32e3,!0),i.setUint16(32,2,!0),i.setUint16(34,16,!0),i.setUint32(36,1684108385,!1),i.setUint32(40,t,!0);for(var r=0;r<t;r++)i.setInt8(44+r,e.getInt8(r));return i}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);console.log(t+"\n")}}}]);function K(e){return j.apply(this,arguments)}function j(){return j=g(h().mark(function e(t){var n,i,r,o,s,a,c,u,l,d=arguments;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=d.length>1&&void 0!==d[1]?d[1]:350,i=d.length>2&&void 0!==d[2]?d[2]:.01,r=null,o=null,e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:t},channelCount:1}});case 7:return r=e.sent,o=new AudioContext,s=o.createMediaStreamSource(r),(a=o.createAnalyser()).fftSize=256,s.connect(a),c=a.frequencyBinCount,u=new Float32Array(c),e.next=17,new Promise(function(e){var t=0,r=performance.now();requestAnimationFrame(function o(){a.getFloatTimeDomainData(u);for(var s=0,l=0;l<c;l++)s+=u[l]*u[l];var d=Math.sqrt(s/c);d>t&&(t=d),performance.now()-r<n?requestAnimationFrame(o):e(t>i)})});case 17:return e.abrupt("return",e.sent);case 20:return e.prev=20,e.t0=e.catch(4),e.abrupt("return",!1);case 23:return e.prev=23,null===(l=r)||void 0===l||l.getTracks().forEach(function(e){return e.stop()}),o&&"closed"!==o.state&&o.close().catch(function(){}),e.finish(23);case 27:case"end":return e.stop()}},e,null,[[4,20,23,27]])})),j.apply(this,arguments)}function W(e){return F.apply(this,arguments)}function F(){return(F=g(h().mark(function e(t){var n,i,r,o,s;return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=1,e.next=4,navigator.mediaDevices.enumerateDevices();case 4:n=e.sent,e.next=10;break;case 7:return e.prev=7,e.t0=e.catch(1),e.abrupt("return",null);case 10:i=n.filter(function(e){return"audioinput"===e.kind&&e.deviceId!==t}),r=S(i),e.prev=12,r.s();case 14:if((o=r.n()).done){e.next=23;break}return s=o.value,e.next=18,K(s.deviceId);case 18:if(!e.sent){e.next=21;break}return e.abrupt("return",s.deviceId);case 21:e.next=14;break;case 23:e.next=28;break;case 25:e.prev=25,e.t1=e.catch(12),r.e(e.t1);case 28:return e.prev=28,r.f(),e.finish(28);case 31:return e.abrupt("return",null);case 32:case"end":return e.stop()}},e,null,[[1,7],[12,25,28,31]])}))).apply(this,arguments)}var G=function(){function e(){var t,n,i,r,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{serverURL:"",enableLogs:!1,isDebug:!1,bufferInterval:1,pausedBufferInterval:1,EOS_Message:void 0,socketTimeoutInterval:void 0,shouldSendAudioDataSequence:!1,reconnectAudioDuration:0,shouldPreIntialiseRecorder:!1,shouldReadIntensity:!1,debounceDelay:300,switchToRegularSpeechProfile:!1,echoCancellation:void 0,noiseSuppression:void 0,autoGainControl:void 0},s=arguments.length>1?arguments[1]:void 0;if(v(this,e),e.instance)return e.instance;this.WebsocketURL=null!==(t=o.serverURL)&&void 0!==t?t:"",this.enableLogs=o.enableLogs,this.isDebug=o.isDebug,this.streamer=null,this.streamerNotStarted=!1,this.isStreamerStarting=!1,this.pendingStartStream=!1,this.heavyOp=s,this.bufferInterval=o.bufferInterval,this.pausedBufferInterval=o.pausedBufferInterval,this.eosMessage=o.EOS_Message,this.socketTimeoutInterval=o.socketTimeoutInterval,this.shouldSendAudioDataSequence=o.shouldSendAudioDataSequence,this.reconnectAudioDuration=null!==(n=o.reconnectAudioDuration)&&void 0!==n?n:0,this.shouldPreIntialiseRecorder=o.shouldPreIntialiseRecorder,this.switchToRegularSpeechProfile=null!==(i=o.switchToRegularSpeechProfile)&&void 0!==i&&i,this._echoCancellation=o.echoCancellation,this._noiseSuppression=o.noiseSuppression,this._autoGainControl=o.autoGainControl,this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0),this.shouldReadIntensity=o.shouldReadIntensity,this.delay=null!==(r=o.debounceDelay)&&void 0!==r?r:300,this.toggleStartStopAudioStream=B(this.toggleStartStopAudioStream.bind(this),this.delay),this.togglePauseResumeAudioStream=B(this.togglePauseResumeAudioStream.bind(this),this.delay),this.needsDispose=!1,e.instance=this}return m(e,[{key:"echoCancellation",get:function(){return this._echoCancellation},set:function(e){this._echoCancellation=e,this.streamer&&(this.streamer.echoCancellation=e)}},{key:"noiseSuppression",get:function(){return this._noiseSuppression},set:function(e){this._noiseSuppression=e,this.streamer&&(this.streamer.noiseSuppression=e)}},{key:"autoGainControl",get:function(){return this._autoGainControl},set:function(e){this._autoGainControl=e,this.streamer&&(this.streamer.autoGainControl=e)}},{key:"initialiseStreamer",value:function(){this.streamer=new J(this.WebsocketURL,this.enableLogs,this.isDebug,this.bufferInterval,this.pausedBufferInterval,this.eosMessage,this.socketTimeoutInterval,this.shouldSendAudioDataSequence,this.reconnectAudioDuration,this.shouldPreIntialiseRecorder,this.shouldReadIntensity,this.switchToRegularSpeechProfile,this._echoCancellation,this._noiseSuppression,this._autoGainControl,this.heavyOp,this.onFinalResultCallback.bind(this),this.onPartialResultCallback.bind(this),this.onErrorCallback.bind(this),this.onStateChangedCallback.bind(this),this.onSessionEventCallback.bind(this),this.onOtherResultCallback.bind(this),this.onSpeechResponseCallback.bind(this),this.onIntensityCallback.bind(this),this.onJobStatusCallback.bind(this),this.onMicReadyCallback.bind(this))}},{key:"updateIntentStartStream",value:function(){var e;this.pendingStartStream=!0,null===(e=this.streamer)||void 0===e||e.IntentStartStream()}},{key:"togglePauseResumeAudioStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;!this.streamer||this.streamerNotStarted?(t&&(this.WebsocketURL=t),this.startAudio(e)):this.streamer.IsPaused?this.resumeAudio():this.pauseAudio()}},{key:"toggleStartStopAudioStream",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;!this.streamer||this.streamerNotStarted?(t&&(this.WebsocketURL=t),this.startAudio(e)):this.stopAudio()}},{key:"startAudio",value:(t=g(h().mark(function e(t){return h().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isStreamerStarting){e.next=2;break}return e.abrupt("return");case 2:return this.isStreamerStarting=!0,this.shouldPreIntialiseRecorder&&this.streamer||this.initialiseStreamer(),e.prev=4,e.next=7,this.streamer.StartStream(t,this.WebsocketURL);case 7:e.sent?(this.streamerNotStarted=!1,this.log("Stream Started...")):this.streamer=null;case 9:return e.prev=9,this.isStreamerStarting=!1,e.finish(9);case 12:case"end":return e.stop()}},e,this,[[4,,9,12]])})),function(e){return t.apply(this,arguments)})},{key:"pauseAudio",value:function(){this.streamer.PauseStream(),this.log("Stream Paused...")}},{key:"resumeAudio",value:function(){this.streamer.ResumeStream(),this.enableLogs&&this.log("Stream Resumed...")}},{key:"stopAudio",value:function(){var e,t,n=this,i=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(null!==(e=this.streamer)&&void 0!==e&&e.IsStreaming||r)&&(null===(t=this.streamer)||void 0===t||t.StopStream(i),this.streamer=null,this.log("Stream Stopped..."),this.shouldPreIntialiseRecorder&&setTimeout(function(){n.needsDispose?n.needsDispose=!1:(n.initialiseStreamer(),n.streamerNotStarted=!0)},500))}},{key:"getBlob",value:function(){var e=this.streamer.getBlob();return this.log("Blob Sent..."),e}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);this.showLogCallback(t+"\n")}}},{key:"dispose",value:function(){var t;this.needsDispose=!0,null===(t=this.streamer)||void 0===t||t.StopStream(!1),this.streamer=null,e.instance=null}},{key:"onSessionEventCallback",value:function(e){this.onSessionEvent&&this.onSessionEvent(e)}},{key:"onStateChangedCallback",value:function(e){this.onStateChanged&&this.onStateChanged(e)}},{key:"onIntensityCallback",value:function(e){this.onIntensity&&this.onIntensity(e)}},{key:"onErrorCallback",value:function(e){this.onError&&this.onError(e)}},{key:"onPartialResultCallback",value:function(e){this.onPartialResult&&this.onPartialResult(e)}},{key:"onFinalResultCallback",value:function(e){this.onFinalResult&&this.onFinalResult(e)}},{key:"onOtherResultCallback",value:function(e){this.onOtherResults&&this.onOtherResults(e)}},{key:"onSpeechResponseCallback",value:function(e){this.onSpeechResponse&&this.onSpeechResponse(e)}},{key:"onJobStatusCallback",value:function(e){this.onJobStatus&&this.onJobStatus(e)}},{key:"onMicReadyCallback",value:function(){this.onMicReady&&this.onMicReady()}},{key:"showLogCallback",value:function(e){this.showLog&&this.showLog(e)}}]);var t}();function B(e,t){var n;return function(){for(var i=this,r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];n&&clearTimeout(n),n=setTimeout(function(){return e.apply(i,o)},t)}}class H extends u{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._baseUrl=`https://${e.server}/pace/v1/sdk`}getURL(e){return`${this._baseUrl}${e}`}getNoteParams(){return e(this,void 0,void 0,function*(){const e=this.getURL("/noteparams"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}getSettingsConfigMaster(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/configmaster"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}getOrgConfigMapping(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/configmapping").replace("/v1","/v2"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}getUserConfigSettings(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/userconfigmapping"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,ConfigTypeId:t};return yield this.makePostRequest(e,n)})}updateUserConfig(t){return e(this,void 0,void 0,function*(){const e=this.getURL("/userconfigmapping"),n={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,UserConfigMapping:t};return yield this.makePatchRequest(e,n)})}getUserPreferences(){return e(this,void 0,void 0,function*(){const e=this.getURL("/getuserpreferences"),t={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag};return yield this.makePostRequest(e,t)})}updateUserPreference(t,n,i,r,o,s){return e(this,void 0,void 0,function*(){const e=this.getURL("/postuserpreferences"),a={SubscriptionCode:this._config.subscriptionCode,AccessKey:this._config.accessKey,UserTag:this._config.userTag,UserPreferences:{AutomaticallyGenerateTranscript:t,PreferredTranscriptionLanguage:n,HighlightMedicalTerms:i,DisplayPatientContext:r,NoteOutputStyle:o,NoteOutputVerbosity:s}};return yield this.makePostRequest(e,a)})}}const V="Invalid user details, please check again",q="Subscription is not valid.",z="invalid request. Please make sure AccessKey, SubscriptionCode and UserTag is sent along with the request",$="Active seat is not available for user",Y="Unable to fetch account details, please try again.",Q="Unable to fetch job details, please try again.",X="Job not reconnectable",Z="Timeout exceeded",ee="Rate Limit Exceeded, Please try again in sometime!",te="Audio Signal is power very LOW, Mic might be muted",ne="Job Id is empty",ie="Page Size is undefined",re="Note Data is empty",oe="Job Name is empty",se="Patient Context is empty",ae="Mic permission denied",ce="Microphone is muted",ue="Audio track ended. Possibly the mic was unplugged",le="Internet is not available. Try again later.",de="Feedback is not enabled. Please contact administrator for more details.",he="Automatic Transcription is not enabled for the organisation";class fe{static isBrowserOnline(){return"undefined"!=typeof navigator&&!0===navigator.onLine}static isValidHttpUrl(e){if("string"!=typeof e||e.length>2048)return!1;try{const t=new URL(e);return("http:"===t.protocol||"https:"===t.protocol)&&(!t.username&&!t.password)}catch(e){return!1}}static hasInternetConnection(){return e(this,arguments,void 0,function*(e={url:null,timeoutMs:null}){var t=e.url||fe.DEFAULT_URL;const n=e.timeoutMs||fe.DEFAULT_TIMEOUT;if(!fe.isBrowserOnline())return!1;fe.isValidHttpUrl(t)||(t=fe.DEFAULT_URL);const i=new AbortController,r=setTimeout(()=>i.abort(),n);try{return yield fetch(t,{method:"HEAD",mode:"no-cors",cache:"no-cache",signal:i.signal}),!0}catch(e){return!1}finally{clearTimeout(r)}})}static isOnline(t){return e(this,void 0,void 0,function*(){return fe.hasInternetConnection(t)})}}Object.defineProperty(fe,"DEFAULT_URL",{enumerable:!0,configurable:!0,writable:!0,value:"https://www.google.com/favicon.ico"}),Object.defineProperty(fe,"DEFAULT_TIMEOUT",{enumerable:!0,configurable:!0,writable:!0,value:5e3});class pe{constructor(e){Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"Augnito-Ambient"}),Object.defineProperty(this,"_ambientRestAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_ambientPaceAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableLog",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shouldReadAudioIntensity",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"recorderIns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"forceStopAudio",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_isRecording",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"echoCancellation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"noiseSuppression",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"autoGainControl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onJobCreated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStateChanged",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onOtherResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onIntensityValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onIdleMic",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onSoapNoteGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onTranscriptGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onCodesGenerated",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onJobStatus",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMicRecoveredAfterUnplugged",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._ambientRestAPI=new l(this.validateConfig(e)),this._ambientPaceAPI=new H(e),this.config=this.createSocketConfig(e),this.enableLog=e.enableLogs,this.shouldReadAudioIntensity=e.shouldReadAudioIntensity,this.echoCancellation=e.echoCancellation,this.noiseSuppression=e.noiseSuppression,this.autoGainControl=e.autoGainControl}initRecorder(e){var t,n,i,r,o;this.recorderIns=new G({serverURL:e,enableLogs:null!==(t=this.enableLog)&&void 0!==t&&t,isDebug:null!==(n=this.enableLog)&&void 0!==n&&n,bufferInterval:15,EOS_Message:'{"JobAction": "EOS","Status": 0,"Type": "meta"}',socketTimeoutInterval:2e4,shouldSendAudioDataSequence:!0,shouldReadIntensity:this.shouldReadAudioIntensity,echoCancellation:this.echoCancellation,noiseSuppression:this.noiseSuppression,autoGainControl:this.autoGainControl}),this.recorderIns.echoCancellation=null!==(i=this.echoCancellation)&&void 0!==i&&i,this.recorderIns.noiseSuppression=null!==(r=this.noiseSuppression)&&void 0!==r&&r,this.recorderIns.autoGainControl=null!==(o=this.autoGainControl)&&void 0!==o&&o,this.recorderIns.onError=this.onErrorCallback.bind(this),this.recorderIns.onStateChanged=this.onStateChangeCallback.bind(this),this.recorderIns.onSessionEvent=this.onSessionEventCallback.bind(this),this.recorderIns.onOtherResults=this.onOtherResultsCallback.bind(this),this.recorderIns.onIntensity=this.onIntensityCallback.bind(this),this.recorderIns.onSpeechResponse=this.onSpeechResponseCallback.bind(this),this.recorderIns.onJobStatus=this.onJobStatusEventCallback.bind(this),this.recorderIns.onMicReady=this.onMicRecoveredAfterUnpluggedCallback.bind(this)}getNoteParams(){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getNoteParams();if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getAllNotes(t,n){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.ListJobs(t,n);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getSummarizedNote(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.FetchJob(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}sendSummarizedNote(t,n){return e(this,void 0,void 0,function*(){try{return this._ambientRestAPI?yield this._ambientRestAPI.SendFinalNote(t,n):void d.error("SDK not initialized",this._logTag)}catch(e){this.handleException(e)}})}toggleListening(e,t,n,i,r){var o,s,a=(null===(o=this.config)||void 0===o?void 0:o.prepareWSSURL(e,t,n,i))||"";this.recorderIns||this.initRecorder(a),null===(s=this.recorderIns)||void 0===s||s.toggleStartStopAudioStream(r,a)}togglePauseResumeListening(e,t,n,i,r){var o,s,a=(null===(o=this.config)||void 0===o?void 0:o.prepareWSSURL(e,t,n,i))||"";this.recorderIns||this.initRecorder(a),null===(s=this.recorderIns)||void 0===s||s.togglePauseResumeAudioStream(r,a)}startListening(){var e;null===(e=this.recorderIns)||void 0===e||e.startAudio()}stopListening(){var e;null===(e=this.recorderIns)||void 0===e||e.stopAudio(!0,!0)}deleteNotes(t){return e(this,void 0,void 0,function*(){var e;try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var n=yield this._ambientRestAPI.DeleteNotes(t);if(n){if(200===n.Status)return null===(e=this.recorderIns)||void 0===e||e.stopAudio(!1,!0),n;this.onErrorCallback(n.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}renameNoteTitle(t,n){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.RenameNoteTitle(t,n);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getNotePDF(t,n,i,r,o,s){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.DownloadNotePDF(t,n,i,r,o,s);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}endPausedJob(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.EndJob(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}generateCDISuggestions(t,n,r,o,s){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=1,a=yield this._ambientPaceAPI.getOrgConfigMapping(i.CDIVersion);if((null==a?void 0:a.Items)&&a.Items.length>0&&a.Items[0].Settings){var c=a.Items[0].Settings.find(e=>209===e.ID);c&&(e=Number.parseInt(c.ConfigValue))}var u=yield this._ambientRestAPI.GenerateSuggestions(t,n,r,s,o,e);if(u){if(200===u.Status)return u;this.onErrorCallback(u.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updatePatientContext(t,n,i){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.UpdatePatientContext(t,n,i);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}modifyGeneratedNote(t,n,i){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientRestAPI.ModifyGeneratedNote(t,n,i);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}fetchTranscriptionForNote(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);if((yield this._ambientPaceAPI.getUserPreferences()).Items[0].AutomaticTranscriptionEnabledForOrg){var e=yield this._ambientRestAPI.FetchTranscription(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}else this.onErrorCallback(he)}catch(e){this.handleException(e)}})}sendFeedback(t,n,i,r){return e(this,void 0,void 0,function*(){var e,o;try{if(!this._ambientRestAPI)return void d.error("SDK not initialized",this._logTag);var s=yield this._ambientPaceAPI.getUserPreferences();if((null===(e=s.Items[0])||void 0===e?void 0:e.FeedbackEnabledForOrg)&&(null===(o=s.Items[0])||void 0===o?void 0:o.FeedbackEnabled)){var a=yield this._ambientRestAPI.SendFeedback(t,n,null!=i?i:"",null!=r?r:"SOAPFeedBack");if(a){if(200===a.Status)return a;this.onErrorCallback(a.ServerMessage)}else this.onErrorCallback("Unknown Error!")}else this.onErrorCallback(de)}catch(e){this.handleException(e)}})}getUserConfiguration(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getUserConfigSettings(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updateUserConfiguration(t){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.updateUserConfig(t);if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}getUserPreferenceSettings(){return e(this,void 0,void 0,function*(){try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var e=yield this._ambientPaceAPI.getUserPreferences();if(e){if(200===e.Status)return e;this.onErrorCallback(e.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}updateUserPreferenceSettings(t){return e(this,void 0,void 0,function*(){var e,n,i,r,o,c;try{if(!this._ambientPaceAPI)return void d.error("SDK not initialized",this._logTag);var u=yield this._ambientPaceAPI.updateUserPreference(null!==(e=t.AutomaticallyGenerateTranscript)&&void 0!==e&&e,null!==(n=t.PreferredTranscriptionLanguage)&&void 0!==n?n:"English",null!==(i=t.HighlightMedicalTerms)&&void 0!==i&&i,null!==(r=t.DisplayPatientContext)&&void 0!==r&&r,null!==(o=t.NoteOutputStyle)&&void 0!==o?o:a.DashFormat,null!==(c=t.NoteOutputVerbosity)&&void 0!==c?c:s.Detailed);if(u){if(200===u.Status)return u;this.onErrorCallback(u.ServerMessage)}else this.onErrorCallback("Unknown Error!")}catch(e){this.handleException(e)}})}isInternetAvailable(t){return e(this,void 0,void 0,function*(){const e=yield fe.isOnline(t);return e||this.onErrorCallback(le),e})}onEventCallback(e){this.onJobCreated&&this.onJobCreated(e)}onStateChangeCallback(e){var t;if(this.forceStopAudio)return null===(t=this.recorderIns)||void 0===t||t.stopAudio(!1,!0),void(this.forceStopAudio=!1);this._isRecording=e,this.onStateChanged&&this.onStateChanged(e)}handleException(e){if(e instanceof TypeError)this.onErrorCallback(e.message);else{if(e instanceof c)throw e;d.error(e.message,this._logTag)}}onErrorCallback(e,t){var n,i,r,s,a,c,u,l,h,f,p,g,v,b,m,y,S={ErrorCode:null!=t?t:o.ERRUNKNOWN,ErrorMessage:e};try{var C=JSON.parse(e);S.ErrorMessage=C.Data,C.Data===Z?(this.stopListening(),d.error("Recording time limit exceeded",this._logTag),S.ErrorCode=o.WSJOB05):C.Data===V?(this._isRecording?null===(n=this.recorderIns)||void 0===n||n.stopAudio(!1,!0):this.forceStopAudio=!0,S.ErrorCode=o.WSAUTH03):C.Data.includes(Y)?S.ErrorCode=o.WSAUTH04:C.Data.includes(Q)?S.ErrorCode=o.WSJOB01:C.Data.includes(X)?S.ErrorCode=o.WSJOB02:C.Data.includes(ee)?S.ErrorCode=o.WSACC01:C.Data.includes(te)&&(S.ErrorCode=o.WSAUD01)}catch(e){}(null===(i=S.ErrorMessage)||void 0===i?void 0:i.includes(ne))?S.ErrorCode=o.SDK01:(null===(r=S.ErrorMessage)||void 0===r?void 0:r.includes(ie))?S.ErrorCode=o.SDK02:(null===(s=S.ErrorMessage)||void 0===s?void 0:s.includes(re))?S.ErrorCode=o.SDK03:(null===(a=S.ErrorMessage)||void 0===a?void 0:a.includes(oe))?S.ErrorCode=o.SDK04:(null===(c=S.ErrorMessage)||void 0===c?void 0:c.includes(se))?S.ErrorCode=o.SDK05:(null===(u=S.ErrorMessage)||void 0===u?void 0:u.includes(ae))?S.ErrorCode=o.SDK06:(null===(l=S.ErrorMessage)||void 0===l?void 0:l.includes(ce))?(S.ErrorCode=o.SDK07,null===(h=this.recorderIns)||void 0===h||h.stopAudio(!1,!0)):(null===(f=S.ErrorMessage)||void 0===f?void 0:f.includes(ue))?S.ErrorCode=o.SDK08:(null===(p=S.ErrorMessage)||void 0===p?void 0:p.includes(q))||(null===(g=S.ErrorMessage)||void 0===g?void 0:g.includes(z))?S.ErrorCode=o.AUTH01:(null===(v=S.ErrorMessage)||void 0===v?void 0:v.includes($))?S.ErrorCode=o.AUTH02:(null===(b=S.ErrorMessage)||void 0===b?void 0:b.includes(le))?S.ErrorCode=o.SDK12:(null===(m=S.ErrorMessage)||void 0===m?void 0:m.includes(he))?S.ErrorCode=o.SDK13:(null===(y=S.ErrorMessage)||void 0===y?void 0:y.includes(de))&&(S.ErrorCode=o.SDK14),this.onError&&this.onError(S)}onOtherResultsCallback(e){this.onOtherResult&&this.onOtherResult(e)}onIntensityCallback(e){this.onIntensityValue&&this.onIntensityValue(e)}onIdleMicCallback(){this.onIdleMic&&this.onIdleMic()}onSpeechResponseCallback(e){var t=JSON.parse(e);"note"===t.Type.toLowerCase()&&this.onSoapNoteGenerated?this.onSoapNoteGenerated(t.Data):"transcript"===t.Type.toLowerCase()&&this.onTranscriptGenerated?this.onTranscriptGenerated(t.Data):"codes"===t.Type.toLowerCase()&&this.onCodesGenerated&&this.onCodesGenerated(t.Data)}onJobStatusEventCallback(e){this.onJobStatus&&this.onJobStatus(e)}onMicRecoveredAfterUnpluggedCallback(){this.onMicRecoveredAfterUnplugged&&this.onMicRecoveredAfterUnplugged()}onSessionEventCallback(e){var t;if(!e)return;let n;try{n="string"==typeof e?JSON.parse(e):e}catch(e){return void d.error(`Error parsing session event data: ${e}`,this._logTag)}if(!n||!("Type"in n))return;if("meta"===n.Type.toLowerCase()&&(null===(t=this.config)||void 0===t?void 0:t.onMetaEvent)){if(!n.JobID)return void d.error("JobID is missing in meta event",this._logTag);this.config.onMetaEvent(n.JobID)}else"error"===n.Type.toLowerCase()&&n.Data&&this.onErrorCallback(n.Data);if("object"!=typeof n.Event||null===n.Event)return;const{Type:i,Value:r}=n.Event;i&&("SESSION_CREATED"===i&&r?d.log(`session Token ${r}`,this._logTag):"SERVICE_DOWN"===i?d.error(i,this._logTag):"NO_DICTATION_STOP_MIC"===i?(d.log("NO_DICTATION_STOP_MIC",this._logTag),this.onIdleMicCallback()):"INVALID_AUTH_CREDENTIALS"===i?d.error("INVALID_AUTH_CREDENTIALS",this._logTag):"LOW_BANDWIDTH"===i&&d.log("LOW_BANDWIDTH: Check internet connection",this._logTag))}validateConfig(e){return n.Against.NullOrEmpty(e.server,"Server"),n.Against.NullOrEmpty(e.subscriptionCode,"SubscriptionCode"),n.Against.NullOrEmpty(e.accessKey,"AccessKey"),n.Against.NullOrEmpty(e.userTag,"UserTag"),e}createSocketConfig(e){const n=new t(e);return n.onError=this.onErrorCallback.bind(this),n.onMetaEvent=this.onEventCallback.bind(this),n}}export{pe as AugnitoAmbient,o as ErrorCodes,c as HttpCodedError,a as NoteOutputStyleConfig,r as NoteTypeConfig,s as NoteVerbosityConfig,i as SettingsConfigType};
@@ -23,6 +23,5 @@ export declare enum ErrorCodes {
23
23
  SDK12 = "SDK12",
24
24
  SDK13 = "SDK13",
25
25
  SDK14 = "SDK14",
26
- SDK15 = "SDK15",
27
26
  ERRUNKNOWN = "ERRUNKNOWN"
28
27
  }
@@ -5,5 +5,5 @@ export declare class socketConfig {
5
5
  onError?: (errorMessage: string) => void;
6
6
  onMetaEvent?: (jobId: string) => void;
7
7
  constructor(_config: AmbientConfig);
8
- prepareWSSURL(_filetype: string, _noteparams: string, jobName?: string, jobId?: string, parentJobId?: string, inheritParentConfig?: boolean): string;
8
+ prepareWSSURL(_filetype: string, _noteparams: string, jobName?: string, jobId?: string): string;
9
9
  }
@@ -24,5 +24,4 @@ export declare const ErrorMessages: {
24
24
  noInternetConnection: string;
25
25
  feedbackNotEnabled: string;
26
26
  transcriptionNotEnabled: string;
27
- resumeNotAllowed: string;
28
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaugnitoambientsdk2",
3
- "version": "2.1.72",
3
+ "version": "2.1.73",
4
4
  "description": "Use this typescript SDK to integrate Augnito’s Ambient Tech within your EMR. To get access credentials or know more about how Augnito Ambient can benefit you, please visit our website and connect with our sales team: https://augnito.ai/",
5
5
  "main": "dist/augnitoambientsdk.js",
6
6
  "types": "dist/index.d.ts",
@@ -125,13 +125,13 @@ export class AugnitoAmbient {
125
125
  * @param PageID is optional parameter, send start page id to fetch
126
126
  * @returns list of notes for the user
127
127
  */
128
- public async getAllNotes(PageSize: number, PageID?: string, Collapse?: boolean): Promise<any> {
128
+ public async getAllNotes(PageSize: number, PageID?: string): Promise<any> {
129
129
  try {
130
130
  if (!this._ambientRestAPI) {
131
131
  Logger.error("SDK not initialized", this._logTag);
132
132
  return;
133
133
  }
134
- var responseJson = await this._ambientRestAPI.ListJobs(PageSize, PageID, Collapse ?? true);
134
+ var responseJson = await this._ambientRestAPI.ListJobs(PageSize, PageID);
135
135
  if (responseJson) {
136
136
  if (responseJson.Status === 200) {
137
137
  return responseJson;
@@ -196,28 +196,16 @@ export class AugnitoAmbient {
196
196
  * @param noteparams Qualifiers to determine the type of clinical note to be generated for that audio file.
197
197
  * @returns Callback triggers to reurn the Job id on meta message
198
198
  */
199
- public async toggleListening(
199
+ public toggleListening(
200
200
  _filetype: string,
201
201
  _noteparams: string,
202
202
  jobName?: string,
203
203
  jobId?: string,
204
- recordedDuration?: number,
205
- parentJobId?: string,
206
- inheritParentConfig?: boolean
207
- ): Promise<void> {
204
+ recordedDuration?: number
205
+ ): void {
208
206
  // console.log("toggleListening:", _filetype, _noteparams);
209
- if (parentJobId !== undefined && parentJobId.trim() !== "") {
210
- var configs = await this._ambientPaceAPI.getOrgConfigMapping(SettingsConfigType.CDIVersion);
211
- if (configs?.Items && configs.Items.length > 0 && configs.Items[0].Settings) {
212
- var setting = configs.Items[0].Settings.find((x: { ID: number; }) => x.ID === 300);
213
- if (!setting) {
214
- this.onErrorCallback(ErrorMessages.resumeNotAllowed)
215
- return;
216
- }
217
- }
218
- }
219
207
  var serverUrl =
220
- this.config?.prepareWSSURL(_filetype, _noteparams, jobName, jobId, parentJobId, inheritParentConfig) || "";
208
+ this.config?.prepareWSSURL(_filetype, _noteparams, jobName, jobId) || "";
221
209
  if (!this.recorderIns) {
222
210
  this.initRecorder(serverUrl);
223
211
  }
@@ -230,28 +218,16 @@ export class AugnitoAmbient {
230
218
  * @param noteparams Qualifiers to determine the type of clinical note to be generated for that audio file.
231
219
  * @returns Callback triggers to reurn the Job id on meta message
232
220
  */
233
- public async togglePauseResumeListening(
221
+ public togglePauseResumeListening(
234
222
  _filetype: string,
235
223
  _noteparams: string,
236
224
  jobName?: string,
237
225
  jobId?: string,
238
- recordedDuration?: number,
239
- parentJobId?: string,
240
- inheritParentConfig?: boolean
241
- ): Promise<void> {
226
+ recordedDuration?: number
227
+ ): void {
242
228
  // console.log("togglePauseResumeListening:", _filetype, _noteparams);
243
- if (parentJobId !== undefined && parentJobId.trim() !== "") {
244
- var configs = await this._ambientPaceAPI.getOrgConfigMapping(SettingsConfigType.CDIVersion);
245
- if (configs?.Items && configs.Items.length > 0 && configs.Items[0].Settings) {
246
- var setting = configs.Items[0].Settings.find((x: { ID: number; }) => x.ID === 300);
247
- if (!setting) {
248
- this.onErrorCallback(ErrorMessages.resumeNotAllowed)
249
- return;
250
- }
251
- }
252
- }
253
229
  var serverUrl =
254
- this.config?.prepareWSSURL(_filetype, _noteparams, jobName, jobId, parentJobId, inheritParentConfig) || "";
230
+ this.config?.prepareWSSURL(_filetype, _noteparams, jobName, jobId) || "";
255
231
  if (!this.recorderIns) {
256
232
  this.initRecorder(serverUrl);
257
233
  }
@@ -276,7 +252,7 @@ export class AugnitoAmbient {
276
252
  * @param JobIds to delete one or more notes
277
253
  * @returns success response on successful delete of notes else fail response
278
254
  */
279
- public async deleteNotes(JobIds: string[], DeleteParent?: boolean): Promise<any> {
255
+ public async deleteNotes(JobIds: string[]): Promise<any> {
280
256
  try {
281
257
  if (!this._ambientRestAPI) {
282
258
  Logger.error("SDK not initialized", this._logTag);
@@ -286,7 +262,7 @@ export class AugnitoAmbient {
286
262
  // this.onErrorCallback(ErrorMessages.noInternetConnection);
287
263
  // return;
288
264
  // }
289
- var responseJson = await this._ambientRestAPI.DeleteNotes(JobIds, DeleteParent);
265
+ var responseJson = await this._ambientRestAPI.DeleteNotes(JobIds);
290
266
  if (responseJson) {
291
267
  if (responseJson.Status === 200) {
292
268
  this.recorderIns?.stopAudio(false, true);
@@ -814,7 +790,7 @@ export class AugnitoAmbient {
814
790
  errorInfo.ErrorCode = ErrorCodes.SDK06
815
791
  } else if (errorInfo.ErrorMessage?.includes(ErrorMessages.micMuted)) {
816
792
  errorInfo.ErrorCode = ErrorCodes.SDK07
817
- // this.recorderIns?.stopAudio(false, true);
793
+ this.recorderIns?.stopAudio(false, true);
818
794
  } else if (errorInfo.ErrorMessage?.includes(ErrorMessages.audioUnplugged)) {
819
795
  errorInfo.ErrorCode = ErrorCodes.SDK08
820
796
  } else if (errorInfo.ErrorMessage?.includes(ErrorMessages.invalidSubscription) || errorInfo.ErrorMessage?.includes(ErrorMessages.invalidRequest)) {
@@ -827,8 +803,6 @@ export class AugnitoAmbient {
827
803
  errorInfo.ErrorCode = ErrorCodes.SDK13
828
804
  } else if (errorInfo.ErrorMessage?.includes(ErrorMessages.feedbackNotEnabled)) {
829
805
  errorInfo.ErrorCode = ErrorCodes.SDK14
830
- } else if (errorInfo.ErrorMessage?.includes(ErrorMessages.resumeNotAllowed)) {
831
- errorInfo.ErrorCode = ErrorCodes.SDK15
832
806
  }
833
807
  if (this.onError) {
834
808
  this.onError(errorInfo);
@@ -24,7 +24,7 @@ export class AmbientRestAPI extends BaseAPI {
24
24
  return await this.makePostRequest(url, requestData);
25
25
  }
26
26
 
27
- async ListJobs(_pageSize: number, _pageId?: string, _collapse?: boolean): Promise<any> {
27
+ async ListJobs(_pageSize: number, _pageId?: string): Promise<any> {
28
28
  Guard.Against.NullOrEmpty(_pageSize, "Page Size");
29
29
  const url = this.getURL("/list-jobs");
30
30
  const requestData = {
@@ -33,7 +33,6 @@ export class AmbientRestAPI extends BaseAPI {
33
33
  UserTag: this._config.userTag,
34
34
  PageSize: _pageSize,
35
35
  PageID: _pageId,
36
- Collapse: _collapse
37
36
  };
38
37
  return await this.makePostRequest(url, requestData);
39
38
  }
@@ -64,7 +63,7 @@ export class AmbientRestAPI extends BaseAPI {
64
63
  return await this.makePostRequest(url, requestData);
65
64
  }
66
65
 
67
- async DeleteNotes(_jobIds: string[], _deleteParent?: boolean): Promise<any> {
66
+ async DeleteNotes(_jobIds: string[]): Promise<any> {
68
67
  Guard.Against.NullOrEmpty(_jobIds, "Job Id");
69
68
  const url = this.getURL("/delete-job");
70
69
  const requestData = {
@@ -72,7 +71,6 @@ export class AmbientRestAPI extends BaseAPI {
72
71
  AccessKey: this._config.accessKey,
73
72
  UserTag: this._config.userTag,
74
73
  JobIDs: _jobIds,
75
- DeleteParent: _deleteParent
76
74
  };
77
75
  return await this.makePostRequest(url, requestData);
78
76
  }
@@ -23,7 +23,6 @@ export enum ErrorCodes {
23
23
  SDK12 = "SDK12",
24
24
  SDK13 = "SDK13",
25
25
  SDK14 = "SDK14",
26
- SDK15 = "SDK15",
27
26
  ERRUNKNOWN = "ERRUNKNOWN",
28
27
  }
29
28
 
@@ -15,9 +15,7 @@ export class socketConfig {
15
15
  _filetype: string,
16
16
  _noteparams: string,
17
17
  jobName?: string,
18
- jobId?: string,
19
- parentJobId?: string,
20
- inheritParentConfig?: boolean
18
+ jobId?: string
21
19
  ): string {
22
20
  let WSSURL = this.wssBaseURL;
23
21
  WSSURL += `?filetype=${_filetype}`;
@@ -31,12 +29,6 @@ export class socketConfig {
31
29
  if (jobId && jobId !== "") {
32
30
  WSSURL += `&jobid=${jobId}`;
33
31
  }
34
- if (parentJobId && parentJobId !== "") {
35
- WSSURL += `&parentjobid=${parentJobId}`;
36
- }
37
- if (inheritParentConfig !== undefined) {
38
- WSSURL += `&inheritparentconfig=${inheritParentConfig}`;
39
- }
40
32
  return WSSURL;
41
33
  }
42
34
  }
@@ -24,5 +24,4 @@ export const ErrorMessages = {
24
24
  noInternetConnection: 'Internet is not available. Try again later.',
25
25
  feedbackNotEnabled: 'Feedback is not enabled. Please contact administrator for more details.',
26
26
  transcriptionNotEnabled: 'Automatic Transcription is not enabled for the organisation',
27
- resumeNotAllowed: 'Resume job is not enabled for the organisation',
28
27
  }
package/tsconfig.json CHANGED
@@ -28,9 +28,9 @@
28
28
  // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
29
29
 
30
30
  /* Modules */
31
- "module": "esnext" /* Specify what module code is generated. */,
31
+ "module": "ESNext" /* Specify what module code is generated. */,
32
32
  // "rootDir": "./", /* Specify the root folder within your source files. */
33
- "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
33
+ "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
34
34
  // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
35
35
  // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
36
36
  // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
@@ -59,7 +59,6 @@
59
59
  // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
60
60
  // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
61
61
  "outDir": "./dist" /* Specify an output folder for all emitted files. */,
62
- "rootDir": "src",
63
62
  // "removeComments": true, /* Disable emitting comments. */
64
63
  "noEmit": false /* Disable emitting files from a compilation. */,
65
64
  "importHelpers": true /* Allow importing helper functions from tslib once per project, instead of including them per-file. */,