testaugnitosdk2 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/augnitosdk.js +36 -41
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/augnitosdk.js
CHANGED
|
@@ -8553,37 +8553,51 @@ var Streamer = /* @__PURE__ */ function() {
|
|
|
8553
8553
|
this.closeSocketWithoutEOS = false;
|
|
8554
8554
|
this.shouldPreIntialiseRecorder = shouldPreIntialiseRecorder !== null && shouldPreIntialiseRecorder !== void 0 ? shouldPreIntialiseRecorder : false;
|
|
8555
8555
|
if (this.shouldPreIntialiseRecorder) {
|
|
8556
|
-
this.
|
|
8556
|
+
this.InitialiseMediaStream();
|
|
8557
8557
|
}
|
|
8558
8558
|
}
|
|
8559
8559
|
return _createClass(Streamer2, [{
|
|
8560
|
-
key: "
|
|
8560
|
+
key: "InitialiseMediaStream",
|
|
8561
8561
|
value: function() {
|
|
8562
|
-
var
|
|
8562
|
+
var _InitialiseMediaStream = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
|
|
8563
8563
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
8564
8564
|
while (1) switch (_context.prev = _context.next) {
|
|
8565
8565
|
case 0:
|
|
8566
8566
|
_context.next = 2;
|
|
8567
8567
|
return this.createMediaStreamSourceNode();
|
|
8568
8568
|
case 2:
|
|
8569
|
-
|
|
8569
|
+
if (this.source) {
|
|
8570
|
+
_context.next = 5;
|
|
8571
|
+
break;
|
|
8572
|
+
}
|
|
8573
|
+
console.error("Error: unable to create source node");
|
|
8574
|
+
return _context.abrupt("return", false);
|
|
8575
|
+
case 5:
|
|
8576
|
+
_context.next = 7;
|
|
8570
8577
|
return this.createProcessorNode();
|
|
8571
|
-
case
|
|
8578
|
+
case 7:
|
|
8579
|
+
if (this.processorNode) {
|
|
8580
|
+
_context.next = 10;
|
|
8581
|
+
break;
|
|
8582
|
+
}
|
|
8583
|
+
console.error("Error: unable to create processor node");
|
|
8584
|
+
return _context.abrupt("return", false);
|
|
8585
|
+
case 10:
|
|
8572
8586
|
this.source.connect(this.processorNode).connect(this.audioContext.destination);
|
|
8573
|
-
|
|
8587
|
+
this.log("AudioContext Sample Rate: " + this.audioContext.sampleRate);
|
|
8574
8588
|
// if (this.audioContext && this.audioContext.state == "running") {
|
|
8575
8589
|
// await this.audioContext.suspend();
|
|
8576
8590
|
// }
|
|
8577
|
-
case
|
|
8591
|
+
case 12:
|
|
8578
8592
|
case "end":
|
|
8579
8593
|
return _context.stop();
|
|
8580
8594
|
}
|
|
8581
8595
|
}, _callee, this);
|
|
8582
8596
|
}));
|
|
8583
|
-
function
|
|
8584
|
-
return
|
|
8597
|
+
function InitialiseMediaStream() {
|
|
8598
|
+
return _InitialiseMediaStream.apply(this, arguments);
|
|
8585
8599
|
}
|
|
8586
|
-
return
|
|
8600
|
+
return InitialiseMediaStream;
|
|
8587
8601
|
}()
|
|
8588
8602
|
}, {
|
|
8589
8603
|
key: "StartStream",
|
|
@@ -8594,65 +8608,46 @@ var Streamer = /* @__PURE__ */ function() {
|
|
|
8594
8608
|
case 0:
|
|
8595
8609
|
this.log("New stream started...");
|
|
8596
8610
|
if (!(!this.shouldPreIntialiseRecorder || !this.source)) {
|
|
8597
|
-
_context2.next =
|
|
8611
|
+
_context2.next = 6;
|
|
8598
8612
|
break;
|
|
8599
8613
|
}
|
|
8600
8614
|
_context2.next = 4;
|
|
8601
|
-
return this.
|
|
8615
|
+
return this.InitialiseMediaStream();
|
|
8602
8616
|
case 4:
|
|
8603
|
-
if (this.source) {
|
|
8604
|
-
_context2.next = 7;
|
|
8605
|
-
break;
|
|
8606
|
-
}
|
|
8607
|
-
console.error("Error: unable to create source node");
|
|
8608
|
-
return _context2.abrupt("return", false);
|
|
8609
|
-
case 7:
|
|
8610
8617
|
_context2.next = 9;
|
|
8611
|
-
return this.createProcessorNode();
|
|
8612
|
-
case 9:
|
|
8613
|
-
if (this.processorNode) {
|
|
8614
|
-
_context2.next = 12;
|
|
8615
|
-
break;
|
|
8616
|
-
}
|
|
8617
|
-
console.error("Error: unable to create processor node");
|
|
8618
|
-
return _context2.abrupt("return", false);
|
|
8619
|
-
case 12:
|
|
8620
|
-
this.source.connect(this.processorNode).connect(this.audioContext.destination);
|
|
8621
|
-
this.log("AudioContext Sample Rate: " + this.audioContext.sampleRate);
|
|
8622
|
-
_context2.next = 19;
|
|
8623
8618
|
break;
|
|
8624
|
-
case
|
|
8619
|
+
case 6:
|
|
8625
8620
|
if (!(this.audioContext.state == "suspended")) {
|
|
8626
|
-
_context2.next =
|
|
8621
|
+
_context2.next = 9;
|
|
8627
8622
|
break;
|
|
8628
8623
|
}
|
|
8629
|
-
_context2.next =
|
|
8624
|
+
_context2.next = 9;
|
|
8630
8625
|
return this.audioContext.resume();
|
|
8631
|
-
case
|
|
8626
|
+
case 9:
|
|
8632
8627
|
if (!this.IsMicrophoneMuted) {
|
|
8633
|
-
_context2.next =
|
|
8628
|
+
_context2.next = 15;
|
|
8634
8629
|
break;
|
|
8635
8630
|
}
|
|
8636
8631
|
if (!(this.audioContext && this.audioContext.state == "running")) {
|
|
8637
|
-
_context2.next =
|
|
8632
|
+
_context2.next = 13;
|
|
8638
8633
|
break;
|
|
8639
8634
|
}
|
|
8640
|
-
_context2.next =
|
|
8635
|
+
_context2.next = 13;
|
|
8641
8636
|
return this.audioContext.suspend();
|
|
8642
|
-
case
|
|
8637
|
+
case 13:
|
|
8643
8638
|
this.onError(JSON.stringify({
|
|
8644
8639
|
Type: "ERROR",
|
|
8645
8640
|
Data: "Microphone is muted."
|
|
8646
8641
|
}));
|
|
8647
8642
|
return _context2.abrupt("return", false);
|
|
8648
|
-
case
|
|
8643
|
+
case 15:
|
|
8649
8644
|
if (wsUrl !== "") {
|
|
8650
8645
|
this.executor.Start(duration, wsUrl);
|
|
8651
8646
|
}
|
|
8652
8647
|
this.onStateChanged(true);
|
|
8653
8648
|
this.isStreaming = true;
|
|
8654
8649
|
return _context2.abrupt("return", true);
|
|
8655
|
-
case
|
|
8650
|
+
case 19:
|
|
8656
8651
|
case "end":
|
|
8657
8652
|
return _context2.stop();
|
|
8658
8653
|
}
|
package/dist/index.js
CHANGED
|
@@ -185,4 +185,4 @@ function H(){var e="object",t="undefined",n=["startContainer","startOffset","end
|
|
|
185
185
|
* Dissemination of this information or reproduction of this material
|
|
186
186
|
* is strictly forbidden unless prior written permission is obtained
|
|
187
187
|
* from ScribeTech India Healthcare Pvt ltd.
|
|
188
|
-
*/}function J(e){e.createModule("Util",["WrappedSelection"],(function(e,t){var n=e.rangePrototype,i=e.selectionPrototype;i.pasteText=function(e){this.deleteFromDocument();var t=this.getRangeAt(0),n=t.getDocument().createTextNode(e);t.insertNode(n),this.setSingleRange(t)},n.pasteText=function(e){this.deleteContents();var t=this.getDocument().createTextNode(e);this.insertNode(t)},i.pasteHtml=function(e){this.deleteFromDocument();var t=this.getRangeAt(0),n=this.createContextualFragment(e),i=n.lastChild;t.insertNode(n),i&&t.setStartAfter(i),this.setSingleRange(t)},n.pasteHtml=function(e){this.deleteContents();var t=this.createContextualFragment(e);this.insertNode(t)},i.selectNodeContents=function(t){var n=e.createRange(this.win);n.selectNodeContents(t),this.setSingleRange(n)},e.createRangeFromNode=function(t){var n=e.createRange(t);return n.selectNode(t),n},e.createRangeFromNodeContents=function(t){var n=e.createRange(t);return n.selectNodeContents(t),n},e.selectNodeContents=function(t){e.getSelection().selectNodeContents(t)},n.selectSelectedTextElements=function(){function t(t){return 1==t.nodeType&&"inline"==e.dom.getComputedStyleProperty(t,"display")}function n(e,n){var i=null,o=e.cloneRange();if(o.selectNode(n),""!==o.toString())for(;(n=n.parentNode)&&t(n)&&e.containsNodeText(n);)i=n;return i}return function(){var e=n(this,this.startContainer);e&&this.setStartBefore(e);var t=n(this,this.endContainer);t&&this.setEndAfter(t)}}()}))}W=V,Object.defineProperty(V,"processText",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i,o,r)=>{" ,"!==e&&" ."!==e||(e=e.trim())," \n"!==e&&" \n\n"!==e&&"\n"!==e&&"\n\n"!==e||(e=W.trimWithoutNewLine(e)),0!==i&&o||(e=W.capitalizeFirstLetter(e,0),e=W.trimWithoutNewLine(e)),(t||n)&&(e=W.capitalizeFirstLetter(e,0),t||(e=W.trimWithoutNewLine(e)));var a=e.trim();return a.length>0&&("."===a[0]||":"===a[0])&&(e=W.trimWithoutNewLine(e)),r&&(e=W.trimWithoutNewLine(e)),e}}),Object.defineProperty(V,"ProcessText",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i)=>{new RegExp("^ ([.|:|,])(.*?)$","gis").exec(e)&&(e=W.lTrim(e))," ,"!=e&&" ."!=e||(e=e.trim())," \n"!=e&&" \n\n"!=e||(e=W.trimWithoutNewLine(e)),0==n&&(e=W.capitalizeFirstLetter(e,0),e=W.trimWithoutNewLine(e));var o=!1,r=!1,a=0;0==i.start&&(r=!0);for(var s=t,l=s.length-1;l>-1;l--){var c=s[l];if(null!=c){if("."==c||":"==c){o=!0;break}if("\r\n"==c||"\n"==c||"\r"==c||"\v"==c){r=!0;break}if(null!=c.trim()&&""!=c.trim())break;a++}}if(o){var u=W.capitalizeFirstLetter(e,0);u=W.trimWithoutNewLine(u),e=a>0||0==u.trim().length?u:" "+u}if(r){u=W.capitalizeFirstLetter(e,0);e=u=W.trimWithoutNewLine(u)}return a>0&&(e=W.trimWithoutNewLine(e)),{ReceivedText:e=W.replaceSpaceAfterNewline(e),EndLine:o||r}}}),Object.defineProperty(V,"trimWithoutNewLine",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if(!e)return e;return e=(e=(e=e.replace(/\n/gi,"@newline@")).trim()).replace(new RegExp("@newline@","gi"),"\n")}}),Object.defineProperty(V,"lTrim",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?e.replace(/^\s+/,""):e}),Object.defineProperty(V,"replaceSpaceAfterNewline",{enumerable:!0,configurable:!0,writable:!0,value:e=>e.replace(/\n +/g,"\n")}),window.EnableLog=!1;var Y,Z=function(){};Z.prototype.build=function(){const e=new H;return new z(e),new K(e),new X(e),new q(e),new J(e),e};class Q{}Object.defineProperty(Q,"NODE_ELEMENT",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(Q,"NODE_TEXT",{enumerable:!0,configurable:!0,writable:!0,value:3});class ee{}Y=ee,Object.defineProperty(ee,"linkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"br"}),Object.defineProperty(ee,"divLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"div"}),Object.defineProperty(ee,"paragraphLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"p"}),Object.defineProperty(ee,"listLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"li"}),Object.defineProperty(ee,"lineBreakElements",{enumerable:!0,configurable:!0,writable:!0,value:[Y.linkBreakElement,Y.divLinkBreakElement,Y.paragraphLinkBreakElement,Y.listLinkBreakElement]});class te extends G{constructor(e){super(e,"CommonContentEditableProcessor"),Object.defineProperty(this,"_augnitoRange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_editorDocument",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dynamicSelect",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"findLineBreakAtCursor",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t;if(null!=e)if(null!=e.previousSibling&&e.previousSibling.nodeType===Q.NODE_ELEMENT){if(ee.lineBreakElements.includes(e.localName))return!0}else{if(null!=e.previousSibling&&e.previousSibling.nodeType===Q.NODE_TEXT&&e.previousSibling.nodeValue&&e.previousSibling.nodeValue.length>0)return!1;if(e.previousElementSibling&&(null===(t=e.previousElementSibling)||void 0===t?void 0:t.nodeType)===Q.NODE_ELEMENT){const t=e.previousElementSibling;if(t&&ee.lineBreakElements.includes(t.localName))return!0}else if(null==e.previousSibling&&null==e.previousElementSibling&&(null!=e.parentElement||null!=e.parentNode)){const t=e.parentElement?e.parentElement:e.parentNode,n=t&&t.nodeType==Q.NODE_ELEMENT?t.localName:"";if(t&&ee.lineBreakElements.includes(n))return!0;if(t&&null!=t.previousSibling){if(t.previousSibling.nodeType===Q.NODE_TEXT&&t.previousSibling.nodeValue&&t.previousSibling.nodeValue.length>0)return!1;if(t.previousSibling.nodeType===Q.NODE_ELEMENT&&ee.lineBreakElements.includes(t.previousSibling.localName))return!0}const i=t&&t.nodeType==Q.NODE_ELEMENT?t.previousElementSibling:null;if(i&&ee.lineBreakElements.includes(i.localName))return!0;if(null!=i)return!1;if(null!=t)return this.findLineBreakAtCursor(t)}}return!1}}),Object.defineProperty(this,"findLineBreakAtNextCursor",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t;if(null!=e)if(null!=e.nextSibling&&e.nextSibling.nodeType===Q.NODE_ELEMENT){if(ee.lineBreakElements.includes(e.nextSibling.localName))return!0}else{if(null!=e.nextSibling&&e.nextSibling.nodeType===Q.NODE_TEXT&&e.nextSibling.nodeValue&&e.nextSibling.nodeValue.length>0)return!1;if(null!=e.nextElementSibling&&(null===(t=e.nextElementSibling)||void 0===t?void 0:t.nodeType)===Q.NODE_ELEMENT){const t=e.nextElementSibling;if(t&&ee.lineBreakElements.includes(t.localName))return!0}else if(null==e.nextSibling&&null==e.nextElementSibling&&(null!=e.parentElement||null!=e.parentNode)){const t=e.parentElement?e.parentElement:e.parentNode,n=t&&t.nodeType==Q.NODE_ELEMENT?t.localName:"";if(n&&ee.lineBreakElements.includes(n))return!0;if(t&&null!=t.nextSibling){if(t.nextSibling.nodeType===Q.NODE_TEXT&&t.nextSibling.nodeValue&&t.nextSibling.nodeValue.length>0)return!1;if(t.nextSibling.nodeType===Q.NODE_ELEMENT&&ee.lineBreakElements.includes(t.nextSibling.localName))return!0}const i=t&&t.nodeType==Q.NODE_ELEMENT?t.nextElementSibling:null;if(i&&ee.lineBreakElements.includes(i.localName))return!0;if(null!=i)return!1;if(null!=t)return this.findLineBreakAtNextCursor(t)}}return!1}}),this._augnitoRange=(new Z).build(),this.validateDependencies()}processFinalResult(e,t){if(!this.validateEditorDocument(t)||!this._editorDocument)return;if(this.onBeforeProcess(e))return;let n=e.receivedText||"";n=n.replace(/\n/gi,"@newline@");let i=!1,o=!1,r=!1,a=!1;this.deleteSelection(null);const s=this._augnitoRange.getSelection(this._editorDocument);if(!s||0===s.rangeCount)return;const l=s.getRangeAt(0),c=l.cloneRange(),u=l.startOffset;n=n.replace(new RegExp("@newline@","gi"),"\n");const d=this.findLastChar(this._editorDocument);a=d.cursorInSameLine,o=""==d.lastImmediateChar.trim(),i=d.isLastFullStop,r=d.isLastNewLine,s.removeAllRanges(),s.addRange(c),n=V.processText(n,i,r,u,a,o),this.insertTextAtCursor(this._editorDocument,n)}processCommand(e,t){if(this.validateEditorDocument(t)&&this._editorDocument&&!(this.onBeforeProcess(e)||e.action&&this.customCommandProcessor&&this.customCommandProcessor(e.action)))if(e.action===r.SPACE_ADD)this.insertTextCallback(this._editorDocument," ",!0);else if(e.action===r.SELECT_ALL)if(this.customActionProcessor)this.customActionProcessor(e.action);else{const e=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0),t=this._editorDocument.activeElement&&this._editorDocument.activeElement.firstElementChild?this._editorDocument.activeElement.firstElementChild.firstChild:null;t&&e.setStart(t,0);const n=this._editorDocument.activeElement&&this._editorDocument.activeElement.lastElementChild?this._editorDocument.activeElement.lastElementChild.lastChild:null;n&&e.setEnd(n,n.textContent?n.textContent.length:0),this._augnitoRange.getSelection(this._editorDocument).removeAllRanges(),this._augnitoRange.getSelection(this._editorDocument).addRange(e)}else if(!e.action&&e.name===r.SELECT&&this.customSelectProcessor&&this.customSelectProcessor({searchText:e.searchText||"",selectFor:e.selectFor||""}));else if(e.action&&0===e.action.indexOf(r.SELECT)||0===e.name.indexOf(r.SELECT)){this.deSelectSelection(this._editorDocument,!1,!0),e.name=e.name.replace(r.SELECT,""),e.chooseNumber=e.chooseNumber?e.chooseNumber:0;const t={name:e.name,chooseNumber:e.chooseNumber||0};this.processSelect(Object.assign(Object.assign({},e),t),this._editorDocument),e.selectFor&&e.selectFor!==r.SELECT&&this.deSelectSelection(this._editorDocument)}else if(e.action&&r.NEXT_FIELD===e.action.toLowerCase()){const e={caseSensitive:!1,wholeWordsOnly:!1,direction:"forward"};this.deSelectSelection(this._editorDocument,!1,!0),this.searchDynamicFiled(e);const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}else if(e.action&&r.PREVIOUS_FIELD===e.action.toLowerCase()){const e={caseSensitive:!1,wholeWordsOnly:!1,direction:"backward"};this.deSelectSelection(this._editorDocument,!0,!0),this.searchDynamicFiled(e);const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}else if(e.action&&r.DESELECT_IT===e.action.toLowerCase())this.deSelectSelection(this._editorDocument,!1,!0);else if(e.action&&this.processSelectForAction(e.action,this._editorDocument));else if(e.action===r.GO_TO_LINE_START){const e=this.traverseTextNodes("character",-1,["\n"],!1,this._editorDocument,!0);e.rangeAfterProcess&&this.setSelectionRange(this._editorDocument,e.rangeAfterProcess)}else if(e.action===r.GO_TO_LINE_END){const e=this.traverseTextNodes("character",1,["\n"],!1,this._editorDocument,!0);e.rangeAfterProcess&&(null!=e.rangeAfterProcess.endContainer.nodeValue&&e.rangeAfterProcess.endContainer.nodeValue.length!==e.rangeAfterProcess.endOffset&&e.rangeAfterProcess.setStartAndEnd(e.rangeAfterProcess.endContainer,e.rangeAfterProcess.endContainer.nodeValue.length),this.setSelectionRange(this._editorDocument,e.rangeAfterProcess))}else if(e.name===r.GOTO){const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText+":",i={caseSensitive:!1,wholeWordsOnly:!1};t.findText(n,i)&&(t.collapse(!1),t.setStartAndEnd(t.endContainer,t.endOffset),this.setSelectionRange(this._editorDocument,t))}}}insertTextAtCursor(e,t){const n=t.split("\n");if(n.length>0)for(let t=0;t<n.length;t++){""!==n[t]&&this.insertTextCallback(e,n[t],!1);n.length>1&&!(t===n.length-2&&""===n[n.length-1]||t===n.length-1&&""!==n[t])&&this.insertTextCallback(e,"\n",!1)}}findLastChar(e){const t=this.traverseTextNodes("character",-1,[" ","\n"],!0,e);this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(t.rangeBeforeProcess);const n={lastChar:t.lastChar,cursorInSameLine:t.isCursorInSameLine,isLastFullStop:!1,isLastNewLine:!1,lastImmediateChar:t.lastImmediateChar};return""!==t.lastChar&&("."===t.lastChar||":"===t.lastChar?n.isLastFullStop=!0:"\r\n"!==t.lastChar&&"\n"!==t.lastChar&&"\r"!==t.lastChar||(n.isLastNewLine=!0)),n}processSelect(e,t){e.searchText||(e.searchText="");const n=e.searchText.replace(/ /gi,"").toLowerCase().trim(),i=e.nextPrevious,o=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;if(!e.name)return this.log("warning. attempt to process select but recipe has no name"),!1;if("nextword"===n||"next"===i){return this.getNextInterval(e.name,o,t)&&e.selectFor&&this.processSelectForAction(e.selectFor,t,!0),!0}if("previousword"===n||"it"===n||"that"===n||"previous"===i||"last"===i){return this.getPrevInterval(e.name,o,t)&&e.selectFor&&this.processSelectForAction(e.selectFor,t,!0),!0}return!1}processSelectForAction(e,t,n){const i=this._augnitoRange.getSelection(t).getRangeAt(0),o=i.cloneRange();if(i.startOffset===i.endOffset&&i.endContainer===i.startContainer&&this.getPrevInterval("word",1,t),this.customActionProcessor)return setTimeout((function(e,t,n,i){if(e&&e.customActionProcessor){var o=e.customActionProcessor(t);i&&t!==r.SELECT?e.deSelectSelection(n,!1,!0):o||t===r.SELECT||e.deSelectSelection(n,!1,!0)}}),100,this,e,t,n),!0;let a=!1;return"bold"===e.toLowerCase()||r.BOLD_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Bold",t),a=!0):"italicize"===e.toLowerCase()||r.ITALICIZE_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Italic",t),a=!0):"underline"===e.toLowerCase()||r.UNDERLINE_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Underline",t),a=!0):"capitalize"===e.toLowerCase()||r.CAPITALIZED_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Uppercase",t),a=!0):r.DELETE!==e.toLowerCase()&&"deleteit"!==e.toLowerCase()&&r.PRESS_DELETE!==e.toLowerCase()||(this.deleteSelection(t),a=!0),a||this.setSelectionRange(t,o),a}onBeforeProcess(e){if(null==this._editorDocument||!e.receivedTextWithoutSpace)return!1;if(!this._dynamicSelect)return!1;const t=parseInt(e.receivedTextWithoutSpace,10),n=t-1;if(isNaN(t)||n>this._dynamicSelect.length)return this.removeDynamicSelect(),!1;const i=this._dynamicSelect.getBadge(n).range;this.setSelectionRange(this._editorDocument,i),this._dynamicSelect.selectFor&&(this.processSelectForAction(this._dynamicSelect.selectFor,this._editorDocument,!0),this.deSelectSelection(this._editorDocument)),this.removeDynamicSelect();const o=this._augnitoRange.getSelection(this._editorDocument);return this.scrollElementToView(o),!0}removeDynamicSelect(){this._dynamicSelect&&(this._dynamicSelect.removeBadges(),this._dynamicSelect=null)}getLastLines(e,t){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),null;const n=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0);var i=$(n.nativeRange.startContainer).closest("p")[0];if(i||(i=$(n.nativeRange.startContainer).closest("li")[0]),null==i)return null;const o=this._augnitoRange.createRange(this._editorDocument);if(1===e)if(0===n.startOffset){const t=this.getLastLinesRecursive(0,e,i);o.setStart(t,0);const n=i.previousSibling?i.previousSibling:i,r=i.previousSibling?i.previousSibling.childNodes.length:0;o.setEnd(n,r)}else o.selectNodeContents(i);else{const t=0===n.startOffset?0:1,r=this.getLastLinesRecursive(t,e,i);if(o.setStart(r,0),0===n.startOffset){const e=i.previousSibling?i.previousSibling:i,t=i.previousSibling?i.previousSibling.childNodes.length:0;o.setEnd(e,t)}else o.setEnd(i,i.childNodes.length)}return this._augnitoRange.getSelection(t).removeAllRanges(),this._augnitoRange.getSelection(t).addRange(o),o}getLastLinesRecursive(e,t,n){if(e===t)return n;if(n.previousSibling){const i=this.isListElement(n.previousSibling)&&n.previousSibling.lastChild?n.previousSibling.lastChild:n.previousSibling;return this.getLastLinesRecursive(e+1,t,i)}if(n.parentElement&&this.isListElement(n.parentElement)){const i=n.parentElement.previousSibling;if(!i||!i.lastChild)return n.parentElement;const o=this.isListElement(i)?i.lastChild:i;return this.getLastLinesRecursive(e+1,t,o)}return n}isListElement(e){if(e.nodeType==Q.NODE_ELEMENT){const t=e.tagName;return"UL"===t||"OL"===t}return!1}getNextInterval(e,t,n){return"word"===e?this.getNextWordInterval(t,n):null}getPrevInterval(e,t,n){return"word"===e?this.getPrevWordInterval(t,n):"line"===e?this.getLastLines(t,n):null}getNextWordInterval(e,t){let n;""!==this.traverseTextNodes("character",1,1,!0,t).lastChar.trim()&&(n=this.traverseTextNodes("character",-1,[" ","\n",",",":",";","."],!1,t,!1),n.rangeAfterProcess&&this.setSelectionRange(t,n.rangeAfterProcess)),n=this.traverseTextNodes("word",1,e,!1,t,!1);const i=this._augnitoRange.createRange(t);return n.rangeAfterProcess&&(i.setEnd(n.rangeAfterProcess.endContainer,n.rangeAfterProcess.endOffset),i.setStart(n.rangeBeforeProcess.startContainer,n.rangeBeforeProcess.startOffset)),this.setSelectionRange(t,i),i}getPrevWordInterval(e,t){let n;""!==this.traverseTextNodes("character",-1,1,!0,t).lastChar.trim()&&(n=this.traverseTextNodes("character",1,[" ","\n",",",":",";","."],!1,t,!1),n.rangeAfterProcess&&this.setSelectionRange(t,n.rangeAfterProcess)),n=this.traverseTextNodes("word",-1,e,!1,t,!1);const i=this._augnitoRange.createRange(t);return n.rangeAfterProcess&&(i.setEnd(n.rangeBeforeProcess.endContainer,n.rangeBeforeProcess.endOffset),i.setStart(n.rangeAfterProcess.startContainer,n.rangeAfterProcess.startOffset)),this.setSelectionRange(t,i),i}deSelectSelection(e,t,n){if(null==this._editorDocument)return void this.error("missing editor document. Make sure to provide a non null Document type");if(this.customActionProcessor&&!n)return;const i=this._augnitoRange.getSelection(e).getRangeAt(0);t?i.setEnd(i.startContainer,i.startOffset):i.setStart(i.endContainer,i.endOffset),this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(i)}searchDynamicFiled(e){if(null==this._editorDocument)return void this.error("missing editor document. Make sure to provide a non null Document type");const t=this._augnitoRange.createRange(this._editorDocument);t.selectNodeContents(this._editorDocument.body);const n=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0);e.withinRange=n;t.findText(/\[(.*?)\]/gi,e)&&(t.setStart(t.startContainer,t.startOffset),t.setEnd(t.endContainer,t.endOffset),this.setSelectionRange(this._editorDocument,t))}deleteSelection(e){null!=this._editorDocument?null==e?this._augnitoRange.getSelection(this._editorDocument).deleteFromDocument():e.execCommand("delete"):this.error("missing editor document. Make sure to provide a non null Document type")}setSelectionRange(e,t){this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(t)}insertTextCallback(e,t,n){const i=this._augnitoRange.getSelection(e);if(!i||0===i.rangeCount)return;let o=i.getRangeAt(0);if(o){if("\n"===t)if(this.customLineBreakFunction)this.customLineBreakFunction();else if(e!==document.getRootNode()){const t=e.createElement(ee.linkBreakElement),n=e.createElement(ee.linkBreakElement),i=e.createTextNode("");null!=o.endContainer.nextElementSibling&&o.endContainer.nextElementSibling.localName===ee.linkBreakElement||o.insertNode(n),o.insertNode(i),o.insertNode(t),o.setStartAndEnd(i,0),this._augnitoRange.getSelection(e).setSingleRange(o)}else{const t=o.cloneRange(),n=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,keyCode:13});if(e.activeElement&&e.activeElement.dispatchEvent(n),o=this._augnitoRange.getSelection(e).getRangeAt(0),o.endContainer===t.endContainer&&o.endOffset===t.endOffset){const t=e.createElement(ee.divLinkBreakElement),n=e.createElement(ee.divLinkBreakElement),i=e.createTextNode("");null!=o.endContainer.nextElementSibling&&o.endContainer.nextElementSibling.localName===ee.divLinkBreakElement||o.insertNode(n),o.insertNode(i),o.insertNode(t),o.setStartAndEnd(i,0),this._augnitoRange.getSelection(e).setSingleRange(o)}}else if(this.customTextWriteFunction&&!n)this.customTextWriteFunction(t);else{const n=e.createTextNode(t);o.insertNode(n);const i=n.nodeValue?n.nodeValue.length:0;o.setStartAndEnd(n,i),this._augnitoRange.getSelection(e).setSingleRange(o)}this.scrollElementToView(i)}}scrollElementToView(e){try{var t=e.getRangeAt(0).endContainer;t instanceof HTMLElement?t.scrollIntoView(!0):t instanceof Text&&t.parentElement&&t.parentElement.scrollIntoView(!0)}catch(e){console.log(e)}}traverseTextNodes(e,t,n,i,o,r){const a=this._augnitoRange.getSelection(o).getRangeAt(0),s=a.cloneRange();let l,c=!0,u="",d="",h=-1;for(;0!==h;){let s=!1,g=a;const f=g.cloneRange();if(0===g.endOffset&&t<0?(s=this.findLineBreakAtCursor(g.endContainer),s&&(s=!0,c=!1)):t>0&&g.endContainer.nodeType===Q.NODE_TEXT&&g.endOffset===g.endContainer.length&&(s=this.findLineBreakAtNextCursor(g.endContainer),s&&(s=!0,c=!1)),"object"==typeof n&&s&&n.includes("\n")){l=g;break}if(h=g.move(e,t),g=a,l=f.cloneRange(),g.endOffset===f.endOffset&&g.endContainer===f.endContainer)break;const p=this._augnitoRange.createRange(o);if(t<0)p.setEnd(f.endContainer,f.endOffset),p.setStart(g.endContainer,g.endOffset);else{if(!(t>0))break;p.setEnd(g.endContainer,g.endOffset),p.setStart(f.endContainer,f.endOffset)}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(p);const m=this._augnitoRange.getSelection(o);if(0===m.rangeCount)continue;const v=m.getRangeAt(0);if(u=v.toString(),""==d&&(d=u),0===v.endOffset&&t<0?(s=this.findLineBreakAtCursor(v.endContainer),s&&(s=!0,c=!1)):t>0&&v.endContainer.nodeType===Q.NODE_TEXT&&v.endOffset===v.endContainer.length&&(s=this.findLineBreakAtNextCursor(v.endContainer),s&&(s=!0,c=!1)),r?t>0?l.setStartAndEnd(f.endContainer,f.endOffset):t<0&&l.setStartAndEnd(f.startContainer,f.startOffset):t>0?l.setStartAndEnd(v.endContainer,v.endOffset):t<0&&l.setStartAndEnd(v.startContainer,v.startOffset),"number"==typeof n){let e;if(e=i?u.split(" "):u.split(" ").filter((function(e){return""!==e&&":"!==e&&";"!==e&&"."!==e})),(n-=e.length)<=0)break}else{if("object"!=typeof n)break;if(!/^[\u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/.test(u)&&""!==u){if(!i&&n.includes(u))break;if(i&&!n.includes(u))break}if(s&&n.includes("\n"))break}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(l),0===h&&(c=!1)}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(s);return{rangeBeforeProcess:s,rangeAfterProcess:l,isCursorInSameLine:c,lastChar:u,lastImmediateChar:d}}static findActiveEditor(e){if(e instanceof HTMLIFrameElement||"iframe"===e.localName||"frame"===e.localName){let t;const n=e.contentWindow,i=n?n.document.activeElement:null;return t=i&&(i instanceof HTMLIFrameElement||"iframe"===i.localName||"frame"===i.localName)?this.findActiveEditor(i):i,t||e}return e}validateEditorDocument(e){return null==e?(this.error("Unable to add content. Must provide an editor of type Element or Document"),!1):(this._editorDocument=e.ownerDocument,null!=this._editorDocument||(this.error("invalid editor: unable to determine the owner document. An Child of Document element is required."),!1))}}class ne{constructor(e,t,n){Object.defineProperty(this,"_ranges",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_selectFor",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"badges",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.badges=[],this.createBadgesFromRanges(e)}removeBadges(){for(let e=0;e<this.badges.length;e++){const t=this.badges[e].badge;t.parentNode&&t.parentNode.removeChild(t)}}getBadge(e){return this.badges[e]}get selectFor(){return this._selectFor}get length(){return this.badges.length}createBadgesFromRanges(e){var t;for(let n=0;n<this._ranges.length;n++){const i=this._ranges[n],o=i.nativeRange.getClientRects();if(o&&1===o.length){const r=this.createBadge(n,o[0],(null===(t=e.scrollingElement)||void 0===t?void 0:t.scrollTop)||0);e.body.append(r),this.badges.push({badge:r,range:i})}}}createBadge(e,t,n){const i=document.createElement("div");return i.innerHTML=(e+1).toString(),i.contentEditable="false",i.style.position="absolute",i.style.top=t.top-18+n+"px",i.style.left=t.left-9+"px",i.style.width="24px",i.style.lineHeight="1.4",i.style.textAlign="center",i.style.backgroundColor="#313e48",i.style.color="#ffffff",i}}class ie extends te{validateDependencies(){if("undefined"==typeof CKEDITOR)throw"CKEditor Lib not found. Please add references to your project"}get editorType(){return v.CKEDITOR4}customLineBreakFunction(){const e=this.findInstance();e&&e.execCommand("enter")}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);return o.length>1?this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor):1===o.length&&(this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument))),!0}return!1}customCommandProcessor(e){let t=!1;const n=this.getEditor();return n&&("bulletliststart"!=e||this.CKEditorPanelButtonEnable("bulletedlist")?"numberliststart"!=e||this.CKEditorPanelButtonEnable("numberedlist")?"bulletliststop"==e&&this.CKEditorPanelButtonEnable("bulletedlist")?(n.commands.bulletedlist.exec(),t=!0):"numberliststop"==e&&this.CKEditorPanelButtonEnable("numberedlist")&&(n.commands.numberedlist.exec(),t=!0):(n.commands.numberedlist.exec(),t=!0):(n.commands.bulletedlist.exec(),t=!0)),t}getEditor(){return this.findInstance()}findInstance(){var e;const t=CKEDITOR;let n=null;if(t)for(const i in t.instances)if(Object.prototype.hasOwnProperty.call(t.instances,i)){const o=t.instances[i];((null===(e=U.anchoredEditor)||void 0===e?void 0:e.anchoredElement)&&o.name===U.anchoredEditor.elementName||o.focusManager.hasFocus)&&(n=o)}return n}CKEditorPanelButtonEnable(e){const t="cke_button__"+e;let n=!1;const i=document.querySelector("."+t);if(i)for(let e=0;e<(null==i?void 0:i.classList.length);e++)"cke_button_on"===i.classList[e]&&(n=!0);return n}}class oe extends te{validateDependencies(){}get editorType(){return v.CKEDITOR5}customLineBreakFunction(){const e=this.findInstance();if(e){var t=e.commands.get("enter");null==t||t.execute()}}customTextWriteFunction(e){const t=this.findInstance();if(t){0==e.indexOf(" ")&&(e=e.replace(" "," "));var n=t.data.processor.toView(e),i=t.data.toModel(n);t.model.insertContent(i,t.model.document.selection)}}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);if(o.length>1)this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor);else if(1===o.length){this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument));const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}return!0}return!1}customCommandProcessor(e){let t=!1;const n=this.getEditor();if(n)if("bulletliststart"!=e||this.CKEditorPanelButtonEnable("Bulleted List"))if("numberliststart"!=e||this.CKEditorPanelButtonEnable("Numbered List")){if("bulletliststop"==e&&this.CKEditorPanelButtonEnable("Bulleted List")){var i;null==(i=n.commands.get("bulletedList"))||i.execute(),t=!0}else if("numberliststop"==e&&this.CKEditorPanelButtonEnable("Numbered List")){null==(o=n.commands.get("numberedList"))||o.execute(),t=!0}}else{var o;null==(o=n.commands.get("numberedList"))||o.execute(),t=!0}else null==(i=n.commands.get("bulletedList"))||i.execute(),t=!0;return t}customActionProcessor(e){let t=!1;const n=this.getEditor();if(n)if("bold"===(null==e?void 0:e.toLowerCase())||r.BOLD_IT===(null==e?void 0:e.toLowerCase()))null==(o=n.commands.get("bold"))||o.execute(),t=!0;else if("italicize"===(null==e?void 0:e.toLowerCase())||r.ITALICIZE_IT===(null==e?void 0:e.toLowerCase())){null==(o=n.commands.get("italic"))||o.execute(),t=!0}else if("underline"===(null==e?void 0:e.toLowerCase())||r.UNDERLINE_IT===(null==e?void 0:e.toLowerCase())){null==(o=n.commands.get("underline"))||o.execute(),t=!0}else if("capitalize"===(null==e?void 0:e.toLowerCase())||r.CAPITALIZED_IT===(null==e?void 0:e.toLowerCase()));else if(r.DELETE===(null==e?void 0:e.toLowerCase())||"deleteit"===(null==e?void 0:e.toLowerCase())||r.PRESS_DELETE===(null==e?void 0:e.toLowerCase())){var i=n.commands.get("delete");null==i||i.execute(),t=!0}else if(r.SELECT_ALL===(null==e?void 0:e.toLowerCase())){var o;null==(o=n.commands.get("selectAll"))||o.execute(),t=!0}return t}getEditor(){return this.findInstance()}getActiveEditorElement(){let e=U.getActiveEditorElement();if(e){const t=te.findActiveEditor(e);t&&(e=t)}return e}findInstance(){let e=null;var t=this.getActiveEditorElement();t&&t.classList.contains("ck-editor__editable")&&(e=Object.getOwnPropertyDescriptors(t).ckeditorInstance.value);return e}CKEditorPanelButtonEnable(e){const t='[data-cke-tooltip-text="'+e+'"]';let n=!1;const i=document.querySelector(t);if(i)for(let e=0;e<(null==i?void 0:i.classList.length);e++)"ck-on"===i.classList[e]&&(n=!0);return n}}class re extends G{constructor(e){super(e,"DevExpressRichEditProcessor"),Object.defineProperty(this,"searchWordList",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get editorType(){return v.DEVEXPRESS}processFinalResult(e,t){var n,i=t;i.beginUpdate(),i.history.beginTransaction(),this.searchWordList=[],y(i);var o=i.selection.activeSubDocument,r=i.selection.intervals[0],a=this.GetLastCharacter(i),s=V.ProcessText(e.receivedText,a,o.length,r);e.receivedText=s.ReceivedText,r.length>0&&(i._native.core.commandManager.getCommand(125).execute(!1),r.length=0,i.selection.setSelection(r));var l=null===(n=e.receivedText)||void 0===n?void 0:n.split("\n");if(l&&l.length>0)for(var c=0;c<l.length;c++){""!=l[c]&&("."==l[c].trim()||":"==l[c].trim()?i._native.core.commandManager.getCommand(117).execute(!1,l[c].trim()):i._native.core.commandManager.getCommand(117).execute(!1,l[c])),l.length>1&&!(c==l.length-2&&""==l[l.length-1]||c==l.length-1&&""!=l[c])&&i._native.core.commandManager.getCommand(116).execute(!1)}this.ApplyPostBeautification(e,s.EndLine,i),i.history.endTransaction(),i.endUpdate()}processCommand(e,t){var n,i,o,a,s,l,c,u,d,h=t.selection.anchor,g=t.selection.intervals,f=t.document.subDocuments._core.commandManager,p=g[0],m=NaN,v=this.searchWordList;if(this.searchWordList=[],null!=e.searchText&&(m=parseInt(e.searchText.trim())),y(t),e.action===r.SPACE_ADD)t._native.core.commandManager.getCommand(117).execute(!1," "),p.start=h+1,p.length=0,t.selection.setSelection(p);else if(r.SELECT==(null===(n=e.name)||void 0===n?void 0:n.toLowerCase())&&"all"==(null===(i=e.searchText)||void 0===i?void 0:i.toLowerCase())&&"delete"==(null===(o=e.selectFor)||void 0===o?void 0:o.toLowerCase()))t._native.core.commandManager.getCommand(106).execute(!1,void 0),t._native.core.commandManager.getCommand(126).execute(!1);else if(r.SELECT==(null===(a=e.name)||void 0===a?void 0:a.toLowerCase())&&""==e.action||!isNaN(m))if(!isNaN(m)&&null!=v&&v.length>0){var b=v.filter((t=>{var n;return t.HighlightButton.innerHTML==(null===(n=e.searchText)||void 0===n?void 0:n.trim())}));b.length>0&&t.selection.setSelection(b[0].WordInterval)}else this.searchWordList=function(e,t){var n,i=N(e,t,"");if(1==i.length)return y(t),void t.selection.setSelection(i[0]);i=i.sort((function(e,t){return e.start-t.start}));var o=document.querySelectorAll(".dxreSelSearch"),r=[];if(o.length>0)for(var a=0;a<o.length;a++){var s=o[a],l=document.createElement("button");l.innerHTML=a+1,l.style.position="absolute",l.style.zIndex=9e3,l.style.left=(s.offsetLeft+s.offsetWidth/2-12.5).toString()+"px",l.style.top=(s.offsetTop-21).toString()+"px",l.style.width=25..toString()+"px",l.style.height=21..toString()+"px",l.style.backgroundColor="teal",l.style.color="white",l.className="searchIndex",l.disabled=!0,null===(n=document.querySelector(".dxreControl"))||void 0===n||n.querySelectorAll(".dxrePageService")[0].appendChild(l),r.push({HighlightButton:l,WordInterval:i[a]})}return r}(e,t);else if(e.action==r.SELECT)!function(e,t){var n;e.searchText||(e.searchText="");var i=e.searchText.replace(/ /gi,"").toLowerCase().trim(),o=e.nextPrevious,r=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;if("nextword"==i||"next"==o)return _(e.name,r,t)&&e.selectFor&&A(e.selectFor,t),!0;if("previousword"==i||"it"==i||"that"==i||"previous"==o||"last"==o){var a=L(null!==(n=e.name)&&void 0!==n?n:"",r,t);return a&&e.selectFor&&("delete"==e.selectFor.toLowerCase()&&a[0].start>0&&(a=O(a,t),t.selection.setSelection(a[0])),A(e.selectFor,t)),!0}}(e,t),e.selectFor&&((p=t.selection.intervals[0]).start=p.start+p.length,p.length=0,t.selection.setSelection(p));else if(e.action&&e.action.toLowerCase().indexOf("dynamic")>=0)R(e,t);else if("bulletliststart"==(null===(s=e.action)||void 0===s?void 0:s.toLowerCase())||"bulletliststop"==(null===(l=e.action)||void 0===l?void 0:l.toLowerCase()))j("togglebulletedlistitem",t);else if("deselectit"==(null===(c=e.action)||void 0===c?void 0:c.toLowerCase())){(p=t.selection.intervals[0]).start=p.start+p.length,"\r"==t.selection.activeSubDocument.getText().substr(p.start-1,1)&&(p.start=p.start-1),p.length=0,t.selection.setSelection(p)}else{if(A(null!==(u=e.action)&&void 0!==u?u:"",t))return;if(e.action){var E=T[null===(d=e.action)||void 0===d?void 0:d.toLowerCase().trim()];if(null!=E&&null!=E)f.getCommand(E).execute(!1,void 0)}}}GetLastCharacter(e){for(var t=[],n=0,i=e.selection,o=i.intervals[0].start,r=o-4,a=o,s=i.activeSubDocument.getText().length,l=r;l<a;l++)t[n]=l<0||l>=s?null:i.activeSubDocument.getText().substr(l,1),n++;return t}ApplyPostBeautification(e,t,n){var i,o,r,a,s=n.selection,l=n.selection.intervals,c=s.activeSubDocument.getText().length,u=l[0].start;if(!(u>=c)){var d,h,g=(null===(i=e.name)||void 0===i?void 0:i.endsWith("."))||(null===(o=e.receivedText)||void 0===o?void 0:o.endsWith(".")),f=(null===(r=e.name)||void 0===r?void 0:r.endsWith("\n"))||(null===(a=e.receivedText)||void 0===a?void 0:a.endsWith("\n")),p=g||f,m=l[0];if(u<c){var v=m.start;if(m.start=u,m.length=1,n.selection.setSelection(m),d=l){var b=n.selection.activeSubDocument.getText(),E=b.substr(d[0].start,d[0].length),S="";if(d[0].start+1<c&&(S=n.selection.activeSubDocument.getText(d[0])),E&&E.trim().length>0||"\r"==S||"\v"==S){t&&(E=E.toLowerCase()),p&&(E=E.toUpperCase()),"\r"!=S&&"\v"!=S||(m.start=m.start+1,E=(E=b.substr(d[0].start,d[0].length)).toUpperCase(),n.selection.setSelection(m)),"\r"!=E&&n._native.core.commandManager.getCommand(125).execute(!1);var C=(f||"\r"==S||"\v"==S||[",",".",":"].includes(S)?"":" ")+E,T=s.anchor;n.selection.setSelection(T),n._native.core.commandManager.getCommand(117).execute(!1,C),m.start=T+C.length+1,m.length=1;var R=n.document.getCharacterProperties(m);return m.start=T,m.length=C.length,n.document.setCharacterProperties(m,R),"\r"!=S&&"\v"!=S||(m.start=m.start-1,m.length=0,n.selection.setSelection(m)),m.start=v,m.length=0,void n.selection.setSelection(m)}m.start=d[0].start,m.length=0,n.selection.setSelection(m)}}if(u+1<c&&(m.start=u+1,m.length=1,n.selection.setSelection(m),h=l)){var y=n.selection.activeSubDocument.getText().substr(h[0].start,h[0].length);if(y&&y.trim().length>0){if(y.length>1)return;t&&(y=y.toLowerCase());S=n.selection.activeSubDocument.getText(h[0]);(p||"\v"==S)&&(y=y.toUpperCase()),n._native.core.commandManager.getCommand(125).execute(!1);T=s.anchor;n.selection.setSelection(T),n._native.core.commandManager.getCommand(117).execute(!1,y),m.start=T+y.length+1,m.length=1;R=n.document.getCharacterProperties(m);if(m.start=T,m.length=y.length,n.document.setCharacterProperties(m,R),m.start=h[0].start-1,m.length=0,s.setSelection(m),f&&u<c&&(m.start=u,m.length=1,n.selection.setSelection(m),d=l)){var N=s.activeSubDocument.getText().substr(d[0].start,d[0].length);N&&0==N.trim().length&&"\r"!=N&&n._native.core.commandManager.getCommand(125).execute(!1)}return m.start=h[0].start,m.length=0,void n.selection.setSelection(m)}m.start=h[0].start-1,m.length=0,n.selection.setSelection(m)}}}}class ae extends te{constructor(){super(...arguments),Object.defineProperty(this,"insertTextAtCursorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}validateDependencies(){}get editorType(){return v.GENERIC}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);return o.length>1?this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor):1===o.length&&(this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument))),!0}return!1}customCommandProcessor(e){return!1}}class se extends G{constructor(e){super(e,"HTMLInteropProcessor"),Object.defineProperty(this,"_buffer",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"stringWriteAtCaret",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i)=>{const o=e.substring(0,n);let r=e.substring(n);r.length>0&&t[0]===t[0].toUpperCase()&&!t.endsWith(". ")&&!t.endsWith(".")&&r[0]===r[0].toUpperCase()&&(r=r[0].toLowerCase()+r.substring(1)),e=o+t+r,i.value=e;const a=o.length+t.length;this.setCaretPosition(a,i),this.fireEvents(i)}})}get buffer(){return this._buffer}get editorType(){return v.HTML}processFinalResult(e,t){t.focus();const n=V.beautify(e.receivedText||"");this.isTextSelected(t)&&this.deleteSelected(t);const i=this.getCaretPosition(t),o=this.beautify(n,i,t.value);this.stringWriteAtCaret(t.value,o,i,t)}processCommand(e,t){t.focus();const n=this.getCaretPosition(t),i=t.value;let o=!1;if(e.action===r.PRESS_DELETE)this.isTextSelected(t)||(e.name=r.SELECT_WORD,this.selectWordLineSentence(e,i,n,t)),this.deleteSelected(t),o=!0;else if(e.name===r.SELECT_WORD)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.name===r.SELECT_LINE)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.action===r.SELECT_ALL)t.setSelectionRange(0,t.value.length),o=!0;else if(e.name===r.SELECT_SENTENCE)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.action===r.GO_TO_LINE_START)this.setCaretPosition(this.getStartOfLine(i,n),t),o=!0;else if(e.action===r.GO_TO_DOCUMENT_START)this.setCaretPosition(0,t),o=!0;else if(e.action===r.GO_TO_DOCUMENT_END)this.setCaretPosition(i.length,t),o=!0;else if(e.action===r.GO_TO_LINE_END){const e=this.getEndOfLine(i,n);this.setCaretPosition(e,t),o=!0}else e.action===r.COPY_IT?(this.copySelected(t),o=!0):e.action===r.UNDO_IT?(this.undo(),this.setCaretPosition(t.selectionEnd||t.value.length,t),o=!0):e.action===r.REDO_IT?(this.redo(),o=!0):e.action===r.DOCUMENT_PRINT?(this.print(),o=!0):e.action===r.SPACE_ADD?(this.stringWriteAtCaret(i," ",n,t),o=!0):e.action===r.NEXT_FIELD?this.searchDynamicFiled("forward",i,t):e.action===r.PREVIOUS_FIELD?this.searchDynamicFiled("backward",i,t):this.log("Command NOT Processed");return o}selectWordLineSentence(e,t,n,i){let o=i.value.length,a=e.nextPrevious;a||(a="previous");let s=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;const l=t.length===n;if("next"===a)n=Math.max(n,i.selectionEnd||i.value.length);else if("previous"===a||"last"===a){const e=this.getCaretPosition(i);n=Math.min(n,e-1)}let c=n;const u=this.getDelimiterArray(e);if("next"===a){const e=!0;for(;e;){if(n>t.length){n=t.length;break}if(t[n]===u[0])n++;else{if(!(u.length>1&&t[n]===u[1]))break;n++}}c=n,o=n;let i=!1;for(let e=n;e-1>=0&&!1===i;e--)for(const n of u)if(t[e-1]===n){c=e,i=!0;break}i||(c=0);for(let e=n;e<t.length&&s>0;e++,o++)for(const n of u)t[e]===n&&s--;s>0&&(o=t.length)}else if("previous"===a||"last"===a){const i=!0;for(;i;){if(n<0){n=0;break}if(t[n]===u[0])n--;else{if(!(u.length>1&&t[n]===u[1]))break;n--}}c=n,o=n;let a=!1;for(let e=n;e<t.length&&!1===a;e++)for(const n of u)if(t[e]===n){o=e+1,a=!0;break}a||(o=t.length);for(let e=n;e>=0&&s>0;e--,c--){for(const n of u)t[e]===n&&s--;if(0===s){c=e+1;break}}s>0&&(c=0),c>0&&"delete"===e.selectFor&&d.setSelectObjectType(e.searchText||"")===r.SELECT_WORD&&l&&c--}i.setSelectionRange(c,o)}getDelimiterArray(e){let t=[];return e.name===r.SELECT_WORD||e.name===r.SELECT_ACTIVE_WORD?t=[" ","\n"]:e.name===r.SELECT_LINE||e.name===r.SELECT_ACTIVE_LINE?t=["\n"]:e.name!==r.SELECT_SENTENCE&&e.name!==r.SELECT_ACTIVE_SENTENCE||(t=["."]),t}isTextSelected(e){return e.selectionStart!==e.selectionEnd}deleteSelected(e){const t=this.getCaretPosition(e);document.execCommand("delete",!1,void 0),this.setCaretPosition(t,e)}getSelectedText(e){const t=e.value,n=e.selectionStart,i=e.selectionEnd;return n&&i?t.substring(n,i):""}copySelected(e){this._buffer=this.getSelectedText(e),document.execCommand("copy")}undo(){document.execCommand("undo")}redo(){document.execCommand("redo")}print(){window.print()}getStartOfLine(e,t){for(let n=t;n>=0;n--)if(n===t&&"\n"===e[n]&&n--,"\n"===e[n])return n+1;return 0}getEndOfLine(e,t){for(let n=t;n<e.length;n++)if("\n"===e[n])return n;return e.length}beautify(e,t,n){let i=e;if(""===n&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1))," \n"!==i&&" \n\n"!==i||(i=this.trimLeft(i)),n.length>1&&(" "===n[t-1]&&"."===n[t-2]||0===t)&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1)),n.length>0&&" "===n[t-1]&&(i=this.trimLeft(i)),n.length>0&&"\n"===n[t-1]&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1)),n.length>0&&("."===n[t-1]||":"===n[t-1]||"#"===n[t-1])){const e=this.trimLeft(i);e.length>0&&(i=" "+e[0].toUpperCase()),e.length>1&&(i+=e.substring(1))}"."!==i.trim()&&":"!==i.trim()||(i=this.trimLeft(i));var o=i.trim();return o.length>0&&("."===o[0]||":"===o[0])&&(i=this.trimLeft(i)),i}trimLeft(e){return e=(e=(e=e.replace(/\n/gi,"@newline@")).trimStart()).replace(new RegExp("@newline@","gi"),"\n")}setCaretPosition(e,t){t.setSelectionRange(e,e)}fireEvents(e){const t=new KeyboardEvent("keyup",{bubbles:!0,cancelable:!0,keyCode:13});e.dispatchEvent(t);const n=new Event("input",{bubbles:!0,cancelable:!0});e.dispatchEvent(n)}getCaretPosition(e){return null===e.selectionStart?e.value?e.value.length:0:e.selectionStart}searchDynamicFiled(e,t,n){if(null!==n.selectionStart&&null!==n.selectionEnd)switch(e){case"forward":this.searchDynamicFieldForward(n.selectionEnd,t,n);break;case"backward":this.searchDynamicFieldBackward(n.selectionStart,t,n)}}searchDynamicFieldForward(e,t,n){const i=/\[(.*?)\]/gi;let o;const r=t.substring(e);null!==(o=i.exec(r))&&n.setSelectionRange(o.index+e,i.lastIndex+e)}searchDynamicFieldBackward(e,t,n){const i=/\[(.*?)\]/gi;let o;const r=t.substring(0,e);let a=-1,s=-1;for(;null!==(o=i.exec(r));)a=o.index,s=i.lastIndex;-1!==a&&-1!==s&&n.setSelectionRange(a,s)}}class le{static createProcessor(e,t){switch(e){case v.HTML:return new se(t);case v.CKEDITOR4:return new ie(t);case v.CKEDITOR5:return new oe(t);case v.DEVEXPRESS:return new re(t);case v.GENERIC:return new ae(t);default:throw new TypeError(`Processor for editor ${e} not implemented`)}}}class ce{constructor(e,t,n){Object.defineProperty(this,"_listOfControls",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_editorType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_interopProcessors",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"ProcessorHandler"}),n&&this.getProcessor(n)}getProcessorForEditor(e){if(this._editorType==v.DEVEXPRESS)return this.getProcessor(this._editorType);if(e.id){const t=this._listOfControls.find((t=>t.controlId==e.id));if(this._listOfControls.length>0&&t&&t.type)return this.getProcessor(t.type)}if(this.isHtmlEditor(e))return this.getProcessor(v.HTML);if(this.isContentEditable(e)&&this._editorType)return this.getProcessor(this._editorType);throw new Error("Editor not implemented: Unknown contentEditable")}getValidEditor(){const e=this.getActiveEditorElement();return e?this._editorType===v.DEVEXPRESS||this.isValidEditor(e)?e:(a.log("unable to validate the provided editor. Has focus ? Is it on the list of control ? has and id set ?",this._logTag),null):(a.log("unable to find a focused editor",this._logTag),null)}getActiveEditorElement(){if(this._listOfControls&&this._listOfControls.length>0&&this._listOfControls[0].editorInstance)return this._listOfControls[0].editorInstance;let e=U.getActiveEditorElement();if(e){const t=te.findActiveEditor(e);t&&(e=t)}return e}isValidEditor(e){if(this._listOfControls.length>0&&e.id){const t=e.id;return void 0!==this._listOfControls.find((e=>e.controlId===t))}return!!this.isHtmlEditor(e)||!(!this.isContentEditable(e)||!this._editorType)}getProcessor(e){let t=this._interopProcessors.find((t=>t.editorType===e));return t||(t=le.createProcessor(e,this._enableLogs),this._interopProcessors.push(t),t)}isHtmlEditor(e){return"TEXTAREA"===e.nodeName||"INPUT"===e.nodeName}isContentEditable(e){return e.isContentEditable}}class ue{constructor(e,t,n){Object.defineProperty(this,"_listOfControls",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_editor",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"processorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.processorHandler=new ce(e,t,n)}onFinalResult(e){const t=this.processorHandler.getValidEditor();if(t){this.processorHandler.getProcessorForEditor(t).processFinalResult(e,t)}}onCommandResult(e){const t=this.processorHandler.getValidEditor();if(t){if(this.interfaceSharedCommand(e,t))return;this.processorHandler.getProcessorForEditor(t).processCommand(e,t)}}onSetAnchoredEditor(e,t){U.setAnchoredElement(e,t)}handleDynamicFieldNavigation(e){if(this._editor==v.DEVEXPRESS){const t=this.processorHandler.getValidEditor();R(e,t)}}handleGotoDocumentEnd(){const e=this.processorHandler.getValidEditor();var t;j("gotodocumentend",t=e),t.focus()}getCursorPosition(){return this.processorHandler.getValidEditor().selection.intervals[0].start}setCursorAtPosition(e){const t=this.processorHandler.getValidEditor();t.selection.setSelection(e),t.focus()}interfaceSharedCommand(e,t){if(e.name!==r.GOTO)return!1;if(e.searchText){const n=e.searchText.replace(/\s+/g,"");if("nextfield"===n||"nextfields"===n)U.moveToNextField(t,this._listOfControls);else if("previousfield"===n||"previousfields"===n)U.moveToPreviousField(t,this._listOfControls);else{const e=e=>e.controlName===n,t=this._listOfControls.findIndex(e);if(t>-1){const e=this._listOfControls[t];e&&document.querySelector("#"+e.controlId).focus()}}}return!0}}class de{constructor(e,t){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_webClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"onMicrophoneOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}get clientConfig(){return this._config}get enableLogs(){return this._config.enableLogs}setEnableLogs(e){this._config.enableLogs=e}get deviceId(){return this._webClient.getConfig().clientConfig.deviceId}get userTag(){return this._webClient.getConfig().clientConfig.userTag}startListening(e){this._webClient.startListening(this.prepareSpeechMicURL(e),n.MOBILE_APP)}stopListening(){this._webClient&&this._webClient.stopListening(!1)}prepareNotificationURL(){const e=this._webClient.getConfig();let t=e.pushNotificationURL;return t+=`?devicecode=${e.clientConfig.deviceId}`,t+=`¤tTabId=${E()}`,t+=`&accountcode=${e.clientConfig.accountCode}`,t+=`&accesskey=${e.clientConfig.accessKey}`,t=t.replace(new RegExp("amp;","gi"),""),t}prepareSpeechMicURL(e){const t=this._webClient.getConfig();let n=this._webClient.getConfig().speechMicURL;return n+=`?accountcode=${t.clientConfig.accountCode}`,n+=`&usertag=${t.clientConfig.userTag}`,n+=`&seqid=${e.SeqId}`,n+=`&mobiledevicecode=${e.FromDeviceId}`,n+=`&clientdevicecode=${t.clientConfig.deviceId}`,n=n.replace(new RegExp("amp;","gi"),""),n}}class he{constructor(e){Object.defineProperty(this,"_mobileClient",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"onConnectionRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMobileScan",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e.onConnectionRequest=this.onConnectionRequestCallback.bind(this),e.onMobileScan=this.onMobileScanCallback.bind(this)}dispose(){this._mobileClient.dispose()}stopMobileMicConnection(){this._mobileClient.stopMobileListening()}onConnectionRequestCallback(){this.onConnectionRequest&&this.onConnectionRequest()}onMobileScanCallback(){this.onMobileScan&&this.onMobileScan()}}function ge(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{l(i.next(e))}catch(e){r(e)}}function s(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class fe{makePostRequest(e,t){return ge(this,void 0,void 0,(function*(){try{const n=yield fetch(t,{method:"POST",headers:{accept:"*/*","Content-Type":"application/json"},body:JSON.stringify(e)}),i=yield n.json();return[200,0].includes(i.Status)?i:i.ErrorMessage}catch(e){return e instanceof Error?e.message:"Unknown Error"}}))}}class pe extends fe{constructor(e,t,n){super(),Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e,"AccountCode"),g.Against.NullOrEmpty(t,"AccessKey"),g.Against.NullOrEmpty(n,"Server"),this._baseUrl=`https://${n}/manage/v2/macro`}getMacros(e){return ge(this,void 0,void 0,(function*(){return yield this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/fetchall"))}))}upsertMacro(e){return ge(this,void 0,void 0,(function*(){return this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/modify"))}))}deleteMacro(e){return ge(this,void 0,void 0,(function*(){return this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/delete"))}))}getURL(e){return`${this._baseUrl}${e}`}getAccountModel(){return{AccountCode:this._accountCode,AccessKey:this._accessKey}}}function me(){me=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",l=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,i){var r=t&&t.prototype instanceof v?t:v,a=Object.create(r.prototype),s=new L(i||[]);return o(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var h="suspendedStart",g="suspendedYield",f="executing",p="completed",m={};function v(){}function b(){}function E(){}var S={};c(S,a,(function(){return this}));var C=Object.getPrototypeOf,T=C&&C(C(I([])));T&&T!==n&&i.call(T,a)&&(S=T);var R=E.prototype=v.prototype=Object.create(S);function y(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function N(e,t){function n(o,r,a,s){var l=d(e[o],e,r);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var r;o(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,o){n(e,i,t,o)}))}return r=r?r.then(o,o):o()}})}function O(t,n,i){var o=h;return function(r,a){if(o===f)throw Error("Generator is already running");if(o===p){if("throw"===r)throw a;return{value:e,done:!0}}for(i.method=r,i.arg=a;;){var s=i.delegate;if(s){var l=A(s,i);if(l){if(l===m)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(o===h)throw o=p,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);o=f;var c=d(t,n,i);if("normal"===c.type){if(o=i.done?p:g,c.arg===m)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(o=p,i.method="throw",i.arg=c.arg)}}}function A(t,n){var i=n.method,o=t.iterator[i];if(o===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,A(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var r=d(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,m;var a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function w(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 _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function I(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,r=function n(){for(;++o<t.length;)if(i.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return r.next=r}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=E,o(R,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:b,configurable:!0}),b.displayName=c(E,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,c(e,l,"GeneratorFunction")),e.prototype=Object.create(R),e},t.awrap=function(e){return{__await:e}},y(N.prototype),c(N.prototype,s,(function(){return this})),t.AsyncIterator=N,t.async=function(e,n,i,o,r){void 0===r&&(r=Promise);var a=new N(u(e,n,i,o),r);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(R),c(R,l,"Generator"),c(R,a,(function(){return this})),c(R,"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=I,L.prototype={constructor:L,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)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 o(i,o){return s.type="throw",s.arg=t,n.next=i,o&&(n.method="next",n.arg=e),!!o}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&i.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var r=o;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var a=r?r.completion:{};return a.type=e,a.arg=t,r?(this.method="next",this.next=r.finallyLoc,m):this.complete(a)},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),m},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),_(n),m}},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 o=i.arg;_(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:I(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),m}},t}function ve(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 be(e,t,n,i,o,r,a){try{var s=e[r](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,o)}function Ee(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var r=e.apply(t,n);function a(e){be(r,i,o,a,s,"next",e)}function s(e){be(r,i,o,a,s,"throw",e)}a(void 0)}))}}function Se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ce(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,ve(i.key),i)}}function Te(e,t,n){return t&&Ce(e.prototype,t),n&&Ce(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Re="DONE",ye="PAUSESOCKET",Ne="RESUMESOCKET",Oe="CLOSE",Ae=12e4,we=Te((function e(t,n,i,o,r,a,s,l,c,u,d,h){Se(this,e),this.worker,this.onFinalResultCallback=r,this.onErrorCallback=s,this.onPartialResultCallback=a,this.onSessionEventCallback=l,this.onOtherResultsCallback=c,this.onSpeechResponseCallback=u,this.packetSeqId=0,this.audioDuration=0,this.shouldSendAudioDataSequence=o,this.heavyOp,this.idleLoop,this.lastSent,this.enableLogs=t,this.eosMessage=n||"EOS",this.socketTimeoutInterval=i||1e4,this.bufferSizeInterval=d,this.switchToRegularSpeech=h}),[{key:"Start",value:function(e,t){var n=this;this.audioDuration=e;var i="\n (() => {\n (".concat(_e.toString(),")(").concat(JSON.stringify(Re),", ").concat(JSON.stringify(this.eosMessage),", ").concat(JSON.stringify(Oe),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(this.socketTimeoutInterval),", ").concat(JSON.stringify(1e3),", ").concat(JSON.stringify(100),", ").concat(JSON.stringify(t),", ").concat(JSON.stringify(this.enableLogs),", ").concat(JSON.stringify(this.shouldSendAudioDataSequence),",").concat(JSON.stringify(ye),", ").concat(JSON.stringify(Ne),", ").concat(JSON.stringify(this.switchToRegularSpeech),", ").concat(JSON.stringify(this.heavyOp),");\n })();\n");this.worker=new Worker(URL.createObjectURL(new Blob([i],{type:"application/javascript"}))),this.worker.onmessage=function(e){n.enableLogs&&console.log("Augnito [MAIN]: "+JSON.stringify(e.data));var t=e.data;"final"==t.type?n.onFinalResultCallback(t.data):"partial"==t.type?n.onPartialResultCallback(t.data):"meta"==t.type?n.onSessionEventCallback(t.data):"error"==t.type?n.onErrorCallback(t.data):"other"==t.type?n.onOtherResultsCallback(t.data):"speechResponse"==t.type&&n.onSpeechResponseCallback(t.data)},this.idleLoop=setInterval((function(){var e=+new Date;n.lastSent&&e-n.lastSent>Ae&&(n.Send(n.eosMessage),n.enableLogs&&console.warn("No data sent since more than ".concat(120," secs, closing time...")))}),1e4)}},{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),o=new Uint8Array(i);return o.set(new Uint8Array(e),0),o.set(new Uint8Array(t),e.byteLength),i}},{key:"Send",value:function(e){var t;if(this.lastSent=+new Date,e===Oe)null===(t=this.worker)||void 0===t||t.postMessage(Oe),clearInterval(this.idleLoop);else if(e===Re){if(this.shouldSendAudioDataSequence){var n,i=this.createAudioPacketHeader(!0);null===(n=this.worker)||void 0===n||n.postMessage(i)}else{var o;null===(o=this.worker)||void 0===o||o.postMessage(Re)}clearInterval(this.idleLoop)}else if(e==ye){var r;null===(r=this.worker)||void 0===r||r.postMessage(ye)}else if(e==Ne){var a;null===(a=this.worker)||void 0===a||a.postMessage(Ne)}else if(e===this.eosMessage){var s;this.shouldSendAudioDataSequence||null===(s=this.worker)||void 0===s||s.postMessage(e)}else{var l,c=[];this.shouldSendAudioDataSequence?(i=this.createAudioPacketHeader(!1),c=this.appendAudioData(i,e)):c=e,void 0!==c&&(null===(l=this.worker)||void 0===l||l.postMessage(c,[c]))}}},{key:"HeavyOp",set:function(e){this.heavyOp=e}}]);function _e(e,t,n,i,o,r,a,s,l,c,u,d,h,g){var f,p,m,v,b,E,S,C,T=[],R=[],y=!1,N=!1,O=!1,A="",w=!1;function _(){f=+new Date,(E=""!=A?new WebSocket(s+"&jobid="+A):new WebSocket(s)).onopen=function(e){l&&console.log("Augnito: WebSocket connection established - "+JSON.stringify(e)),R.length>0&&(N=!0)},E.onmessage=function(e){l&&console.log("Augnito: Message from server - "+JSON.stringify(e.data)),m=+new Date,function(e){try{if("PING"===e.data)v=+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&&(A=t.JobID,console.log("Augnito JobID:",A)),self.postMessage({type:"meta",data:e.data});var n=JSON.parse(e.data);O=!(!n.Event||"INVALID_AUTH_CREDENTIALS"!==n.Event.Type)}else if(t.Result&&t.Result.Final){var i=JSON.stringify(t.Result);g&&(i=g(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?(R=R.filter((function(e){return e.packetNumber>t.Index})),self.postMessage({type:"other",data:e.data})):"ERROR"==t.Type?("Timeout exceeded"==t.Data&&(y=!0,x()),self.postMessage({type:"error",data: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)),x()},p=+new Date,m=p,v=+new Date}function L(e){if(E&&E.readyState===WebSocket.OPEN){E.send(e);var n=+new Date;return p<=m&&(m=n-1),p=n,!0}return e===t?(l&&console.warn("Gulping ".concat(t," as socket seems already closed...")),x(),!0):(+new Date-f>i&&!O&&_(),!1)}function I(e){T.push(e)}function x(){y&&(clearInterval(S),clearInterval(C),T=[],R=[],self.close())}_(),S=setInterval((function(){if(N){for(var e=0;e<R.length;e++){if(!L(R[e].packetData))break}N=!1}else for(;T.length>0;){var t=T.shift();if(!L(t)){T.unshift(t);break}if(c){var n=new DataView(t),i={packetNumber:Number(n.getBigInt64(4)),packetData:t};R.push(i)}}}),a),C=setInterval((function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;(h?p>m&&e-m>o:e-v>o)&&(l&&console.error("No data received since more than ".concat(o/1e3," secs, closing time...")),E.close())}}),r),self.onmessage=function(i){i.data===n?(A="",y=!0,O=!0,E.close()):i.data===e?(I(t),A="",l&&console.log("Augnito: Worker received DONE, time to terminate..."),y=!0):i.data===u?w=!0:i.data===d?(I(b),w=!1,b=[]):w?b=i.data:I(i.data)}}var Le,Ie,xe,Pe,Me,De,ke,Be,Fe,je=Te((function e(t,n,i,o,r,a,s,l,c,u,d,h,g,f,p,m,v,b,E){Se(this,e),this.audioContext,this.audioStream,this.executor=new we(t,r,a,s,h,g,f,m,v,b,i,u),this.executor.HeavyOp=d,this.source,this.processorNode,this.isPaused=!1,this.isStreaming=!1,this.audioData=[],this.isDebug=n,this.enableLogs=t,this.onStateChanged=p,this.onIntensity=E,this.onError=f,this.bufferSizeInterval=i,this.pausedBufferInterval=null!=o?o:1,this.shouldReadIntensity=c,this.closeSocketWithoutEOS=!1,this.shouldPreIntialiseRecorder=null!=l&&l,this.shouldPreIntialiseRecorder&&this.EarlyInitialiseMediaStream()}),[{key:"EarlyInitialiseMediaStream",value:(Fe=Ee(me().mark((function e(){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createMediaStreamSourceNode();case 2:return e.next=4,this.createProcessorNode();case 4:this.source.connect(this.processorNode).connect(this.audioContext.destination);case 5:case"end":return e.stop()}}),e,this)}))),function(){return Fe.apply(this,arguments)})},{key:"StartStream",value:(Be=Ee(me().mark((function e(t,n){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.log("New stream started..."),this.shouldPreIntialiseRecorder&&this.source){e.next=16;break}return 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),e.next=19;break;case 16:if("suspended"!=this.audioContext.state){e.next=19;break}return e.next=19,this.audioContext.resume();case 19:if(!this.IsMicrophoneMuted){e.next=25;break}if(!this.audioContext||"running"!=this.audioContext.state){e.next=23;break}return e.next=23,this.audioContext.suspend();case 23:return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return",!1);case 25:return""!==n&&this.executor.Start(t,n),this.onStateChanged(!0),this.isStreaming=!0,e.abrupt("return",!0);case 29:case"end":return e.stop()}}),e,this)}))),function(e,t){return Be.apply(this,arguments)})},{key:"createBufferedSourceNode",value:(ke=Ee(me().mark((function e(){var t;return me().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 ke.apply(this,arguments)})},{key:"createMediaStreamSourceNode",value:(De=Ee(me().mark((function e(){var t,n=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!1}});case 3:this.audioStream=e.sent,this.audioContext=new AudioContext,this.source=this.audioContext.createMediaStreamSource(this.audioStream),this.audioStream.getAudioTracks()[0].addEventListener("ended",(function(){n.onError(JSON.stringify({Type:"ERROR",Data:"Audio track ended. Possibly the mic was unplugged."}))})),e.next=14;break;case 9:e.prev=9,e.t0=e.catch(0),t="","NotAllowedError"==e.t0.name?t="Mic permission denied":"NotFoundError"===e.t0.name&&(t="No suitable media device found"),this.onError(JSON.stringify({Type:"ERROR",Data:t}));case 14:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return De.apply(this,arguments)})},{key:"loadAudio",value:(Me=Ee(me().mark((function e(){var t,n,i;return me().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 Me.apply(this,arguments)})},{key:"createProcessorNode",value:(Pe=Ee(me().mark((function e(){var t,n=this;return me().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);\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,o=t.value;if(i==Re)n.log("Worklet processing done, clearing resources..."),n.isDebug&&n.saveAudio(),n.cleanup();else if(e.data==ye)n.executor.Send(ye);else{var r;"intensity"===i?null===(r=n.onIntensity)||void 0===r||r.call(n,o):"audioData"===i&&n.isDebug&&new Int16Array(o).forEach((function(e){n.audioData.length<=288e5&&n.audioData.push(e)}))}n.executor&&(n.closeSocketWithoutEOS?(n.executor.Send(Oe),n.closeSocketWithoutEOS=!1):"intensity"!==i&&n.executor.Send(o))},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 Pe.apply(this,arguments)})},{key:"PauseStream",value:(xe=Ee(me().mark((function e(){return me().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(ye);case 9:this.onStateChanged(!1),this.isPaused=!0,this.isStreaming=!1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return xe.apply(this,arguments)})},{key:"ResumeStream",value:(Ie=Ee(me().mark((function e(){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.shouldPreIntialiseRecorder||"suspended"!=this.audioContext.state){e.next=9;break}if(!this.IsMicrophoneMuted){e.next=4;break}return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return");case 4:return e.next=6,this.audioContext.resume();case 6:this.log("Stream resumed..."),e.next=11;break;case 9:this.processorNode.port.postMessage(Ne),this.executor.Send(Ne);case 11:this.onStateChanged(!0),this.isPaused=!1,this.isStreaming=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return Ie.apply(this,arguments)})},{key:"IsPaused",get:function(){return this.isPaused}},{key:"IsStreaming",get:function(){return this.isStreaming}},{key:"IsMicrophoneMuted",get:function(){return this.audioStream.getAudioTracks()[0].muted}},{key:"StopStream",value:(Le=Ee(me().mark((function e(t){var n,i,o,r;return me().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===(r=this.audioContext)||void 0===r?void 0:r.suspend();case 3:this.onStateChanged(!1);case 4:this.log("Stream stopped..."),this.isStreaming=!1,this.closeSocketWithoutEOS=!t,null===(i=this.processorNode)||void 0===i||null===(i=i.port)||void 0===i||i.postMessage("STOP"),null===(o=this.audioStream)||void 0===o||o.getAudioTracks()[0].removeEventListener("ended",(function(){}));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Le.apply(this,arguments)})},{key:"cleanup",value:function(){this.source.mediaStream.getAudioTracks()[0].stop(),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();console.log(e);var t=new Blob([e],{type:"audio/wav"});return console.log(t),t}},{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 o=0;o<t;o++)i.setInt8(44+o,e.getInt8(o));return i}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);console.log(t+"\n")}}}]),Ue=function(){function e(){var t,n,i,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,shouldPreIntialiseRecorder:!1,shouldReadIntensity:!1,debounceDelay:300,switchToRegularSpeechProfile:!1},r=arguments.length>1?arguments[1]:void 0;if(Se(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.heavyOp=r,this.bufferInterval=o.bufferInterval,this.pausedBufferInterval=o.pausedBufferInterval,this.eosMessage=o.EOS_Message,this.socketTimeoutInterval=o.socketTimeoutInterval,this.shouldSendAudioDataSequence=o.shouldSendAudioDataSequence,this.shouldPreIntialiseRecorder=o.shouldPreIntialiseRecorder,this.switchToRegularSpeechProfile=null!==(n=o.switchToRegularSpeechProfile)&&void 0!==n&&n,this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0),this.shouldReadIntensity=o.shouldReadIntensity,this.delay=null!==(i=o.debounceDelay)&&void 0!==i?i:300,this.toggleStartStopAudioStream=Ge(this.toggleStartStopAudioStream.bind(this),this.delay),this.togglePauseResumeAudioStream=Ge(this.togglePauseResumeAudioStream.bind(this),this.delay),e.instance=this}return Te(e,[{key:"initialiseStreamer",value:function(){this.streamer=new je(this.enableLogs,this.isDebug,this.bufferInterval,this.pausedBufferInterval,this.eosMessage,this.socketTimeoutInterval,this.shouldSendAudioDataSequence,this.shouldPreIntialiseRecorder,this.shouldReadIntensity,this.switchToRegularSpeechProfile,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))}},{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=Ee(me().mark((function e(t){return me().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=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(null!==(e=this.streamer)&&void 0!==e&&e.IsStreaming||i)&&(null===(t=this.streamer)||void 0===t||t.StopStream(n),this.streamer=null,this.log("Stream Stopped..."),this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0))}},{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(){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:"showLogCallback",value:function(e){this.showLog&&this.showLog(e)}}]);var t}();function Ge(e,t){var n;return function(){for(var i=this,o=arguments.length,r=new Array(o),a=0;a<o;a++)r[a]=arguments[a];n&&clearTimeout(n),n=setTimeout((function(){return e.apply(i,r)}),t)}}class We extends fe{constructor(e,t,n){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_notifSubscribedInOtherWindow",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"VocabularyAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_recorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_preventOverrun",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_overrunRecording",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_recordingStart",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_isRecording",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_stream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onVocabularyAdded",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e.SubscriptionCode,"SubscriptionCode"),g.Against.NullOrEmpty(e.AccessKey,"AccessKey"),g.Against.NullOrEmpty(e.Server,"Server"),g.Against.NullOrEmpty(e.UserCode,"UserCode"),g.Against.NullOrEmpty(e.DeviceCode,"DeviceCode"),g.Against.NullOrEmpty(e.SourceApp,"SourceApp"),g.Against.NullOrEmpty(e.SmId,"SmId"),this._baseUrl=`https://${e.Server}/db/speechapi`,this._notifSubscribedInOtherWindow||(this._notificationClient.ensureNotificationClientConnected(),this._notificationClient.onVocabularyAdded=this.onVocabularyAddedCallback.bind(this))}getVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting vocabulary for user"),yield this.makePostRequest({Request:Object.assign(Object.assign({},e),this.getGetCommonModel())},this.getURL("/get_user_prs_word"))}))}removeVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Removing vocabulary for user"),yield this.makePostRequest({Request:Object.assign(Object.assign({},this.getGetCommonModel()),e)},this.getURL("/remove_personal_word"))}))}upsertVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Upserting vocabulary for user"),this.makePostFormRequest(Object.assign(Object.assign({},e),this.getUpsertCommonModel()),this.getURL("/add_personal_word"))}))}startRecording(){return this.log("Starting recording for vocabulary"),new Promise(((e,t)=>{this._isRecording?(this.log("Already recording"),t("Already recording")):(this._isRecording=!0,this._recorder=new Ue({serverURL:"",enableLogs:!0,isDebug:!0,bufferInterval:1,EOS_Message:"EOS",socketTimeoutInterval:1e4}),this._recorder.startAudio(),this._recordingStart=(new Date).getTime(),this._preventOverrun=setTimeout((()=>{var e,t;this._overrunRecording=null===(e=this._recorder)||void 0===e?void 0:e.getBlob(),this.log("Recording overrun"),null===(t=this._recorder)||void 0===t||t.stopAudio()}),9e3),e())}))}stopRecording(){return this.log("stopping recording for vocabulary"),this._preventOverrun&&clearTimeout(this._preventOverrun),new Promise(((e,t)=>{if(this._recorder){this._isRecording=!1;let t=(new Date).getTime()-this._recordingStart;setTimeout((()=>{var n,i;if(t=(new Date).getTime()-this._recordingStart,this._overrunRecording){const t=this._overrunRecording;this._overrunRecording=void 0,this._recorder=void 0,null===(n=this._stream)||void 0===n||n.getAudioTracks()[0].stop(),e(t)}else{const t=this._recorder.getBlob();null===(i=this._recorder)||void 0===i||i.stopAudio(),this._recorder=void 0,e(t)}}),Math.max(0,1200-t))}else t("Recorder not started")}))}getURL(e){return`${this._baseUrl}${e}`}getGetCommonModel(){return{SubscriptionCode:this._config.SubscriptionCode,AccessKey:this._config.AccessKey,SmId:this._config.SmId,UserCode:this._config.UserCode}}getUpsertCommonModel(){return Object.assign(Object.assign({},this.getGetCommonModel()),{DeviceCode:this._config.DeviceCode,SourceApp:this._config.SourceApp})}onVocabularyAddedCallback(e){this.onVocabularyAdded&&this.onVocabularyAdded(e)}log(e){this._config.enableLogs&&a.log(e,this._logTag)}makePostFormRequest(e,t){return ge(this,void 0,void 0,(function*(){try{const n=new FormData;for(const[t,i]of Object.entries(e))n.append(t,i);const i=yield fetch(t,{method:"POST",headers:{accept:"*/*"},body:n}),o=yield i.json();return[200,0].includes(o.Status)?o:o.ErrorMessage}catch(e){return e instanceof Error?e.message:"Unknown Error"}}))}}class Ve extends fe{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"FormattingAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e.SubscriptionCode,"SubscriptionCode"),g.Against.NullOrEmpty(e.AccessKey,"AccessKey"),g.Against.NullOrEmpty(e.Server,"Server"),g.Against.NullOrEmpty(e.UserCode,"UserCode"),g.Against.NullOrEmpty(e.DeviceCode,"DeviceCode"),g.Against.NullOrEmpty(e.SourceApp,"SourceApp"),g.Against.NullOrEmpty(e.SmId,"SmId"),this._baseUrl=`https://${e.Server}/db/speechapi/fp`}getURL(e){return`${this._baseUrl}${e}`}getFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/get"))}))}upsertFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Upserting formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/modify"))}))}removeFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Removing formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/delete"))}))}log(e){this._config.enableLogs&&a.log(e,this._logTag)}getGetCommonModel(){return{SubscriptionCode:this._config.SubscriptionCode,AccessKey:this._config.AccessKey,SmId:this._config.SmId,UserTag:this._config.UserCode}}}class He extends fe{constructor(e,t,n,i,o){super(),Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_userTag",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"MedicineOrderingAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e,"AccountCode"),g.Against.NullOrEmpty(t,"AccessKey"),g.Against.NullOrEmpty(o,"Server"),this._baseUrl=`https://${o}/augnote/nlp`}getMedicineOrderData(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting Medicine Order for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getCommonModel()),this.getURL("/ordermedicine"))}))}getCommonModel(){return{SubscriptionCode:this._accountCode,AccessKey:this._accessKey,UserTag:this._userTag}}getURL(e){return`${this._baseUrl}${e}`}log(e){this._enableLogs&&a.log(e,this._logTag)}}class ze{constructor(e,t,n,i,o,r,a,s,l){Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_server",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_userTag",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_lmid",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_sourceApp",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:l})}getMacrosAPI(){return new pe(this._accountCode,this._accessKey,this._server)}getMedicineOrderingAPI(){return new He(this._accountCode,this._accessKey,this._userTag,this._enableLogs,this._server)}getFormattingAPI(){return new Ve({SubscriptionCode:this._accountCode,AccessKey:this._accessKey,Server:this._server,SmId:this._lmid,DeviceCode:this._deviceId,SourceApp:this._sourceApp,UserCode:this._userTag,enableLogs:this._enableLogs})}getVocabularyAPI(e=!1){return new We({SubscriptionCode:this._accountCode,AccessKey:this._accessKey,Server:this._server,SmId:this._lmid,DeviceCode:this._deviceId,SourceApp:this._sourceApp,UserCode:this._userTag,enableLogs:this._enableLogs},this._notificationClient,e)}}class Ke{get notificationSocket(){return this._pushNotificationSocket}constructor(e){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"NotificationClient"}),Object.defineProperty(this,"onConnectionRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMobileScan",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onVocabularyAdded",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pushNotificationSocket",{enumerable:!0,configurable:!0,writable:!0,value:null})}Send(e){var t;null===(t=this._pushNotificationSocket)||void 0===t||t.send(e)}ensureNotificationClientConnected(){null!=this.notificationSocket&&[WebSocket.OPEN,WebSocket.CONNECTING].includes(this.notificationSocket.readyState)||this.createNotificationClient()}createNotificationClient(){this.closeMobileWebSocket()||null!==this.notificationSocket&&this.notificationSocket.readyState===WebSocket.OPEN||(this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Connecting",this._logTag),this.createNotificationSocket(this._config.prepareNotificationURL()))}createNotificationSocket(e){this._pushNotificationSocket=new WebSocket(e),this._pushNotificationSocket.onmessage=e=>{var t,n;if(this._config.enableLogs&&a.log({message:"NOTIFICATION CLIENT: Message received",data:e},this._logTag),e.data){const i=JSON.parse(e.data);if(this._config.deviceId&&this._config.deviceId!==i.ToDeviceId)return void(this._pushNotificationSocket?this._pushNotificationSocket.send(this.getReplyMessage(i,"WRONG_DESTINATION")):a.error("push notification socket not created",this._logTag));"Type"in i&&("MOBILE_SCAN_SUCCESSFUL"===i.Type?this.onMobileScanCallback():"MIC_CONNECTION_REQUEST"===i.Type?this.onConnectionRequestCallback(i):"GENERAL_NOTIFICATION"===i.Type&&"Vocabulary"==(null===(n=null===(t=i.Data)||void 0===t?void 0:t.AppNotification)||void 0===n?void 0:n.SubType)&&this.onVocabularyAddedCallback(i.Data.AppNotification))}},this._pushNotificationSocket.onopen=()=>{this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Socket Opened.",this._logTag)},this._pushNotificationSocket.onclose=()=>{this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Socket Closed.",this._logTag),this._pushNotificationSocket=null},this._pushNotificationSocket.onerror=e=>{this._config.enableLogs&&a.log({message:"NOTIFICATION CLIENT: Socket Error: ",data:e},this._logTag),this._pushNotificationSocket=null}}closeMobileWebSocket(){return null!=this._pushNotificationSocket?(this._pushNotificationSocket.close(),this._pushNotificationSocket=null,!0):(this._config.stopListening(),!1)}dispose(){this.closeMobileWebSocket(),this._pushNotificationSocket=null}onMobileScanCallback(){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: MOBILE_SCAN_SUCCESSFUL",this._logTag),this.onMobileScan&&this.onMobileScan()}onVocabularyAddedCallback(e){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Vocabulary Added",this._logTag),this.onVocabularyAdded&&this.onVocabularyAdded(e)}onConnectionRequestCallback(e){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: MIC_CONNECTION_REQUEST",this._logTag),this.onConnectionRequest&&this.onConnectionRequest(e)}getReplyMessage(e,t){const n={FromDeviceId:this._config.deviceId||"",ToDeviceId:e.FromDeviceId,SeqId:E(),AckOf:e.SeqId,Type:t,TimeStamp:S()};return JSON.stringify(n)}}class Xe{constructor(e,t){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"PhilipsMicClient"}),Object.defineProperty(this,"intervalInMillis",{enumerable:!0,configurable:!0,writable:!0,value:100}),Object.defineProperty(this,"isRecodingIsPressed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"counter",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"WasMicStartedByPressToSpeak",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onPhilipsMicPressed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getConnectedPhilipsDeviceName",{enumerable:!0,configurable:!0,writable:!0,value:e=>-1!==e.toLowerCase().indexOf("911")&&-1!==e.indexOf("fa0")?"SpeechMike":-1!==e.toLowerCase().indexOf("911")&&-1!==e.indexOf("c1e")?(this._enableLogs&&a.log("SpeechOne detected",this._logTag),"SpeechOne"):-1===e.toLowerCase().indexOf("911")||-1===e.indexOf("1844")&&-1===e.indexOf("91a")?"":(this._enableLogs&&a.log("Footswitch detected",this._logTag),"Footswitch")}),Object.defineProperty(this,"gamepadCallBack",{enumerable:!0,configurable:!0,writable:!0,value:()=>{for(var e=navigator.getGamepads(),t=0;t<e.length;t++){var n=e[t];if(n){if(""===this.getConnectedPhilipsDeviceName(n.id))continue;n.buttons[5].pressed?this._config.philipsMicMode===b.HandsFree?this.isRecodingIsPressed=!0:(this._config.philipsMicMode===b.PushToTalk||(this.isRecodingIsPressed=!0),this.HandlePushToTalk()):this.isRecodingIsPressed&&!this.WasMicStartedByPressToSpeak?(this.isRecodingIsPressed=!1,this.counter=0,this.onPhilipsMicPressedCallback(void 0)):this.WasMicStartedByPressToSpeak&&(this.isRecodingIsPressed=!1,this.WasMicStartedByPressToSpeak=!1,this.counter=0,this.onPhilipsMicPressedCallback(!1))}}}}),setInterval(this.gamepadCallBack,this.intervalInMillis)}HandlePushToTalk(){5===this.counter?this.CheckForRECPressed():this.counter++}CheckForRECPressed(){this.WasMicStartedByPressToSpeak||(this.isRecodingIsPressed=!1,this.WasMicStartedByPressToSpeak=!0,this.counter=0,this.onPhilipsMicPressedCallback(!0))}onPhilipsMicPressedCallback(e){this._enableLogs&&a.log("PHILIPS_MIC_CONNECTION_REQUEST",this._logTag),this.onPhilipsMicPressed&&this.onPhilipsMicPressed(e)}}class qe{static addCommand(e,t,n){var i;let o={CommandName:e,CustomCallback:n,CustomCallbackParameter:t};null===(i=qe.dynamicList)||void 0===i||i.push(o)}static prepareCustomCommandRecipe(e){var t;let n=e.receivedText.replace(/\n/gi,r.NEXT_LINE_TEXT);n=n.replace(/ /gi,"").toLowerCase().trim(),n=n.replace(new RegExp(r.NEXT_LINE_TEXT,"gi"),"\n");const i={sessionCode:e.sessionCode,isCommand:e.isCommand,final:e.final,receivedText:e.receivedText,receivedTextWithoutSpace:n,action:e.action,name:n},o=null===(t=qe.dynamicList)||void 0===t?void 0:t.find((e=>e.CommandName.replace(/ /gi,"").toLowerCase().trim()===n));return o?o.CustomCallback?(o.CustomCallback(o.CustomCallbackParameter),null):Object.assign(Object.assign({},i),{isCustomCommand:!0}):i}}Object.defineProperty(qe,"dynamicList",{enumerable:!0,configurable:!0,writable:!0,value:[]});class Je{constructor(e){var t,n,i,o,r;Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"Augnito"}),Object.defineProperty(this,"_webClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sdkMobileConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_augnitoMobile",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_worker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isConnected",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"switchToRegularSpeechProfile",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"shouldPreInitialiseMic",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"forceStopAudio",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_factoryAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_editorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"recorderIns",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPartialResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinalResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onCommandResult",{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,"onSessionEvent",{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,"onMicrophoneOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enableLogs=null!==(t=e.enableLogs)&&void 0!==t&&t,this.shouldPreInitialiseMic=e.earlyInitialiseRecorder,this.switchToRegularSpeechProfile=null!==(n=e.switchToRegularSpeechProfile)&&void 0!==n&&n,this.config=this.createSDKConfig((e=>(g.Against.NullOrUndefined(e,"Config"),g.Against.NullOrEmpty(e.userTag,"UserTag"),g.Against.NullOrEmpty(e.lmId,"LmId"),g.Against.NullOrEmpty(e.accountCode,"AccountCode"),g.Against.NullOrEmpty(e.accessKey,"AccessKey"),g.Against.NullOrEmpty(e.sourceApp,"SourceApp"),g.Against.NullOrEmpty(p(e.server),"AugnitoAPIServer"),C(e),e.enableLogs=e.enableLogs||!1,e.deviceId=e.deviceId||E(),e))(e)),this._webClient=new s(this.config),this._sdkMobileConfig=new de(((e,t)=>(g.Against.NullOrUndefined(e,"WebClient"),g.Against.NullOrEmpty(e.getConfig().clientConfig.deviceId,"deviceId"),t.enableLogs=t.enableLogs||!1,t))(this._webClient,e||{}),this._webClient),this._notificationClient=new Ke(this._sdkMobileConfig),this._worker=this.createWorker(),this._editorHandler=new ue(e.listOfControls||[],this.enableLogs,e.editor),this._factoryAPI=new ze(e.accountCode,e.accessKey,p(e.server),e.userTag,e.lmId,e.deviceId,e.sourceApp,null!==(i=e.enableLogs)&&void 0!==i&&i,this._notificationClient),this.recorderIns=new Ue({serverURL:this.config.prepareSpeechURL(),enableLogs:null!==(o=e.enableLogs)&&void 0!==o&&o,isDebug:null!==(r=e.enableLogs)&&void 0!==r&&r,bufferInterval:1,pausedBufferInterval:e.pauseStateBufferInterval,EOS_Message:"EOS",socketTimeoutInterval:2e4,shouldSendAudioDataSequence:!1,shouldPreIntialiseRecorder:this.shouldPreInitialiseMic,debounceDelay:e.debounceDelay,switchToRegularSpeechProfile:e.switchToRegularSpeechProfile}),this.recorderIns.onError=this.onErrorCallback.bind(this),this.recorderIns.onPartialResult=this.onPartialResultsCallback.bind(this),this.recorderIns.onFinalResult=this.onSocketFinalResult.bind(this),this.recorderIns.onStateChanged=this.onStateChangeCallback.bind(this),this.recorderIns.onSessionEvent=this.onSessionEventCallback.bind(this),window.addEventListener("storage",this.handleStorageChangeEvent.bind(this)),window.addEventListener("beforeunload",this.handleBeforeUnloadEvent.bind(this))}toggleListening(e=!1){var t,n;a.log("toggleListening clicked",this._logTag),this.forceStopAudio=!1,this.isConnected||localStorage.getItem(o.KEY)!==o.ON?this._webClient&&this._webClient.connected?this._webClient.stopListening(!0):e||this.shouldPreInitialiseMic?null===(t=this.recorderIns)||void 0===t||t.togglePauseResumeAudioStream():null===(n=this.recorderIns)||void 0===n||n.toggleStartStopAudioStream():this.onMicrophoneOnErrorCallback(!0)}getQRCode(){var e;return null===(e=this.config)||void 0===e?void 0:e.qrCode}navigateToNextField(){var e={name:"",action:r.NEXT_FIELD,sessionCode:"",final:!1,isCommand:!1,receivedText:"",receivedTextWithoutSpace:"",chooseNumber:0,fontSize:0,nextPrevious:"",searchText:"",selectFor:"",isCustomCommand:!1};this._editorHandler.handleDynamicFieldNavigation(e)}navigateToPreviousField(){var e={name:"",action:r.PREVIOUS_FIELD,sessionCode:"",final:!1,isCommand:!1,receivedText:"",receivedTextWithoutSpace:"",chooseNumber:0,fontSize:0,nextPrevious:"",searchText:"",selectFor:"",isCustomCommand:!1};this._editorHandler.handleDynamicFieldNavigation(e)}getCursorPosition(){return this._editorHandler.getCursorPosition()}setCursorAtPosition(e){this._editorHandler.setCursorAtPosition(e)}setCursorAtDocumentEnd(){this._editorHandler.handleGotoDocumentEnd()}dispose(){this._augnitoMobile&&(this._augnitoMobile.dispose(),this._augnitoMobile=null),this._worker&&(this._worker.terminate(),this._worker=null),this.recorderIns&&(this.recorderIns.dispose(),this.recorderIns=null)}initMobileClient(e){var t;if(!this._webClient)throw new Error("augnito client not set");if(this._augnitoMobile)throw new Error("augnito mobile client has already been initialized");return this._sdkMobileConfig.setEnableLogs(null!==(t=null==e?void 0:e.enableLogs)&&void 0!==t&&t),this._sdkMobileConfig.onMicrophoneOnError=this.onMicrophoneOnErrorCallback.bind(this),this._augnitoMobile=new he(new l(this._sdkMobileConfig,this._notificationClient)),this._augnitoMobile}initPhilipMicClient(e){return new Xe(e,this.enableLogs)}requestMicOff(){var e;localStorage.getItem(o.KEY)===o.ON&&localStorage.setItem(o.KEY,o.REQUEST_OFF),this.stopAudio(),null===(e=this.recorderIns)||void 0===e||e.dispose()}addCustomCommand(e,t,n){qe.addCommand(e,t,n)}setAnchoredEditor(e,t){this._editorHandler.onSetAnchoredEditor(e,t)}get apisFactory(){return this._factoryAPI}get configuration(){return this.config?this.config:null}stopAudio(){var e;this._augnitoMobile&&this._augnitoMobile.stopMobileMicConnection();try{null===(e=this.recorderIns)||void 0===e||e.stopAudio(!0,!0)}catch(e){}}onPartialResultsCallback(e){this.enableLogs&&a.log({type:"onPartialResults",data:e},this._logTag),this.onPartialResult&&this.onPartialResult(e)}onFinalResultsCallback(e){this.enableLogs&&a.log({type:"FinalText",recipe:e},this._logTag),this.onFinalResult&&this.onFinalResult(e)||this._editorHandler.onFinalResult(e)}onCommandResultsCallback(e){this.enableLogs&&a.log({type:"Command",command:e},this._logTag),this.onCommandResult&&this.onCommandResult(e)||this.interfaceCommand(e)||this._editorHandler.onCommandResult(e)}interfaceCommand(e){return r.STOP_MIC===e.name&&(this.stopAudio(),!0)}onErrorCallback(t){this.enableLogs&&a.error({type:"onError",error:e.ERR_SERVER,data:t},this._logTag),(t.includes("Audio track ended. Possibly the mic was unplugged")||t.includes("Microphone is muted"))&&this.requestMicOff(),this.onError&&this.onError({Type:e.ERR_SERVER,Message:t,IsWebClient:!0}),this.isConnected=!1,localStorage.setItem(o.KEY,o.OFF)}onIdleMicCallback(){this.onIdleMic&&this.onIdleMic()}onStateChangeCallback(e){if(this.forceStopAudio)return this.stopAudio(),void(this.forceStopAudio=!1);this.isConnected=e,e?(localStorage.setItem(o.KEY,o.ON),this.onPartialResultsCallback("")):localStorage.setItem(o.KEY,o.OFF),this.enableLogs&&a.log(`AUGNITO STATUS CHANGED. Connected: ${e}`,this._logTag),this.onStateChanged&&this.onStateChanged(e)}onSocketFinalResult(e){let t;if(t="string"==typeof e?JSON.parse(e):e.Result,this.enableLogs&&a.log({type:"onSocketFinalResult",data:e},this._logTag),this.switchToRegularSpeechProfile&&this.onPartialResultsCallback(""),this._worker){const e=t.Transcript,n=t.Action,i={name:t.Transcript,sessionCode:"",final:t.Final,isCommand:t.IsCommand,receivedText:e,action:t.IsCommand?n.replace(/\s+/g,""):""};this._worker.postMessage(i)}}onSessionEventCallback(e){var t=void 0;if(t="string"==typeof e?JSON.parse(e):e,this.enableLogs&&a.log({type:"onSessionEvent",data:e},this._logTag),this.onSessionEvent&&this.onSessionEvent(t),"string"==typeof t.Event&&"None"===t.Event)return;const n=t.Event.Type,i=t.Event.Value;if("SESSION_CREATED"===n){if(this.isConnected=!0,this.enableLogs){const e=i;a.log("session Token "+e,this._logTag)}}else"SERVICE_DOWN"===n?(a.error(n,this._logTag),this.isConnected?this.stopAudio():this.forceStopAudio=!0,this.onErrorCallback(i)):"NO_DICTATION_STOP_MIC"===n?(this.enableLogs&&a.log("NO_DICTATION_STOP_MIC",this._logTag),this.onIdleMicCallback()):"INVALID_AUTH_CREDENTIALS"===n?(a.error("INVALID_AUTH_CREDENTIALS",this._logTag),a.log("Invalid authentication, Please check your Account Status, Lm Id and Access Key."),this.isConnected?this.stopAudio():this.forceStopAudio=!0,this.onErrorCallback(i)):"LOW_BANDWIDTH"===n&&(this.enableLogs&&a.log("LOW_BANDWIDTH: Check internet connection",this._logTag),this.onErrorCallback(i))}onMicrophoneOnErrorCallback(t){this.enableLogs&&a.log(`AUGNITO Error. Microphone is already On. Is Web Client? ${t}`,this._logTag),this.onMicrophoneOnError?this.onMicrophoneOnError(t):this.onError&&this.onError({Type:e.ERR_CLIENT,Message:"Microphone is already On",IsWebClient:t})}createSDKConfig(e){const t=new m(e);return t.onError=this.onErrorCallback.bind(this),t.onSocketPartialResult=this.onPartialResultsCallback.bind(this),t.onSocketFinalResult=this.onSocketFinalResult.bind(this),t.onReadyForSpeech=this.onStateChangeCallback.bind(this),t.onEndOfSession=this.onStateChangeCallback.bind(this),t.onSessionEvent=this.onSessionEventCallback.bind(this),t.onMicrophoneOnError=this.onMicrophoneOnErrorCallback.bind(this),t}createWorker(){const e=URL.createObjectURL(new Blob(["this.onmessage = function (eee) {self.postMessage(eee.data);}"],{type:"application/javascript"})),t=new Worker(e);return t.onmessage=e=>{const t=e.data,n=qe.prepareCustomCommandRecipe(t);if(null==n)this.enableLogs&&a.log({type:"AugnitoCustomCommands",command:n},this._logTag);else if(n.isCustomCommand)this.enableLogs&&a.log({type:"AugnitoCustomCommands",command:n},this._logTag),this.onCommandResultsCallback(n);else if(t.isCommand){const e=h.prepareRecipe(t);this.enableLogs&&a.log({type:"AugnitoCommandsStatic",command:e},this._logTag),this.onCommandResultsCallback(e)}else{const e=d.prepareRecipe(t);e.isCommand?(this.enableLogs&&a.log({type:"AugnitoCommandsRegex",command:e},this._logTag),this.onCommandResultsCallback(e)):this.onFinalResultsCallback(e)}},t}handleBeforeUnloadEvent(e){this.enableLogs&&a.log({type:"handleBeforeUnloadEvent",event:e},this._logTag),this.isConnected&&this.requestMicOff()}handleStorageChangeEvent(e){e.key===o.KEY&&(this.enableLogs&&a.log({type:"handleStorageChangeEvent",event:e},this._logTag),localStorage.getItem(o.KEY)===o.REQUEST_OFF&&this.isConnected&&this.toggleListening())}}const $e=["--select--","BD - Afternoon & Night","BD - Morning & Afternoon","BD - Morning & Evening","BD - Morning & Night","Continuous infusion","EIGHT times a day","Every 10 days","Every 2 hours","Every Alternate day","Every hour","Every two weeks","FIVE times a day","FIVE times a week","FOUR times a week","HS - At bedtime","OD - Afternoon","OD - Evening","OD - Morning","OD - Night","Once - One time only","Once a month","Once a week","Once a year","Q12H - Every 12 hours","Q4H - Every 4 hours","Q6H - Every 6 hours","Q8H - Every 8 hours","QID - Morning, Afternoon, Evening & Night","Refer instructions for dosage","SIX times a day","SOS - Whenever needed","STAT ( Immediately)","TDS - Afternoon, Evening & Night","TDS - Morning, Afternoon & Evening","TDS - Morning, Afternoon & Night","TDS - Morning, Evening & Night","THREE times a week","TWO times a week"],Ye=["--select--","After Breakfast","After dinner","After lunch","After meal","At Bed Time","Before Breakfast","Before dinner","Before lunch","Before meal","Empty Stomach","Local Application","Not Applicable to Meals","With Food"],Ze=["--select--","Day(s)","Month(s)","Till Next Review","Week(s)"],Qe=["--select--","Vial(s)","Ampoule","Bag","Bar","Bottle(s)","Box","Capsule(s)","Carton","Cartridge(s)","Cream","Dressing","Drops","Gel","gm","I.U.","Inhaler","Jar","Kit","Lozenge","mg","Micro drops","Microgram (mcg)","ml","Ounce (30 ml)","Pad","Patch(s)","Pen","Pessary","Piece","Pre Filled Syringe","puff(s)","Respule(s)","Sachet(s)","Scoop(s)","Spray","Strip(s)","Suppository","Tablespoon (15 ml)","Tablet(s)","Tampon","Teaspoon (5 ml)","Tube","Unit(s)"],et=["--select--","Gastronomy Tube","Mouth And Throat","Nasogastric","Nasotrachial Tube","Oral","Rectal","Sublingual","Translingual","Dental","Epidural","Gargle","Inhalation","Intra-Arterial","Intrabursal","Intracardiac","Intrahepatic Artery","Intramuscular","Intraperitoneal","Intrathecal","Intratracheal","Intrauterine","Intravenous","Irrigation","Local Application","N/A","Nasal","Nebulization","Perfusion","Urethral","Ventimask","Apply Externally","Buccal","Immerse(Soak) Body Part","Implant","Intracervical (Uterus)","Intradermal","Intranasal","Intraocular","Mucous Membrane","Other/Miscellaneous","Otic","Subcutaneous","Topical","Transdermal","Vaginal"],tt=["--select--","SOMAZINA PLUS TAB","KEZONE S FORTE 1.5GM INJ","NEOROF 1% 10ML INJ","INOGLA 20MG TAB 10'S","GRAFEEL 1ML 300MCG INJ","GABAPIN 100MG TAB 15'S","SYNCAPONE 150MG TAB","OXA-50MG/25ML INJ","PRIN PLUS SOFTGEL CAP 10'S","DOLONEURON PG-75MG CAP","DOLO 1000MG TAB","DOLO 100ML IV","DOLO 15ML DROPS","DOLO 250MG SYP","DOLO 650MG TAB 15'S","DOLO INFUSION 100ML","DOLO IVG 1%INFUSION 1000MG/100ML","DOLO SUSP - 60ML","DOLO-500MG TAB","ZEROSCAB 120ML LOTION","DHYAN-NTP TAB 10'S","FUZOLID 200MG/100ML INFUSION","SUNBAN ULTRA SPF 31 GEL","PENTASURE VANILA 400GM TIN","BRONCOREX EXP 100ML","AMPILOX 500MG CAP","GABAPIN 100MG TAB 10'S","ND-PAIN TAB","PANTODAC 40MG IV INJ","LIFEPILL 3MG CAP","CLOPILET A 150MG TAB","DOMSTAL DT 10MG TAB","REJUNURON CAPS 30'S","CARDIOPLEGIA INJ - 20ML (DBL)","CINOD-N 10/5MG TAB","KETOART TAB","DOBESIL H 30GRM OINT","DYRECT TAB","ZIMBA 1% WW 10GM CREAM","PLASBUMIN-12.5GM/250ML","SOFZID NS SYP 180 ML","OFLOCHEM 200MG TAB","FAROTAB 200MG TAB 6'S","C WIN 1%W/W CREAM 30GM","SEMI GLYNASE 2.500 MG TAB","OXONEG ORANGE FLAV EFFERVESCENT TAB 15'S","KEPHAZON-S FORTE 3.0 GM INJ","METROGYL-P 2% OINT 20GM","MAXMALA 50MG TAB","OXIFUL - FORTE CAP 10S","TREMIDON 50MG TAB","CREMAFFIN PLUS - 110ML [BOOTS CO.]","PARI CR FORTE TAB","CEFOLAC DT 50MG TAB","TRIOPTAL 450MG TAB","BRYXTA 300MG/12ML INJ","CARDIMAX SR 60MG TAB","CYBLEX 80MG TAB 15S","DOMSTAL BABY 5 ML DROPS","INSUGEN-30/70 REFIL 3ML INJ","CALCIRIN-FORTE CAP","ROMILAST 10 MG TAB","EPSOLIN ER 300MG TAB","MOTIVYST 300MG TAB","NIMEK PARA TAB","CREMA ANO 20GM CREAM","NOSTRA CR 15MG TAB","MACPEE 25MG TAB","NUROZENOL CAP","MYCOPHEN 500MG TAB","REPACE-A TAB","FULVIRA 250MG/5ML INJ","PHYSIOGEL HYPOALERGENIC LOTION","DEXTOMID 50MG 0.5ML INJ","METROGYL DG GEL 10 GRM","FEBRINIL 2ML INJ","TUSQ X 100ML SYP","ZIVAST 10 MG TAB","MOMEFLO NASAL SPRAY","HISTAC 300MG TAB","RENO-PRO HIGH PROTEIN VANILLA FLAV 200GM POWDER","VENUSIA 75GM CREAM","TAMDART TAB","BRAIN UP PINEAPPLE FLAV SUSP 150ML","AMLOSUN 5MG TAB","C QNEXT CAP","HEPLOCK 10ML","6IPZOCIN 30MG/1ML INJ","NUROKIND FAST STRIP 1'S","TORQ-SR 4MG CAP 30'S","RABEZ - D CAPS","TAZLOC 80MG TAB","LIFOGEM 200MG INJ","TRICIUM MAX TAB 15S","TASIGNA 150MG CAP","GAVISCON PEP LIQ 150ML","MELACARE 20GRM CREAM","KEYCEPT S 360MG TAB","DOXYMIZ SL CAP","TAPAL 100MG TAB","DIABEND - 40MG TAB","NUBLEXA 40 MG TAB 28'S","TAXOTERE 80 MG 2 ML INJ","FLUPETRA TAB","BISPEC 5MG TAB 15'S","DICLOPEP TAB","KABIPRO 400GM CREAMY VENILLA","XERINA 100 ML","CYPHOS 1GM INJ","BRIVIACT 75MG TAB 14'S","DOXOFLY 400MG TAB","GABAWIN 50MG TAB","ACITROM 2MG TAB 20'S","V&M 20MG TAB 15'S","WEPOX 5000 INJECTION 0.5ML","MOMATE - S 5GRM OINT","CALPOL (PEDIA )DROPS - 15ML","HEPLIST-400MG TAB","PREGEB FORTE 75MG CAP","DENTOGEL 15GM","STARPRESS - H 50MG XL TAB","ENSURE FOS(VANILA) 400G (ABBOTT)","MIMCIPAR 30MG TAB","MECONEURON OD 1500MCG TAB 15'S","UNIZID-TZ 1.125MG INJ","RESPIDON 2 MG TAB","COQ SUPPORT TAB","NURIVITA-OD SOFTGEL CAP 10'S","KERA XL HAIR GROWTH SERUM(60ML)","AMINO MIX 1000ML (P) (FRU)","BRYXTA 400MG/16ML INJ","CALCIUM FOLINATE 7.5MG INJ 15MG/2ML","ATARAX SYP - 100ML","MAXUM TAB 10'S","KET-AMINOS TAB","URSETOR 300 MG TAB","CQRA CAP","DISTACLOR CD 750MG TAB","ZEN RETARD 400 MG TAB","ERYKINE 40000 IU 1ML INJ *","STONE IB6 200ML SYP","GLIPI MET 500/50MG TAB.","TAZOTUM 1.125G INJ","AMBILIP 50MG INJ","TEAR 10 ML DROP","COMBINIB 250MG TAB","ROZAVEL - 10MG TAB","NEBISTAR 5MG TAB 15'S","COGNOXYN 200ML SYP","BIPACEF-500 TAB 10S","NOVO WHITE 50GM CREAM","CMXX 500MG TAB 10'S","HEAM UP - GEM 30'S CAP","TRAMACIP CAPS 10'S","DELCON PLUS 60 ML SYP","FONDAKEM 2.5MG/0.5ML INJ","GEN COLL 15GM COLLAGEN BASE","NEOSPORIN 5 GRM OINT","NITREST 10MG TAB","XIDORIN 2.5MG TAB 20S","INTAGESIC MR TAB","ENFIERA 100MG/10ML INJ","LIPIROSE F 10 TAB","MAHAMONT-L TAB","JALRA M 50/500MG TAB 10'S","ENOXION 20MG INJ","AZULIX 4MG TAB","ROSEDAY 40MG TAB","RASIN-DSR CAP 10'S","VOMIKIND-FAST STRIP PATCH","EPITHRA 50MG INJ","ACIPANT 40 INJ","BIFILAC LOZENGES 10'S","RESHAPE NATURAL TAB 10'S","TRILOSAR 12.5MG TAB","BETAGAN - 0.5% DROP","CROCIN SUSPENSION 60 ML","AZTRIC-80MG TAB","CLINDATEC 300MG CAPS.","OXIPLAT 100MG IV INJ","SUFRATE LA 30GM CREAM","DOXINATE TABLET","REFLORA 1GM SACHETS","HUMAN ALBUMIN 20% 50ML","DYCIPAR 30GM GEL","SEVLAREN-800MG TAB 10'S","CIFRAN I.V - 100ML INJ","ATEN H 25MG TAB","EUSOL 400ML SOLUTION (CENTRAL DRUGS)","SYSTAFLAM MR TAB","FOLITRAX 20MG/1ML INJ","BUFATAS 60 MG/10ML","MACORATE CR 200MG TAB","BISPEC 5MG TAB 15'S","NOVAPIME 1G INJ","BILAZO 20MG TAB 10'S","ADENOJECT INJ - 2ML**","EMCITABEN 1GM INJ","TELPRES CT 40/12.5MG TAB 15'S","OCUPOL DX 5ML DROPS","OXYTOCIN ING 2ML","REMMAG TAB","BETAFERON 0.25MG INJ","CLOCIP 15GRM CREAM","ALFAREN 200MG TAB","HEALON GV 1.4% 0.55ML","OROFER CAPS","ASTHALIN 100ML SYP","DOLONAT TAB","LOPEZ MD 1 10'S TAB","MELACYN GEL 50GM","HALOVATE F 10GM CREAM","LACOSAM 50 MG TABLET","FOLTOP-M CAP 10'S","GRANICIP 1MG TAB","DOTAMIN 5ML INJ","THYRONORM 12.5MCG CAPS","DILTIACT GEL 2% 30GM","PLACENTREX 100GM GEL","EYEVITAL CAPS","NS 0.9%W/V SODIUM CHLORIDE 3000ML (FRESENIUS)","CEFADROX 500MG TAB","GLYCOMET SR 850MG TAB","HDYSHIL 500MG CAP 10S","MAXIGARD 500MG INJ","BUDAMATE 200 INHALER","MEXATE 7.5MG TAB","GENTACOL EYE DROP","RINIFOL 60ML DRY SYP","CASIRIVIMAB / IMDEVIMAB COMBO PACK 2400MG (REGN-COV2)INJ","KUZET 3MIU INJ","PANTHE 5% GEL 5GM","HEALON GV 1.4% 0.55ML","DERMANEX CREAM 30GM","ALFAPIME TZ 2.25GM INJ","EFAVIR 200MG 30'S CAPS","INHALEX RESPULES 2ML","DEXALAB 2ML INJ","RX-PLUS CAP","TIMOLET GFS 0.5% 3ML EYE DRO","KABIMMUNE SACHETS - 15GM","JANUMET XR CP KIT 7's","BETALOC 5ML INJ","INSUPEN PRO+INSUGEN 30/70 REFIL INITIATION KIT","ENGERIX - B ADULTS INJ","ELOVERA IMF 50ML LOTION","CARTIKOOL XP TAB 10'S","MINO QILIB 5 LOTION 60ML","METHYL PREDNISOLONE 1000MG INJ","MYOKRAMP TAB","TOPNERVE 500MCG/ML INJ","REMYLIN D 1000 IU TAB","ABITATE U 250MG TAB 120S","L-HIST TAB","ISOTROY 100ML LIQUID FOR INHALATION","FDSON MP TAB","THEOASTHALIN SR 4 MG TAB","TIGEPLUG 50MG INJ","SUFRATE LA 30GM CREAM","ETOPOGEN 100 MG INJ","MACRALFATE-O 200ML SUSP","CORTIMAX 30MG TAB","METOCARD XL 50MG TAB","PRESMOVAC 2MG TAB 10'S","SISONEXT 10GM CREAM","PHENOBARBITONE SODIUM 200MG/1ML INJ (VULCAN)","GUTPRO 2BILLION/5ML SYP 30ML","GTX 600MG INJ","ADDBACTAM 1GM INJ","MECONUS TAB 10`S","HYLCOBA 500MG INJ","CYCLOREG 5MGTAB","BACLOF 25MG TAB","PARAPIC-500 TAB","TRIOMUNE 30MG TAB","NANOPACLI 100 MG INJ","ALTAXEL - 100MG 16.7ML INJ","AMARYL M2 FORTE 2+1000 MG TAB","URLPLUS CAP","ATRAPURE 25MG/2.5ML INJ","PARACETAMOL 1 GM IV","PARACETAMOL 1000MG TAB","PARACETAMOL 100ML I.V","PARACETAMOL 2ML INJ","PARACETAMOL 30ML INJ","PARACETAMOL 500MG TAB","PARACETAMOL 500MG TAB (CADILA)"];export{Je as Augnito,f as AugnitoAPIServer,r as AugnitoCommands,he as AugnitoMobile,e as AugnitoSDKError,tt as Drug,Ze as DurationType,v as EditorType,ze as FactoryAPI,Ve as FormattingAPI,$e as Frequency,pe as MacrosAPI,Ye as MealsRelation,b as PhilipsMicMode,Qe as QuantityUnit,et as Route,We as VocabularyAPI};
|
|
188
|
+
*/}function J(e){e.createModule("Util",["WrappedSelection"],(function(e,t){var n=e.rangePrototype,i=e.selectionPrototype;i.pasteText=function(e){this.deleteFromDocument();var t=this.getRangeAt(0),n=t.getDocument().createTextNode(e);t.insertNode(n),this.setSingleRange(t)},n.pasteText=function(e){this.deleteContents();var t=this.getDocument().createTextNode(e);this.insertNode(t)},i.pasteHtml=function(e){this.deleteFromDocument();var t=this.getRangeAt(0),n=this.createContextualFragment(e),i=n.lastChild;t.insertNode(n),i&&t.setStartAfter(i),this.setSingleRange(t)},n.pasteHtml=function(e){this.deleteContents();var t=this.createContextualFragment(e);this.insertNode(t)},i.selectNodeContents=function(t){var n=e.createRange(this.win);n.selectNodeContents(t),this.setSingleRange(n)},e.createRangeFromNode=function(t){var n=e.createRange(t);return n.selectNode(t),n},e.createRangeFromNodeContents=function(t){var n=e.createRange(t);return n.selectNodeContents(t),n},e.selectNodeContents=function(t){e.getSelection().selectNodeContents(t)},n.selectSelectedTextElements=function(){function t(t){return 1==t.nodeType&&"inline"==e.dom.getComputedStyleProperty(t,"display")}function n(e,n){var i=null,o=e.cloneRange();if(o.selectNode(n),""!==o.toString())for(;(n=n.parentNode)&&t(n)&&e.containsNodeText(n);)i=n;return i}return function(){var e=n(this,this.startContainer);e&&this.setStartBefore(e);var t=n(this,this.endContainer);t&&this.setEndAfter(t)}}()}))}W=V,Object.defineProperty(V,"processText",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i,o,r)=>{" ,"!==e&&" ."!==e||(e=e.trim())," \n"!==e&&" \n\n"!==e&&"\n"!==e&&"\n\n"!==e||(e=W.trimWithoutNewLine(e)),0!==i&&o||(e=W.capitalizeFirstLetter(e,0),e=W.trimWithoutNewLine(e)),(t||n)&&(e=W.capitalizeFirstLetter(e,0),t||(e=W.trimWithoutNewLine(e)));var a=e.trim();return a.length>0&&("."===a[0]||":"===a[0])&&(e=W.trimWithoutNewLine(e)),r&&(e=W.trimWithoutNewLine(e)),e}}),Object.defineProperty(V,"ProcessText",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i)=>{new RegExp("^ ([.|:|,])(.*?)$","gis").exec(e)&&(e=W.lTrim(e))," ,"!=e&&" ."!=e||(e=e.trim())," \n"!=e&&" \n\n"!=e||(e=W.trimWithoutNewLine(e)),0==n&&(e=W.capitalizeFirstLetter(e,0),e=W.trimWithoutNewLine(e));var o=!1,r=!1,a=0;0==i.start&&(r=!0);for(var s=t,l=s.length-1;l>-1;l--){var c=s[l];if(null!=c){if("."==c||":"==c){o=!0;break}if("\r\n"==c||"\n"==c||"\r"==c||"\v"==c){r=!0;break}if(null!=c.trim()&&""!=c.trim())break;a++}}if(o){var u=W.capitalizeFirstLetter(e,0);u=W.trimWithoutNewLine(u),e=a>0||0==u.trim().length?u:" "+u}if(r){u=W.capitalizeFirstLetter(e,0);e=u=W.trimWithoutNewLine(u)}return a>0&&(e=W.trimWithoutNewLine(e)),{ReceivedText:e=W.replaceSpaceAfterNewline(e),EndLine:o||r}}}),Object.defineProperty(V,"trimWithoutNewLine",{enumerable:!0,configurable:!0,writable:!0,value:e=>{if(!e)return e;return e=(e=(e=e.replace(/\n/gi,"@newline@")).trim()).replace(new RegExp("@newline@","gi"),"\n")}}),Object.defineProperty(V,"lTrim",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?e.replace(/^\s+/,""):e}),Object.defineProperty(V,"replaceSpaceAfterNewline",{enumerable:!0,configurable:!0,writable:!0,value:e=>e.replace(/\n +/g,"\n")}),window.EnableLog=!1;var Y,Z=function(){};Z.prototype.build=function(){const e=new H;return new z(e),new K(e),new X(e),new q(e),new J(e),e};class Q{}Object.defineProperty(Q,"NODE_ELEMENT",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(Q,"NODE_TEXT",{enumerable:!0,configurable:!0,writable:!0,value:3});class ee{}Y=ee,Object.defineProperty(ee,"linkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"br"}),Object.defineProperty(ee,"divLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"div"}),Object.defineProperty(ee,"paragraphLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"p"}),Object.defineProperty(ee,"listLinkBreakElement",{enumerable:!0,configurable:!0,writable:!0,value:"li"}),Object.defineProperty(ee,"lineBreakElements",{enumerable:!0,configurable:!0,writable:!0,value:[Y.linkBreakElement,Y.divLinkBreakElement,Y.paragraphLinkBreakElement,Y.listLinkBreakElement]});class te extends G{constructor(e){super(e,"CommonContentEditableProcessor"),Object.defineProperty(this,"_augnitoRange",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_editorDocument",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_dynamicSelect",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"findLineBreakAtCursor",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t;if(null!=e)if(null!=e.previousSibling&&e.previousSibling.nodeType===Q.NODE_ELEMENT){if(ee.lineBreakElements.includes(e.localName))return!0}else{if(null!=e.previousSibling&&e.previousSibling.nodeType===Q.NODE_TEXT&&e.previousSibling.nodeValue&&e.previousSibling.nodeValue.length>0)return!1;if(e.previousElementSibling&&(null===(t=e.previousElementSibling)||void 0===t?void 0:t.nodeType)===Q.NODE_ELEMENT){const t=e.previousElementSibling;if(t&&ee.lineBreakElements.includes(t.localName))return!0}else if(null==e.previousSibling&&null==e.previousElementSibling&&(null!=e.parentElement||null!=e.parentNode)){const t=e.parentElement?e.parentElement:e.parentNode,n=t&&t.nodeType==Q.NODE_ELEMENT?t.localName:"";if(t&&ee.lineBreakElements.includes(n))return!0;if(t&&null!=t.previousSibling){if(t.previousSibling.nodeType===Q.NODE_TEXT&&t.previousSibling.nodeValue&&t.previousSibling.nodeValue.length>0)return!1;if(t.previousSibling.nodeType===Q.NODE_ELEMENT&&ee.lineBreakElements.includes(t.previousSibling.localName))return!0}const i=t&&t.nodeType==Q.NODE_ELEMENT?t.previousElementSibling:null;if(i&&ee.lineBreakElements.includes(i.localName))return!0;if(null!=i)return!1;if(null!=t)return this.findLineBreakAtCursor(t)}}return!1}}),Object.defineProperty(this,"findLineBreakAtNextCursor",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t;if(null!=e)if(null!=e.nextSibling&&e.nextSibling.nodeType===Q.NODE_ELEMENT){if(ee.lineBreakElements.includes(e.nextSibling.localName))return!0}else{if(null!=e.nextSibling&&e.nextSibling.nodeType===Q.NODE_TEXT&&e.nextSibling.nodeValue&&e.nextSibling.nodeValue.length>0)return!1;if(null!=e.nextElementSibling&&(null===(t=e.nextElementSibling)||void 0===t?void 0:t.nodeType)===Q.NODE_ELEMENT){const t=e.nextElementSibling;if(t&&ee.lineBreakElements.includes(t.localName))return!0}else if(null==e.nextSibling&&null==e.nextElementSibling&&(null!=e.parentElement||null!=e.parentNode)){const t=e.parentElement?e.parentElement:e.parentNode,n=t&&t.nodeType==Q.NODE_ELEMENT?t.localName:"";if(n&&ee.lineBreakElements.includes(n))return!0;if(t&&null!=t.nextSibling){if(t.nextSibling.nodeType===Q.NODE_TEXT&&t.nextSibling.nodeValue&&t.nextSibling.nodeValue.length>0)return!1;if(t.nextSibling.nodeType===Q.NODE_ELEMENT&&ee.lineBreakElements.includes(t.nextSibling.localName))return!0}const i=t&&t.nodeType==Q.NODE_ELEMENT?t.nextElementSibling:null;if(i&&ee.lineBreakElements.includes(i.localName))return!0;if(null!=i)return!1;if(null!=t)return this.findLineBreakAtNextCursor(t)}}return!1}}),this._augnitoRange=(new Z).build(),this.validateDependencies()}processFinalResult(e,t){if(!this.validateEditorDocument(t)||!this._editorDocument)return;if(this.onBeforeProcess(e))return;let n=e.receivedText||"";n=n.replace(/\n/gi,"@newline@");let i=!1,o=!1,r=!1,a=!1;this.deleteSelection(null);const s=this._augnitoRange.getSelection(this._editorDocument);if(!s||0===s.rangeCount)return;const l=s.getRangeAt(0),c=l.cloneRange(),u=l.startOffset;n=n.replace(new RegExp("@newline@","gi"),"\n");const d=this.findLastChar(this._editorDocument);a=d.cursorInSameLine,o=""==d.lastImmediateChar.trim(),i=d.isLastFullStop,r=d.isLastNewLine,s.removeAllRanges(),s.addRange(c),n=V.processText(n,i,r,u,a,o),this.insertTextAtCursor(this._editorDocument,n)}processCommand(e,t){if(this.validateEditorDocument(t)&&this._editorDocument&&!(this.onBeforeProcess(e)||e.action&&this.customCommandProcessor&&this.customCommandProcessor(e.action)))if(e.action===r.SPACE_ADD)this.insertTextCallback(this._editorDocument," ",!0);else if(e.action===r.SELECT_ALL)if(this.customActionProcessor)this.customActionProcessor(e.action);else{const e=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0),t=this._editorDocument.activeElement&&this._editorDocument.activeElement.firstElementChild?this._editorDocument.activeElement.firstElementChild.firstChild:null;t&&e.setStart(t,0);const n=this._editorDocument.activeElement&&this._editorDocument.activeElement.lastElementChild?this._editorDocument.activeElement.lastElementChild.lastChild:null;n&&e.setEnd(n,n.textContent?n.textContent.length:0),this._augnitoRange.getSelection(this._editorDocument).removeAllRanges(),this._augnitoRange.getSelection(this._editorDocument).addRange(e)}else if(!e.action&&e.name===r.SELECT&&this.customSelectProcessor&&this.customSelectProcessor({searchText:e.searchText||"",selectFor:e.selectFor||""}));else if(e.action&&0===e.action.indexOf(r.SELECT)||0===e.name.indexOf(r.SELECT)){this.deSelectSelection(this._editorDocument,!1,!0),e.name=e.name.replace(r.SELECT,""),e.chooseNumber=e.chooseNumber?e.chooseNumber:0;const t={name:e.name,chooseNumber:e.chooseNumber||0};this.processSelect(Object.assign(Object.assign({},e),t),this._editorDocument),e.selectFor&&e.selectFor!==r.SELECT&&this.deSelectSelection(this._editorDocument)}else if(e.action&&r.NEXT_FIELD===e.action.toLowerCase()){const e={caseSensitive:!1,wholeWordsOnly:!1,direction:"forward"};this.deSelectSelection(this._editorDocument,!1,!0),this.searchDynamicFiled(e);const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}else if(e.action&&r.PREVIOUS_FIELD===e.action.toLowerCase()){const e={caseSensitive:!1,wholeWordsOnly:!1,direction:"backward"};this.deSelectSelection(this._editorDocument,!0,!0),this.searchDynamicFiled(e);const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}else if(e.action&&r.DESELECT_IT===e.action.toLowerCase())this.deSelectSelection(this._editorDocument,!1,!0);else if(e.action&&this.processSelectForAction(e.action,this._editorDocument));else if(e.action===r.GO_TO_LINE_START){const e=this.traverseTextNodes("character",-1,["\n"],!1,this._editorDocument,!0);e.rangeAfterProcess&&this.setSelectionRange(this._editorDocument,e.rangeAfterProcess)}else if(e.action===r.GO_TO_LINE_END){const e=this.traverseTextNodes("character",1,["\n"],!1,this._editorDocument,!0);e.rangeAfterProcess&&(null!=e.rangeAfterProcess.endContainer.nodeValue&&e.rangeAfterProcess.endContainer.nodeValue.length!==e.rangeAfterProcess.endOffset&&e.rangeAfterProcess.setStartAndEnd(e.rangeAfterProcess.endContainer,e.rangeAfterProcess.endContainer.nodeValue.length),this.setSelectionRange(this._editorDocument,e.rangeAfterProcess))}else if(e.name===r.GOTO){const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText+":",i={caseSensitive:!1,wholeWordsOnly:!1};t.findText(n,i)&&(t.collapse(!1),t.setStartAndEnd(t.endContainer,t.endOffset),this.setSelectionRange(this._editorDocument,t))}}}insertTextAtCursor(e,t){const n=t.split("\n");if(n.length>0)for(let t=0;t<n.length;t++){""!==n[t]&&this.insertTextCallback(e,n[t],!1);n.length>1&&!(t===n.length-2&&""===n[n.length-1]||t===n.length-1&&""!==n[t])&&this.insertTextCallback(e,"\n",!1)}}findLastChar(e){const t=this.traverseTextNodes("character",-1,[" ","\n"],!0,e);this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(t.rangeBeforeProcess);const n={lastChar:t.lastChar,cursorInSameLine:t.isCursorInSameLine,isLastFullStop:!1,isLastNewLine:!1,lastImmediateChar:t.lastImmediateChar};return""!==t.lastChar&&("."===t.lastChar||":"===t.lastChar?n.isLastFullStop=!0:"\r\n"!==t.lastChar&&"\n"!==t.lastChar&&"\r"!==t.lastChar||(n.isLastNewLine=!0)),n}processSelect(e,t){e.searchText||(e.searchText="");const n=e.searchText.replace(/ /gi,"").toLowerCase().trim(),i=e.nextPrevious,o=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;if(!e.name)return this.log("warning. attempt to process select but recipe has no name"),!1;if("nextword"===n||"next"===i){return this.getNextInterval(e.name,o,t)&&e.selectFor&&this.processSelectForAction(e.selectFor,t,!0),!0}if("previousword"===n||"it"===n||"that"===n||"previous"===i||"last"===i){return this.getPrevInterval(e.name,o,t)&&e.selectFor&&this.processSelectForAction(e.selectFor,t,!0),!0}return!1}processSelectForAction(e,t,n){const i=this._augnitoRange.getSelection(t).getRangeAt(0),o=i.cloneRange();if(i.startOffset===i.endOffset&&i.endContainer===i.startContainer&&this.getPrevInterval("word",1,t),this.customActionProcessor)return setTimeout((function(e,t,n,i){if(e&&e.customActionProcessor){var o=e.customActionProcessor(t);i&&t!==r.SELECT?e.deSelectSelection(n,!1,!0):o||t===r.SELECT||e.deSelectSelection(n,!1,!0)}}),100,this,e,t,n),!0;let a=!1;return"bold"===e.toLowerCase()||r.BOLD_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Bold",t),a=!0):"italicize"===e.toLowerCase()||r.ITALICIZE_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Italic",t),a=!0):"underline"===e.toLowerCase()||r.UNDERLINE_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Underline",t),a=!0):"capitalize"===e.toLowerCase()||r.CAPITALIZED_IT===e.toLowerCase()?(this._augnitoRange.execSelectionCommand("Uppercase",t),a=!0):r.DELETE!==e.toLowerCase()&&"deleteit"!==e.toLowerCase()&&r.PRESS_DELETE!==e.toLowerCase()||(this.deleteSelection(t),a=!0),a||this.setSelectionRange(t,o),a}onBeforeProcess(e){if(null==this._editorDocument||!e.receivedTextWithoutSpace)return!1;if(!this._dynamicSelect)return!1;const t=parseInt(e.receivedTextWithoutSpace,10),n=t-1;if(isNaN(t)||n>this._dynamicSelect.length)return this.removeDynamicSelect(),!1;const i=this._dynamicSelect.getBadge(n).range;this.setSelectionRange(this._editorDocument,i),this._dynamicSelect.selectFor&&(this.processSelectForAction(this._dynamicSelect.selectFor,this._editorDocument,!0),this.deSelectSelection(this._editorDocument)),this.removeDynamicSelect();const o=this._augnitoRange.getSelection(this._editorDocument);return this.scrollElementToView(o),!0}removeDynamicSelect(){this._dynamicSelect&&(this._dynamicSelect.removeBadges(),this._dynamicSelect=null)}getLastLines(e,t){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),null;const n=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0);var i=$(n.nativeRange.startContainer).closest("p")[0];if(i||(i=$(n.nativeRange.startContainer).closest("li")[0]),null==i)return null;const o=this._augnitoRange.createRange(this._editorDocument);if(1===e)if(0===n.startOffset){const t=this.getLastLinesRecursive(0,e,i);o.setStart(t,0);const n=i.previousSibling?i.previousSibling:i,r=i.previousSibling?i.previousSibling.childNodes.length:0;o.setEnd(n,r)}else o.selectNodeContents(i);else{const t=0===n.startOffset?0:1,r=this.getLastLinesRecursive(t,e,i);if(o.setStart(r,0),0===n.startOffset){const e=i.previousSibling?i.previousSibling:i,t=i.previousSibling?i.previousSibling.childNodes.length:0;o.setEnd(e,t)}else o.setEnd(i,i.childNodes.length)}return this._augnitoRange.getSelection(t).removeAllRanges(),this._augnitoRange.getSelection(t).addRange(o),o}getLastLinesRecursive(e,t,n){if(e===t)return n;if(n.previousSibling){const i=this.isListElement(n.previousSibling)&&n.previousSibling.lastChild?n.previousSibling.lastChild:n.previousSibling;return this.getLastLinesRecursive(e+1,t,i)}if(n.parentElement&&this.isListElement(n.parentElement)){const i=n.parentElement.previousSibling;if(!i||!i.lastChild)return n.parentElement;const o=this.isListElement(i)?i.lastChild:i;return this.getLastLinesRecursive(e+1,t,o)}return n}isListElement(e){if(e.nodeType==Q.NODE_ELEMENT){const t=e.tagName;return"UL"===t||"OL"===t}return!1}getNextInterval(e,t,n){return"word"===e?this.getNextWordInterval(t,n):null}getPrevInterval(e,t,n){return"word"===e?this.getPrevWordInterval(t,n):"line"===e?this.getLastLines(t,n):null}getNextWordInterval(e,t){let n;""!==this.traverseTextNodes("character",1,1,!0,t).lastChar.trim()&&(n=this.traverseTextNodes("character",-1,[" ","\n",",",":",";","."],!1,t,!1),n.rangeAfterProcess&&this.setSelectionRange(t,n.rangeAfterProcess)),n=this.traverseTextNodes("word",1,e,!1,t,!1);const i=this._augnitoRange.createRange(t);return n.rangeAfterProcess&&(i.setEnd(n.rangeAfterProcess.endContainer,n.rangeAfterProcess.endOffset),i.setStart(n.rangeBeforeProcess.startContainer,n.rangeBeforeProcess.startOffset)),this.setSelectionRange(t,i),i}getPrevWordInterval(e,t){let n;""!==this.traverseTextNodes("character",-1,1,!0,t).lastChar.trim()&&(n=this.traverseTextNodes("character",1,[" ","\n",",",":",";","."],!1,t,!1),n.rangeAfterProcess&&this.setSelectionRange(t,n.rangeAfterProcess)),n=this.traverseTextNodes("word",-1,e,!1,t,!1);const i=this._augnitoRange.createRange(t);return n.rangeAfterProcess&&(i.setEnd(n.rangeBeforeProcess.endContainer,n.rangeBeforeProcess.endOffset),i.setStart(n.rangeAfterProcess.startContainer,n.rangeAfterProcess.startOffset)),this.setSelectionRange(t,i),i}deSelectSelection(e,t,n){if(null==this._editorDocument)return void this.error("missing editor document. Make sure to provide a non null Document type");if(this.customActionProcessor&&!n)return;const i=this._augnitoRange.getSelection(e).getRangeAt(0);t?i.setEnd(i.startContainer,i.startOffset):i.setStart(i.endContainer,i.endOffset),this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(i)}searchDynamicFiled(e){if(null==this._editorDocument)return void this.error("missing editor document. Make sure to provide a non null Document type");const t=this._augnitoRange.createRange(this._editorDocument);t.selectNodeContents(this._editorDocument.body);const n=this._augnitoRange.getSelection(this._editorDocument).getRangeAt(0);e.withinRange=n;t.findText(/\[(.*?)\]/gi,e)&&(t.setStart(t.startContainer,t.startOffset),t.setEnd(t.endContainer,t.endOffset),this.setSelectionRange(this._editorDocument,t))}deleteSelection(e){null!=this._editorDocument?null==e?this._augnitoRange.getSelection(this._editorDocument).deleteFromDocument():e.execCommand("delete"):this.error("missing editor document. Make sure to provide a non null Document type")}setSelectionRange(e,t){this._augnitoRange.getSelection(e).removeAllRanges(),this._augnitoRange.getSelection(e).addRange(t)}insertTextCallback(e,t,n){const i=this._augnitoRange.getSelection(e);if(!i||0===i.rangeCount)return;let o=i.getRangeAt(0);if(o){if("\n"===t)if(this.customLineBreakFunction)this.customLineBreakFunction();else if(e!==document.getRootNode()){const t=e.createElement(ee.linkBreakElement),n=e.createElement(ee.linkBreakElement),i=e.createTextNode("");null!=o.endContainer.nextElementSibling&&o.endContainer.nextElementSibling.localName===ee.linkBreakElement||o.insertNode(n),o.insertNode(i),o.insertNode(t),o.setStartAndEnd(i,0),this._augnitoRange.getSelection(e).setSingleRange(o)}else{const t=o.cloneRange(),n=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,keyCode:13});if(e.activeElement&&e.activeElement.dispatchEvent(n),o=this._augnitoRange.getSelection(e).getRangeAt(0),o.endContainer===t.endContainer&&o.endOffset===t.endOffset){const t=e.createElement(ee.divLinkBreakElement),n=e.createElement(ee.divLinkBreakElement),i=e.createTextNode("");null!=o.endContainer.nextElementSibling&&o.endContainer.nextElementSibling.localName===ee.divLinkBreakElement||o.insertNode(n),o.insertNode(i),o.insertNode(t),o.setStartAndEnd(i,0),this._augnitoRange.getSelection(e).setSingleRange(o)}}else if(this.customTextWriteFunction&&!n)this.customTextWriteFunction(t);else{const n=e.createTextNode(t);o.insertNode(n);const i=n.nodeValue?n.nodeValue.length:0;o.setStartAndEnd(n,i),this._augnitoRange.getSelection(e).setSingleRange(o)}this.scrollElementToView(i)}}scrollElementToView(e){try{var t=e.getRangeAt(0).endContainer;t instanceof HTMLElement?t.scrollIntoView(!0):t instanceof Text&&t.parentElement&&t.parentElement.scrollIntoView(!0)}catch(e){console.log(e)}}traverseTextNodes(e,t,n,i,o,r){const a=this._augnitoRange.getSelection(o).getRangeAt(0),s=a.cloneRange();let l,c=!0,u="",d="",h=-1;for(;0!==h;){let s=!1,g=a;const f=g.cloneRange();if(0===g.endOffset&&t<0?(s=this.findLineBreakAtCursor(g.endContainer),s&&(s=!0,c=!1)):t>0&&g.endContainer.nodeType===Q.NODE_TEXT&&g.endOffset===g.endContainer.length&&(s=this.findLineBreakAtNextCursor(g.endContainer),s&&(s=!0,c=!1)),"object"==typeof n&&s&&n.includes("\n")){l=g;break}if(h=g.move(e,t),g=a,l=f.cloneRange(),g.endOffset===f.endOffset&&g.endContainer===f.endContainer)break;const p=this._augnitoRange.createRange(o);if(t<0)p.setEnd(f.endContainer,f.endOffset),p.setStart(g.endContainer,g.endOffset);else{if(!(t>0))break;p.setEnd(g.endContainer,g.endOffset),p.setStart(f.endContainer,f.endOffset)}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(p);const m=this._augnitoRange.getSelection(o);if(0===m.rangeCount)continue;const v=m.getRangeAt(0);if(u=v.toString(),""==d&&(d=u),0===v.endOffset&&t<0?(s=this.findLineBreakAtCursor(v.endContainer),s&&(s=!0,c=!1)):t>0&&v.endContainer.nodeType===Q.NODE_TEXT&&v.endOffset===v.endContainer.length&&(s=this.findLineBreakAtNextCursor(v.endContainer),s&&(s=!0,c=!1)),r?t>0?l.setStartAndEnd(f.endContainer,f.endOffset):t<0&&l.setStartAndEnd(f.startContainer,f.startOffset):t>0?l.setStartAndEnd(v.endContainer,v.endOffset):t<0&&l.setStartAndEnd(v.startContainer,v.startOffset),"number"==typeof n){let e;if(e=i?u.split(" "):u.split(" ").filter((function(e){return""!==e&&":"!==e&&";"!==e&&"."!==e})),(n-=e.length)<=0)break}else{if("object"!=typeof n)break;if(!/^[\u0085\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]+$/.test(u)&&""!==u){if(!i&&n.includes(u))break;if(i&&!n.includes(u))break}if(s&&n.includes("\n"))break}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(l),0===h&&(c=!1)}this._augnitoRange.getSelection(o).removeAllRanges(),this._augnitoRange.getSelection(o).addRange(s);return{rangeBeforeProcess:s,rangeAfterProcess:l,isCursorInSameLine:c,lastChar:u,lastImmediateChar:d}}static findActiveEditor(e){if(e instanceof HTMLIFrameElement||"iframe"===e.localName||"frame"===e.localName){let t;const n=e.contentWindow,i=n?n.document.activeElement:null;return t=i&&(i instanceof HTMLIFrameElement||"iframe"===i.localName||"frame"===i.localName)?this.findActiveEditor(i):i,t||e}return e}validateEditorDocument(e){return null==e?(this.error("Unable to add content. Must provide an editor of type Element or Document"),!1):(this._editorDocument=e.ownerDocument,null!=this._editorDocument||(this.error("invalid editor: unable to determine the owner document. An Child of Document element is required."),!1))}}class ne{constructor(e,t,n){Object.defineProperty(this,"_ranges",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_selectFor",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"badges",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.badges=[],this.createBadgesFromRanges(e)}removeBadges(){for(let e=0;e<this.badges.length;e++){const t=this.badges[e].badge;t.parentNode&&t.parentNode.removeChild(t)}}getBadge(e){return this.badges[e]}get selectFor(){return this._selectFor}get length(){return this.badges.length}createBadgesFromRanges(e){var t;for(let n=0;n<this._ranges.length;n++){const i=this._ranges[n],o=i.nativeRange.getClientRects();if(o&&1===o.length){const r=this.createBadge(n,o[0],(null===(t=e.scrollingElement)||void 0===t?void 0:t.scrollTop)||0);e.body.append(r),this.badges.push({badge:r,range:i})}}}createBadge(e,t,n){const i=document.createElement("div");return i.innerHTML=(e+1).toString(),i.contentEditable="false",i.style.position="absolute",i.style.top=t.top-18+n+"px",i.style.left=t.left-9+"px",i.style.width="24px",i.style.lineHeight="1.4",i.style.textAlign="center",i.style.backgroundColor="#313e48",i.style.color="#ffffff",i}}class ie extends te{validateDependencies(){if("undefined"==typeof CKEDITOR)throw"CKEditor Lib not found. Please add references to your project"}get editorType(){return v.CKEDITOR4}customLineBreakFunction(){const e=this.findInstance();e&&e.execCommand("enter")}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);return o.length>1?this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor):1===o.length&&(this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument))),!0}return!1}customCommandProcessor(e){let t=!1;const n=this.getEditor();return n&&("bulletliststart"!=e||this.CKEditorPanelButtonEnable("bulletedlist")?"numberliststart"!=e||this.CKEditorPanelButtonEnable("numberedlist")?"bulletliststop"==e&&this.CKEditorPanelButtonEnable("bulletedlist")?(n.commands.bulletedlist.exec(),t=!0):"numberliststop"==e&&this.CKEditorPanelButtonEnable("numberedlist")&&(n.commands.numberedlist.exec(),t=!0):(n.commands.numberedlist.exec(),t=!0):(n.commands.bulletedlist.exec(),t=!0)),t}getEditor(){return this.findInstance()}findInstance(){var e;const t=CKEDITOR;let n=null;if(t)for(const i in t.instances)if(Object.prototype.hasOwnProperty.call(t.instances,i)){const o=t.instances[i];((null===(e=U.anchoredEditor)||void 0===e?void 0:e.anchoredElement)&&o.name===U.anchoredEditor.elementName||o.focusManager.hasFocus)&&(n=o)}return n}CKEditorPanelButtonEnable(e){const t="cke_button__"+e;let n=!1;const i=document.querySelector("."+t);if(i)for(let e=0;e<(null==i?void 0:i.classList.length);e++)"cke_button_on"===i.classList[e]&&(n=!0);return n}}class oe extends te{validateDependencies(){}get editorType(){return v.CKEDITOR5}customLineBreakFunction(){const e=this.findInstance();if(e){var t=e.commands.get("enter");null==t||t.execute()}}customTextWriteFunction(e){const t=this.findInstance();if(t){0==e.indexOf(" ")&&(e=e.replace(" "," "));var n=t.data.processor.toView(e),i=t.data.toModel(n);t.model.insertContent(i,t.model.document.selection)}}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);if(o.length>1)this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor);else if(1===o.length){this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument));const t=this._augnitoRange.getSelection(this._editorDocument);this.scrollElementToView(t)}return!0}return!1}customCommandProcessor(e){let t=!1;const n=this.getEditor();if(n)if("bulletliststart"!=e||this.CKEditorPanelButtonEnable("Bulleted List"))if("numberliststart"!=e||this.CKEditorPanelButtonEnable("Numbered List")){if("bulletliststop"==e&&this.CKEditorPanelButtonEnable("Bulleted List")){var i;null==(i=n.commands.get("bulletedList"))||i.execute(),t=!0}else if("numberliststop"==e&&this.CKEditorPanelButtonEnable("Numbered List")){null==(o=n.commands.get("numberedList"))||o.execute(),t=!0}}else{var o;null==(o=n.commands.get("numberedList"))||o.execute(),t=!0}else null==(i=n.commands.get("bulletedList"))||i.execute(),t=!0;return t}customActionProcessor(e){let t=!1;const n=this.getEditor();if(n)if("bold"===(null==e?void 0:e.toLowerCase())||r.BOLD_IT===(null==e?void 0:e.toLowerCase()))null==(o=n.commands.get("bold"))||o.execute(),t=!0;else if("italicize"===(null==e?void 0:e.toLowerCase())||r.ITALICIZE_IT===(null==e?void 0:e.toLowerCase())){null==(o=n.commands.get("italic"))||o.execute(),t=!0}else if("underline"===(null==e?void 0:e.toLowerCase())||r.UNDERLINE_IT===(null==e?void 0:e.toLowerCase())){null==(o=n.commands.get("underline"))||o.execute(),t=!0}else if("capitalize"===(null==e?void 0:e.toLowerCase())||r.CAPITALIZED_IT===(null==e?void 0:e.toLowerCase()));else if(r.DELETE===(null==e?void 0:e.toLowerCase())||"deleteit"===(null==e?void 0:e.toLowerCase())||r.PRESS_DELETE===(null==e?void 0:e.toLowerCase())){var i=n.commands.get("delete");null==i||i.execute(),t=!0}else if(r.SELECT_ALL===(null==e?void 0:e.toLowerCase())){var o;null==(o=n.commands.get("selectAll"))||o.execute(),t=!0}return t}getEditor(){return this.findInstance()}getActiveEditorElement(){let e=U.getActiveEditorElement();if(e){const t=te.findActiveEditor(e);t&&(e=t)}return e}findInstance(){let e=null;var t=this.getActiveEditorElement();t&&t.classList.contains("ck-editor__editable")&&(e=Object.getOwnPropertyDescriptors(t).ckeditorInstance.value);return e}CKEditorPanelButtonEnable(e){const t='[data-cke-tooltip-text="'+e+'"]';let n=!1;const i=document.querySelector(t);if(i)for(let e=0;e<(null==i?void 0:i.classList.length);e++)"ck-on"===i.classList[e]&&(n=!0);return n}}class re extends G{constructor(e){super(e,"DevExpressRichEditProcessor"),Object.defineProperty(this,"searchWordList",{enumerable:!0,configurable:!0,writable:!0,value:[]})}get editorType(){return v.DEVEXPRESS}processFinalResult(e,t){var n,i=t;i.beginUpdate(),i.history.beginTransaction(),this.searchWordList=[],y(i);var o=i.selection.activeSubDocument,r=i.selection.intervals[0],a=this.GetLastCharacter(i),s=V.ProcessText(e.receivedText,a,o.length,r);e.receivedText=s.ReceivedText,r.length>0&&(i._native.core.commandManager.getCommand(125).execute(!1),r.length=0,i.selection.setSelection(r));var l=null===(n=e.receivedText)||void 0===n?void 0:n.split("\n");if(l&&l.length>0)for(var c=0;c<l.length;c++){""!=l[c]&&("."==l[c].trim()||":"==l[c].trim()?i._native.core.commandManager.getCommand(117).execute(!1,l[c].trim()):i._native.core.commandManager.getCommand(117).execute(!1,l[c])),l.length>1&&!(c==l.length-2&&""==l[l.length-1]||c==l.length-1&&""!=l[c])&&i._native.core.commandManager.getCommand(116).execute(!1)}this.ApplyPostBeautification(e,s.EndLine,i),i.history.endTransaction(),i.endUpdate()}processCommand(e,t){var n,i,o,a,s,l,c,u,d,h=t.selection.anchor,g=t.selection.intervals,f=t.document.subDocuments._core.commandManager,p=g[0],m=NaN,v=this.searchWordList;if(this.searchWordList=[],null!=e.searchText&&(m=parseInt(e.searchText.trim())),y(t),e.action===r.SPACE_ADD)t._native.core.commandManager.getCommand(117).execute(!1," "),p.start=h+1,p.length=0,t.selection.setSelection(p);else if(r.SELECT==(null===(n=e.name)||void 0===n?void 0:n.toLowerCase())&&"all"==(null===(i=e.searchText)||void 0===i?void 0:i.toLowerCase())&&"delete"==(null===(o=e.selectFor)||void 0===o?void 0:o.toLowerCase()))t._native.core.commandManager.getCommand(106).execute(!1,void 0),t._native.core.commandManager.getCommand(126).execute(!1);else if(r.SELECT==(null===(a=e.name)||void 0===a?void 0:a.toLowerCase())&&""==e.action||!isNaN(m))if(!isNaN(m)&&null!=v&&v.length>0){var b=v.filter((t=>{var n;return t.HighlightButton.innerHTML==(null===(n=e.searchText)||void 0===n?void 0:n.trim())}));b.length>0&&t.selection.setSelection(b[0].WordInterval)}else this.searchWordList=function(e,t){var n,i=N(e,t,"");if(1==i.length)return y(t),void t.selection.setSelection(i[0]);i=i.sort((function(e,t){return e.start-t.start}));var o=document.querySelectorAll(".dxreSelSearch"),r=[];if(o.length>0)for(var a=0;a<o.length;a++){var s=o[a],l=document.createElement("button");l.innerHTML=a+1,l.style.position="absolute",l.style.zIndex=9e3,l.style.left=(s.offsetLeft+s.offsetWidth/2-12.5).toString()+"px",l.style.top=(s.offsetTop-21).toString()+"px",l.style.width=25..toString()+"px",l.style.height=21..toString()+"px",l.style.backgroundColor="teal",l.style.color="white",l.className="searchIndex",l.disabled=!0,null===(n=document.querySelector(".dxreControl"))||void 0===n||n.querySelectorAll(".dxrePageService")[0].appendChild(l),r.push({HighlightButton:l,WordInterval:i[a]})}return r}(e,t);else if(e.action==r.SELECT)!function(e,t){var n;e.searchText||(e.searchText="");var i=e.searchText.replace(/ /gi,"").toLowerCase().trim(),o=e.nextPrevious,r=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;if("nextword"==i||"next"==o)return _(e.name,r,t)&&e.selectFor&&A(e.selectFor,t),!0;if("previousword"==i||"it"==i||"that"==i||"previous"==o||"last"==o){var a=L(null!==(n=e.name)&&void 0!==n?n:"",r,t);return a&&e.selectFor&&("delete"==e.selectFor.toLowerCase()&&a[0].start>0&&(a=O(a,t),t.selection.setSelection(a[0])),A(e.selectFor,t)),!0}}(e,t),e.selectFor&&((p=t.selection.intervals[0]).start=p.start+p.length,p.length=0,t.selection.setSelection(p));else if(e.action&&e.action.toLowerCase().indexOf("dynamic")>=0)R(e,t);else if("bulletliststart"==(null===(s=e.action)||void 0===s?void 0:s.toLowerCase())||"bulletliststop"==(null===(l=e.action)||void 0===l?void 0:l.toLowerCase()))j("togglebulletedlistitem",t);else if("deselectit"==(null===(c=e.action)||void 0===c?void 0:c.toLowerCase())){(p=t.selection.intervals[0]).start=p.start+p.length,"\r"==t.selection.activeSubDocument.getText().substr(p.start-1,1)&&(p.start=p.start-1),p.length=0,t.selection.setSelection(p)}else{if(A(null!==(u=e.action)&&void 0!==u?u:"",t))return;if(e.action){var E=T[null===(d=e.action)||void 0===d?void 0:d.toLowerCase().trim()];if(null!=E&&null!=E)f.getCommand(E).execute(!1,void 0)}}}GetLastCharacter(e){for(var t=[],n=0,i=e.selection,o=i.intervals[0].start,r=o-4,a=o,s=i.activeSubDocument.getText().length,l=r;l<a;l++)t[n]=l<0||l>=s?null:i.activeSubDocument.getText().substr(l,1),n++;return t}ApplyPostBeautification(e,t,n){var i,o,r,a,s=n.selection,l=n.selection.intervals,c=s.activeSubDocument.getText().length,u=l[0].start;if(!(u>=c)){var d,h,g=(null===(i=e.name)||void 0===i?void 0:i.endsWith("."))||(null===(o=e.receivedText)||void 0===o?void 0:o.endsWith(".")),f=(null===(r=e.name)||void 0===r?void 0:r.endsWith("\n"))||(null===(a=e.receivedText)||void 0===a?void 0:a.endsWith("\n")),p=g||f,m=l[0];if(u<c){var v=m.start;if(m.start=u,m.length=1,n.selection.setSelection(m),d=l){var b=n.selection.activeSubDocument.getText(),E=b.substr(d[0].start,d[0].length),S="";if(d[0].start+1<c&&(S=n.selection.activeSubDocument.getText(d[0])),E&&E.trim().length>0||"\r"==S||"\v"==S){t&&(E=E.toLowerCase()),p&&(E=E.toUpperCase()),"\r"!=S&&"\v"!=S||(m.start=m.start+1,E=(E=b.substr(d[0].start,d[0].length)).toUpperCase(),n.selection.setSelection(m)),"\r"!=E&&n._native.core.commandManager.getCommand(125).execute(!1);var C=(f||"\r"==S||"\v"==S||[",",".",":"].includes(S)?"":" ")+E,T=s.anchor;n.selection.setSelection(T),n._native.core.commandManager.getCommand(117).execute(!1,C),m.start=T+C.length+1,m.length=1;var R=n.document.getCharacterProperties(m);return m.start=T,m.length=C.length,n.document.setCharacterProperties(m,R),"\r"!=S&&"\v"!=S||(m.start=m.start-1,m.length=0,n.selection.setSelection(m)),m.start=v,m.length=0,void n.selection.setSelection(m)}m.start=d[0].start,m.length=0,n.selection.setSelection(m)}}if(u+1<c&&(m.start=u+1,m.length=1,n.selection.setSelection(m),h=l)){var y=n.selection.activeSubDocument.getText().substr(h[0].start,h[0].length);if(y&&y.trim().length>0){if(y.length>1)return;t&&(y=y.toLowerCase());S=n.selection.activeSubDocument.getText(h[0]);(p||"\v"==S)&&(y=y.toUpperCase()),n._native.core.commandManager.getCommand(125).execute(!1);T=s.anchor;n.selection.setSelection(T),n._native.core.commandManager.getCommand(117).execute(!1,y),m.start=T+y.length+1,m.length=1;R=n.document.getCharacterProperties(m);if(m.start=T,m.length=y.length,n.document.setCharacterProperties(m,R),m.start=h[0].start-1,m.length=0,s.setSelection(m),f&&u<c&&(m.start=u,m.length=1,n.selection.setSelection(m),d=l)){var N=s.activeSubDocument.getText().substr(d[0].start,d[0].length);N&&0==N.trim().length&&"\r"!=N&&n._native.core.commandManager.getCommand(125).execute(!1)}return m.start=h[0].start,m.length=0,void n.selection.setSelection(m)}m.start=h[0].start-1,m.length=0,n.selection.setSelection(m)}}}}class ae extends te{constructor(){super(...arguments),Object.defineProperty(this,"insertTextAtCursorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}validateDependencies(){}get editorType(){return v.GENERIC}customSelectProcessor(e){if(null==this._editorDocument)return this.error("missing editor document. Make sure to provide a non null Document type"),!1;const t=this._augnitoRange.createRange(this._editorDocument);if(t.selectNodeContents(this._editorDocument.body),""!==e.searchText){const n=e.searchText||"",i={caseSensitive:!1,wholeWordsOnly:!1},o=[];for(;t.findText(n,i);)o.push(t.cloneRange()),t.collapse(!1);return o.length>1?this._dynamicSelect=new ne(this._editorDocument,o,e.selectFor):1===o.length&&(this.setSelectionRange(this._editorDocument,o[0]),e.selectFor&&(this.processSelectForAction(e.selectFor,this._editorDocument),this.deSelectSelection(this._editorDocument))),!0}return!1}customCommandProcessor(e){return!1}}class se extends G{constructor(e){super(e,"HTMLInteropProcessor"),Object.defineProperty(this,"_buffer",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"stringWriteAtCaret",{enumerable:!0,configurable:!0,writable:!0,value:(e,t,n,i)=>{const o=e.substring(0,n);let r=e.substring(n);r.length>0&&t[0]===t[0].toUpperCase()&&!t.endsWith(". ")&&!t.endsWith(".")&&r[0]===r[0].toUpperCase()&&(r=r[0].toLowerCase()+r.substring(1)),e=o+t+r,i.value=e;const a=o.length+t.length;this.setCaretPosition(a,i),this.fireEvents(i)}})}get buffer(){return this._buffer}get editorType(){return v.HTML}processFinalResult(e,t){t.focus();const n=V.beautify(e.receivedText||"");this.isTextSelected(t)&&this.deleteSelected(t);const i=this.getCaretPosition(t),o=this.beautify(n,i,t.value);this.stringWriteAtCaret(t.value,o,i,t)}processCommand(e,t){t.focus();const n=this.getCaretPosition(t),i=t.value;let o=!1;if(e.action===r.PRESS_DELETE)this.isTextSelected(t)||(e.name=r.SELECT_WORD,this.selectWordLineSentence(e,i,n,t)),this.deleteSelected(t),o=!0;else if(e.name===r.SELECT_WORD)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.name===r.SELECT_LINE)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.action===r.SELECT_ALL)t.setSelectionRange(0,t.value.length),o=!0;else if(e.name===r.SELECT_SENTENCE)this.selectWordLineSentence(e,i,n,t),e.selectFor===r.DELETE&&this.deleteSelected(t),o=!0;else if(e.action===r.GO_TO_LINE_START)this.setCaretPosition(this.getStartOfLine(i,n),t),o=!0;else if(e.action===r.GO_TO_DOCUMENT_START)this.setCaretPosition(0,t),o=!0;else if(e.action===r.GO_TO_DOCUMENT_END)this.setCaretPosition(i.length,t),o=!0;else if(e.action===r.GO_TO_LINE_END){const e=this.getEndOfLine(i,n);this.setCaretPosition(e,t),o=!0}else e.action===r.COPY_IT?(this.copySelected(t),o=!0):e.action===r.UNDO_IT?(this.undo(),this.setCaretPosition(t.selectionEnd||t.value.length,t),o=!0):e.action===r.REDO_IT?(this.redo(),o=!0):e.action===r.DOCUMENT_PRINT?(this.print(),o=!0):e.action===r.SPACE_ADD?(this.stringWriteAtCaret(i," ",n,t),o=!0):e.action===r.NEXT_FIELD?this.searchDynamicFiled("forward",i,t):e.action===r.PREVIOUS_FIELD?this.searchDynamicFiled("backward",i,t):this.log("Command NOT Processed");return o}selectWordLineSentence(e,t,n,i){let o=i.value.length,a=e.nextPrevious;a||(a="previous");let s=e.chooseNumber&&e.chooseNumber>0?e.chooseNumber:1;const l=t.length===n;if("next"===a)n=Math.max(n,i.selectionEnd||i.value.length);else if("previous"===a||"last"===a){const e=this.getCaretPosition(i);n=Math.min(n,e-1)}let c=n;const u=this.getDelimiterArray(e);if("next"===a){const e=!0;for(;e;){if(n>t.length){n=t.length;break}if(t[n]===u[0])n++;else{if(!(u.length>1&&t[n]===u[1]))break;n++}}c=n,o=n;let i=!1;for(let e=n;e-1>=0&&!1===i;e--)for(const n of u)if(t[e-1]===n){c=e,i=!0;break}i||(c=0);for(let e=n;e<t.length&&s>0;e++,o++)for(const n of u)t[e]===n&&s--;s>0&&(o=t.length)}else if("previous"===a||"last"===a){const i=!0;for(;i;){if(n<0){n=0;break}if(t[n]===u[0])n--;else{if(!(u.length>1&&t[n]===u[1]))break;n--}}c=n,o=n;let a=!1;for(let e=n;e<t.length&&!1===a;e++)for(const n of u)if(t[e]===n){o=e+1,a=!0;break}a||(o=t.length);for(let e=n;e>=0&&s>0;e--,c--){for(const n of u)t[e]===n&&s--;if(0===s){c=e+1;break}}s>0&&(c=0),c>0&&"delete"===e.selectFor&&d.setSelectObjectType(e.searchText||"")===r.SELECT_WORD&&l&&c--}i.setSelectionRange(c,o)}getDelimiterArray(e){let t=[];return e.name===r.SELECT_WORD||e.name===r.SELECT_ACTIVE_WORD?t=[" ","\n"]:e.name===r.SELECT_LINE||e.name===r.SELECT_ACTIVE_LINE?t=["\n"]:e.name!==r.SELECT_SENTENCE&&e.name!==r.SELECT_ACTIVE_SENTENCE||(t=["."]),t}isTextSelected(e){return e.selectionStart!==e.selectionEnd}deleteSelected(e){const t=this.getCaretPosition(e);document.execCommand("delete",!1,void 0),this.setCaretPosition(t,e)}getSelectedText(e){const t=e.value,n=e.selectionStart,i=e.selectionEnd;return n&&i?t.substring(n,i):""}copySelected(e){this._buffer=this.getSelectedText(e),document.execCommand("copy")}undo(){document.execCommand("undo")}redo(){document.execCommand("redo")}print(){window.print()}getStartOfLine(e,t){for(let n=t;n>=0;n--)if(n===t&&"\n"===e[n]&&n--,"\n"===e[n])return n+1;return 0}getEndOfLine(e,t){for(let n=t;n<e.length;n++)if("\n"===e[n])return n;return e.length}beautify(e,t,n){let i=e;if(""===n&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1))," \n"!==i&&" \n\n"!==i||(i=this.trimLeft(i)),n.length>1&&(" "===n[t-1]&&"."===n[t-2]||0===t)&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1)),n.length>0&&" "===n[t-1]&&(i=this.trimLeft(i)),n.length>0&&"\n"===n[t-1]&&(i=this.trimLeft(i),i=i[0].toUpperCase()+i.substring(1)),n.length>0&&("."===n[t-1]||":"===n[t-1]||"#"===n[t-1])){const e=this.trimLeft(i);e.length>0&&(i=" "+e[0].toUpperCase()),e.length>1&&(i+=e.substring(1))}"."!==i.trim()&&":"!==i.trim()||(i=this.trimLeft(i));var o=i.trim();return o.length>0&&("."===o[0]||":"===o[0])&&(i=this.trimLeft(i)),i}trimLeft(e){return e=(e=(e=e.replace(/\n/gi,"@newline@")).trimStart()).replace(new RegExp("@newline@","gi"),"\n")}setCaretPosition(e,t){t.setSelectionRange(e,e)}fireEvents(e){const t=new KeyboardEvent("keyup",{bubbles:!0,cancelable:!0,keyCode:13});e.dispatchEvent(t);const n=new Event("input",{bubbles:!0,cancelable:!0});e.dispatchEvent(n)}getCaretPosition(e){return null===e.selectionStart?e.value?e.value.length:0:e.selectionStart}searchDynamicFiled(e,t,n){if(null!==n.selectionStart&&null!==n.selectionEnd)switch(e){case"forward":this.searchDynamicFieldForward(n.selectionEnd,t,n);break;case"backward":this.searchDynamicFieldBackward(n.selectionStart,t,n)}}searchDynamicFieldForward(e,t,n){const i=/\[(.*?)\]/gi;let o;const r=t.substring(e);null!==(o=i.exec(r))&&n.setSelectionRange(o.index+e,i.lastIndex+e)}searchDynamicFieldBackward(e,t,n){const i=/\[(.*?)\]/gi;let o;const r=t.substring(0,e);let a=-1,s=-1;for(;null!==(o=i.exec(r));)a=o.index,s=i.lastIndex;-1!==a&&-1!==s&&n.setSelectionRange(a,s)}}class le{static createProcessor(e,t){switch(e){case v.HTML:return new se(t);case v.CKEDITOR4:return new ie(t);case v.CKEDITOR5:return new oe(t);case v.DEVEXPRESS:return new re(t);case v.GENERIC:return new ae(t);default:throw new TypeError(`Processor for editor ${e} not implemented`)}}}class ce{constructor(e,t,n){Object.defineProperty(this,"_listOfControls",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_editorType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_interopProcessors",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"ProcessorHandler"}),n&&this.getProcessor(n)}getProcessorForEditor(e){if(this._editorType==v.DEVEXPRESS)return this.getProcessor(this._editorType);if(e.id){const t=this._listOfControls.find((t=>t.controlId==e.id));if(this._listOfControls.length>0&&t&&t.type)return this.getProcessor(t.type)}if(this.isHtmlEditor(e))return this.getProcessor(v.HTML);if(this.isContentEditable(e)&&this._editorType)return this.getProcessor(this._editorType);throw new Error("Editor not implemented: Unknown contentEditable")}getValidEditor(){const e=this.getActiveEditorElement();return e?this._editorType===v.DEVEXPRESS||this.isValidEditor(e)?e:(a.log("unable to validate the provided editor. Has focus ? Is it on the list of control ? has and id set ?",this._logTag),null):(a.log("unable to find a focused editor",this._logTag),null)}getActiveEditorElement(){if(this._listOfControls&&this._listOfControls.length>0&&this._listOfControls[0].editorInstance)return this._listOfControls[0].editorInstance;let e=U.getActiveEditorElement();if(e){const t=te.findActiveEditor(e);t&&(e=t)}return e}isValidEditor(e){if(this._listOfControls.length>0&&e.id){const t=e.id;return void 0!==this._listOfControls.find((e=>e.controlId===t))}return!!this.isHtmlEditor(e)||!(!this.isContentEditable(e)||!this._editorType)}getProcessor(e){let t=this._interopProcessors.find((t=>t.editorType===e));return t||(t=le.createProcessor(e,this._enableLogs),this._interopProcessors.push(t),t)}isHtmlEditor(e){return"TEXTAREA"===e.nodeName||"INPUT"===e.nodeName}isContentEditable(e){return e.isContentEditable}}class ue{constructor(e,t,n){Object.defineProperty(this,"_listOfControls",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_editor",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"processorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.processorHandler=new ce(e,t,n)}onFinalResult(e){const t=this.processorHandler.getValidEditor();if(t){this.processorHandler.getProcessorForEditor(t).processFinalResult(e,t)}}onCommandResult(e){const t=this.processorHandler.getValidEditor();if(t){if(this.interfaceSharedCommand(e,t))return;this.processorHandler.getProcessorForEditor(t).processCommand(e,t)}}onSetAnchoredEditor(e,t){U.setAnchoredElement(e,t)}handleDynamicFieldNavigation(e){if(this._editor==v.DEVEXPRESS){const t=this.processorHandler.getValidEditor();R(e,t)}}handleGotoDocumentEnd(){const e=this.processorHandler.getValidEditor();var t;j("gotodocumentend",t=e),t.focus()}getCursorPosition(){return this.processorHandler.getValidEditor().selection.intervals[0].start}setCursorAtPosition(e){const t=this.processorHandler.getValidEditor();t.selection.setSelection(e),t.focus()}interfaceSharedCommand(e,t){if(e.name!==r.GOTO)return!1;if(e.searchText){const n=e.searchText.replace(/\s+/g,"");if("nextfield"===n||"nextfields"===n)U.moveToNextField(t,this._listOfControls);else if("previousfield"===n||"previousfields"===n)U.moveToPreviousField(t,this._listOfControls);else{const e=e=>e.controlName===n,t=this._listOfControls.findIndex(e);if(t>-1){const e=this._listOfControls[t];e&&document.querySelector("#"+e.controlId).focus()}}}return!0}}class de{constructor(e,t){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_webClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"onMicrophoneOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}get clientConfig(){return this._config}get enableLogs(){return this._config.enableLogs}setEnableLogs(e){this._config.enableLogs=e}get deviceId(){return this._webClient.getConfig().clientConfig.deviceId}get userTag(){return this._webClient.getConfig().clientConfig.userTag}startListening(e){this._webClient.startListening(this.prepareSpeechMicURL(e),n.MOBILE_APP)}stopListening(){this._webClient&&this._webClient.stopListening(!1)}prepareNotificationURL(){const e=this._webClient.getConfig();let t=e.pushNotificationURL;return t+=`?devicecode=${e.clientConfig.deviceId}`,t+=`¤tTabId=${E()}`,t+=`&accountcode=${e.clientConfig.accountCode}`,t+=`&accesskey=${e.clientConfig.accessKey}`,t=t.replace(new RegExp("amp;","gi"),""),t}prepareSpeechMicURL(e){const t=this._webClient.getConfig();let n=this._webClient.getConfig().speechMicURL;return n+=`?accountcode=${t.clientConfig.accountCode}`,n+=`&usertag=${t.clientConfig.userTag}`,n+=`&seqid=${e.SeqId}`,n+=`&mobiledevicecode=${e.FromDeviceId}`,n+=`&clientdevicecode=${t.clientConfig.deviceId}`,n=n.replace(new RegExp("amp;","gi"),""),n}}class he{constructor(e){Object.defineProperty(this,"_mobileClient",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"onConnectionRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMobileScan",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e.onConnectionRequest=this.onConnectionRequestCallback.bind(this),e.onMobileScan=this.onMobileScanCallback.bind(this)}dispose(){this._mobileClient.dispose()}stopMobileMicConnection(){this._mobileClient.stopMobileListening()}onConnectionRequestCallback(){this.onConnectionRequest&&this.onConnectionRequest()}onMobileScanCallback(){this.onMobileScan&&this.onMobileScan()}}function ge(e,t,n,i){return new(n||(n=Promise))((function(o,r){function a(e){try{l(i.next(e))}catch(e){r(e)}}function s(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class fe{makePostRequest(e,t){return ge(this,void 0,void 0,(function*(){try{const n=yield fetch(t,{method:"POST",headers:{accept:"*/*","Content-Type":"application/json"},body:JSON.stringify(e)}),i=yield n.json();return[200,0].includes(i.Status)?i:i.ErrorMessage}catch(e){return e instanceof Error?e.message:"Unknown Error"}}))}}class pe extends fe{constructor(e,t,n){super(),Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e,"AccountCode"),g.Against.NullOrEmpty(t,"AccessKey"),g.Against.NullOrEmpty(n,"Server"),this._baseUrl=`https://${n}/manage/v2/macro`}getMacros(e){return ge(this,void 0,void 0,(function*(){return yield this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/fetchall"))}))}upsertMacro(e){return ge(this,void 0,void 0,(function*(){return this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/modify"))}))}deleteMacro(e){return ge(this,void 0,void 0,(function*(){return this.makePostRequest(Object.assign(Object.assign({},e),this.getAccountModel()),this.getURL("/delete"))}))}getURL(e){return`${this._baseUrl}${e}`}getAccountModel(){return{AccountCode:this._accountCode,AccessKey:this._accessKey}}}function me(){me=function(){return t};var e,t={},n=Object.prototype,i=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},r="function"==typeof Symbol?Symbol:{},a=r.iterator||"@@iterator",s=r.asyncIterator||"@@asyncIterator",l=r.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,i){var r=t&&t.prototype instanceof v?t:v,a=Object.create(r.prototype),s=new L(i||[]);return o(a,"_invoke",{value:O(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var h="suspendedStart",g="suspendedYield",f="executing",p="completed",m={};function v(){}function b(){}function E(){}var S={};c(S,a,(function(){return this}));var C=Object.getPrototypeOf,T=C&&C(C(I([])));T&&T!==n&&i.call(T,a)&&(S=T);var R=E.prototype=v.prototype=Object.create(S);function y(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function N(e,t){function n(o,r,a,s){var l=d(e[o],e,r);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(l.arg)}var r;o(this,"_invoke",{value:function(e,i){function o(){return new t((function(t,o){n(e,i,t,o)}))}return r=r?r.then(o,o):o()}})}function O(t,n,i){var o=h;return function(r,a){if(o===f)throw Error("Generator is already running");if(o===p){if("throw"===r)throw a;return{value:e,done:!0}}for(i.method=r,i.arg=a;;){var s=i.delegate;if(s){var l=A(s,i);if(l){if(l===m)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(o===h)throw o=p,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);o=f;var c=d(t,n,i);if("normal"===c.type){if(o=i.done?p:g,c.arg===m)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(o=p,i.method="throw",i.arg=c.arg)}}}function A(t,n){var i=n.method,o=t.iterator[i];if(o===e)return n.delegate=null,"throw"===i&&t.iterator.return&&(n.method="return",n.arg=e,A(t,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var r=d(o,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,m;var a=r.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function w(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 _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function L(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function I(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,r=function n(){for(;++o<t.length;)if(i.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return r.next=r}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=E,o(R,"constructor",{value:E,configurable:!0}),o(E,"constructor",{value:b,configurable:!0}),b.displayName=c(E,l,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,c(e,l,"GeneratorFunction")),e.prototype=Object.create(R),e},t.awrap=function(e){return{__await:e}},y(N.prototype),c(N.prototype,s,(function(){return this})),t.AsyncIterator=N,t.async=function(e,n,i,o,r){void 0===r&&(r=Promise);var a=new N(u(e,n,i,o),r);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(R),c(R,l,"Generator"),c(R,a,(function(){return this})),c(R,"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=I,L.prototype={constructor:L,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)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 o(i,o){return s.type="throw",s.arg=t,n.next=i,o&&(n.method="next",n.arg=e),!!o}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(l&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&i.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var r=o;break}}r&&("break"===e||"continue"===e)&&r.tryLoc<=t&&t<=r.finallyLoc&&(r=null);var a=r?r.completion:{};return a.type=e,a.arg=t,r?(this.method="next",this.next=r.finallyLoc,m):this.complete(a)},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),m},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),_(n),m}},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 o=i.arg;_(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,n,i){return this.delegate={iterator:I(t),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=e),m}},t}function ve(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 be(e,t,n,i,o,r,a){try{var s=e[r](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(i,o)}function Ee(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var r=e.apply(t,n);function a(e){be(r,i,o,a,s,"next",e)}function s(e){be(r,i,o,a,s,"throw",e)}a(void 0)}))}}function Se(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ce(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,ve(i.key),i)}}function Te(e,t,n){return t&&Ce(e.prototype,t),n&&Ce(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}var Re="DONE",ye="PAUSESOCKET",Ne="RESUMESOCKET",Oe="CLOSE",Ae=12e4,we=Te((function e(t,n,i,o,r,a,s,l,c,u,d,h){Se(this,e),this.worker,this.onFinalResultCallback=r,this.onErrorCallback=s,this.onPartialResultCallback=a,this.onSessionEventCallback=l,this.onOtherResultsCallback=c,this.onSpeechResponseCallback=u,this.packetSeqId=0,this.audioDuration=0,this.shouldSendAudioDataSequence=o,this.heavyOp,this.idleLoop,this.lastSent,this.enableLogs=t,this.eosMessage=n||"EOS",this.socketTimeoutInterval=i||1e4,this.bufferSizeInterval=d,this.switchToRegularSpeech=h}),[{key:"Start",value:function(e,t){var n=this;this.audioDuration=e;var i="\n (() => {\n (".concat(_e.toString(),")(").concat(JSON.stringify(Re),", ").concat(JSON.stringify(this.eosMessage),", ").concat(JSON.stringify(Oe),", ").concat(JSON.stringify(1e4),", ").concat(JSON.stringify(this.socketTimeoutInterval),", ").concat(JSON.stringify(1e3),", ").concat(JSON.stringify(100),", ").concat(JSON.stringify(t),", ").concat(JSON.stringify(this.enableLogs),", ").concat(JSON.stringify(this.shouldSendAudioDataSequence),",").concat(JSON.stringify(ye),", ").concat(JSON.stringify(Ne),", ").concat(JSON.stringify(this.switchToRegularSpeech),", ").concat(JSON.stringify(this.heavyOp),");\n })();\n");this.worker=new Worker(URL.createObjectURL(new Blob([i],{type:"application/javascript"}))),this.worker.onmessage=function(e){n.enableLogs&&console.log("Augnito [MAIN]: "+JSON.stringify(e.data));var t=e.data;"final"==t.type?n.onFinalResultCallback(t.data):"partial"==t.type?n.onPartialResultCallback(t.data):"meta"==t.type?n.onSessionEventCallback(t.data):"error"==t.type?n.onErrorCallback(t.data):"other"==t.type?n.onOtherResultsCallback(t.data):"speechResponse"==t.type&&n.onSpeechResponseCallback(t.data)},this.idleLoop=setInterval((function(){var e=+new Date;n.lastSent&&e-n.lastSent>Ae&&(n.Send(n.eosMessage),n.enableLogs&&console.warn("No data sent since more than ".concat(120," secs, closing time...")))}),1e4)}},{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),o=new Uint8Array(i);return o.set(new Uint8Array(e),0),o.set(new Uint8Array(t),e.byteLength),i}},{key:"Send",value:function(e){var t;if(this.lastSent=+new Date,e===Oe)null===(t=this.worker)||void 0===t||t.postMessage(Oe),clearInterval(this.idleLoop);else if(e===Re){if(this.shouldSendAudioDataSequence){var n,i=this.createAudioPacketHeader(!0);null===(n=this.worker)||void 0===n||n.postMessage(i)}else{var o;null===(o=this.worker)||void 0===o||o.postMessage(Re)}clearInterval(this.idleLoop)}else if(e==ye){var r;null===(r=this.worker)||void 0===r||r.postMessage(ye)}else if(e==Ne){var a;null===(a=this.worker)||void 0===a||a.postMessage(Ne)}else if(e===this.eosMessage){var s;this.shouldSendAudioDataSequence||null===(s=this.worker)||void 0===s||s.postMessage(e)}else{var l,c=[];this.shouldSendAudioDataSequence?(i=this.createAudioPacketHeader(!1),c=this.appendAudioData(i,e)):c=e,void 0!==c&&(null===(l=this.worker)||void 0===l||l.postMessage(c,[c]))}}},{key:"HeavyOp",set:function(e){this.heavyOp=e}}]);function _e(e,t,n,i,o,r,a,s,l,c,u,d,h,g){var f,p,m,v,b,E,S,C,T=[],R=[],y=!1,N=!1,O=!1,A="",w=!1;function _(){f=+new Date,(E=""!=A?new WebSocket(s+"&jobid="+A):new WebSocket(s)).onopen=function(e){l&&console.log("Augnito: WebSocket connection established - "+JSON.stringify(e)),R.length>0&&(N=!0)},E.onmessage=function(e){l&&console.log("Augnito: Message from server - "+JSON.stringify(e.data)),m=+new Date,function(e){try{if("PING"===e.data)v=+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&&(A=t.JobID,console.log("Augnito JobID:",A)),self.postMessage({type:"meta",data:e.data});var n=JSON.parse(e.data);O=!(!n.Event||"INVALID_AUTH_CREDENTIALS"!==n.Event.Type)}else if(t.Result&&t.Result.Final){var i=JSON.stringify(t.Result);g&&(i=g(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?(R=R.filter((function(e){return e.packetNumber>t.Index})),self.postMessage({type:"other",data:e.data})):"ERROR"==t.Type?("Timeout exceeded"==t.Data&&(y=!0,x()),self.postMessage({type:"error",data: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)),x()},p=+new Date,m=p,v=+new Date}function L(e){if(E&&E.readyState===WebSocket.OPEN){E.send(e);var n=+new Date;return p<=m&&(m=n-1),p=n,!0}return e===t?(l&&console.warn("Gulping ".concat(t," as socket seems already closed...")),x(),!0):(+new Date-f>i&&!O&&_(),!1)}function I(e){T.push(e)}function x(){y&&(clearInterval(S),clearInterval(C),T=[],R=[],self.close())}_(),S=setInterval((function(){if(N){for(var e=0;e<R.length;e++){if(!L(R[e].packetData))break}N=!1}else for(;T.length>0;){var t=T.shift();if(!L(t)){T.unshift(t);break}if(c){var n=new DataView(t),i={packetNumber:Number(n.getBigInt64(4)),packetData:t};R.push(i)}}}),a),C=setInterval((function(){if(E&&E.readyState===WebSocket.OPEN){var e=+new Date;(h?p>m&&e-m>o:e-v>o)&&(l&&console.error("No data received since more than ".concat(o/1e3," secs, closing time...")),E.close())}}),r),self.onmessage=function(i){i.data===n?(A="",y=!0,O=!0,E.close()):i.data===e?(I(t),A="",l&&console.log("Augnito: Worker received DONE, time to terminate..."),y=!0):i.data===u?w=!0:i.data===d?(I(b),w=!1,b=[]):w?b=i.data:I(i.data)}}var Le,Ie,xe,Pe,Me,De,ke,Be,Fe,je=Te((function e(t,n,i,o,r,a,s,l,c,u,d,h,g,f,p,m,v,b,E){Se(this,e),this.audioContext,this.audioStream,this.executor=new we(t,r,a,s,h,g,f,m,v,b,i,u),this.executor.HeavyOp=d,this.source,this.processorNode,this.isPaused=!1,this.isStreaming=!1,this.audioData=[],this.isDebug=n,this.enableLogs=t,this.onStateChanged=p,this.onIntensity=E,this.onError=f,this.bufferSizeInterval=i,this.pausedBufferInterval=null!=o?o:1,this.shouldReadIntensity=c,this.closeSocketWithoutEOS=!1,this.shouldPreIntialiseRecorder=null!=l&&l,this.shouldPreIntialiseRecorder&&this.InitialiseMediaStream()}),[{key:"InitialiseMediaStream",value:(Fe=Ee(me().mark((function e(){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createMediaStreamSourceNode();case 2:if(this.source){e.next=5;break}return console.error("Error: unable to create source node"),e.abrupt("return",!1);case 5:return e.next=7,this.createProcessorNode();case 7:if(this.processorNode){e.next=10;break}return console.error("Error: unable to create processor node"),e.abrupt("return",!1);case 10:this.source.connect(this.processorNode).connect(this.audioContext.destination),this.log("AudioContext Sample Rate: "+this.audioContext.sampleRate);case 12:case"end":return e.stop()}}),e,this)}))),function(){return Fe.apply(this,arguments)})},{key:"StartStream",value:(Be=Ee(me().mark((function e(t,n){return me().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();case 4:e.next=9;break;case 6:if("suspended"!=this.audioContext.state){e.next=9;break}return e.next=9,this.audioContext.resume();case 9:if(!this.IsMicrophoneMuted){e.next=15;break}if(!this.audioContext||"running"!=this.audioContext.state){e.next=13;break}return e.next=13,this.audioContext.suspend();case 13:return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return",!1);case 15:return""!==n&&this.executor.Start(t,n),this.onStateChanged(!0),this.isStreaming=!0,e.abrupt("return",!0);case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return Be.apply(this,arguments)})},{key:"createBufferedSourceNode",value:(ke=Ee(me().mark((function e(){var t;return me().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 ke.apply(this,arguments)})},{key:"createMediaStreamSourceNode",value:(De=Ee(me().mark((function e(){var t,n=this;return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!1}});case 3:this.audioStream=e.sent,this.audioContext=new AudioContext,this.source=this.audioContext.createMediaStreamSource(this.audioStream),this.audioStream.getAudioTracks()[0].addEventListener("ended",(function(){n.onError(JSON.stringify({Type:"ERROR",Data:"Audio track ended. Possibly the mic was unplugged."}))})),e.next=14;break;case 9:e.prev=9,e.t0=e.catch(0),t="","NotAllowedError"==e.t0.name?t="Mic permission denied":"NotFoundError"===e.t0.name&&(t="No suitable media device found"),this.onError(JSON.stringify({Type:"ERROR",Data:t}));case 14:case"end":return e.stop()}}),e,this,[[0,9]])}))),function(){return De.apply(this,arguments)})},{key:"loadAudio",value:(Me=Ee(me().mark((function e(){var t,n,i;return me().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 Me.apply(this,arguments)})},{key:"createProcessorNode",value:(Pe=Ee(me().mark((function e(){var t,n=this;return me().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);\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,o=t.value;if(i==Re)n.log("Worklet processing done, clearing resources..."),n.isDebug&&n.saveAudio(),n.cleanup();else if(e.data==ye)n.executor.Send(ye);else{var r;"intensity"===i?null===(r=n.onIntensity)||void 0===r||r.call(n,o):"audioData"===i&&n.isDebug&&new Int16Array(o).forEach((function(e){n.audioData.length<=288e5&&n.audioData.push(e)}))}n.executor&&(n.closeSocketWithoutEOS?(n.executor.Send(Oe),n.closeSocketWithoutEOS=!1):"intensity"!==i&&n.executor.Send(o))},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 Pe.apply(this,arguments)})},{key:"PauseStream",value:(xe=Ee(me().mark((function e(){return me().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(ye);case 9:this.onStateChanged(!1),this.isPaused=!0,this.isStreaming=!1;case 12:case"end":return e.stop()}}),e,this)}))),function(){return xe.apply(this,arguments)})},{key:"ResumeStream",value:(Ie=Ee(me().mark((function e(){return me().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.shouldPreIntialiseRecorder||"suspended"!=this.audioContext.state){e.next=9;break}if(!this.IsMicrophoneMuted){e.next=4;break}return this.onError(JSON.stringify({Type:"ERROR",Data:"Microphone is muted."})),e.abrupt("return");case 4:return e.next=6,this.audioContext.resume();case 6:this.log("Stream resumed..."),e.next=11;break;case 9:this.processorNode.port.postMessage(Ne),this.executor.Send(Ne);case 11:this.onStateChanged(!0),this.isPaused=!1,this.isStreaming=!0;case 14:case"end":return e.stop()}}),e,this)}))),function(){return Ie.apply(this,arguments)})},{key:"IsPaused",get:function(){return this.isPaused}},{key:"IsStreaming",get:function(){return this.isStreaming}},{key:"IsMicrophoneMuted",get:function(){return this.audioStream.getAudioTracks()[0].muted}},{key:"StopStream",value:(Le=Ee(me().mark((function e(t){var n,i,o,r;return me().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===(r=this.audioContext)||void 0===r?void 0:r.suspend();case 3:this.onStateChanged(!1);case 4:this.log("Stream stopped..."),this.isStreaming=!1,this.closeSocketWithoutEOS=!t,null===(i=this.processorNode)||void 0===i||null===(i=i.port)||void 0===i||i.postMessage("STOP"),null===(o=this.audioStream)||void 0===o||o.getAudioTracks()[0].removeEventListener("ended",(function(){}));case 9:case"end":return e.stop()}}),e,this)}))),function(e){return Le.apply(this,arguments)})},{key:"cleanup",value:function(){this.source.mediaStream.getAudioTracks()[0].stop(),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();console.log(e);var t=new Blob([e],{type:"audio/wav"});return console.log(t),t}},{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 o=0;o<t;o++)i.setInt8(44+o,e.getInt8(o));return i}},{key:"log",value:function(e){if(this.enableLogs){var t="".concat((new Date).toLocaleTimeString()," Augnito: ").concat(e);console.log(t+"\n")}}}]),Ue=function(){function e(){var t,n,i,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,shouldPreIntialiseRecorder:!1,shouldReadIntensity:!1,debounceDelay:300,switchToRegularSpeechProfile:!1},r=arguments.length>1?arguments[1]:void 0;if(Se(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.heavyOp=r,this.bufferInterval=o.bufferInterval,this.pausedBufferInterval=o.pausedBufferInterval,this.eosMessage=o.EOS_Message,this.socketTimeoutInterval=o.socketTimeoutInterval,this.shouldSendAudioDataSequence=o.shouldSendAudioDataSequence,this.shouldPreIntialiseRecorder=o.shouldPreIntialiseRecorder,this.switchToRegularSpeechProfile=null!==(n=o.switchToRegularSpeechProfile)&&void 0!==n&&n,this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0),this.shouldReadIntensity=o.shouldReadIntensity,this.delay=null!==(i=o.debounceDelay)&&void 0!==i?i:300,this.toggleStartStopAudioStream=Ge(this.toggleStartStopAudioStream.bind(this),this.delay),this.togglePauseResumeAudioStream=Ge(this.togglePauseResumeAudioStream.bind(this),this.delay),e.instance=this}return Te(e,[{key:"initialiseStreamer",value:function(){this.streamer=new je(this.enableLogs,this.isDebug,this.bufferInterval,this.pausedBufferInterval,this.eosMessage,this.socketTimeoutInterval,this.shouldSendAudioDataSequence,this.shouldPreIntialiseRecorder,this.shouldReadIntensity,this.switchToRegularSpeechProfile,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))}},{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=Ee(me().mark((function e(t){return me().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=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(null!==(e=this.streamer)&&void 0!==e&&e.IsStreaming||i)&&(null===(t=this.streamer)||void 0===t||t.StopStream(n),this.streamer=null,this.log("Stream Stopped..."),this.shouldPreIntialiseRecorder&&(this.initialiseStreamer(),this.streamerNotStarted=!0))}},{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(){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:"showLogCallback",value:function(e){this.showLog&&this.showLog(e)}}]);var t}();function Ge(e,t){var n;return function(){for(var i=this,o=arguments.length,r=new Array(o),a=0;a<o;a++)r[a]=arguments[a];n&&clearTimeout(n),n=setTimeout((function(){return e.apply(i,r)}),t)}}class We extends fe{constructor(e,t,n){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_notifSubscribedInOtherWindow",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"VocabularyAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_recorder",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_preventOverrun",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_overrunRecording",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_recordingStart",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_isRecording",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"_stream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onVocabularyAdded",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e.SubscriptionCode,"SubscriptionCode"),g.Against.NullOrEmpty(e.AccessKey,"AccessKey"),g.Against.NullOrEmpty(e.Server,"Server"),g.Against.NullOrEmpty(e.UserCode,"UserCode"),g.Against.NullOrEmpty(e.DeviceCode,"DeviceCode"),g.Against.NullOrEmpty(e.SourceApp,"SourceApp"),g.Against.NullOrEmpty(e.SmId,"SmId"),this._baseUrl=`https://${e.Server}/db/speechapi`,this._notifSubscribedInOtherWindow||(this._notificationClient.ensureNotificationClientConnected(),this._notificationClient.onVocabularyAdded=this.onVocabularyAddedCallback.bind(this))}getVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting vocabulary for user"),yield this.makePostRequest({Request:Object.assign(Object.assign({},e),this.getGetCommonModel())},this.getURL("/get_user_prs_word"))}))}removeVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Removing vocabulary for user"),yield this.makePostRequest({Request:Object.assign(Object.assign({},this.getGetCommonModel()),e)},this.getURL("/remove_personal_word"))}))}upsertVocabulary(e){return ge(this,void 0,void 0,(function*(){return this.log("Upserting vocabulary for user"),this.makePostFormRequest(Object.assign(Object.assign({},e),this.getUpsertCommonModel()),this.getURL("/add_personal_word"))}))}startRecording(){return this.log("Starting recording for vocabulary"),new Promise(((e,t)=>{this._isRecording?(this.log("Already recording"),t("Already recording")):(this._isRecording=!0,this._recorder=new Ue({serverURL:"",enableLogs:!0,isDebug:!0,bufferInterval:1,EOS_Message:"EOS",socketTimeoutInterval:1e4}),this._recorder.startAudio(),this._recordingStart=(new Date).getTime(),this._preventOverrun=setTimeout((()=>{var e,t;this._overrunRecording=null===(e=this._recorder)||void 0===e?void 0:e.getBlob(),this.log("Recording overrun"),null===(t=this._recorder)||void 0===t||t.stopAudio()}),9e3),e())}))}stopRecording(){return this.log("stopping recording for vocabulary"),this._preventOverrun&&clearTimeout(this._preventOverrun),new Promise(((e,t)=>{if(this._recorder){this._isRecording=!1;let t=(new Date).getTime()-this._recordingStart;setTimeout((()=>{var n,i;if(t=(new Date).getTime()-this._recordingStart,this._overrunRecording){const t=this._overrunRecording;this._overrunRecording=void 0,this._recorder=void 0,null===(n=this._stream)||void 0===n||n.getAudioTracks()[0].stop(),e(t)}else{const t=this._recorder.getBlob();null===(i=this._recorder)||void 0===i||i.stopAudio(),this._recorder=void 0,e(t)}}),Math.max(0,1200-t))}else t("Recorder not started")}))}getURL(e){return`${this._baseUrl}${e}`}getGetCommonModel(){return{SubscriptionCode:this._config.SubscriptionCode,AccessKey:this._config.AccessKey,SmId:this._config.SmId,UserCode:this._config.UserCode}}getUpsertCommonModel(){return Object.assign(Object.assign({},this.getGetCommonModel()),{DeviceCode:this._config.DeviceCode,SourceApp:this._config.SourceApp})}onVocabularyAddedCallback(e){this.onVocabularyAdded&&this.onVocabularyAdded(e)}log(e){this._config.enableLogs&&a.log(e,this._logTag)}makePostFormRequest(e,t){return ge(this,void 0,void 0,(function*(){try{const n=new FormData;for(const[t,i]of Object.entries(e))n.append(t,i);const i=yield fetch(t,{method:"POST",headers:{accept:"*/*"},body:n}),o=yield i.json();return[200,0].includes(o.Status)?o:o.ErrorMessage}catch(e){return e instanceof Error?e.message:"Unknown Error"}}))}}class Ve extends fe{constructor(e){super(),Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"FormattingAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e.SubscriptionCode,"SubscriptionCode"),g.Against.NullOrEmpty(e.AccessKey,"AccessKey"),g.Against.NullOrEmpty(e.Server,"Server"),g.Against.NullOrEmpty(e.UserCode,"UserCode"),g.Against.NullOrEmpty(e.DeviceCode,"DeviceCode"),g.Against.NullOrEmpty(e.SourceApp,"SourceApp"),g.Against.NullOrEmpty(e.SmId,"SmId"),this._baseUrl=`https://${e.Server}/db/speechapi/fp`}getURL(e){return`${this._baseUrl}${e}`}getFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/get"))}))}upsertFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Upserting formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/modify"))}))}removeFormatting(e){return ge(this,void 0,void 0,(function*(){return this.log("Removing formatting for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getGetCommonModel()),this.getURL("/delete"))}))}log(e){this._config.enableLogs&&a.log(e,this._logTag)}getGetCommonModel(){return{SubscriptionCode:this._config.SubscriptionCode,AccessKey:this._config.AccessKey,SmId:this._config.SmId,UserTag:this._config.UserCode}}}class He extends fe{constructor(e,t,n,i,o){super(),Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_userTag",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"MedicineOrderingAPI"}),Object.defineProperty(this,"_baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),g.Against.NullOrEmpty(e,"AccountCode"),g.Against.NullOrEmpty(t,"AccessKey"),g.Against.NullOrEmpty(o,"Server"),this._baseUrl=`https://${o}/augnote/nlp`}getMedicineOrderData(e){return ge(this,void 0,void 0,(function*(){return this.log("Getting Medicine Order for user"),yield this.makePostRequest(Object.assign(Object.assign({},e),this.getCommonModel()),this.getURL("/ordermedicine"))}))}getCommonModel(){return{SubscriptionCode:this._accountCode,AccessKey:this._accessKey,UserTag:this._userTag}}getURL(e){return`${this._baseUrl}${e}`}log(e){this._enableLogs&&a.log(e,this._logTag)}}class ze{constructor(e,t,n,i,o,r,a,s,l){Object.defineProperty(this,"_accountCode",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_accessKey",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_server",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"_userTag",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_lmid",{enumerable:!0,configurable:!0,writable:!0,value:o}),Object.defineProperty(this,"_deviceId",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_sourceApp",{enumerable:!0,configurable:!0,writable:!0,value:a}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:l})}getMacrosAPI(){return new pe(this._accountCode,this._accessKey,this._server)}getMedicineOrderingAPI(){return new He(this._accountCode,this._accessKey,this._userTag,this._enableLogs,this._server)}getFormattingAPI(){return new Ve({SubscriptionCode:this._accountCode,AccessKey:this._accessKey,Server:this._server,SmId:this._lmid,DeviceCode:this._deviceId,SourceApp:this._sourceApp,UserCode:this._userTag,enableLogs:this._enableLogs})}getVocabularyAPI(e=!1){return new We({SubscriptionCode:this._accountCode,AccessKey:this._accessKey,Server:this._server,SmId:this._lmid,DeviceCode:this._deviceId,SourceApp:this._sourceApp,UserCode:this._userTag,enableLogs:this._enableLogs},this._notificationClient,e)}}class Ke{get notificationSocket(){return this._pushNotificationSocket}constructor(e){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"NotificationClient"}),Object.defineProperty(this,"onConnectionRequest",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onMobileScan",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onVocabularyAdded",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pushNotificationSocket",{enumerable:!0,configurable:!0,writable:!0,value:null})}Send(e){var t;null===(t=this._pushNotificationSocket)||void 0===t||t.send(e)}ensureNotificationClientConnected(){null!=this.notificationSocket&&[WebSocket.OPEN,WebSocket.CONNECTING].includes(this.notificationSocket.readyState)||this.createNotificationClient()}createNotificationClient(){this.closeMobileWebSocket()||null!==this.notificationSocket&&this.notificationSocket.readyState===WebSocket.OPEN||(this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Connecting",this._logTag),this.createNotificationSocket(this._config.prepareNotificationURL()))}createNotificationSocket(e){this._pushNotificationSocket=new WebSocket(e),this._pushNotificationSocket.onmessage=e=>{var t,n;if(this._config.enableLogs&&a.log({message:"NOTIFICATION CLIENT: Message received",data:e},this._logTag),e.data){const i=JSON.parse(e.data);if(this._config.deviceId&&this._config.deviceId!==i.ToDeviceId)return void(this._pushNotificationSocket?this._pushNotificationSocket.send(this.getReplyMessage(i,"WRONG_DESTINATION")):a.error("push notification socket not created",this._logTag));"Type"in i&&("MOBILE_SCAN_SUCCESSFUL"===i.Type?this.onMobileScanCallback():"MIC_CONNECTION_REQUEST"===i.Type?this.onConnectionRequestCallback(i):"GENERAL_NOTIFICATION"===i.Type&&"Vocabulary"==(null===(n=null===(t=i.Data)||void 0===t?void 0:t.AppNotification)||void 0===n?void 0:n.SubType)&&this.onVocabularyAddedCallback(i.Data.AppNotification))}},this._pushNotificationSocket.onopen=()=>{this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Socket Opened.",this._logTag)},this._pushNotificationSocket.onclose=()=>{this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Socket Closed.",this._logTag),this._pushNotificationSocket=null},this._pushNotificationSocket.onerror=e=>{this._config.enableLogs&&a.log({message:"NOTIFICATION CLIENT: Socket Error: ",data:e},this._logTag),this._pushNotificationSocket=null}}closeMobileWebSocket(){return null!=this._pushNotificationSocket?(this._pushNotificationSocket.close(),this._pushNotificationSocket=null,!0):(this._config.stopListening(),!1)}dispose(){this.closeMobileWebSocket(),this._pushNotificationSocket=null}onMobileScanCallback(){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: MOBILE_SCAN_SUCCESSFUL",this._logTag),this.onMobileScan&&this.onMobileScan()}onVocabularyAddedCallback(e){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: Vocabulary Added",this._logTag),this.onVocabularyAdded&&this.onVocabularyAdded(e)}onConnectionRequestCallback(e){this._config.enableLogs&&a.log("NOTIFICATION CLIENT: MIC_CONNECTION_REQUEST",this._logTag),this.onConnectionRequest&&this.onConnectionRequest(e)}getReplyMessage(e,t){const n={FromDeviceId:this._config.deviceId||"",ToDeviceId:e.FromDeviceId,SeqId:E(),AckOf:e.SeqId,Type:t,TimeStamp:S()};return JSON.stringify(n)}}class Xe{constructor(e,t){Object.defineProperty(this,"_config",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"_enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"PhilipsMicClient"}),Object.defineProperty(this,"intervalInMillis",{enumerable:!0,configurable:!0,writable:!0,value:100}),Object.defineProperty(this,"isRecodingIsPressed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"counter",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"WasMicStartedByPressToSpeak",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onPhilipsMicPressed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getConnectedPhilipsDeviceName",{enumerable:!0,configurable:!0,writable:!0,value:e=>-1!==e.toLowerCase().indexOf("911")&&-1!==e.indexOf("fa0")?"SpeechMike":-1!==e.toLowerCase().indexOf("911")&&-1!==e.indexOf("c1e")?(this._enableLogs&&a.log("SpeechOne detected",this._logTag),"SpeechOne"):-1===e.toLowerCase().indexOf("911")||-1===e.indexOf("1844")&&-1===e.indexOf("91a")?"":(this._enableLogs&&a.log("Footswitch detected",this._logTag),"Footswitch")}),Object.defineProperty(this,"gamepadCallBack",{enumerable:!0,configurable:!0,writable:!0,value:()=>{for(var e=navigator.getGamepads(),t=0;t<e.length;t++){var n=e[t];if(n){if(""===this.getConnectedPhilipsDeviceName(n.id))continue;n.buttons[5].pressed?this._config.philipsMicMode===b.HandsFree?this.isRecodingIsPressed=!0:(this._config.philipsMicMode===b.PushToTalk||(this.isRecodingIsPressed=!0),this.HandlePushToTalk()):this.isRecodingIsPressed&&!this.WasMicStartedByPressToSpeak?(this.isRecodingIsPressed=!1,this.counter=0,this.onPhilipsMicPressedCallback(void 0)):this.WasMicStartedByPressToSpeak&&(this.isRecodingIsPressed=!1,this.WasMicStartedByPressToSpeak=!1,this.counter=0,this.onPhilipsMicPressedCallback(!1))}}}}),setInterval(this.gamepadCallBack,this.intervalInMillis)}HandlePushToTalk(){5===this.counter?this.CheckForRECPressed():this.counter++}CheckForRECPressed(){this.WasMicStartedByPressToSpeak||(this.isRecodingIsPressed=!1,this.WasMicStartedByPressToSpeak=!0,this.counter=0,this.onPhilipsMicPressedCallback(!0))}onPhilipsMicPressedCallback(e){this._enableLogs&&a.log("PHILIPS_MIC_CONNECTION_REQUEST",this._logTag),this.onPhilipsMicPressed&&this.onPhilipsMicPressed(e)}}class qe{static addCommand(e,t,n){var i;let o={CommandName:e,CustomCallback:n,CustomCallbackParameter:t};null===(i=qe.dynamicList)||void 0===i||i.push(o)}static prepareCustomCommandRecipe(e){var t;let n=e.receivedText.replace(/\n/gi,r.NEXT_LINE_TEXT);n=n.replace(/ /gi,"").toLowerCase().trim(),n=n.replace(new RegExp(r.NEXT_LINE_TEXT,"gi"),"\n");const i={sessionCode:e.sessionCode,isCommand:e.isCommand,final:e.final,receivedText:e.receivedText,receivedTextWithoutSpace:n,action:e.action,name:n},o=null===(t=qe.dynamicList)||void 0===t?void 0:t.find((e=>e.CommandName.replace(/ /gi,"").toLowerCase().trim()===n));return o?o.CustomCallback?(o.CustomCallback(o.CustomCallbackParameter),null):Object.assign(Object.assign({},i),{isCustomCommand:!0}):i}}Object.defineProperty(qe,"dynamicList",{enumerable:!0,configurable:!0,writable:!0,value:[]});class Je{constructor(e){var t,n,i,o,r;Object.defineProperty(this,"_logTag",{enumerable:!0,configurable:!0,writable:!0,value:"Augnito"}),Object.defineProperty(this,"_webClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_sdkMobileConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_augnitoMobile",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_worker",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"enableLogs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isConnected",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"switchToRegularSpeechProfile",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"shouldPreInitialiseMic",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"forceStopAudio",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_factoryAPI",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_editorHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"recorderIns",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"_notificationClient",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onPartialResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinalResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onCommandResult",{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,"onSessionEvent",{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,"onMicrophoneOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.enableLogs=null!==(t=e.enableLogs)&&void 0!==t&&t,this.shouldPreInitialiseMic=e.earlyInitialiseRecorder,this.switchToRegularSpeechProfile=null!==(n=e.switchToRegularSpeechProfile)&&void 0!==n&&n,this.config=this.createSDKConfig((e=>(g.Against.NullOrUndefined(e,"Config"),g.Against.NullOrEmpty(e.userTag,"UserTag"),g.Against.NullOrEmpty(e.lmId,"LmId"),g.Against.NullOrEmpty(e.accountCode,"AccountCode"),g.Against.NullOrEmpty(e.accessKey,"AccessKey"),g.Against.NullOrEmpty(e.sourceApp,"SourceApp"),g.Against.NullOrEmpty(p(e.server),"AugnitoAPIServer"),C(e),e.enableLogs=e.enableLogs||!1,e.deviceId=e.deviceId||E(),e))(e)),this._webClient=new s(this.config),this._sdkMobileConfig=new de(((e,t)=>(g.Against.NullOrUndefined(e,"WebClient"),g.Against.NullOrEmpty(e.getConfig().clientConfig.deviceId,"deviceId"),t.enableLogs=t.enableLogs||!1,t))(this._webClient,e||{}),this._webClient),this._notificationClient=new Ke(this._sdkMobileConfig),this._worker=this.createWorker(),this._editorHandler=new ue(e.listOfControls||[],this.enableLogs,e.editor),this._factoryAPI=new ze(e.accountCode,e.accessKey,p(e.server),e.userTag,e.lmId,e.deviceId,e.sourceApp,null!==(i=e.enableLogs)&&void 0!==i&&i,this._notificationClient),this.recorderIns=new Ue({serverURL:this.config.prepareSpeechURL(),enableLogs:null!==(o=e.enableLogs)&&void 0!==o&&o,isDebug:null!==(r=e.enableLogs)&&void 0!==r&&r,bufferInterval:1,pausedBufferInterval:e.pauseStateBufferInterval,EOS_Message:"EOS",socketTimeoutInterval:2e4,shouldSendAudioDataSequence:!1,shouldPreIntialiseRecorder:this.shouldPreInitialiseMic,debounceDelay:e.debounceDelay,switchToRegularSpeechProfile:e.switchToRegularSpeechProfile}),this.recorderIns.onError=this.onErrorCallback.bind(this),this.recorderIns.onPartialResult=this.onPartialResultsCallback.bind(this),this.recorderIns.onFinalResult=this.onSocketFinalResult.bind(this),this.recorderIns.onStateChanged=this.onStateChangeCallback.bind(this),this.recorderIns.onSessionEvent=this.onSessionEventCallback.bind(this),window.addEventListener("storage",this.handleStorageChangeEvent.bind(this)),window.addEventListener("beforeunload",this.handleBeforeUnloadEvent.bind(this))}toggleListening(e=!1){var t,n;a.log("toggleListening clicked",this._logTag),this.forceStopAudio=!1,this.isConnected||localStorage.getItem(o.KEY)!==o.ON?this._webClient&&this._webClient.connected?this._webClient.stopListening(!0):e||this.shouldPreInitialiseMic?null===(t=this.recorderIns)||void 0===t||t.togglePauseResumeAudioStream():null===(n=this.recorderIns)||void 0===n||n.toggleStartStopAudioStream():this.onMicrophoneOnErrorCallback(!0)}getQRCode(){var e;return null===(e=this.config)||void 0===e?void 0:e.qrCode}navigateToNextField(){var e={name:"",action:r.NEXT_FIELD,sessionCode:"",final:!1,isCommand:!1,receivedText:"",receivedTextWithoutSpace:"",chooseNumber:0,fontSize:0,nextPrevious:"",searchText:"",selectFor:"",isCustomCommand:!1};this._editorHandler.handleDynamicFieldNavigation(e)}navigateToPreviousField(){var e={name:"",action:r.PREVIOUS_FIELD,sessionCode:"",final:!1,isCommand:!1,receivedText:"",receivedTextWithoutSpace:"",chooseNumber:0,fontSize:0,nextPrevious:"",searchText:"",selectFor:"",isCustomCommand:!1};this._editorHandler.handleDynamicFieldNavigation(e)}getCursorPosition(){return this._editorHandler.getCursorPosition()}setCursorAtPosition(e){this._editorHandler.setCursorAtPosition(e)}setCursorAtDocumentEnd(){this._editorHandler.handleGotoDocumentEnd()}dispose(){this._augnitoMobile&&(this._augnitoMobile.dispose(),this._augnitoMobile=null),this._worker&&(this._worker.terminate(),this._worker=null),this.recorderIns&&(this.recorderIns.dispose(),this.recorderIns=null)}initMobileClient(e){var t;if(!this._webClient)throw new Error("augnito client not set");if(this._augnitoMobile)throw new Error("augnito mobile client has already been initialized");return this._sdkMobileConfig.setEnableLogs(null!==(t=null==e?void 0:e.enableLogs)&&void 0!==t&&t),this._sdkMobileConfig.onMicrophoneOnError=this.onMicrophoneOnErrorCallback.bind(this),this._augnitoMobile=new he(new l(this._sdkMobileConfig,this._notificationClient)),this._augnitoMobile}initPhilipMicClient(e){return new Xe(e,this.enableLogs)}requestMicOff(){var e;localStorage.getItem(o.KEY)===o.ON&&localStorage.setItem(o.KEY,o.REQUEST_OFF),this.stopAudio(),null===(e=this.recorderIns)||void 0===e||e.dispose()}addCustomCommand(e,t,n){qe.addCommand(e,t,n)}setAnchoredEditor(e,t){this._editorHandler.onSetAnchoredEditor(e,t)}get apisFactory(){return this._factoryAPI}get configuration(){return this.config?this.config:null}stopAudio(){var e;this._augnitoMobile&&this._augnitoMobile.stopMobileMicConnection();try{null===(e=this.recorderIns)||void 0===e||e.stopAudio(!0,!0)}catch(e){}}onPartialResultsCallback(e){this.enableLogs&&a.log({type:"onPartialResults",data:e},this._logTag),this.onPartialResult&&this.onPartialResult(e)}onFinalResultsCallback(e){this.enableLogs&&a.log({type:"FinalText",recipe:e},this._logTag),this.onFinalResult&&this.onFinalResult(e)||this._editorHandler.onFinalResult(e)}onCommandResultsCallback(e){this.enableLogs&&a.log({type:"Command",command:e},this._logTag),this.onCommandResult&&this.onCommandResult(e)||this.interfaceCommand(e)||this._editorHandler.onCommandResult(e)}interfaceCommand(e){return r.STOP_MIC===e.name&&(this.stopAudio(),!0)}onErrorCallback(t){this.enableLogs&&a.error({type:"onError",error:e.ERR_SERVER,data:t},this._logTag),(t.includes("Audio track ended. Possibly the mic was unplugged")||t.includes("Microphone is muted"))&&this.requestMicOff(),this.onError&&this.onError({Type:e.ERR_SERVER,Message:t,IsWebClient:!0}),this.isConnected=!1,localStorage.setItem(o.KEY,o.OFF)}onIdleMicCallback(){this.onIdleMic&&this.onIdleMic()}onStateChangeCallback(e){if(this.forceStopAudio)return this.stopAudio(),void(this.forceStopAudio=!1);this.isConnected=e,e?(localStorage.setItem(o.KEY,o.ON),this.onPartialResultsCallback("")):localStorage.setItem(o.KEY,o.OFF),this.enableLogs&&a.log(`AUGNITO STATUS CHANGED. Connected: ${e}`,this._logTag),this.onStateChanged&&this.onStateChanged(e)}onSocketFinalResult(e){let t;if(t="string"==typeof e?JSON.parse(e):e.Result,this.enableLogs&&a.log({type:"onSocketFinalResult",data:e},this._logTag),this.switchToRegularSpeechProfile&&this.onPartialResultsCallback(""),this._worker){const e=t.Transcript,n=t.Action,i={name:t.Transcript,sessionCode:"",final:t.Final,isCommand:t.IsCommand,receivedText:e,action:t.IsCommand?n.replace(/\s+/g,""):""};this._worker.postMessage(i)}}onSessionEventCallback(e){var t=void 0;if(t="string"==typeof e?JSON.parse(e):e,this.enableLogs&&a.log({type:"onSessionEvent",data:e},this._logTag),this.onSessionEvent&&this.onSessionEvent(t),"string"==typeof t.Event&&"None"===t.Event)return;const n=t.Event.Type,i=t.Event.Value;if("SESSION_CREATED"===n){if(this.isConnected=!0,this.enableLogs){const e=i;a.log("session Token "+e,this._logTag)}}else"SERVICE_DOWN"===n?(a.error(n,this._logTag),this.isConnected?this.stopAudio():this.forceStopAudio=!0,this.onErrorCallback(i)):"NO_DICTATION_STOP_MIC"===n?(this.enableLogs&&a.log("NO_DICTATION_STOP_MIC",this._logTag),this.onIdleMicCallback()):"INVALID_AUTH_CREDENTIALS"===n?(a.error("INVALID_AUTH_CREDENTIALS",this._logTag),a.log("Invalid authentication, Please check your Account Status, Lm Id and Access Key."),this.isConnected?this.stopAudio():this.forceStopAudio=!0,this.onErrorCallback(i)):"LOW_BANDWIDTH"===n&&(this.enableLogs&&a.log("LOW_BANDWIDTH: Check internet connection",this._logTag),this.onErrorCallback(i))}onMicrophoneOnErrorCallback(t){this.enableLogs&&a.log(`AUGNITO Error. Microphone is already On. Is Web Client? ${t}`,this._logTag),this.onMicrophoneOnError?this.onMicrophoneOnError(t):this.onError&&this.onError({Type:e.ERR_CLIENT,Message:"Microphone is already On",IsWebClient:t})}createSDKConfig(e){const t=new m(e);return t.onError=this.onErrorCallback.bind(this),t.onSocketPartialResult=this.onPartialResultsCallback.bind(this),t.onSocketFinalResult=this.onSocketFinalResult.bind(this),t.onReadyForSpeech=this.onStateChangeCallback.bind(this),t.onEndOfSession=this.onStateChangeCallback.bind(this),t.onSessionEvent=this.onSessionEventCallback.bind(this),t.onMicrophoneOnError=this.onMicrophoneOnErrorCallback.bind(this),t}createWorker(){const e=URL.createObjectURL(new Blob(["this.onmessage = function (eee) {self.postMessage(eee.data);}"],{type:"application/javascript"})),t=new Worker(e);return t.onmessage=e=>{const t=e.data,n=qe.prepareCustomCommandRecipe(t);if(null==n)this.enableLogs&&a.log({type:"AugnitoCustomCommands",command:n},this._logTag);else if(n.isCustomCommand)this.enableLogs&&a.log({type:"AugnitoCustomCommands",command:n},this._logTag),this.onCommandResultsCallback(n);else if(t.isCommand){const e=h.prepareRecipe(t);this.enableLogs&&a.log({type:"AugnitoCommandsStatic",command:e},this._logTag),this.onCommandResultsCallback(e)}else{const e=d.prepareRecipe(t);e.isCommand?(this.enableLogs&&a.log({type:"AugnitoCommandsRegex",command:e},this._logTag),this.onCommandResultsCallback(e)):this.onFinalResultsCallback(e)}},t}handleBeforeUnloadEvent(e){this.enableLogs&&a.log({type:"handleBeforeUnloadEvent",event:e},this._logTag),this.isConnected&&this.requestMicOff()}handleStorageChangeEvent(e){e.key===o.KEY&&(this.enableLogs&&a.log({type:"handleStorageChangeEvent",event:e},this._logTag),localStorage.getItem(o.KEY)===o.REQUEST_OFF&&this.isConnected&&this.toggleListening())}}const $e=["--select--","BD - Afternoon & Night","BD - Morning & Afternoon","BD - Morning & Evening","BD - Morning & Night","Continuous infusion","EIGHT times a day","Every 10 days","Every 2 hours","Every Alternate day","Every hour","Every two weeks","FIVE times a day","FIVE times a week","FOUR times a week","HS - At bedtime","OD - Afternoon","OD - Evening","OD - Morning","OD - Night","Once - One time only","Once a month","Once a week","Once a year","Q12H - Every 12 hours","Q4H - Every 4 hours","Q6H - Every 6 hours","Q8H - Every 8 hours","QID - Morning, Afternoon, Evening & Night","Refer instructions for dosage","SIX times a day","SOS - Whenever needed","STAT ( Immediately)","TDS - Afternoon, Evening & Night","TDS - Morning, Afternoon & Evening","TDS - Morning, Afternoon & Night","TDS - Morning, Evening & Night","THREE times a week","TWO times a week"],Ye=["--select--","After Breakfast","After dinner","After lunch","After meal","At Bed Time","Before Breakfast","Before dinner","Before lunch","Before meal","Empty Stomach","Local Application","Not Applicable to Meals","With Food"],Ze=["--select--","Day(s)","Month(s)","Till Next Review","Week(s)"],Qe=["--select--","Vial(s)","Ampoule","Bag","Bar","Bottle(s)","Box","Capsule(s)","Carton","Cartridge(s)","Cream","Dressing","Drops","Gel","gm","I.U.","Inhaler","Jar","Kit","Lozenge","mg","Micro drops","Microgram (mcg)","ml","Ounce (30 ml)","Pad","Patch(s)","Pen","Pessary","Piece","Pre Filled Syringe","puff(s)","Respule(s)","Sachet(s)","Scoop(s)","Spray","Strip(s)","Suppository","Tablespoon (15 ml)","Tablet(s)","Tampon","Teaspoon (5 ml)","Tube","Unit(s)"],et=["--select--","Gastronomy Tube","Mouth And Throat","Nasogastric","Nasotrachial Tube","Oral","Rectal","Sublingual","Translingual","Dental","Epidural","Gargle","Inhalation","Intra-Arterial","Intrabursal","Intracardiac","Intrahepatic Artery","Intramuscular","Intraperitoneal","Intrathecal","Intratracheal","Intrauterine","Intravenous","Irrigation","Local Application","N/A","Nasal","Nebulization","Perfusion","Urethral","Ventimask","Apply Externally","Buccal","Immerse(Soak) Body Part","Implant","Intracervical (Uterus)","Intradermal","Intranasal","Intraocular","Mucous Membrane","Other/Miscellaneous","Otic","Subcutaneous","Topical","Transdermal","Vaginal"],tt=["--select--","SOMAZINA PLUS TAB","KEZONE S FORTE 1.5GM INJ","NEOROF 1% 10ML INJ","INOGLA 20MG TAB 10'S","GRAFEEL 1ML 300MCG INJ","GABAPIN 100MG TAB 15'S","SYNCAPONE 150MG TAB","OXA-50MG/25ML INJ","PRIN PLUS SOFTGEL CAP 10'S","DOLONEURON PG-75MG CAP","DOLO 1000MG TAB","DOLO 100ML IV","DOLO 15ML DROPS","DOLO 250MG SYP","DOLO 650MG TAB 15'S","DOLO INFUSION 100ML","DOLO IVG 1%INFUSION 1000MG/100ML","DOLO SUSP - 60ML","DOLO-500MG TAB","ZEROSCAB 120ML LOTION","DHYAN-NTP TAB 10'S","FUZOLID 200MG/100ML INFUSION","SUNBAN ULTRA SPF 31 GEL","PENTASURE VANILA 400GM TIN","BRONCOREX EXP 100ML","AMPILOX 500MG CAP","GABAPIN 100MG TAB 10'S","ND-PAIN TAB","PANTODAC 40MG IV INJ","LIFEPILL 3MG CAP","CLOPILET A 150MG TAB","DOMSTAL DT 10MG TAB","REJUNURON CAPS 30'S","CARDIOPLEGIA INJ - 20ML (DBL)","CINOD-N 10/5MG TAB","KETOART TAB","DOBESIL H 30GRM OINT","DYRECT TAB","ZIMBA 1% WW 10GM CREAM","PLASBUMIN-12.5GM/250ML","SOFZID NS SYP 180 ML","OFLOCHEM 200MG TAB","FAROTAB 200MG TAB 6'S","C WIN 1%W/W CREAM 30GM","SEMI GLYNASE 2.500 MG TAB","OXONEG ORANGE FLAV EFFERVESCENT TAB 15'S","KEPHAZON-S FORTE 3.0 GM INJ","METROGYL-P 2% OINT 20GM","MAXMALA 50MG TAB","OXIFUL - FORTE CAP 10S","TREMIDON 50MG TAB","CREMAFFIN PLUS - 110ML [BOOTS CO.]","PARI CR FORTE TAB","CEFOLAC DT 50MG TAB","TRIOPTAL 450MG TAB","BRYXTA 300MG/12ML INJ","CARDIMAX SR 60MG TAB","CYBLEX 80MG TAB 15S","DOMSTAL BABY 5 ML DROPS","INSUGEN-30/70 REFIL 3ML INJ","CALCIRIN-FORTE CAP","ROMILAST 10 MG TAB","EPSOLIN ER 300MG TAB","MOTIVYST 300MG TAB","NIMEK PARA TAB","CREMA ANO 20GM CREAM","NOSTRA CR 15MG TAB","MACPEE 25MG TAB","NUROZENOL CAP","MYCOPHEN 500MG TAB","REPACE-A TAB","FULVIRA 250MG/5ML INJ","PHYSIOGEL HYPOALERGENIC LOTION","DEXTOMID 50MG 0.5ML INJ","METROGYL DG GEL 10 GRM","FEBRINIL 2ML INJ","TUSQ X 100ML SYP","ZIVAST 10 MG TAB","MOMEFLO NASAL SPRAY","HISTAC 300MG TAB","RENO-PRO HIGH PROTEIN VANILLA FLAV 200GM POWDER","VENUSIA 75GM CREAM","TAMDART TAB","BRAIN UP PINEAPPLE FLAV SUSP 150ML","AMLOSUN 5MG TAB","C QNEXT CAP","HEPLOCK 10ML","6IPZOCIN 30MG/1ML INJ","NUROKIND FAST STRIP 1'S","TORQ-SR 4MG CAP 30'S","RABEZ - D CAPS","TAZLOC 80MG TAB","LIFOGEM 200MG INJ","TRICIUM MAX TAB 15S","TASIGNA 150MG CAP","GAVISCON PEP LIQ 150ML","MELACARE 20GRM CREAM","KEYCEPT S 360MG TAB","DOXYMIZ SL CAP","TAPAL 100MG TAB","DIABEND - 40MG TAB","NUBLEXA 40 MG TAB 28'S","TAXOTERE 80 MG 2 ML INJ","FLUPETRA TAB","BISPEC 5MG TAB 15'S","DICLOPEP TAB","KABIPRO 400GM CREAMY VENILLA","XERINA 100 ML","CYPHOS 1GM INJ","BRIVIACT 75MG TAB 14'S","DOXOFLY 400MG TAB","GABAWIN 50MG TAB","ACITROM 2MG TAB 20'S","V&M 20MG TAB 15'S","WEPOX 5000 INJECTION 0.5ML","MOMATE - S 5GRM OINT","CALPOL (PEDIA )DROPS - 15ML","HEPLIST-400MG TAB","PREGEB FORTE 75MG CAP","DENTOGEL 15GM","STARPRESS - H 50MG XL TAB","ENSURE FOS(VANILA) 400G (ABBOTT)","MIMCIPAR 30MG TAB","MECONEURON OD 1500MCG TAB 15'S","UNIZID-TZ 1.125MG INJ","RESPIDON 2 MG TAB","COQ SUPPORT TAB","NURIVITA-OD SOFTGEL CAP 10'S","KERA XL HAIR GROWTH SERUM(60ML)","AMINO MIX 1000ML (P) (FRU)","BRYXTA 400MG/16ML INJ","CALCIUM FOLINATE 7.5MG INJ 15MG/2ML","ATARAX SYP - 100ML","MAXUM TAB 10'S","KET-AMINOS TAB","URSETOR 300 MG TAB","CQRA CAP","DISTACLOR CD 750MG TAB","ZEN RETARD 400 MG TAB","ERYKINE 40000 IU 1ML INJ *","STONE IB6 200ML SYP","GLIPI MET 500/50MG TAB.","TAZOTUM 1.125G INJ","AMBILIP 50MG INJ","TEAR 10 ML DROP","COMBINIB 250MG TAB","ROZAVEL - 10MG TAB","NEBISTAR 5MG TAB 15'S","COGNOXYN 200ML SYP","BIPACEF-500 TAB 10S","NOVO WHITE 50GM CREAM","CMXX 500MG TAB 10'S","HEAM UP - GEM 30'S CAP","TRAMACIP CAPS 10'S","DELCON PLUS 60 ML SYP","FONDAKEM 2.5MG/0.5ML INJ","GEN COLL 15GM COLLAGEN BASE","NEOSPORIN 5 GRM OINT","NITREST 10MG TAB","XIDORIN 2.5MG TAB 20S","INTAGESIC MR TAB","ENFIERA 100MG/10ML INJ","LIPIROSE F 10 TAB","MAHAMONT-L TAB","JALRA M 50/500MG TAB 10'S","ENOXION 20MG INJ","AZULIX 4MG TAB","ROSEDAY 40MG TAB","RASIN-DSR CAP 10'S","VOMIKIND-FAST STRIP PATCH","EPITHRA 50MG INJ","ACIPANT 40 INJ","BIFILAC LOZENGES 10'S","RESHAPE NATURAL TAB 10'S","TRILOSAR 12.5MG TAB","BETAGAN - 0.5% DROP","CROCIN SUSPENSION 60 ML","AZTRIC-80MG TAB","CLINDATEC 300MG CAPS.","OXIPLAT 100MG IV INJ","SUFRATE LA 30GM CREAM","DOXINATE TABLET","REFLORA 1GM SACHETS","HUMAN ALBUMIN 20% 50ML","DYCIPAR 30GM GEL","SEVLAREN-800MG TAB 10'S","CIFRAN I.V - 100ML INJ","ATEN H 25MG TAB","EUSOL 400ML SOLUTION (CENTRAL DRUGS)","SYSTAFLAM MR TAB","FOLITRAX 20MG/1ML INJ","BUFATAS 60 MG/10ML","MACORATE CR 200MG TAB","BISPEC 5MG TAB 15'S","NOVAPIME 1G INJ","BILAZO 20MG TAB 10'S","ADENOJECT INJ - 2ML**","EMCITABEN 1GM INJ","TELPRES CT 40/12.5MG TAB 15'S","OCUPOL DX 5ML DROPS","OXYTOCIN ING 2ML","REMMAG TAB","BETAFERON 0.25MG INJ","CLOCIP 15GRM CREAM","ALFAREN 200MG TAB","HEALON GV 1.4% 0.55ML","OROFER CAPS","ASTHALIN 100ML SYP","DOLONAT TAB","LOPEZ MD 1 10'S TAB","MELACYN GEL 50GM","HALOVATE F 10GM CREAM","LACOSAM 50 MG TABLET","FOLTOP-M CAP 10'S","GRANICIP 1MG TAB","DOTAMIN 5ML INJ","THYRONORM 12.5MCG CAPS","DILTIACT GEL 2% 30GM","PLACENTREX 100GM GEL","EYEVITAL CAPS","NS 0.9%W/V SODIUM CHLORIDE 3000ML (FRESENIUS)","CEFADROX 500MG TAB","GLYCOMET SR 850MG TAB","HDYSHIL 500MG CAP 10S","MAXIGARD 500MG INJ","BUDAMATE 200 INHALER","MEXATE 7.5MG TAB","GENTACOL EYE DROP","RINIFOL 60ML DRY SYP","CASIRIVIMAB / IMDEVIMAB COMBO PACK 2400MG (REGN-COV2)INJ","KUZET 3MIU INJ","PANTHE 5% GEL 5GM","HEALON GV 1.4% 0.55ML","DERMANEX CREAM 30GM","ALFAPIME TZ 2.25GM INJ","EFAVIR 200MG 30'S CAPS","INHALEX RESPULES 2ML","DEXALAB 2ML INJ","RX-PLUS CAP","TIMOLET GFS 0.5% 3ML EYE DRO","KABIMMUNE SACHETS - 15GM","JANUMET XR CP KIT 7's","BETALOC 5ML INJ","INSUPEN PRO+INSUGEN 30/70 REFIL INITIATION KIT","ENGERIX - B ADULTS INJ","ELOVERA IMF 50ML LOTION","CARTIKOOL XP TAB 10'S","MINO QILIB 5 LOTION 60ML","METHYL PREDNISOLONE 1000MG INJ","MYOKRAMP TAB","TOPNERVE 500MCG/ML INJ","REMYLIN D 1000 IU TAB","ABITATE U 250MG TAB 120S","L-HIST TAB","ISOTROY 100ML LIQUID FOR INHALATION","FDSON MP TAB","THEOASTHALIN SR 4 MG TAB","TIGEPLUG 50MG INJ","SUFRATE LA 30GM CREAM","ETOPOGEN 100 MG INJ","MACRALFATE-O 200ML SUSP","CORTIMAX 30MG TAB","METOCARD XL 50MG TAB","PRESMOVAC 2MG TAB 10'S","SISONEXT 10GM CREAM","PHENOBARBITONE SODIUM 200MG/1ML INJ (VULCAN)","GUTPRO 2BILLION/5ML SYP 30ML","GTX 600MG INJ","ADDBACTAM 1GM INJ","MECONUS TAB 10`S","HYLCOBA 500MG INJ","CYCLOREG 5MGTAB","BACLOF 25MG TAB","PARAPIC-500 TAB","TRIOMUNE 30MG TAB","NANOPACLI 100 MG INJ","ALTAXEL - 100MG 16.7ML INJ","AMARYL M2 FORTE 2+1000 MG TAB","URLPLUS CAP","ATRAPURE 25MG/2.5ML INJ","PARACETAMOL 1 GM IV","PARACETAMOL 1000MG TAB","PARACETAMOL 100ML I.V","PARACETAMOL 2ML INJ","PARACETAMOL 30ML INJ","PARACETAMOL 500MG TAB","PARACETAMOL 500MG TAB (CADILA)"];export{Je as Augnito,f as AugnitoAPIServer,r as AugnitoCommands,he as AugnitoMobile,e as AugnitoSDKError,tt as Drug,Ze as DurationType,v as EditorType,ze as FactoryAPI,Ve as FormattingAPI,$e as Frequency,pe as MacrosAPI,Ye as MealsRelation,b as PhilipsMicMode,Qe as QuantityUnit,et as Route,We as VocabularyAPI};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "testaugnitosdk2",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.13",
|
|
5
5
|
"license": "Restricted",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@types/webrtc": "^0.0.43",
|
|
67
67
|
"augnito-dom-ranges": "^0.0.1",
|
|
68
68
|
"augnitorecorder": "^1.0.46",
|
|
69
|
-
"testaugnitorecorder4": "^1.0.
|
|
69
|
+
"testaugnitorecorder4": "^1.0.53"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@ckeditor/ckeditor5-core": ">=38.1.1"
|