deep-chat-dev 9.0.347 → 9.0.350

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.
Files changed (44) hide show
  1. package/custom-elements.json +9235 -9235
  2. package/dist/deepChat.bundle.js +1 -1
  3. package/dist/deepChat.js +38 -38
  4. package/dist/services/cohere/cohereIO.d.ts.map +1 -1
  5. package/dist/services/gemini/geminiIO.d.ts +1 -1
  6. package/dist/services/gemini/geminiIO.d.ts.map +1 -1
  7. package/dist/services/kimi/kimiIO.d.ts +1 -1
  8. package/dist/services/kimi/kimiIO.d.ts.map +1 -1
  9. package/dist/services/mistral/mistralIO.d.ts +1 -1
  10. package/dist/services/mistral/mistralIO.d.ts.map +1 -1
  11. package/dist/services/openRouter/openRouterIO.d.ts +1 -1
  12. package/dist/services/openRouter/openRouterIO.d.ts.map +1 -1
  13. package/dist/services/openWebUI/openWebUIIO.d.ts.map +1 -1
  14. package/dist/services/qwen/qwenIO.d.ts +1 -1
  15. package/dist/services/qwen/qwenIO.d.ts.map +1 -1
  16. package/dist/types/claude.d.ts +2 -1
  17. package/dist/types/claude.d.ts.map +1 -1
  18. package/dist/types/cohere.d.ts +2 -1
  19. package/dist/types/cohere.d.ts.map +1 -1
  20. package/dist/types/deepSeek.d.ts +2 -1
  21. package/dist/types/deepSeek.d.ts.map +1 -1
  22. package/dist/types/gemini.d.ts +2 -1
  23. package/dist/types/gemini.d.ts.map +1 -1
  24. package/dist/types/kimi.d.ts +2 -1
  25. package/dist/types/kimi.d.ts.map +1 -1
  26. package/dist/types/miniMax.d.ts +2 -1
  27. package/dist/types/miniMax.d.ts.map +1 -1
  28. package/dist/types/mistral.d.ts +3 -2
  29. package/dist/types/mistral.d.ts.map +1 -1
  30. package/dist/types/openRouter.d.ts +2 -1
  31. package/dist/types/openRouter.d.ts.map +1 -1
  32. package/dist/types/openWebUI.d.ts +3 -11
  33. package/dist/types/openWebUI.d.ts.map +1 -1
  34. package/dist/types/openWebUIInternal.d.ts +1 -2
  35. package/dist/types/openWebUIInternal.d.ts.map +1 -1
  36. package/dist/types/perplexity.d.ts +2 -1
  37. package/dist/types/perplexity.d.ts.map +1 -1
  38. package/dist/types/qwen.d.ts +2 -1
  39. package/dist/types/qwen.d.ts.map +1 -1
  40. package/dist/utils/legacy/legacy.d.ts +2 -2
  41. package/dist/utils/legacy/legacy.d.ts.map +1 -1
  42. package/dist/views/chat/messages/stream/messageStream.d.ts +4 -4
  43. package/dist/views/chat/messages/stream/messageStream.d.ts.map +1 -1
  44. package/package.json +1 -1
package/dist/deepChat.js CHANGED
@@ -1,4 +1,4 @@
1
- function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n19){function n(){return _n19.apply(this,arguments);}n.toString=function(){return _n19.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _wrapNativeSuper(t){var r="function"==typeof Map?new Map():void 0;return _wrapNativeSuper=function _wrapNativeSuper(t){if(null===t||!_isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,Wrapper);}function Wrapper(){return _construct(t,arguments,_getPrototypeOf(this).constructor);}return Wrapper.prototype=Object.create(t.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,t);},_wrapNativeSuper(t);}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o))();return r&&_setPrototypeOf(p,r.prototype),p;}function _isNativeFunction(t){try{return-1!==Function.toString.call(t).indexOf("[native code]");}catch(n){return"function"==typeof t;}}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1;}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r;}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return;}finally{if(o)throw n;}}return a;}}function _arrayWithHoles(r){if(Array.isArray(r))return r;}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof Generator?n:Generator,u=Object.create(c.prototype);return _regeneratorDefine2(u,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],y=!1,G={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function d(t,r){return i=t,c=0,u=e,G.n=r,a;}};function d(r,n){for(c=r,u=n,t=0;!y&&f&&!o&&t<p.length;t++){var o,i=p[t],d=G.p,l=i[2];r>3?(o=l===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,G.v=n,G.n=i[1]):d<l&&(o=r<3||i[0]>n||n>l)&&(i[4]=r,i[5]=n,G.n=l,c=0));}if(o||r>1)return a;throw y=!0,n;}return function(o,p,l){if(f>1)throw TypeError("Generator is already running");for(y&&1===p&&d(p,l),c=p,u=l;(t=c<2?e:u)||!y;){i||(c?c<3?(c>1&&(G.n=-1),d(c,u)):G.n=u:G.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0);}else 1===c&&(t=i["return"])&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e;}else if((t=(y=G.n<0)?u:r.call(n,G))!==a)break;}catch(t){i=e,c=1,u=t;}finally{f=1;}}return{value:t,done:y};};}(r,o,i),!0),u;}var a={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(_regeneratorDefine2(t={},n,function(){return this;}),t),u=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(u),e;}return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(u,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,o,"GeneratorFunction"),_regeneratorDefine2(u),_regeneratorDefine2(u,o,"Generator"),_regeneratorDefine2(u,n,function(){return this;}),_regeneratorDefine2(u,"toString",function(){return"[object Generator]";}),(_regenerator=function _regenerator(){return{w:i,m:f};})();}function _regeneratorDefine2(e,r,n,t){var i=Object.defineProperty;try{i({},"",{});}catch(e){i=0;}_regeneratorDefine2=function _regeneratorDefine(e,r,n,t){function o(r,n){_regeneratorDefine2(e,r,function(e){return this._invoke(r,n,e);});}r?i?i(e,r,{value:n,enumerable:!t,configurable:!t,writable:!t}):e[r]=n:(o("next",0),o("throw",1),o("return",2));},_regeneratorDefine2(e,r,n,t);}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}var m="classList",_="style",Xo="unset",Zo="html-wrapper",S=function S(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"div";return document.createElement(r);};var Yo=/*#__PURE__*/function(){function Yo(){_classCallCheck(this,Yo);}return _createClass(Yo,null,[{key:"render",value:function render(e,t){var n=S();n.id="error-view",n.innerText=t,e.replaceChildren(n);}}]);}();var Cs=/*#__PURE__*/function(){function Cs(){_classCallCheck(this,Cs);}return _createClass(Cs,null,[{key:"onLoad",value:function onLoad(e){e.innerHTML='<div id="loading-validate-key-property"></div>';}},{key:"createElements",value:function createElements(){var e=S();return e.id="validate-property-key-view",e;}},{key:"render",value:function render(e,t,n){var s=Cs.createElements(),i={onSuccess:t,onFail:Yo.render.bind(this,e,"Your 'key' has failed authentication"),onLoad:Cs.onLoad.bind(this,s)};n.key&&n.verifyKey(n.key,i),e.replaceChildren(s);}}]);}();var Q="service",h="text",M="html",f="error",$="https://deepchat.dev/docs/",K="ai",H="user",ot="assistant",Ts="error-message-text",ys="deep-chat-outer-container-role-",fr="empty-message",di="deep-chat-top-message",mr="deep-chat-middle-message",hi="deep-chat-bottom-message",A="src",T="type",ee="file",y="files",q="image",J="images",Ie="camera",hn="gifs",L="audio",Ye="microphone",po="mixedFiles",Vt="any",fo="file-message",Mt="start",mo="end",go="messages",gr="0",yr="1";function br(r){return r.charAt(0).toUpperCase()+r.slice(1);}function Qo(r){return r&&JSON.stringify(r);}function Di(r,e,t,n){var s="\n".concat(br(e)," message: ").concat(JSON.stringify(r)," \n"),i=t?"".concat(br(e)," message after interceptor: ").concat(Qo(n)," \n"):"";return s+i;}function ea(r,e,t,n){return"".concat(Di(r,e,t,n),"Make sure the ").concat(e," message is using the Response format: ").concat($,"connect/#Response \nYou can also augment it using the responseInterceptor property: ").concat($,"interceptors#responseInterceptor");}function ta(r,e,t){var n="response";return"".concat(Di(r,n,e,t),"Make sure the ").concat(n," message is using the {text: string} format, e.g: {text: \"Model Response\"}");}function na(r,e){var t="request";return"".concat(Di(r,t,e),"Make sure the ").concat(t," message is using the {body: {text: string}} format, e.g: {body: {text: \"Model Response\"}}");}function sa(r){return"".concat(r," failed - please wait for chat view to render before calling this property.");}var un=ea,ia=na,ra=ta,vr=sa,le="Invalid API Key",He="Failed to connect",Me="Request settings have not been set up",Qs="No file was added",Fi="Image was not found",yo="Multi-response arrays are not supported for streaming",bo="Make sure the events are using {text: string} or {html: string} format.\nYou can also augment them using the responseInterceptor property: ".concat($,"interceptors#responseInterceptor"),oa="Cannot mix {text: string} and {html: string} responses.",aa="No valid stream events were sent.\n".concat(bo),la="Readable Stream connection error.",kt="Please define a `function_handler` property inside the service config.",Jt="Function tool response must be an array or contain a text property",vo="Failed to fetch history",fn="inside-start",it="inside-end",Ae="outside-start",ue="outside-end",ze="dropup-menu",x="default",Re="hover",z="click";var te=/*#__PURE__*/function(){function te(){_classCallCheck(this,te);}return _createClass(te,null,[{key:"unsetStyle",value:function unsetStyle(e,t){var n=Object.keys(t).reduce(function(s,i){return s[i]="",s;},{});Object.assign(e[_],n);}},{key:"unsetActivityCSSMouseStates",value:function unsetActivityCSSMouseStates(e,t){t[z]&&te.unsetStyle(e,t[z]),t[Re]&&te.unsetStyle(e,t[Re]);}},{key:"unsetAllCSSMouseStates",value:function unsetAllCSSMouseStates(e,t){te.unsetActivityCSSMouseStates(e,t),t[x]&&te.unsetStyle(e,t[x]);}// if you want to asdd default styling - use pure css classes
1
+ function _superPropGet(t,o,e,r){var p=_get(_getPrototypeOf(1&r?t.prototype:t),o,e);return 2&r&&"function"==typeof p?function(t){return p.apply(e,t);}:p;}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var p=_superPropBase(e,t);if(p){var n=Object.getOwnPropertyDescriptor(p,t);return n.get?n.get.call(arguments.length<3?e:r):n.value;}},_get.apply(null,arguments);}function _superPropBase(t,o){for(;!{}.hasOwnProperty.call(t,o)&&null!==(t=_getPrototypeOf(t)););return t;}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,F=function F(){};return{s:F,n:function(_n19){function n(){return _n19.apply(this,arguments);}n.toString=function(){return _n19.toString();};return n;}(function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]};}),e:function e(r){throw r;},f:F};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}var o,a=!0,u=!1;return{s:function s(){t=t.call(r);},n:function n(){var r=t.next();return a=r.done,r;},e:function e(r){u=!0,o=r;},f:function f(){try{a||null==t["return"]||t["return"]();}finally{if(u)throw o;}}};}function _wrapNativeSuper(t){var r="function"==typeof Map?new Map():void 0;return _wrapNativeSuper=function _wrapNativeSuper(t){if(null===t||!_isNativeFunction(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,Wrapper);}function Wrapper(){return _construct(t,arguments,_getPrototypeOf(this).constructor);}return Wrapper.prototype=Object.create(t.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,t);},_wrapNativeSuper(t);}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o))();return r&&_setPrototypeOf(p,r.prototype),p;}function _isNativeFunction(t){try{return-1!==Function.toString.call(t).indexOf("[native code]");}catch(n){return"function"==typeof t;}}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1;}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r;}finally{try{if(!f&&null!=t["return"]&&(u=t["return"](),Object(u)!==u))return;}finally{if(o)throw n;}}return a;}}function _arrayWithHoles(r){if(Array.isArray(r))return r;}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread();}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0;}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r);}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r);}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n;}function _callSuper(t,o,e){return o=_getPrototypeOf(o),_possibleConstructorReturn(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e));}function _possibleConstructorReturn(t,e){if(e&&("object"==_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t);}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e;}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t;})();}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t);},_getPrototypeOf(t);}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e);}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t;},_setPrototypeOf(t,e);}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof Generator?n:Generator,u=Object.create(c.prototype);return _regeneratorDefine2(u,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],y=!1,G={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function d(t,r){return i=t,c=0,u=e,G.n=r,a;}};function d(r,n){for(c=r,u=n,t=0;!y&&f&&!o&&t<p.length;t++){var o,i=p[t],d=G.p,l=i[2];r>3?(o=l===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,G.v=n,G.n=i[1]):d<l&&(o=r<3||i[0]>n||n>l)&&(i[4]=r,i[5]=n,G.n=l,c=0));}if(o||r>1)return a;throw y=!0,n;}return function(o,p,l){if(f>1)throw TypeError("Generator is already running");for(y&&1===p&&d(p,l),c=p,u=l;(t=c<2?e:u)||!y;){i||(c?c<3?(c>1&&(G.n=-1),d(c,u)):G.n=u:G.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0);}else 1===c&&(t=i["return"])&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e;}else if((t=(y=G.n<0)?u:r.call(n,G))!==a)break;}catch(t){i=e,c=1,u=t;}finally{f=1;}}return{value:t,done:y};};}(r,o,i),!0),u;}var a={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(_regeneratorDefine2(t={},n,function(){return this;}),t),u=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(u),e;}return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(u,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,o,"GeneratorFunction"),_regeneratorDefine2(u),_regeneratorDefine2(u,o,"Generator"),_regeneratorDefine2(u,n,function(){return this;}),_regeneratorDefine2(u,"toString",function(){return"[object Generator]";}),(_regenerator=function _regenerator(){return{w:i,m:f};})();}function _regeneratorDefine2(e,r,n,t){var i=Object.defineProperty;try{i({},"",{});}catch(e){i=0;}_regeneratorDefine2=function _regeneratorDefine(e,r,n,t){function o(r,n){_regeneratorDefine2(e,r,function(e){return this._invoke(r,n,e);});}r?i?i(e,r,{value:n,enumerable:!t,configurable:!t,writable:!t}):e[r]=n:(o("next",0),o("throw",1),o("return",2));},_regeneratorDefine2(e,r,n,t);}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value;}catch(n){return void e(n);}i.done?t(u):Promise.resolve(u).then(r,o);}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n);}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n);}_next(void 0);});};}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function");}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o);}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}var m="classList",_="style",Xo="unset",Zo="html-wrapper",S=function S(){var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:"div";return document.createElement(r);};var Yo=/*#__PURE__*/function(){function Yo(){_classCallCheck(this,Yo);}return _createClass(Yo,null,[{key:"render",value:function render(e,t){var n=S();n.id="error-view",n.innerText=t,e.replaceChildren(n);}}]);}();var ws=/*#__PURE__*/function(){function ws(){_classCallCheck(this,ws);}return _createClass(ws,null,[{key:"onLoad",value:function onLoad(e){e.innerHTML='<div id="loading-validate-key-property"></div>';}},{key:"createElements",value:function createElements(){var e=S();return e.id="validate-property-key-view",e;}},{key:"render",value:function render(e,t,n){var s=ws.createElements(),i={onSuccess:t,onFail:Yo.render.bind(this,e,"Your 'key' has failed authentication"),onLoad:ws.onLoad.bind(this,s)};n.key&&n.verifyKey(n.key,i),e.replaceChildren(s);}}]);}();var Q="service",h="text",M="html",f="error",$="https://deepchat.dev/docs/",K="ai",H="user",ot="assistant",Ts="error-message-text",ys="deep-chat-outer-container-role-",fr="empty-message",di="deep-chat-top-message",mr="deep-chat-middle-message",hi="deep-chat-bottom-message",A="src",T="type",ee="file",y="files",q="image",J="images",Ie="camera",hn="gifs",L="audio",Ye="microphone",po="mixedFiles",Vt="any",fo="file-message",Mt="start",mo="end",go="messages",gr="0",yr="1";function br(r){return r.charAt(0).toUpperCase()+r.slice(1);}function Qo(r){return r&&JSON.stringify(r);}function Di(r,e,t,n){var s="\n".concat(br(e)," message: ").concat(JSON.stringify(r)," \n"),i=t?"".concat(br(e)," message after interceptor: ").concat(Qo(n)," \n"):"";return s+i;}function ea(r,e,t,n){return"".concat(Di(r,e,t,n),"Make sure the ").concat(e," message is using the Response format: ").concat($,"connect/#Response \nYou can also augment it using the responseInterceptor property: ").concat($,"interceptors#responseInterceptor");}function ta(r,e,t){var n="response";return"".concat(Di(r,n,e,t),"Make sure the ").concat(n," message is using the {text: string} format, e.g: {text: \"Model Response\"}");}function na(r,e){var t="request";return"".concat(Di(r,t,e),"Make sure the ").concat(t," message is using the {body: {text: string}} format, e.g: {body: {text: \"Model Response\"}}");}function sa(r){return"".concat(r," failed - please wait for chat view to render before calling this property.");}var un=ea,ia=na,ra=ta,vr=sa,le="Invalid API Key",He="Failed to connect",Me="Request settings have not been set up",Qs="No file was added",Fi="Image was not found",yo="Multi-response arrays are not supported for streaming",bo="Make sure the events are using {text: string} or {html: string} format.\nYou can also augment them using the responseInterceptor property: ".concat($,"interceptors#responseInterceptor"),oa="Cannot mix {text: string} and {html: string} responses.",aa="No valid stream events were sent.\n".concat(bo),la="Readable Stream connection error.",kt="Please define a `function_handler` property inside the service config.",Jt="Function tool response must be an array or contain a text property",vo="Failed to fetch history",fn="inside-start",it="inside-end",Ae="outside-start",ue="outside-end",ze="dropup-menu",x="default",Re="hover",z="click";var te=/*#__PURE__*/function(){function te(){_classCallCheck(this,te);}return _createClass(te,null,[{key:"unsetStyle",value:function unsetStyle(e,t){var n=Object.keys(t).reduce(function(s,i){return s[i]="",s;},{});Object.assign(e[_],n);}},{key:"unsetActivityCSSMouseStates",value:function unsetActivityCSSMouseStates(e,t){t[z]&&te.unsetStyle(e,t[z]),t[Re]&&te.unsetStyle(e,t[Re]);}},{key:"unsetAllCSSMouseStates",value:function unsetAllCSSMouseStates(e,t){te.unsetActivityCSSMouseStates(e,t),t[x]&&te.unsetStyle(e,t[x]);}// if you want to asdd default styling - use pure css classes
2
2
  },{key:"processStateful",value:function processStateful(e){var t=e[x]||{},n=Object.assign(JSON.parse(JSON.stringify(t)),e==null?void 0:e[Re]),s=Object.assign(JSON.parse(JSON.stringify(n)),e==null?void 0:e[z]);return _defineProperty(_defineProperty(_defineProperty({},x,t),Re,n),z,s);}},{key:"mergeStatefulStyles",value:function mergeStatefulStyles(e){var t=_defineProperty(_defineProperty(_defineProperty({},x,{}),Re,{}),z,{});return e.forEach(function(n){t[x]=Object.assign(t[x],n[x]),t[Re]=Object.assign(t[Re],n[Re]),t[z]=Object.assign(t[z],n[z]);}),t;}},{key:"overwriteDefaultWithAlreadyApplied",value:function overwriteDefaultWithAlreadyApplied(e,t){Object.keys(e[x]||[]).forEach(function(n){var i;var s=n;t[_][s]&&(i=e[x])!=null&&i[s]&&(e[x][n]=t[_][s]);});}},{key:"applyToStyleIfNotDefined",value:function applyToStyleIfNotDefined(e,t){for(var n in t){var s=t[n];e[n]===""&&s&&(e[n]=s);}}}]);}();var Bt=/*#__PURE__*/function(){function Bt(){_classCallCheck(this,Bt);}return _createClass(Bt,null,[{key:"attemptAppendStyleSheetToHead",value:function attemptAppendStyleSheetToHead(e){if(e.fontFamily&&e.fontFamily!==Bt.DEFAULT_FONT_FAMILY)return;var t=document.getElementsByTagName("head")[0];if(!Array.from(t.getElementsByTagName("link")).some(function(s){return s.getAttribute("href")===Bt.FONT_URL;})){var s=S("link");s.rel="stylesheet",s.href=Bt.FONT_URL,t.appendChild(s);}}}]);}();Bt.FONT_URL="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap",Bt.DEFAULT_FONT_FAMILY="'Inter', sans-serif, Avenir, Helvetica, Arial";var Rs=Bt;var on=/*#__PURE__*/function(){function on(){_classCallCheck(this,on);}return _createClass(on,null,[{key:"apply",value:function apply(e,t){if(t)try{on.applyStyleSheet(e,t);}catch(_unused){on.addStyleElement(e,t);}}},{key:"applyStyleSheet",value:function applyStyleSheet(e,t){var n=new CSSStyleSheet();n.replaceSync(e),t.adoptedStyleSheets.push(n);}},{key:"addStyleElement",value:function addStyleElement(e,t){var n=S("style");n.innerHTML=e,t.appendChild(n);}},{key:"applyDefaultStyleToComponent",value:function applyDefaultStyleToComponent(e,t){t&&te.applyToStyleIfNotDefined(e,t),te.applyToStyleIfNotDefined(e,on.DEFAULT_COMPONENT_STYLE);}}]);}();on.DEFAULT_COMPONENT_STYLE={height:"350px",width:"320px",borderTop:"1px solid #cacaca",borderRight:"1px solid #cacaca",borderLeft:"1px solid #cacaca",borderBottom:"1px solid #cacaca",fontFamily:Rs.DEFAULT_FONT_FAMILY,fontSize:"0.9rem",backgroundColor:"white",position:"relative",// this is used to prevent inputAreaStyle background color from going beyond the container's rounded border
3
3
  // it will cause issues if there are elements that are meant to be outside of the chat component and in
4
4
  // that instance they should overwrite this
@@ -14,8 +14,8 @@ function clear(){var t,n,s;var e=window.scrollY;this.inputElementRef[m].contains
14
14
  // prettier-ignore
15
15
  },{key:"preventAutomaticScrollUpOnNewLine",value:function preventAutomaticScrollUpOnNewLine(e){var t;e.addEventListener("keydown",function(){t=window.scrollY;}),e.addEventListener("input",function(){t!==window.scrollY&&window.scrollTo({top:t});});}},{key:"addFilesToAnyType",value:function addFilesToAnyType(e,t){t&&e.addFilesToAnyType(Array.from(t).map(function(n){return n;}));}}]);}();At.TEXT_INPUT_ID="text-input";var Is=At;var Wt=/*#__PURE__*/function(){function Wt(){_classCallCheck(this,Wt);}return _createClass(Wt,null,[{key:"focusEndOfInput",value:function focusEndOfInput(e){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(t),(Oe.IS_MOBILE||Oe.IS_SAFARI)&&e.focus();}},{key:"focusFromParentElement",value:function focusFromParentElement(e){var t=e.querySelector("#".concat(Is.TEXT_INPUT_ID));t&&Wt.focusEndOfInput(t);}}]);}();var _o="Authentication",oe="Authorization",da="authorization",Ui="Unauthorized",Hi="Authorization header",Ot="Invalid",fs="Incorrect",be="authentication_error",We="invalid_request_error",D="Content-Type",ha="content-type",W="application/json",B="object",ji="completed",ye="Bearer ",ae="GET",he="POST",qi="Upload an audio file",As="function_call",Gt="input_audio",Ne="image_url",Ks=/*#__PURE__*/function(){function Ks(){_classCallCheck(this,Ks);}return _createClass(Ks,null,[{key:"addElements",value:function addElements(e){for(var _len=arguments.length,t=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){t[_key-1]=arguments[_key];}t.forEach(function(n){return e.appendChild(n);});}},{key:"isScrollbarAtBottomOfElement",value:function isScrollbarAtBottomOfElement(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:Ks.CODE_SNIPPET_GENERATION_JUMP;var n=e.scrollHeight,s=e.clientHeight,i=e.scrollTop,o=n-s;return i>=o-t;}},{key:"cloneElement",value:function cloneElement(e){var t=e.cloneNode(!0);return e.parentNode.replaceChild(t,e),t;}},{key:"scrollToBottom",value:function scrollToBottom(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var n=arguments.length>2?arguments[2]:undefined;e.scrollButton&&e.scrollButton.hiddenElements.size>0&&e.scrollButton.clearHidden(),n?e.elementRef.scrollTo({left:0,top:n.offsetTop}):t?e.elementRef.scrollTo({left:0,top:e.elementRef.scrollHeight,behavior:"smooth"}):e.elementRef.scrollTop=e.elementRef.scrollHeight;}},{key:"scrollToTop",value:function scrollToTop(e){e.scrollTop=0;}},{key:"isVisibleInParent",value:function isVisibleInParent(e,t){var n=e.getBoundingClientRect(),s=t.getBoundingClientRect();return n.bottom>s.top&&n.top<s.bottom;}},{key:"waitForScrollEnd",value:function waitForScrollEnd(e,t){var n=-1,s=0;var _i2=function i(){var o=e.scrollTop;if(o===n){if(s++,s>2){t();return;}}else s=0,n=o;requestAnimationFrame(_i2);};requestAnimationFrame(_i2);}},{key:"assignButtonEvents",value:function assignButtonEvents(e,t){e.onclick=t,e.onkeydown=function(n){n.key===de.ENTER&&setTimeout(t);};}}]);}();Ks.CODE_SNIPPET_GENERATION_JUMP=1;var F=Ks;var Xs=/*#__PURE__*/function(){function Xs(){_classCallCheck(this,Xs);}return _createClass(Xs,null,[{key:"speak",value:function speak(e,t){if(!t.audio&&window.SpeechSynthesisUtterance){var n=new SpeechSynthesisUtterance(e);Object.assign(n,t),speechSynthesis.speak(n);}}},{key:"processConfig",value:function processConfig(e,t){var n={};setTimeout(function(){if(_typeof(e)=="object"&&(e.audio&&(n.audio=e.audio),e.lang&&(n.lang=e.lang),e.pitch&&(n.pitch=e.pitch),e.rate&&(n.rate=e.rate),e.volume&&(n.volume=e.volume),e.voiceName)){var s=window.speechSynthesis.getVoices().find(function(i){var o;return i.name.toLocaleLowerCase()===((o=e.voiceName)==null?void 0:o.toLocaleLowerCase());});s&&(n.voice=s);}t(n);},Xs.LOAD_VOICES_MS);}}]);}();Xs.LOAD_VOICES_MS=200;var pn=Xs;var an=/*#__PURE__*/function(){function an(){_classCallCheck(this,an);}return _createClass(an,null,[{key:"colorToHex",value:function colorToHex(e){var t=S();return t[_].color=e,document.body.appendChild(t),"#".concat(window.getComputedStyle(t).color.match(/\d+/g).map(function(i){return parseInt(i).toString(16).padStart(2,"0");}).join(""));}},{key:"setDots",value:function setDots(e,t){var n,s;if((s=(n=t==null?void 0:t.styles)==null?void 0:n.bubble)!=null&&s.color){var i=an.colorToHex(t.styles.bubble.color);e[_].setProperty("--loading-message-color",i),e[_].setProperty("--loading-message-color-fade","".concat(i,"33"));}else e[_].setProperty("--loading-message-color","#848484"),e[_].setProperty("--loading-message-color-fade","#55555533");}},{key:"setRing",value:function setRing(e,t){var _ref4=t||{},n=_ref4.color,s=_ref4.width,i=_ref4.height,o=_ref4.margin,a=_ref4.border;if(n){var l=an.colorToHex(n);e[_].setProperty("--loading-history-color",l);}else e[_].setProperty("--loading-history-color","#dbdbdb");e[_].setProperty("--loading-history-height",i||"57px"),e[_].setProperty("--loading-history-width",s||"57px"),e[_].setProperty("--loading-history-margin",o||"7px"),e[_].setProperty("--loading-history-border",a||"6px solid");}}]);}();an.BUBBLE_CLASS="deep-chat-loading-message-bubble",an.DOTS_CONTAINER_CLASS="deep-chat-loading-message-dots-container";var rt=an;var ne=/*#__PURE__*/function(){function ne(){_classCallCheck(this,ne);}return _createClass(ne,null,[{key:"checkForContainerStyles",value:function checkForContainerStyles(e,t){var n=e.containerStyle;n&&(Object.assign(t[_],n),console[f]("The containerStyle property".concat(qe,"1.3.14.")),console[f]("".concat(Nt,"the style property instead: ").concat($,"styles#style")));}// eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  },{key:"handleResponseProperty",value:function handleResponseProperty(e){return console[f]("The {result: ....} response object type".concat(qe,"1.3.0.")),console[f]("".concat(Nt,"the new response object: ").concat($,"connect#Response")),e.result;}},{key:"processHistory",value:function processHistory(e){var t=e.initialMessages;if(t)return console[f]("The initialMessages property".concat(qe,"2.0.0.")),console[f]("".concat(Nt,"the history property instead: ").concat($,"messages/#history")),t;}},{key:"processHistoryFile",value:function processHistoryFile(e){var t=e[ee];t&&(console[f]("The file property in MessageContent".concat(qe,"1.3.17.")),console[f]("".concat(Nt,"the files array property: ").concat($,"messages/#MessageContent")),e[y]=[t]);}},{key:"processValidateInput",value:function processValidateInput(e){var t=e.validateMessageBeforeSending;if(t)return console[f]("The validateMessageBeforeSending property".concat(qe,"1.3.24.")),console[f]("".concat(Nt,"validateInput: ").concat($,"interceptors#validateInput")),t;}},{key:"processSubmitUserMessage",value:function processSubmitUserMessage(e){return console[f]("The submitUserMessage(text: string) argument string type".concat(qe,"1.4.4.")),console[f]("".concat(Nt,"the new argument type: ").concat($,"methods#submitUserMessage")),_defineProperty({},h,e);}},{key:"flagHTMLUpdateClass",value:function flagHTMLUpdateClass(e){var t;(t=e.children[0])!=null&&t[m].contains("deep-chat-update-message")&&(console[f]("The \"deep-chat-update-message\" html class".concat(qe,"1.4.4.")),console[f]("".concat(Nt,"using {..., overwrite: true} object: ").concat($,"connect#Response")));}},{key:"processConnect",value:function processConnect(e){var t=e;t.request&&(t.connect?Object.assign(t.connect,t.request):t.connect=t.request,console[f]("The request property".concat(qe,"2.0.0.")),console[f]("".concat(bs,"connect object: ").concat($,"connect#connect-1")));}},{key:"checkForStream",value:function checkForStream(e){var t=e.stream;if(t)return console[f]("The stream property".concat(Er,"the connect object in version 2.0.0.")),console[f]("".concat(bs,"connect object: ").concat($,"connect#connect-1")),t;}},{key:"fireOnNewMessage",value:function fireOnNewMessage(e,t){var s;var n=e;n.onNewMessage&&(console[f]("The onNewMessage event".concat(qe,"2.0.0.")),console[f]("".concat(bs,"onMessage event: ").concat($,"events#onMessage")),(s=n.onNewMessage)==null||s.call(n,t)),e.dispatchEvent(new CustomEvent("new-message",{detail:t}));}},{key:"processFileConfigConnect",value:function processFileConfigConnect(e){var t=e;t.request&&(console[f]("The request property in file configuration".concat(qe,"2.0.0.")),console[f]("Please use the connect property instead: ".concat($,"files")),t.connect||(t.connect=t.request));}},{key:"processMessageStyles",value:function processMessageStyles(e){if(!e)return;var t=JSON.parse(JSON.stringify(e)),n=t.loading;return n&&(n.outerContainer||n.innerContainer||n.bubble||n.media)&&(console[f]("The loading message styles are defined using LoadingMessageStyles interface".concat(sn,"2.1.0.")),console[f]("Check it out here: ".concat($,"messages/styles#LoadingMessageStyles")),t.loading={message:{styles:n}}),t;}},{key:"processDemo",value:function processDemo(e){return typeof e=="boolean"||e.displayLoadingBubble&&(console[f]("The demo displayLoadingBubble property".concat(qe,"2.1.0.")),console[f]("Please use displayLoading instead: ".concat($,"modes#demo")),e.displayLoading={message:!0}),e;}},{key:"processCohere",value:function processCohere(e){var t=e,n="".concat(bs,"official documentation: ").concat($,"directConnection/Cohere");return t.chat&&(console[f]("Cohere chat property".concat(qe,"2.2.3.")),console[f](n),delete t.chat),t.textGeneration?(console[f]("Cohere textGeneration".concat(_r,"2.2.3.")),console[f](n),delete t.textGeneration,!1):t.summarization?(console[f]("Cohere summarization".concat(_r,"2.2.3.")),console[f](n),delete t.summarization,!1):!0;}},{key:"processStreamHTMLWrappers",value:function processStreamHTMLWrappers(e){if(!e||_typeof(e)!==B)return;var t=e.htmlWrappers;if(t)return console[f]("The htmlWrappers property".concat(Er,"Deep Chat's base").concat(sn,"2.3.0.")),console[f]("Check it out here: ".concat($,"messages/HTML#htmlWrappers")),t;}},{key:"processFocusMode",value:function processFocusMode(e){return!e||typeof e=="boolean"||e.scroll&&(console[f]("The scroll property in focusMode has been changed to smoothScroll".concat(sn,"2.3.0.")),console[f]("Check it out here: ".concat($,"modes#focusMode")),e.smoothScroll=!0),e;}},{key:"processPosition",value:function processPosition(e){if(!e)return e;var t="Position names have been updated".concat(sn,"2.3.1.");return e==="inside-left"?(console[f](t),fn):e==="inside-right"?(console[f](t),it):e==="outside-left"?(console[f](t),Ae):e==="outside-right"?(console[f](t),ue):e;}},{key:"processBrowserStorage",value:function processBrowserStorage(e){var t=e.get();t&&Array.isArray(t)&&e.addMessages(t);}}]);}();var sn=" since version ",qe=" is deprecated ".concat(sn),Nt="Please change to using ",bs="Please see the ",_r=" is not supported ".concat(sn),Er=" has been moved to ";var bt=/*#__PURE__*/function(){function bt(){_classCallCheck(this,bt);}return _createClass(bt,null,[{key:"mouseUp",value:function mouseUp(e,t){te.unsetAllCSSMouseStates(e,t),Object.assign(e[_],t[x]),Object.assign(e[_],t[Re]);}},{key:"mouseDown",value:function mouseDown(e,t){Object.assign(e[_],t[z]);}},{key:"mouseLeave",value:function mouseLeave(e,t){te.unsetAllCSSMouseStates(e,t),Object.assign(e[_],t[x]);}},{key:"mouseEnter",value:function mouseEnter(e,t){Object.assign(e[_],t[Re]);}},{key:"add",value:function add(e,t){e.addEventListener("mouseenter",bt.mouseEnter.bind(this,e,t)),e.addEventListener("mouseleave",bt.mouseLeave.bind(this,e,t)),e.addEventListener("mousedown",bt.mouseDown.bind(this,e,t)),e.addEventListener("mouseup",bt.mouseUp.bind(this,e,t));}}]);}();var ua="deep-chat-temporary-message",pa="deep-chat-suggestion-button",bi={"deep-chat-button":{styles:_defineProperty(_defineProperty(_defineProperty({},x,{backgroundColor:"white",padding:"5px",paddingLeft:"7px",paddingRight:"7px",border:"1px solid #c2c2c2",borderRadius:"6px",cursor:"pointer"}),Re,{backgroundColor:"#fafafa"}),z,{backgroundColor:"#f1f1f1"})}},Sr=Object.keys(bi);var at=/*#__PURE__*/function(){function at(){_classCallCheck(this,at);}return _createClass(at,null,[{key:"applySuggestionEvent",value:function applySuggestionEvent(e,t){setTimeout(function(){t.addEventListener(z,function(){var n,s;(s=e.submitUserMessage)==null||s.call(e,_defineProperty({},h,((n=t.textContent)==null?void 0:n.trim())||""));});});}},{key:"isElementTemporary",value:function isElementTemporary(e){var t;return e?(t=e.bubbleElement.children[0])==null?void 0:t[m].contains(ua):!1;}},{key:"doesElementContainDeepChatClass",value:function doesElementContainDeepChatClass(e){return Sr.find(function(t){return e[m].contains(t);});}},{key:"applyEvents",value:function applyEvents(e,t){var n=bi[t].events;Object.keys(n||[]).forEach(function(s){e.addEventListener(s,n==null?void 0:n[s]);});}},{key:"getProcessedStyles",value:function getProcessedStyles(e,t,n){var s=Array.from(t[m]).reduce(function(a,l){var d;var c=(d=e[l])==null?void 0:d.styles;return c&&e[l].styles&&a.push(c),a;},[]),i=bi[n].styles;if(i){var a=JSON.parse(JSON.stringify(i));a[x]&&te.overwriteDefaultWithAlreadyApplied(a,t),s.unshift(a);}var o=te.mergeStatefulStyles(s);return te.processStateful(o);}},{key:"applyDeepChatUtilities",value:function applyDeepChatUtilities(e,t,n){Sr.forEach(function(i){var o=n.getElementsByClassName(i);Array.from(o||[]).forEach(function(a){var l=at.getProcessedStyles(t,a,i);Y.applyStylesToElement(a,l),at.applyEvents(a,i);});});var s=n.getElementsByClassName(pa);Array.from(s).forEach(function(i){return at.applySuggestionEvent(e,i);});}}]);}();var Y=/*#__PURE__*/function(){function Y(){_classCallCheck(this,Y);}return _createClass(Y,null,[{key:"applyStylesToElement",value:function applyStylesToElement(e,t){var n=te.processStateful(t);bt.add(e,n),Object.assign(e[_],n[x]);}},{key:"applyEventsToElement",value:function applyEventsToElement(e,t){Object.keys(t).forEach(function(n){var s=t[n];s&&e.addEventListener(n,s);});}},{key:"applyClassUtilitiesToElement",value:function applyClassUtilitiesToElement(e,t){var n=t.events,s=t.styles;n&&Y.applyEventsToElement(e,n),s&&!at.doesElementContainDeepChatClass(e)&&Y.applyStylesToElement(e,s);}},{key:"applyCustomClassUtilities",value:function applyCustomClassUtilities(e,t){Object.keys(e).forEach(function(n){var s=t.getElementsByClassName(n);Array.from(s).forEach(function(i){e[n]&&Y.applyClassUtilitiesToElement(i,e[n]);});});}},{key:"apply",value:function apply(e,t){at.applyDeepChatUtilities(e,e.htmlClassUtilities,t),Y.applyCustomClassUtilities(e.htmlClassUtilities,t);}},{key:"traverseNodes",value:function traverseNodes(e,t){e.nodeType===Node.ELEMENT_NODE&&t.push(e.outerHTML),e.childNodes.forEach(function(n){Y.traverseNodes(n,t);});}},{key:"splitHTML",value:function splitHTML(e){var n=new DOMParser().parseFromString(e,"text/html"),s=[];return n.body.childNodes.forEach(function(i){Y.traverseNodes(i,s);}),s;}},{key:"isTemporaryBasedOnHTML",value:function isTemporaryBasedOnHTML(e){var t=S();return t.innerHTML=e,at.isElementTemporary({outerContainer:t,bubbleElement:t,innerContainer:t});}// useful for removing event listeners
17
- },{key:"replaceElementWithNewClone",value:function replaceElementWithNewClone(e,t){var s;var n=(t||e).cloneNode(!0);return(s=e.parentNode)==null||s.replaceChild(n,e),n;}},{key:"tryAddWrapper",value:function tryAddWrapper(e,t,n,s){if(t&&s){var i=(n==null?void 0:n[s])||(n==null?void 0:n[x]);if(i)return e.innerHTML=i,{contentEl:Y.getTargetWrapper(e),wrapper:!0};}return{contentEl:e,wrapper:!1};}},{key:"getTargetWrapper",value:function getTargetWrapper(e){return e.getElementsByClassName(Zo)[0]||e;}}]);}();var wt=/*#__PURE__*/function(){function wt(){_classCallCheck(this,wt);}return _createClass(wt,null,[{key:"createElements",value:function createElements(e,t,n,s){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;var o=e.createMessageElementsOnOrientation("",n,s,i);o.bubbleElement[m].add(wt.HTML_BUBBLE_CLASS);var _Y$tryAddWrapper=Y.tryAddWrapper(o.bubbleElement,t,e._customWrappers,n),a=_Y$tryAddWrapper.contentEl;return a.innerHTML=t,o;}},{key:"overwriteElements",value:function overwriteElements(e,t,n){n.bubbleElement.innerHTML=t,Y.apply(e,n.outerContainer),ne.flagHTMLUpdateClass(n.bubbleElement);}// prettier-ignore
18
- },{key:"overwrite",value:function overwrite(e,t,n,s){var i=e.messageToElements,o=N.overwriteMessage(i,s,t,n,M,wt.HTML_BUBBLE_CLASS);return o&&wt.overwriteElements(e,t,o),o;}},{key:"create",value:function create(e,t,n){var s=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var o;var i=wt.createElements(e,t,n,s);return N.fillEmptyMessageElement(i.bubbleElement,t),Y.apply(e,i.outerContainer),ne.flagHTMLUpdateClass(i.bubbleElement),e.applyCustomStyles(i,n,!1,(o=e.messageStyles)==null?void 0:o[M]),i;}},{key:"add",value:function add(e,t,n,s){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;if(s!=null&&s.status){var a=this.overwrite(e,t,n,e.messageElementRefs);if(a)return a;s.status=!1;}if(i&&e.messageElementRefs.length>0&&Y.isTemporaryBasedOnHTML(t))return;var o=wt.create(e,t,n,i);return i||e.appendOuterContainerElemet(o.outerContainer),o;}}]);}();wt.HTML_BUBBLE_CLASS="html-message";var lt=wt;var fa=/*#__PURE__*/function(){function fa(){_classCallCheck(this,fa);}return _createClass(fa,null,[{key:"katex",value:function katex(e,t,n){var a=(n||{}).delimiter||"$";if(a.length!==1)throw new Error("invalid delimiter");var l=function l(p,u){var g;return((g=window.katex)==null?void 0:g.renderToString(p,_objectSpread({displayMode:u,throwOnError:!1,output:"mathml"},e)))||"";},c=function c(p,u,g){var b=!1,v=p.bMarks[u]+p.tShift[u],E=p.eMarks[u];if(v+1>E)return!1;var C=p[A].charAt(v);if(C!==a)return!1;var j=v;v=p.skipChars(v,C);var X=v-j;if(X!==2)return!1;var Z=u;for(;++Z,!(Z>=g||(v=j=p.bMarks[Z]+p.tShift[Z],E=p.eMarks[Z],v<E&&p.tShift[Z]<p.blkIndent));)if(p[A].charAt(v)===a&&!(p.tShift[Z]-p.blkIndent>=4)&&(v=p.skipChars(v,C),!(v-j<X)&&(v=p.skipSpaces(v),!(v<E)))){b=!0;break;}X=p.tShift[u],p.line=Z+(b?1:0);var ve=p.getLines(u+1,Z,X,!0).replace(/[ \n]+/g," ").trim();return p.tokens.push({type:"katex",params:null,content:ve,lines:[u,p.line],level:p.level,block:!0}),!0;},d=function d(p,u){var g=p.pos,b=p.posMax;var v=g;if(p[A].charAt(v)!==a)return!1;for(++v;v<b&&p[A].charAt(v)===a;)++v;var E=p[A].slice(g,v);if(E.length>2)return!1;var C=v;var j=0;for(;v<b;){var X=p[A].charAt(v);if(X==="{"&&(v===0||p[A].charAt(v-1)!=="\\"))j+=1;else if(X==="}"&&(v===0||p[A].charAt(v-1)!=="\\")){if(j-=1,j<0)return!1;}else if(X===a&&j===0){var Z=v;var ve=v+1;for(;ve<b&&p[A].charAt(ve)===a;)++ve;if(ve-Z===E.length){if(!u){var St=p[A].slice(C,Z).replace(/[ \n]+/g," ").trim();p.push({type:"katex",content:St,block:E.length>1,level:p.level});}return p.pos=ve,!0;}}v+=1;}return u||(p.pending+=E),p.pos+=E.length,!0;};t.inline.ruler.push("katex",d,n),t.block.ruler.push("katex",c,n),t.renderer.rules.katex=function(p,u){return l(p[u].content,p[u].block);},t.renderer.rules.katex.delimiter=a;}}]);}();var vs;function Eo(r){return vs=vs||document.createElement("textarea"),vs.innerHTML="&"+r+";",vs.value;}var ma=Object.prototype.hasOwnProperty;function ga(r,e){return r?ma.call(r,e):!1;}function So(r){var e=[].slice.call(arguments,1);return e.forEach(function(t){if(t){if(_typeof(t)!="object")throw new TypeError(t+"must be object");Object.keys(t).forEach(function(n){r[n]=t[n];});}}),r;}var ya=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function os(r){return r.indexOf("\\")<0?r:r.replace(ya,"$1");}function xo(r){return!(r>=55296&&r<=57343||r>=64976&&r<=65007||(r&65535)===65535||(r&65535)===65534||r>=0&&r<=8||r===11||r>=14&&r<=31||r>=127&&r<=159||r>1114111);}function vi(r){if(r>65535){r-=65536;var e=55296+(r>>10),t=56320+(r&1023);return String.fromCharCode(e,t);}return String.fromCharCode(r);}var ba=/&([a-z#][a-z0-9]{1,31});/gi,va=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;function _a(r,e){var t=0,n=Eo(e);return e!==n?n:e.charCodeAt(0)===35&&va.test(e)&&(t=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10),xo(t))?vi(t):r;}function Kt(r){return r.indexOf("&")<0?r:r.replace(ba,_a);}var Ea=/[&<>"]/,Sa=/[&<>"]/g,xa={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function Aa(r){return xa[r];}function Pe(r){return Ea.test(r)?r.replace(Sa,Aa):r;}var w={};w.blockquote_open=function(){return"<blockquote>\n";};w.blockquote_close=function(r,e){return"</blockquote>"+Yt(r,e);};w.code=function(r,e){return r[e].block?"<pre><code>"+Pe(r[e].content)+"</code></pre>"+Yt(r,e):"<code>"+Pe(r[e].content)+"</code>";};w.fence=function(r,e,t,n,s){var i=r[e],o="",a=t.langPrefix,l="",c,d,p;if(i.params){if(c=i.params.split(/\s+/g),d=c.join(" "),ga(s.rules.fence_custom,c[0]))return s.rules.fence_custom[c[0]](r,e,t,n,s);l=Pe(Kt(os(d))),o=' class="'+a+l+'"';}return t.highlight?p=t.highlight.apply(t.highlight,[i.content].concat(c))||Pe(i.content):p=Pe(i.content),"<pre><code"+o+">"+p+"</code></pre>"+Yt(r,e);};w.fence_custom={};w.heading_open=function(r,e){return"<h"+r[e].hLevel+">";};w.heading_close=function(r,e){return"</h"+r[e].hLevel+">\n";};w.hr=function(r,e,t){return(t.xhtmlOut?"<hr />":"<hr>")+Yt(r,e);};w.bullet_list_open=function(){return"<ul>\n";};w.bullet_list_close=function(r,e){return"</ul>"+Yt(r,e);};w.list_item_open=function(){return"<li>";};w.list_item_close=function(){return"</li>\n";};w.ordered_list_open=function(r,e){var t=r[e],n=t.order>1?' start="'+t.order+'"':"";return"<ol"+n+">\n";};w.ordered_list_close=function(r,e){return"</ol>"+Yt(r,e);};w.paragraph_open=function(r,e){return r[e].tight?"":"<p>";};w.paragraph_close=function(r,e){var t=!(r[e].tight&&e&&r[e-1].type==="inline"&&!r[e-1].content);return(r[e].tight?"":"</p>")+(t?Yt(r,e):"");};w.link_open=function(r,e,t){var n=r[e].title?' title="'+Pe(Kt(r[e].title))+'"':"",s=t.linkTarget?' target="'+t.linkTarget+'"':"";return'<a href="'+Pe(r[e].href)+'"'+n+s+">";};w.link_close=function(){return"</a>";};w.image=function(r,e,t){var n=' src="'+Pe(r[e].src)+'"',s=r[e].title?' title="'+Pe(Kt(r[e].title))+'"':"",i=' alt="'+(r[e].alt?Pe(Kt(os(r[e].alt))):"")+'"',o=t.xhtmlOut?" /":"";return"<img"+n+i+s+o+">";};w.table_open=function(){return"<table>\n";};w.table_close=function(){return"</table>\n";};w.thead_open=function(){return"<thead>\n";};w.thead_close=function(){return"</thead>\n";};w.tbody_open=function(){return"<tbody>\n";};w.tbody_close=function(){return"</tbody>\n";};w.tr_open=function(){return"<tr>";};w.tr_close=function(){return"</tr>\n";};w.th_open=function(r,e){var t=r[e];return"<th"+(t.align?' style="text-align:'+t.align+'"':"")+">";};w.th_close=function(){return"</th>";};w.td_open=function(r,e){var t=r[e];return"<td"+(t.align?' style="text-align:'+t.align+'"':"")+">";};w.td_close=function(){return"</td>";};w.strong_open=function(){return"<strong>";};w.strong_close=function(){return"</strong>";};w.em_open=function(){return"<em>";};w.em_close=function(){return"</em>";};w.del_open=function(){return"<del>";};w.del_close=function(){return"</del>";};w.ins_open=function(){return"<ins>";};w.ins_close=function(){return"</ins>";};w.mark_open=function(){return"<mark>";};w.mark_close=function(){return"</mark>";};w.sub=function(r,e){return"<sub>"+Pe(r[e].content)+"</sub>";};w.sup=function(r,e){return"<sup>"+Pe(r[e].content)+"</sup>";};w.hardbreak=function(r,e,t){return t.xhtmlOut?"<br />\n":"<br>\n";};w.softbreak=function(r,e,t){return t.breaks?t.xhtmlOut?"<br />\n":"<br>\n":"\n";};w.text=function(r,e){return Pe(r[e].content);};w.htmlblock=function(r,e){return r[e].content;};w.htmltag=function(r,e){return r[e].content;};w.abbr_open=function(r,e){return'<abbr title="'+Pe(Kt(r[e].title))+'">';};w.abbr_close=function(){return"</abbr>";};w.footnote_ref=function(r,e){var t=Number(r[e].id+1).toString(),n="fnref"+t;return r[e].subId>0&&(n+=":"+r[e].subId),'<sup class="footnote-ref"><a href="#fn'+t+'" id="'+n+'">['+t+"]</a></sup>";};w.footnote_block_open=function(r,e,t){var n=t.xhtmlOut?"<hr class=\"footnotes-sep\" />\n":"<hr class=\"footnotes-sep\">\n";return n+"<section class=\"footnotes\">\n<ol class=\"footnotes-list\">\n";};w.footnote_block_close=function(){return"</ol>\n</section>\n";};w.footnote_open=function(r,e){var t=Number(r[e].id+1).toString();return'<li id="fn'+t+'" class="footnote-item">';};w.footnote_close=function(){return"</li>\n";};w.footnote_anchor=function(r,e){var t=Number(r[e].id+1).toString(),n="fnref"+t;return r[e].subId>0&&(n+=":"+r[e].subId),' <a href="#'+n+'" class="footnote-backref">↩</a>';};w.dl_open=function(){return"<dl>\n";};w.dt_open=function(){return"<dt>";};w.dd_open=function(){return"<dd>";};w.dl_close=function(){return"</dl>\n";};w.dt_close=function(){return"</dt>\n";};w.dd_close=function(){return"</dd>\n";};function Ao(r,e){return++e>=r.length-2?e:r[e].type==="paragraph_open"&&r[e].tight&&r[e+1].type==="inline"&&r[e+1].content.length===0&&r[e+2].type==="paragraph_close"&&r[e+2].tight?Ao(r,e+2):e;}var Yt=w.getBreak=function(e,t){return t=Ao(e,t),t<e.length&&e[t].type==="list_item_close"?"":"\n";};function $i(){this.rules=So({},w),this.getBreak=w.getBreak;}$i.prototype.renderInline=function(r,e,t){for(var n=this.rules,s=r.length,i=0,o="";s--;)o+=n[r[i].type](r,i++,e,t,this);return o;};$i.prototype.render=function(r,e,t){for(var n=this.rules,s=r.length,i=-1,o="";++i<s;)r[i].type==="inline"?o+=this.renderInline(r[i].children,e,t):o+=n[r[i].type](r,i,e,t,this);return o;};function je(){this.__rules__=[],this.__cache__=null;}je.prototype.__find__=function(r){for(var e=this.__rules__.length,t=-1;e--;)if(this.__rules__[++t].name===r)return t;return-1;};je.prototype.__compile__=function(){var r=this,e=[""];r.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n);});}),r.__cache__={},e.forEach(function(t){r.__cache__[t]=[],r.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||r.__cache__[t].push(n.fn));});});};je.prototype.at=function(r,e,t){var n=this.__find__(r),s=t||{};if(n===-1)throw new Error("Parser rule not found: "+r);this.__rules__[n].fn=e,this.__rules__[n].alt=s.alt||[],this.__cache__=null;};je.prototype.before=function(r,e,t,n){var s=this.__find__(r),i=n||{};if(s===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(s,0,{name:e,enabled:!0,fn:t,alt:i.alt||[]}),this.__cache__=null;};je.prototype.after=function(r,e,t,n){var s=this.__find__(r),i=n||{};if(s===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(s+1,0,{name:e,enabled:!0,fn:t,alt:i.alt||[]}),this.__cache__=null;};je.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null;};je.prototype.enable=function(r,e){r=Array.isArray(r)?r:[r],e&&this.__rules__.forEach(function(t){t.enabled=!1;}),r.forEach(function(t){var n=this.__find__(t);if(n<0)throw new Error("Rules manager: invalid rule name "+t);this.__rules__[n].enabled=!0;},this),this.__cache__=null;};je.prototype.disable=function(r){r=Array.isArray(r)?r:[r],r.forEach(function(e){var t=this.__find__(e);if(t<0)throw new Error("Rules manager: invalid rule name "+e);this.__rules__[t].enabled=!1;},this),this.__cache__=null;};je.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[];};function wa(r){r.inlineMode?r.tokens.push({type:"inline",content:r.src.replace(/\n/g," ").trim(),level:0,lines:[0,1],children:[]}):r.block.parse(r.src,r.options,r.env,r.tokens);}function Qt(r,e,t,n,s){this.src=r,this.env=n,this.options=t,this.parser=e,this.tokens=s,this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache=[],this.isInLabel=!1,this.linkLevel=0,this.linkContent="",this.labelUnmatchedScopes=0;}Qt.prototype.pushPending=function(){this.tokens.push({type:"text",content:this.pending,level:this.pendingLevel}),this.pending="";};Qt.prototype.push=function(r){this.pending&&this.pushPending(),this.tokens.push(r),this.pendingLevel=this.level;};Qt.prototype.cacheSet=function(r,e){for(var t=this.cache.length;t<=r;t++)this.cache.push(0);this.cache[r]=e;};Qt.prototype.cacheGet=function(r){return r<this.cache.length?this.cache[r]:0;};function as(r,e){var t,n,s,i=-1,o=r.posMax,a=r.pos,l=r.isInLabel;if(r.isInLabel)return-1;if(r.labelUnmatchedScopes)return r.labelUnmatchedScopes--,-1;for(r.pos=e+1,r.isInLabel=!0,t=1;r.pos<o;){if(s=r.src.charCodeAt(r.pos),s===91)t++;else if(s===93&&(t--,t===0)){n=!0;break;}r.parser.skipToken(r);}return n?(i=r.pos,r.labelUnmatchedScopes=0):r.labelUnmatchedScopes=t-1,r.pos=a,r.isInLabel=l,i;}function Ca(r,e,t,n){var s,i,o,a,l,c;if(r.charCodeAt(0)!==42||r.charCodeAt(1)!==91||r.indexOf("]:")===-1||(s=new Qt(r,e,t,n,[]),i=as(s,1),i<0||r.charCodeAt(i+1)!==58))return-1;for(a=s.posMax,o=i+2;o<a&&s.src.charCodeAt(o)!==10;o++);return l=r.slice(2,i),c=r.slice(i+2,o).trim(),c.length===0?-1:(n.abbreviations||(n.abbreviations={}),_typeof(n.abbreviations[":"+l])>"u"&&(n.abbreviations[":"+l]=c),o);}function Ta(r){var e=r.tokens,t,n,s,i;if(!r.inlineMode){for(t=1,n=e.length-1;t<n;t++)if(e[t-1].type==="paragraph_open"&&e[t].type==="inline"&&e[t+1].type==="paragraph_close"){for(s=e[t].content;s.length&&(i=Ca(s,r.inline,r.options,r.env),!(i<0));)s=s.slice(i).trim();e[t].content=s,s.length||(e[t-1].tight=!0,e[t+1].tight=!0);}}}function _i(r){var e=Kt(r);try{e=decodeURI(e);}catch(_unused2){}return encodeURI(e);}function wo(r,e){var t,n,s,i=e,o=r.posMax;if(r.src.charCodeAt(e)===60){for(e++;e<o;){if(t=r.src.charCodeAt(e),t===10)return!1;if(t===62)return s=_i(os(r.src.slice(i+1,e))),r.parser.validateLink(s)?(r.pos=e+1,r.linkContent=s,!0):!1;if(t===92&&e+1<o){e+=2;continue;}e++;}return!1;}for(n=0;e<o&&(t=r.src.charCodeAt(e),!(t===32||t<32||t===127));){if(t===92&&e+1<o){e+=2;continue;}if(t===40&&(n++,n>1)||t===41&&(n--,n<0))break;e++;}return i===e||(s=os(r.src.slice(i,e)),!r.parser.validateLink(s))?!1:(r.linkContent=s,r.pos=e,!0);}function Co(r,e){var t,n=e,s=r.posMax,i=r.src.charCodeAt(e);if(i!==34&&i!==39&&i!==40)return!1;for(e++,i===40&&(i=41);e<s;){if(t=r.src.charCodeAt(e),t===i)return r.pos=e+1,r.linkContent=os(r.src.slice(n+1,e)),!0;if(t===92&&e+1<s){e+=2;continue;}e++;}return!1;}function To(r){return r.trim().replace(/\s+/g," ").toUpperCase();}function Ra(r,e,t,n){var s,i,o,a,l,c,d,p,u;if(r.charCodeAt(0)!==91||r.indexOf("]:")===-1||(s=new Qt(r,e,t,n,[]),i=as(s,0),i<0||r.charCodeAt(i+1)!==58))return-1;for(a=s.posMax,o=i+2;o<a&&(l=s.src.charCodeAt(o),!(l!==32&&l!==10));o++);if(!wo(s,o))return-1;for(d=s.linkContent,o=s.pos,c=o,o=o+1;o<a&&(l=s.src.charCodeAt(o),!(l!==32&&l!==10));o++);for(o<a&&c!==o&&Co(s,o)?(p=s.linkContent,o=s.pos):(p="",o=c);o<a&&s.src.charCodeAt(o)===32;)o++;return o<a&&s.src.charCodeAt(o)!==10?-1:(u=To(r.slice(1,i)),_typeof(n.references[u])>"u"&&(n.references[u]={title:p,href:d}),o);}function Ia(r){var e=r.tokens,t,n,s,i;if(r.env.references=r.env.references||{},!r.inlineMode){for(t=1,n=e.length-1;t<n;t++)if(e[t].type==="inline"&&e[t-1].type==="paragraph_open"&&e[t+1].type==="paragraph_close"){for(s=e[t].content;s.length&&(i=Ra(s,r.inline,r.options,r.env),!(i<0));)s=s.slice(i).trim();e[t].content=s,s.length||(e[t-1].tight=!0,e[t+1].tight=!0);}}}function Ma(r){var e=r.tokens,t,n,s;for(n=0,s=e.length;n<s;n++)t=e[n],t.type==="inline"&&r.inline.parse(t.content,r.options,r.env,t.children);}function ka(r){var e,t,n,s,i,o,a,l,c,d=0,p=!1,u={};if(r.env.footnotes&&(r.tokens=r.tokens.filter(function(g){return g.type==="footnote_reference_open"?(p=!0,l=[],c=g.label,!1):g.type==="footnote_reference_close"?(p=!1,u[":"+c]=l,!1):(p&&l.push(g),!p);}),!!r.env.footnotes.list)){for(o=r.env.footnotes.list,r.tokens.push({type:"footnote_block_open",level:d++}),e=0,t=o.length;e<t;e++){for(r.tokens.push({type:"footnote_open",id:e,level:d++}),o[e].tokens?(a=[],a.push({type:"paragraph_open",tight:!1,level:d++}),a.push({type:"inline",content:"",level:d,children:o[e].tokens}),a.push({type:"paragraph_close",tight:!1,level:--d})):o[e].label&&(a=u[":"+o[e].label]),r.tokens=r.tokens.concat(a),r.tokens[r.tokens.length-1].type==="paragraph_close"?i=r.tokens.pop():i=null,s=o[e].count>0?o[e].count:1,n=0;n<s;n++)r.tokens.push({type:"footnote_anchor",id:e,subId:n,level:d});i&&r.tokens.push(i),r.tokens.push({type:"footnote_close",level:--d});}r.tokens.push({type:"footnote_block_close",level:--d});}}var xr=" \n()[]'\".,!?-";function ui(r){return r.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1");}function Oa(r){var e,t,n,s,i,o,a,l,c,d,p,u,g=r.tokens;if(r.env.abbreviations){for(r.env.abbrRegExp||(u="(^|["+xr.split("").map(ui).join("")+"])("+Object.keys(r.env.abbreviations).map(function(b){return b.substr(1);}).sort(function(b,v){return v.length-b.length;}).map(ui).join("|")+")($|["+xr.split("").map(ui).join("")+"])",r.env.abbrRegExp=new RegExp(u,"g")),d=r.env.abbrRegExp,t=0,n=g.length;t<n;t++)if(g[t].type==="inline"){for(s=g[t].children,e=s.length-1;e>=0;e--)if(i=s[e],i.type==="text"){for(l=0,o=i.content,d.lastIndex=0,c=i.level,a=[];p=d.exec(o);)d.lastIndex>l&&a.push({type:"text",content:o.slice(l,p.index+p[1].length),level:c}),a.push({type:"abbr_open",title:r.env.abbreviations[":"+p[2]],level:c++}),a.push({type:"text",content:p[2],level:c}),a.push({type:"abbr_close",level:--c}),l=d.lastIndex-p[3].length;a.length&&(l<o.length&&a.push({type:"text",content:o.slice(l),level:c}),g[t].children=s=[].concat(s.slice(0,e),a,s.slice(e+1)));}}}}var Na=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Pa=/\((c|tm|r|p)\)/ig,La={c:"©",r:"®",p:"§",tm:"™"};function Ba(r){return r.indexOf("(")<0?r:r.replace(Pa,function(e,t){return La[t.toLowerCase()];});}function Da(r){var e,t,n,s,i;if(r.options.typographer){for(i=r.tokens.length-1;i>=0;i--)if(r.tokens[i].type==="inline")for(s=r.tokens[i].children,e=s.length-1;e>=0;e--)t=s[e],t.type==="text"&&(n=t.content,n=Ba(n),Na.test(n)&&(n=n.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/mg,"$1—$2").replace(/(^|\s)--(\s|$)/mg,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/mg,"$1–$2")),t.content=n);}}var Fa=/['"]/,Ar=/['"]/g,Ua=/[-\s()\[\]]/,wr="’";function Cr(r,e){return e<0||e>=r.length?!1:!Ua.test(r[e]);}function nn(r,e,t){return r.substr(0,e)+t+r.substr(e+1);}function Ha(r){var e,t,n,s,i,o,a,l,c,d,p,u,g,b,v,E,C;if(r.options.typographer){for(C=[],v=r.tokens.length-1;v>=0;v--)if(r.tokens[v].type==="inline"){for(E=r.tokens[v].children,C.length=0,e=0;e<E.length;e++)if(t=E[e],!(t.type!=="text"||Fa.test(t.text))){for(a=E[e].level,g=C.length-1;g>=0&&!(C[g].level<=a);g--);C.length=g+1,n=t.content,i=0,o=n.length;e:for(;i<o&&(Ar.lastIndex=i,s=Ar.exec(n),!!s);){if(l=!Cr(n,s.index-1),i=s.index+1,b=s[0]==="'",c=!Cr(n,i),!c&&!l){b&&(t.content=nn(t.content,s.index,wr));continue;}if(p=!c,u=!l,u){for(g=C.length-1;g>=0&&(d=C[g],!(C[g].level<a));g--)if(d.single===b&&C[g].level===a){d=C[g],b?(E[d.token].content=nn(E[d.token].content,d.pos,r.options.quotes[2]),t.content=nn(t.content,s.index,r.options.quotes[3])):(E[d.token].content=nn(E[d.token].content,d.pos,r.options.quotes[0]),t.content=nn(t.content,s.index,r.options.quotes[1])),C.length=g;continue e;}}p?C.push({token:e,pos:s.index,single:b,level:a}):u&&b&&(t.content=nn(t.content,s.index,wr));}}}}}var pi=[["block",wa],["abbr",Ta],["references",Ia],["inline",Ma],["footnote_tail",ka],["abbr2",Oa],["replacements",Da],["smartquotes",Ha]];function Ro(){this.options={},this.ruler=new je();for(var r=0;r<pi.length;r++)this.ruler.push(pi[r][0],pi[r][1]);}Ro.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r);};function en(r,e,t,n,s){var i,o,a,l,c,d,p;for(this.src=r,this.parser=e,this.options=t,this.env=n,this.tokens=s,this.bMarks=[],this.eMarks=[],this.tShift=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.parentType="root",this.ddIndent=-1,this.level=0,this.result="",o=this.src,d=0,p=!1,a=l=d=0,c=o.length;l<c;l++){if(i=o.charCodeAt(l),!p)if(i===32){d++;continue;}else p=!0;(i===10||l===c-1)&&(i!==10&&l++,this.bMarks.push(a),this.eMarks.push(l),this.tShift.push(d),p=!1,d=0,a=l+1);}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.lineMax=this.bMarks.length-1;}en.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e];};en.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e;};en.prototype.skipSpaces=function(e){for(var t=this.src.length;e<t&&this.src.charCodeAt(e)===32;e++);return e;};en.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e;};en.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e;};en.prototype.getLines=function(e,t,n,s){var i,o,a,l,c,d=e;if(e>=t)return"";if(d+1===t)return o=this.bMarks[d]+Math.min(this.tShift[d],n),a=s?this.eMarks[d]+1:this.eMarks[d],this.src.slice(o,a);for(l=new Array(t-e),i=0;d<t;d++,i++)c=this.tShift[d],c>n&&(c=n),c<0&&(c=0),o=this.bMarks[d]+c,d+1<t||s?a=this.eMarks[d]+1:a=this.eMarks[d],l[i]=this.src.slice(o,a);return l.join("");};function ja(r,e,t){var n,s;if(r.tShift[e]-r.blkIndent<4)return!1;for(s=n=e+1;n<t;){if(r.isEmpty(n)){n++;continue;}if(r.tShift[n]-r.blkIndent>=4){n++,s=n;continue;}break;}return r.line=n,r.tokens.push({type:"code",content:r.getLines(e,s,4+r.blkIndent,!0),block:!0,lines:[e,r.line],level:r.level}),!0;}function qa(r,e,t,n){var s,i,o,a,l,c=!1,d=r.bMarks[e]+r.tShift[e],p=r.eMarks[e];if(d+3>p||(s=r.src.charCodeAt(d),s!==126&&s!==96)||(l=d,d=r.skipChars(d,s),i=d-l,i<3)||(o=r.src.slice(d,p).trim(),o.indexOf("`")>=0))return!1;if(n)return!0;for(a=e;a++,!(a>=t||(d=l=r.bMarks[a]+r.tShift[a],p=r.eMarks[a],d<p&&r.tShift[a]<r.blkIndent));)if(r.src.charCodeAt(d)===s&&!(r.tShift[a]-r.blkIndent>=4)&&(d=r.skipChars(d,s),!(d-l<i)&&(d=r.skipSpaces(d),!(d<p)))){c=!0;break;}return i=r.tShift[e],r.line=a+(c?1:0),r.tokens.push({type:"fence",params:o,content:r.getLines(e+1,a,i,!0),lines:[e,r.line],level:r.level}),!0;}function $a(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v=r.bMarks[e]+r.tShift[e],E=r.eMarks[e];if(v>E||r.src.charCodeAt(v++)!==62||r.level>=r.options.maxNesting)return!1;if(n)return!0;for(r.src.charCodeAt(v)===32&&v++,l=r.blkIndent,r.blkIndent=0,a=[r.bMarks[e]],r.bMarks[e]=v,v=v<E?r.skipSpaces(v):v,i=v>=E,o=[r.tShift[e]],r.tShift[e]=v-r.bMarks[e],p=r.parser.ruler.getRules("blockquote"),s=e+1;s<t&&(v=r.bMarks[s]+r.tShift[s],E=r.eMarks[s],!(v>=E));s++){if(r.src.charCodeAt(v++)===62){r.src.charCodeAt(v)===32&&v++,a.push(r.bMarks[s]),r.bMarks[s]=v,v=v<E?r.skipSpaces(v):v,i=v>=E,o.push(r.tShift[s]),r.tShift[s]=v-r.bMarks[s];continue;}if(i)break;for(b=!1,u=0,g=p.length;u<g;u++)if(p[u](r,s,t,!0)){b=!0;break;}if(b)break;a.push(r.bMarks[s]),o.push(r.tShift[s]),r.tShift[s]=-1337;}for(c=r.parentType,r.parentType="blockquote",r.tokens.push({type:"blockquote_open",lines:d=[e,0],level:r.level++}),r.parser.tokenize(r,e,s),r.tokens.push({type:"blockquote_close",level:--r.level}),r.parentType=c,d[1]=r.line,u=0;u<o.length;u++)r.bMarks[u+e]=a[u],r.tShift[u+e]=o[u];return r.blkIndent=l,!0;}function Ga(r,e,t,n){var s,i,o,a=r.bMarks[e],l=r.eMarks[e];if(a+=r.tShift[e],a>l||(s=r.src.charCodeAt(a++),s!==42&&s!==45&&s!==95))return!1;for(i=1;a<l;){if(o=r.src.charCodeAt(a++),o!==s&&o!==32)return!1;o===s&&i++;}return i<3?!1:(n||(r.line=e+1,r.tokens.push({type:"hr",lines:[e,r.line],level:r.level})),!0);}function Tr(r,e){var t,n,s;return n=r.bMarks[e]+r.tShift[e],s=r.eMarks[e],n>=s||(t=r.src.charCodeAt(n++),t!==42&&t!==45&&t!==43)||n<s&&r.src.charCodeAt(n)!==32?-1:n;}function Rr(r,e){var t,n=r.bMarks[e]+r.tShift[e],s=r.eMarks[e];if(n+1>=s||(t=r.src.charCodeAt(n++),t<48||t>57))return-1;for(;;){if(n>=s)return-1;if(t=r.src.charCodeAt(n++),!(t>=48&&t<=57)){if(t===41||t===46)break;return-1;}}return n<s&&r.src.charCodeAt(n)!==32?-1:n;}function za(r,e){var t,n,s=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===s&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].tight=!0,r.tokens[t].tight=!0,t+=2);}function Va(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v,E,C,j,X,Z,ve,St=!0,xt,Be,pr,ci;if((p=Rr(r,e))>=0)E=!0;else if((p=Tr(r,e))>=0)E=!1;else return!1;if(r.level>=r.options.maxNesting)return!1;if(v=r.src.charCodeAt(p-1),n)return!0;for(j=r.tokens.length,E?(d=r.bMarks[e]+r.tShift[e],b=Number(r.src.substr(d,p-d-1)),r.tokens.push({type:"ordered_list_open",order:b,lines:Z=[e,0],level:r.level++})):r.tokens.push({type:"bullet_list_open",lines:Z=[e,0],level:r.level++}),s=e,X=!1,xt=r.parser.ruler.getRules("list");s<t&&(C=r.skipSpaces(p),u=r.eMarks[s],C>=u?g=1:g=C-p,g>4&&(g=1),g<1&&(g=1),i=p-r.bMarks[s]+g,r.tokens.push({type:"list_item_open",lines:ve=[e,0],level:r.level++}),a=r.blkIndent,l=r.tight,o=r.tShift[e],c=r.parentType,r.tShift[e]=C-r.bMarks[e],r.blkIndent=i,r.tight=!0,r.parentType="list",r.parser.tokenize(r,e,t,!0),(!r.tight||X)&&(St=!1),X=r.line-e>1&&r.isEmpty(r.line-1),r.blkIndent=a,r.tShift[e]=o,r.tight=l,r.parentType=c,r.tokens.push({type:"list_item_close",level:--r.level}),s=e=r.line,ve[1]=s,C=r.bMarks[e],!(s>=t||r.isEmpty(s)||r.tShift[s]<r.blkIndent));){for(ci=!1,Be=0,pr=xt.length;Be<pr;Be++)if(xt[Be](r,s,t,!0)){ci=!0;break;}if(ci)break;if(E){if(p=Rr(r,s),p<0)break;}else if(p=Tr(r,s),p<0)break;if(v!==r.src.charCodeAt(p-1))break;}return r.tokens.push({type:E?"ordered_list_close":"bullet_list_close",level:--r.level}),Z[1]=s,r.line=s,St&&za(r,j),!0;}function Ja(r,e,t,n){var s,i,o,a,l,c=r.bMarks[e]+r.tShift[e],d=r.eMarks[e];if(c+4>d||r.src.charCodeAt(c)!==91||r.src.charCodeAt(c+1)!==94||r.level>=r.options.maxNesting)return!1;for(a=c+2;a<d;a++){if(r.src.charCodeAt(a)===32)return!1;if(r.src.charCodeAt(a)===93)break;}return a===c+2||a+1>=d||r.src.charCodeAt(++a)!==58?!1:(n||(a++,r.env.footnotes||(r.env.footnotes={}),r.env.footnotes.refs||(r.env.footnotes.refs={}),l=r.src.slice(c+2,a-2),r.env.footnotes.refs[":"+l]=-1,r.tokens.push({type:"footnote_reference_open",label:l,level:r.level++}),s=r.bMarks[e],i=r.tShift[e],o=r.parentType,r.tShift[e]=r.skipSpaces(a)-a,r.bMarks[e]=a,r.blkIndent+=4,r.parentType="footnote",r.tShift[e]<r.blkIndent&&(r.tShift[e]+=r.blkIndent,r.bMarks[e]-=r.blkIndent),r.parser.tokenize(r,e,t,!0),r.parentType=o,r.blkIndent-=4,r.tShift[e]=i,r.bMarks[e]=s,r.tokens.push({type:"footnote_reference_close",level:--r.level})),!0);}function Wa(r,e,t,n){var s,i,o,a=r.bMarks[e]+r.tShift[e],l=r.eMarks[e];if(a>=l||(s=r.src.charCodeAt(a),s!==35||a>=l))return!1;for(i=1,s=r.src.charCodeAt(++a);s===35&&a<l&&i<=6;)i++,s=r.src.charCodeAt(++a);return i>6||a<l&&s!==32?!1:(n||(l=r.skipCharsBack(l,32,a),o=r.skipCharsBack(l,35,a),o>a&&r.src.charCodeAt(o-1)===32&&(l=o),r.line=e+1,r.tokens.push({type:"heading_open",hLevel:i,lines:[e,r.line],level:r.level}),a<l&&r.tokens.push({type:"inline",content:r.src.slice(a,l).trim(),level:r.level+1,lines:[e,r.line],children:[]}),r.tokens.push({type:"heading_close",hLevel:i,level:r.level})),!0);}function Ka(r,e,t){var n,s,i,o=e+1;return o>=t||r.tShift[o]<r.blkIndent||r.tShift[o]-r.blkIndent>3||(s=r.bMarks[o]+r.tShift[o],i=r.eMarks[o],s>=i)||(n=r.src.charCodeAt(s),n!==45&&n!==61)||(s=r.skipChars(s,n),s=r.skipSpaces(s),s<i)?!1:(s=r.bMarks[e]+r.tShift[e],r.line=o+1,r.tokens.push({type:"heading_open",hLevel:n===61?1:2,lines:[e,r.line],level:r.level}),r.tokens.push({type:"inline",content:r.src.slice(s,r.eMarks[e]).trim(),level:r.level+1,lines:[e,r.line-1],children:[]}),r.tokens.push({type:"heading_close",hLevel:n===61?1:2,level:r.level}),!0);}var Io={};["article","aside","button","blockquote","body","canvas","caption","col","colgroup","dd","div","dl","dt","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","iframe","li","map","object","ol","output","p","pre","progress","script","section","style","table","tbody","td","textarea","tfoot","th","tr","thead","ul","video"].forEach(function(r){Io[r]=!0;});var Xa=/^<([a-zA-Z]{1,15})[\s\/>]/,Za=/^<\/([a-zA-Z]{1,15})[\s>]/;function Ya(r){var e=r|32;return e>=97&&e<=122;}function Qa(r,e,t,n){var s,i,o,a=r.bMarks[e],l=r.eMarks[e],c=r.tShift[e];if(a+=c,!r.options.html||c>3||a+2>=l||r.src.charCodeAt(a)!==60)return!1;if(s=r.src.charCodeAt(a+1),s===33||s===63){if(n)return!0;}else if(s===47||Ya(s)){if(s===47){if(i=r.src.slice(a,l).match(Za),!i)return!1;}else if(i=r.src.slice(a,l).match(Xa),!i)return!1;if(Io[i[1].toLowerCase()]!==!0)return!1;if(n)return!0;}else return!1;for(o=e+1;o<r.lineMax&&!r.isEmpty(o);)o++;return r.line=o,r.tokens.push({type:"htmlblock",level:r.level,lines:[e,r.line],content:r.getLines(e,o,0,!0)}),!0;}function fi(r,e){var t=r.bMarks[e]+r.blkIndent,n=r.eMarks[e];return r.src.substr(t,n-t);}function el(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b;if(e+2>t||(l=e+1,r.tShift[l]<r.blkIndent)||(o=r.bMarks[l]+r.tShift[l],o>=r.eMarks[l])||(s=r.src.charCodeAt(o),s!==124&&s!==45&&s!==58)||(i=fi(r,e+1),!/^[-:| ]+$/.test(i))||(c=i.split("|"),c<=2))return!1;for(p=[],a=0;a<c.length;a++){if(u=c[a].trim(),!u){if(a===0||a===c.length-1)continue;return!1;}if(!/^:?-+:?$/.test(u))return!1;u.charCodeAt(u.length-1)===58?p.push(u.charCodeAt(0)===58?"center":"right"):u.charCodeAt(0)===58?p.push("left"):p.push("");}if(i=fi(r,e).trim(),i.indexOf("|")===-1||(c=i.replace(/^\||\|$/g,"").split("|"),p.length!==c.length))return!1;if(n)return!0;for(r.tokens.push({type:"table_open",lines:g=[e,0],level:r.level++}),r.tokens.push({type:"thead_open",lines:[e,e+1],level:r.level++}),r.tokens.push({type:"tr_open",lines:[e,e+1],level:r.level++}),a=0;a<c.length;a++)r.tokens.push({type:"th_open",align:p[a],lines:[e,e+1],level:r.level++}),r.tokens.push({type:"inline",content:c[a].trim(),lines:[e,e+1],level:r.level,children:[]}),r.tokens.push({type:"th_close",level:--r.level});for(r.tokens.push({type:"tr_close",level:--r.level}),r.tokens.push({type:"thead_close",level:--r.level}),r.tokens.push({type:"tbody_open",lines:b=[e+2,0],level:r.level++}),l=e+2;l<t&&!(r.tShift[l]<r.blkIndent||(i=fi(r,l).trim(),i.indexOf("|")===-1));l++){for(c=i.replace(/^\||\|$/g,"").split("|"),r.tokens.push({type:"tr_open",level:r.level++}),a=0;a<c.length;a++)r.tokens.push({type:"td_open",align:p[a],level:r.level++}),d=c[a].substring(c[a].charCodeAt(0)===124?1:0,c[a].charCodeAt(c[a].length-1)===124?c[a].length-1:c[a].length).trim(),r.tokens.push({type:"inline",content:d,level:r.level,children:[]}),r.tokens.push({type:"td_close",level:--r.level});r.tokens.push({type:"tr_close",level:--r.level});}return r.tokens.push({type:"tbody_close",level:--r.level}),r.tokens.push({type:"table_close",level:--r.level}),g[1]=b[1]=l,r.line=l,!0;}function _s(r,e){var t,n,s=r.bMarks[e]+r.tShift[e],i=r.eMarks[e];return s>=i||(n=r.src.charCodeAt(s++),n!==126&&n!==58)||(t=r.skipSpaces(s),s===t)||t>=i?-1:t;}function tl(r,e){var t,n,s=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===s&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].tight=!0,r.tokens[t].tight=!0,t+=2);}function nl(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v,E,C;if(n)return r.ddIndent<0?!1:_s(r,e)>=0;if(d=e+1,r.isEmpty(d)&&++d>t||r.tShift[d]<r.blkIndent||(s=_s(r,d),s<0)||r.level>=r.options.maxNesting)return!1;c=r.tokens.length,r.tokens.push({type:"dl_open",lines:l=[e,0],level:r.level++}),o=e,i=d;e:for(;;){for(C=!0,E=!1,r.tokens.push({type:"dt_open",lines:[o,o],level:r.level++}),r.tokens.push({type:"inline",content:r.getLines(o,o+1,r.blkIndent,!1).trim(),level:r.level+1,lines:[o,o],children:[]}),r.tokens.push({type:"dt_close",level:--r.level});;){if(r.tokens.push({type:"dd_open",lines:a=[d,0],level:r.level++}),v=r.tight,u=r.ddIndent,p=r.blkIndent,b=r.tShift[i],g=r.parentType,r.blkIndent=r.ddIndent=r.tShift[i]+2,r.tShift[i]=s-r.bMarks[i],r.tight=!0,r.parentType="deflist",r.parser.tokenize(r,i,t,!0),(!r.tight||E)&&(C=!1),E=r.line-i>1&&r.isEmpty(r.line-1),r.tShift[i]=b,r.tight=v,r.parentType=g,r.blkIndent=p,r.ddIndent=u,r.tokens.push({type:"dd_close",level:--r.level}),a[1]=d=r.line,d>=t||r.tShift[d]<r.blkIndent)break e;if(s=_s(r,d),s<0)break;i=d;}if(d>=t||(o=d,r.isEmpty(o))||r.tShift[o]<r.blkIndent||(i=o+1,i>=t)||(r.isEmpty(i)&&i++,i>=t)||r.tShift[i]<r.blkIndent||(s=_s(r,i),s<0))break;}return r.tokens.push({type:"dl_close",level:--r.level}),l[1]=d,r.line=d,C&&tl(r,c),!0;}function sl(r,e){var t,n,s,i,o,a=e+1,l;if(t=r.lineMax,a<t&&!r.isEmpty(a)){for(l=r.parser.ruler.getRules("paragraph");a<t&&!r.isEmpty(a);a++)if(!(r.tShift[a]-r.blkIndent>3)){for(s=!1,i=0,o=l.length;i<o;i++)if(l[i](r,a,t,!0)){s=!0;break;}if(s)break;}}return n=r.getLines(e,a,r.blkIndent,!1).trim(),r.line=a,n.length&&(r.tokens.push({type:"paragraph_open",tight:!1,lines:[e,r.line],level:r.level}),r.tokens.push({type:"inline",content:n,level:r.level+1,lines:[e,r.line],children:[]}),r.tokens.push({type:"paragraph_close",tight:!1,level:r.level})),!0;}var Es=[["code",ja],["fences",qa,["paragraph","blockquote","list"]],["blockquote",$a,["paragraph","blockquote","list"]],["hr",Ga,["paragraph","blockquote","list"]],["list",Va,["paragraph","blockquote"]],["footnote",Ja,["paragraph"]],["heading",Wa,["paragraph","blockquote"]],["lheading",Ka],["htmlblock",Qa,["paragraph","blockquote"]],["table",el,["paragraph"]],["deflist",nl,["paragraph"]],["paragraph",sl]];function Gi(){this.ruler=new je();for(var r=0;r<Es.length;r++)this.ruler.push(Es[r][0],Es[r][1],{alt:(Es[r][2]||[]).slice()});}Gi.prototype.tokenize=function(r,e,t){for(var n=this.ruler.getRules(""),s=n.length,i=e,o=!1,a,l;i<t&&(r.line=i=r.skipEmptyLines(i),!(i>=t||r.tShift[i]<r.blkIndent));){for(l=0;l<s&&(a=n[l](r,i,t,!1),!a);l++);if(r.tight=!o,r.isEmpty(r.line-1)&&(o=!0),i=r.line,i<t&&r.isEmpty(i)){if(o=!0,i++,i<t&&r.parentType==="list"&&r.isEmpty(i))break;r.line=i;}}};var il=/[\n\t]/g,rl=/\r[\n\u0085]|[\u2424\u2028\u0085]/g,ol=/\u00a0/g;Gi.prototype.parse=function(r,e,t,n){var s,i=0,o=0;if(!r)return[];r=r.replace(ol," "),r=r.replace(rl,"\n"),r.indexOf(" ")>=0&&(r=r.replace(il,function(a,l){var c;return r.charCodeAt(l)===10?(i=l+1,o=0,a):(c=" ".slice((l-i-o)%4),o=l-i+1,c);})),s=new en(r,this,e,t,n),this.tokenize(s,s.line,s.lineMax);};function al(r){switch(r){case 10:case 92:case 96:case 42:case 95:case 94:case 91:case 93:case 33:case 38:case 60:case 62:case 123:case 125:case 36:case 37:case 64:case 126:case 43:case 61:case 58:return!0;default:return!1;}}function ll(r,e){for(var t=r.pos;t<r.posMax&&!al(r.src.charCodeAt(t));)t++;return t===r.pos?!1:(e||(r.pending+=r.src.slice(r.pos,t)),r.pos=t,!0);}function cl(r,e){var t,n,s=r.pos;if(r.src.charCodeAt(s)!==10)return!1;if(t=r.pending.length-1,n=r.posMax,!e)if(t>=0&&r.pending.charCodeAt(t)===32){if(t>=1&&r.pending.charCodeAt(t-1)===32){for(var i=t-2;i>=0;i--)if(r.pending.charCodeAt(i)!==32){r.pending=r.pending.substring(0,i+1);break;}r.push({type:"hardbreak",level:r.level});}else r.pending=r.pending.slice(0,-1),r.push({type:"softbreak",level:r.level});}else r.push({type:"softbreak",level:r.level});for(s++;s<n&&r.src.charCodeAt(s)===32;)s++;return r.pos=s,!0;}var zi=[];for(var Ir=0;Ir<256;Ir++)zi.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){zi[r.charCodeAt(0)]=1;});function dl(r,e){var t,n=r.pos,s=r.posMax;if(r.src.charCodeAt(n)!==92)return!1;if(n++,n<s){if(t=r.src.charCodeAt(n),t<256&&zi[t]!==0)return e||(r.pending+=r.src[n]),r.pos+=2,!0;if(t===10){for(e||r.push({type:"hardbreak",level:r.level}),n++;n<s&&r.src.charCodeAt(n)===32;)n++;return r.pos=n,!0;}}return e||(r.pending+="\\"),r.pos++,!0;}function hl(r,e){var t,n,s,i,o,a=r.pos,l=r.src.charCodeAt(a);if(l!==96)return!1;for(t=a,a++,n=r.posMax;a<n&&r.src.charCodeAt(a)===96;)a++;for(s=r.src.slice(t,a),i=o=a;(i=r.src.indexOf("`",o))!==-1;){for(o=i+1;o<n&&r.src.charCodeAt(o)===96;)o++;if(o-i===s.length)return e||r.push({type:"code",content:r.src.slice(a,i).replace(/[ \n]+/g," ").trim(),block:!1,level:r.level}),r.pos=o,!0;}return e||(r.pending+=s),r.pos+=s.length,!0;}function ul(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==126||e||o+4>=i||r.src.charCodeAt(o+1)!==126||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===126)||l===126||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===126;)n++;if(n>o+3)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===126&&r.src.charCodeAt(r.pos+1)===126&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==126&&a!==126&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"del_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"del_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function pl(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==43||e||o+4>=i||r.src.charCodeAt(o+1)!==43||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===43)||l===43||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===43;)n++;if(n!==o+2)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===43&&r.src.charCodeAt(r.pos+1)===43&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==43&&a!==43&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"ins_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"ins_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function fl(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==61||e||o+4>=i||r.src.charCodeAt(o+1)!==61||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===61)||l===61||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===61;)n++;if(n!==o+2)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===61&&r.src.charCodeAt(r.pos+1)===61&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==61&&a!==61&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"mark_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"mark_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function Mr(r){return r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122;}function kr(r,e){var t=e,n,s,i,o=!0,a=!0,l=r.posMax,c=r.src.charCodeAt(e);for(n=e>0?r.src.charCodeAt(e-1):-1;t<l&&r.src.charCodeAt(t)===c;)t++;return t>=l&&(o=!1),i=t-e,i>=4?o=a=!1:(s=t<l?r.src.charCodeAt(t):-1,(s===32||s===10)&&(o=!1),(n===32||n===10)&&(a=!1),c===95&&(Mr(n)&&(o=!1),Mr(s)&&(a=!1))),{can_open:o,can_close:a,delims:i};}function ml(r,e){var t,n,s,i,o,a,l,c=r.posMax,d=r.pos,p=r.src.charCodeAt(d);if(p!==95&&p!==42||e)return!1;if(l=kr(r,d),t=l.delims,!l.can_open)return r.pos+=t,e||(r.pending+=r.src.slice(d,r.pos)),!0;if(r.level>=r.options.maxNesting)return!1;for(r.pos=d+t,a=[t];r.pos<c;){if(r.src.charCodeAt(r.pos)===p){if(l=kr(r,r.pos),n=l.delims,l.can_close){for(i=a.pop(),o=n;i!==o;){if(o<i){a.push(i-o);break;}if(o-=i,a.length===0)break;r.pos+=i,i=a.pop();}if(a.length===0){t=i,s=!0;break;}r.pos+=n;continue;}l.can_open&&a.push(n),r.pos+=n;continue;}r.parser.skipToken(r);}return s?(r.posMax=r.pos,r.pos=d+t,e||((t===2||t===3)&&r.push({type:"strong_open",level:r.level++}),(t===1||t===3)&&r.push({type:"em_open",level:r.level++}),r.parser.tokenize(r),(t===1||t===3)&&r.push({type:"em_close",level:--r.level}),(t===2||t===3)&&r.push({type:"strong_close",level:--r.level})),r.pos=r.posMax+t,r.posMax=c,!0):(r.pos=d,!1);}var gl=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function yl(r,e){var t,n,s=r.posMax,i=r.pos;if(r.src.charCodeAt(i)!==126||e||i+2>=s||r.level>=r.options.maxNesting)return!1;for(r.pos=i+1;r.pos<s;){if(r.src.charCodeAt(r.pos)===126){t=!0;break;}r.parser.skipToken(r);}return!t||i+1===r.pos||(n=r.src.slice(i+1,r.pos),n.match(/(^|[^\\])(\\\\)*\s/))?(r.pos=i,!1):(r.posMax=r.pos,r.pos=i+1,e||r.push({type:"sub",level:r.level,content:n.replace(gl,"$1")}),r.pos=r.posMax+1,r.posMax=s,!0);}var bl=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function vl(r,e){var t,n,s=r.posMax,i=r.pos;if(r.src.charCodeAt(i)!==94||e||i+2>=s||r.level>=r.options.maxNesting)return!1;for(r.pos=i+1;r.pos<s;){if(r.src.charCodeAt(r.pos)===94){t=!0;break;}r.parser.skipToken(r);}return!t||i+1===r.pos||(n=r.src.slice(i+1,r.pos),n.match(/(^|[^\\])(\\\\)*\s/))?(r.pos=i,!1):(r.posMax=r.pos,r.pos=i+1,e||r.push({type:"sup",level:r.level,content:n.replace(bl,"$1")}),r.pos=r.posMax+1,r.posMax=s,!0);}function _l(r,e){var t,n,s,i,o,a,l,c,d=!1,p=r.pos,u=r.posMax,g=r.pos,b=r.src.charCodeAt(g);if(b===33&&(d=!0,b=r.src.charCodeAt(++g)),b!==91||r.level>=r.options.maxNesting||(t=g+1,n=as(r,g),n<0))return!1;if(a=n+1,a<u&&r.src.charCodeAt(a)===40){for(a++;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a>=u)return!1;for(g=a,wo(r,a)?(i=r.linkContent,a=r.pos):i="",g=a;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a<u&&g!==a&&Co(r,a))for(o=r.linkContent,a=r.pos;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);else o="";if(a>=u||r.src.charCodeAt(a)!==41)return r.pos=p,!1;a++;}else{if(r.linkLevel>0)return!1;for(;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a<u&&r.src.charCodeAt(a)===91&&(g=a+1,a=as(r,a),a>=0?s=r.src.slice(g,a++):a=g-1),s||(_typeof(s)>"u"&&(a=n+1),s=r.src.slice(t,n)),l=r.env.references[To(s)],!l)return r.pos=p,!1;i=l.href,o=l.title;}return e||(r.pos=t,r.posMax=n,d?r.push({type:"image",src:i,title:o,alt:r.src.substr(t,n-t),level:r.level}):(r.push({type:"link_open",href:i,title:o,level:r.level++}),r.linkLevel++,r.parser.tokenize(r),r.linkLevel--,r.push({type:"link_close",level:--r.level}))),r.pos=a,r.posMax=u,!0;}function El(r,e){var t,n,s,i,o=r.posMax,a=r.pos;return a+2>=o||r.src.charCodeAt(a)!==94||r.src.charCodeAt(a+1)!==91||r.level>=r.options.maxNesting||(t=a+2,n=as(r,a+1),n<0)?!1:(e||(r.env.footnotes||(r.env.footnotes={}),r.env.footnotes.list||(r.env.footnotes.list=[]),s=r.env.footnotes.list.length,r.pos=t,r.posMax=n,r.push({type:"footnote_ref",id:s,level:r.level}),r.linkLevel++,i=r.tokens.length,r.parser.tokenize(r),r.env.footnotes.list[s]={tokens:r.tokens.splice(i)},r.linkLevel--),r.pos=n+1,r.posMax=o,!0);}function Sl(r,e){var t,n,s,i,o=r.posMax,a=r.pos;if(a+3>o||!r.env.footnotes||!r.env.footnotes.refs||r.src.charCodeAt(a)!==91||r.src.charCodeAt(a+1)!==94||r.level>=r.options.maxNesting)return!1;for(n=a+2;n<o;n++){if(r.src.charCodeAt(n)===32||r.src.charCodeAt(n)===10)return!1;if(r.src.charCodeAt(n)===93)break;}return n===a+2||n>=o||(n++,t=r.src.slice(a+2,n-1),_typeof(r.env.footnotes.refs[":"+t])>"u")?!1:(e||(r.env.footnotes.list||(r.env.footnotes.list=[]),r.env.footnotes.refs[":"+t]<0?(s=r.env.footnotes.list.length,r.env.footnotes.list[s]={label:t,count:0},r.env.footnotes.refs[":"+t]=s):s=r.env.footnotes.refs[":"+t],i=r.env.footnotes.list[s].count,r.env.footnotes.list[s].count++,r.push({type:"footnote_ref",id:s,subId:i,level:r.level})),r.pos=n,r.posMax=o,!0);}var xl=["coap","doi","javascript","aaa","aaas","about","acap","cap","cid","crid","data","dav","dict","dns","file","ftp","geo","go","gopher","h323","http","https","iax","icap","im","imap","info","ipp","iris","iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid","msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp","opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve","sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet","tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon","xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s","adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin","bolo","callto","chrome","chrome-extension","com-eventbrite-attendee","content","cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb","ed2k","facetime","feed","finger","fish","gg","git","gizmoproject","gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms","keyparc","lastfm","ldaps","magnet","maps","market","message","mms","ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi","platform","proxy","psyc","query","res","resource","rmi","rsync","rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify","ssh","steam","svn","teamspeak","things","udp","unreal","ut2004","ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri","ymsgr"],Al=/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/,wl=/^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;function Cl(r,e){var t,n,s,i,o,a=r.pos;return r.src.charCodeAt(a)!==60||(t=r.src.slice(a),t.indexOf(">")<0)?!1:(n=t.match(wl),n?xl.indexOf(n[1].toLowerCase())<0||(i=n[0].slice(1,-1),o=_i(i),!r.parser.validateLink(i))?!1:(e||(r.push({type:"link_open",href:o,level:r.level}),r.push({type:"text",content:i,level:r.level+1}),r.push({type:"link_close",level:r.level})),r.pos+=n[0].length,!0):(s=t.match(Al),s?(i=s[0].slice(1,-1),o=_i("mailto:"+i),r.parser.validateLink(o)?(e||(r.push({type:"link_open",href:o,level:r.level}),r.push({type:"text",content:i,level:r.level+1}),r.push({type:"link_close",level:r.level})),r.pos+=s[0].length,!0):!1):!1));}function ei(r,e){return r=r.source,e=e||"",function t(n,s){return n?(s=s.source||s,r=r.replace(n,s),t):new RegExp(r,e);};}var Tl=/[a-zA-Z_:][a-zA-Z0-9:._-]*/,Rl=/[^"'=<>`\x00-\x20]+/,Il=/'[^']*'/,Ml=/"[^"]*"/,kl=ei(/(?:unquoted|single_quoted|double_quoted)/)("unquoted",Rl)("single_quoted",Il)("double_quoted",Ml)(),Ol=ei(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)("attr_name",Tl)("attr_value",kl)(),Nl=ei(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)("attribute",Ol)(),Pl=/<\/[A-Za-z][A-Za-z0-9]*\s*>/,Ll=/<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->/,Bl=/<[?].*?[?]>/,Dl=/<![A-Z]+\s+[^>]*>/,Fl=/<!\[CDATA\[[\s\S]*?\]\]>/,Ul=ei(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)("open_tag",Nl)("close_tag",Pl)("comment",Ll)("processing",Bl)("declaration",Dl)("cdata",Fl)();function Hl(r){var e=r|32;return e>=97&&e<=122;}function jl(r,e){var t,n,s,i=r.pos;return!r.options.html||(s=r.posMax,r.src.charCodeAt(i)!==60||i+2>=s)||(t=r.src.charCodeAt(i+1),t!==33&&t!==63&&t!==47&&!Hl(t))||(n=r.src.slice(i).match(Ul),!n)?!1:(e||r.push({type:"htmltag",content:r.src.slice(i,i+n[0].length),level:r.level}),r.pos+=n[0].length,!0);}var ql=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,$l=/^&([a-z][a-z0-9]{1,31});/i;function Gl(r,e){var t,n,s,i=r.pos,o=r.posMax;if(r.src.charCodeAt(i)!==38)return!1;if(i+1<o){if(t=r.src.charCodeAt(i+1),t===35){if(s=r.src.slice(i).match(ql),s)return e||(n=s[1][0].toLowerCase()==="x"?parseInt(s[1].slice(1),16):parseInt(s[1],10),r.pending+=xo(n)?vi(n):vi(65533)),r.pos+=s[0].length,!0;}else if(s=r.src.slice(i).match($l),s){var a=Eo(s[1]);if(s[1]!==a)return e||(r.pending+=a),r.pos+=s[0].length,!0;}}return e||(r.pending+="&"),r.pos++,!0;}var mi=[["text",ll],["newline",cl],["escape",dl],["backticks",hl],["del",ul],["ins",pl],["mark",fl],["emphasis",ml],["sub",yl],["sup",vl],["links",_l],["footnote_inline",El],["footnote_ref",Sl],["autolink",Cl],["htmltag",jl],["entity",Gl]];function ti(){this.ruler=new je();for(var r=0;r<mi.length;r++)this.ruler.push(mi[r][0],mi[r][1]);this.validateLink=zl;}ti.prototype.skipToken=function(r){var e=this.ruler.getRules(""),t=e.length,n=r.pos,s,i;if((i=r.cacheGet(n))>0){r.pos=i;return;}for(s=0;s<t;s++)if(e[s](r,!0)){r.cacheSet(n,r.pos);return;}r.pos++,r.cacheSet(n,r.pos);};ti.prototype.tokenize=function(r){for(var e=this.ruler.getRules(""),t=e.length,n=r.posMax,s,i;r.pos<n;){for(i=0;i<t&&(s=e[i](r,!1),!s);i++);if(s){if(r.pos>=n)break;continue;}r.pending+=r.src[r.pos++];}r.pending&&r.pushPending();};ti.prototype.parse=function(r,e,t,n){var s=new Qt(r,this,e,t,n);this.tokenize(s);};function zl(r){var e=["vbscript","javascript","file","data"],t=r.trim().toLowerCase();return t=Kt(t),!(t.indexOf(":")!==-1&&e.indexOf(t.split(":")[0])!==-1);}var Vl={options:{html:!1,// Enable HTML tags in source
17
+ },{key:"replaceElementWithNewClone",value:function replaceElementWithNewClone(e,t){var s;var n=(t||e).cloneNode(!0);return(s=e.parentNode)==null||s.replaceChild(n,e),n;}},{key:"tryAddWrapper",value:function tryAddWrapper(e,t,n,s){if(t&&s){var i=(n==null?void 0:n[s])||(n==null?void 0:n[x]);if(i)return e.innerHTML=i,{contentEl:Y.getTargetWrapper(e),wrapper:!0};}return{contentEl:e,wrapper:!1};}},{key:"getTargetWrapper",value:function getTargetWrapper(e){return e.getElementsByClassName(Zo)[0]||e;}}]);}();var Ct=/*#__PURE__*/function(){function Ct(){_classCallCheck(this,Ct);}return _createClass(Ct,null,[{key:"createElements",value:function createElements(e,t,n,s){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;var o=e.createMessageElementsOnOrientation("",n,s,i);o.bubbleElement[m].add(Ct.HTML_BUBBLE_CLASS);var _Y$tryAddWrapper=Y.tryAddWrapper(o.bubbleElement,t,e._customWrappers,n),a=_Y$tryAddWrapper.contentEl;return a.innerHTML=t,o;}},{key:"overwriteElements",value:function overwriteElements(e,t,n){n.bubbleElement.innerHTML=t,Y.apply(e,n.outerContainer),ne.flagHTMLUpdateClass(n.bubbleElement);}// prettier-ignore
18
+ },{key:"overwrite",value:function overwrite(e,t,n,s){var i=e.messageToElements,o=N.overwriteMessage(i,s,t,n,M,Ct.HTML_BUBBLE_CLASS);return o&&Ct.overwriteElements(e,t,o),o;}},{key:"create",value:function create(e,t,n){var s=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var o;var i=Ct.createElements(e,t,n,s);return N.fillEmptyMessageElement(i.bubbleElement,t),Y.apply(e,i.outerContainer),ne.flagHTMLUpdateClass(i.bubbleElement),e.applyCustomStyles(i,n,!1,(o=e.messageStyles)==null?void 0:o[M]),i;}},{key:"add",value:function add(e,t,n,s){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;if(s!=null&&s.status){var a=this.overwrite(e,t,n,e.messageElementRefs);if(a)return a;s.status=!1;}if(i&&e.messageElementRefs.length>0&&Y.isTemporaryBasedOnHTML(t))return;var o=Ct.create(e,t,n,i);return i||e.appendOuterContainerElemet(o.outerContainer),o;}}]);}();Ct.HTML_BUBBLE_CLASS="html-message";var lt=Ct;var fa=/*#__PURE__*/function(){function fa(){_classCallCheck(this,fa);}return _createClass(fa,null,[{key:"katex",value:function katex(e,t,n){var a=(n||{}).delimiter||"$";if(a.length!==1)throw new Error("invalid delimiter");var l=function l(p,u){var g;return((g=window.katex)==null?void 0:g.renderToString(p,_objectSpread({displayMode:u,throwOnError:!1,output:"mathml"},e)))||"";},c=function c(p,u,g){var b=!1,v=p.bMarks[u]+p.tShift[u],E=p.eMarks[u];if(v+1>E)return!1;var w=p[A].charAt(v);if(w!==a)return!1;var j=v;v=p.skipChars(v,w);var X=v-j;if(X!==2)return!1;var Z=u;for(;++Z,!(Z>=g||(v=j=p.bMarks[Z]+p.tShift[Z],E=p.eMarks[Z],v<E&&p.tShift[Z]<p.blkIndent));)if(p[A].charAt(v)===a&&!(p.tShift[Z]-p.blkIndent>=4)&&(v=p.skipChars(v,w),!(v-j<X)&&(v=p.skipSpaces(v),!(v<E)))){b=!0;break;}X=p.tShift[u],p.line=Z+(b?1:0);var ve=p.getLines(u+1,Z,X,!0).replace(/[ \n]+/g," ").trim();return p.tokens.push({type:"katex",params:null,content:ve,lines:[u,p.line],level:p.level,block:!0}),!0;},d=function d(p,u){var g=p.pos,b=p.posMax;var v=g;if(p[A].charAt(v)!==a)return!1;for(++v;v<b&&p[A].charAt(v)===a;)++v;var E=p[A].slice(g,v);if(E.length>2)return!1;var w=v;var j=0;for(;v<b;){var X=p[A].charAt(v);if(X==="{"&&(v===0||p[A].charAt(v-1)!=="\\"))j+=1;else if(X==="}"&&(v===0||p[A].charAt(v-1)!=="\\")){if(j-=1,j<0)return!1;}else if(X===a&&j===0){var Z=v;var ve=v+1;for(;ve<b&&p[A].charAt(ve)===a;)++ve;if(ve-Z===E.length){if(!u){var St=p[A].slice(w,Z).replace(/[ \n]+/g," ").trim();p.push({type:"katex",content:St,block:E.length>1,level:p.level});}return p.pos=ve,!0;}}v+=1;}return u||(p.pending+=E),p.pos+=E.length,!0;};t.inline.ruler.push("katex",d,n),t.block.ruler.push("katex",c,n),t.renderer.rules.katex=function(p,u){return l(p[u].content,p[u].block);},t.renderer.rules.katex.delimiter=a;}}]);}();var vs;function Eo(r){return vs=vs||document.createElement("textarea"),vs.innerHTML="&"+r+";",vs.value;}var ma=Object.prototype.hasOwnProperty;function ga(r,e){return r?ma.call(r,e):!1;}function So(r){var e=[].slice.call(arguments,1);return e.forEach(function(t){if(t){if(_typeof(t)!="object")throw new TypeError(t+"must be object");Object.keys(t).forEach(function(n){r[n]=t[n];});}}),r;}var ya=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function os(r){return r.indexOf("\\")<0?r:r.replace(ya,"$1");}function xo(r){return!(r>=55296&&r<=57343||r>=64976&&r<=65007||(r&65535)===65535||(r&65535)===65534||r>=0&&r<=8||r===11||r>=14&&r<=31||r>=127&&r<=159||r>1114111);}function vi(r){if(r>65535){r-=65536;var e=55296+(r>>10),t=56320+(r&1023);return String.fromCharCode(e,t);}return String.fromCharCode(r);}var ba=/&([a-z#][a-z0-9]{1,31});/gi,va=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;function _a(r,e){var t=0,n=Eo(e);return e!==n?n:e.charCodeAt(0)===35&&va.test(e)&&(t=e[1].toLowerCase()==="x"?parseInt(e.slice(2),16):parseInt(e.slice(1),10),xo(t))?vi(t):r;}function Kt(r){return r.indexOf("&")<0?r:r.replace(ba,_a);}var Ea=/[&<>"]/,Sa=/[&<>"]/g,xa={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function Aa(r){return xa[r];}function Pe(r){return Ea.test(r)?r.replace(Sa,Aa):r;}var C={};C.blockquote_open=function(){return"<blockquote>\n";};C.blockquote_close=function(r,e){return"</blockquote>"+Yt(r,e);};C.code=function(r,e){return r[e].block?"<pre><code>"+Pe(r[e].content)+"</code></pre>"+Yt(r,e):"<code>"+Pe(r[e].content)+"</code>";};C.fence=function(r,e,t,n,s){var i=r[e],o="",a=t.langPrefix,l="",c,d,p;if(i.params){if(c=i.params.split(/\s+/g),d=c.join(" "),ga(s.rules.fence_custom,c[0]))return s.rules.fence_custom[c[0]](r,e,t,n,s);l=Pe(Kt(os(d))),o=' class="'+a+l+'"';}return t.highlight?p=t.highlight.apply(t.highlight,[i.content].concat(c))||Pe(i.content):p=Pe(i.content),"<pre><code"+o+">"+p+"</code></pre>"+Yt(r,e);};C.fence_custom={};C.heading_open=function(r,e){return"<h"+r[e].hLevel+">";};C.heading_close=function(r,e){return"</h"+r[e].hLevel+">\n";};C.hr=function(r,e,t){return(t.xhtmlOut?"<hr />":"<hr>")+Yt(r,e);};C.bullet_list_open=function(){return"<ul>\n";};C.bullet_list_close=function(r,e){return"</ul>"+Yt(r,e);};C.list_item_open=function(){return"<li>";};C.list_item_close=function(){return"</li>\n";};C.ordered_list_open=function(r,e){var t=r[e],n=t.order>1?' start="'+t.order+'"':"";return"<ol"+n+">\n";};C.ordered_list_close=function(r,e){return"</ol>"+Yt(r,e);};C.paragraph_open=function(r,e){return r[e].tight?"":"<p>";};C.paragraph_close=function(r,e){var t=!(r[e].tight&&e&&r[e-1].type==="inline"&&!r[e-1].content);return(r[e].tight?"":"</p>")+(t?Yt(r,e):"");};C.link_open=function(r,e,t){var n=r[e].title?' title="'+Pe(Kt(r[e].title))+'"':"",s=t.linkTarget?' target="'+t.linkTarget+'"':"";return'<a href="'+Pe(r[e].href)+'"'+n+s+">";};C.link_close=function(){return"</a>";};C.image=function(r,e,t){var n=' src="'+Pe(r[e].src)+'"',s=r[e].title?' title="'+Pe(Kt(r[e].title))+'"':"",i=' alt="'+(r[e].alt?Pe(Kt(os(r[e].alt))):"")+'"',o=t.xhtmlOut?" /":"";return"<img"+n+i+s+o+">";};C.table_open=function(){return"<table>\n";};C.table_close=function(){return"</table>\n";};C.thead_open=function(){return"<thead>\n";};C.thead_close=function(){return"</thead>\n";};C.tbody_open=function(){return"<tbody>\n";};C.tbody_close=function(){return"</tbody>\n";};C.tr_open=function(){return"<tr>";};C.tr_close=function(){return"</tr>\n";};C.th_open=function(r,e){var t=r[e];return"<th"+(t.align?' style="text-align:'+t.align+'"':"")+">";};C.th_close=function(){return"</th>";};C.td_open=function(r,e){var t=r[e];return"<td"+(t.align?' style="text-align:'+t.align+'"':"")+">";};C.td_close=function(){return"</td>";};C.strong_open=function(){return"<strong>";};C.strong_close=function(){return"</strong>";};C.em_open=function(){return"<em>";};C.em_close=function(){return"</em>";};C.del_open=function(){return"<del>";};C.del_close=function(){return"</del>";};C.ins_open=function(){return"<ins>";};C.ins_close=function(){return"</ins>";};C.mark_open=function(){return"<mark>";};C.mark_close=function(){return"</mark>";};C.sub=function(r,e){return"<sub>"+Pe(r[e].content)+"</sub>";};C.sup=function(r,e){return"<sup>"+Pe(r[e].content)+"</sup>";};C.hardbreak=function(r,e,t){return t.xhtmlOut?"<br />\n":"<br>\n";};C.softbreak=function(r,e,t){return t.breaks?t.xhtmlOut?"<br />\n":"<br>\n":"\n";};C.text=function(r,e){return Pe(r[e].content);};C.htmlblock=function(r,e){return r[e].content;};C.htmltag=function(r,e){return r[e].content;};C.abbr_open=function(r,e){return'<abbr title="'+Pe(Kt(r[e].title))+'">';};C.abbr_close=function(){return"</abbr>";};C.footnote_ref=function(r,e){var t=Number(r[e].id+1).toString(),n="fnref"+t;return r[e].subId>0&&(n+=":"+r[e].subId),'<sup class="footnote-ref"><a href="#fn'+t+'" id="'+n+'">['+t+"]</a></sup>";};C.footnote_block_open=function(r,e,t){var n=t.xhtmlOut?"<hr class=\"footnotes-sep\" />\n":"<hr class=\"footnotes-sep\">\n";return n+"<section class=\"footnotes\">\n<ol class=\"footnotes-list\">\n";};C.footnote_block_close=function(){return"</ol>\n</section>\n";};C.footnote_open=function(r,e){var t=Number(r[e].id+1).toString();return'<li id="fn'+t+'" class="footnote-item">';};C.footnote_close=function(){return"</li>\n";};C.footnote_anchor=function(r,e){var t=Number(r[e].id+1).toString(),n="fnref"+t;return r[e].subId>0&&(n+=":"+r[e].subId),' <a href="#'+n+'" class="footnote-backref">↩</a>';};C.dl_open=function(){return"<dl>\n";};C.dt_open=function(){return"<dt>";};C.dd_open=function(){return"<dd>";};C.dl_close=function(){return"</dl>\n";};C.dt_close=function(){return"</dt>\n";};C.dd_close=function(){return"</dd>\n";};function Ao(r,e){return++e>=r.length-2?e:r[e].type==="paragraph_open"&&r[e].tight&&r[e+1].type==="inline"&&r[e+1].content.length===0&&r[e+2].type==="paragraph_close"&&r[e+2].tight?Ao(r,e+2):e;}var Yt=C.getBreak=function(e,t){return t=Ao(e,t),t<e.length&&e[t].type==="list_item_close"?"":"\n";};function $i(){this.rules=So({},C),this.getBreak=C.getBreak;}$i.prototype.renderInline=function(r,e,t){for(var n=this.rules,s=r.length,i=0,o="";s--;)o+=n[r[i].type](r,i++,e,t,this);return o;};$i.prototype.render=function(r,e,t){for(var n=this.rules,s=r.length,i=-1,o="";++i<s;)r[i].type==="inline"?o+=this.renderInline(r[i].children,e,t):o+=n[r[i].type](r,i,e,t,this);return o;};function je(){this.__rules__=[],this.__cache__=null;}je.prototype.__find__=function(r){for(var e=this.__rules__.length,t=-1;e--;)if(this.__rules__[++t].name===r)return t;return-1;};je.prototype.__compile__=function(){var r=this,e=[""];r.__rules__.forEach(function(t){t.enabled&&t.alt.forEach(function(n){e.indexOf(n)<0&&e.push(n);});}),r.__cache__={},e.forEach(function(t){r.__cache__[t]=[],r.__rules__.forEach(function(n){n.enabled&&(t&&n.alt.indexOf(t)<0||r.__cache__[t].push(n.fn));});});};je.prototype.at=function(r,e,t){var n=this.__find__(r),s=t||{};if(n===-1)throw new Error("Parser rule not found: "+r);this.__rules__[n].fn=e,this.__rules__[n].alt=s.alt||[],this.__cache__=null;};je.prototype.before=function(r,e,t,n){var s=this.__find__(r),i=n||{};if(s===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(s,0,{name:e,enabled:!0,fn:t,alt:i.alt||[]}),this.__cache__=null;};je.prototype.after=function(r,e,t,n){var s=this.__find__(r),i=n||{};if(s===-1)throw new Error("Parser rule not found: "+r);this.__rules__.splice(s+1,0,{name:e,enabled:!0,fn:t,alt:i.alt||[]}),this.__cache__=null;};je.prototype.push=function(r,e,t){var n=t||{};this.__rules__.push({name:r,enabled:!0,fn:e,alt:n.alt||[]}),this.__cache__=null;};je.prototype.enable=function(r,e){r=Array.isArray(r)?r:[r],e&&this.__rules__.forEach(function(t){t.enabled=!1;}),r.forEach(function(t){var n=this.__find__(t);if(n<0)throw new Error("Rules manager: invalid rule name "+t);this.__rules__[n].enabled=!0;},this),this.__cache__=null;};je.prototype.disable=function(r){r=Array.isArray(r)?r:[r],r.forEach(function(e){var t=this.__find__(e);if(t<0)throw new Error("Rules manager: invalid rule name "+e);this.__rules__[t].enabled=!1;},this),this.__cache__=null;};je.prototype.getRules=function(r){return this.__cache__===null&&this.__compile__(),this.__cache__[r]||[];};function Ca(r){r.inlineMode?r.tokens.push({type:"inline",content:r.src.replace(/\n/g," ").trim(),level:0,lines:[0,1],children:[]}):r.block.parse(r.src,r.options,r.env,r.tokens);}function Qt(r,e,t,n,s){this.src=r,this.env=n,this.options=t,this.parser=e,this.tokens=s,this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache=[],this.isInLabel=!1,this.linkLevel=0,this.linkContent="",this.labelUnmatchedScopes=0;}Qt.prototype.pushPending=function(){this.tokens.push({type:"text",content:this.pending,level:this.pendingLevel}),this.pending="";};Qt.prototype.push=function(r){this.pending&&this.pushPending(),this.tokens.push(r),this.pendingLevel=this.level;};Qt.prototype.cacheSet=function(r,e){for(var t=this.cache.length;t<=r;t++)this.cache.push(0);this.cache[r]=e;};Qt.prototype.cacheGet=function(r){return r<this.cache.length?this.cache[r]:0;};function as(r,e){var t,n,s,i=-1,o=r.posMax,a=r.pos,l=r.isInLabel;if(r.isInLabel)return-1;if(r.labelUnmatchedScopes)return r.labelUnmatchedScopes--,-1;for(r.pos=e+1,r.isInLabel=!0,t=1;r.pos<o;){if(s=r.src.charCodeAt(r.pos),s===91)t++;else if(s===93&&(t--,t===0)){n=!0;break;}r.parser.skipToken(r);}return n?(i=r.pos,r.labelUnmatchedScopes=0):r.labelUnmatchedScopes=t-1,r.pos=a,r.isInLabel=l,i;}function wa(r,e,t,n){var s,i,o,a,l,c;if(r.charCodeAt(0)!==42||r.charCodeAt(1)!==91||r.indexOf("]:")===-1||(s=new Qt(r,e,t,n,[]),i=as(s,1),i<0||r.charCodeAt(i+1)!==58))return-1;for(a=s.posMax,o=i+2;o<a&&s.src.charCodeAt(o)!==10;o++);return l=r.slice(2,i),c=r.slice(i+2,o).trim(),c.length===0?-1:(n.abbreviations||(n.abbreviations={}),_typeof(n.abbreviations[":"+l])>"u"&&(n.abbreviations[":"+l]=c),o);}function Ta(r){var e=r.tokens,t,n,s,i;if(!r.inlineMode){for(t=1,n=e.length-1;t<n;t++)if(e[t-1].type==="paragraph_open"&&e[t].type==="inline"&&e[t+1].type==="paragraph_close"){for(s=e[t].content;s.length&&(i=wa(s,r.inline,r.options,r.env),!(i<0));)s=s.slice(i).trim();e[t].content=s,s.length||(e[t-1].tight=!0,e[t+1].tight=!0);}}}function _i(r){var e=Kt(r);try{e=decodeURI(e);}catch(_unused2){}return encodeURI(e);}function Co(r,e){var t,n,s,i=e,o=r.posMax;if(r.src.charCodeAt(e)===60){for(e++;e<o;){if(t=r.src.charCodeAt(e),t===10)return!1;if(t===62)return s=_i(os(r.src.slice(i+1,e))),r.parser.validateLink(s)?(r.pos=e+1,r.linkContent=s,!0):!1;if(t===92&&e+1<o){e+=2;continue;}e++;}return!1;}for(n=0;e<o&&(t=r.src.charCodeAt(e),!(t===32||t<32||t===127));){if(t===92&&e+1<o){e+=2;continue;}if(t===40&&(n++,n>1)||t===41&&(n--,n<0))break;e++;}return i===e||(s=os(r.src.slice(i,e)),!r.parser.validateLink(s))?!1:(r.linkContent=s,r.pos=e,!0);}function wo(r,e){var t,n=e,s=r.posMax,i=r.src.charCodeAt(e);if(i!==34&&i!==39&&i!==40)return!1;for(e++,i===40&&(i=41);e<s;){if(t=r.src.charCodeAt(e),t===i)return r.pos=e+1,r.linkContent=os(r.src.slice(n+1,e)),!0;if(t===92&&e+1<s){e+=2;continue;}e++;}return!1;}function To(r){return r.trim().replace(/\s+/g," ").toUpperCase();}function Ra(r,e,t,n){var s,i,o,a,l,c,d,p,u;if(r.charCodeAt(0)!==91||r.indexOf("]:")===-1||(s=new Qt(r,e,t,n,[]),i=as(s,0),i<0||r.charCodeAt(i+1)!==58))return-1;for(a=s.posMax,o=i+2;o<a&&(l=s.src.charCodeAt(o),!(l!==32&&l!==10));o++);if(!Co(s,o))return-1;for(d=s.linkContent,o=s.pos,c=o,o=o+1;o<a&&(l=s.src.charCodeAt(o),!(l!==32&&l!==10));o++);for(o<a&&c!==o&&wo(s,o)?(p=s.linkContent,o=s.pos):(p="",o=c);o<a&&s.src.charCodeAt(o)===32;)o++;return o<a&&s.src.charCodeAt(o)!==10?-1:(u=To(r.slice(1,i)),_typeof(n.references[u])>"u"&&(n.references[u]={title:p,href:d}),o);}function Ia(r){var e=r.tokens,t,n,s,i;if(r.env.references=r.env.references||{},!r.inlineMode){for(t=1,n=e.length-1;t<n;t++)if(e[t].type==="inline"&&e[t-1].type==="paragraph_open"&&e[t+1].type==="paragraph_close"){for(s=e[t].content;s.length&&(i=Ra(s,r.inline,r.options,r.env),!(i<0));)s=s.slice(i).trim();e[t].content=s,s.length||(e[t-1].tight=!0,e[t+1].tight=!0);}}}function Ma(r){var e=r.tokens,t,n,s;for(n=0,s=e.length;n<s;n++)t=e[n],t.type==="inline"&&r.inline.parse(t.content,r.options,r.env,t.children);}function ka(r){var e,t,n,s,i,o,a,l,c,d=0,p=!1,u={};if(r.env.footnotes&&(r.tokens=r.tokens.filter(function(g){return g.type==="footnote_reference_open"?(p=!0,l=[],c=g.label,!1):g.type==="footnote_reference_close"?(p=!1,u[":"+c]=l,!1):(p&&l.push(g),!p);}),!!r.env.footnotes.list)){for(o=r.env.footnotes.list,r.tokens.push({type:"footnote_block_open",level:d++}),e=0,t=o.length;e<t;e++){for(r.tokens.push({type:"footnote_open",id:e,level:d++}),o[e].tokens?(a=[],a.push({type:"paragraph_open",tight:!1,level:d++}),a.push({type:"inline",content:"",level:d,children:o[e].tokens}),a.push({type:"paragraph_close",tight:!1,level:--d})):o[e].label&&(a=u[":"+o[e].label]),r.tokens=r.tokens.concat(a),r.tokens[r.tokens.length-1].type==="paragraph_close"?i=r.tokens.pop():i=null,s=o[e].count>0?o[e].count:1,n=0;n<s;n++)r.tokens.push({type:"footnote_anchor",id:e,subId:n,level:d});i&&r.tokens.push(i),r.tokens.push({type:"footnote_close",level:--d});}r.tokens.push({type:"footnote_block_close",level:--d});}}var xr=" \n()[]'\".,!?-";function ui(r){return r.replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1");}function Oa(r){var e,t,n,s,i,o,a,l,c,d,p,u,g=r.tokens;if(r.env.abbreviations){for(r.env.abbrRegExp||(u="(^|["+xr.split("").map(ui).join("")+"])("+Object.keys(r.env.abbreviations).map(function(b){return b.substr(1);}).sort(function(b,v){return v.length-b.length;}).map(ui).join("|")+")($|["+xr.split("").map(ui).join("")+"])",r.env.abbrRegExp=new RegExp(u,"g")),d=r.env.abbrRegExp,t=0,n=g.length;t<n;t++)if(g[t].type==="inline"){for(s=g[t].children,e=s.length-1;e>=0;e--)if(i=s[e],i.type==="text"){for(l=0,o=i.content,d.lastIndex=0,c=i.level,a=[];p=d.exec(o);)d.lastIndex>l&&a.push({type:"text",content:o.slice(l,p.index+p[1].length),level:c}),a.push({type:"abbr_open",title:r.env.abbreviations[":"+p[2]],level:c++}),a.push({type:"text",content:p[2],level:c}),a.push({type:"abbr_close",level:--c}),l=d.lastIndex-p[3].length;a.length&&(l<o.length&&a.push({type:"text",content:o.slice(l),level:c}),g[t].children=s=[].concat(s.slice(0,e),a,s.slice(e+1)));}}}}var Na=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,Pa=/\((c|tm|r|p)\)/ig,La={c:"©",r:"®",p:"§",tm:"™"};function Ba(r){return r.indexOf("(")<0?r:r.replace(Pa,function(e,t){return La[t.toLowerCase()];});}function Da(r){var e,t,n,s,i;if(r.options.typographer){for(i=r.tokens.length-1;i>=0;i--)if(r.tokens[i].type==="inline")for(s=r.tokens[i].children,e=s.length-1;e>=0;e--)t=s[e],t.type==="text"&&(n=t.content,n=Ba(n),Na.test(n)&&(n=n.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/mg,"$1—$2").replace(/(^|\s)--(\s|$)/mg,"$1–$2").replace(/(^|[^-\s])--([^-\s]|$)/mg,"$1–$2")),t.content=n);}}var Fa=/['"]/,Ar=/['"]/g,Ua=/[-\s()\[\]]/,Cr="’";function wr(r,e){return e<0||e>=r.length?!1:!Ua.test(r[e]);}function nn(r,e,t){return r.substr(0,e)+t+r.substr(e+1);}function Ha(r){var e,t,n,s,i,o,a,l,c,d,p,u,g,b,v,E,w;if(r.options.typographer){for(w=[],v=r.tokens.length-1;v>=0;v--)if(r.tokens[v].type==="inline"){for(E=r.tokens[v].children,w.length=0,e=0;e<E.length;e++)if(t=E[e],!(t.type!=="text"||Fa.test(t.text))){for(a=E[e].level,g=w.length-1;g>=0&&!(w[g].level<=a);g--);w.length=g+1,n=t.content,i=0,o=n.length;e:for(;i<o&&(Ar.lastIndex=i,s=Ar.exec(n),!!s);){if(l=!wr(n,s.index-1),i=s.index+1,b=s[0]==="'",c=!wr(n,i),!c&&!l){b&&(t.content=nn(t.content,s.index,Cr));continue;}if(p=!c,u=!l,u){for(g=w.length-1;g>=0&&(d=w[g],!(w[g].level<a));g--)if(d.single===b&&w[g].level===a){d=w[g],b?(E[d.token].content=nn(E[d.token].content,d.pos,r.options.quotes[2]),t.content=nn(t.content,s.index,r.options.quotes[3])):(E[d.token].content=nn(E[d.token].content,d.pos,r.options.quotes[0]),t.content=nn(t.content,s.index,r.options.quotes[1])),w.length=g;continue e;}}p?w.push({token:e,pos:s.index,single:b,level:a}):u&&b&&(t.content=nn(t.content,s.index,Cr));}}}}}var pi=[["block",Ca],["abbr",Ta],["references",Ia],["inline",Ma],["footnote_tail",ka],["abbr2",Oa],["replacements",Da],["smartquotes",Ha]];function Ro(){this.options={},this.ruler=new je();for(var r=0;r<pi.length;r++)this.ruler.push(pi[r][0],pi[r][1]);}Ro.prototype.process=function(r){var e,t,n;for(n=this.ruler.getRules(""),e=0,t=n.length;e<t;e++)n[e](r);};function en(r,e,t,n,s){var i,o,a,l,c,d,p;for(this.src=r,this.parser=e,this.options=t,this.env=n,this.tokens=s,this.bMarks=[],this.eMarks=[],this.tShift=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.parentType="root",this.ddIndent=-1,this.level=0,this.result="",o=this.src,d=0,p=!1,a=l=d=0,c=o.length;l<c;l++){if(i=o.charCodeAt(l),!p)if(i===32){d++;continue;}else p=!0;(i===10||l===c-1)&&(i!==10&&l++,this.bMarks.push(a),this.eMarks.push(l),this.tShift.push(d),p=!1,d=0,a=l+1);}this.bMarks.push(o.length),this.eMarks.push(o.length),this.tShift.push(0),this.lineMax=this.bMarks.length-1;}en.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e];};en.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e;};en.prototype.skipSpaces=function(e){for(var t=this.src.length;e<t&&this.src.charCodeAt(e)===32;e++);return e;};en.prototype.skipChars=function(e,t){for(var n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e;};en.prototype.skipCharsBack=function(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e;};en.prototype.getLines=function(e,t,n,s){var i,o,a,l,c,d=e;if(e>=t)return"";if(d+1===t)return o=this.bMarks[d]+Math.min(this.tShift[d],n),a=s?this.eMarks[d]+1:this.eMarks[d],this.src.slice(o,a);for(l=new Array(t-e),i=0;d<t;d++,i++)c=this.tShift[d],c>n&&(c=n),c<0&&(c=0),o=this.bMarks[d]+c,d+1<t||s?a=this.eMarks[d]+1:a=this.eMarks[d],l[i]=this.src.slice(o,a);return l.join("");};function ja(r,e,t){var n,s;if(r.tShift[e]-r.blkIndent<4)return!1;for(s=n=e+1;n<t;){if(r.isEmpty(n)){n++;continue;}if(r.tShift[n]-r.blkIndent>=4){n++,s=n;continue;}break;}return r.line=n,r.tokens.push({type:"code",content:r.getLines(e,s,4+r.blkIndent,!0),block:!0,lines:[e,r.line],level:r.level}),!0;}function qa(r,e,t,n){var s,i,o,a,l,c=!1,d=r.bMarks[e]+r.tShift[e],p=r.eMarks[e];if(d+3>p||(s=r.src.charCodeAt(d),s!==126&&s!==96)||(l=d,d=r.skipChars(d,s),i=d-l,i<3)||(o=r.src.slice(d,p).trim(),o.indexOf("`")>=0))return!1;if(n)return!0;for(a=e;a++,!(a>=t||(d=l=r.bMarks[a]+r.tShift[a],p=r.eMarks[a],d<p&&r.tShift[a]<r.blkIndent));)if(r.src.charCodeAt(d)===s&&!(r.tShift[a]-r.blkIndent>=4)&&(d=r.skipChars(d,s),!(d-l<i)&&(d=r.skipSpaces(d),!(d<p)))){c=!0;break;}return i=r.tShift[e],r.line=a+(c?1:0),r.tokens.push({type:"fence",params:o,content:r.getLines(e+1,a,i,!0),lines:[e,r.line],level:r.level}),!0;}function $a(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v=r.bMarks[e]+r.tShift[e],E=r.eMarks[e];if(v>E||r.src.charCodeAt(v++)!==62||r.level>=r.options.maxNesting)return!1;if(n)return!0;for(r.src.charCodeAt(v)===32&&v++,l=r.blkIndent,r.blkIndent=0,a=[r.bMarks[e]],r.bMarks[e]=v,v=v<E?r.skipSpaces(v):v,i=v>=E,o=[r.tShift[e]],r.tShift[e]=v-r.bMarks[e],p=r.parser.ruler.getRules("blockquote"),s=e+1;s<t&&(v=r.bMarks[s]+r.tShift[s],E=r.eMarks[s],!(v>=E));s++){if(r.src.charCodeAt(v++)===62){r.src.charCodeAt(v)===32&&v++,a.push(r.bMarks[s]),r.bMarks[s]=v,v=v<E?r.skipSpaces(v):v,i=v>=E,o.push(r.tShift[s]),r.tShift[s]=v-r.bMarks[s];continue;}if(i)break;for(b=!1,u=0,g=p.length;u<g;u++)if(p[u](r,s,t,!0)){b=!0;break;}if(b)break;a.push(r.bMarks[s]),o.push(r.tShift[s]),r.tShift[s]=-1337;}for(c=r.parentType,r.parentType="blockquote",r.tokens.push({type:"blockquote_open",lines:d=[e,0],level:r.level++}),r.parser.tokenize(r,e,s),r.tokens.push({type:"blockquote_close",level:--r.level}),r.parentType=c,d[1]=r.line,u=0;u<o.length;u++)r.bMarks[u+e]=a[u],r.tShift[u+e]=o[u];return r.blkIndent=l,!0;}function Ga(r,e,t,n){var s,i,o,a=r.bMarks[e],l=r.eMarks[e];if(a+=r.tShift[e],a>l||(s=r.src.charCodeAt(a++),s!==42&&s!==45&&s!==95))return!1;for(i=1;a<l;){if(o=r.src.charCodeAt(a++),o!==s&&o!==32)return!1;o===s&&i++;}return i<3?!1:(n||(r.line=e+1,r.tokens.push({type:"hr",lines:[e,r.line],level:r.level})),!0);}function Tr(r,e){var t,n,s;return n=r.bMarks[e]+r.tShift[e],s=r.eMarks[e],n>=s||(t=r.src.charCodeAt(n++),t!==42&&t!==45&&t!==43)||n<s&&r.src.charCodeAt(n)!==32?-1:n;}function Rr(r,e){var t,n=r.bMarks[e]+r.tShift[e],s=r.eMarks[e];if(n+1>=s||(t=r.src.charCodeAt(n++),t<48||t>57))return-1;for(;;){if(n>=s)return-1;if(t=r.src.charCodeAt(n++),!(t>=48&&t<=57)){if(t===41||t===46)break;return-1;}}return n<s&&r.src.charCodeAt(n)!==32?-1:n;}function za(r,e){var t,n,s=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===s&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].tight=!0,r.tokens[t].tight=!0,t+=2);}function Va(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v,E,w,j,X,Z,ve,St=!0,xt,Be,pr,ci;if((p=Rr(r,e))>=0)E=!0;else if((p=Tr(r,e))>=0)E=!1;else return!1;if(r.level>=r.options.maxNesting)return!1;if(v=r.src.charCodeAt(p-1),n)return!0;for(j=r.tokens.length,E?(d=r.bMarks[e]+r.tShift[e],b=Number(r.src.substr(d,p-d-1)),r.tokens.push({type:"ordered_list_open",order:b,lines:Z=[e,0],level:r.level++})):r.tokens.push({type:"bullet_list_open",lines:Z=[e,0],level:r.level++}),s=e,X=!1,xt=r.parser.ruler.getRules("list");s<t&&(w=r.skipSpaces(p),u=r.eMarks[s],w>=u?g=1:g=w-p,g>4&&(g=1),g<1&&(g=1),i=p-r.bMarks[s]+g,r.tokens.push({type:"list_item_open",lines:ve=[e,0],level:r.level++}),a=r.blkIndent,l=r.tight,o=r.tShift[e],c=r.parentType,r.tShift[e]=w-r.bMarks[e],r.blkIndent=i,r.tight=!0,r.parentType="list",r.parser.tokenize(r,e,t,!0),(!r.tight||X)&&(St=!1),X=r.line-e>1&&r.isEmpty(r.line-1),r.blkIndent=a,r.tShift[e]=o,r.tight=l,r.parentType=c,r.tokens.push({type:"list_item_close",level:--r.level}),s=e=r.line,ve[1]=s,w=r.bMarks[e],!(s>=t||r.isEmpty(s)||r.tShift[s]<r.blkIndent));){for(ci=!1,Be=0,pr=xt.length;Be<pr;Be++)if(xt[Be](r,s,t,!0)){ci=!0;break;}if(ci)break;if(E){if(p=Rr(r,s),p<0)break;}else if(p=Tr(r,s),p<0)break;if(v!==r.src.charCodeAt(p-1))break;}return r.tokens.push({type:E?"ordered_list_close":"bullet_list_close",level:--r.level}),Z[1]=s,r.line=s,St&&za(r,j),!0;}function Ja(r,e,t,n){var s,i,o,a,l,c=r.bMarks[e]+r.tShift[e],d=r.eMarks[e];if(c+4>d||r.src.charCodeAt(c)!==91||r.src.charCodeAt(c+1)!==94||r.level>=r.options.maxNesting)return!1;for(a=c+2;a<d;a++){if(r.src.charCodeAt(a)===32)return!1;if(r.src.charCodeAt(a)===93)break;}return a===c+2||a+1>=d||r.src.charCodeAt(++a)!==58?!1:(n||(a++,r.env.footnotes||(r.env.footnotes={}),r.env.footnotes.refs||(r.env.footnotes.refs={}),l=r.src.slice(c+2,a-2),r.env.footnotes.refs[":"+l]=-1,r.tokens.push({type:"footnote_reference_open",label:l,level:r.level++}),s=r.bMarks[e],i=r.tShift[e],o=r.parentType,r.tShift[e]=r.skipSpaces(a)-a,r.bMarks[e]=a,r.blkIndent+=4,r.parentType="footnote",r.tShift[e]<r.blkIndent&&(r.tShift[e]+=r.blkIndent,r.bMarks[e]-=r.blkIndent),r.parser.tokenize(r,e,t,!0),r.parentType=o,r.blkIndent-=4,r.tShift[e]=i,r.bMarks[e]=s,r.tokens.push({type:"footnote_reference_close",level:--r.level})),!0);}function Wa(r,e,t,n){var s,i,o,a=r.bMarks[e]+r.tShift[e],l=r.eMarks[e];if(a>=l||(s=r.src.charCodeAt(a),s!==35||a>=l))return!1;for(i=1,s=r.src.charCodeAt(++a);s===35&&a<l&&i<=6;)i++,s=r.src.charCodeAt(++a);return i>6||a<l&&s!==32?!1:(n||(l=r.skipCharsBack(l,32,a),o=r.skipCharsBack(l,35,a),o>a&&r.src.charCodeAt(o-1)===32&&(l=o),r.line=e+1,r.tokens.push({type:"heading_open",hLevel:i,lines:[e,r.line],level:r.level}),a<l&&r.tokens.push({type:"inline",content:r.src.slice(a,l).trim(),level:r.level+1,lines:[e,r.line],children:[]}),r.tokens.push({type:"heading_close",hLevel:i,level:r.level})),!0);}function Ka(r,e,t){var n,s,i,o=e+1;return o>=t||r.tShift[o]<r.blkIndent||r.tShift[o]-r.blkIndent>3||(s=r.bMarks[o]+r.tShift[o],i=r.eMarks[o],s>=i)||(n=r.src.charCodeAt(s),n!==45&&n!==61)||(s=r.skipChars(s,n),s=r.skipSpaces(s),s<i)?!1:(s=r.bMarks[e]+r.tShift[e],r.line=o+1,r.tokens.push({type:"heading_open",hLevel:n===61?1:2,lines:[e,r.line],level:r.level}),r.tokens.push({type:"inline",content:r.src.slice(s,r.eMarks[e]).trim(),level:r.level+1,lines:[e,r.line-1],children:[]}),r.tokens.push({type:"heading_close",hLevel:n===61?1:2,level:r.level}),!0);}var Io={};["article","aside","button","blockquote","body","canvas","caption","col","colgroup","dd","div","dl","dt","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","iframe","li","map","object","ol","output","p","pre","progress","script","section","style","table","tbody","td","textarea","tfoot","th","tr","thead","ul","video"].forEach(function(r){Io[r]=!0;});var Xa=/^<([a-zA-Z]{1,15})[\s\/>]/,Za=/^<\/([a-zA-Z]{1,15})[\s>]/;function Ya(r){var e=r|32;return e>=97&&e<=122;}function Qa(r,e,t,n){var s,i,o,a=r.bMarks[e],l=r.eMarks[e],c=r.tShift[e];if(a+=c,!r.options.html||c>3||a+2>=l||r.src.charCodeAt(a)!==60)return!1;if(s=r.src.charCodeAt(a+1),s===33||s===63){if(n)return!0;}else if(s===47||Ya(s)){if(s===47){if(i=r.src.slice(a,l).match(Za),!i)return!1;}else if(i=r.src.slice(a,l).match(Xa),!i)return!1;if(Io[i[1].toLowerCase()]!==!0)return!1;if(n)return!0;}else return!1;for(o=e+1;o<r.lineMax&&!r.isEmpty(o);)o++;return r.line=o,r.tokens.push({type:"htmlblock",level:r.level,lines:[e,r.line],content:r.getLines(e,o,0,!0)}),!0;}function fi(r,e){var t=r.bMarks[e]+r.blkIndent,n=r.eMarks[e];return r.src.substr(t,n-t);}function el(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b;if(e+2>t||(l=e+1,r.tShift[l]<r.blkIndent)||(o=r.bMarks[l]+r.tShift[l],o>=r.eMarks[l])||(s=r.src.charCodeAt(o),s!==124&&s!==45&&s!==58)||(i=fi(r,e+1),!/^[-:| ]+$/.test(i))||(c=i.split("|"),c<=2))return!1;for(p=[],a=0;a<c.length;a++){if(u=c[a].trim(),!u){if(a===0||a===c.length-1)continue;return!1;}if(!/^:?-+:?$/.test(u))return!1;u.charCodeAt(u.length-1)===58?p.push(u.charCodeAt(0)===58?"center":"right"):u.charCodeAt(0)===58?p.push("left"):p.push("");}if(i=fi(r,e).trim(),i.indexOf("|")===-1||(c=i.replace(/^\||\|$/g,"").split("|"),p.length!==c.length))return!1;if(n)return!0;for(r.tokens.push({type:"table_open",lines:g=[e,0],level:r.level++}),r.tokens.push({type:"thead_open",lines:[e,e+1],level:r.level++}),r.tokens.push({type:"tr_open",lines:[e,e+1],level:r.level++}),a=0;a<c.length;a++)r.tokens.push({type:"th_open",align:p[a],lines:[e,e+1],level:r.level++}),r.tokens.push({type:"inline",content:c[a].trim(),lines:[e,e+1],level:r.level,children:[]}),r.tokens.push({type:"th_close",level:--r.level});for(r.tokens.push({type:"tr_close",level:--r.level}),r.tokens.push({type:"thead_close",level:--r.level}),r.tokens.push({type:"tbody_open",lines:b=[e+2,0],level:r.level++}),l=e+2;l<t&&!(r.tShift[l]<r.blkIndent||(i=fi(r,l).trim(),i.indexOf("|")===-1));l++){for(c=i.replace(/^\||\|$/g,"").split("|"),r.tokens.push({type:"tr_open",level:r.level++}),a=0;a<c.length;a++)r.tokens.push({type:"td_open",align:p[a],level:r.level++}),d=c[a].substring(c[a].charCodeAt(0)===124?1:0,c[a].charCodeAt(c[a].length-1)===124?c[a].length-1:c[a].length).trim(),r.tokens.push({type:"inline",content:d,level:r.level,children:[]}),r.tokens.push({type:"td_close",level:--r.level});r.tokens.push({type:"tr_close",level:--r.level});}return r.tokens.push({type:"tbody_close",level:--r.level}),r.tokens.push({type:"table_close",level:--r.level}),g[1]=b[1]=l,r.line=l,!0;}function _s(r,e){var t,n,s=r.bMarks[e]+r.tShift[e],i=r.eMarks[e];return s>=i||(n=r.src.charCodeAt(s++),n!==126&&n!==58)||(t=r.skipSpaces(s),s===t)||t>=i?-1:t;}function tl(r,e){var t,n,s=r.level+2;for(t=e+2,n=r.tokens.length-2;t<n;t++)r.tokens[t].level===s&&r.tokens[t].type==="paragraph_open"&&(r.tokens[t+2].tight=!0,r.tokens[t].tight=!0,t+=2);}function nl(r,e,t,n){var s,i,o,a,l,c,d,p,u,g,b,v,E,w;if(n)return r.ddIndent<0?!1:_s(r,e)>=0;if(d=e+1,r.isEmpty(d)&&++d>t||r.tShift[d]<r.blkIndent||(s=_s(r,d),s<0)||r.level>=r.options.maxNesting)return!1;c=r.tokens.length,r.tokens.push({type:"dl_open",lines:l=[e,0],level:r.level++}),o=e,i=d;e:for(;;){for(w=!0,E=!1,r.tokens.push({type:"dt_open",lines:[o,o],level:r.level++}),r.tokens.push({type:"inline",content:r.getLines(o,o+1,r.blkIndent,!1).trim(),level:r.level+1,lines:[o,o],children:[]}),r.tokens.push({type:"dt_close",level:--r.level});;){if(r.tokens.push({type:"dd_open",lines:a=[d,0],level:r.level++}),v=r.tight,u=r.ddIndent,p=r.blkIndent,b=r.tShift[i],g=r.parentType,r.blkIndent=r.ddIndent=r.tShift[i]+2,r.tShift[i]=s-r.bMarks[i],r.tight=!0,r.parentType="deflist",r.parser.tokenize(r,i,t,!0),(!r.tight||E)&&(w=!1),E=r.line-i>1&&r.isEmpty(r.line-1),r.tShift[i]=b,r.tight=v,r.parentType=g,r.blkIndent=p,r.ddIndent=u,r.tokens.push({type:"dd_close",level:--r.level}),a[1]=d=r.line,d>=t||r.tShift[d]<r.blkIndent)break e;if(s=_s(r,d),s<0)break;i=d;}if(d>=t||(o=d,r.isEmpty(o))||r.tShift[o]<r.blkIndent||(i=o+1,i>=t)||(r.isEmpty(i)&&i++,i>=t)||r.tShift[i]<r.blkIndent||(s=_s(r,i),s<0))break;}return r.tokens.push({type:"dl_close",level:--r.level}),l[1]=d,r.line=d,w&&tl(r,c),!0;}function sl(r,e){var t,n,s,i,o,a=e+1,l;if(t=r.lineMax,a<t&&!r.isEmpty(a)){for(l=r.parser.ruler.getRules("paragraph");a<t&&!r.isEmpty(a);a++)if(!(r.tShift[a]-r.blkIndent>3)){for(s=!1,i=0,o=l.length;i<o;i++)if(l[i](r,a,t,!0)){s=!0;break;}if(s)break;}}return n=r.getLines(e,a,r.blkIndent,!1).trim(),r.line=a,n.length&&(r.tokens.push({type:"paragraph_open",tight:!1,lines:[e,r.line],level:r.level}),r.tokens.push({type:"inline",content:n,level:r.level+1,lines:[e,r.line],children:[]}),r.tokens.push({type:"paragraph_close",tight:!1,level:r.level})),!0;}var Es=[["code",ja],["fences",qa,["paragraph","blockquote","list"]],["blockquote",$a,["paragraph","blockquote","list"]],["hr",Ga,["paragraph","blockquote","list"]],["list",Va,["paragraph","blockquote"]],["footnote",Ja,["paragraph"]],["heading",Wa,["paragraph","blockquote"]],["lheading",Ka],["htmlblock",Qa,["paragraph","blockquote"]],["table",el,["paragraph"]],["deflist",nl,["paragraph"]],["paragraph",sl]];function Gi(){this.ruler=new je();for(var r=0;r<Es.length;r++)this.ruler.push(Es[r][0],Es[r][1],{alt:(Es[r][2]||[]).slice()});}Gi.prototype.tokenize=function(r,e,t){for(var n=this.ruler.getRules(""),s=n.length,i=e,o=!1,a,l;i<t&&(r.line=i=r.skipEmptyLines(i),!(i>=t||r.tShift[i]<r.blkIndent));){for(l=0;l<s&&(a=n[l](r,i,t,!1),!a);l++);if(r.tight=!o,r.isEmpty(r.line-1)&&(o=!0),i=r.line,i<t&&r.isEmpty(i)){if(o=!0,i++,i<t&&r.parentType==="list"&&r.isEmpty(i))break;r.line=i;}}};var il=/[\n\t]/g,rl=/\r[\n\u0085]|[\u2424\u2028\u0085]/g,ol=/\u00a0/g;Gi.prototype.parse=function(r,e,t,n){var s,i=0,o=0;if(!r)return[];r=r.replace(ol," "),r=r.replace(rl,"\n"),r.indexOf(" ")>=0&&(r=r.replace(il,function(a,l){var c;return r.charCodeAt(l)===10?(i=l+1,o=0,a):(c=" ".slice((l-i-o)%4),o=l-i+1,c);})),s=new en(r,this,e,t,n),this.tokenize(s,s.line,s.lineMax);};function al(r){switch(r){case 10:case 92:case 96:case 42:case 95:case 94:case 91:case 93:case 33:case 38:case 60:case 62:case 123:case 125:case 36:case 37:case 64:case 126:case 43:case 61:case 58:return!0;default:return!1;}}function ll(r,e){for(var t=r.pos;t<r.posMax&&!al(r.src.charCodeAt(t));)t++;return t===r.pos?!1:(e||(r.pending+=r.src.slice(r.pos,t)),r.pos=t,!0);}function cl(r,e){var t,n,s=r.pos;if(r.src.charCodeAt(s)!==10)return!1;if(t=r.pending.length-1,n=r.posMax,!e)if(t>=0&&r.pending.charCodeAt(t)===32){if(t>=1&&r.pending.charCodeAt(t-1)===32){for(var i=t-2;i>=0;i--)if(r.pending.charCodeAt(i)!==32){r.pending=r.pending.substring(0,i+1);break;}r.push({type:"hardbreak",level:r.level});}else r.pending=r.pending.slice(0,-1),r.push({type:"softbreak",level:r.level});}else r.push({type:"softbreak",level:r.level});for(s++;s<n&&r.src.charCodeAt(s)===32;)s++;return r.pos=s,!0;}var zi=[];for(var Ir=0;Ir<256;Ir++)zi.push(0);"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach(function(r){zi[r.charCodeAt(0)]=1;});function dl(r,e){var t,n=r.pos,s=r.posMax;if(r.src.charCodeAt(n)!==92)return!1;if(n++,n<s){if(t=r.src.charCodeAt(n),t<256&&zi[t]!==0)return e||(r.pending+=r.src[n]),r.pos+=2,!0;if(t===10){for(e||r.push({type:"hardbreak",level:r.level}),n++;n<s&&r.src.charCodeAt(n)===32;)n++;return r.pos=n,!0;}}return e||(r.pending+="\\"),r.pos++,!0;}function hl(r,e){var t,n,s,i,o,a=r.pos,l=r.src.charCodeAt(a);if(l!==96)return!1;for(t=a,a++,n=r.posMax;a<n&&r.src.charCodeAt(a)===96;)a++;for(s=r.src.slice(t,a),i=o=a;(i=r.src.indexOf("`",o))!==-1;){for(o=i+1;o<n&&r.src.charCodeAt(o)===96;)o++;if(o-i===s.length)return e||r.push({type:"code",content:r.src.slice(a,i).replace(/[ \n]+/g," ").trim(),block:!1,level:r.level}),r.pos=o,!0;}return e||(r.pending+=s),r.pos+=s.length,!0;}function ul(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==126||e||o+4>=i||r.src.charCodeAt(o+1)!==126||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===126)||l===126||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===126;)n++;if(n>o+3)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===126&&r.src.charCodeAt(r.pos+1)===126&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==126&&a!==126&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"del_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"del_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function pl(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==43||e||o+4>=i||r.src.charCodeAt(o+1)!==43||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===43)||l===43||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===43;)n++;if(n!==o+2)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===43&&r.src.charCodeAt(r.pos+1)===43&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==43&&a!==43&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"ins_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"ins_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function fl(r,e){var t,n,s,i=r.posMax,o=r.pos,a,l;if(r.src.charCodeAt(o)!==61||e||o+4>=i||r.src.charCodeAt(o+1)!==61||r.level>=r.options.maxNesting||(a=o>0?r.src.charCodeAt(o-1):-1,l=r.src.charCodeAt(o+2),a===61)||l===61||l===32||l===10)return!1;for(n=o+2;n<i&&r.src.charCodeAt(n)===61;)n++;if(n!==o+2)return r.pos+=n-o,e||(r.pending+=r.src.slice(o,n)),!0;for(r.pos=o+2,s=1;r.pos+1<i;){if(r.src.charCodeAt(r.pos)===61&&r.src.charCodeAt(r.pos+1)===61&&(a=r.src.charCodeAt(r.pos-1),l=r.pos+2<i?r.src.charCodeAt(r.pos+2):-1,l!==61&&a!==61&&(a!==32&&a!==10?s--:l!==32&&l!==10&&s++,s<=0))){t=!0;break;}r.parser.skipToken(r);}return t?(r.posMax=r.pos,r.pos=o+2,e||(r.push({type:"mark_open",level:r.level++}),r.parser.tokenize(r),r.push({type:"mark_close",level:--r.level})),r.pos=r.posMax+2,r.posMax=i,!0):(r.pos=o,!1);}function Mr(r){return r>=48&&r<=57||r>=65&&r<=90||r>=97&&r<=122;}function kr(r,e){var t=e,n,s,i,o=!0,a=!0,l=r.posMax,c=r.src.charCodeAt(e);for(n=e>0?r.src.charCodeAt(e-1):-1;t<l&&r.src.charCodeAt(t)===c;)t++;return t>=l&&(o=!1),i=t-e,i>=4?o=a=!1:(s=t<l?r.src.charCodeAt(t):-1,(s===32||s===10)&&(o=!1),(n===32||n===10)&&(a=!1),c===95&&(Mr(n)&&(o=!1),Mr(s)&&(a=!1))),{can_open:o,can_close:a,delims:i};}function ml(r,e){var t,n,s,i,o,a,l,c=r.posMax,d=r.pos,p=r.src.charCodeAt(d);if(p!==95&&p!==42||e)return!1;if(l=kr(r,d),t=l.delims,!l.can_open)return r.pos+=t,e||(r.pending+=r.src.slice(d,r.pos)),!0;if(r.level>=r.options.maxNesting)return!1;for(r.pos=d+t,a=[t];r.pos<c;){if(r.src.charCodeAt(r.pos)===p){if(l=kr(r,r.pos),n=l.delims,l.can_close){for(i=a.pop(),o=n;i!==o;){if(o<i){a.push(i-o);break;}if(o-=i,a.length===0)break;r.pos+=i,i=a.pop();}if(a.length===0){t=i,s=!0;break;}r.pos+=n;continue;}l.can_open&&a.push(n),r.pos+=n;continue;}r.parser.skipToken(r);}return s?(r.posMax=r.pos,r.pos=d+t,e||((t===2||t===3)&&r.push({type:"strong_open",level:r.level++}),(t===1||t===3)&&r.push({type:"em_open",level:r.level++}),r.parser.tokenize(r),(t===1||t===3)&&r.push({type:"em_close",level:--r.level}),(t===2||t===3)&&r.push({type:"strong_close",level:--r.level})),r.pos=r.posMax+t,r.posMax=c,!0):(r.pos=d,!1);}var gl=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function yl(r,e){var t,n,s=r.posMax,i=r.pos;if(r.src.charCodeAt(i)!==126||e||i+2>=s||r.level>=r.options.maxNesting)return!1;for(r.pos=i+1;r.pos<s;){if(r.src.charCodeAt(r.pos)===126){t=!0;break;}r.parser.skipToken(r);}return!t||i+1===r.pos||(n=r.src.slice(i+1,r.pos),n.match(/(^|[^\\])(\\\\)*\s/))?(r.pos=i,!1):(r.posMax=r.pos,r.pos=i+1,e||r.push({type:"sub",level:r.level,content:n.replace(gl,"$1")}),r.pos=r.posMax+1,r.posMax=s,!0);}var bl=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function vl(r,e){var t,n,s=r.posMax,i=r.pos;if(r.src.charCodeAt(i)!==94||e||i+2>=s||r.level>=r.options.maxNesting)return!1;for(r.pos=i+1;r.pos<s;){if(r.src.charCodeAt(r.pos)===94){t=!0;break;}r.parser.skipToken(r);}return!t||i+1===r.pos||(n=r.src.slice(i+1,r.pos),n.match(/(^|[^\\])(\\\\)*\s/))?(r.pos=i,!1):(r.posMax=r.pos,r.pos=i+1,e||r.push({type:"sup",level:r.level,content:n.replace(bl,"$1")}),r.pos=r.posMax+1,r.posMax=s,!0);}function _l(r,e){var t,n,s,i,o,a,l,c,d=!1,p=r.pos,u=r.posMax,g=r.pos,b=r.src.charCodeAt(g);if(b===33&&(d=!0,b=r.src.charCodeAt(++g)),b!==91||r.level>=r.options.maxNesting||(t=g+1,n=as(r,g),n<0))return!1;if(a=n+1,a<u&&r.src.charCodeAt(a)===40){for(a++;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a>=u)return!1;for(g=a,Co(r,a)?(i=r.linkContent,a=r.pos):i="",g=a;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a<u&&g!==a&&wo(r,a))for(o=r.linkContent,a=r.pos;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);else o="";if(a>=u||r.src.charCodeAt(a)!==41)return r.pos=p,!1;a++;}else{if(r.linkLevel>0)return!1;for(;a<u&&(c=r.src.charCodeAt(a),!(c!==32&&c!==10));a++);if(a<u&&r.src.charCodeAt(a)===91&&(g=a+1,a=as(r,a),a>=0?s=r.src.slice(g,a++):a=g-1),s||(_typeof(s)>"u"&&(a=n+1),s=r.src.slice(t,n)),l=r.env.references[To(s)],!l)return r.pos=p,!1;i=l.href,o=l.title;}return e||(r.pos=t,r.posMax=n,d?r.push({type:"image",src:i,title:o,alt:r.src.substr(t,n-t),level:r.level}):(r.push({type:"link_open",href:i,title:o,level:r.level++}),r.linkLevel++,r.parser.tokenize(r),r.linkLevel--,r.push({type:"link_close",level:--r.level}))),r.pos=a,r.posMax=u,!0;}function El(r,e){var t,n,s,i,o=r.posMax,a=r.pos;return a+2>=o||r.src.charCodeAt(a)!==94||r.src.charCodeAt(a+1)!==91||r.level>=r.options.maxNesting||(t=a+2,n=as(r,a+1),n<0)?!1:(e||(r.env.footnotes||(r.env.footnotes={}),r.env.footnotes.list||(r.env.footnotes.list=[]),s=r.env.footnotes.list.length,r.pos=t,r.posMax=n,r.push({type:"footnote_ref",id:s,level:r.level}),r.linkLevel++,i=r.tokens.length,r.parser.tokenize(r),r.env.footnotes.list[s]={tokens:r.tokens.splice(i)},r.linkLevel--),r.pos=n+1,r.posMax=o,!0);}function Sl(r,e){var t,n,s,i,o=r.posMax,a=r.pos;if(a+3>o||!r.env.footnotes||!r.env.footnotes.refs||r.src.charCodeAt(a)!==91||r.src.charCodeAt(a+1)!==94||r.level>=r.options.maxNesting)return!1;for(n=a+2;n<o;n++){if(r.src.charCodeAt(n)===32||r.src.charCodeAt(n)===10)return!1;if(r.src.charCodeAt(n)===93)break;}return n===a+2||n>=o||(n++,t=r.src.slice(a+2,n-1),_typeof(r.env.footnotes.refs[":"+t])>"u")?!1:(e||(r.env.footnotes.list||(r.env.footnotes.list=[]),r.env.footnotes.refs[":"+t]<0?(s=r.env.footnotes.list.length,r.env.footnotes.list[s]={label:t,count:0},r.env.footnotes.refs[":"+t]=s):s=r.env.footnotes.refs[":"+t],i=r.env.footnotes.list[s].count,r.env.footnotes.list[s].count++,r.push({type:"footnote_ref",id:s,subId:i,level:r.level})),r.pos=n,r.posMax=o,!0);}var xl=["coap","doi","javascript","aaa","aaas","about","acap","cap","cid","crid","data","dav","dict","dns","file","ftp","geo","go","gopher","h323","http","https","iax","icap","im","imap","info","ipp","iris","iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid","msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp","opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve","sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet","tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon","xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s","adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin","bolo","callto","chrome","chrome-extension","com-eventbrite-attendee","content","cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb","ed2k","facetime","feed","finger","fish","gg","git","gizmoproject","gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms","keyparc","lastfm","ldaps","magnet","maps","market","message","mms","ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi","platform","proxy","psyc","query","res","resource","rmi","rsync","rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify","ssh","steam","svn","teamspeak","things","udp","unreal","ut2004","ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri","ymsgr"],Al=/^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/,Cl=/^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;function wl(r,e){var t,n,s,i,o,a=r.pos;return r.src.charCodeAt(a)!==60||(t=r.src.slice(a),t.indexOf(">")<0)?!1:(n=t.match(Cl),n?xl.indexOf(n[1].toLowerCase())<0||(i=n[0].slice(1,-1),o=_i(i),!r.parser.validateLink(i))?!1:(e||(r.push({type:"link_open",href:o,level:r.level}),r.push({type:"text",content:i,level:r.level+1}),r.push({type:"link_close",level:r.level})),r.pos+=n[0].length,!0):(s=t.match(Al),s?(i=s[0].slice(1,-1),o=_i("mailto:"+i),r.parser.validateLink(o)?(e||(r.push({type:"link_open",href:o,level:r.level}),r.push({type:"text",content:i,level:r.level+1}),r.push({type:"link_close",level:r.level})),r.pos+=s[0].length,!0):!1):!1));}function ei(r,e){return r=r.source,e=e||"",function t(n,s){return n?(s=s.source||s,r=r.replace(n,s),t):new RegExp(r,e);};}var Tl=/[a-zA-Z_:][a-zA-Z0-9:._-]*/,Rl=/[^"'=<>`\x00-\x20]+/,Il=/'[^']*'/,Ml=/"[^"]*"/,kl=ei(/(?:unquoted|single_quoted|double_quoted)/)("unquoted",Rl)("single_quoted",Il)("double_quoted",Ml)(),Ol=ei(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)("attr_name",Tl)("attr_value",kl)(),Nl=ei(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)("attribute",Ol)(),Pl=/<\/[A-Za-z][A-Za-z0-9]*\s*>/,Ll=/<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->/,Bl=/<[?].*?[?]>/,Dl=/<![A-Z]+\s+[^>]*>/,Fl=/<!\[CDATA\[[\s\S]*?\]\]>/,Ul=ei(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)("open_tag",Nl)("close_tag",Pl)("comment",Ll)("processing",Bl)("declaration",Dl)("cdata",Fl)();function Hl(r){var e=r|32;return e>=97&&e<=122;}function jl(r,e){var t,n,s,i=r.pos;return!r.options.html||(s=r.posMax,r.src.charCodeAt(i)!==60||i+2>=s)||(t=r.src.charCodeAt(i+1),t!==33&&t!==63&&t!==47&&!Hl(t))||(n=r.src.slice(i).match(Ul),!n)?!1:(e||r.push({type:"htmltag",content:r.src.slice(i,i+n[0].length),level:r.level}),r.pos+=n[0].length,!0);}var ql=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,$l=/^&([a-z][a-z0-9]{1,31});/i;function Gl(r,e){var t,n,s,i=r.pos,o=r.posMax;if(r.src.charCodeAt(i)!==38)return!1;if(i+1<o){if(t=r.src.charCodeAt(i+1),t===35){if(s=r.src.slice(i).match(ql),s)return e||(n=s[1][0].toLowerCase()==="x"?parseInt(s[1].slice(1),16):parseInt(s[1],10),r.pending+=xo(n)?vi(n):vi(65533)),r.pos+=s[0].length,!0;}else if(s=r.src.slice(i).match($l),s){var a=Eo(s[1]);if(s[1]!==a)return e||(r.pending+=a),r.pos+=s[0].length,!0;}}return e||(r.pending+="&"),r.pos++,!0;}var mi=[["text",ll],["newline",cl],["escape",dl],["backticks",hl],["del",ul],["ins",pl],["mark",fl],["emphasis",ml],["sub",yl],["sup",vl],["links",_l],["footnote_inline",El],["footnote_ref",Sl],["autolink",wl],["htmltag",jl],["entity",Gl]];function ti(){this.ruler=new je();for(var r=0;r<mi.length;r++)this.ruler.push(mi[r][0],mi[r][1]);this.validateLink=zl;}ti.prototype.skipToken=function(r){var e=this.ruler.getRules(""),t=e.length,n=r.pos,s,i;if((i=r.cacheGet(n))>0){r.pos=i;return;}for(s=0;s<t;s++)if(e[s](r,!0)){r.cacheSet(n,r.pos);return;}r.pos++,r.cacheSet(n,r.pos);};ti.prototype.tokenize=function(r){for(var e=this.ruler.getRules(""),t=e.length,n=r.posMax,s,i;r.pos<n;){for(i=0;i<t&&(s=e[i](r,!1),!s);i++);if(s){if(r.pos>=n)break;continue;}r.pending+=r.src[r.pos++];}r.pending&&r.pushPending();};ti.prototype.parse=function(r,e,t,n){var s=new Qt(r,this,e,t,n);this.tokenize(s);};function zl(r){var e=["vbscript","javascript","file","data"],t=r.trim().toLowerCase();return t=Kt(t),!(t.indexOf(":")!==-1&&e.indexOf(t.split(":")[0])!==-1);}var Vl={options:{html:!1,// Enable HTML tags in source
19
19
  xhtmlOut:!1,// Use '/' to close single tags (<br />)
20
20
  breaks:!1,// Convert '\n' in paragraphs into <br>
21
21
  langPrefix:"language-",// CSS language prefix for fenced blocks
@@ -89,15 +89,15 @@ function addInnerContainerElements(e,t,n){var s=this.messageElementRefs[this.mes
89
89
  },{key:"classifyRoleMessages",value:function classifyRoleMessages(e,t){var n=t?N.buildRoleOuterContainerClass(t):void 0;for(var s=e.length-1;s>=0;s-=1){if(t||(n=Array.from(e[s].outerContainer[m]).find(function(p){return p.startsWith(ys);})),!n)continue;var i=e[s],o=i.outerContainer[m].contains(n),a=e[s-1],l=e[s+1],c=a==null?void 0:a.outerContainer[m].contains(n),d=l==null?void 0:l.outerContainer[m].contains(n);if(o)!c&&d?N.addNewPositionClasses(i,[di]):c&&d?N.addNewPositionClasses(i,[mr]):c&&!d?N.addNewPositionClasses(i,[hi]):!c&&!d&&N.addNewPositionClasses(i,[di,hi]);else if(t)break;}}},{key:"areOuterContainerClassRolesSame",value:function areOuterContainerClassRolesSame(e,t){return t?Array.from(t.outerContainer[m]).find(function(s){return s.startsWith(ys);})===N.buildRoleOuterContainerClass(e):!1;}},{key:"resetAllRoleElements",value:function resetAllRoleElements(e,t,n){if(!t&&!n)return;var s="";e.forEach(function(i,o){i.bubbleElement[m].contains(Ts)||N.revealRoleElements(i.innerContainer,t,n);var a=Array.from(i.outerContainer[m]).find(function(l){return l.startsWith(ys);});s===a&&N.hideRoleElements(e[o-1].innerContainer,t,n),s=a;});}// this is a workaround to prevent JSON.parse(JSON.stringify()) from removing the files' 'ref' property values
90
90
  // and 'custom' property value if it is not shallow copyable
91
91
  // note - structuredClone can fix this but it doesn't have good legacy compatibility
92
- },{key:"deepCloneMessagesWithReferences",value:function deepCloneMessagesWithReferences(e){return e.map(function(t){return N.processMessageContent(t);});}},{key:"processMessageContent",value:function processMessageContent(e){if(e==null||_typeof(e)!==B)return e;if(Array.isArray(e))return e.map(function(n){return N.processMessageContent(n);});var t={};return Object.entries(e).forEach(function(_ref6){var _ref7=_slicedToArray(_ref6,2),n=_ref7[0],s=_ref7[1];n==="ref"&&s instanceof File||n==="custom"?t[n]=s:s!==null&&_typeof(s)===B?t[n]=N.processMessageContent(s):t[n]=s;}),t;}}]);}();var pt=/*#__PURE__*/function(){function pt(e,t){_classCallCheck(this,pt);this._fileAdded=!1,this._streamType="",this._hasStreamEnded=!1,this._partialText="",this._messages=e,_typeof(t)=="object"&&(this._partialRender=t.partialRender);}return _createClass(pt,[{key:"upsertStreamedMessage",value:function upsertStreamedMessage(e){if(this._hasStreamEnded)return;if((e==null?void 0:e[h])===void 0&&(e==null?void 0:e[M])===void 0)return console[f](bo);var t=(e==null?void 0:e[h])||(e==null?void 0:e[M])||"",n=F.isScrollbarAtBottomOfElement(this._messages.elementRef),s=(e==null?void 0:e[h])!==void 0?h:M;if(!this._elements&&!this._message)this.setInitialState(s,t,e==null?void 0:e.role);else{if(this._streamType!==s)return console[f](oa);e!=null&&e.role&&(e==null?void 0:e.role)!==this._activeMessageRole?(this.finaliseStreamedMessage(!1),this.setInitialState(s,t,e==null?void 0:e.role)):this.updateBasedOnType(t,s,e==null?void 0:e.overwrite);}e!=null&&e._sessionId&&(this._sessionId=e==null?void 0:e._sessionId),e!=null&&e.custom&&this._message&&(this._message.custom=e.custom),n&&F.scrollToBottom(this._messages);}},{key:"setInitialState",value:function setInitialState(e,t,n){var o,a,l;this._streamType=e,this._targetWrapper=void 0,this._fileAdded=!1,this._partialText="",this._partialBubble=void 0,n!==null&&n!==void 0?n:n=K;var s=((o=this._messages._customWrappers)==null?void 0:o[n])||((a=this._messages._customWrappers)==null?void 0:a[x]),i=s?"":t;this._elements=e===h?this._messages.addNewTextMessage(i,n):lt.add(this._messages,i,n),this._elements&&(this._elements.bubbleElement[m].add(pt.MESSAGE_CLASS),this._activeMessageRole=n,this._message=_defineProperty({role:this._activeMessageRole},e,i),this._messages.messageToElements.push([this._message,_defineProperty({},e,this._elements)]),s&&this.setTargetWrapperIfNeeded(this._elements,t,this._streamType,s),(l=this._messages.scrollButton)==null||l.updateHidden());}// not using existing htmlUtils htmlWrappers logic to be able to stream html
93
- },{key:"setTargetWrapperIfNeeded",value:function setTargetWrapperIfNeeded(e,t,n,s){e.bubbleElement.innerHTML=s,this._targetWrapper=Y.getTargetWrapper(e.bubbleElement),this._elements&&Y.apply(this._messages,this._elements.bubbleElement),this.updateBasedOnType(t,n);}},{key:"updateBasedOnType",value:function updateBasedOnType(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;var o;var s=this._targetWrapper||((o=this._elements)==null?void 0:o.bubbleElement);this._partialRender||N.unfillEmptyMessageElement(s,e),(t===h?this.updateText:this.updateHTML).bind(this)(e,s,n);}},{key:"updateText",value:function updateText(e,t,n){this._message&&(this._message[h]=n?e:this._message[h]+e,this._partialRender&&this.isNewPartialRenderParagraph(t,n)&&this.partialRenderNewParagraph(t),this._partialBubble?this.partialRenderBubbleUpdate(e):this._messages.renderText(t,this._message[h]));}},{key:"isNewPartialRenderParagraph",value:function isNewPartialRenderParagraph(e,t){var n;return t?(e.innerHTML="",!0):this._partialBubble?this._partialText&&this.shouldCreateNewParagraph(this._partialText):((n=this._message)==null?void 0:n[h])&&this.shouldCreateNewParagraph(this._message[h]);}},{key:"shouldCreateNewParagraph",value:function shouldCreateNewParagraph(e){var t=e.indexOf(pt.PARTIAL_RENDER_TEXT_MARK);return t===-1?!1:!e.substring(t+pt.PARTIAL_RENDER_TEXT_MARK.length).startsWith("---");}},{key:"partialRenderNewParagraph",value:function partialRenderNewParagraph(e){this._partialText="",this._partialBubble=S(),this._partialBubble[m].add("partial-render-message"),e.appendChild(this._partialBubble);}},{key:"partialRenderBubbleUpdate",value:function partialRenderBubbleUpdate(e){this._partialText+=e,this._messages.renderText(this._partialBubble,this._partialText);}},{key:"updateHTML",value:function updateHTML(e,t,n){if(this._message)if(n)this._message[M]=e,t.innerHTML=e;else{var s=S("span");s.innerHTML=e,t.appendChild(s),this._message[M]=(t==null?void 0:t.innerHTML)||"";}}},{key:"finaliseStreamedMessage",value:function finaliseStreamedMessage(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var t,n;if(!(this._endStreamAfterOperation||!this._message)&&!(this._fileAdded&&!this._elements)){if(!this._elements)throw Error(aa);(t=this._elements.bubbleElement)!=null&&t[m].contains(pt.MESSAGE_CLASS)&&(this._streamType===h?this._messages.textToSpeech&&pn.speak(this._message[h]||"",this._messages.textToSpeech):this._streamType===M&&this._elements&&Y.apply(this._messages,this._elements.outerContainer),this._elements.bubbleElement[m].remove(pt.MESSAGE_CLASS),this._message&&(this._sessionId&&(this._message._sessionId=this._sessionId),this._messages.sendClientUpdate(Je.createMessageContent(this._message),!1),(n=this._messages.browserStorage)==null||n.addMessages(this._messages.messageToElements.map(function(_ref9){var _ref0=_slicedToArray(_ref9,1),s=_ref0[0];return s;}))),this._hasStreamEnded=e);}}},{key:"markFileAdded",value:function markFileAdded(){this._fileAdded=!0;}// prettier-ignore
94
- },{key:"endStreamAfterFileDownloaded",value:function(){var _endStreamAfterFileDownloaded=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e,t){var _yield$t,n,s;return _regenerator().w(function(_context2){while(1)switch(_context2.n){case 0:this._endStreamAfterOperation=!0;_context2.n=1;return t();case 1:_yield$t=_context2.v;n=_yield$t.text;s=_yield$t.files;n&&this.updateBasedOnType(n,h,!0),this._endStreamAfterOperation=!1,this.finaliseStreamedMessage(),s&&e.addNewMessage(_defineProperty({},y,s));case 2:return _context2.a(2);}},_callee2,this);}));function endStreamAfterFileDownloaded(_x3,_x4){return _endStreamAfterFileDownloaded.apply(this,arguments);}return endStreamAfterFileDownloaded;}()}]);}();pt.MESSAGE_CLASS="streamed-message",pt.PARTIAL_RENDER_TEXT_MARK="\n\n";var tt=pt;var P=/*#__PURE__*/function(){function P(){_classCallCheck(this,P);}return _createClass(P,null,[{key:"tempRemoveContentHeader",value:// need to pass stringifyBody boolean separately as binding is throwing an error for some reason
92
+ },{key:"deepCloneMessagesWithReferences",value:function deepCloneMessagesWithReferences(e){return e.map(function(t){return N.processMessageContent(t);});}},{key:"processMessageContent",value:function processMessageContent(e){if(e==null||_typeof(e)!==B)return e;if(Array.isArray(e))return e.map(function(n){return N.processMessageContent(n);});var t={};return Object.entries(e).forEach(function(_ref6){var _ref7=_slicedToArray(_ref6,2),n=_ref7[0],s=_ref7[1];n==="ref"&&s instanceof File||n==="custom"?t[n]=s:s!==null&&_typeof(s)===B?t[n]=N.processMessageContent(s):t[n]=s;}),t;}}]);}();var pt=/*#__PURE__*/function(){function pt(e,t){_classCallCheck(this,pt);this._fileAdded=!1,this._streamType="",this._hasStreamEnded=!1,this._partialContent="",this._messages=e,_typeof(t)=="object"&&(this._partialRender=t.partialRender);}return _createClass(pt,[{key:"upsertStreamedMessage",value:function upsertStreamedMessage(e){if(this._hasStreamEnded)return;if((e==null?void 0:e[h])===void 0&&(e==null?void 0:e[M])===void 0)return console[f](bo);var t=(e==null?void 0:e[h])||(e==null?void 0:e[M])||"",n=F.isScrollbarAtBottomOfElement(this._messages.elementRef),s=(e==null?void 0:e[h])!==void 0?h:M;if(!this._elements&&!this._message)this.setInitialState(s,t,e==null?void 0:e.role);else{if(this._streamType!==s)return console[f](oa);e!=null&&e.role&&(e==null?void 0:e.role)!==this._activeMessageRole?(this.finaliseStreamedMessage(!1),this.setInitialState(s,t,e==null?void 0:e.role)):this.updateBasedOnType(t,s,e==null?void 0:e.overwrite);}e!=null&&e._sessionId&&(this._sessionId=e==null?void 0:e._sessionId),e!=null&&e.custom&&this._message&&(this._message.custom=e.custom),n&&F.scrollToBottom(this._messages);}},{key:"setInitialState",value:function setInitialState(e,t,n){var o,a,l;this._streamType=e,this._targetWrapper=void 0,this._fileAdded=!1,this._partialContent="",this._partialBubble=void 0,n!==null&&n!==void 0?n:n=K;var s=((o=this._messages._customWrappers)==null?void 0:o[n])||((a=this._messages._customWrappers)==null?void 0:a[x]),i=s?"":t;this._elements=e===h?this._messages.addNewTextMessage(i,n):lt.add(this._messages,i,n),this._elements&&(this._elements.bubbleElement[m].add(pt.MESSAGE_CLASS),this._activeMessageRole=n,this._message=_defineProperty({role:this._activeMessageRole},e,i),this._messages.messageToElements.push([this._message,_defineProperty({},e,this._elements)]),s&&this.setTargetWrapperIfNeeded(this._elements,t,this._streamType,s),(l=this._messages.scrollButton)==null||l.updateHidden());}// not using existing htmlUtils htmlWrappers logic to be able to stream html
93
+ },{key:"setTargetWrapperIfNeeded",value:function setTargetWrapperIfNeeded(e,t,n,s){e.bubbleElement.innerHTML=s,this._targetWrapper=Y.getTargetWrapper(e.bubbleElement),this._elements&&Y.apply(this._messages,this._elements.bubbleElement),this.updateBasedOnType(t,n);}},{key:"updateBasedOnType",value:function updateBasedOnType(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;var o;var s=this._targetWrapper||((o=this._elements)==null?void 0:o.bubbleElement);this._partialRender||N.unfillEmptyMessageElement(s,e),(t===h?this.updateText:this.updateHTML).bind(this)(e,s,n);}},{key:"updateText",value:function updateText(e,t,n){this._message&&(this._message[h]=n?e:this._message[h]+e,this._partialRender&&this.isNewPartialRenderParagraph(t,n)&&this.partialRenderNewParagraph(t),this._partialBubble?this.updatePartialRenderBubble(e):this._messages.renderText(t,this._message[h]));}},{key:"containsPartialRenderMark",value:function containsPartialRenderMark(e){var t=e.indexOf(pt.PARTIAL_RENDER_MARK);return t===-1?!1:!e.substring(t+pt.PARTIAL_RENDER_MARK.length).startsWith("---");}},{key:"isNewPartialRenderParagraph",value:function isNewPartialRenderParagraph(e,t){var s;if(t)return e.innerHTML="",!0;var n=this._streamType;if(!this._partialBubble){var i=(s=this._message)==null?void 0:s[n];return!!i&&this.containsPartialRenderMark(i);}return!!this._partialContent&&this.containsPartialRenderMark(this._partialContent);}},{key:"partialRenderNewParagraph",value:function partialRenderNewParagraph(e){this._partialContent="",this._partialBubble=S(),this._partialBubble[m].add("partial-render-message"),e.appendChild(this._partialBubble);}},{key:"updatePartialRenderBubble",value:function updatePartialRenderBubble(e){this._partialContent+=e,this._streamType===h?this._messages.renderText(this._partialBubble,this._partialContent):this._partialBubble.innerHTML=this._partialContent;}},{key:"updateHTML",value:function updateHTML(e,t,n){if(this._message)if(this._message[M]=n?e:(this._message[M]||"")+e,this._partialRender&&this.isNewPartialRenderParagraph(t,n)&&this.partialRenderNewParagraph(t),this._partialBubble)this.updatePartialRenderBubble(e);else if(n)t.innerHTML=e;else{var s=S("span");s.innerHTML=e,t.appendChild(s);}}},{key:"finaliseStreamedMessage",value:function finaliseStreamedMessage(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!0;var t,n;if(!(this._endStreamAfterOperation||!this._message)&&!(this._fileAdded&&!this._elements)){if(!this._elements)throw Error(aa);(t=this._elements.bubbleElement)!=null&&t[m].contains(pt.MESSAGE_CLASS)&&(this._streamType===h?this._messages.textToSpeech&&pn.speak(this._message[h]||"",this._messages.textToSpeech):this._streamType===M&&this._elements&&Y.apply(this._messages,this._elements.outerContainer),this._elements.bubbleElement[m].remove(pt.MESSAGE_CLASS),this._message&&(this._sessionId&&(this._message._sessionId=this._sessionId),this._messages.sendClientUpdate(Je.createMessageContent(this._message),!1),(n=this._messages.browserStorage)==null||n.addMessages(this._messages.messageToElements.map(function(_ref9){var _ref0=_slicedToArray(_ref9,1),s=_ref0[0];return s;}))),this._hasStreamEnded=e);}}},{key:"markFileAdded",value:function markFileAdded(){this._fileAdded=!0;}// prettier-ignore
94
+ },{key:"endStreamAfterFileDownloaded",value:function(){var _endStreamAfterFileDownloaded=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(e,t){var _yield$t,n,s;return _regenerator().w(function(_context2){while(1)switch(_context2.n){case 0:this._endStreamAfterOperation=!0;_context2.n=1;return t();case 1:_yield$t=_context2.v;n=_yield$t.text;s=_yield$t.files;n&&this.updateBasedOnType(n,h,!0),this._endStreamAfterOperation=!1,this.finaliseStreamedMessage(),s&&e.addNewMessage(_defineProperty({},y,s));case 2:return _context2.a(2);}},_callee2,this);}));function endStreamAfterFileDownloaded(_x3,_x4){return _endStreamAfterFileDownloaded.apply(this,arguments);}return endStreamAfterFileDownloaded;}()}]);}();pt.MESSAGE_CLASS="streamed-message",pt.PARTIAL_RENDER_MARK="\n\n";var tt=pt;var P=/*#__PURE__*/function(){function P(){_classCallCheck(this,P);}return _createClass(P,null,[{key:"tempRemoveContentHeader",value:// need to pass stringifyBody boolean separately as binding is throwing an error for some reason
95
95
  // prettier-ignore
96
96
  function(){var _tempRemoveContentHeader=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(e,t,n){var s,i,_t3;return _regenerator().w(function(_context3){while(1)switch(_context3.p=_context3.n){case 0:if(e!=null&&e.headers){_context3.n=1;break;}throw new Error(Me);case 1:s=e.headers[D];delete e.headers[D];_context3.p=2;_context3.n=3;return t(n);case 3:i=_context3.v;_context3.n=5;break;case 4:_context3.p=4;_t3=_context3.v;throw e.headers[D]=s,_t3;case 5:return _context3.a(2,(e.headers[D]=s,i));}},_callee3,null,[[2,4]]);}));function tempRemoveContentHeader(_x9,_x0,_x1){return _tempRemoveContentHeader.apply(this,arguments);}return tempRemoveContentHeader;}()},{key:"displayError",value:function displayError(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"Service error, please try again.";if(console[f](t),_typeof(t)===B)return t instanceof Error?e.addNewErrorMessage(Q,t.message):Array.isArray(t)||typeof t[f]=="string"?e.addNewErrorMessage(Q,t):Object.keys(t).length===0?e.addNewErrorMessage(Q,n):e.addNewErrorMessage(Q,JSON.stringify(t));e.addNewErrorMessage(Q,t);}// eslint-disable-next-line @typescript-eslint/no-explicit-any
97
97
  },{key:"fetch",value:function(_fetch){function fetch(_x5,_x6,_x7,_x8){return _fetch.apply(this,arguments);}fetch.toString=function(){return _fetch.toString();};return fetch;}(function(e,t,n,s){var o,a;var i={method:((o=e.connectSettings)==null?void 0:o.method)||he,headers:t};return i.method!==ae&&(i.body=n?JSON.stringify(s):s),e.connectSettings.credentials&&(i.credentials=e.connectSettings.credentials),fetch(((a=e.connectSettings)==null?void 0:a.url)||e.url||"",i);})},{key:"processResponseByType",value:function processResponseByType(e){var t=e.headers.get("content-type");return t!=null&&t.includes(W)?e.json():t!=null&&t.includes("text/plain")||!t?e:e.blob();}},{key:"processRequestInterceptor",value:function(){var _processRequestInterceptor=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(e,t){var o,n,s,i,_t4;return _regenerator().w(function(_context4){while(1)switch(_context4.n){case 0:_context4.n=1;return(o=e.requestInterceptor)==null?void 0:o.call(e,t);case 1:_t4=_context4.v;if(_t4){_context4.n=2;break;}_t4=t;case 2:n=_t4;s=n;i=n;return _context4.a(2,{body:s.body,headers:s.headers,error:i[f]});}},_callee4);}));function processRequestInterceptor(_x10,_x11){return _processRequestInterceptor.apply(this,arguments);}return processRequestInterceptor;}()},{key:"validateResponseFormat",value:function validateResponseFormat(e,t){if(!e)return!1;var n=Array.isArray(e)?e:[e];return t&&n.length>1?(console[f](yo),!1):!n.find(function(i){return _typeof(i)!="object"||!(typeof i[f]=="string"||typeof i[h]=="string"||typeof i[M]=="string"||Array.isArray(i[y]));});}},{key:"onInterceptorError",value:function onInterceptorError(e,t,n){e.addNewErrorMessage(Q,t),n==null||n();}// prettier-ignore
98
- },{key:"basicResponseProcessing",value:function(){var _basicResponseProcessing=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(e,t){var n,s,_n$displayError,i,_n$useRI,o,a,l,c,d,_args5=arguments,_t5;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:n=_args5.length>2&&_args5[2]!==undefined?_args5[2]:{};s=n.io,_n$displayError=n.displayError,i=_n$displayError===void 0?!0:_n$displayError,_n$useRI=n.useRI,o=_n$useRI===void 0?!0:_n$useRI;if(s!=null&&s.extractResultData){_context5.n=1;break;}return _context5.a(2,t);case 1:a=o?s.deepChat.responseInterceptor:void 0;_context5.n=2;return a==null?void 0:a(t);case 2:_t5=_context5.v;if(_t5){_context5.n=3;break;}_t5=t;case 3:l=_t5;_context5.n=4;return s.extractResultData(l);case 4:c=_context5.v;if(!(!c||_typeof(c)!="object"&&!Array.isArray(c))){_context5.n=5;break;}if(i){d=un(t,"response",!!a,l);P.displayError(e,d);}return _context5.a(2);case 5:return _context5.a(2,c);}},_callee5);}));function basicResponseProcessing(_x12,_x13){return _basicResponseProcessing.apply(this,arguments);}return basicResponseProcessing;}()}]);}();function Zl(_x14,_x15){return _Zl.apply(this,arguments);}function _Zl(){_Zl=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee194(r,e){var t,n;return _regenerator().w(function(_context194){while(1)switch(_context194.n){case 0:t=r.getReader();case 1:_context194.n=2;return t.read();case 2:if((n=_context194.v).done){_context194.n=4;break;}e(n.value);case 3:_context194.n=1;break;case 4:return _context194.a(2);}},_callee194);}));return _Zl.apply(this,arguments);}function Yl(r){var e,t,n,s=!1;return function(o){e===void 0?(e=o,t=0,n=-1):e=ec(e,o);var a=e.length;var l=0;for(;t<a;){s&&(e[t]===10&&(l=++t),s=!1);var c=-1;for(;t<a&&c===-1;++t)switch(e[t]){case 58:n===-1&&(n=t-l);break;case 13:s=!0;case 10:c=t;break;}if(c===-1)break;r(e.subarray(l,c),n),l=t,n=-1;}l===a?e=void 0:l!==0&&(e=e.subarray(l),t-=l);};}function Ql(r,e,t){var n=Nr();var s=new TextDecoder();return function(o,a){if(o.length===0)t==null||t(n),n=Nr();else if(a>0){var l=s.decode(o.subarray(0,a)),c=a+(o[a+1]===32?2:1),d=s.decode(o.subarray(c));switch(l){case"data":n.data=n.data?n.data+"\n"+d:d;break;case"event":n.event=d;break;case"id":r(n.id=d);break;case"retry":var p=parseInt(d,10);isNaN(p)||e(n.retry=p);break;}}};}function ec(r,e){var t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t;}function Nr(){return{data:"",event:"",id:"",retry:void 0};}var tc=function tc(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t;};var Si="text/event-stream",nc=1e3,Pr="last-event-id";function sc(r,e){var t=e.signal,n=e.headers,s=e.onopen,i=e.onmessage,o=e.onclose,a=e.onerror,l=e.openWhenHidden,c=e.fetch,d=tc(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(function(p,u){var g=Object.assign({},n);g.accept||(g.accept=Si);var b;function v(){b.abort(),document.hidden||ve();}l||document.addEventListener("visibilitychange",v);var E=nc,C=0;function j(){document.removeEventListener("visibilitychange",v),window.clearTimeout(C),b.abort();}t==null||t.addEventListener("abort",function(){j(),p();});var X=c!==null&&c!==void 0?c:window.fetch,Z=s!==null&&s!==void 0?s:ic;function ve(){return _ve.apply(this,arguments);}function _ve(){_ve=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(){var St,xt,Be,_t6;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:b=new AbortController();_context6.p=1;_context6.n=2;return X(r,Object.assign(Object.assign({},d),{headers:g,signal:b.signal}));case 2:xt=_context6.v;_context6.n=3;return Z(xt);case 3:_context6.n=4;return Zl(xt.body,Yl(Ql(function(Be){Be?g[Pr]=Be:delete g[Pr];},function(Be){E=Be;},i)));case 4:o==null||o();j();p();_context6.n=6;break;case 5:_context6.p=5;_t6=_context6.v;if(!b.signal.aborted)try{Be=(St=a==null?void 0:a(_t6))!==null&&St!==void 0?St:E;window.clearTimeout(C),C=window.setTimeout(ve,Be);}catch(Be){j(),u(Be);}case 6:return _context6.a(2);}},_callee6,null,[[1,5]]);}));return _ve.apply(this,arguments);}ve();});}function ic(r){var e=r.headers.get("content-type");if(!(e!=null&&e.startsWith(Si)))throw new Error("Expected content-type to be ".concat(Si,", Actual: ").concat(e));}var U=/*#__PURE__*/function(){function U(){_classCallCheck(this,U);}return _createClass(U,null,[{key:"request",value:// prettier-ignore
98
+ },{key:"basicResponseProcessing",value:function(){var _basicResponseProcessing=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(e,t){var n,s,_n$displayError,i,_n$useRI,o,a,l,c,d,_args5=arguments,_t5;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:n=_args5.length>2&&_args5[2]!==undefined?_args5[2]:{};s=n.io,_n$displayError=n.displayError,i=_n$displayError===void 0?!0:_n$displayError,_n$useRI=n.useRI,o=_n$useRI===void 0?!0:_n$useRI;if(s!=null&&s.extractResultData){_context5.n=1;break;}return _context5.a(2,t);case 1:a=o?s.deepChat.responseInterceptor:void 0;_context5.n=2;return a==null?void 0:a(t);case 2:_t5=_context5.v;if(_t5){_context5.n=3;break;}_t5=t;case 3:l=_t5;_context5.n=4;return s.extractResultData(l);case 4:c=_context5.v;if(!(!c||_typeof(c)!="object"&&!Array.isArray(c))){_context5.n=5;break;}if(i){d=un(t,"response",!!a,l);P.displayError(e,d);}return _context5.a(2);case 5:return _context5.a(2,c);}},_callee5);}));function basicResponseProcessing(_x12,_x13){return _basicResponseProcessing.apply(this,arguments);}return basicResponseProcessing;}()}]);}();function Zl(_x14,_x15){return _Zl.apply(this,arguments);}function _Zl(){_Zl=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee194(r,e){var t,n;return _regenerator().w(function(_context194){while(1)switch(_context194.n){case 0:t=r.getReader();case 1:_context194.n=2;return t.read();case 2:if((n=_context194.v).done){_context194.n=4;break;}e(n.value);case 3:_context194.n=1;break;case 4:return _context194.a(2);}},_callee194);}));return _Zl.apply(this,arguments);}function Yl(r){var e,t,n,s=!1;return function(o){e===void 0?(e=o,t=0,n=-1):e=ec(e,o);var a=e.length;var l=0;for(;t<a;){s&&(e[t]===10&&(l=++t),s=!1);var c=-1;for(;t<a&&c===-1;++t)switch(e[t]){case 58:n===-1&&(n=t-l);break;case 13:s=!0;case 10:c=t;break;}if(c===-1)break;r(e.subarray(l,c),n),l=t,n=-1;}l===a?e=void 0:l!==0&&(e=e.subarray(l),t-=l);};}function Ql(r,e,t){var n=Nr();var s=new TextDecoder();return function(o,a){if(o.length===0)t==null||t(n),n=Nr();else if(a>0){var l=s.decode(o.subarray(0,a)),c=a+(o[a+1]===32?2:1),d=s.decode(o.subarray(c));switch(l){case"data":n.data=n.data?n.data+"\n"+d:d;break;case"event":n.event=d;break;case"id":r(n.id=d);break;case"retry":var p=parseInt(d,10);isNaN(p)||e(n.retry=p);break;}}};}function ec(r,e){var t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t;}function Nr(){return{data:"",event:"",id:"",retry:void 0};}var tc=function tc(r,e){var t={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(r);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(r,n[s])&&(t[n[s]]=r[n[s]]);return t;};var Si="text/event-stream",nc=1e3,Pr="last-event-id";function sc(r,e){var t=e.signal,n=e.headers,s=e.onopen,i=e.onmessage,o=e.onclose,a=e.onerror,l=e.openWhenHidden,c=e.fetch,d=tc(e,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(function(p,u){var g=Object.assign({},n);g.accept||(g.accept=Si);var b;function v(){b.abort(),document.hidden||ve();}l||document.addEventListener("visibilitychange",v);var E=nc,w=0;function j(){document.removeEventListener("visibilitychange",v),window.clearTimeout(w),b.abort();}t==null||t.addEventListener("abort",function(){j(),p();});var X=c!==null&&c!==void 0?c:window.fetch,Z=s!==null&&s!==void 0?s:ic;function ve(){return _ve.apply(this,arguments);}function _ve(){_ve=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(){var St,xt,Be,_t6;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:b=new AbortController();_context6.p=1;_context6.n=2;return X(r,Object.assign(Object.assign({},d),{headers:g,signal:b.signal}));case 2:xt=_context6.v;_context6.n=3;return Z(xt);case 3:_context6.n=4;return Zl(xt.body,Yl(Ql(function(Be){Be?g[Pr]=Be:delete g[Pr];},function(Be){E=Be;},i)));case 4:o==null||o();j();p();_context6.n=6;break;case 5:_context6.p=5;_t6=_context6.v;if(!b.signal.aborted)try{Be=(St=a==null?void 0:a(_t6))!==null&&St!==void 0?St:E;window.clearTimeout(w),w=window.setTimeout(ve,Be);}catch(Be){j(),u(Be);}case 6:return _context6.a(2);}},_callee6,null,[[1,5]]);}));return _ve.apply(this,arguments);}ve();});}function ic(r){var e=r.headers.get("content-type");if(!(e!=null&&e.startsWith(Si)))throw new Error("Expected content-type to be ".concat(Si,", Actual: ").concat(e));}var U=/*#__PURE__*/function(){function U(){_classCallCheck(this,U);}return _createClass(U,null,[{key:"request",value:// prettier-ignore
99
99
  function(){var _request=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(e,t,n){var s,i,u,g,b,v,E,o,_yield$P$processReque,a,l,c,d,p,_args7=arguments;return _regenerator().w(function(_context7){while(1)switch(_context7.n){case 0:s=_args7.length>3&&_args7[3]!==undefined?_args7[3]:!0;i=_args7.length>4&&_args7[4]!==undefined?_args7[4]:!1;o={body:t,headers:(u=e.connectSettings)==null?void 0:u.headers};_context7.n=1;return P.processRequestInterceptor(e.deepChat,o);case 1:_yield$P$processReque=_context7.v;a=_yield$P$processReque.body;l=_yield$P$processReque.headers;c=_yield$P$processReque.error;if(!c){_context7.n=2;break;}return _context7.a(2,P.onInterceptorError(n,c,e.streamHandlers.onClose));case 2:if(!((g=e.connectSettings)!=null&&g.handler)){_context7.n=3;break;}return _context7.a(2,et.stream(e,a,n));case 3:if(!(((b=e.connectSettings)==null?void 0:b.url)===st.URL)){_context7.n=4;break;}return _context7.a(2,st.requestStream(n,e));case 4:d=new tt(n,e.stream),p={method:((v=e.connectSettings)==null?void 0:v.method)||he,headers:l,credentials:(E=e.connectSettings)==null?void 0:E.credentials,body:s?JSON.stringify(a):a};return _context7.a(2,(_typeof(e.stream)=="object"&&e.stream.readable?U.handleReadableStream(e,n,d,p,i,a):U.handleEventStream(e,n,d,p,i,a),d));}},_callee7);}));function request(_x16,_x17,_x18){return _request.apply(this,arguments);}return request;}()// prettier-ignore
100
- },{key:"handleReadableStream",value:function handleReadableStream(e,t,n,s,i,o){var d;var _e$streamHandlers=e.streamHandlers,a=_e$streamHandlers.onOpen,l=_e$streamHandlers.onClose;var c=!1;fetch(((d=e.connectSettings)==null?void 0:d.url)||e.url||"",s).then(/*#__PURE__*/function(){var _ref1=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(p){var v,E,u,g,b,_yield$u$read,C,j,X,Z,ve,_t7;return _regenerator().w(function(_context8){while(1)switch(_context8.n){case 0:if(p.body){_context8.n=1;break;}throw new Error(la);case 1:u=p.body.getReader(),g=new TextDecoder();a();b=!1;case 2:if(!(!b&&!c)){_context8.n=8;break;}_context8.n=3;return u.read();case 3:_yield$u$read=_context8.v;C=_yield$u$read.value;j=_yield$u$read.done;if(!(b=j,b)){_context8.n=4;break;}U.handleClose(e,n,l,i);_context8.n=7;break;case 4:X=g.decode(C,{stream:!0});_context8.n=5;return(E=(v=e.deepChat).responseInterceptor)==null?void 0:E.call(v,X);case 5:_t7=_context8.v;if(_t7){_context8.n=6;break;}_t7=X;case 6:Z=_t7;ve=_typeof(Z)=="object"?Z:_defineProperty({},h,X);U.handleMessage(e,t,n,ve,o);case 7:_context8.n=2;break;case 8:return _context8.a(2);}},_callee8);}));return function(_x19){return _ref1.apply(this,arguments);};}())["catch"](function(p){U.handleError(e,t,p);}),e.streamHandlers.onAbort=function(){n.finaliseStreamedMessage(),e.streamHandlers.onClose(),c=!0;};}// prettier-ignore
100
+ },{key:"handleReadableStream",value:function handleReadableStream(e,t,n,s,i,o){var d;var _e$streamHandlers=e.streamHandlers,a=_e$streamHandlers.onOpen,l=_e$streamHandlers.onClose;var c=!1;fetch(((d=e.connectSettings)==null?void 0:d.url)||e.url||"",s).then(/*#__PURE__*/function(){var _ref1=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(p){var v,E,u,g,b,_yield$u$read,w,j,X,Z,ve,_t7;return _regenerator().w(function(_context8){while(1)switch(_context8.n){case 0:if(p.body){_context8.n=1;break;}throw new Error(la);case 1:u=p.body.getReader(),g=new TextDecoder();a();b=!1;case 2:if(!(!b&&!c)){_context8.n=8;break;}_context8.n=3;return u.read();case 3:_yield$u$read=_context8.v;w=_yield$u$read.value;j=_yield$u$read.done;if(!(b=j,b)){_context8.n=4;break;}U.handleClose(e,n,l,i);_context8.n=7;break;case 4:X=g.decode(w,{stream:!0});_context8.n=5;return(E=(v=e.deepChat).responseInterceptor)==null?void 0:E.call(v,X);case 5:_t7=_context8.v;if(_t7){_context8.n=6;break;}_t7=X;case 6:Z=_t7;ve=_typeof(Z)=="object"?Z:_defineProperty({},h,X);U.handleMessage(e,t,n,ve,o);case 7:_context8.n=2;break;case 8:return _context8.a(2);}},_callee8);}));return function(_x19){return _ref1.apply(this,arguments);};}())["catch"](function(p){U.handleError(e,t,p);}),e.streamHandlers.onAbort=function(){n.finaliseStreamedMessage(),e.streamHandlers.onClose(),c=!0;};}// prettier-ignore
101
101
  },{key:"handleEventStream",value:function handleEventStream(e,t,n,s,i,o){var d;var _e$streamHandlers2=e.streamHandlers,a=_e$streamHandlers2.onOpen,l=_e$streamHandlers2.onClose,c=new AbortController();e.streamHandlers.onAbort=function(){n.finaliseStreamedMessage(),e.streamHandlers.onClose(),c.abort();},sc(((d=e.connectSettings)==null?void 0:d.url)||e.url||"",_objectSpread(_objectSpread({},s),{},{openWhenHidden:!0,// keep stream open when browser tab not open
102
102
  onopen:function onopen(p){return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(){return _regenerator().w(function(_context9){while(1)switch(_context9.n){case 0:if(!p.ok){_context9.n=1;break;}return _context9.a(2,a());case 1:_context9.n=2;return P.processResponseByType(p);case 2:throw _context9.v;case 3:return _context9.a(2);}},_callee9);}))();},onmessage:function onmessage(p){return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(){var u,g,b,v,_t8;return _regenerator().w(function(_context0){while(1)switch(_context0.n){case 0:if(!(JSON.stringify(p.data)!==JSON.stringify("[DONE]"))){_context0.n=3;break;}try{b=JSON.parse(p.data);}catch(_unused6){b={};}_context0.n=1;return(g=(u=e.deepChat).responseInterceptor)==null?void 0:g.call(u,b);case 1:_t8=_context0.v;if(_t8){_context0.n=2;break;}_t8=b;case 2:v=_t8;U.handleMessage(e,t,n,v,o);case 3:return _context0.a(2);}},_callee0);}))();},onerror:function onerror(p){throw l(),p;},onclose:function onclose(){U.handleClose(e,n,l,i);},signal:c.signal}))["catch"](function(p){U.handleError(e,t,p);});}//prettier-ignore
103
103
  },{key:"handleMessage",value:function handleMessage(e,t,n,s,i){var o;(o=e.extractResultData)==null||o.call(e,s,i).then(function(a){U.upsertContent(t,n.upsertStreamedMessage.bind(n),n,a),t.removeError();})["catch"](function(a){t.isLastMessageError()||P.displayError(t,a);});}// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -110,12 +110,12 @@ onopen:function onopen(p){return _asyncToGenerator(/*#__PURE__*/_regenerator().m
110
110
  },{key:"isWebSocket",value:function isWebSocket(e){return e.send!==void 0;}},{key:"stream",value:function stream(e,t,n,s){if(!s)return;var i=e.stream.simulation;if(typeof i=="string"){var _n$o;var o=s.role||K,a=n[o];s[h]===i||s[M]===i?(a==null||a.finaliseStreamedMessage(),delete n[o]):((_n$o=n[o])!==null&&_n$o!==void 0?_n$o:n[o]=new tt(t,e.stream),n[o].upsertStreamedMessage(s));}else U.simulate(t,e.streamHandlers,s);}}]);}();var et=/*#__PURE__*/function(){function et(){_classCallCheck(this,et);}return _createClass(et,null,[{key:"request",value:function(){var _request2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(e,t,n){var a,l,s,i,o;return _regenerator().w(function(_context15){while(1)switch(_context15.n){case 0:s=!0;i=/*#__PURE__*/function(){var _ref15=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(c){var d,p,u;return _regenerator().w(function(_context14){while(1)switch(_context14.n){case 0:if(s){_context14.n=1;break;}return _context14.a(2);case 1:s=!1;_context14.n=2;return P.basicResponseProcessing(n,c,{io:e,displayError:!1});case 2:d=_context14.v;if(!d)console[f](un(c,"server",!!e.deepChat.responseInterceptor,d)),n.addNewErrorMessage(Q,"Error in server message"),e.completionsHandlers.onFinish();else{p=Array.isArray(d)?d:[d],u=p.find(function(g){return typeof g[f]=="string";});u?(console[f](u[f]),n.addNewErrorMessage(Q,u[f]),e.completionsHandlers.onFinish()):U.isSimulatable(e.stream,d)?U.simulate(n,e.streamHandlers,d):(p.forEach(function(g){return n.addNewMessage(g);}),e.completionsHandlers.onFinish());}case 3:return _context14.a(2);}},_callee14);}));return function i(_x38){return _ref15.apply(this,arguments);};}(),o=et.generateOptionalSignals();(l=(a=e.connectSettings).handler)==null||l.call(a,t,_objectSpread(_objectSpread({},o),{},{onResponse:i}));case 1:return _context15.a(2);}},_callee15);}));function request(_x35,_x36,_x37){return _request2.apply(this,arguments);}return request;}()},{key:"attemptToFinaliseStream",value:function attemptToFinaliseStream(e,t){try{var n=t.messageElementRefs[t.messageElementRefs.length-1];Je.isLoadingMessage(n)?t.removeLastMessage():e.finaliseStreamedMessage();}catch(n){console[f](n),t.addNewErrorMessage(Q,n);}}// prettier-ignore
111
111
  },{key:"stream",value:function stream(e,t,n){var p,u;var s=!0,i=!1;var o=new tt(n,e.stream),a=function a(){i||!s||(e.streamHandlers.onOpen(),i=!0);},l=function l(){s&&(et.attemptToFinaliseStream(o,n),e.streamHandlers.onClose(),s=!1);},c=/*#__PURE__*/function(){var _ref16=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(g){var b,v;return _regenerator().w(function(_context16){while(1)switch(_context16.n){case 0:if(s){_context16.n=1;break;}return _context16.a(2);case 1:_context16.n=2;return P.basicResponseProcessing(n,g,{io:e,displayError:!1});case 2:b=_context16.v;if(b)b[f]?(et.streamError(b[f],o,e,n),s=!1):U.upsertContent(n,o.upsertStreamedMessage.bind(o),o,b);else{v=un(g,"server",!!e.deepChat.responseInterceptor,b);et.streamError(v,o,e,n),s=!1;}case 3:return _context16.a(2);}},_callee16);}));return function c(_x39){return _ref16.apply(this,arguments);};}();e.streamHandlers.onAbort=function(){et.attemptToFinaliseStream(o,n),e.streamHandlers.onClose(),s=!1;};var d=et.generateOptionalSignals();(u=(p=e.connectSettings).handler)==null||u.call(p,t,_objectSpread(_objectSpread({},d),{},{onOpen:a,onResponse:c,onClose:l,stopClicked:e.streamHandlers.stopClicked}));}},{key:"streamError",value:function streamError(e,t,n,s){console[f](e),t.finaliseStreamedMessage(),s.addNewErrorMessage(Q,e),n.streamHandlers.onClose();}// prettier-ignore
112
112
  },{key:"websocket",value:function websocket(e,t){var _this10=this;var l,c;var n={isOpen:!1,newUserMessage:{listener:function listener(){}},roleToStream:{}};e.websocket=n;var s=function s(){t.removeError(),n.isOpen=!0;},i=function i(){n.isOpen=!1;},o=/*#__PURE__*/function(){var _ref17=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(d){var p,u,g,b,v,E;return _regenerator().w(function(_context17){while(1)switch(_context17.n){case 0:_context17.n=1;return P.basicResponseProcessing(t,d,{io:e,displayError:!1});case 1:p=_context17.v;if(!p)console[f](un(d,"server",!!e.deepChat.responseInterceptor,p)),t.addNewErrorMessage(Q,"Error in server message");else{u=Array.isArray(p)?p:[p],g=u.find(function(b){return typeof b[f]=="string";});if(g)console[f](g[f]),t.isLastMessageError()||t.addNewErrorMessage(Q,g[f]);else if(U.isSimulation(e.stream)){b=p,v=Se.stream.bind(_this10,e,t,n.roleToStream),E=n.roleToStream[b.role||K];U.upsertContent(t,v,E,b);}else u.forEach(function(b){return t.addNewMessage(b);});}case 2:return _context17.a(2);}},_callee17);}));return function o(_x40){return _ref17.apply(this,arguments);};}(),a=et.generateOptionalSignals();(c=(l=e.connectSettings).handler)==null||c.call(l,void 0,_objectSpread(_objectSpread({},a),{},{onOpen:s,onResponse:o,onClose:i,newUserMessage:n.newUserMessage}));}},{key:"generateOptionalSignals",value:function generateOptionalSignals(){return{onClose:function onClose(){},onOpen:function onOpen(){},stopClicked:{listener:function listener(){}},newUserMessage:{listener:function listener(){}}};}}]);}();var re=/*#__PURE__*/function(){function re(){_classCallCheck(this,re);}return _createClass(re,null,[{key:"request",value:// prettier-ignore
113
- function(){var _request3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(e,t,n){var s,p,u,g,i,_yield$P$processReque3,o,a,l,c,d,_args19=arguments;return _regenerator().w(function(_context19){while(1)switch(_context19.n){case 0:s=_args19.length>3&&_args19[3]!==undefined?_args19[3]:!0;i={body:t,headers:(p=e.connectSettings)==null?void 0:p.headers};_context19.n=1;return P.processRequestInterceptor(e.deepChat,i);case 1:_yield$P$processReque3=_context19.v;o=_yield$P$processReque3.body;a=_yield$P$processReque3.headers;l=_yield$P$processReque3.error;c=e.completionsHandlers.onFinish;if(!l){_context19.n=2;break;}return _context19.a(2,P.onInterceptorError(n,l,c));case 2:if(!((u=e.connectSettings)!=null&&u.handler)){_context19.n=3;break;}return _context19.a(2,et.request(e,o,n));case 3:if(!(((g=e.connectSettings)==null?void 0:g.url)===st.URL)){_context19.n=4;break;}return _context19.a(2,st.request(e,n));case 4:d=!0;P.fetch(e,a,s,o).then(function(b){return d=!!b.ok,b;}).then(function(b){return P.processResponseByType(b);}).then(/*#__PURE__*/function(){var _ref18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(b){var C,j,v,E,_t1;return _regenerator().w(function(_context18){while(1)switch(_context18.n){case 0:if(e.extractResultData){_context18.n=1;break;}return _context18.a(2);case 1:_context18.n=2;return(j=(C=e.deepChat).responseInterceptor)==null?void 0:j.call(C,b);case 2:_t1=_context18.v;if(_t1){_context18.n=3;break;}_t1=b;case 3:v=_t1;_context18.n=4;return e.extractResultData(v,o);case 4:E=_context18.v;if(d){_context18.n=5;break;}throw b;case 5:if(!(!E||_typeof(E)!==B&&!Array.isArray(E))){_context18.n=6;break;}throw Error(un(b,"response",!!e.deepChat.responseInterceptor,v));case 6:if(!E[f]){_context18.n=7;break;}throw E[f];case 7:if(!e.asyncCallInProgress){_context18.n=8;break;}e.asyncCallInProgress=!1;return _context18.a(2);case 8:U.isSimulatable(e.stream,E)?U.simulate(n,e.streamHandlers,E):((Array.isArray(E)?E:[E]).forEach(function(Z){return n.addNewMessage(Z);}),c());case 9:return _context18.a(2);}},_callee18);}));return function(_x44){return _ref18.apply(this,arguments);};}())["catch"](function(b){P.displayError(n,b),c();});case 5:return _context19.a(2);}},_callee19);}));function request(_x41,_x42,_x43){return _request3.apply(this,arguments);}return request;}()},{key:"executePollRequest",value:function executePollRequest(e,t,n,s){var i=e.completionsHandlers.onFinish;fetch(t,n).then(function(o){return o.json();}).then(/*#__PURE__*/function(){var _ref19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(o){var l,c,a,_t10,_t11;return _regenerator().w(function(_context20){while(1)switch(_context20.n){case 0:if(e.extractPollResultData){_context20.n=1;break;}return _context20.a(2);case 1:_t10=e;_context20.n=2;return(c=(l=e.deepChat).responseInterceptor)==null?void 0:c.call(l,o);case 2:_t11=_context20.v;if(_t11){_context20.n=3;break;}_t11=o;case 3:_context20.n=4;return _t10.extractPollResultData.call(_t10,_t11);case 4:a=_context20.v;a.timeoutMS?setTimeout(function(){re.executePollRequest(e,t,n,s);},a.timeoutMS):U.isSimulatable(e.stream,a)?U.simulate(s,e.streamHandlers,a):(s.addNewMessage(a),i());case 5:return _context20.a(2);}},_callee20);}));return function(_x45){return _ref19.apply(this,arguments);};}())["catch"](function(o){P.displayError(s,o),i();});}// prettier-ignore
113
+ function(){var _request3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(e,t,n){var s,p,u,g,i,_yield$P$processReque3,o,a,l,c,d,_args19=arguments;return _regenerator().w(function(_context19){while(1)switch(_context19.n){case 0:s=_args19.length>3&&_args19[3]!==undefined?_args19[3]:!0;i={body:t,headers:(p=e.connectSettings)==null?void 0:p.headers};_context19.n=1;return P.processRequestInterceptor(e.deepChat,i);case 1:_yield$P$processReque3=_context19.v;o=_yield$P$processReque3.body;a=_yield$P$processReque3.headers;l=_yield$P$processReque3.error;c=e.completionsHandlers.onFinish;if(!l){_context19.n=2;break;}return _context19.a(2,P.onInterceptorError(n,l,c));case 2:if(!((u=e.connectSettings)!=null&&u.handler)){_context19.n=3;break;}return _context19.a(2,et.request(e,o,n));case 3:if(!(((g=e.connectSettings)==null?void 0:g.url)===st.URL)){_context19.n=4;break;}return _context19.a(2,st.request(e,n));case 4:d=!0;P.fetch(e,a,s,o).then(function(b){return d=!!b.ok,b;}).then(function(b){return P.processResponseByType(b);}).then(/*#__PURE__*/function(){var _ref18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(b){var w,j,v,E,_t1;return _regenerator().w(function(_context18){while(1)switch(_context18.n){case 0:if(e.extractResultData){_context18.n=1;break;}return _context18.a(2);case 1:_context18.n=2;return(j=(w=e.deepChat).responseInterceptor)==null?void 0:j.call(w,b);case 2:_t1=_context18.v;if(_t1){_context18.n=3;break;}_t1=b;case 3:v=_t1;_context18.n=4;return e.extractResultData(v,o);case 4:E=_context18.v;if(d){_context18.n=5;break;}throw b;case 5:if(!(!E||_typeof(E)!==B&&!Array.isArray(E))){_context18.n=6;break;}throw Error(un(b,"response",!!e.deepChat.responseInterceptor,v));case 6:if(!E[f]){_context18.n=7;break;}throw E[f];case 7:if(!e.asyncCallInProgress){_context18.n=8;break;}e.asyncCallInProgress=!1;return _context18.a(2);case 8:U.isSimulatable(e.stream,E)?U.simulate(n,e.streamHandlers,E):((Array.isArray(E)?E:[E]).forEach(function(Z){return n.addNewMessage(Z);}),c());case 9:return _context18.a(2);}},_callee18);}));return function(_x44){return _ref18.apply(this,arguments);};}())["catch"](function(b){P.displayError(n,b),c();});case 5:return _context19.a(2);}},_callee19);}));function request(_x41,_x42,_x43){return _request3.apply(this,arguments);}return request;}()},{key:"executePollRequest",value:function executePollRequest(e,t,n,s){var i=e.completionsHandlers.onFinish;fetch(t,n).then(function(o){return o.json();}).then(/*#__PURE__*/function(){var _ref19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(o){var l,c,a,_t10,_t11;return _regenerator().w(function(_context20){while(1)switch(_context20.n){case 0:if(e.extractPollResultData){_context20.n=1;break;}return _context20.a(2);case 1:_t10=e;_context20.n=2;return(c=(l=e.deepChat).responseInterceptor)==null?void 0:c.call(l,o);case 2:_t11=_context20.v;if(_t11){_context20.n=3;break;}_t11=o;case 3:_context20.n=4;return _t10.extractPollResultData.call(_t10,_t11);case 4:a=_context20.v;a.timeoutMS?setTimeout(function(){re.executePollRequest(e,t,n,s);},a.timeoutMS):U.isSimulatable(e.stream,a)?U.simulate(s,e.streamHandlers,a):(s.addNewMessage(a),i());case 5:return _context20.a(2);}},_callee20);}));return function(_x45){return _ref19.apply(this,arguments);};}())["catch"](function(o){P.displayError(s,o),i();});}// prettier-ignore
114
114
  },{key:"poll",value:function(){var _poll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(e,t,n){var s,g,b,v,i,_yield$P$processReque4,o,a,l,c,d,p,u,_args21=arguments;return _regenerator().w(function(_context21){while(1)switch(_context21.n){case 0:s=_args21.length>3&&_args21[3]!==undefined?_args21[3]:!0;i={body:t,headers:(g=e.connectSettings)==null?void 0:g.headers};_context21.n=1;return P.processRequestInterceptor(e.deepChat,i);case 1:_yield$P$processReque4=_context21.v;o=_yield$P$processReque4.body;a=_yield$P$processReque4.headers;l=_yield$P$processReque4.error;if(!l){_context21.n=2;break;}return _context21.a(2,P.onInterceptorError(n,l));case 2:c=((b=e.connectSettings)==null?void 0:b.url)||e.url||"",d=((v=e.connectSettings)==null?void 0:v.method)||he,p=s?JSON.stringify(o):o,u={method:d,body:p,headers:a};e.connectSettings.credentials&&(u.credentials=e.connectSettings.credentials),re.executePollRequest(e,c,u,n);case 3:return _context21.a(2);}},_callee21);}));function poll(_x46,_x47,_x48){return _poll.apply(this,arguments);}return poll;}()// prettier-ignore
115
115
  },{key:"verifyKey",value:function verifyKey(e,t,n,s,i,o,a,l,c){if(e==="")return o(le);a(),fetch(t,{method:s,headers:n,body:c||null}).then(function(d){return P.processResponseByType(d);}).then(function(d){l(d,e,i,o);})["catch"](function(d){o(He),console[f](d);});}}]);}();var mn=/*#__PURE__*/function(){function mn(){_classCallCheck(this,mn);}return _createClass(mn,null,[{key:"getCharacterLimitMessages",value:function getCharacterLimitMessages(e,t){var i;if(t===-1)return e;var n=0,s=e.length-1;for(s;s>=0;s-=1){var o=(i=e[s])==null?void 0:i[h];if(o!==void 0&&(n+=o.length,n>t)){e[s][h]=o.substring(0,o.length-(n-t));break;}}return e.slice(Math.max(s,0));}},{key:"getMaxMessages",value:function getMaxMessages(e,t){return e.slice(Math.max(e.length-t,0));}// if maxMessages is not defined we send all messages
116
116
  // if maxMessages above 0 we send that number
117
117
  // if maxMessages 0 or below we send only what is in the request
118
- },{key:"processMessages",value:function processMessages(e,t,n){return t!==void 0?t>0&&(e=mn.getMaxMessages(e,t)):e=[e[e.length-1]],e=JSON.parse(JSON.stringify(e)),n===void 0?e:mn.getCharacterLimitMessages(e,n);}}]);}();var Ct=/*#__PURE__*/function(){function Ct(e,t,n){_classCallCheck(this,Ct);this._isLoading=!1,this._isPaginationComplete=!1,this._index=0,this._messages=t,n.fetchHistory&&this.fetchHistory(n.fetchHistory),this.setupInitialHistory(e);}return _createClass(Ct,[{key:"fetchHistory",value:function(){var _fetchHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(e){var _this11=this;var t,n;return _regenerator().w(function(_context22){while(1)switch(_context22.n){case 0:t=vt.addMessage(this._messages);_context22.n=1;return e();case 1:n=_context22.v;this._messages.removeMessage(t),Ct.displayIntroMessages(this._messages.messageElementRefs),n.forEach(function(s){return _this11._messages.addAnyMessage(s,!0);}),setTimeout(function(){return F.scrollToBottom(_this11._messages);},0);case 2:return _context22.a(2);}},_callee22,this);}));function fetchHistory(_x49){return _fetchHistory.apply(this,arguments);}return fetchHistory;}()},{key:"scrollToPreloadFirstEl",value:function scrollToPreloadFirstEl(e,t){this._messages.elementRef.scrollTop=t+e.offsetTop-40;}},{key:"processLoadedHistory",value:function processLoadedHistory(e){var _this12=this;var a;var _this$_messages=this._messages,t=_this$_messages.messageElementRefs,n=_this$_messages.messageToElements,s=_this$_messages.elementRef,i=(a=t.find(function(l){return!l.outerContainer[m].contains(Je.INTRO_CLASS);}))==null?void 0:a.outerContainer,o=s.scrollTop;e==null||e.reverse().map(function(l){var c=_this12._messages.addAnyMessage(_objectSpread(_objectSpread({},l),{},{sendUpdate:!0}),!0,!0);if(c){var d=N.generateMessageBody(c,t,!0);n.unshift([c,d]);}return c;}).filter(function(l){return!!l;}).reverse().forEach(function(l){return _this12._messages.sendClientUpdate(l,!0);}),i&&(this._messages.messageElementRefs.length>=this._messages.maxVisibleMessages?setTimeout(function(){return _this12.scrollToPreloadFirstEl(i,o);}):this.scrollToPreloadFirstEl(i,o));}},{key:"populateMessages",value:function populateMessages(e,t){this._messages.removeMessage(e),this._isPaginationComplete=t.findIndex(function(a){return!a;})<0;var n=t.filter(function(a){return!!a;});this.processLoadedHistory(n);var _this$_messages2=this._messages,s=_this$_messages2.messageElementRefs,i=_this$_messages2.avatar,o=_this$_messages2.name;N.resetAllRoleElements(s,i,o);}},{key:"loadHistoryOnScroll",value:function(){var _loadHistoryOnScroll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(e){var _this13=this;return _regenerator().w(function(_context24){while(1)switch(_context24.n){case 0:this._messages.elementRef.onscroll=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(){var t,n,_t12;return _regenerator().w(function(_context23){while(1)switch(_context23.p=_context23.n){case 0:if(!(!_this13._isLoading&&!_this13._isPaginationComplete&&_this13._messages.elementRef.scrollTop===0)){_context23.n=4;break;}_this13._isLoading=!0;t=vt.addMessage(_this13._messages,!1);_context23.p=1;_context23.n=2;return e(_this13._index++);case 2:n=_context23.v;_this13.populateMessages(t,n),_this13._isLoading=!1;_context23.n=4;break;case 3:_context23.p=3;_t12=_context23.v;_this13._messages.removeMessage(t),_this13._isPaginationComplete=!0,_this13._messages.addNewErrorMessage(Q,Ct.FAILED_ERROR_MESSAGE,!0),console[f](_t12);case 4:return _context23.a(2);}},_callee23,null,[[1,3]]);}));case 1:return _context24.a(2);}},_callee24,this);}));function loadHistoryOnScroll(_x50){return _loadHistoryOnScroll.apply(this,arguments);}return loadHistoryOnScroll;}()},{key:"populateInitialHistory",value:function populateInitialHistory(e){var _this14=this;e.forEach(function(t){ne.processHistoryFile(t),_this14._messages.addAnyMessage(t,!0);});}},{key:"loadInitialHistory",value:function(){var _loadInitialHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(e){var t,n,s,_t13;return _regenerator().w(function(_context25){while(1)switch(_context25.p=_context25.n){case 0:this._isLoading=!0;t=vt.addMessage(this._messages);_context25.p=1;_context25.n=2;return e(this._index++);case 2:n=_context25.v;s=this._messages.elementRef.scrollTop;this.populateMessages(t,n),this.restoreScrollOrScrollToBottom(s===0);_context25.n=4;break;case 3:_context25.p=3;_t13=_context25.v;this._messages.removeMessage(t),this._isPaginationComplete=!0,this._messages.addNewErrorMessage(Q,Ct.FAILED_ERROR_MESSAGE,!0),console[f](_t13);case 4:Ct.displayIntroMessages(this._messages.messageElementRefs),this._isLoading=!1;case 5:return _context25.a(2);}},_callee25,this,[[1,3]]);}));function loadInitialHistory(_x51){return _loadInitialHistory.apply(this,arguments);}return loadInitialHistory;}()},{key:"setupInitialHistory",value:function(){var _setupInitialHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(e){var s,t,n;return _regenerator().w(function(_context26){while(1)switch(_context26.n){case 0:e.loadHistory&&this.loadInitialHistory(e.loadHistory);t=(s=this._messages.browserStorage)==null?void 0:s.get(),n=e.history||ne.processHistory(e)||(t==null?void 0:t.messages);n&&(this.populateInitialHistory(n),this.restoreScrollOrScrollToBottom(!0),this._index+=1);case 1:return _context26.a(2);}},_callee26,this);}));function setupInitialHistory(_x52){return _setupInitialHistory.apply(this,arguments);}return setupInitialHistory;}()},{key:"restoreScrollOrScrollToBottom",value:function restoreScrollOrScrollToBottom(e){var _this15=this;var n,s,i;var t=(s=(n=this._messages.browserStorage)==null?void 0:n.get())==null?void 0:s.scrollHeight;t!==void 0&&(i=this._messages.browserStorage)!=null&&i.trackScrollHeight?setTimeout(function(){_this15._messages.elementRef.scrollTop=t;},0):e&&setTimeout(function(){return F.scrollToBottom(_this15._messages);},0);}}],[{key:"addErrorPrefix",value:function addErrorPrefix(e){var _e$permittedErrorPref;(_e$permittedErrorPref=e.permittedErrorPrefixes)!==null&&_e$permittedErrorPref!==void 0?_e$permittedErrorPref:e.permittedErrorPrefixes=[],e.permittedErrorPrefixes.push(Ct.FAILED_ERROR_MESSAGE);}},{key:"displayIntroMessages",value:function displayIntroMessages(e){for(var t=0;t<e.length;t+=1){var n=e[0];if(n.outerContainer[m].contains(Je.INTRO_CLASS))n.outerContainer[_].display="";else break;}}}]);}();Ct.FAILED_ERROR_MESSAGE="Failed to load history";var cs=Ct;var me=/*#__PURE__*/function(){function me(){_classCallCheck(this,me);}return _createClass(me,null,[{key:"parseConfig",value:function parseConfig(e,t,n){var i;var s={files:e};if(_typeof(n)=="object"){ne.processFileConfigConnect(n);var o=n.files,a=n.connect,l=n.button;o&&(o.infoModal&&(s[y].infoModal=o.infoModal,(i=o.infoModal)!=null&&i.textMarkDown&&(s.infoModalTextMarkUp=t.render(o.infoModal.textMarkDown))),o.acceptedFormats&&(s[y].acceptedFormats=o.acceptedFormats),o.maxNumberOfFiles&&(s[y].maxNumberOfFiles=o.maxNumberOfFiles)),s.button=l,a&&Object.keys(a).length>0&&(s.connect=a);}return s;}},{key:"processMixedFiles",value:function processMixedFiles(e,t,n){if(n){var s={acceptedFormats:""};e.fileTypes.mixedFiles=me.parseConfig(s,t,n);}}// needs to be set after audio to overwrite maxNumberOfFiles
118
+ },{key:"processMessages",value:function processMessages(e,t,n){return t!==void 0?t>0&&(e=mn.getMaxMessages(e,t)):e=[e[e.length-1]],e=JSON.parse(JSON.stringify(e)),n===void 0?e:mn.getCharacterLimitMessages(e,n);}}]);}();var wt=/*#__PURE__*/function(){function wt(e,t,n){_classCallCheck(this,wt);this._isLoading=!1,this._isPaginationComplete=!1,this._index=0,this._messages=t,n.fetchHistory&&this.fetchHistory(n.fetchHistory),this.setupInitialHistory(e);}return _createClass(wt,[{key:"fetchHistory",value:function(){var _fetchHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(e){var _this11=this;var t,n;return _regenerator().w(function(_context22){while(1)switch(_context22.n){case 0:t=vt.addMessage(this._messages);_context22.n=1;return e();case 1:n=_context22.v;this._messages.removeMessage(t),wt.displayIntroMessages(this._messages.messageElementRefs),n.forEach(function(s){return _this11._messages.addAnyMessage(s,!0);}),setTimeout(function(){return F.scrollToBottom(_this11._messages);},0);case 2:return _context22.a(2);}},_callee22,this);}));function fetchHistory(_x49){return _fetchHistory.apply(this,arguments);}return fetchHistory;}()},{key:"scrollToPreloadFirstEl",value:function scrollToPreloadFirstEl(e,t){this._messages.elementRef.scrollTop=t+e.offsetTop-40;}},{key:"processLoadedHistory",value:function processLoadedHistory(e){var _this12=this;var a;var _this$_messages=this._messages,t=_this$_messages.messageElementRefs,n=_this$_messages.messageToElements,s=_this$_messages.elementRef,i=(a=t.find(function(l){return!l.outerContainer[m].contains(Je.INTRO_CLASS);}))==null?void 0:a.outerContainer,o=s.scrollTop;e==null||e.reverse().map(function(l){var c=_this12._messages.addAnyMessage(_objectSpread(_objectSpread({},l),{},{sendUpdate:!0}),!0,!0);if(c){var d=N.generateMessageBody(c,t,!0);n.unshift([c,d]);}return c;}).filter(function(l){return!!l;}).reverse().forEach(function(l){return _this12._messages.sendClientUpdate(l,!0);}),i&&(this._messages.messageElementRefs.length>=this._messages.maxVisibleMessages?setTimeout(function(){return _this12.scrollToPreloadFirstEl(i,o);}):this.scrollToPreloadFirstEl(i,o));}},{key:"populateMessages",value:function populateMessages(e,t){this._messages.removeMessage(e),this._isPaginationComplete=t.findIndex(function(a){return!a;})<0;var n=t.filter(function(a){return!!a;});this.processLoadedHistory(n);var _this$_messages2=this._messages,s=_this$_messages2.messageElementRefs,i=_this$_messages2.avatar,o=_this$_messages2.name;N.resetAllRoleElements(s,i,o);}},{key:"loadHistoryOnScroll",value:function(){var _loadHistoryOnScroll=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee24(e){var _this13=this;return _regenerator().w(function(_context24){while(1)switch(_context24.n){case 0:this._messages.elementRef.onscroll=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23(){var t,n,_t12;return _regenerator().w(function(_context23){while(1)switch(_context23.p=_context23.n){case 0:if(!(!_this13._isLoading&&!_this13._isPaginationComplete&&_this13._messages.elementRef.scrollTop===0)){_context23.n=4;break;}_this13._isLoading=!0;t=vt.addMessage(_this13._messages,!1);_context23.p=1;_context23.n=2;return e(_this13._index++);case 2:n=_context23.v;_this13.populateMessages(t,n),_this13._isLoading=!1;_context23.n=4;break;case 3:_context23.p=3;_t12=_context23.v;_this13._messages.removeMessage(t),_this13._isPaginationComplete=!0,_this13._messages.addNewErrorMessage(Q,wt.FAILED_ERROR_MESSAGE,!0),console[f](_t12);case 4:return _context23.a(2);}},_callee23,null,[[1,3]]);}));case 1:return _context24.a(2);}},_callee24,this);}));function loadHistoryOnScroll(_x50){return _loadHistoryOnScroll.apply(this,arguments);}return loadHistoryOnScroll;}()},{key:"populateInitialHistory",value:function populateInitialHistory(e){var _this14=this;e.forEach(function(t){ne.processHistoryFile(t),_this14._messages.addAnyMessage(t,!0);});}},{key:"loadInitialHistory",value:function(){var _loadInitialHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee25(e){var t,n,s,_t13;return _regenerator().w(function(_context25){while(1)switch(_context25.p=_context25.n){case 0:this._isLoading=!0;t=vt.addMessage(this._messages);_context25.p=1;_context25.n=2;return e(this._index++);case 2:n=_context25.v;s=this._messages.elementRef.scrollTop;this.populateMessages(t,n),this.restoreScrollOrScrollToBottom(s===0);_context25.n=4;break;case 3:_context25.p=3;_t13=_context25.v;this._messages.removeMessage(t),this._isPaginationComplete=!0,this._messages.addNewErrorMessage(Q,wt.FAILED_ERROR_MESSAGE,!0),console[f](_t13);case 4:wt.displayIntroMessages(this._messages.messageElementRefs),this._isLoading=!1;case 5:return _context25.a(2);}},_callee25,this,[[1,3]]);}));function loadInitialHistory(_x51){return _loadInitialHistory.apply(this,arguments);}return loadInitialHistory;}()},{key:"setupInitialHistory",value:function(){var _setupInitialHistory=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee26(e){var s,t,n;return _regenerator().w(function(_context26){while(1)switch(_context26.n){case 0:e.loadHistory&&this.loadInitialHistory(e.loadHistory);t=(s=this._messages.browserStorage)==null?void 0:s.get(),n=e.history||ne.processHistory(e)||(t==null?void 0:t.messages);n&&(this.populateInitialHistory(n),this.restoreScrollOrScrollToBottom(!0),this._index+=1);case 1:return _context26.a(2);}},_callee26,this);}));function setupInitialHistory(_x52){return _setupInitialHistory.apply(this,arguments);}return setupInitialHistory;}()},{key:"restoreScrollOrScrollToBottom",value:function restoreScrollOrScrollToBottom(e){var _this15=this;var n,s,i;var t=(s=(n=this._messages.browserStorage)==null?void 0:n.get())==null?void 0:s.scrollHeight;t!==void 0&&(i=this._messages.browserStorage)!=null&&i.trackScrollHeight?setTimeout(function(){_this15._messages.elementRef.scrollTop=t;},0):e&&setTimeout(function(){return F.scrollToBottom(_this15._messages);},0);}}],[{key:"addErrorPrefix",value:function addErrorPrefix(e){var _e$permittedErrorPref;(_e$permittedErrorPref=e.permittedErrorPrefixes)!==null&&_e$permittedErrorPref!==void 0?_e$permittedErrorPref:e.permittedErrorPrefixes=[],e.permittedErrorPrefixes.push(wt.FAILED_ERROR_MESSAGE);}},{key:"displayIntroMessages",value:function displayIntroMessages(e){for(var t=0;t<e.length;t+=1){var n=e[0];if(n.outerContainer[m].contains(Je.INTRO_CLASS))n.outerContainer[_].display="";else break;}}}]);}();wt.FAILED_ERROR_MESSAGE="Failed to load history";var cs=wt;var me=/*#__PURE__*/function(){function me(){_classCallCheck(this,me);}return _createClass(me,null,[{key:"parseConfig",value:function parseConfig(e,t,n){var i;var s={files:e};if(_typeof(n)=="object"){ne.processFileConfigConnect(n);var o=n.files,a=n.connect,l=n.button;o&&(o.infoModal&&(s[y].infoModal=o.infoModal,(i=o.infoModal)!=null&&i.textMarkDown&&(s.infoModalTextMarkUp=t.render(o.infoModal.textMarkDown))),o.acceptedFormats&&(s[y].acceptedFormats=o.acceptedFormats),o.maxNumberOfFiles&&(s[y].maxNumberOfFiles=o.maxNumberOfFiles)),s.button=l,a&&Object.keys(a).length>0&&(s.connect=a);}return s;}},{key:"processMixedFiles",value:function processMixedFiles(e,t,n){if(n){var s={acceptedFormats:""};e.fileTypes.mixedFiles=me.parseConfig(s,t,n);}}// needs to be set after audio to overwrite maxNumberOfFiles
119
119
  // prettier-ignore
120
120
  },{key:"processMicrophone",value:function processMicrophone(e,t,n,s){var _l$y,_u$maxNumberOfFiles;var a,l,c,d,p,u;var o=_objectSpread({acceptedFormats:"audio/*"},((a=e.fileTypes[L])==null?void 0:a[y])||{});n&&(navigator.mediaDevices.getUserMedia!==void 0?(e.recordAudio=me.parseConfig(o,t,n),_typeof(n)=="object"&&n[y]&&((_l$y=(l=e.recordAudio)[y])!==null&&_l$y!==void 0?_l$y:l[y]={},e.recordAudio[y].format=(c=n[y])==null?void 0:c.format,e.recordAudio[y].maxDurationSeconds=(d=n[y])==null?void 0:d.maxDurationSeconds,(p=e.fileTypes[L])!=null&&p[y]&&((_u$maxNumberOfFiles=(u=e.fileTypes[L][y]).maxNumberOfFiles)!==null&&_u$maxNumberOfFiles!==void 0?_u$maxNumberOfFiles:u.maxNumberOfFiles=n[y].maxNumberOfFiles))):s||(e.fileTypes[L]=me.parseConfig(o,t,n)));}// prettier-ignore
121
121
  },{key:"processAudioConfig",value:function processAudioConfig(e,t,n,s){if(!n&&!s)return;var o=_objectSpread({acceptedFormats:"audio/*"},(s==null?void 0:s[y])||{});e.fileTypes[L]=me.parseConfig(o,t,n);}// prettier-ignore
@@ -130,10 +130,10 @@ function R(e,t,n,s,i){var _this16;_classCallCheck(this,R);var o;_this16=_callSup
130
130
  function ft(){var _this17;_classCallCheck(this,ft);_this17=_callSuper(this,ft),_this17._waitingToRender_=!1,_this17._propUpdated_=!1,Object.keys(ft._attributeToProperty_).forEach(function(e){var t=ft._attributeToProperty_[e];_this17.constructPropertyAccessors(t),_this17.hasOwnProperty(e)||_this17.constructPropertyAccessors(t,e);});return _this17;}_inherits(ft,_HTMLElement);return _createClass(ft,[{key:"constructPropertyAccessors",value:// need to be called here as accessors need to be set for the class instance
131
131
  function constructPropertyAccessors(e,t){var n;Object.defineProperty(this,t||e,{get:function get(){return n;},set:function set(o){n=o,t?this[e]=o:ks.attemptRender(this);}});}},{key:"attributeChangedCallback",value:function attributeChangedCallback(e,t,n){if(t===n)return;var s=ft._attributes_[e](n),i=ft._attributeToProperty_[e];this[i]=s;}},{key:"onRender",value:function onRender(){}}],[{key:"observedAttributes",get:function get(){return Object.keys(ft._attributes_)||[];}}]);}(/*#__PURE__*/_wrapNativeSuper(HTMLElement));ft._attributes_={},ft._attributeToProperty_={};var xi=ft;var rc="<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path d=\"\n\t\t\tM669.727,273.516c-22.891-2.476-46.15-3.895-69.727-4.248c-103.025,0.457-209.823,25.517-310.913,73.536\n\t\t\tc-75.058,37.122-148.173,89.529-211.67,154.174C46.232,529.978,6.431,577.76,0,628.74c0.76,44.162,48.153,98.67,77.417,131.764\n\t\t\tc59.543,62.106,130.754,113.013,211.67,154.174c2.75,1.335,5.51,2.654,8.276,3.955l-75.072,131.102l102.005,60.286l551.416-960.033\n\t\t\tl-98.186-60.008L669.727,273.516z M902.563,338.995l-74.927,129.857c34.47,44.782,54.932,100.006,54.932,159.888\n\t\t\tc0,149.257-126.522,270.264-282.642,270.264c-6.749,0-13.29-0.728-19.922-1.172l-49.585,85.84c22.868,2.449,45.99,4.233,69.58,4.541\n\t\t\tc103.123-0.463,209.861-25.812,310.84-73.535c75.058-37.122,148.246-89.529,211.743-154.174\n\t\t\tc31.186-32.999,70.985-80.782,77.417-131.764c-0.76-44.161-48.153-98.669-77.417-131.763\n\t\t\tc-59.543-62.106-130.827-113.013-211.743-154.175C908.108,341.478,905.312,340.287,902.563,338.995L902.563,338.995z\n\t\t\tM599.927,358.478c6.846,0,13.638,0.274,20.361,0.732l-58.081,100.561c-81.514,16.526-142.676,85.88-142.676,168.897\n\t\t\tc0,20.854,3.841,40.819,10.913,59.325c0.008,0.021-0.008,0.053,0,0.074l-58.228,100.854\n\t\t\tc-34.551-44.823-54.932-100.229-54.932-160.182C317.285,479.484,443.808,358.477,599.927,358.478L599.927,358.478z M768.896,570.513\n\t\t\tL638.013,797.271c81.076-16.837,141.797-85.875,141.797-168.603C779.81,608.194,775.724,588.729,768.896,570.513L768.896,570.513z\"\n\t\t\t/>\n</svg>\n",oc="<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path id=\"path6686\" inkscape:connector-curvature=\"0\" d=\"M779.843,599.925c0,95.331-80.664,172.612-180.169,172.612\n\t\t\tc-99.504,0-180.168-77.281-180.168-172.612c0-95.332,80.664-172.612,180.168-172.612\n\t\t\tC699.179,427.312,779.843,504.594,779.843,599.925z M600,240.521c-103.025,0.457-209.814,25.538-310.904,73.557\n\t\t\tc-75.058,37.122-148.206,89.496-211.702,154.141C46.208,501.218,6.431,549,0,599.981c0.76,44.161,48.13,98.669,77.394,131.763\n\t\t\tc59.543,62.106,130.786,113.018,211.702,154.179c94.271,45.751,198.616,72.092,310.904,73.557\n\t\t\tc103.123-0.464,209.888-25.834,310.866-73.557c75.058-37.122,148.243-89.534,211.74-154.179\n\t\t\tc31.185-32.999,70.962-80.782,77.394-131.763c-0.76-44.161-48.13-98.671-77.394-131.764\n\t\t\tc-59.543-62.106-130.824-112.979-211.74-154.141C816.644,268.36,712.042,242.2,600,240.521z M599.924,329.769\n\t\t\tc156.119,0,282.675,120.994,282.675,270.251c0,149.256-126.556,270.25-282.675,270.25S317.249,749.275,317.249,600.02\n\t\t\tC317.249,450.763,443.805,329.769,599.924,329.769L599.924,329.769z\"/>\n</svg>\n";var _t=/*#__PURE__*/function(){function _t(){_classCallCheck(this,_t);}return _createClass(_t,null,[{key:"createSVGElement",value:function createSVGElement(e){return new DOMParser().parseFromString(e,"image/svg+xml").documentElement;}}]);}();var Tt=/*#__PURE__*/function(){function Tt(){_classCallCheck(this,Tt);}return _createClass(Tt,null,[{key:"changeVisibility",value:// prettier-ignore
132
132
  function changeVisibility(e,t,n,s){s.target.id===Tt.VISIBLE_ICON_ID?(t[_].display="none",n[_].display="block",e.type="password"):(t[_].display="block",n[_].display="none",e.type=h);}},{key:"createIconElement",value:function createIconElement(e,t){var n=_t.createSVGElement(e);return n.id=t,n[m].add("visibility-icon"),n;}// prettier-ignore
133
- },{key:"create",value:function create(e){var t=S();t.id="visibility-icon-container";var n=Tt.createIconElement(oc,Tt.VISIBLE_ICON_ID);n[_].display="none",t.appendChild(n);var s=Tt.createIconElement(rc,"not-visible-icon");return t.appendChild(s),t.onclick=Tt.changeVisibility.bind(this,e,n,s),t;}}]);}();Tt.VISIBLE_ICON_ID="visible-icon";var Ai=Tt;var we=/*#__PURE__*/function(){function we(){_classCallCheck(this,we);}return _createClass(we,null,[{key:"createCautionText",value:function createCautionText(){var e=S("a");return e[m].add("insert-key-input-help-text"),e.innerText="Please exercise CAUTION when inserting your API key outside of deepchat.dev or localhost!!",e;}},{key:"createHelpLink",value:function createHelpLink(e){var t=S("a");return t[m].add("insert-key-input-help-text"),t.href=e,t.innerText="Find more info here",t.target="_blank",t;}},{key:"createFailText",value:function createFailText(){var e=S();return e.id="insert-key-input-invalid-text",e[_].display="none",e;}},{key:"createHelpTextContainer",value:function createHelpTextContainer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n=S();n.id="insert-key-help-text-container";var s=S();s.id="insert-key-help-text-contents";var i=we.createFailText();if(s.appendChild(i),e){var o=we.createHelpLink(e);s.appendChild(o);}if(t===!0){var _o3=we.createCautionText();s.appendChild(_o3);}return n.appendChild(s),{helpTextContainerElement:n,failTextElement:i};}},{key:"onFail",value:function onFail(e,t,n,s){e[m].replace("insert-key-input-valid","insert-key-input-invalid"),n.innerText=s,n[_].display="block",t.innerText="Start",e[m].remove("loading");}},{key:"onLoad",value:function onLoad(e,t){e[m].add("loading"),t.innerHTML='<div id="loading-key"></div>';}// prettier-ignore
133
+ },{key:"create",value:function create(e){var t=S();t.id="visibility-icon-container";var n=Tt.createIconElement(oc,Tt.VISIBLE_ICON_ID);n[_].display="none",t.appendChild(n);var s=Tt.createIconElement(rc,"not-visible-icon");return t.appendChild(s),t.onclick=Tt.changeVisibility.bind(this,e,n,s),t;}}]);}();Tt.VISIBLE_ICON_ID="visible-icon";var Ai=Tt;var Ce=/*#__PURE__*/function(){function Ce(){_classCallCheck(this,Ce);}return _createClass(Ce,null,[{key:"createCautionText",value:function createCautionText(){var e=S("a");return e[m].add("insert-key-input-help-text"),e.innerText="Please exercise CAUTION when inserting your API key outside of deepchat.dev or localhost!!",e;}},{key:"createHelpLink",value:function createHelpLink(e){var t=S("a");return t[m].add("insert-key-input-help-text"),t.href=e,t.innerText="Find more info here",t.target="_blank",t;}},{key:"createFailText",value:function createFailText(){var e=S();return e.id="insert-key-input-invalid-text",e[_].display="none",e;}},{key:"createHelpTextContainer",value:function createHelpTextContainer(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n=S();n.id="insert-key-help-text-container";var s=S();s.id="insert-key-help-text-contents";var i=Ce.createFailText();if(s.appendChild(i),e){var o=Ce.createHelpLink(e);s.appendChild(o);}if(t===!0){var _o3=Ce.createCautionText();s.appendChild(_o3);}return n.appendChild(s),{helpTextContainerElement:n,failTextElement:i};}},{key:"onFail",value:function onFail(e,t,n,s){e[m].replace("insert-key-input-valid","insert-key-input-invalid"),n.innerText=s,n[_].display="block",t.innerText="Start",e[m].remove("loading");}},{key:"onLoad",value:function onLoad(e,t){e[m].add("loading"),t.innerHTML='<div id="loading-key"></div>';}// prettier-ignore
134
134
  },{key:"verifyKey",value:function verifyKey(e,t,n){var s=e.value.trim();n.verifyKey(s,t);}// prettier-ignore
135
- },{key:"addVerificationEvents",value:function addVerificationEvents(e,t,n,s,i){var o={onSuccess:s,onFail:we.onFail.bind(this,e,t,n),onLoad:we.onLoad.bind(this,e,t)},a=we.verifyKey.bind(this,e,o,i);t.onclick=a,e.onkeydown=function(l){!e[m].contains("loading")&&l.key===de.ENTER&&a();};}},{key:"createStartButton",value:function createStartButton(){var e=S();return e.id="start-button",e.innerText="Start",e;}},{key:"onInputFocus",value:function onInputFocus(e){e.target[m].replace("insert-key-input-invalid","insert-key-input-valid");}},{key:"createInput",value:function createInput(e){var t=S();t.id="insert-key-input-container";var n=S("input");return n.id="insert-key-input",n.placeholder=e||"API Key",n.type="password",n[m].add("insert-key-input-valid"),n.onfocus=we.onInputFocus,t.appendChild(n),t;}// prettier-ignore
136
- },{key:"createContents",value:function createContents(e,t){var d;var n=S();n.id="insert-key-contents";var s=we.createInput(t.insertKeyPlaceholderText),i=s.children[0],o=Ai.create(i);s.appendChild(o),n.appendChild(s);var a=we.createStartButton(),_we$createHelpTextCon=we.createHelpTextContainer(t.keyHelpUrl,(d=t.deepChat._insertKeyViewStyles)==null?void 0:d.displayCautionText),l=_we$createHelpTextCon.helpTextContainerElement,c=_we$createHelpTextCon.failTextElement;return n.appendChild(a),n.appendChild(l),we.addVerificationEvents(i,a,c,e,t),n;}},{key:"createElements",value:function createElements(e,t){var n=S();n.id="insert-key-view";var s=we.createContents(e,t);return n.appendChild(s),n;}},{key:"render",value:function render(e,t,n){var s=we.createElements(t,n);e.replaceChildren(s);}}]);}();var De=/*#__PURE__*/function(){function De(){_classCallCheck(this,De);}return _createClass(De,null,[{key:"enableButtons",value:function enableButtons(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;window.webLLM?(e&&(e.disabled=!1),t&&(t.disabled=!1)):n<ds.MODULE_SEARCH_LIMIT_S*4&&setTimeout(function(){return De.enableButtons(e,t,n+1);},250);}// prettier-ignore
135
+ },{key:"addVerificationEvents",value:function addVerificationEvents(e,t,n,s,i){var o={onSuccess:s,onFail:Ce.onFail.bind(this,e,t,n),onLoad:Ce.onLoad.bind(this,e,t)},a=Ce.verifyKey.bind(this,e,o,i);t.onclick=a,e.onkeydown=function(l){!e[m].contains("loading")&&l.key===de.ENTER&&a();};}},{key:"createStartButton",value:function createStartButton(){var e=S();return e.id="start-button",e.innerText="Start",e;}},{key:"onInputFocus",value:function onInputFocus(e){e.target[m].replace("insert-key-input-invalid","insert-key-input-valid");}},{key:"createInput",value:function createInput(e){var t=S();t.id="insert-key-input-container";var n=S("input");return n.id="insert-key-input",n.placeholder=e||"API Key",n.type="password",n[m].add("insert-key-input-valid"),n.onfocus=Ce.onInputFocus,t.appendChild(n),t;}// prettier-ignore
136
+ },{key:"createContents",value:function createContents(e,t){var d;var n=S();n.id="insert-key-contents";var s=Ce.createInput(t.insertKeyPlaceholderText),i=s.children[0],o=Ai.create(i);s.appendChild(o),n.appendChild(s);var a=Ce.createStartButton(),_Ce$createHelpTextCon=Ce.createHelpTextContainer(t.keyHelpUrl,(d=t.deepChat._insertKeyViewStyles)==null?void 0:d.displayCautionText),l=_Ce$createHelpTextCon.helpTextContainerElement,c=_Ce$createHelpTextCon.failTextElement;return n.appendChild(a),n.appendChild(l),Ce.addVerificationEvents(i,a,c,e,t),n;}},{key:"createElements",value:function createElements(e,t){var n=S();n.id="insert-key-view";var s=Ce.createContents(e,t);return n.appendChild(s),n;}},{key:"render",value:function render(e,t,n){var s=Ce.createElements(t,n);e.replaceChildren(s);}}]);}();var De=/*#__PURE__*/function(){function De(){_classCallCheck(this,De);}return _createClass(De,null,[{key:"enableButtons",value:function enableButtons(e,t){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;window.webLLM?(e&&(e.disabled=!1),t&&(t.disabled=!1)):n<ds.MODULE_SEARCH_LIMIT_S*4&&setTimeout(function(){return De.enableButtons(e,t,n+1);},250);}// prettier-ignore
137
137
  },{key:"setUpInitial",value:function setUpInitial(e,t,n,s){var i=(t==null?void 0:t.downloadClass)||De.DOWNLOAD_BUTTON_CLASS,o=(t==null?void 0:t.uploadClass)||De.UPLOAD_BUTTON_CLASS,a=(t==null?void 0:t.fileInputClass)||De.FILE_INPUT_CLASS;return setTimeout(function(){var l=n==null?void 0:n.getElementsByClassName(i)[0],c=n==null?void 0:n.getElementsByClassName(a)[0],d=n==null?void 0:n.getElementsByClassName(o)[0];l&&(l.onclick=function(){return e();}),c&&(c.onchange=function(){c[y]&&c[y].length>0&&e(c[y]);}),d&&(d.onclick=function(){return c[z]();}),(l||d)&&De.enableButtons(l,d);}),(t==null?void 0:t.initialHtml)||"<div>\n Download or upload a web model that will run entirely on your browser: <br/> \n <button disabled class=\"".concat(i," deep-chat-button deep-chat-web-model-button\">Download</button>\n ").concat(s?"":"<input type=\"file\" class=\"".concat(a,"\" hidden multiple />\n <button disabled class=\"").concat(o," deep-chat-button deep-chat-web-model-button\">Upload</button>"),"\n </div>");}},{key:"exportFile",value:function exportFile(e){var t=S("a"),n=4;var _loop2=function _loop2(s){setTimeout(function(){var i=s*n;for(var o=i;o<Math.min(i+n,e.length);o+=1){var a=URL.createObjectURL(e[o]);t.href=a,t.download=e[o].name,document.body.appendChild(t),t[z](),URL.revokeObjectURL(a);}},500*s);};for(var s=0;s<e.length/n;s+=1){_loop2(s);}}// prettier-ignore
138
138
  },{key:"setUpAfterLoad",value:function setUpAfterLoad(e,t,n,s){var i=(t==null?void 0:t.exportFilesClass)||De.EXPORT_BUTTON_CLASS;return setTimeout(function(){var o=n==null?void 0:n.getElementsByClassName(i)[0];o&&(o.onclick=function(){return De.exportFile(e);});}),(t==null?void 0:t.afterLoadHtml)||"<div>\n Model loaded successfully and has been cached for future requests.\n ".concat(s?"":"<br/> <button style=\"margin-top: 5px\" class=\"".concat(i," deep-chat-button\">Export</button>"),"\n </div>");}}]);}();De.DOWNLOAD_BUTTON_CLASS="deep-chat-download-button",De.UPLOAD_BUTTON_CLASS="deep-chat-upload-button",De.FILE_INPUT_CLASS="deep-chat-file-input",De.EXPORT_BUTTON_CLASS="deep-chat-export-button";var Os=De;var Lr={model_list:[// Llama-2
139
139
  {model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f32_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f32_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f32_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:9109.03,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:6749.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:4618.52,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-13b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-13b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-13b-chat-hf/Llama-2-13b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:11814.09,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-70b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-70b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-70b-chat-hf/Llama-2-70b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:43729.05,low_resource_required:!1,required_features:["shader-f16"]},// RedPajama
@@ -153,7 +153,7 @@ function ii(e,t,n,s,i){var _this26;_classCallCheck(this,ii);_this26=_callSuper(t
153
153
  },{key:"callServiceAPI",value:function(){var _callServiceAPI6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee54(e,t,n){var o,a,s,i;return _regenerator().w(function(_context54){while(1)switch(_context54.n){case 0:if(this.connectSettings){_context54.n=1;break;}throw new Error(Me);case 1:if(!(!n||!n[0]||!n[1])){_context54.n=2;break;}throw new Error(Fi);case 2:s=(a=(o=t[t.length-1])==null?void 0:o[h])==null?void 0:a.trim(),i=this.createFormDataBody(this.rawBody,n[0],n[1],s);P.tempRemoveContentHeader(this.connectSettings,re.request.bind(this,this,i,e),!1);case 3:return _context54.a(2);}},_callee54,this);}));function callServiceAPI(_x120,_x121,_x122){return _callServiceAPI6.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee55(e){var t;return _regenerator().w(function(_context55){while(1)switch(_context55.n){case 0:if(!e.message){_context55.n=1;break;}throw e.message;case 1:t=e.artifacts.map(function(n){return _defineProperty(_defineProperty({},A,"".concat(bn).concat(n.base64)),T,q);});return _context55.a(2,_defineProperty({},y,t));}},_callee55);}));function extractResultData(_x123){return _extractResultData3.apply(this,arguments);}return extractResultData;}()}],[{key:"cleanConfig",value:function cleanConfig(e){delete e.engine_id,delete e.weight;}},{key:"canSendFileTextMessage",value:function canSendFileTextMessage(e,t){return!!(t!=null&&t[0])&&!!(e&&e.trim()!=="");}}]);}(ii);var pc=/*#__PURE__*/function(_ms3){function pc(e){_classCallCheck(this,pc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.audioSpeechRecognition,n=(o=e.directConnection)==null?void 0:o.huggingFace;return _callSuper(this,pc,[e,"Attach an audio ".concat(ee),"facebook/wav2vec2-large-960h-lv60-self",t,n,{audio:{}}]);}_inherits(pc,_ms3);return _createClass(pc,[{key:"extractPollResultData",value:function(){var _extractPollResultData3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee56(e){return _regenerator().w(function(_context56){while(1)switch(_context56.n){case 0:if(!e.estimated_time){_context56.n=1;break;}return _context56.a(2,{timeoutMS:(e.estimated_time+1)*1e3});case 1:if(!e[f]){_context56.n=2;break;}throw e[f];case 2:return _context56.a(2,_defineProperty({},h,e[h]||""));}},_callee56);}));function extractPollResultData(_x124){return _extractPollResultData3.apply(this,arguments);}return extractPollResultData;}()}]);}(ms);var fc=/*#__PURE__*/function(_Et2){function fc(e){_classCallCheck(this,fc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.textGeneration,n=(o=e.directConnection)==null?void 0:o.huggingFace;return _callSuper(this,fc,[e,"Once upon a time","gpt2",t,n]);}_inherits(fc,_Et2);return _createClass(fc,[{key:"extractResultData",value:function(){var _extractResultData4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee57(e){var t;return _regenerator().w(function(_context57){while(1)switch(_context57.n){case 0:if(!e[f]){_context57.n=1;break;}throw e[f];case 1:return _context57.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.generated_text)||""));}},_callee57);}));function extractResultData(_x125){return _extractResultData4.apply(this,arguments);}return extractResultData;}()}]);}(Et);var mc=/*#__PURE__*/function(_Et3){function mc(e){var _this29;_classCallCheck(this,mc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.questionAnswer,n=(o=e.directConnection)==null?void 0:o.huggingFace;_this29=_callSuper(this,mc,[e,"Ask a question","bert-large-uncased-whole-word-masking-finetuned-squad",t,n]),_this29.permittedErrorPrefixes=[Hi,"Error in"],_this29._context=t.context;return _this29;}_inherits(mc,_Et3);return _createClass(mc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h];if(n)return{inputs:{question:n,context:this._context,options:{wait_for_model:!0}}};}},{key:"extractResultData",value:function(){var _extractResultData5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee58(e){return _regenerator().w(function(_context58){while(1)switch(_context58.n){case 0:if(!e[f]){_context58.n=1;break;}throw e[f];case 1:return _context58.a(2,_defineProperty({},h,e.answer||""));}},_callee58);}));function extractResultData(_x126){return _extractResultData5.apply(this,arguments);}return extractResultData;}()}]);}(Et);var gc=/*#__PURE__*/function(_Et4){function gc(e){_classCallCheck(this,gc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.summarization,n=(o=e.directConnection)==null?void 0:o.huggingFace;return _callSuper(this,gc,[e,"Insert text to summarize","facebook/bart-large-cnn",t,n]);}_inherits(gc,_Et4);return _createClass(gc,[{key:"extractResultData",value:function(){var _extractResultData6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee59(e){var t;return _regenerator().w(function(_context59){while(1)switch(_context59.n){case 0:if(!e[f]){_context59.n=1;break;}throw e[f];case 1:return _context59.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.summary_text)||""));}},_callee59);}));function extractResultData(_x127){return _extractResultData6.apply(this,arguments);}return extractResultData;}()}]);}(Et);var yc=/*#__PURE__*/function(_Et5){function yc(e){var _this30$maxMessages;var _this30;_classCallCheck(this,yc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.conversation,n=(o=e.directConnection)==null?void 0:o.huggingFace;_this30=_callSuper(this,yc,[e,"Ask me anything!","facebook/blenderbot-400M-distill",t,n]),(_this30$maxMessages=_this30.maxMessages)!==null&&_this30$maxMessages!==void 0?_this30$maxMessages:_this30.maxMessages=-1;return _this30;}// prettier-ignore
154
154
  _inherits(yc,_Et5);return _createClass(yc,[{key:"processMessagesI",value:function processMessagesI(e){var t=e.filter(function(a){return a[h];}),n=t[t.length-1][h],s=t.slice(0,t.length-1);if(!n)return;var i=s.filter(function(a){return a.role===H;}).map(function(a){return a[h];}),o=s.filter(function(a){return a.role===K;}).map(function(a){return a[h];});return{past_user_inputs:i,generated_responses:o,mostRecentMessageText:n};}// prettier-ignore
155
155
  },{key:"preprocessBody",value:function preprocessBody(e,t){var _n$options;var n=JSON.parse(JSON.stringify(e)),s=this.processMessagesI(t);if(s)return(_n$options=n.options)!==null&&_n$options!==void 0?_n$options:n.options={},n.options.wait_for_model=!0,_objectSpread({inputs:_defineProperty({past_user_inputs:s.past_user_inputs,generated_responses:s.generated_responses},h,s.mostRecentMessageText)},n);}},{key:"extractResultData",value:function(){var _extractResultData7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee60(e){return _regenerator().w(function(_context60){while(1)switch(_context60.n){case 0:if(!e[f]){_context60.n=1;break;}throw e[f];case 1:return _context60.a(2,_defineProperty({},h,e.generated_text||""));}},_callee60);}));function extractResultData(_x128){return _extractResultData7.apply(this,arguments);}return extractResultData;}()}]);}(Et);var Ls=/*#__PURE__*/function(_ii3){function Ls(e){var _this31;_classCallCheck(this,Ls);var o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.stabilityAI,s=_defineProperty({},J,_defineProperty({},y,{acceptedFormats:".png",maxNumberOfFiles:1}));_this31=_callSuper(this,Ls,[e,si(),ni,n,s]),_this31.url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/image-to-image",_this31.textInputPlaceholderText="Describe image changes";var i=(o=t.stabilityAI)==null?void 0:o.imageToImage;_typeof(i)=="object"&&(i.engine_id&&(_this31.url="https://api.stability.ai/v1/generation/".concat(i.engine_id,"/text-to-image")),i.weight!==void 0&&i.weight!==null&&(_this31._imageWeight=i.weight),Ls.cleanConfig(i),Object.assign(_this31.rawBody,i)),_this31.canSendMessage=Ls.canSendFileTextMessage;return _this31;}_inherits(Ls,_ii3);return _createClass(Ls,[{key:"createFormDataBody",value:function createFormDataBody(e,t,n){var s=new FormData();return s.append("init_image",t),n&&n!==""&&s.append("text_prompts[0][text]",n),this._imageWeight!==void 0&&this._imageWeight!==null&&s.append("text_prompts[0][weight]",String(this._imageWeight)),Object.keys(e).forEach(function(i){s.append(i,String(e[i]));}),s.get("weight")===void 0&&s.append("weight",String(1)),s;}// prettier-ignore
156
- },{key:"callServiceAPI",value:function(){var _callServiceAPI7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(e,t,n){var o,a,s,i;return _regenerator().w(function(_context61){while(1)switch(_context61.n){case 0:if(this.connectSettings){_context61.n=1;break;}throw new Error(Me);case 1:if(n){_context61.n=2;break;}throw new Error(Fi);case 2:s=(a=(o=t[t.length-1])==null?void 0:o[h])==null?void 0:a.trim(),i=this.createFormDataBody(this.rawBody,n[0],s);P.tempRemoveContentHeader(this.connectSettings,re.request.bind(this,this,i,e),!1);case 3:return _context61.a(2);}},_callee61,this);}));function callServiceAPI(_x129,_x130,_x131){return _callServiceAPI7.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData8=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(e){var t;return _regenerator().w(function(_context62){while(1)switch(_context62.n){case 0:if(!e.message){_context62.n=1;break;}throw e.message;case 1:t=e.artifacts.map(function(n){return _defineProperty(_defineProperty({},A,"".concat(bn).concat(n.base64)),T,q);});return _context62.a(2,_defineProperty({},y,t));}},_callee62);}));function extractResultData(_x132){return _extractResultData8.apply(this,arguments);}return extractResultData;}()}],[{key:"cleanConfig",value:function cleanConfig(e){delete e.engine_id,delete e.weight;}},{key:"canSendFileTextMessage",value:function canSendFileTextMessage(e,t){return!!(t!=null&&t[0])&&!!(e&&e.trim()!=="");}}]);}(ii);var bc=/*#__PURE__*/function(_Et6){function bc(e){_classCallCheck(this,bc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.translation,n=(o=e.directConnection)==null?void 0:o.huggingFace;return _callSuper(this,bc,[e,"Insert text to translate","Helsinki-NLP/opus-tatoeba-en-ja",t,n]);}_inherits(bc,_Et6);return _createClass(bc,[{key:"extractResultData",value:function(){var _extractResultData9=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(e){var t;return _regenerator().w(function(_context63){while(1)switch(_context63.n){case 0:if(!e[f]){_context63.n=1;break;}throw e[f];case 1:return _context63.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.translation_text)||""));}},_callee63);}));function extractResultData(_x133){return _extractResultData9.apply(this,arguments);}return extractResultData;}()}]);}(Et);var Bs=/*#__PURE__*/function(_ii4){function Bs(e){var _this32;_classCallCheck(this,Bs);var i;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.stabilityAI;_this32=_callSuper(this,Bs,[e,si(),ni,n]),_this32.url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image",_this32.textInputPlaceholderText="Describe an image";var s=(i=t.stabilityAI)==null?void 0:i.textToImage;_typeof(s)=="object"&&(s.engine_id&&(_this32.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/text-to-image")),s.weight!==void 0&&s.weight!==null&&(_this32._imageWeight=s.weight),Bs.cleanConfig(s),Object.assign(_this32.rawBody,s)),_this32.canSendMessage=Bs.canSendTextMessage;return _this32;}_inherits(Bs,_ii4);return _createClass(Bs,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h],s=JSON.parse(JSON.stringify(e)),i=_defineProperty({},h,n);return this._imageWeight&&(i.weight=this._imageWeight),s.text_prompts=[i],s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI8=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(e,t){return _regenerator().w(function(_context64){while(1)switch(_context64.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context64.a(2);}},_callee64,this);}));function callServiceAPI(_x134,_x135){return _callServiceAPI8.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData0=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(e){var t;return _regenerator().w(function(_context65){while(1)switch(_context65.n){case 0:if(!e.message){_context65.n=1;break;}throw e.message;case 1:t=e.artifacts.map(function(n){return _defineProperty(_defineProperty({},A,"".concat(bn).concat(n.base64)),T,q);});return _context65.a(2,_defineProperty({},y,t));}},_callee65);}));function extractResultData(_x136){return _extractResultData0.apply(this,arguments);}return extractResultData;}()}],[{key:"cleanConfig",value:function cleanConfig(e){delete e.engine_id,delete e.weight;}},{key:"canSendTextMessage",value:function canSendTextMessage(e){return!!(e&&e.trim()!=="");}}]);}(ii);var vc=/*#__PURE__*/function(_Et7){function vc(e){var _this33;_classCallCheck(this,vc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.fillMask,n=(o=e.directConnection)==null?void 0:o.huggingFace;_this33=_callSuper(this,vc,[e,"The goal of life is [MASK].","bert-base-uncased",t,n]),_this33.permittedErrorPrefixes=[Hi,"No mask_token"];return _this33;}_inherits(vc,_Et7);return _createClass(vc,[{key:"extractResultData",value:function(){var _extractResultData1=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(e){var t;return _regenerator().w(function(_context66){while(1)switch(_context66.n){case 0:if(!e[f]){_context66.n=1;break;}throw e[f];case 1:return _context66.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.sequence)||""));}},_callee66);}));function extractResultData(_x137){return _extractResultData1.apply(this,arguments);}return extractResultData;}()}]);}(Et);var Vi=function Vi(r){return _defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(r));},_c=function _c(r,e,t,n){var s=r;s[f]?s[f].message===Ui?n(le):n(He):t(e);},Ji=function Ji(){return ce("https://open.bigmodel.cn/api/paas/v4/models",ae,_c);};var Ec=/*#__PURE__*/function(_R3){function Ec(e){var _o$model,_a$voice;var _this34;_classCallCheck(this,Ec);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.bigModel;_this34=_callSuper(this,Ec,[e,Ji(),Vi,n]),_this34.insertKeyPlaceholderText=_this34.genereteAPIKeyName("BigModel"),_this34.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this34.url="https://open.bigmodel.cn/api/paas/v4/audio/speech",_this34.permittedErrorPrefixes=[oe,be];var s=(i=t.bigModel)==null?void 0:i.textToSpeech;_typeof(s)===B&&(_this34.cleanConfig(s),Object.assign(_this34.rawBody,s)),(_o$model=(o=_this34.rawBody).model)!==null&&_o$model!==void 0?_o$model:o.model="cogtts",(_a$voice=(a=_this34.rawBody).voice)!==null&&_a$voice!==void 0?_a$voice:a.voice="tongtong";return _this34;}_inherits(Ec,_R3);return _createClass(Ec,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.input=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI9=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(e,t){return _regenerator().w(function(_context67){while(1)switch(_context67.n){case 0:return _context67.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee67,this);}));function callServiceAPI(_x138,_x139){return _callServiceAPI9.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData10=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(e){var t,n;return _regenerator().w(function(_context68){while(1)switch(_context68.n){case 0:t=new Blob([e],_defineProperty({},T,"audio/mpeg")),n=URL.createObjectURL(t);return _context68.a(2,_defineProperty({},y,[_defineProperty(_defineProperty({},A,n),T,L)]));}},_callee68);}));function extractResultData(_x140){return _extractResultData10.apply(this,arguments);}return extractResultData;}()}]);}(R);var Wi=function Wi(r){return _defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(r));},Sc=function Sc(r,e,t,n){var s=r;s[f]?s[f].message===Ui?n(le):n(He):t(e);},Ki=function Ki(){return ce("https://api.together.xyz/v1/models",ae,Sc);};var xc=/*#__PURE__*/function(_R4){function xc(e){var _o$model2,_a$voice2;var _this35;_classCallCheck(this,xc);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.together;_this35=_callSuper(this,xc,[e,Ki(),Wi,n]),_this35.insertKeyPlaceholderText=_this35.genereteAPIKeyName("Together AI"),_this35.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this35.url="https://api.together.xyz/v1/audio/speech",_this35.permittedErrorPrefixes=[We,be];var s=(i=t.together)==null?void 0:i.textToSpeech;_typeof(s)===B&&_this35.completeConfig(s),(_o$model2=(o=_this35.rawBody).model)!==null&&_o$model2!==void 0?_o$model2:o.model="cartesia/sonic",(_a$voice2=(a=_this35.rawBody).voice)!==null&&_a$voice2!==void 0?_a$voice2:a.voice="laidback woman";return _this35;}_inherits(xc,_R4);return _createClass(xc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.input=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI0=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(e,t){return _regenerator().w(function(_context69){while(1)switch(_context69.n){case 0:return _context69.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee69,this);}));function callServiceAPI(_x141,_x142){return _callServiceAPI0.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData11=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(e){var t,n;return _regenerator().w(function(_context70){while(1)switch(_context70.n){case 0:t=new Blob([e],_defineProperty({},T,"audio/mpeg")),n=URL.createObjectURL(t);return _context70.a(2,_defineProperty({},y,[_defineProperty(_defineProperty({},A,n),T,L)]));}},_callee70);}));function extractResultData(_x143){return _extractResultData11.apply(this,arguments);}return extractResultData;}()}]);}(R);var Le="https://api.openai.com/v1/",vn="https://platform.openai.com/account/api-keys",wi="input_text",Br="input_image",Dr="output_text",gi="image_generation_call",Oo="function_call_output",xn="response",_n=function _n(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},No=function No(r,e,t,n){var s=r;s[f]?s[f].code==="invalid_api_key"?n(le):n(He):t(e);},En=function En(){return ce("".concat(Le,"models"),ae,No);},It=/*#__PURE__*/function(){var _ref54=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(r,e,t){var n,s,i,o,a,l,_yield$P$processReque6,c,d,p,u,g,_args71=arguments;return _regenerator().w(function(_context71){while(1)switch(_context71.n){case 0:n=_args71.length>3&&_args71[3]!==undefined?_args71[3]:!0;s=r.connectSettings,i=r.deepChat,o=r.completionsHandlers,a=r.messages;s.method=t;l={body:e,headers:s.headers};_context71.n=1;return P.processRequestInterceptor(i,l);case 1:_yield$P$processReque6=_context71.v;c=_yield$P$processReque6.body;d=_yield$P$processReque6.headers;p=_yield$P$processReque6.error;u=o.onFinish;if(!(p&&a)){_context71.n=2;break;}return _context71.a(2,P.onInterceptorError(a,p,u));case 2:_context71.n=3;return P.fetch(r,d,n,c).then(function(b){return P.processResponseByType(b);});case 3:g=_context71.v;if(!g[f]){_context71.n=4;break;}throw g[f].message;case 4:return _context71.a(2,g);}},_callee71);}));return function It(_x144,_x145,_x146){return _ref54.apply(this,arguments);};}(),Fe=/*#__PURE__*/function(){function Fe(){_classCallCheck(this,Fe);}return _createClass(Fe,null,[{key:"storeFiles",value:function(){var _storeFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(e,t,n,s){var i,o,a,l,_t24;return _regenerator().w(function(_context73){while(1)switch(_context73.p=_context73.n){case 0:i=e.connectSettings.headers;if(i){_context73.n=1;break;}return _context73.a(2);case 1:e.url=s;o=i[D];delete i[D];a=n.map(/*#__PURE__*/function(){var _ref55=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(l){var c;return _regenerator().w(function(_context72){while(1)switch(_context72.n){case 0:c=new FormData();return _context72.a(2,(c.append("purpose","assistants"),c.append("file",l),new Promise(function(d){d(It(e,c,he,!1));})));}},_callee72);}));return function(_x151){return _ref55.apply(this,arguments);};}());_context73.p=2;_context73.n=3;return Promise.all(a);case 3:l=_context73.v.map(function(c){return{id:c.id,name:c.filename};});return _context73.a(2,(i[D]=o,l));case 4:_context73.p=4;_t24=_context73.v;throw i[D]=o,P.displayError(t,_t24),e.completionsHandlers.onFinish(),_t24;case 5:return _context73.a(2);}},_callee73,null,[[2,4]]);}));function storeFiles(_x147,_x148,_x149,_x150){return _storeFiles.apply(this,arguments);}return storeFiles;}()},{key:"getType",value:function getType(e,t){var n=e[t].path;return!n||n.endsWith("png")?q:Vt;}},{key:"getFiles",value:function(){var _getFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(e,t,n,s){var i,a;return _regenerator().w(function(_context74){while(1)switch(_context74.n){case 0:i=t.map(function(_ref56){var l=_ref56.fileId;return e.url="".concat(n).concat(l).concat(s),new Promise(function(c){c(It(e,void 0,"GET",!1));});});_context74.n=1;return Promise.all(i);case 1:a=_context74.v.map(function(l,c){return new Promise(function(d){var p=new FileReader();p.readAsDataURL(l),p.onload=function(u){d(_defineProperty(_defineProperty(_defineProperty({},A,u.target.result),"name",t[c].name),T,Fe.getType(t,c)));};});});_context74.n=2;return Promise.all(a);case 2:return _context74.a(2,_context74.v);}},_callee74);}));function getFiles(_x152,_x153,_x154,_x155){return _getFiles.apply(this,arguments);}return getFiles;}()},{key:"getFileName",value:function getFileName(e){var t=e.split("/");return t[t.length-1];}// prettier-ignore
156
+ },{key:"callServiceAPI",value:function(){var _callServiceAPI7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee61(e,t,n){var o,a,s,i;return _regenerator().w(function(_context61){while(1)switch(_context61.n){case 0:if(this.connectSettings){_context61.n=1;break;}throw new Error(Me);case 1:if(n){_context61.n=2;break;}throw new Error(Fi);case 2:s=(a=(o=t[t.length-1])==null?void 0:o[h])==null?void 0:a.trim(),i=this.createFormDataBody(this.rawBody,n[0],s);P.tempRemoveContentHeader(this.connectSettings,re.request.bind(this,this,i,e),!1);case 3:return _context61.a(2);}},_callee61,this);}));function callServiceAPI(_x129,_x130,_x131){return _callServiceAPI7.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData8=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee62(e){var t;return _regenerator().w(function(_context62){while(1)switch(_context62.n){case 0:if(!e.message){_context62.n=1;break;}throw e.message;case 1:t=e.artifacts.map(function(n){return _defineProperty(_defineProperty({},A,"".concat(bn).concat(n.base64)),T,q);});return _context62.a(2,_defineProperty({},y,t));}},_callee62);}));function extractResultData(_x132){return _extractResultData8.apply(this,arguments);}return extractResultData;}()}],[{key:"cleanConfig",value:function cleanConfig(e){delete e.engine_id,delete e.weight;}},{key:"canSendFileTextMessage",value:function canSendFileTextMessage(e,t){return!!(t!=null&&t[0])&&!!(e&&e.trim()!=="");}}]);}(ii);var bc=/*#__PURE__*/function(_Et6){function bc(e){_classCallCheck(this,bc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.translation,n=(o=e.directConnection)==null?void 0:o.huggingFace;return _callSuper(this,bc,[e,"Insert text to translate","Helsinki-NLP/opus-tatoeba-en-ja",t,n]);}_inherits(bc,_Et6);return _createClass(bc,[{key:"extractResultData",value:function(){var _extractResultData9=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee63(e){var t;return _regenerator().w(function(_context63){while(1)switch(_context63.n){case 0:if(!e[f]){_context63.n=1;break;}throw e[f];case 1:return _context63.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.translation_text)||""));}},_callee63);}));function extractResultData(_x133){return _extractResultData9.apply(this,arguments);}return extractResultData;}()}]);}(Et);var Bs=/*#__PURE__*/function(_ii4){function Bs(e){var _this32;_classCallCheck(this,Bs);var i;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.stabilityAI;_this32=_callSuper(this,Bs,[e,si(),ni,n]),_this32.url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image",_this32.textInputPlaceholderText="Describe an image";var s=(i=t.stabilityAI)==null?void 0:i.textToImage;_typeof(s)=="object"&&(s.engine_id&&(_this32.url="https://api.stability.ai/v1/generation/".concat(s.engine_id,"/text-to-image")),s.weight!==void 0&&s.weight!==null&&(_this32._imageWeight=s.weight),Bs.cleanConfig(s),Object.assign(_this32.rawBody,s)),_this32.canSendMessage=Bs.canSendTextMessage;return _this32;}_inherits(Bs,_ii4);return _createClass(Bs,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h],s=JSON.parse(JSON.stringify(e)),i=_defineProperty({},h,n);return this._imageWeight&&(i.weight=this._imageWeight),s.text_prompts=[i],s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI8=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee64(e,t){return _regenerator().w(function(_context64){while(1)switch(_context64.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context64.a(2);}},_callee64,this);}));function callServiceAPI(_x134,_x135){return _callServiceAPI8.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData0=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee65(e){var t;return _regenerator().w(function(_context65){while(1)switch(_context65.n){case 0:if(!e.message){_context65.n=1;break;}throw e.message;case 1:t=e.artifacts.map(function(n){return _defineProperty(_defineProperty({},A,"".concat(bn).concat(n.base64)),T,q);});return _context65.a(2,_defineProperty({},y,t));}},_callee65);}));function extractResultData(_x136){return _extractResultData0.apply(this,arguments);}return extractResultData;}()}],[{key:"cleanConfig",value:function cleanConfig(e){delete e.engine_id,delete e.weight;}},{key:"canSendTextMessage",value:function canSendTextMessage(e){return!!(e&&e.trim()!=="");}}]);}(ii);var vc=/*#__PURE__*/function(_Et7){function vc(e){var _this33;_classCallCheck(this,vc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.huggingFace)==null?void 0:i.fillMask,n=(o=e.directConnection)==null?void 0:o.huggingFace;_this33=_callSuper(this,vc,[e,"The goal of life is [MASK].","bert-base-uncased",t,n]),_this33.permittedErrorPrefixes=[Hi,"No mask_token"];return _this33;}_inherits(vc,_Et7);return _createClass(vc,[{key:"extractResultData",value:function(){var _extractResultData1=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee66(e){var t;return _regenerator().w(function(_context66){while(1)switch(_context66.n){case 0:if(!e[f]){_context66.n=1;break;}throw e[f];case 1:return _context66.a(2,_defineProperty({},h,((t=e[0])==null?void 0:t.sequence)||""));}},_callee66);}));function extractResultData(_x137){return _extractResultData1.apply(this,arguments);}return extractResultData;}()}]);}(Et);var Vi=function Vi(r){return _defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(r));},_c=function _c(r,e,t,n){var s=r;s[f]?s[f].message===Ui?n(le):n(He):t(e);},Ji=function Ji(){return ce("https://open.bigmodel.cn/api/paas/v4/models",ae,_c);};var Ec=/*#__PURE__*/function(_R3){function Ec(e){var _o$model,_a$voice;var _this34;_classCallCheck(this,Ec);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.bigModel;_this34=_callSuper(this,Ec,[e,Ji(),Vi,n]),_this34.insertKeyPlaceholderText=_this34.genereteAPIKeyName("BigModel"),_this34.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this34.url="https://open.bigmodel.cn/api/paas/v4/audio/speech",_this34.permittedErrorPrefixes=[oe,be];var s=(i=t.bigModel)==null?void 0:i.textToSpeech;_typeof(s)===B&&(_this34.cleanConfig(s),Object.assign(_this34.rawBody,s)),(_o$model=(o=_this34.rawBody).model)!==null&&_o$model!==void 0?_o$model:o.model="cogtts",(_a$voice=(a=_this34.rawBody).voice)!==null&&_a$voice!==void 0?_a$voice:a.voice="tongtong";return _this34;}_inherits(Ec,_R3);return _createClass(Ec,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.input=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI9=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee67(e,t){return _regenerator().w(function(_context67){while(1)switch(_context67.n){case 0:return _context67.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee67,this);}));function callServiceAPI(_x138,_x139){return _callServiceAPI9.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData10=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee68(e){var t,n;return _regenerator().w(function(_context68){while(1)switch(_context68.n){case 0:t=new Blob([e],_defineProperty({},T,"audio/mpeg")),n=URL.createObjectURL(t);return _context68.a(2,_defineProperty({},y,[_defineProperty(_defineProperty({},A,n),T,L)]));}},_callee68);}));function extractResultData(_x140){return _extractResultData10.apply(this,arguments);}return extractResultData;}()}]);}(R);var Wi=function Wi(r){return _defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(r));},Sc=function Sc(r,e,t,n){var s=r;s[f]?s[f].message===Ui?n(le):n(He):t(e);},Ki=function Ki(){return ce("https://api.together.xyz/v1/models",ae,Sc);};var xc=/*#__PURE__*/function(_R4){function xc(e){var _o$model2,_a$voice2;var _this35;_classCallCheck(this,xc);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.together;_this35=_callSuper(this,xc,[e,Ki(),Wi,n]),_this35.insertKeyPlaceholderText=_this35.genereteAPIKeyName("Together AI"),_this35.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this35.url="https://api.together.xyz/v1/audio/speech",_this35.permittedErrorPrefixes=[We,be];var s=(i=t.together)==null?void 0:i.textToSpeech;_typeof(s)===B&&_this35.completeConfig(s),(_o$model2=(o=_this35.rawBody).model)!==null&&_o$model2!==void 0?_o$model2:o.model="cartesia/sonic",(_a$voice2=(a=_this35.rawBody).voice)!==null&&_a$voice2!==void 0?_a$voice2:a.voice="laidback woman";return _this35;}_inherits(xc,_R4);return _createClass(xc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.input=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI0=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee69(e,t){return _regenerator().w(function(_context69){while(1)switch(_context69.n){case 0:return _context69.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee69,this);}));function callServiceAPI(_x141,_x142){return _callServiceAPI0.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData11=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee70(e){var t,n;return _regenerator().w(function(_context70){while(1)switch(_context70.n){case 0:t=new Blob([e],_defineProperty({},T,"audio/mpeg")),n=URL.createObjectURL(t);return _context70.a(2,_defineProperty({},y,[_defineProperty(_defineProperty({},A,n),T,L)]));}},_callee70);}));function extractResultData(_x143){return _extractResultData11.apply(this,arguments);}return extractResultData;}()}]);}(R);var Le="https://api.openai.com/v1/",vn="https://platform.openai.com/account/api-keys",Ci="input_text",Br="input_image",Dr="output_text",gi="image_generation_call",Oo="function_call_output",xn="response",_n=function _n(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},No=function No(r,e,t,n){var s=r;s[f]?s[f].code==="invalid_api_key"?n(le):n(He):t(e);},En=function En(){return ce("".concat(Le,"models"),ae,No);},It=/*#__PURE__*/function(){var _ref54=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee71(r,e,t){var n,s,i,o,a,l,_yield$P$processReque6,c,d,p,u,g,_args71=arguments;return _regenerator().w(function(_context71){while(1)switch(_context71.n){case 0:n=_args71.length>3&&_args71[3]!==undefined?_args71[3]:!0;s=r.connectSettings,i=r.deepChat,o=r.completionsHandlers,a=r.messages;s.method=t;l={body:e,headers:s.headers};_context71.n=1;return P.processRequestInterceptor(i,l);case 1:_yield$P$processReque6=_context71.v;c=_yield$P$processReque6.body;d=_yield$P$processReque6.headers;p=_yield$P$processReque6.error;u=o.onFinish;if(!(p&&a)){_context71.n=2;break;}return _context71.a(2,P.onInterceptorError(a,p,u));case 2:_context71.n=3;return P.fetch(r,d,n,c).then(function(b){return P.processResponseByType(b);});case 3:g=_context71.v;if(!g[f]){_context71.n=4;break;}throw g[f].message;case 4:return _context71.a(2,g);}},_callee71);}));return function It(_x144,_x145,_x146){return _ref54.apply(this,arguments);};}(),Fe=/*#__PURE__*/function(){function Fe(){_classCallCheck(this,Fe);}return _createClass(Fe,null,[{key:"storeFiles",value:function(){var _storeFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee73(e,t,n,s){var i,o,a,l,_t24;return _regenerator().w(function(_context73){while(1)switch(_context73.p=_context73.n){case 0:i=e.connectSettings.headers;if(i){_context73.n=1;break;}return _context73.a(2);case 1:e.url=s;o=i[D];delete i[D];a=n.map(/*#__PURE__*/function(){var _ref55=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee72(l){var c;return _regenerator().w(function(_context72){while(1)switch(_context72.n){case 0:c=new FormData();return _context72.a(2,(c.append("purpose","assistants"),c.append("file",l),new Promise(function(d){d(It(e,c,he,!1));})));}},_callee72);}));return function(_x151){return _ref55.apply(this,arguments);};}());_context73.p=2;_context73.n=3;return Promise.all(a);case 3:l=_context73.v.map(function(c){return{id:c.id,name:c.filename};});return _context73.a(2,(i[D]=o,l));case 4:_context73.p=4;_t24=_context73.v;throw i[D]=o,P.displayError(t,_t24),e.completionsHandlers.onFinish(),_t24;case 5:return _context73.a(2);}},_callee73,null,[[2,4]]);}));function storeFiles(_x147,_x148,_x149,_x150){return _storeFiles.apply(this,arguments);}return storeFiles;}()},{key:"getType",value:function getType(e,t){var n=e[t].path;return!n||n.endsWith("png")?q:Vt;}},{key:"getFiles",value:function(){var _getFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee74(e,t,n,s){var i,a;return _regenerator().w(function(_context74){while(1)switch(_context74.n){case 0:i=t.map(function(_ref56){var l=_ref56.fileId;return e.url="".concat(n).concat(l).concat(s),new Promise(function(c){c(It(e,void 0,"GET",!1));});});_context74.n=1;return Promise.all(i);case 1:a=_context74.v.map(function(l,c){return new Promise(function(d){var p=new FileReader();p.readAsDataURL(l),p.onload=function(u){d(_defineProperty(_defineProperty(_defineProperty({},A,u.target.result),"name",t[c].name),T,Fe.getType(t,c)));};});});_context74.n=2;return Promise.all(a);case 2:return _context74.a(2,_context74.v);}},_callee74);}));function getFiles(_x152,_x153,_x154,_x155){return _getFiles.apply(this,arguments);}return getFiles;}()},{key:"getFileName",value:function getFileName(e){var t=e.split("/");return t[t.length-1];}// prettier-ignore
157
157
  },{key:"getFilesAndNewText",value:function(){var _getFilesAndNewText=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee75(e,t,n,s,i){var c,d,o,a,l,_t25;return _regenerator().w(function(_context75){while(1)switch(_context75.n){case 0:a=n.getFilesPrefix,l=n.getFilesPostfix;_t25=t.length>0;if(!_t25){_context75.n=2;break;}_context75.n=1;return Fe.getFiles(e,t,a,l);case 1:o=_context75.v;(c=i==null?void 0:i[h])!=null&&c.value&&o.forEach(function(p,u){var b;if(!p[A])return;var g=t[u].path;(b=i==null?void 0:i[h])!=null&&b.value&&g&&(i[h].value=i[h].value.replace(g,p[A]));});case 2:return _context75.a(2,(d=i==null?void 0:i[h])!=null&&d.value?_defineProperty(_defineProperty({},h,i[h].value),"role",s):_defineProperty(_defineProperty({},y,o),"role",s));}},_callee75);}));function getFilesAndNewText(_x156,_x157,_x158,_x159,_x160){return _getFilesAndNewText.apply(this,arguments);}return getFilesAndNewText;}()// Noticed an issue where text contains a sandbox hyperlink to a csv, but no annotation provided
158
158
  // To reproduce use the following text:
159
159
  // give example data for a csv and create a suitable bar chart for it with a link
@@ -168,27 +168,27 @@ function Rt(e,t,n,s,i,o){var _this36;_classCallCheck(this,Rt);if(_this36=_callSu
168
168
  },{key:"handleTools",value:function(){var _handleTools=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee88(e){var t,n,s,i,o,a;return _regenerator().w(function(_context88){while(1)switch(_context88.n){case 0:if(this.functionHandler){_context88.n=1;break;}throw Error(kt);case 1:t=e.map(function(l){return{name:l["function"].name,arguments:l["function"].arguments};});_context88.n=2;return this.functionHandler(t);case 2:n=_context88.v;if(!(!Array.isArray(n)||e.length!==n.length)){_context88.n=3;break;}throw Error(ut.FUNCTION_TOOL_RESP_ERROR);case 3:_context88.n=4;return Promise.all(n);case 4:s=_context88.v;if(!s.find(function(l){return typeof l!="string";})){_context88.n=5;break;}throw Error(ut.FUNCTION_TOOL_RESP_ERROR);case 5:i=s.map(function(l,c){return{tool_call_id:e[c].id,output:l};}),o="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId),a="/runs/".concat(this.run_id,"/submit_tool_outputs").concat(this.urlSegments.threadsPosfix);this.url="".concat(o).concat(a);if(!this._isSSEStream){_context88.n=7;break;}_context88.n=6;return this.createStreamRun({tool_outputs:i});case 6:_context88.n=8;break;case 7:_context88.n=8;return It(this,{tool_outputs:i},he);case 8:return _context88.a(2,{timeoutMS:Rt.POLLING_TIMEOUT_MS});}},_callee88,this);}));function handleTools(_x181){return _handleTools.apply(this,arguments);}return handleTools;}()},{key:"handleStream",value:function(){var _handleStream=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee89(e){var n,s,t,i;return _regenerator().w(function(_context89){while(1)switch(_context89.n){case 0:t=(s=(n=e.required_action)==null?void 0:n.submit_tool_outputs)==null?void 0:s.tool_calls;if(!(e.status==="requires_action"&&t)){_context89.n=2;break;}this.run_id=e.id;_context89.n=1;return this.handleTools(t);case 1:return _context89.a(2,_context89.v);case 2:if(!this._waitingForStreamResponse){_context89.n=3;break;}return _context89.a(2,this.parseStreamResult(e));case 3:if(this._isSSEStream&&this.sessionId){this.asyncCallInProgress=!0,this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs").concat(this.urlSegments.threadsPosfix);i=JSON.parse(JSON.stringify(this.rawBody));this.createStreamRun(i);}return _context89.a(2,_defineProperty({},h,""));}},_callee89,this);}));function handleStream(_x182){return _handleStream.apply(this,arguments);}return handleStream;}()// prettier-ignore
169
169
  },{key:"parseStreamResult",value:function(){var _parseStreamResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee90(e){var t,n,s,i,o,a,l,c,_a4,_l3;return _regenerator().w(function(_context90){while(1)switch(_context90.n){case 0:if(!(e.content&&e.content.length>0&&this.messages)){_context90.n=1;break;}a=e.content.find(function(l){return l[h];});if(!((t=a==null?void 0:a[h])!=null&&t.annotations&&a[h].annotations.length>0)){_context90.n=1;break;}l=e.content.find(function(d){return!!d[h];})||e.content[0],c=ut.getFilesAndText.bind(this,this,{role:ot,content:e.content},this.urlSegments,l);return _context90.a(2,((n=this._messageStream)==null||n.endStreamAfterFileDownloaded(this.messages,c),_defineProperty({},h,"")));case 1:if(!((s=e.delta)!=null&&s.content)){_context90.n=4;break;}if(!(e.delta.content.length>1)){_context90.n=3;break;}_a4=e.delta.content.find(function(l){return l[h];});if(!((i=_a4==null?void 0:_a4[h])!=null&&i.annotations&&_a4[h].annotations.length===0)){_context90.n=3;break;}_context90.n=2;return ut.processStreamMessages(this,e.delta.content,this.urlSegments);case 2:_l3=_context90.v;return _context90.a(2,_defineProperty(_defineProperty({},h,_l3[0][h]),y,_l3[1][y]));case 3:return _context90.a(2,_defineProperty({},h,(o=e.delta.content[0][h])==null?void 0:o.value));case 4:return _context90.a(2,(!this.sessionId&&e.thread_id&&(this.sessionId=e.thread_id),_defineProperty({},h,"")));}},_callee90,this);}));function parseStreamResult(_x183){return _parseStreamResult.apply(this,arguments);}return parseStreamResult;}()// https://platform.openai.com/docs/api-reference/assistants-streaming
170
170
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
- },{key:"createStreamRun",value:function(){var _createStreamRun=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(e){return _regenerator().w(function(_context91){while(1)switch(_context91.n){case 0:e.stream=!0;this._waitingForStreamResponse=!0;_context91.n=1;return U.request(this,e,this.messages,!0,!0);case 1:this._messageStream=_context91.v;case 2:return _context91.a(2);}},_callee91,this);}));function createStreamRun(_x184){return _createStreamRun.apply(this,arguments);}return createStreamRun;}()}],[{key:"processImageMessage",value:function processImageMessage(e,t){var n=t==null?void 0:t.filter(function(s){return pe.isImageFileExtension(s.name);}).map(function(s){return _defineProperty(_defineProperty({},T,"image_file"),"image_file",{file_id:s.id});});if(n&&n.length>0)return e[h]&&e[h].length>0&&n.push(_defineProperty(_defineProperty({},T,h),h,e[h])),{content:n,role:H};}},{key:"processAttachmentsMessage",value:function processAttachmentsMessage(e,t,n){return{attachments:t.map(function(i){return{tools:[_defineProperty({},T,n)],file_id:i.id};}),content:[_defineProperty(_defineProperty({},T,h),h,e[h])],role:H};}}]);}(R);Rt.POLLING_TIMEOUT_MS=500;var Ds=Rt;var Xi=/*#__PURE__*/function(_Ds){function Xi(e){var _a$headers,_l$OpenAIBeta;var _this39;_classCallCheck(this,Xi);var o,a,l,c,d;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.openAI,s=(o=t.openAI)==null?void 0:o.assistant,i=Xi.buildUrlSegments(s);if(_this39=_callSuper(this,Xi,[e,s,i,En(),_n,n]),(_a$headers=(a=_this39.connectSettings).headers)!==null&&_a$headers!==void 0?_a$headers:a.headers={},(_l$OpenAIBeta=(l=_this39.connectSettings.headers)["OpenAI-Beta"])!==null&&_l$OpenAIBeta!==void 0?_l$OpenAIBeta:l["OpenAI-Beta"]="assistants=v2",_this39.shouldFetchHistory&&_this39.sessionId&&(_this39.fetchHistory=_this39.fetchHistoryFunc.bind(_assertThisInitialized(_this39))),_typeof(s)===B){var _ref76=(d=(c=e.directConnection)==null?void 0:c.openAI)==null?void 0:d.assistant,p=_ref76.function_handler,u=_ref76.files_tool_type;p&&(_this39._functionHandlerI=p),u&&(_this39.filesToolType=u);}return _this39;}_inherits(Xi,_Ds);return _createClass(Xi,null,[{key:"buildUrlSegments",value:function buildUrlSegments(e){var t=_typeof(e)=="object"&&e.custom_base_url||Le;return{threadsPrefix:"".concat(t,"/threads"),threadsPosfix:"",newAssistantUrl:"".concat(t,"/assistants"),createMessagePostfix:"",listMessagesPostfix:"order=desc",storeFiles:"".concat(t,"/").concat(y),getFilesPrefix:"".concat(t,"/").concat(y,"/"),getFilesPostfix:"/content"};}}]);}(Ds);var Fs="Please define the Azure URL Details. [More Information](".concat($,"directConnection/Azure)"),Po=function Po(r){return _defineProperty({"api-key":r},D,W);},Lo=function Lo(r){return ce("".concat(r.endpoint,"/openai/models?api-version=").concat(r.version),ae,No);},Bo=function Bo(r){var e=r.endpoint,t=r.version,n=r.deploymentId;return e&&t&&n;},ln=/*#__PURE__*/function(_Ds2){function ln(e){var _E$headers;var _this40;_classCallCheck(this,ln);var c,d,p,u,g,b,v,E;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.azure,s=(c=t.azure)==null?void 0:c.openAI,i=(s==null?void 0:s.urlDetails)||{},o="".concat((d=s==null?void 0:s.urlDetails)==null?void 0:d.endpoint,"/openai/"),a="?api-version=".concat((p=s==null?void 0:s.urlDetails)==null?void 0:p.version),l={threadsPrefix:"".concat(o).concat(ln.THREAD_RESOURCE),threadsPosfix:a,newAssistantUrl:"".concat(o).concat(ln.NEW_ASSISTANT_RESOURCE).concat(a),createMessagePostfix:a,listMessagesPostfix:"order=desc&api-version=".concat((u=s==null?void 0:s.urlDetails)==null?void 0:u.version),storeFiles:"".concat(o).concat(y).concat(a),getFilesPrefix:"".concat(o).concat(y,"/"),getFilesPostfix:"/content".concat(a)};if(_this40=_callSuper(this,ln,[e,s==null?void 0:s.assistant,l,Lo(i),Po,n]),_this40.permittedErrorPrefixes=[Fs],_this40.insertKeyPlaceholderText=_this40.genereteAPIKeyName("Azure OpenAI"),_this40.keyHelpUrl="https://learn.microsoft.com/en-us/answers/questions/1193991/how-to-get-the-value-of-openai-api-key",_this40.isTextInputDisabled=!1,_typeof(s==null?void 0:s.assistant)===B){var _ref78=(v=(b=(g=e.directConnection)==null?void 0:g.azure)==null?void 0:b.openAI)==null?void 0:v.assistant,C=_ref78.function_handler,j=_ref78.files_tool_type;C&&(_this40._functionHandlerI=C),j&&(_this40.filesToolType=j);}Bo(i)?(_E$headers=(E=_this40.connectSettings).headers)!==null&&_E$headers!==void 0?_E$headers:E.headers={}:(_this40.isTextInputDisabled=!0,_this40.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,Fs));}));return _this40;}_inherits(ln,_Ds2);return _createClass(ln);}(Ds);ln.THREAD_RESOURCE="threads",ln.NEW_ASSISTANT_RESOURCE="assistants";var Ci=ln;var Ac="sts-session-started",wc="sts-session-stopped";var ie=/*#__PURE__*/function(){function ie(){_classCallCheck(this,ie);}return _createClass(ie,null,[{key:"addAttributes",value:function addAttributes(e){e.role="button",e.setAttribute("tabindex","0");}},{key:"addAriaBusy",value:function addAriaBusy(e){e.setAttribute("aria-busy","true");}},{key:"removeAriaBusy",value:function removeAriaBusy(e){e.removeAttribute("aria-busy");}},{key:"addAriaDisabled",value:function addAriaDisabled(e){e.setAttribute("aria-disabled","true");}},{key:"removeAriaDisabled",value:function removeAriaDisabled(e){e.removeAttribute("aria-disabled");}},{key:"removeAriaAttributes",value:function removeAriaAttributes(e){ie.removeAriaBusy(e),ie.removeAriaDisabled(e);}}]);}();var Do="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg height=\"1.4em\" width=\"1.4em\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t viewBox=\"0 0 490.9 490.9\" xml:space=\"preserve\">\n\t<g>\n\t\t<g>\n\t\t\t<path d=\"M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v130.5\n\t\t\t\tC149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5\n\t\t\t\tc0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z\"/>\n\t\t\t<path d=\"M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3\n\t\t\t\ts5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8\n\t\t\t\tc0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9\n\t\t\t\tC106.6,220,101.2,214.5,94.4,214.5z\"/>\n\t\t</g>\n\t</g>\n</svg>\n",Ue=/*#__PURE__*/function(){function Ue(){_classCallCheck(this,Ue);}return _createClass(Ue,null,[{key:"createTextElement",value:function createTextElement(e){var t=S();return t[m].add(Ue.INPUT_BUTTON_INNER_TEXT_CLASS),t.innerText=e,t;}},{key:"tryAddSVGElement",value:function tryAddSVGElement(e,t,n,s){n?e.push(_t.createSVGElement(n)):n!==""&&s&&e.push(t);}},{key:"createCustomElements",value:function createCustomElements(e,t,n){var l,c;var s=n==null?void 0:n[e],i=(l=s==null?void 0:s[h])==null?void 0:l.content,o=(c=s==null?void 0:s.svg)==null?void 0:c.content,a=[];return Ue.tryAddSVGElement(a,t,o,i),i&&a.push(Ue.createTextElement(i)),a.length>0?a:void 0;}},{key:"reassignClassBasedOnChildren",value:function reassignClassBasedOnChildren(e,t){e[m].remove(Ue.INPUT_BUTTON_SVG_CLASS,Ue.INPUT_BUTTON_SVG_TEXT_CLASS),t.find(function(n){return n[m].contains(Ue.INPUT_BUTTON_INNER_TEXT_CLASS);})?t.length>1&&e[m].add(Ue.INPUT_BUTTON_SVG_TEXT_CLASS):e[m].add(Ue.INPUT_BUTTON_SVG_CLASS);}}]);}();Ue.INPUT_BUTTON_SVG_TEXT_CLASS="input-button-svg-text",Ue.INPUT_BUTTON_INNER_TEXT_CLASS="text-button",Ue.INPUT_BUTTON_SVG_CLASS="input-button-svg";var dt=Ue;var Xn=/*#__PURE__*/function(){function Xn(){_classCallCheck(this,Xn);}return _createClass(Xn,null,[{key:"parseSVGTextElements",value:function parseSVGTextElements(e){return _defineProperty({svg:e.find(function(t){return t.tagName.toLowerCase()==="svg";})},h,e.find(function(t){return t.tagName.toLowerCase()==="div";}));}}]);}();var fe=/*#__PURE__*/function(){function fe(){_classCallCheck(this,fe);}return _createClass(fe,null,[{key:"unsetAllCSS",value:function unsetAllCSS(e,t){var i,o;t.container&&te.unsetAllCSSMouseStates(e,t.container);var _Xn$parseSVGTextEleme=Xn.parseSVGTextElements(Array.from(e.children)),n=_Xn$parseSVGTextEleme.svg,s=_Xn$parseSVGTextEleme.text;(i=t.svg)!=null&&i.styles&&n&&te.unsetAllCSSMouseStates(n,t.svg.styles),(o=t[h])!=null&&o.styles&&s&&te.unsetAllCSSMouseStates(s,t[h].styles);}},{key:"unsetActionCSS",value:function unsetActionCSS(e,t){var i,o;t.container&&te.unsetActivityCSSMouseStates(e,t.container);var _Xn$parseSVGTextEleme2=Xn.parseSVGTextElements(Array.from(e.children)),n=_Xn$parseSVGTextEleme2.svg,s=_Xn$parseSVGTextEleme2.text;(i=t.svg)!=null&&i.styles&&n&&te.unsetActivityCSSMouseStates(n,t.svg.styles),(o=t[h])!=null&&o.styles&&s&&te.unsetActivityCSSMouseStates(s,t[h].styles);}},{key:"setElementsCSS",value:function setElementsCSS(e,t,n){var o,a,l,c,d;Object.assign(e[_],(o=t.container)==null?void 0:o[n]);var _Xn$parseSVGTextEleme3=Xn.parseSVGTextElements(Array.from(e.children)),s=_Xn$parseSVGTextEleme3.svg,i=_Xn$parseSVGTextEleme3.text;s&&Object.assign(s[_],(l=(a=t.svg)==null?void 0:a.styles)==null?void 0:l[n]),i&&Object.assign(i[_],(d=(c=t[h])==null?void 0:c.styles)==null?void 0:d[n]);}},{key:"setElementCssUpToState",value:function setElementCssUpToState(e,t,n){fe.setElementsCSS(e,t,x),n!==x&&(fe.setElementsCSS(e,t,Re),n!==Re&&fe.setElementsCSS(e,t,z));}}]);}();var tn=/*#__PURE__*/function(){// prettier-ignore
171
+ },{key:"createStreamRun",value:function(){var _createStreamRun=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee91(e){return _regenerator().w(function(_context91){while(1)switch(_context91.n){case 0:e.stream=!0;this._waitingForStreamResponse=!0;_context91.n=1;return U.request(this,e,this.messages,!0,!0);case 1:this._messageStream=_context91.v;case 2:return _context91.a(2);}},_callee91,this);}));function createStreamRun(_x184){return _createStreamRun.apply(this,arguments);}return createStreamRun;}()}],[{key:"processImageMessage",value:function processImageMessage(e,t){var n=t==null?void 0:t.filter(function(s){return pe.isImageFileExtension(s.name);}).map(function(s){return _defineProperty(_defineProperty({},T,"image_file"),"image_file",{file_id:s.id});});if(n&&n.length>0)return e[h]&&e[h].length>0&&n.push(_defineProperty(_defineProperty({},T,h),h,e[h])),{content:n,role:H};}},{key:"processAttachmentsMessage",value:function processAttachmentsMessage(e,t,n){return{attachments:t.map(function(i){return{tools:[_defineProperty({},T,n)],file_id:i.id};}),content:[_defineProperty(_defineProperty({},T,h),h,e[h])],role:H};}}]);}(R);Rt.POLLING_TIMEOUT_MS=500;var Ds=Rt;var Xi=/*#__PURE__*/function(_Ds){function Xi(e){var _a$headers,_l$OpenAIBeta;var _this39;_classCallCheck(this,Xi);var o,a,l,c,d;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.openAI,s=(o=t.openAI)==null?void 0:o.assistant,i=Xi.buildUrlSegments(s);if(_this39=_callSuper(this,Xi,[e,s,i,En(),_n,n]),(_a$headers=(a=_this39.connectSettings).headers)!==null&&_a$headers!==void 0?_a$headers:a.headers={},(_l$OpenAIBeta=(l=_this39.connectSettings.headers)["OpenAI-Beta"])!==null&&_l$OpenAIBeta!==void 0?_l$OpenAIBeta:l["OpenAI-Beta"]="assistants=v2",_this39.shouldFetchHistory&&_this39.sessionId&&(_this39.fetchHistory=_this39.fetchHistoryFunc.bind(_assertThisInitialized(_this39))),_typeof(s)===B){var _ref76=(d=(c=e.directConnection)==null?void 0:c.openAI)==null?void 0:d.assistant,p=_ref76.function_handler,u=_ref76.files_tool_type;p&&(_this39._functionHandlerI=p),u&&(_this39.filesToolType=u);}return _this39;}_inherits(Xi,_Ds);return _createClass(Xi,null,[{key:"buildUrlSegments",value:function buildUrlSegments(e){var t=_typeof(e)=="object"&&e.custom_base_url||Le;return{threadsPrefix:"".concat(t,"/threads"),threadsPosfix:"",newAssistantUrl:"".concat(t,"/assistants"),createMessagePostfix:"",listMessagesPostfix:"order=desc",storeFiles:"".concat(t,"/").concat(y),getFilesPrefix:"".concat(t,"/").concat(y,"/"),getFilesPostfix:"/content"};}}]);}(Ds);var Fs="Please define the Azure URL Details. [More Information](".concat($,"directConnection/Azure)"),Po=function Po(r){return _defineProperty({"api-key":r},D,W);},Lo=function Lo(r){return ce("".concat(r.endpoint,"/openai/models?api-version=").concat(r.version),ae,No);},Bo=function Bo(r){var e=r.endpoint,t=r.version,n=r.deploymentId;return e&&t&&n;},ln=/*#__PURE__*/function(_Ds2){function ln(e){var _E$headers;var _this40;_classCallCheck(this,ln);var c,d,p,u,g,b,v,E;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.azure,s=(c=t.azure)==null?void 0:c.openAI,i=(s==null?void 0:s.urlDetails)||{},o="".concat((d=s==null?void 0:s.urlDetails)==null?void 0:d.endpoint,"/openai/"),a="?api-version=".concat((p=s==null?void 0:s.urlDetails)==null?void 0:p.version),l={threadsPrefix:"".concat(o).concat(ln.THREAD_RESOURCE),threadsPosfix:a,newAssistantUrl:"".concat(o).concat(ln.NEW_ASSISTANT_RESOURCE).concat(a),createMessagePostfix:a,listMessagesPostfix:"order=desc&api-version=".concat((u=s==null?void 0:s.urlDetails)==null?void 0:u.version),storeFiles:"".concat(o).concat(y).concat(a),getFilesPrefix:"".concat(o).concat(y,"/"),getFilesPostfix:"/content".concat(a)};if(_this40=_callSuper(this,ln,[e,s==null?void 0:s.assistant,l,Lo(i),Po,n]),_this40.permittedErrorPrefixes=[Fs],_this40.insertKeyPlaceholderText=_this40.genereteAPIKeyName("Azure OpenAI"),_this40.keyHelpUrl="https://learn.microsoft.com/en-us/answers/questions/1193991/how-to-get-the-value-of-openai-api-key",_this40.isTextInputDisabled=!1,_typeof(s==null?void 0:s.assistant)===B){var _ref78=(v=(b=(g=e.directConnection)==null?void 0:g.azure)==null?void 0:b.openAI)==null?void 0:v.assistant,w=_ref78.function_handler,j=_ref78.files_tool_type;w&&(_this40._functionHandlerI=w),j&&(_this40.filesToolType=j);}Bo(i)?(_E$headers=(E=_this40.connectSettings).headers)!==null&&_E$headers!==void 0?_E$headers:E.headers={}:(_this40.isTextInputDisabled=!0,_this40.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,Fs));}));return _this40;}_inherits(ln,_Ds2);return _createClass(ln);}(Ds);ln.THREAD_RESOURCE="threads",ln.NEW_ASSISTANT_RESOURCE="assistants";var wi=ln;var Ac="sts-session-started",Cc="sts-session-stopped";var ie=/*#__PURE__*/function(){function ie(){_classCallCheck(this,ie);}return _createClass(ie,null,[{key:"addAttributes",value:function addAttributes(e){e.role="button",e.setAttribute("tabindex","0");}},{key:"addAriaBusy",value:function addAriaBusy(e){e.setAttribute("aria-busy","true");}},{key:"removeAriaBusy",value:function removeAriaBusy(e){e.removeAttribute("aria-busy");}},{key:"addAriaDisabled",value:function addAriaDisabled(e){e.setAttribute("aria-disabled","true");}},{key:"removeAriaDisabled",value:function removeAriaDisabled(e){e.removeAttribute("aria-disabled");}},{key:"removeAriaAttributes",value:function removeAriaAttributes(e){ie.removeAriaBusy(e),ie.removeAriaDisabled(e);}}]);}();var Do="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg height=\"1.4em\" width=\"1.4em\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t viewBox=\"0 0 490.9 490.9\" xml:space=\"preserve\">\n\t<g>\n\t\t<g>\n\t\t\t<path d=\"M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v130.5\n\t\t\t\tC149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5\n\t\t\t\tc0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z\"/>\n\t\t\t<path d=\"M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3\n\t\t\t\ts5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8\n\t\t\t\tc0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9\n\t\t\t\tC106.6,220,101.2,214.5,94.4,214.5z\"/>\n\t\t</g>\n\t</g>\n</svg>\n",Ue=/*#__PURE__*/function(){function Ue(){_classCallCheck(this,Ue);}return _createClass(Ue,null,[{key:"createTextElement",value:function createTextElement(e){var t=S();return t[m].add(Ue.INPUT_BUTTON_INNER_TEXT_CLASS),t.innerText=e,t;}},{key:"tryAddSVGElement",value:function tryAddSVGElement(e,t,n,s){n?e.push(_t.createSVGElement(n)):n!==""&&s&&e.push(t);}},{key:"createCustomElements",value:function createCustomElements(e,t,n){var l,c;var s=n==null?void 0:n[e],i=(l=s==null?void 0:s[h])==null?void 0:l.content,o=(c=s==null?void 0:s.svg)==null?void 0:c.content,a=[];return Ue.tryAddSVGElement(a,t,o,i),i&&a.push(Ue.createTextElement(i)),a.length>0?a:void 0;}},{key:"reassignClassBasedOnChildren",value:function reassignClassBasedOnChildren(e,t){e[m].remove(Ue.INPUT_BUTTON_SVG_CLASS,Ue.INPUT_BUTTON_SVG_TEXT_CLASS),t.find(function(n){return n[m].contains(Ue.INPUT_BUTTON_INNER_TEXT_CLASS);})?t.length>1&&e[m].add(Ue.INPUT_BUTTON_SVG_TEXT_CLASS):e[m].add(Ue.INPUT_BUTTON_SVG_CLASS);}}]);}();Ue.INPUT_BUTTON_SVG_TEXT_CLASS="input-button-svg-text",Ue.INPUT_BUTTON_INNER_TEXT_CLASS="text-button",Ue.INPUT_BUTTON_SVG_CLASS="input-button-svg";var dt=Ue;var Xn=/*#__PURE__*/function(){function Xn(){_classCallCheck(this,Xn);}return _createClass(Xn,null,[{key:"parseSVGTextElements",value:function parseSVGTextElements(e){return _defineProperty({svg:e.find(function(t){return t.tagName.toLowerCase()==="svg";})},h,e.find(function(t){return t.tagName.toLowerCase()==="div";}));}}]);}();var fe=/*#__PURE__*/function(){function fe(){_classCallCheck(this,fe);}return _createClass(fe,null,[{key:"unsetAllCSS",value:function unsetAllCSS(e,t){var i,o;t.container&&te.unsetAllCSSMouseStates(e,t.container);var _Xn$parseSVGTextEleme=Xn.parseSVGTextElements(Array.from(e.children)),n=_Xn$parseSVGTextEleme.svg,s=_Xn$parseSVGTextEleme.text;(i=t.svg)!=null&&i.styles&&n&&te.unsetAllCSSMouseStates(n,t.svg.styles),(o=t[h])!=null&&o.styles&&s&&te.unsetAllCSSMouseStates(s,t[h].styles);}},{key:"unsetActionCSS",value:function unsetActionCSS(e,t){var i,o;t.container&&te.unsetActivityCSSMouseStates(e,t.container);var _Xn$parseSVGTextEleme2=Xn.parseSVGTextElements(Array.from(e.children)),n=_Xn$parseSVGTextEleme2.svg,s=_Xn$parseSVGTextEleme2.text;(i=t.svg)!=null&&i.styles&&n&&te.unsetActivityCSSMouseStates(n,t.svg.styles),(o=t[h])!=null&&o.styles&&s&&te.unsetActivityCSSMouseStates(s,t[h].styles);}},{key:"setElementsCSS",value:function setElementsCSS(e,t,n){var o,a,l,c,d;Object.assign(e[_],(o=t.container)==null?void 0:o[n]);var _Xn$parseSVGTextEleme3=Xn.parseSVGTextElements(Array.from(e.children)),s=_Xn$parseSVGTextEleme3.svg,i=_Xn$parseSVGTextEleme3.text;s&&Object.assign(s[_],(l=(a=t.svg)==null?void 0:a.styles)==null?void 0:l[n]),i&&Object.assign(i[_],(d=(c=t[h])==null?void 0:c.styles)==null?void 0:d[n]);}},{key:"setElementCssUpToState",value:function setElementCssUpToState(e,t,n){fe.setElementsCSS(e,t,x),n!==x&&(fe.setElementsCSS(e,t,Re),n!==Re&&fe.setElementsCSS(e,t,z));}}]);}();var tn=/*#__PURE__*/function(){// prettier-ignore
172
172
  function tn(e,t,n,s,i,o){_classCallCheck(this,tn);this._mouseState={state:"default"},this.isCustom=!1,ie.addAttributes(e),this.elementRef=e,this.svg=_t.createSVGElement(t),this.customStyles=i,this.position=ne.processPosition(n),this._tooltipSettings=s,this.dropupText=o;}return _createClass(tn,[{key:"buttonMouseLeave",value:function buttonMouseLeave(e){var t;this._mouseState.state=x,((t=this._activeTooltip)==null?void 0:t.element[_].visibility)==="visible"&&this._tooltipSettings&&nt.hide(this._activeTooltip,this._tooltipSettings),e&&(fe.unsetAllCSS(this.elementRef,e),fe.setElementsCSS(this.elementRef,e,x));}},{key:"buttonMouseEnter",value:function buttonMouseEnter(e){var t;this._mouseState.state=Re,this._tooltipSettings&&(this._activeTooltip=nt.display(this.elementRef,this._tooltipSettings,(t=this._activeTooltip)==null?void 0:t.element)),e&&fe.setElementsCSS(this.elementRef,e,Re);}},{key:"buttonMouseUp",value:function buttonMouseUp(e){e&&fe.unsetActionCSS(this.elementRef,e),this.buttonMouseEnter(e);}},{key:"buttonMouseDown",value:function buttonMouseDown(e){this._mouseState.state=z,e&&fe.setElementsCSS(this.elementRef,e,z);}// be careful not to use onclick as that is used for button functionality
173
173
  },{key:"setEvents",value:function setEvents(e){this.elementRef.onmousedown=this.buttonMouseDown.bind(this,e),this.elementRef.onmouseup=this.buttonMouseUp.bind(this,e),this.elementRef.onmouseenter=this.buttonMouseEnter.bind(this,e),this.elementRef.onmouseleave=this.buttonMouseLeave.bind(this,e);}},{key:"unsetCustomStateStyles",value:function unsetCustomStateStyles(e){if(this.customStyles)for(var t=0;t<e.length;t+=1){var _n2=e[t],s=_n2&&this.customStyles[_n2];s&&fe.unsetActionCSS(this.elementRef,s);}}},{key:"reapplyStateStyle",value:function reapplyStateStyle(e,t){if(!this.customStyles)return;t&&this.unsetCustomStateStyles(t);var n=this.customStyles[e];n&&fe.setElementCssUpToState(this.elementRef,n,this._mouseState.state),this.setEvents(n);}},{key:"changeElementsByState",value:function changeElementsByState(e){var _this$elementRef;(_this$elementRef=this.elementRef).replaceChildren.apply(_this$elementRef,_toConsumableArray(e)),dt.reassignClassBasedOnChildren(this.elementRef,e);}},{key:"buildDefaultIconElement",value:function buildDefaultIconElement(e){var t=this.svg.cloneNode(!0);return t.id=e,[t];}},{key:"createInnerElements",value:function createInnerElements(e,t,n){var s=dt.createCustomElements(t,this.svg,n);if(s&&s.length>0){if(this.position===ze){var i=this.svg.cloneNode(!0);i.id=s[0]===this.svg?e:"dropup-menu-item-icon-element-custom",s[0]=i;}return s;}return this.buildDefaultIconElement(e);}}]);}();var Zs=/*#__PURE__*/function(_tn){function Zs(e){var _this41;_classCallCheck(this,Zs);var n,s;var t=((s=(n=e==null?void 0:e[x])==null?void 0:n.svg)==null?void 0:s.content)||Zs.EMPTY_SVG;_this41=_callSuper(this,Zs,[S(),t,void 0,void 0,e]),_this41.isActive=!1,_this41._innerElements=_this41.createInnerElementsForStates(_this41.customStyles),_this41.changeToDefault();return _this41;}_inherits(Zs,_tn);return _createClass(Zs,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){return _defineProperty(_defineProperty(_defineProperty({},x,this.createInnerButtonElements(x,e)),"active",this.createInnerButtonElements("active",e)),"unavailable",this.createInnerButtonElements("unavailable",e));}},{key:"createInnerButtonElements",value:function createInnerButtonElements(e,t){return dt.createCustomElements(e,this.svg,t)||[this.svg];}},{key:"changeState",value:function changeState(e){this.changeElementsByState(e),this.elementRef[m].replace(dt.INPUT_BUTTON_SVG_CLASS,"deep-chat-openai-realtime-button");}},{key:"changeToActive",value:function changeToActive(){this.changeState(this._innerElements.active),this.reapplyStateStyle("active",["unavailable",x]),this.isActive=!0;}},{key:"changeToDefault",value:function changeToDefault(){var e,t,n,s;this.changeState(this._innerElements[x]),(e=this.customStyles)!=null&&e.active&&fe.unsetAllCSS(this.elementRef,(t=this.customStyles)==null?void 0:t.active),(n=this.customStyles)!=null&&n.unavailable&&fe.unsetAllCSS(this.elementRef,(s=this.customStyles)==null?void 0:s.unavailable),this.reapplyStateStyle(x,["active","unavailable"]),this.isActive=!1;}},{key:"changeToUnavailable",value:function changeToUnavailable(){var e,t,n,s;this.changeState(this._innerElements.unavailable),(e=this.customStyles)!=null&&e.active&&fe.unsetAllCSS(this.elementRef,(t=this.customStyles)==null?void 0:t.active),(n=this.customStyles)!=null&&n[x]&&fe.unsetAllCSS(this.elementRef,(s=this.customStyles)==null?void 0:s[x]),this.reapplyStateStyle("unavailable",[x,"active"]),this.isActive=!1;}}]);}(tn);Zs.EMPTY_SVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"></svg>';var Us=Zs;var xe=/*#__PURE__*/function(){function xe(){_classCallCheck(this,xe);}return _createClass(xe,null,[{key:"setPropertyValueIfDoesNotExist",value:function setPropertyValueIfDoesNotExist(e,t,n){var _e$s,_e$s2;var s=t[0];t.length===1?(_e$s=e[s])!==null&&_e$s!==void 0?_e$s:e[s]=n:((_e$s2=e[s])!==null&&_e$s2!==void 0?_e$s2:e[s]={},t.shift(),xe.setPropertyValueIfDoesNotExist(e[s],t,n));}},{key:"setPropertyValue",value:function setPropertyValue(e,t,n){var _e$s3;var s=t[0];t.length===1?e[s]=n:((_e$s3=e[s])!==null&&_e$s3!==void 0?_e$s3:e[s]={},t.shift(),xe.setPropertyValue(e[s],t,n));}},{key:"getObjectValue",value:function getObjectValue(e,t){var n=t[0],s=e[n];return s===void 0||t.length===1?s:xe.getObjectValue(s,t.slice(1));}},{key:"overwritePropertyObjectFromAnother",value:function overwritePropertyObjectFromAnother(e,t,n){var s=xe.getObjectValue(t,n);if(s){var i=_objectSpread(_objectSpread({},s),xe.getObjectValue(e,n)||{});xe.setPropertyValue(e,n,i);}}},{key:"isJson",value:function isJson(e){try{return JSON.stringify(e),!0;}catch(_unused8){return!1;}}// prettier-ignore
174
174
  },{key:"assignPropertyFromOneToAnother",value:function assignPropertyFromOneToAnother(e,t,n){var _t$e;(_t$e=t[e])!==null&&_t$e!==void 0?_t$e:t[e]={},Object.assign(t[e],n==null?void 0:n[e]);}}]);}();var Fo="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5.92 24.096q0 1.088 0.928 1.728 0.512 0.288 1.088 0.288 0.448 0 0.896-0.224l16.16-8.064q0.48-0.256 0.8-0.736t0.288-1.088-0.288-1.056-0.8-0.736l-16.16-8.064q-0.448-0.224-0.896-0.224-0.544 0-1.088 0.288-0.928 0.608-0.928 1.728v16.16z\"></path>\n</svg>",Ti="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z\"></path>\n</svg>",V=/*#__PURE__*/function(_R6){function V(e){var _c$model;var _this42;_classCallCheck(this,V);var i,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),n=V.getKey(e);_this42=_callSuper(this,V,[e,En(),_n,{key:n}]),_this42.insertKeyPlaceholderText=_this42.genereteAPIKeyName("OpenAI"),_this42.keyHelpUrl=vn,_this42._microphoneButton=null,_this42._toggleButton=null,_this42._errorElement=null,_this42._loadingElement=null,_this42._pc=null,_this42._mediaStream=null,_this42._isMuted=!1;var s=(i=t.openAI)==null?void 0:i.realtime;if(_typeof(s)===B){_this42._avatarConfig=s.avatar,_this42._ephemeralKey=s.ephemeralKey,_this42._errorConfig=s[f],_this42._loadingConfig=s.loading,Object.assign(_this42.rawBody,s.config);var d=(a=(o=e.directConnection)==null?void 0:o.openAI)==null?void 0:a.realtime,_ref81=d.config||{},p=_ref81.function_handler;p&&(_this42._functionHandlerI=p),_this42._events=s.events,d.methods=_this42.generateMethods(),_this42.setInputAudioTranscribe(e,(l=d.config)==null?void 0:l.input_audio_transcription);}(_c$model=(c=_this42.rawBody).model)!==null&&_c$model!==void 0?_c$model:c.model="gpt-4o-realtime-preview-2025-06-03",_this42._avatarConfig=V.buildAvatarConfig(s),_this42._buttonsConfig=V.buildButtonsConfig(s),_this42._avatarEl=V.createAvatar(_this42._avatarConfig),_this42._containerEl=_this42.createContainer(),_this42._deepChat=e;return _this42;}_inherits(V,_R6);return _createClass(V,[{key:"setInputAudioTranscribe",value:// https://community.openai.com/t/unable-to-access-user-audio-transcript-in-realtime-api/1001570/3
175
175
  function setInputAudioTranscribe(e,t){if(t){var _n3="whisper-1";_typeof(t)=="object"?this.rawBody.input_audio_transcription={model:t.model||_n3,language:t.language,prompt:t.prompt}:this.rawBody.input_audio_transcription={model:_n3};}else e.onMessage&&(console.warn("To get user audio transcription, set `input_audio_transcription` in the `realtime` config."),console.warn("See: ".concat($,"directConnection/OpenAI/OpenAIRealtime#OpenAIRealtimeConfig")));}// called after API key was inserted
176
- },{key:"setUpView",value:function setUpView(e,t){e[_].display="none",t.appendChild(this._containerEl),this.setup();}},{key:"setup",value:function(){var _setup=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(){var s,e,t,n;return _regenerator().w(function(_context92){while(1)switch(_context92.n){case 0:e=(s=this._deepChat.directConnection)==null?void 0:s.openAI;if(e){_context92.n=1;break;}return _context92.a(2);case 1:t=e==null?void 0:e.realtime;if(!(_typeof(t)!="object"||!t.autoStart&&!t.autoFetchEphemeralKey)){_context92.n=2;break;}return _context92.a(2);case 2:n=this.key||e.key;(t.fetchEphemeralKey||n)&&t.autoStart&&(this.changeToUnavailable(),this.displayLoading()),this.fetchEphemeralKey(t.autoStart);case 3:return _context92.a(2);}},_callee92,this);}));function setup(){return _setup.apply(this,arguments);}return setup;}()},{key:"fetchEphemeralKey",value:function(){var _fetchEphemeralKey=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(e){var o,t,n,s,i,a,_t31,_t32,_t33;return _regenerator().w(function(_context93){while(1)switch(_context93.p=_context93.n){case 0:t=(o=this._deepChat.directConnection)==null?void 0:o.openAI,n=_typeof(t==null?void 0:t.realtime)=="object"?t==null?void 0:t.realtime.fetchEphemeralKey:void 0,s=t==null?void 0:t.realtime,i=this.key||t.key;if(!(_typeof(s)=="object")){_context93.n=8;break;}if(this._ephemeralKey){_context93.n=7;break;}_context93.p=1;if(!n){_context93.n=3;break;}a=n();a.then&&(this._retrievingEphemeralKey=a);_context93.n=2;return a;case 2:this._ephemeralKey=_context93.v;_context93.n=5;break;case 3:_t31=i;if(!_t31){_context93.n=5;break;}this._retrievingEphemeralKey=this.getEphemeralKey(i);_context93.n=4;return this._retrievingEphemeralKey;case 4:this._ephemeralKey=_context93.v;case 5:_context93.n=7;break;case 6:_context93.p=6;_t32=_context93.v;this.displayFailedToRetrieveEphemeralKey(_t32);case 7:this._ephemeralKey&&(e?this.init(this._ephemeralKey):this.changeToAvailable());_context93.n=12;break;case 8:if(!i){_context93.n=12;break;}_context93.p=9;this._retrievingEphemeralKey=this.getEphemeralKey(i);_context93.n=10;return this._retrievingEphemeralKey;case 10:this._ephemeralKey=_context93.v;e&&this.init(this._ephemeralKey);_context93.n=12;break;case 11:_context93.p=11;_t33=_context93.v;this.displayFailedToRetrieveEphemeralKey(_t33);case 12:return _context93.a(2);}},_callee93,this,[[9,11],[1,6]]);}));function fetchEphemeralKey(_x185){return _fetchEphemeralKey.apply(this,arguments);}return fetchEphemeralKey;}()},{key:"getEphemeralKey",value:function(){var _getEphemeralKey=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(e){return _regenerator().w(function(_context94){while(1)switch(_context94.n){case 0:_context94.n=1;return fetch("".concat(Le,"realtime/sessions"),{method:he,body:JSON.stringify(this.rawBody),headers:_defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(e))});case 1:_context94.n=2;return _context94.v.json();case 2:return _context94.a(2,_context94.v.client_secret.value);}},_callee94,this);}));function getEphemeralKey(_x186){return _getEphemeralKey.apply(this,arguments);}return getEphemeralKey;}()},{key:"generateMethods",value:function generateMethods(){var _this43=this;return{updateConfig:function updateConfig(e){var t;(t=_this43._dc)==null||t.send(JSON.stringify(_defineProperty(_defineProperty({},T,"session.update"),"session",e)));},sendMessage:function sendMessage(e,t){var n=t||"system",s=[_defineProperty(_defineProperty({},T,n==="system"||n===H?wi:h),"text",e)],i=_defineProperty(_defineProperty({role:n},T,"message"),"content",s);_this43.sendMessage(i);}};}},{key:"createContainer",value:function createContainer(){var e=S();return e.id="deep-chat-openai-realtime-container",e.appendChild(this.createAvatarContainer()),e.appendChild(this.createButtonsContainer()),e.appendChild(this.createError()),e;}},{key:"createAvatarContainer",value:function createAvatarContainer(){var t,n;var e=S();return e.id="deep-chat-openai-realtime-avatar-container",Object.assign(e[_],(n=(t=this._avatarConfig)==null?void 0:t.styles)==null?void 0:n.container),e.appendChild(this._avatarEl),e;}},{key:"createButtonsContainer",value:function createButtonsContainer(){var s;var e=S();e.id="deep-chat-openai-realtime-buttons-container",Object.assign(e[_],(s=this._buttonsConfig)==null?void 0:s.container),this._microphoneButton=this.createMicophoneButton();var t=V.createButtonContainer(this._microphoneButton.elementRef);this._toggleButton=this.createToggleButton();var n=V.createButtonContainer(this._toggleButton.elementRef);return e.appendChild(t),e.appendChild(n),e.appendChild(this.createLoading()),e;}},{key:"createMicophoneButton",value:function createMicophoneButton(){var _this44=this;var t;var e=new Us((t=this._buttonsConfig)==null?void 0:t[Ye]);return e.elementRef[m].add(V.BUTTON_DEFAULT,"deep-chat-openai-realtime-microphone"),F.assignButtonEvents(e.elementRef,function(){e.isActive?(_this44.toggleMicorphone(!0),e.elementRef[m].replace(V.MICROPHONE_ACTIVE,V.BUTTON_DEFAULT),e.changeToDefault(),_this44._isMuted=!1):(_this44.toggleMicorphone(!1),e.elementRef[m].replace(V.BUTTON_DEFAULT,V.MICROPHONE_ACTIVE),ie.removeAriaAttributes(e.elementRef),e.changeToActive(),_this44._isMuted=!0);}),e;}},{key:"toggleMicorphone",value:function toggleMicorphone(e){var t;(t=this._mediaStream)==null||t.getAudioTracks().forEach(function(n){return n.enabled=e;});}},{key:"createToggleButton",value:function createToggleButton(){var _this45=this;var t;var e=new Us((t=this._buttonsConfig)==null?void 0:t.toggle);return e.elementRef[m].add(V.BUTTON_DEFAULT,"deep-chat-openai-realtime-toggle"),F.assignButtonEvents(e.elementRef,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(){var n,s,_t34,_t35;return _regenerator().w(function(_context95){while(1)switch(_context95.p=_context95.n){case 0:if(!e.isActive){_context95.n=1;break;}e.changeToDefault(),_this45.stop();_context95.n=9;break;case 1:_context95.p=1;if(!_this45._ephemeralKey){_context95.n=3;break;}_this45.displayLoading();_context95.n=2;return _this45.init(_this45._ephemeralKey);case 2:_context95.n=7;break;case 3:if(!_this45._retrievingEphemeralKey){_context95.n=6;break;}_this45.displayLoading();_context95.n=4;return _this45._retrievingEphemeralKey;case 4:s=_context95.v;_t34=(n=_this45._toggleButton)!=null&&n.isActive;if(!_t34){_context95.n=5;break;}_context95.n=5;return _this45.init(s);case 5:_context95.n=7;break;case 6:_this45.displayLoading();_context95.n=7;return _this45.fetchEphemeralKey(!0);case 7:_context95.n=9;break;case 8:_context95.p=8;_t35=_context95.v;console[f]("Failed to start conversation:",_t35),_this45.displayError(),_this45.hideLoading();case 9:return _context95.a(2);}},_callee95,null,[[1,8]]);}))),e;}},{key:"init",value:function(){var _init2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(e){var _this46=this;var t,n,s,i,o,a,l,c,_t38,_t39,_t40,_t41,_t42;return _regenerator().w(function(_context98){while(1)switch(_context98.p=_context98.n){case 0:t=new RTCPeerConnection();this._pc=t;n=S(L);n.autoplay=!0;s=new AudioContext(),i=s.createAnalyser();i.fftSize=256;o=new Uint8Array(i.frequencyBinCount);this._pc.ontrack=/*#__PURE__*/function(){var _ref84=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(a){var l,_t36;return _regenerator().w(function(_context96){while(1)switch(_context96.n){case 0:if(!a.streams[0]){_context96.n=2;break;}n.srcObject=a.streams[0];l=s.createMediaStreamSource(a.streams[0]);_t36=s.state==="suspended";if(!_t36){_context96.n=1;break;}_context96.n=1;return s.resume();case 1:l.connect(i);_this46.monitorFrequencies(i,o);_context96.n=3;break;case 2:console[f]("No streams found in the ontrack event."),_this46.displayError();case 3:return _context96.a(2);}},_callee96);}));return function(_x188){return _ref84.apply(this,arguments);};}();_context98.n=1;return navigator.mediaDevices.getUserMedia({audio:!0}).then(function(a){var l;t===_this46._pc&&(_this46._mediaStream=a,(l=_this46._pc)==null||l.addTrack(_this46._mediaStream.getTracks()[0]),_this46._isMuted&&_this46.toggleMicorphone(!1));})["catch"](function(a){console[f]("Error accessing microphone:",a),_this46.displayError();});case 1:this._dc=this._pc.createDataChannel("oai-events");this._dc.addEventListener("message",/*#__PURE__*/function(){var _ref85=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(a){var c,d,p,l,g,b,v,_t37;return _regenerator().w(function(_context97){while(1)switch(_context97.p=_context97.n){case 0:l=JSON.parse(a.data);if(!(l.type==="session.created")){_context97.n=1;break;}_this46.removeUnavailable(),_this46._toggleButton&&(ie.removeAriaAttributes(_this46._toggleButton.elementRef),_this46._toggleButton.changeToActive()),(d=(c=_this46._events)==null?void 0:c.started)==null||d.call(c),_this46._deepChat.dispatchEvent(new CustomEvent(Ac)),_this46.hideLoading();_context97.n=7;break;case 1:if(!(l.type==="response.done")){_context97.n=6;break;}g=(p=JSON.parse(a.data).response.output)==null?void 0:p[0];if(!((g==null?void 0:g.type)===As)){_context97.n=5;break;}b=g.name,v=g.call_id;_context97.p=2;_context97.n=3;return _this46.handleTool(b,g.arguments,v);case 3:_context97.n=5;break;case 4:_context97.p=4;_t37=_context97.v;_this46.stopOnError(_t37);case 5:_context97.n=7;break;case 6:l.type===f?_this46.stopOnError(l[f].message):l.type===We?_this46.stopOnError(l.message):l.type==="response.audio_transcript.delta"||(l.type==="response.audio_transcript.done"?l.transcript&&Xt.onMessage(_this46._deepChat,_defineProperty({role:K},h,l.transcript),!1):l.type==="conversation.item.input_audio_transcription.completed"&&l.transcript&&Xt.onMessage(_this46._deepChat,_defineProperty({role:H},h,l.transcript),!1));case 7:return _context97.a(2);}},_callee97,null,[[2,4]]);}));return function(_x189){return _ref85.apply(this,arguments);};}());_context98.p=2;_context98.n=3;return this._pc.createOffer();case 3:a=_context98.v;_t38=t!==this._pc;if(_t38){_context98.n=5;break;}_context98.n=4;return this._pc.setLocalDescription(a);case 4:_t38=t!==this._pc;case 5:if(!_t38){_context98.n=6;break;}return _context98.a(2);case 6:_context98.n=7;return fetch("".concat(Le,"realtime"),{method:he,body:a.sdp,headers:_defineProperty(_defineProperty({},oe,"".concat(ye).concat(e)),D,"application/sdp")});case 7:l=_context98.v;if(!(t!==this._pc)){_context98.n=8;break;}return _context98.a(2);case 8:_t39=_defineProperty;_t40=_defineProperty({},T,"answer");_context98.n=9;return l[h]();case 9:c=_t39(_t40,"sdp",_context98.v);_t41=t!==this._pc;if(_t41){_context98.n=11;break;}_context98.n=10;return this._pc.setRemoteDescription(c);case 10:_t41=t!==this._pc;case 11:if(!_t41){_context98.n=12;break;}return _context98.a(2);case 12:_context98.n=14;break;case 13:_context98.p=13;_t42=_context98.v;console[f](_t42),this.displayError();case 14:return _context98.a(2);}},_callee98,this,[[2,13]]);}));function init(_x187){return _init2.apply(this,arguments);}return init;}()// there is a bug where sometimes upon refreshing the browser too many times the frequencyData is all 0s
176
+ },{key:"setUpView",value:function setUpView(e,t){e[_].display="none",t.appendChild(this._containerEl),this.setup();}},{key:"setup",value:function(){var _setup=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee92(){var s,e,t,n;return _regenerator().w(function(_context92){while(1)switch(_context92.n){case 0:e=(s=this._deepChat.directConnection)==null?void 0:s.openAI;if(e){_context92.n=1;break;}return _context92.a(2);case 1:t=e==null?void 0:e.realtime;if(!(_typeof(t)!="object"||!t.autoStart&&!t.autoFetchEphemeralKey)){_context92.n=2;break;}return _context92.a(2);case 2:n=this.key||e.key;(t.fetchEphemeralKey||n)&&t.autoStart&&(this.changeToUnavailable(),this.displayLoading()),this.fetchEphemeralKey(t.autoStart);case 3:return _context92.a(2);}},_callee92,this);}));function setup(){return _setup.apply(this,arguments);}return setup;}()},{key:"fetchEphemeralKey",value:function(){var _fetchEphemeralKey=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee93(e){var o,t,n,s,i,a,_t31,_t32,_t33;return _regenerator().w(function(_context93){while(1)switch(_context93.p=_context93.n){case 0:t=(o=this._deepChat.directConnection)==null?void 0:o.openAI,n=_typeof(t==null?void 0:t.realtime)=="object"?t==null?void 0:t.realtime.fetchEphemeralKey:void 0,s=t==null?void 0:t.realtime,i=this.key||t.key;if(!(_typeof(s)=="object")){_context93.n=8;break;}if(this._ephemeralKey){_context93.n=7;break;}_context93.p=1;if(!n){_context93.n=3;break;}a=n();a.then&&(this._retrievingEphemeralKey=a);_context93.n=2;return a;case 2:this._ephemeralKey=_context93.v;_context93.n=5;break;case 3:_t31=i;if(!_t31){_context93.n=5;break;}this._retrievingEphemeralKey=this.getEphemeralKey(i);_context93.n=4;return this._retrievingEphemeralKey;case 4:this._ephemeralKey=_context93.v;case 5:_context93.n=7;break;case 6:_context93.p=6;_t32=_context93.v;this.displayFailedToRetrieveEphemeralKey(_t32);case 7:this._ephemeralKey&&(e?this.init(this._ephemeralKey):this.changeToAvailable());_context93.n=12;break;case 8:if(!i){_context93.n=12;break;}_context93.p=9;this._retrievingEphemeralKey=this.getEphemeralKey(i);_context93.n=10;return this._retrievingEphemeralKey;case 10:this._ephemeralKey=_context93.v;e&&this.init(this._ephemeralKey);_context93.n=12;break;case 11:_context93.p=11;_t33=_context93.v;this.displayFailedToRetrieveEphemeralKey(_t33);case 12:return _context93.a(2);}},_callee93,this,[[9,11],[1,6]]);}));function fetchEphemeralKey(_x185){return _fetchEphemeralKey.apply(this,arguments);}return fetchEphemeralKey;}()},{key:"getEphemeralKey",value:function(){var _getEphemeralKey=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee94(e){return _regenerator().w(function(_context94){while(1)switch(_context94.n){case 0:_context94.n=1;return fetch("".concat(Le,"realtime/sessions"),{method:he,body:JSON.stringify(this.rawBody),headers:_defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(e))});case 1:_context94.n=2;return _context94.v.json();case 2:return _context94.a(2,_context94.v.client_secret.value);}},_callee94,this);}));function getEphemeralKey(_x186){return _getEphemeralKey.apply(this,arguments);}return getEphemeralKey;}()},{key:"generateMethods",value:function generateMethods(){var _this43=this;return{updateConfig:function updateConfig(e){var t;(t=_this43._dc)==null||t.send(JSON.stringify(_defineProperty(_defineProperty({},T,"session.update"),"session",e)));},sendMessage:function sendMessage(e,t){var n=t||"system",s=[_defineProperty(_defineProperty({},T,n==="system"||n===H?Ci:h),"text",e)],i=_defineProperty(_defineProperty({role:n},T,"message"),"content",s);_this43.sendMessage(i);}};}},{key:"createContainer",value:function createContainer(){var e=S();return e.id="deep-chat-openai-realtime-container",e.appendChild(this.createAvatarContainer()),e.appendChild(this.createButtonsContainer()),e.appendChild(this.createError()),e;}},{key:"createAvatarContainer",value:function createAvatarContainer(){var t,n;var e=S();return e.id="deep-chat-openai-realtime-avatar-container",Object.assign(e[_],(n=(t=this._avatarConfig)==null?void 0:t.styles)==null?void 0:n.container),e.appendChild(this._avatarEl),e;}},{key:"createButtonsContainer",value:function createButtonsContainer(){var s;var e=S();e.id="deep-chat-openai-realtime-buttons-container",Object.assign(e[_],(s=this._buttonsConfig)==null?void 0:s.container),this._microphoneButton=this.createMicophoneButton();var t=V.createButtonContainer(this._microphoneButton.elementRef);this._toggleButton=this.createToggleButton();var n=V.createButtonContainer(this._toggleButton.elementRef);return e.appendChild(t),e.appendChild(n),e.appendChild(this.createLoading()),e;}},{key:"createMicophoneButton",value:function createMicophoneButton(){var _this44=this;var t;var e=new Us((t=this._buttonsConfig)==null?void 0:t[Ye]);return e.elementRef[m].add(V.BUTTON_DEFAULT,"deep-chat-openai-realtime-microphone"),F.assignButtonEvents(e.elementRef,function(){e.isActive?(_this44.toggleMicorphone(!0),e.elementRef[m].replace(V.MICROPHONE_ACTIVE,V.BUTTON_DEFAULT),e.changeToDefault(),_this44._isMuted=!1):(_this44.toggleMicorphone(!1),e.elementRef[m].replace(V.BUTTON_DEFAULT,V.MICROPHONE_ACTIVE),ie.removeAriaAttributes(e.elementRef),e.changeToActive(),_this44._isMuted=!0);}),e;}},{key:"toggleMicorphone",value:function toggleMicorphone(e){var t;(t=this._mediaStream)==null||t.getAudioTracks().forEach(function(n){return n.enabled=e;});}},{key:"createToggleButton",value:function createToggleButton(){var _this45=this;var t;var e=new Us((t=this._buttonsConfig)==null?void 0:t.toggle);return e.elementRef[m].add(V.BUTTON_DEFAULT,"deep-chat-openai-realtime-toggle"),F.assignButtonEvents(e.elementRef,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee95(){var n,s,_t34,_t35;return _regenerator().w(function(_context95){while(1)switch(_context95.p=_context95.n){case 0:if(!e.isActive){_context95.n=1;break;}e.changeToDefault(),_this45.stop();_context95.n=9;break;case 1:_context95.p=1;if(!_this45._ephemeralKey){_context95.n=3;break;}_this45.displayLoading();_context95.n=2;return _this45.init(_this45._ephemeralKey);case 2:_context95.n=7;break;case 3:if(!_this45._retrievingEphemeralKey){_context95.n=6;break;}_this45.displayLoading();_context95.n=4;return _this45._retrievingEphemeralKey;case 4:s=_context95.v;_t34=(n=_this45._toggleButton)!=null&&n.isActive;if(!_t34){_context95.n=5;break;}_context95.n=5;return _this45.init(s);case 5:_context95.n=7;break;case 6:_this45.displayLoading();_context95.n=7;return _this45.fetchEphemeralKey(!0);case 7:_context95.n=9;break;case 8:_context95.p=8;_t35=_context95.v;console[f]("Failed to start conversation:",_t35),_this45.displayError(),_this45.hideLoading();case 9:return _context95.a(2);}},_callee95,null,[[1,8]]);}))),e;}},{key:"init",value:function(){var _init2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee98(e){var _this46=this;var t,n,s,i,o,a,l,c,_t38,_t39,_t40,_t41,_t42;return _regenerator().w(function(_context98){while(1)switch(_context98.p=_context98.n){case 0:t=new RTCPeerConnection();this._pc=t;n=S(L);n.autoplay=!0;s=new AudioContext(),i=s.createAnalyser();i.fftSize=256;o=new Uint8Array(i.frequencyBinCount);this._pc.ontrack=/*#__PURE__*/function(){var _ref84=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee96(a){var l,_t36;return _regenerator().w(function(_context96){while(1)switch(_context96.n){case 0:if(!a.streams[0]){_context96.n=2;break;}n.srcObject=a.streams[0];l=s.createMediaStreamSource(a.streams[0]);_t36=s.state==="suspended";if(!_t36){_context96.n=1;break;}_context96.n=1;return s.resume();case 1:l.connect(i);_this46.monitorFrequencies(i,o);_context96.n=3;break;case 2:console[f]("No streams found in the ontrack event."),_this46.displayError();case 3:return _context96.a(2);}},_callee96);}));return function(_x188){return _ref84.apply(this,arguments);};}();_context98.n=1;return navigator.mediaDevices.getUserMedia({audio:!0}).then(function(a){var l;t===_this46._pc&&(_this46._mediaStream=a,(l=_this46._pc)==null||l.addTrack(_this46._mediaStream.getTracks()[0]),_this46._isMuted&&_this46.toggleMicorphone(!1));})["catch"](function(a){console[f]("Error accessing microphone:",a),_this46.displayError();});case 1:this._dc=this._pc.createDataChannel("oai-events");this._dc.addEventListener("message",/*#__PURE__*/function(){var _ref85=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee97(a){var c,d,p,l,g,b,v,_t37;return _regenerator().w(function(_context97){while(1)switch(_context97.p=_context97.n){case 0:l=JSON.parse(a.data);if(!(l.type==="session.created")){_context97.n=1;break;}_this46.removeUnavailable(),_this46._toggleButton&&(ie.removeAriaAttributes(_this46._toggleButton.elementRef),_this46._toggleButton.changeToActive()),(d=(c=_this46._events)==null?void 0:c.started)==null||d.call(c),_this46._deepChat.dispatchEvent(new CustomEvent(Ac)),_this46.hideLoading();_context97.n=7;break;case 1:if(!(l.type==="response.done")){_context97.n=6;break;}g=(p=JSON.parse(a.data).response.output)==null?void 0:p[0];if(!((g==null?void 0:g.type)===As)){_context97.n=5;break;}b=g.name,v=g.call_id;_context97.p=2;_context97.n=3;return _this46.handleTool(b,g.arguments,v);case 3:_context97.n=5;break;case 4:_context97.p=4;_t37=_context97.v;_this46.stopOnError(_t37);case 5:_context97.n=7;break;case 6:l.type===f?_this46.stopOnError(l[f].message):l.type===We?_this46.stopOnError(l.message):l.type==="response.audio_transcript.delta"||(l.type==="response.audio_transcript.done"?l.transcript&&Xt.onMessage(_this46._deepChat,_defineProperty({role:K},h,l.transcript),!1):l.type==="conversation.item.input_audio_transcription.completed"&&l.transcript&&Xt.onMessage(_this46._deepChat,_defineProperty({role:H},h,l.transcript),!1));case 7:return _context97.a(2);}},_callee97,null,[[2,4]]);}));return function(_x189){return _ref85.apply(this,arguments);};}());_context98.p=2;_context98.n=3;return this._pc.createOffer();case 3:a=_context98.v;_t38=t!==this._pc;if(_t38){_context98.n=5;break;}_context98.n=4;return this._pc.setLocalDescription(a);case 4:_t38=t!==this._pc;case 5:if(!_t38){_context98.n=6;break;}return _context98.a(2);case 6:_context98.n=7;return fetch("".concat(Le,"realtime"),{method:he,body:a.sdp,headers:_defineProperty(_defineProperty({},oe,"".concat(ye).concat(e)),D,"application/sdp")});case 7:l=_context98.v;if(!(t!==this._pc)){_context98.n=8;break;}return _context98.a(2);case 8:_t39=_defineProperty;_t40=_defineProperty({},T,"answer");_context98.n=9;return l[h]();case 9:c=_t39(_t40,"sdp",_context98.v);_t41=t!==this._pc;if(_t41){_context98.n=11;break;}_context98.n=10;return this._pc.setRemoteDescription(c);case 10:_t41=t!==this._pc;case 11:if(!_t41){_context98.n=12;break;}return _context98.a(2);case 12:_context98.n=14;break;case 13:_context98.p=13;_t42=_context98.v;console[f](_t42),this.displayError();case 14:return _context98.a(2);}},_callee98,this,[[2,13]]);}));function init(_x187){return _init2.apply(this,arguments);}return init;}()// there is a bug where sometimes upon refreshing the browser too many times the frequencyData is all 0s
177
177
  // in such instance please wait and refresh at a later time
178
- },{key:"monitorFrequencies",value:function monitorFrequencies(e,t){var _this47=this;var n=function(_n4){function n(){return _n4.apply(this,arguments);}n.toString=function(){return _n4.toString();};return n;}(function(){var c;e.getByteFrequencyData(t);var s=t.reduce(function(d,p){return d+p;},0),i=t.length*255,o=s/i*100,a=1,l=a+o/100*(((c=_this47._avatarConfig)==null?void 0:c.maxScale)-a);_this47._avatarEl[_].transform="scale(".concat(l,")"),requestAnimationFrame(n);});n();}},{key:"stopOnError",value:function stopOnError(e){this.stop(),console[f](e),this.displayError();}},{key:"stop",value:function stop(){var e,t,n;(e=this._mediaStream)==null||e.getTracks().forEach(function(s){return s.stop();}),this._mediaStream=null,this._pc&&(this._pc.close(),this._pc=null,(n=(t=this._events)==null?void 0:t.stopped)==null||n.call(t),this._deepChat.dispatchEvent(new CustomEvent(wc)),this._dc=void 0);}},{key:"changeToUnavailable",value:function changeToUnavailable(){this._microphoneButton&&V.changeButtonToUnavailable(this._microphoneButton),this._toggleButton&&V.changeButtonToUnavailable(this._toggleButton);}},{key:"changeToAvailable",value:function changeToAvailable(){this._microphoneButton&&V.changeButtonToAvailable(this._microphoneButton),this._toggleButton&&V.changeButtonToAvailable(this._toggleButton);}},{key:"removeUnavailable",value:function removeUnavailable(){this._microphoneButton&&V.removeButtonUnavailable(this._microphoneButton),this._toggleButton&&V.removeButtonUnavailable(this._toggleButton);}},{key:"createError",value:function createError(){var t;var e=S();return e.id="deep-chat-openai-realtime-error",Object.assign(e[_],(t=this._errorConfig)==null?void 0:t[_]),this._errorElement=e,e;}},{key:"displayFailedToRetrieveEphemeralKey",value:function displayFailedToRetrieveEphemeralKey(e){console[f]("Failed to retrieve ephemeral key"),console[f](e),this.displayError();}},{key:"displayError",value:function displayError(){var e;this._errorElement&&(this._errorElement[_].display="block",this._errorElement.textContent=((e=this._errorConfig)==null?void 0:e[h])||"Error",this.changeToUnavailable()),this.hideLoading();}},{key:"createLoading",value:function createLoading(){var t,n;var e=S();return e.id="deep-chat-openai-realtime-loading",this._loadingElement=e,(t=this._loadingConfig)!=null&&t[M]&&(this._loadingElement.innerHTML=this._loadingConfig[M]),Object.assign(e[_],(n=this._loadingConfig)==null?void 0:n[_]),e[_].display="none",e;}},{key:"displayLoading",value:function displayLoading(){var e,t,n;this._toggleButton&&(this._toggleButton.changeToActive(),this._toggleButton.elementRef[m].add(V.BUTTON_LOADING),ie.removeAriaDisabled(this._toggleButton.elementRef),ie.addAriaBusy(this._toggleButton.elementRef)),(typeof((e=this._loadingConfig)==null?void 0:e.display)!="boolean"||this._loadingConfig.display)&&this._loadingElement&&(this._loadingElement[_].display="block",(t=this._loadingConfig)!=null&&t[M]||(this._loadingElement.textContent=((n=this._loadingConfig)==null?void 0:n[h])||"Loading"));}},{key:"hideLoading",value:function hideLoading(){this._toggleButton&&(this._toggleButton.elementRef[m].remove(V.BUTTON_LOADING),ie.removeAriaBusy(this._toggleButton.elementRef)),this._loadingElement&&(this._loadingElement[_].display="none");}// https://platform.openai.com/docs/guides/function-calling?api-mode=responses
178
+ },{key:"monitorFrequencies",value:function monitorFrequencies(e,t){var _this47=this;var n=function(_n4){function n(){return _n4.apply(this,arguments);}n.toString=function(){return _n4.toString();};return n;}(function(){var c;e.getByteFrequencyData(t);var s=t.reduce(function(d,p){return d+p;},0),i=t.length*255,o=s/i*100,a=1,l=a+o/100*(((c=_this47._avatarConfig)==null?void 0:c.maxScale)-a);_this47._avatarEl[_].transform="scale(".concat(l,")"),requestAnimationFrame(n);});n();}},{key:"stopOnError",value:function stopOnError(e){this.stop(),console[f](e),this.displayError();}},{key:"stop",value:function stop(){var e,t,n;(e=this._mediaStream)==null||e.getTracks().forEach(function(s){return s.stop();}),this._mediaStream=null,this._pc&&(this._pc.close(),this._pc=null,(n=(t=this._events)==null?void 0:t.stopped)==null||n.call(t),this._deepChat.dispatchEvent(new CustomEvent(Cc)),this._dc=void 0);}},{key:"changeToUnavailable",value:function changeToUnavailable(){this._microphoneButton&&V.changeButtonToUnavailable(this._microphoneButton),this._toggleButton&&V.changeButtonToUnavailable(this._toggleButton);}},{key:"changeToAvailable",value:function changeToAvailable(){this._microphoneButton&&V.changeButtonToAvailable(this._microphoneButton),this._toggleButton&&V.changeButtonToAvailable(this._toggleButton);}},{key:"removeUnavailable",value:function removeUnavailable(){this._microphoneButton&&V.removeButtonUnavailable(this._microphoneButton),this._toggleButton&&V.removeButtonUnavailable(this._toggleButton);}},{key:"createError",value:function createError(){var t;var e=S();return e.id="deep-chat-openai-realtime-error",Object.assign(e[_],(t=this._errorConfig)==null?void 0:t[_]),this._errorElement=e,e;}},{key:"displayFailedToRetrieveEphemeralKey",value:function displayFailedToRetrieveEphemeralKey(e){console[f]("Failed to retrieve ephemeral key"),console[f](e),this.displayError();}},{key:"displayError",value:function displayError(){var e;this._errorElement&&(this._errorElement[_].display="block",this._errorElement.textContent=((e=this._errorConfig)==null?void 0:e[h])||"Error",this.changeToUnavailable()),this.hideLoading();}},{key:"createLoading",value:function createLoading(){var t,n;var e=S();return e.id="deep-chat-openai-realtime-loading",this._loadingElement=e,(t=this._loadingConfig)!=null&&t[M]&&(this._loadingElement.innerHTML=this._loadingConfig[M]),Object.assign(e[_],(n=this._loadingConfig)==null?void 0:n[_]),e[_].display="none",e;}},{key:"displayLoading",value:function displayLoading(){var e,t,n;this._toggleButton&&(this._toggleButton.changeToActive(),this._toggleButton.elementRef[m].add(V.BUTTON_LOADING),ie.removeAriaDisabled(this._toggleButton.elementRef),ie.addAriaBusy(this._toggleButton.elementRef)),(typeof((e=this._loadingConfig)==null?void 0:e.display)!="boolean"||this._loadingConfig.display)&&this._loadingElement&&(this._loadingElement[_].display="block",(t=this._loadingConfig)!=null&&t[M]||(this._loadingElement.textContent=((n=this._loadingConfig)==null?void 0:n[h])||"Loading"));}},{key:"hideLoading",value:function hideLoading(){this._toggleButton&&(this._toggleButton.elementRef[m].remove(V.BUTTON_LOADING),ie.removeAriaBusy(this._toggleButton.elementRef)),this._loadingElement&&(this._loadingElement[_].display="none");}// https://platform.openai.com/docs/guides/function-calling?api-mode=responses
179
179
  },{key:"handleTool",value:function(){var _handleTool=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee99(e,t,n){var s,i;return _regenerator().w(function(_context99){while(1)switch(_context99.n){case 0:if(this._functionHandlerI){_context99.n=1;break;}throw Error(kt);case 1:_context99.n=2;return this._functionHandlerI({name:e,arguments:t});case 2:s=_context99.v;if(!(_typeof(s)!="object"||!xe.isJson(s))){_context99.n=3;break;}throw Error('The `function_handler` response must be a JSON object, e.g. {response: "My response"}');case 3:i=_defineProperty(_defineProperty(_defineProperty({},T,Oo),"call_id",n),"output",JSON.stringify(s));this.sendMessage(i);case 4:return _context99.a(2);}},_callee99,this);}));function handleTool(_x190,_x191,_x192){return _handleTool.apply(this,arguments);}return handleTool;}()// https://platform.openai.com/docs/api-reference/realtime-client-events/conversation/item/create
180
- },{key:"sendMessage",value:function sendMessage(e){if(!this._dc)return;var t=JSON.stringify(_defineProperty(_defineProperty({},T,"conversation.item.create"),"item",e));this._dc.send(t);var n=_defineProperty({},T,"response.create");this._dc.send(JSON.stringify(n));}},{key:"isCustomView",value:function isCustomView(){return!0;}}],[{key:"getKey",value:function getKey(e){var t=e.directConnection.openAI;if(t!=null&&t.key)return t.key;var n=t==null?void 0:t.realtime;if(_typeof(n)=="object"&&(n.ephemeralKey||n.fetchEphemeralKey))return"placeholder";}},{key:"buildAvatarConfig",value:function buildAvatarConfig(e){var t=_typeof(e)=="object"&&e.avatar?JSON.parse(JSON.stringify(e.avatar)):{};return t.maxScale=t.maxScale&&t.maxScale>=1?t.maxScale:2.5,t;}},{key:"buildButtonsConfig",value:function buildButtonsConfig(e){var _t$Ye,_o$x,_a$svg,_l$content,_t$toggle,_u$x,_g$svg,_b$content,_v$active,_E$svg,_C$content;var n,s,i,o,a,l,c,d,p,u,g,b,v,E,C;var t=_typeof(e)=="object"&&e.buttons?JSON.parse(JSON.stringify(e.buttons)):{};return(i=(s=(n=t[Ye])==null?void 0:n[x])==null?void 0:s[h])!=null&&i.content||((_t$Ye=t[Ye])!==null&&_t$Ye!==void 0?_t$Ye:t[Ye]={},(_o$x=(o=t[Ye])[x])!==null&&_o$x!==void 0?_o$x:o[x]={},(_a$svg=(a=t[Ye][x]).svg)!==null&&_a$svg!==void 0?_a$svg:a.svg={},(_l$content=(l=t[Ye][x].svg).content)!==null&&_l$content!==void 0?_l$content:l.content=Do),(p=(d=(c=t.toggle)==null?void 0:c[x])==null?void 0:d[h])!=null&&p.content||((_t$toggle=t.toggle)!==null&&_t$toggle!==void 0?_t$toggle:t.toggle={},(_u$x=(u=t.toggle)[x])!==null&&_u$x!==void 0?_u$x:u[x]={},(_g$svg=(g=t.toggle[x]).svg)!==null&&_g$svg!==void 0?_g$svg:g.svg={},(_b$content=(b=t.toggle[x].svg).content)!==null&&_b$content!==void 0?_b$content:b.content=Fo,(_v$active=(v=t.toggle).active)!==null&&_v$active!==void 0?_v$active:v.active={},(_E$svg=(E=t.toggle.active).svg)!==null&&_E$svg!==void 0?_E$svg:E.svg={},(_C$content=(C=t.toggle.active.svg).content)!==null&&_C$content!==void 0?_C$content:C.content=Ti),t;}},{key:"createAvatar",value:function createAvatar(e){var n;var t=S("img");return t.id="deep-chat-openai-realtime-avatar",Object.assign(t[_],(n=e==null?void 0:e.styles)==null?void 0:n[q]),t[A]=(e==null?void 0:e[A])||Ei,t;}},{key:"createButtonContainer",value:function createButtonContainer(e){var t=S();return t[m].add("deep-chat-openai-realtime-button-container"),t.appendChild(e),t;}},{key:"changeButtonToUnavailable",value:function changeButtonToUnavailable(e){e.elementRef[m].add(V.UNAVAILABLE),ie.removeAriaBusy(e.elementRef),ie.addAriaDisabled(e.elementRef),e.changeToUnavailable();}},{key:"changeButtonToAvailable",value:function changeButtonToAvailable(e){V.removeButtonUnavailable(e),e.changeToDefault();}},{key:"removeButtonUnavailable",value:function removeButtonUnavailable(e){ie.removeAriaDisabled(e.elementRef),e.elementRef[m].remove(V.UNAVAILABLE);}}]);}(R);V.BUTTON_DEFAULT="deep-chat-openai-realtime-button-default",V.BUTTON_LOADING="deep-chat-openai-realtime-button-loading",V.MICROPHONE_ACTIVE="deep-chat-openai-realtime-microphone-active",V.UNAVAILABLE="deep-chat-openai-realtime-button-unavailable";var Ri=V;var cn=/*#__PURE__*/function(_R7){function cn(e){var _o$model3,_a$voice3;var _this48;_classCallCheck(this,cn);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t==null?void 0:t.openAI;_this48=_callSuper(this,cn,[e,En(),_n,n]),_this48.insertKeyPlaceholderText=_this48.genereteAPIKeyName("OpenAI"),_this48.keyHelpUrl=vn,_this48.url="".concat(Le,"audio/speech"),_this48.permittedErrorPrefixes=[Ot];var s=(i=t==null?void 0:t.openAI)==null?void 0:i.textToSpeech;_typeof(s)===B&&Object.assign(_this48.rawBody,s),(_o$model3=(o=_this48.rawBody).model)!==null&&_o$model3!==void 0?_o$model3:o.model=cn.DEFAULT_MODEL,(_a$voice3=(a=_this48.rawBody).voice)!==null&&_a$voice3!==void 0?_a$voice3:a.voice=cn.DEFAULT_VOIDE,_this48.textInputPlaceholderText="Insert text to generate audio",_this48.rawBody.response_format="mp3";return _this48;}_inherits(cn,_R7);return _createClass(cn,[{key:"preprocessBody",value:function preprocessBody(e,t){var i,o;var n=JSON.parse(JSON.stringify(e)),s=(o=(i=t[t.length-1])==null?void 0:i[h])==null?void 0:o.trim();return s&&s!==""&&(n.input=s),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI10=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(e,t){return _regenerator().w(function(_context100){while(1)switch(_context100.n){case 0:this.url=this.connectSettings.url||this.url,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context100.a(2);}},_callee100,this);}));function callServiceAPI(_x193,_x194){return _callServiceAPI10.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData13=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(e){return _regenerator().w(function(_context101){while(1)switch(_context101.n){case 0:if(!(e instanceof Blob)){_context101.n=1;break;}return _context101.a(2,new Promise(function(t){var n=new FileReader();n.readAsDataURL(e),n.onload=function(s){t(_defineProperty({},y,[_defineProperty(_defineProperty({},A,s.target.result),T,L)]));};}));case 1:if(!e[f]){_context101.n=2;break;}throw e[f].message;case 2:return _context101.a(2,_defineProperty({},f,f));}},_callee101);}));function extractResultData(_x195){return _extractResultData13.apply(this,arguments);}return extractResultData;}()}]);}(R);cn.DEFAULT_MODEL="tts-1",cn.DEFAULT_VOIDE="alloy";var Ii=cn;var Ke=/*#__PURE__*/function(_R8){function Ke(e){var _o$model4;var _this49;_classCallCheck(this,Ke);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t==null?void 0:t.openAI;_this49=_callSuper(this,Ke,[e,En(),_n,n,{audio:{}}]),_this49.insertKeyPlaceholderText=_this49.genereteAPIKeyName("OpenAI"),_this49.keyHelpUrl=vn,_this49.url="",_this49.permittedErrorPrefixes=[Ot],_this49.textInputPlaceholderText=qi,_this49._service_url=Ke.AUDIO_TRANSCRIPTIONS_URL;var s=(i=t==null?void 0:t.openAI)==null?void 0:i[L];_typeof(s)=="object"&&(_this49.processConfig(s),Ke.cleanConfig(s),Object.assign(_this49.rawBody,s)),(_o$model4=(o=_this49.rawBody).model)!==null&&_o$model4!==void 0?_o$model4:o.model=Ke.DEFAULT_MODEL,_this49.rawBody.response_format="json",_this49.canSendMessage=Ke.canSendFileMessage;return _this49;}_inherits(Ke,_R8);return _createClass(Ke,[{key:"processConfig",value:function processConfig(e){e!=null&&e.type&&e.type==="translation"&&(this._service_url=Ke.AUDIO_TRANSLATIONS_URL,delete e.language);}},{key:"preprocessBody",value:function preprocessBody(e,t){var i,o;var n=JSON.parse(JSON.stringify(e)),s=(o=(i=t[t.length-1])==null?void 0:i[h])==null?void 0:o.trim();return s&&s!==""&&(n.prompt=s),n;}// prettier-ignore
180
+ },{key:"sendMessage",value:function sendMessage(e){if(!this._dc)return;var t=JSON.stringify(_defineProperty(_defineProperty({},T,"conversation.item.create"),"item",e));this._dc.send(t);var n=_defineProperty({},T,"response.create");this._dc.send(JSON.stringify(n));}},{key:"isCustomView",value:function isCustomView(){return!0;}}],[{key:"getKey",value:function getKey(e){var t=e.directConnection.openAI;if(t!=null&&t.key)return t.key;var n=t==null?void 0:t.realtime;if(_typeof(n)=="object"&&(n.ephemeralKey||n.fetchEphemeralKey))return"placeholder";}},{key:"buildAvatarConfig",value:function buildAvatarConfig(e){var t=_typeof(e)=="object"&&e.avatar?JSON.parse(JSON.stringify(e.avatar)):{};return t.maxScale=t.maxScale&&t.maxScale>=1?t.maxScale:2.5,t;}},{key:"buildButtonsConfig",value:function buildButtonsConfig(e){var _t$Ye,_o$x,_a$svg,_l$content,_t$toggle,_u$x,_g$svg,_b$content,_v$active,_E$svg,_w$content;var n,s,i,o,a,l,c,d,p,u,g,b,v,E,w;var t=_typeof(e)=="object"&&e.buttons?JSON.parse(JSON.stringify(e.buttons)):{};return(i=(s=(n=t[Ye])==null?void 0:n[x])==null?void 0:s[h])!=null&&i.content||((_t$Ye=t[Ye])!==null&&_t$Ye!==void 0?_t$Ye:t[Ye]={},(_o$x=(o=t[Ye])[x])!==null&&_o$x!==void 0?_o$x:o[x]={},(_a$svg=(a=t[Ye][x]).svg)!==null&&_a$svg!==void 0?_a$svg:a.svg={},(_l$content=(l=t[Ye][x].svg).content)!==null&&_l$content!==void 0?_l$content:l.content=Do),(p=(d=(c=t.toggle)==null?void 0:c[x])==null?void 0:d[h])!=null&&p.content||((_t$toggle=t.toggle)!==null&&_t$toggle!==void 0?_t$toggle:t.toggle={},(_u$x=(u=t.toggle)[x])!==null&&_u$x!==void 0?_u$x:u[x]={},(_g$svg=(g=t.toggle[x]).svg)!==null&&_g$svg!==void 0?_g$svg:g.svg={},(_b$content=(b=t.toggle[x].svg).content)!==null&&_b$content!==void 0?_b$content:b.content=Fo,(_v$active=(v=t.toggle).active)!==null&&_v$active!==void 0?_v$active:v.active={},(_E$svg=(E=t.toggle.active).svg)!==null&&_E$svg!==void 0?_E$svg:E.svg={},(_w$content=(w=t.toggle.active.svg).content)!==null&&_w$content!==void 0?_w$content:w.content=Ti),t;}},{key:"createAvatar",value:function createAvatar(e){var n;var t=S("img");return t.id="deep-chat-openai-realtime-avatar",Object.assign(t[_],(n=e==null?void 0:e.styles)==null?void 0:n[q]),t[A]=(e==null?void 0:e[A])||Ei,t;}},{key:"createButtonContainer",value:function createButtonContainer(e){var t=S();return t[m].add("deep-chat-openai-realtime-button-container"),t.appendChild(e),t;}},{key:"changeButtonToUnavailable",value:function changeButtonToUnavailable(e){e.elementRef[m].add(V.UNAVAILABLE),ie.removeAriaBusy(e.elementRef),ie.addAriaDisabled(e.elementRef),e.changeToUnavailable();}},{key:"changeButtonToAvailable",value:function changeButtonToAvailable(e){V.removeButtonUnavailable(e),e.changeToDefault();}},{key:"removeButtonUnavailable",value:function removeButtonUnavailable(e){ie.removeAriaDisabled(e.elementRef),e.elementRef[m].remove(V.UNAVAILABLE);}}]);}(R);V.BUTTON_DEFAULT="deep-chat-openai-realtime-button-default",V.BUTTON_LOADING="deep-chat-openai-realtime-button-loading",V.MICROPHONE_ACTIVE="deep-chat-openai-realtime-microphone-active",V.UNAVAILABLE="deep-chat-openai-realtime-button-unavailable";var Ri=V;var cn=/*#__PURE__*/function(_R7){function cn(e){var _o$model3,_a$voice3;var _this48;_classCallCheck(this,cn);var i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t==null?void 0:t.openAI;_this48=_callSuper(this,cn,[e,En(),_n,n]),_this48.insertKeyPlaceholderText=_this48.genereteAPIKeyName("OpenAI"),_this48.keyHelpUrl=vn,_this48.url="".concat(Le,"audio/speech"),_this48.permittedErrorPrefixes=[Ot];var s=(i=t==null?void 0:t.openAI)==null?void 0:i.textToSpeech;_typeof(s)===B&&Object.assign(_this48.rawBody,s),(_o$model3=(o=_this48.rawBody).model)!==null&&_o$model3!==void 0?_o$model3:o.model=cn.DEFAULT_MODEL,(_a$voice3=(a=_this48.rawBody).voice)!==null&&_a$voice3!==void 0?_a$voice3:a.voice=cn.DEFAULT_VOIDE,_this48.textInputPlaceholderText="Insert text to generate audio",_this48.rawBody.response_format="mp3";return _this48;}_inherits(cn,_R7);return _createClass(cn,[{key:"preprocessBody",value:function preprocessBody(e,t){var i,o;var n=JSON.parse(JSON.stringify(e)),s=(o=(i=t[t.length-1])==null?void 0:i[h])==null?void 0:o.trim();return s&&s!==""&&(n.input=s),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI10=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee100(e,t){return _regenerator().w(function(_context100){while(1)switch(_context100.n){case 0:this.url=this.connectSettings.url||this.url,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context100.a(2);}},_callee100,this);}));function callServiceAPI(_x193,_x194){return _callServiceAPI10.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData13=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee101(e){return _regenerator().w(function(_context101){while(1)switch(_context101.n){case 0:if(!(e instanceof Blob)){_context101.n=1;break;}return _context101.a(2,new Promise(function(t){var n=new FileReader();n.readAsDataURL(e),n.onload=function(s){t(_defineProperty({},y,[_defineProperty(_defineProperty({},A,s.target.result),T,L)]));};}));case 1:if(!e[f]){_context101.n=2;break;}throw e[f].message;case 2:return _context101.a(2,_defineProperty({},f,f));}},_callee101);}));function extractResultData(_x195){return _extractResultData13.apply(this,arguments);}return extractResultData;}()}]);}(R);cn.DEFAULT_MODEL="tts-1",cn.DEFAULT_VOIDE="alloy";var Ii=cn;var Ke=/*#__PURE__*/function(_R8){function Ke(e){var _o$model4;var _this49;_classCallCheck(this,Ke);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t==null?void 0:t.openAI;_this49=_callSuper(this,Ke,[e,En(),_n,n,{audio:{}}]),_this49.insertKeyPlaceholderText=_this49.genereteAPIKeyName("OpenAI"),_this49.keyHelpUrl=vn,_this49.url="",_this49.permittedErrorPrefixes=[Ot],_this49.textInputPlaceholderText=qi,_this49._service_url=Ke.AUDIO_TRANSCRIPTIONS_URL;var s=(i=t==null?void 0:t.openAI)==null?void 0:i[L];_typeof(s)=="object"&&(_this49.processConfig(s),Ke.cleanConfig(s),Object.assign(_this49.rawBody,s)),(_o$model4=(o=_this49.rawBody).model)!==null&&_o$model4!==void 0?_o$model4:o.model=Ke.DEFAULT_MODEL,_this49.rawBody.response_format="json",_this49.canSendMessage=Ke.canSendFileMessage;return _this49;}_inherits(Ke,_R8);return _createClass(Ke,[{key:"processConfig",value:function processConfig(e){e!=null&&e.type&&e.type==="translation"&&(this._service_url=Ke.AUDIO_TRANSLATIONS_URL,delete e.language);}},{key:"preprocessBody",value:function preprocessBody(e,t){var i,o;var n=JSON.parse(JSON.stringify(e)),s=(o=(i=t[t.length-1])==null?void 0:i[h])==null?void 0:o.trim();return s&&s!==""&&(n.prompt=s),n;}// prettier-ignore
181
181
  },{key:"callServiceAPI",value:function(){var _callServiceAPI11=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee102(e,t,n){var o,s,i;return _regenerator().w(function(_context102){while(1)switch(_context102.n){case 0:if((o=this.connectSettings)!=null&&o.headers){_context102.n=1;break;}throw new Error(Me);case 1:if(n!=null&&n[0]){_context102.n=2;break;}throw new Error(Qs);case 2:this.url=this.connectSettings.url||this._service_url;s=this.preprocessBody(this.rawBody,t),i=Ke.createFormDataBody(s,n[0]);P.tempRemoveContentHeader(this.connectSettings,re.request.bind(this,this,i,e),!1);case 3:return _context102.a(2);}},_callee102,this);}));function callServiceAPI(_x196,_x197,_x198){return _callServiceAPI11.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData14=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee103(e){return _regenerator().w(function(_context103){while(1)switch(_context103.n){case 0:if(!e[f]){_context103.n=1;break;}throw e[f].message;case 1:return _context103.a(2,_defineProperty({},h,e[h]));}},_callee103);}));function extractResultData(_x199){return _extractResultData14.apply(this,arguments);}return extractResultData;}()}],[{key:"canSendFileMessage",value:function canSendFileMessage(e,t){return!!(t!=null&&t[0]);}},{key:"cleanConfig",value:function cleanConfig(e){delete e.type;}},{key:"createFormDataBody",value:function createFormDataBody(e,t){var n=new FormData();return n.append(ee,t),Object.keys(e).forEach(function(s){n.append(s,String(e[s]));}),n;}}]);}(R);Ke.AUDIO_TRANSCRIPTIONS_URL="".concat(Le,"audio/transcriptions"),Ke.AUDIO_TRANSLATIONS_URL="".concat(Le,"audio/translations"),Ke.DEFAULT_MODEL="whisper-1";var Mi=Ke;var Sn="Ocp-Apim-Subscription-Key",Uo=// eslint-disable-next-line max-len
182
- "https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",Cc=function Cc(r,e){return _defineProperty(_defineProperty(_defineProperty({},Sn,e),D,"application/ssml+xml"),"X-Microsoft-OutputFormat",r);},Tc=function Tc(r){return _defineProperty(_defineProperty({},Sn,r),"Accept",W);},Rc=function Rc(r,e,t,n){r[f]?n(le):t(e);},Ic=function Ic(r){return{url:"https://".concat(r,".api.cognitive.microsoft.com/sts/v1.0/issuetoken"),method:he,createHeaders:function createHeaders(e){return _defineProperty({},Sn,"".concat(e));},handleVerificationResult:Rc};},Mc=function Mc(r){return _defineProperty(_defineProperty({},Sn,r),D,W);},kc=function kc(r,e,t,n){var i;((i=r[f])==null?void 0:i.code)==="401"?n(le):t(e);},Oc=function Oc(r){return{url:"".concat(r,"/language/analyze-text/jobs?api-version=2022-10-01-preview"),method:he,createHeaders:function createHeaders(e){return _defineProperty({},Sn,"".concat(e));},handleVerificationResult:kc};},Nc=function Nc(r,e,t,n){r.json().then(function(i){!Array.isArray(i)&&i[f].code===401e3?n(le):t(e);});},Pc=function Pc(r){return{url:"https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es",method:he,createHeaders:function createHeaders(e){return Ho(r,e);},handleVerificationResult:Nc};},Ho=function Ho(r,e){var t=_defineProperty(_defineProperty({},Sn,e),D,W);return r&&(t["Ocp-Apim-Subscription-Region"]=r),t;};var Lc=/*#__PURE__*/function(_R9){// prettier-ignore
182
+ "https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",wc=function wc(r,e){return _defineProperty(_defineProperty(_defineProperty({},Sn,e),D,"application/ssml+xml"),"X-Microsoft-OutputFormat",r);},Tc=function Tc(r){return _defineProperty(_defineProperty({},Sn,r),"Accept",W);},Rc=function Rc(r,e,t,n){r[f]?n(le):t(e);},Ic=function Ic(r){return{url:"https://".concat(r,".api.cognitive.microsoft.com/sts/v1.0/issuetoken"),method:he,createHeaders:function createHeaders(e){return _defineProperty({},Sn,"".concat(e));},handleVerificationResult:Rc};},Mc=function Mc(r){return _defineProperty(_defineProperty({},Sn,r),D,W);},kc=function kc(r,e,t,n){var i;((i=r[f])==null?void 0:i.code)==="401"?n(le):t(e);},Oc=function Oc(r){return{url:"".concat(r,"/language/analyze-text/jobs?api-version=2022-10-01-preview"),method:he,createHeaders:function createHeaders(e){return _defineProperty({},Sn,"".concat(e));},handleVerificationResult:kc};},Nc=function Nc(r,e,t,n){r.json().then(function(i){!Array.isArray(i)&&i[f].code===401e3?n(le):t(e);});},Pc=function Pc(r){return{url:"https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es",method:he,createHeaders:function createHeaders(e){return Ho(r,e);},handleVerificationResult:Nc};},Ho=function Ho(r,e){var t=_defineProperty(_defineProperty({},Sn,e),D,W);return r&&(t["Ocp-Apim-Subscription-Region"]=r),t;};var Lc=/*#__PURE__*/function(_R9){// prettier-ignore
183
183
  function Lc(e,t,n,s,i){var _this50;_classCallCheck(this,Lc);_this50=_callSuper(this,Lc,[e,Oc(n),t,s,i]),_this50.insertKeyPlaceholderText="Azure Language Subscription Key",_this50.keyHelpUrl=Uo,_this50.permittedErrorPrefixes=["Access"];return _this50;}_inherits(Lc,_R9);return _createClass(Lc);}(R);var ss=/*#__PURE__*/function(_Lc){function ss(e){var _a$language;var _this51;_classCallCheck(this,ss);var s,i,o,a;var t=(i=(s=e.directConnection)==null?void 0:s.azure)==null?void 0:i.summarization,n=(o=e.directConnection)==null?void 0:o.azure;_this51=_callSuper(this,ss,[e,Mc,t.endpoint,n]),_this51.permittedErrorPrefixes=[ss.ENDPOINT_ERROR_MESSAGE],_this51.url="",_this51.textInputPlaceholderText="Insert text to summarize",_this51.isTextInputDisabled=!1,t.endpoint?((_a$language=(a=_this51.rawBody).language)!==null&&_a$language!==void 0?_a$language:a.language="en",Object.assign(_this51.rawBody,t),_this51.url="".concat(t.endpoint,"/language/analyze-text/jobs?api-version=2022-10-01-preview")):(_this51.isTextInputDisabled=!0,_this51.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,ss.ENDPOINT_ERROR_MESSAGE));}));return _this51;}_inherits(ss,_Lc);return _createClass(ss,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h];if(n)return{analysisInput:{documents:[_defineProperty({id:"1",language:e.language},h,n)]},tasks:[{kind:"ExtractiveSummarization"}]};}},{key:"callServiceAPI",value:function(){var _callServiceAPI12=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee104(e,t){return _regenerator().w(function(_context104){while(1)switch(_context104.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)),this.messages=e;case 1:return _context104.a(2);}},_callee104,this);}));function callServiceAPI(_x200,_x201){return _callServiceAPI12.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData15=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee105(e){var t,_n6,s;return _regenerator().w(function(_context105){while(1)switch(_context105.n){case 0:if(!e[f]){_context105.n=1;break;}throw e[f].message;case 1:if(this.messages&&this.completionsHandlers){this.asyncCallInProgress=!0;_n6=e.headers.get("operation-location"),s={method:ae,headers:(t=this.connectSettings)==null?void 0:t.headers};re.executePollRequest(this,_n6,s,this.messages);}return _context105.a(2,_defineProperty({},h,""));}},_callee105,this);}));function extractResultData(_x202){return _extractResultData15.apply(this,arguments);}return extractResultData;}()},{key:"extractPollResultData",value:function(){var _extractPollResultData5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee106(e){var t,_iterator,_step,_n7;return _regenerator().w(function(_context106){while(1)switch(_context106.n){case 0:if(!e[f]){_context106.n=1;break;}throw e[f];case 1:if(!(e.status==="running"||e.status==="notStarted")){_context106.n=2;break;}return _context106.a(2,{timeoutMS:2e3});case 2:if(!(e.errors.length>0)){_context106.n=3;break;}throw e.errors[0];case 3:if(!(e.tasks.items[0].results.errors.length>0)){_context106.n=4;break;}throw e.tasks.items[0].results.errors[0];case 4:t="";_iterator=_createForOfIteratorHelper(e.tasks.items[0].results.documents[0].sentences);try{for(_iterator.s();!(_step=_iterator.n()).done;){_n7=_step.value;t+=_n7[h];}}catch(err){_iterator.e(err);}finally{_iterator.f();}return _context106.a(2,_defineProperty({},h,t||""));}},_callee106);}));function extractPollResultData(_x203){return _extractPollResultData5.apply(this,arguments);}return extractPollResultData;}()}]);}(Lc);ss.ENDPOINT_ERROR_MESSAGE=// eslint-disable-next-line max-len
184
184
  "Please define the azure endpoint. [More Information](".concat($,"directConnection/Azure#Summarization)");var ki=ss;var Bc=/*#__PURE__*/function(){var _ref97=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee107(r,e){var t,o,a,c,_t46;return _regenerator().w(function(_context107){while(1)switch(_context107.n){case 0:t=_defineProperty(_defineProperty({},da,r),ha,W);_t46="https://api.assemblyai.com/v2/transcript/";_context107.n=1;return fetch("https://api.assemblyai.com/v2/transcript",{method:he,body:JSON.stringify({audio_url:e}),headers:t});case 1:_context107.n=2;return _context107.v.json();case 2:o=_t46.concat.call(_t46,_context107.v.id);case 3:if(a){_context107.n=9;break;}_context107.n=4;return fetch(o,{headers:t});case 4:_context107.n=5;return _context107.v.json();case 5:c=_context107.v;if(!(c.status===ji)){_context107.n=6;break;}a=c;_context107.n=8;break;case 6:if(!(c.status===f)){_context107.n=7;break;}throw new Error("Transcription failed: ".concat(c[f]));case 7:_context107.n=8;return new Promise(function(d){return setTimeout(d,3e3);});case 8:_context107.n=3;break;case 9:return _context107.a(2,a);}},_callee107);}));return function Bc(_x204,_x205){return _ref97.apply(this,arguments);};}(),Dc=function Dc(r){return _defineProperty(_defineProperty({},oe,r),D,"application/octet-stream");},Fc=function Fc(r,e,t,n){var s=r;s[f]?s[f].code==="invalid_api_key"?n(le):n(He):t(e);},Uc=function Uc(){return ce("https://api.assemblyai.com/v2/upload",he,Fc);};var Zi=/*#__PURE__*/function(_R0){function Zi(e){var _this52;_classCallCheck(this,Zi);var n;var t=(n=e.directConnection)==null?void 0:n.assemblyAI;_this52=_callSuper(this,Zi,[e,Uc(),Dc,t,{audio:{}}]),_this52.insertKeyPlaceholderText=_this52.genereteAPIKeyName("AssemblyAI"),_this52.keyHelpUrl="https://www.assemblyai.com/app/account",_this52.url="https://api.assemblyai.com/v2/upload",_this52.isTextInputDisabled=!0,_this52.textInputPlaceholderText=qi,_this52.permittedErrorPrefixes=[_o,Ot],_this52.canSendMessage=Zi.canFileSendMessage;return _this52;}_inherits(Zi,_R0);return _createClass(Zi,[{key:"callServiceAPI",value:function(){var _callServiceAPI13=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee108(e,t,n){var s;return _regenerator().w(function(_context108){while(1)switch(_context108.n){case 0:if((s=this.connectSettings)!=null&&s.headers){_context108.n=1;break;}throw new Error(Me);case 1:if(n!=null&&n[0]){_context108.n=2;break;}throw new Error(Qs);case 2:re.request(this,n[0],e,!1);case 3:return _context108.a(2);}},_callee108,this);}));function callServiceAPI(_x206,_x207,_x208){return _callServiceAPI13.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData16=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee109(e){var s,i,t,n;return _regenerator().w(function(_context109){while(1)switch(_context109.n){case 0:if(!e[f]){_context109.n=1;break;}throw e[f];case 1:t=(i=(s=this.connectSettings)==null?void 0:s.headers)==null?void 0:i[oe];_context109.n=2;return Bc(t,e.upload_url);case 2:n=_context109.v;return _context109.a(2,_defineProperty({},h,n[h]));}},_callee109,this);}));function extractResultData(_x209){return _extractResultData16.apply(this,arguments);}return extractResultData;}()}],[{key:"canFileSendMessage",value:function canFileSendMessage(e,t){return!!(t!=null&&t[0]);}}]);}(R);var Hs=/*#__PURE__*/function(_R1){// prettier-ignore
185
185
  function Hs(e,t,n,s,i){var _this53$maxMessages,_u$model;var _this53;_classCallCheck(this,Hs);var p,u;var o=JSON.parse(JSON.stringify(e.directConnection)),a=t||En(),l=n||_n,c=s||o.openAI;_this53=_callSuper(this,Hs,[e,a,l,c]),_this53.insertKeyPlaceholderText=_this53.genereteAPIKeyName("OpenAI"),_this53.keyHelpUrl="https://platform.openai.com/account/api-keys",_this53.permittedErrorPrefixes=[fs,"Invalid value"];var d=i||((p=o.openAI)==null?void 0:p.chat);_typeof(d)===B&&_this53.processConfig(d,e),(_this53$maxMessages=_this53.maxMessages)!==null&&_this53$maxMessages!==void 0?_this53$maxMessages:_this53.maxMessages=-1,(_u$model=(u=_this53.rawBody).model)!==null&&_u$model!==void 0?_u$model:u.model="gpt-4o";return _this53;}_inherits(Hs,_R1);return _createClass(Hs,[{key:"processConfig",value:function processConfig(e,t){var n,s,i;this.completeConfig(e,(i=(s=(n=t.directConnection)==null?void 0:n.openAI)==null?void 0:s.chat)==null?void 0:i.function_handler);}}],[{key:"getBaseFileContent",value:function getBaseFileContent(e){return e.map(function(t){var n,s,i;if(t.type===L){var o=(n=t[A])==null?void 0:n.split(",")[1],a=((i=(s=t.name)==null?void 0:s.split(".").pop())==null?void 0:i.toLowerCase())||"wav";return _defineProperty(_defineProperty({},T,Gt),Gt,{data:o,format:a});}return t;});}},{key:"getBaseContent",value:function getBaseContent(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;if(t&&e[y]&&e[y].length>0){var s=this.getBaseFileContent(e[y]);return e[h]&&e[h].trim().length>0&&s.unshift(_defineProperty(_defineProperty({},T,h),h,e[h])),s;}return e[h];}}]);}(R);var js=/*#__PURE__*/function(_Hs){function js(){var _this54;_classCallCheck(this,js);_this54=_callSuper(this,js,arguments),_this54.url="".concat(Le,"chat/completions");return _this54;}_inherits(js,_Hs);return _createClass(js,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:js.getContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI14=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee110(e,t){var _this$messages;return _regenerator().w(function(_context110){while(1)switch(_context110.n){case 0:(_this$messages=this.messages)!==null&&_this$messages!==void 0?_this$messages:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context110.a(2);}},_callee110,this);}));function callServiceAPI(_x210,_x211){return _callServiceAPI14.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData17=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee111(e,t){var n,s,i,o,a,l,c,d;return _regenerator().w(function(_context111){while(1)switch(_context111.n){case 0:if(!e[f]){_context111.n=1;break;}throw e[f].message;case 1:if(!((s=(n=e.choices)==null?void 0:n[0])!=null&&s.delta)){_context111.n=2;break;}return _context111.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!((o=(i=e.choices)==null?void 0:i[0])!=null&&o.message)){_context111.n=5;break;}if(!e.choices[0].message.tool_calls){_context111.n=3;break;}return _context111.a(2,this.handleToolsGeneric(e.choices[0].message,this.functionHandler,this.messages,t));case 3:if(!((a=e.choices[0].message)!=null&&a[L])){_context111.n=4;break;}c=this.deepChat.textToSpeech,d=_typeof(c)=="object"&&typeof((l=c==null?void 0:c[L])==null?void 0:l.displayText)=="boolean";return _context111.a(2,_defineProperty(_defineProperty({},y,[_defineProperty(_defineProperty({},A,"data:audio/wav;base64,".concat(e.choices[0].message[L].data)),T,L)]),h,d?e.choices[0].message[L].transcript:void 0));case 4:return _context111.a(2,_defineProperty({},h,e.choices[0].message.content));case 5:return _context111.a(2,_defineProperty({},h,""));}},_callee111,this);}));function extractResultData(_x212,_x213){return _extractResultData17.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee112(e,t){return _regenerator().w(function(_context112){while(1)switch(_context112.n){case 0:return _context112.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee112,this);}));function extractStreamResult(_x214,_x215){return _extractStreamResult.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return Hs.getBaseFileContent(e).map(function(n){return n.type===Gt?n:_defineProperty(_defineProperty({},T,Ne),Ne,{url:n[A]});});}},{key:"getContent",value:function getContent(e){if(e[y]&&e[y].length>0){var t=js.getFileContent(e[y]);return e[h]&&e[h].trim().length>0&&t.unshift(_defineProperty(_defineProperty({},T,h),h,e[h])),t;}return e[h];}}]);}(Hs);var hr=/*#__PURE__*/function(_R10){// prettier-ignore
186
186
  function hr(e,t,n,s,i){var _this55;_classCallCheck(this,hr);_this55=_callSuper(this,hr,[e,Ic(n),t,s,i]),_this55.insertKeyPlaceholderText="Azure Speech Subscription Key",_this55.keyHelpUrl=Uo;return _this55;}_inherits(hr,_R10);return _createClass(hr);}(R);hr.REGION_ERROR_PREFIX="Please define a region config property. [More Information](".concat($,"directConnection/Azure#");var gn=hr;var is=/*#__PURE__*/function(_gn){// prettier-ignore
187
- function is(e){var _a$lang,_l$name,_c$gender;var _this56;_classCallCheck(this,is);var s,i,o,a,l,c;var t=(i=(s=e.directConnection)==null?void 0:s.azure)==null?void 0:i.textToSpeech,n=(o=e.directConnection)==null?void 0:o.azure;_this56=_callSuper(this,is,[e,Cc.bind({},(t==null?void 0:t.outputFormat)||"audio-16khz-128kbitrate-mono-mp3"),t.region,n]),_this56.permittedErrorPrefixes=[is.REGION_ERROR_MESSAGE],_this56.isTextInputDisabled=!1,_this56.url="",t.region?(Object.assign(_this56.rawBody,t),(_a$lang=(a=_this56.rawBody).lang)!==null&&_a$lang!==void 0?_a$lang:a.lang="en-US",(_l$name=(l=_this56.rawBody).name)!==null&&_l$name!==void 0?_l$name:l.name="en-US-JennyNeural",(_c$gender=(c=_this56.rawBody).gender)!==null&&_c$gender!==void 0?_c$gender:c.gender="Female",_this56.url="https://".concat(t.region,".tts.speech.microsoft.com/cognitiveservices/v1")):(_this56.isTextInputDisabled=!0,_this56.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,is.REGION_ERROR_MESSAGE));}));return _this56;}_inherits(is,_gn);return _createClass(is,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h];if(n)return"<speak version='1.0' xml:lang='".concat(e.lang,"'>\n <voice xml:lang='").concat(e.lang,"' xml:gender='").concat(e.gender,"' name='").concat(e.name,"'>\n ").concat(n,"\n </voice>\n </speak>");}},{key:"callServiceAPI",value:function(){var _callServiceAPI15=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(e,t){return _regenerator().w(function(_context113){while(1)switch(_context113.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),void 0,!1);case 1:return _context113.a(2);}},_callee113,this);}));function callServiceAPI(_x216,_x217){return _callServiceAPI15.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(e){return _regenerator().w(function(_context114){while(1)switch(_context114.n){case 0:return _context114.a(2,new Promise(function(t){var n=new FileReader();n.readAsDataURL(e),n.onload=function(s){t(_defineProperty({},y,[_defineProperty(_defineProperty({},A,s.target.result),T,L)]));};}));}},_callee114);}));function extractResultData(_x218){return _extractResultData18.apply(this,arguments);}return extractResultData;}()}]);}(gn);is.REGION_ERROR_MESSAGE="".concat(gn.REGION_ERROR_PREFIX,"TextToSpeech)");var Oi=is;var dn=/*#__PURE__*/function(_gn2){function dn(e){var _this57;_classCallCheck(this,dn);var i,o,a;var t=(o=(i=e.directConnection)==null?void 0:i.azure)==null?void 0:o.speechToText,n=(a=e.directConnection)==null?void 0:a.azure,s={audio:_defineProperty({},y,{acceptedFormats:".wav,.ogg"})};if(_this57=_callSuper(this,dn,[e,Tc,t.region,n,s]),_this57.permittedErrorPrefixes=[dn.REGION_ERROR_MESSAGE],_this57.url="",_this57.isTextInputDisabled=!0,_this57.textInputPlaceholderText=qi,!t.region)_this57.isTextInputDisabled=!0,_this57.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,dn.REGION_ERROR_MESSAGE));});else{_this57.canSendMessage=dn.canFileSendMessage;var l=t.lang||"en-US";_this57.url="https://".concat(t.region,".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(l,"&format=detailed"),_this57.recordAudio=void 0;}return _this57;}_inherits(dn,_gn2);return _createClass(dn,[{key:"callServiceAPI",value:function(){var _callServiceAPI16=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(e,t,n){var s,i;return _regenerator().w(function(_context115){while(1)switch(_context115.n){case 0:if((s=this.connectSettings)!=null&&s.headers){_context115.n=1;break;}throw new Error(Me);case 1:if(n!=null&&n[0]){_context115.n=2;break;}throw new Error(Qs);case 2:(i=this.connectSettings)!=null&&i.headers&&(this.connectSettings.headers[D]=n[0].name.toLocaleLowerCase().endsWith(".wav")?"audio/wav; codecs=audio/pcm; samplerate=16000":"audio/ogg; codecs=opus"),re.request(this,n[0],e,!1);case 3:return _context115.a(2);}},_callee115,this);}));function callServiceAPI(_x219,_x220,_x221){return _callServiceAPI16.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(e){return _regenerator().w(function(_context116){while(1)switch(_context116.n){case 0:if(!e[f]){_context116.n=1;break;}throw e[f];case 1:return _context116.a(2,_defineProperty({},h,e.DisplayText||""));}},_callee116);}));function extractResultData(_x222){return _extractResultData19.apply(this,arguments);}return extractResultData;}()}],[{key:"canFileSendMessage",value:function canFileSendMessage(e,t){return!!(t!=null&&t[0]);}}]);}(gn);dn.REGION_ERROR_MESSAGE="".concat(gn.REGION_ERROR_PREFIX,"SpeechToText)");var Ni=dn;var Hc=/*#__PURE__*/function(_R11){// prettier-ignore
187
+ function is(e){var _a$lang,_l$name,_c$gender;var _this56;_classCallCheck(this,is);var s,i,o,a,l,c;var t=(i=(s=e.directConnection)==null?void 0:s.azure)==null?void 0:i.textToSpeech,n=(o=e.directConnection)==null?void 0:o.azure;_this56=_callSuper(this,is,[e,wc.bind({},(t==null?void 0:t.outputFormat)||"audio-16khz-128kbitrate-mono-mp3"),t.region,n]),_this56.permittedErrorPrefixes=[is.REGION_ERROR_MESSAGE],_this56.isTextInputDisabled=!1,_this56.url="",t.region?(Object.assign(_this56.rawBody,t),(_a$lang=(a=_this56.rawBody).lang)!==null&&_a$lang!==void 0?_a$lang:a.lang="en-US",(_l$name=(l=_this56.rawBody).name)!==null&&_l$name!==void 0?_l$name:l.name="en-US-JennyNeural",(_c$gender=(c=_this56.rawBody).gender)!==null&&_c$gender!==void 0?_c$gender:c.gender="Female",_this56.url="https://".concat(t.region,".tts.speech.microsoft.com/cognitiveservices/v1")):(_this56.isTextInputDisabled=!0,_this56.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,is.REGION_ERROR_MESSAGE));}));return _this56;}_inherits(is,_gn);return _createClass(is,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h];if(n)return"<speak version='1.0' xml:lang='".concat(e.lang,"'>\n <voice xml:lang='").concat(e.lang,"' xml:gender='").concat(e.gender,"' name='").concat(e.name,"'>\n ").concat(n,"\n </voice>\n </speak>");}},{key:"callServiceAPI",value:function(){var _callServiceAPI15=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee113(e,t){return _regenerator().w(function(_context113){while(1)switch(_context113.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),void 0,!1);case 1:return _context113.a(2);}},_callee113,this);}));function callServiceAPI(_x216,_x217){return _callServiceAPI15.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(e){return _regenerator().w(function(_context114){while(1)switch(_context114.n){case 0:return _context114.a(2,new Promise(function(t){var n=new FileReader();n.readAsDataURL(e),n.onload=function(s){t(_defineProperty({},y,[_defineProperty(_defineProperty({},A,s.target.result),T,L)]));};}));}},_callee114);}));function extractResultData(_x218){return _extractResultData18.apply(this,arguments);}return extractResultData;}()}]);}(gn);is.REGION_ERROR_MESSAGE="".concat(gn.REGION_ERROR_PREFIX,"TextToSpeech)");var Oi=is;var dn=/*#__PURE__*/function(_gn2){function dn(e){var _this57;_classCallCheck(this,dn);var i,o,a;var t=(o=(i=e.directConnection)==null?void 0:i.azure)==null?void 0:o.speechToText,n=(a=e.directConnection)==null?void 0:a.azure,s={audio:_defineProperty({},y,{acceptedFormats:".wav,.ogg"})};if(_this57=_callSuper(this,dn,[e,Tc,t.region,n,s]),_this57.permittedErrorPrefixes=[dn.REGION_ERROR_MESSAGE],_this57.url="",_this57.isTextInputDisabled=!0,_this57.textInputPlaceholderText=qi,!t.region)_this57.isTextInputDisabled=!0,_this57.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,dn.REGION_ERROR_MESSAGE));});else{_this57.canSendMessage=dn.canFileSendMessage;var l=t.lang||"en-US";_this57.url="https://".concat(t.region,".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(l,"&format=detailed"),_this57.recordAudio=void 0;}return _this57;}_inherits(dn,_gn2);return _createClass(dn,[{key:"callServiceAPI",value:function(){var _callServiceAPI16=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(e,t,n){var s,i;return _regenerator().w(function(_context115){while(1)switch(_context115.n){case 0:if((s=this.connectSettings)!=null&&s.headers){_context115.n=1;break;}throw new Error(Me);case 1:if(n!=null&&n[0]){_context115.n=2;break;}throw new Error(Qs);case 2:(i=this.connectSettings)!=null&&i.headers&&(this.connectSettings.headers[D]=n[0].name.toLocaleLowerCase().endsWith(".wav")?"audio/wav; codecs=audio/pcm; samplerate=16000":"audio/ogg; codecs=opus"),re.request(this,n[0],e,!1);case 3:return _context115.a(2);}},_callee115,this);}));function callServiceAPI(_x219,_x220,_x221){return _callServiceAPI16.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(e){return _regenerator().w(function(_context116){while(1)switch(_context116.n){case 0:if(!e[f]){_context116.n=1;break;}throw e[f];case 1:return _context116.a(2,_defineProperty({},h,e.DisplayText||""));}},_callee116);}));function extractResultData(_x222){return _extractResultData19.apply(this,arguments);}return extractResultData;}()}],[{key:"canFileSendMessage",value:function canFileSendMessage(e,t){return!!(t!=null&&t[0]);}}]);}(gn);dn.REGION_ERROR_MESSAGE="".concat(gn.REGION_ERROR_PREFIX,"SpeechToText)");var Ni=dn;var Hc=/*#__PURE__*/function(_R11){// prettier-ignore
188
188
  function Hc(e){var _this58;_classCallCheck(this,Hc);var s,i,o;var t=(i=(s=e.directConnection)==null?void 0:s.azure)==null?void 0:i.translation,n=(o=e.directConnection)==null?void 0:o.azure;_this58=_callSuper(this,Hc,[e,Pc(t.region),Ho.bind({},t==null?void 0:t.region),n]),_this58.insertKeyPlaceholderText="Azure Translate Subscription Key",_this58.keyHelpUrl=// eslint-disable-next-line max-len
189
189
  "https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",_this58.url="",_this58.url="https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(t.language||"es");return _this58;}_inherits(Hc,_R11);return _createClass(Hc,[{key:"preprocessBody",value:function preprocessBody(e){var t=e[e.length-1][h];if(t)return[{Text:t}];}},{key:"callServiceAPI",value:function(){var _callServiceAPI17=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(e,t){return _regenerator().w(function(_context117){while(1)switch(_context117.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context117.a(2);}},_callee117,this);}));function callServiceAPI(_x223,_x224){return _callServiceAPI17.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData20=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(e){var t;return _regenerator().w(function(_context118){while(1)switch(_context118.n){case 0:if(!Array.isArray(e)){_context118.n=1;break;}return _context118.a(2,_defineProperty({},h,((t=e[0].translations)==null?void 0:t[0][h])||""));case 1:throw e[f];case 2:return _context118.a(2);}},_callee118);}));function extractResultData(_x225){return _extractResultData20.apply(this,arguments);}return extractResultData;}()}]);}(R);var jc=/*#__PURE__*/function(_R12){function jc(e){var _o$model5;var _this59;_classCallCheck(this,jc);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.bigModel;_this59=_callSuper(this,jc,[e,Ji(),Vi,n]),_this59.insertKeyPlaceholderText=_this59.genereteAPIKeyName("BigModel"),_this59.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this59.url="https://open.bigmodel.cn/api/paas/v4/images/generations",_this59.permittedErrorPrefixes=[oe,be];var s=(i=t.bigModel)==null?void 0:i[J];_typeof(s)===B&&(_this59.cleanConfig(s),Object.assign(_this59.rawBody,s)),(_o$model5=(o=_this59.rawBody).model)!==null&&_o$model5!==void 0?_o$model5:o.model="cogview-4-250304";return _this59;}_inherits(jc,_R12);return _createClass(jc,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.prompt=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(e,t){return _regenerator().w(function(_context119){while(1)switch(_context119.n){case 0:return _context119.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee119,this);}));function callServiceAPI(_x226,_x227){return _callServiceAPI18.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(e){var t;return _regenerator().w(function(_context120){while(1)switch(_context120.n){case 0:t=e.data.map(function(n){return n!=null&&n.url?_defineProperty(_defineProperty({},A,n.url),T,q):_defineProperty(_defineProperty({},A,""),T,q);});return _context120.a(2,_defineProperty({},y,t));}},_callee120);}));function extractResultData(_x228){return _extractResultData21.apply(this,arguments);}return extractResultData;}()}]);}(R);var jo=function jo(r){return _defineProperty(_defineProperty({},D,W),oe,"".concat(ye).concat(r));},qc=function qc(r,e,t,n){var s=r;s[f]?s[f].message===Ui?n(le):n(He):t(e);},qo=function qo(){return ce("https://api.groq.com/openai/v1/models",ae,qc);};var $c=/*#__PURE__*/function(_R13){function $c(e){var _o$model6,_a$voice4,_l$response_format;var _this60;_classCallCheck(this,$c);var i,o,a,l;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.groq;_this60=_callSuper(this,$c,[e,qo(),jo,n]),_this60.insertKeyPlaceholderText=_this60.genereteAPIKeyName("Groq"),_this60.keyHelpUrl="https://console.groq.com/keys",_this60.url="https://api.groq.com/openai/v1/audio/speech",_this60.permittedErrorPrefixes=[Ot,"property"];var s=(i=t.groq)==null?void 0:i.textToSpeech;_typeof(s)===B&&_this60.completeConfig(s),(_o$model6=(o=_this60.rawBody).model)!==null&&_o$model6!==void 0?_o$model6:o.model="playai-tts",(_a$voice4=(a=_this60.rawBody).voice)!==null&&_a$voice4!==void 0?_a$voice4:a.voice="Fritz-PlayAI",(_l$response_format=(l=_this60.rawBody).response_format)!==null&&_l$response_format!==void 0?_l$response_format:l.response_format="mp3";return _this60;}_inherits($c,_R13);return _createClass($c,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.input=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(e,t){return _regenerator().w(function(_context121){while(1)switch(_context121.n){case 0:return _context121.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee121,this);}));function callServiceAPI(_x229,_x230){return _callServiceAPI19.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(e){var t,n,s;return _regenerator().w(function(_context122){while(1)switch(_context122.n){case 0:t=this.rawBody.response_format||"mp3",n=new Blob([e],_defineProperty({},T,"audio/".concat(t))),s=URL.createObjectURL(n);return _context122.a(2,_defineProperty({},y,[_defineProperty(_defineProperty({},A,s),T,L)]));}},_callee122,this);}));function extractResultData(_x231){return _extractResultData22.apply(this,arguments);}return extractResultData;}()}]);}(R);var Gc=/*#__PURE__*/function(_R14){function Gc(e){var _o$model7;var _this61;_classCallCheck(this,Gc);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.together;_this61=_callSuper(this,Gc,[e,Ki(),Wi,n]),_this61.insertKeyPlaceholderText=_this61.genereteAPIKeyName("Together AI"),_this61.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this61.url="https://api.together.xyz/v1/images/generations",_this61.permittedErrorPrefixes=[We,be];var s=(i=t.together)==null?void 0:i[J];_typeof(s)===B&&_this61.completeConfig(s),(_o$model7=(o=_this61.rawBody).model)!==null&&_o$model7!==void 0?_o$model7:o.model="black-forest-labs/FLUX.1-schnell-Free";return _this61;}_inherits(Gc,_R14);return _createClass(Gc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t[t.length-1];return n.prompt=(s==null?void 0:s[h])||"",n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI20=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(e,t){return _regenerator().w(function(_context123){while(1)switch(_context123.n){case 0:return _context123.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee123,this);}));function callServiceAPI(_x232,_x233){return _callServiceAPI20.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(e){var t;return _regenerator().w(function(_context124){while(1)switch(_context124.n){case 0:t=e.data.map(function(n){return n!=null&&n.url?_defineProperty(_defineProperty({},A,n.url),T,q):n!=null&&n.b64_json?_defineProperty(_defineProperty({},A,"data:image/png;base64,".concat(n.b64_json)),T,q):_defineProperty(_defineProperty({},A,""),T,q);});return _context124.a(2,_defineProperty({},y,t));}},_callee124);}));function extractResultData(_x234){return _extractResultData23.apply(this,arguments);}return extractResultData;}()}]);}(R);var Ge=/*#__PURE__*/function(_Hs2){// https://platform.openai.com/docs/models/gpt-4o-audio-preview
190
190
  // prettier-ignore
191
- function Ge(e,t,n,s,i){var _this62;_classCallCheck(this,Ge);var a,l;_this62=_callSuper(this,Ge,[e,t,n,s,i]),_this62.keyHelpUrl=vn,_this62.url="".concat(Le,"responses"),_this62._functionStreamInProgress=!1,_this62._useConversation=!1,_this62._conversationLoadLimit=50;var o=i||((l=(a=e.directConnection)==null?void 0:a.openAI)==null?void 0:l.chat);_typeof(o)===B&&o!==!0&&o&&(o.conversation&&(_this62._useConversation=!0,typeof o.conversation=="string"&&(_this62._conversationId=o.conversation)),typeof o.conversationLoadLimit=="number"&&(_this62._conversationLoadLimit=o.conversationLoadLimit),_this62.cleanConfig(o)),_this62._conversationId&&(_this62.fetchHistory=_this62.fetchHistoryFunc.bind(_this62));return _this62;}_inherits(Ge,_Hs2);return _createClass(Ge,[{key:"processConfig",value:function processConfig(e,t){_superPropGet(Ge,"processConfig",this,3)([e,t]);}},{key:"cleanConfig",value:function cleanConfig(e){delete e.conversation,delete e.conversationLoadLimit;}},{key:"fetchHistoryFunc",value:function(){var _fetchHistoryFunc2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(){var _this63=this;var e,t,_t48;return _regenerator().w(function(_context125){while(1)switch(_context125.p=_context125.n){case 0:setTimeout(function(){return _this63.deepChat.disableSubmitButton();},2);_context125.p=1;e=this.url;this.url="".concat(Le,"conversations/").concat(this._conversationId,"/items?limit=").concat(this._conversationLoadLimit);_context125.n=2;return It(this,{},ae);case 2:t=_context125.v;return _context125.a(2,(this.connectSettings.method=he,this.url=e,this.deepChat.disableSubmitButton(!1),this.processConversationHistory(t)));case 3:_context125.p=3;_t48=_context125.v;return _context125.a(2,(this.deepChat.disableSubmitButton(!1),[_defineProperty({},f,vo)]));}},_callee125,this,[[1,3]]);}));function fetchHistoryFunc(){return _fetchHistoryFunc2.apply(this,arguments);}return fetchHistoryFunc;}()},{key:"processConversationHistory",value:function processConversationHistory(e){if(!e.data||!Array.isArray(e.data))return[];var t=[];var _iterator2=_createForOfIteratorHelper(Ge.filterCompleted(e.data.reverse())),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _n8=_step2.value;if(_n8.type==="message"&&_n8.content&&Array.isArray(_n8.content)){var _iterator3=_createForOfIteratorHelper(_n8.content),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var s=_step3.value;(s.type===wi||s.type===Dr)&&s[h]?t.push(_defineProperty({role:_n8.role},h,s[h])):s.type===Br&&t.push(_defineProperty({role:_n8.role},y,Ge.generateImageFile(s[Ne]||"")));}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}}else _n8.type===gi&&t.push(_defineProperty({role:K},y,Ge.generateImageFile(_n8.result)));}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}return t;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e));t=this.processMessages(t),t=this._useConversation?[t[t.length-1]]:t;var s=t.map(function(i){return{content:Ge.getContent(i),role:R.getRoleViaUser(i.role)};});return n.input=s,this._conversationId&&(n.conversation=this._conversationId),n;}},{key:"createConversation",value:function(){var _createConversation=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(){var e,t,_t49;return _regenerator().w(function(_context126){while(1)switch(_context126.p=_context126.n){case 0:_context126.p=0;e=this.url;this.url="".concat(Le,"conversations");_context126.n=1;return It(this,{},he);case 1:t=_context126.v;return _context126.a(2,(this.url=e,t.id));case 2:_context126.p=2;_t49=_context126.v;throw console[f]("Failed to create conversation:",_t49),_t49;case 3:return _context126.a(2);}},_callee126,this,[[0,2]]);}));function createConversation(){return _createConversation.apply(this,arguments);}return createConversation;}()},{key:"callServiceAPI",value:function(){var _callServiceAPI21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(e,t){var _this$messages2;var _t50;return _regenerator().w(function(_context127){while(1)switch(_context127.n){case 0:(_this$messages2=this.messages)!==null&&_this$messages2!==void 0?_this$messages2:this.messages=e;_t50=this._useConversation&&!this._conversationId;if(!_t50){_context127.n=2;break;}_context127.n=1;return this.createConversation();case 1:this._conversationId=_context127.v;case 2:this._conversationId&&this.updateSessionId(this._conversationId);this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 3:return _context127.a(2);}},_callee127,this);}));function callServiceAPI(_x235,_x236){return _callServiceAPI21.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(e,t){var n;return _regenerator().w(function(_context128){while(1)switch(_context128.n){case 0:_context128.n=1;return this.extractResult(e,t);case 1:n=_context128.v;return _context128.a(2,(this._conversationId&&(n._sessionId=this._conversationId),n));}},_callee128,this);}));function extractResultData(_x237,_x238){return _extractResultData24.apply(this,arguments);}return extractResultData;}()},{key:"extractResult",value:function(){var _extractResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(e,t){var n,s,i,o,a,l,c,d;return _regenerator().w(function(_context129){while(1)switch(_context129.n){case 0:if(!e[f]){_context129.n=1;break;}throw e[f].message;case 1:if(!e.status){_context129.n=5;break;}a=Ge.filterCompleted(e.output);if(!(a.length>0)){_context129.n=4;break;}l=(i=(s=(n=a.find(function(p){var u,g;return typeof((g=(u=p.content)==null?void 0:u[0])==null?void 0:g[h])=="string";}))==null?void 0:n.content)==null?void 0:s[0])==null?void 0:i[h];_context129.n=2;return this.handleResponsesFunctionCalls(a,t,l);case 2:c=_context129.v;if(!c){_context129.n=3;break;}return _context129.a(2,c);case 3:d=this.handleFileGenerationResponse(a,l);return _context129.a(2,d||_defineProperty({},h,l));case 4:return _context129.a(2,_defineProperty({},h,""));case 5:return _context129.a(2,((o=e.item)==null?void 0:o.type)===As&&e.type?this.handleStreamedResponsesFunctionCall(e,t):e.type==="".concat(xn,".").concat(gi,".partial_image")&&e.partial_image_b64?_defineProperty({},y,[_defineProperty(_defineProperty({},A,"".concat(Ge.IMAGE_BASE64_PREFIX).concat(e.partial_image_b64)),T,q)]):e.delta&&!this._functionStreamInProgress&&e.type==="".concat(xn,".").concat(Dr,".delta")?_defineProperty({},h,e.delta):_defineProperty({},h,""));}},_callee129,this);}));function extractResult(_x239,_x240){return _extractResult.apply(this,arguments);}return extractResult;}()},{key:"handleStreamedResponsesFunctionCall",value:function(){var _handleStreamedResponsesFunctionCall=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(e,t){var n;return _regenerator().w(function(_context130){while(1)switch(_context130.n){case 0:if(!(e.type==="".concat(xn,".output_item.done"))){_context130.n=2;break;}if(!(this._functionStreamInProgress=!1,((n=e.item)==null?void 0:n.type)===As)){_context130.n=1;break;}return _context130.a(2,this.handleResponsesFunctionCalls([e.item],t));case 1:_context130.n=3;break;case 2:e.type==="".concat(xn,".output_item.added")&&(this._functionStreamInProgress=!0);case 3:return _context130.a(2,_defineProperty({},h,""));}},_callee130,this);}));function handleStreamedResponsesFunctionCall(_x241,_x242){return _handleStreamedResponsesFunctionCall.apply(this,arguments);}return handleStreamedResponsesFunctionCall;}()},{key:"handleFileGenerationResponse",value:function handleFileGenerationResponse(e,t){var n=e.find(function(s){return s.type===gi;});return n?_defineProperty(_defineProperty({},y,Ge.generateImageFile(n.result)),h,t):null;}},{key:"handleResponsesFunctionCalls",value:function(){var _handleResponsesFunctionCalls=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(e,t,n){var s,i,_yield$this$callToolF2,o,a,l;return _regenerator().w(function(_context131){while(1)switch(_context131.n){case 0:s=e.filter(function(c){return c.type===As;});if(!(s.length===0)){_context131.n=1;break;}return _context131.a(2,null);case 1:if(!(!t||!this.functionHandler)){_context131.n=2;break;}throw Error(kt);case 2:i=s.map(function(c){return{name:c.name,arguments:c.arguments};});_context131.n=3;return this.callToolFunction(this.functionHandler,i);case 3:_yield$this$callToolF2=_context131.v;o=_yield$this$callToolF2.responses;a=_yield$this$callToolF2.processedResponse;if(!a){_context131.n=4;break;}return _context131.a(2,a);case 4:l=JSON.parse(JSON.stringify(t));if(!(l.input&&(s.forEach(function(c){return l.input.push(c);}),!o.find(function(_ref128){var c=_ref128.response;return typeof c!="string";})&&i.length===o.length))){_context131.n=5;break;}return _context131.a(2,(o.forEach(function(c,d){var p=s[d];l.input.push({type:Oo,call_id:p.call_id,output:c[xn]});}),this.makeAnotherRequest(l,this.messages,n)));case 5:throw Error(Jt);case 6:return _context131.a(2);}},_callee131,this);}));function handleResponsesFunctionCalls(_x243,_x244,_x245){return _handleResponsesFunctionCalls.apply(this,arguments);}return handleResponsesFunctionCalls;}()}],[{key:"getFileContent",value:function getFileContent(e){return Hs.getBaseFileContent(e).map(function(n){return n.type===Gt?n:_defineProperty(_defineProperty({detail:"auto"},T,Br),Ne,n[A]);});}},{key:"getContent",value:function getContent(e){if(e.role===H&&e[y]&&e[y].length>0){var _n9=Ge.getFileContent(e[y]);return e[h]&&e[h].trim().length>0&&_n9.unshift(_defineProperty(_defineProperty({},T,wi),h,e[h])),_n9;}return e[h];}},{key:"filterCompleted",value:function filterCompleted(e){return(e==null?void 0:e.filter(function(t){return t.status===ji;}))||[];}},{key:"generateImageFile",value:function generateImageFile(e){return[_defineProperty(_defineProperty({},A,"".concat(Ge.IMAGE_BASE64_PREFIX).concat(e)),T,q)];}}]);}(Hs);Ge.IMAGE_BASE64_PREFIX="data:image/png;base64,";var qs=Ge;var Yi=/*#__PURE__*/function(_qs){function Yi(e){var _this64;_classCallCheck(this,Yi);var o,a,l,c,d,p,u;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.azure,s=((a=(o=t.azure)==null?void 0:o.openAI)==null?void 0:a.urlDetails)||{},i=(c=(l=t.azure)==null?void 0:l.openAI)==null?void 0:c.chat;if(_this64=_callSuper(this,Yi,[e,Lo(s),Po,n,i]),_this64.permittedErrorPrefixes=[Fs],_this64.isTextInputDisabled=!1,_typeof(i)===B){var _ref131=(u=(p=(d=e.directConnection)==null?void 0:d.azure)==null?void 0:p.openAI)==null?void 0:u.chat,g=_ref131.function_handler;g&&(_this64.functionHandler=g);}Bo(s)?_this64.url=Yi.buildURL(s):(_this64.isTextInputDisabled=!0,_this64.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,Fs));}));return _this64;}_inherits(Yi,_qs);return _createClass(Yi,null,[{key:"buildURL",value:function buildURL(e){var t=e.endpoint,n=e.deploymentId,s=e.version;return"".concat(t,"/openai/deployments/").concat(n,"/chat/completions?api-version=").concat(s);}}]);}(qs);var $s=/*#__PURE__*/function(_R15){function $s(e){var _this65$maxMessages,_c$model2;var _this65;_classCallCheck(this,$s);var i,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.bigModel;_this65=_callSuper(this,$s,[e,Ji(),Vi,n]),_this65.insertKeyPlaceholderText=_this65.genereteAPIKeyName("BigModel"),_this65.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this65.url="https://open.bigmodel.cn/api/paas/v4/chat/completions",_this65.permittedErrorPrefixes=[oe,be];var s=(i=t.bigModel)==null?void 0:i.chat;_typeof(s)===B&&_this65.completeConfig(s,(l=(a=(o=e.directConnection)==null?void 0:o.bigModel)==null?void 0:a.chat)==null?void 0:l.function_handler),(_this65$maxMessages=_this65.maxMessages)!==null&&_this65$maxMessages!==void 0?_this65$maxMessages:_this65.maxMessages=-1,(_c$model2=(c=_this65.rawBody).model)!==null&&_c$model2!==void 0?_c$model2:c.model="glm-4.5";return _this65;}_inherits($s,_R15);return _createClass($s,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:$s.getTextWFilesContent(i,$s.getFileContent),role:R.getRoleViaAI(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(e,t){var _this$messages3;return _regenerator().w(function(_context132){while(1)switch(_context132.n){case 0:(_this$messages3=this.messages)!==null&&_this$messages3!==void 0?_this$messages3:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context132.a(2);}},_callee132,this);}));function callServiceAPI(_x246,_x247){return _callServiceAPI22.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(e,t){var _n0;return _regenerator().w(function(_context133){while(1)switch(_context133.n){case 0:if(!e[f]){_context133.n=1;break;}throw e[f].message;case 1:if(!(e.choices.length>0)){_context133.n=3;break;}if(!(e.choices[0].delta!==void 0)){_context133.n=2;break;}return _context133.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!(e.choices[0].message!==void 0)){_context133.n=3;break;}_n0=e.choices[0].message;return _context133.a(2,_n0.tool_calls?this.handleToolsGeneric({tool_calls:_n0.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n0.content));case 3:return _context133.a(2,_defineProperty({},h,""));}},_callee133,this);}));function extractResultData(_x248,_x249){return _extractResultData25.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(e,t){var o,a,l,c,n,s,i,d;return _regenerator().w(function(_context134){while(1)switch(_context134.n){case 0:n=e.delta,s=e.finish_reason,i=(o=this.messages)==null?void 0:o.messageToElements[this.messages.messageToElements.length-2];if(!((i==null?void 0:i[0].role)===K&&((a=i==null?void 0:i[0][h])==null?void 0:a.replace(/\n/g,"").trim().length)===0&&((l=this.messages)==null||l.removeMessage(i[1][h]),(c=this.messages)==null||c.messageToElements.splice(this.messages.messageToElements.length-2,1)),s==="tool_calls")){_context134.n=2;break;}if(!n.tool_calls){_context134.n=1;break;}d={tool_calls:n.tool_calls};return _context134.a(2,this.handleToolsGeneric(d,this.functionHandler,this.messages,t));case 1:return _context134.a(2,_defineProperty({},h,(n==null?void 0:n.content)||""));case 2:return _context134.a(2,_defineProperty({},h,(n==null?void 0:n.content)||""));}},_callee134,this);}));function extractStreamResult(_x250,_x251){return _extractStreamResult2.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type===q?_defineProperty(_defineProperty({},T,Ne),Ne,{url:t[A]||""}):_defineProperty(_defineProperty({},T,ee),"file_url",{url:t[A]||""});});}}]);}(R);var zc=/*#__PURE__*/function(_R16){function zc(e){var _this66$maxMessages,_o$model8;var _this66;_classCallCheck(this,zc);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.together;_this66=_callSuper(this,zc,[e,Ki(),Wi,n]),_this66.insertKeyPlaceholderText=_this66.genereteAPIKeyName("Together AI"),_this66.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this66.url="https://api.together.xyz/v1/chat/completions",_this66.permittedErrorPrefixes=[We,be];var s=(i=t.together)==null?void 0:i.chat;_typeof(s)===B&&_this66.completeConfig(s),(_this66$maxMessages=_this66.maxMessages)!==null&&_this66$maxMessages!==void 0?_this66$maxMessages:_this66.maxMessages=-1,(_o$model8=(o=_this66.rawBody).model)!==null&&_o$model8!==void 0?_o$model8:o.model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo";return _this66;}_inherits(zc,_R16);return _createClass(zc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:i.role===K?ot:i.role};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(e,t){return _regenerator().w(function(_context135){while(1)switch(_context135.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context135.a(2);}},_callee135,this);}));function callServiceAPI(_x252,_x253){return _callServiceAPI23.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData26=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136(e){return _regenerator().w(function(_context136){while(1)switch(_context136.n){case 0:if(!e[f]){_context136.n=1;break;}throw e[f].message;case 1:if(!(e.choices.length>0)){_context136.n=3;break;}if(!(e.choices[0].message!==void 0)){_context136.n=2;break;}return _context136.a(2,_defineProperty({},h,e.choices[0].message.content));case 2:if(!(e.choices[0].delta!==void 0)){_context136.n=3;break;}return _context136.a(2,_defineProperty({},h,e.choices[0].delta.content));case 3:return _context136.a(2,_defineProperty({},h,""));}},_callee136);}));function extractResultData(_x254){return _extractResultData26.apply(this,arguments);}return extractResultData;}()}]);}(R);var Xe=/*#__PURE__*/function(_R17){function Xe(e){var _this67;_classCallCheck(this,Xe);var o;var t=e.directConnection,n=t==null?void 0:t.openAI,s={images:_defineProperty({},y,{acceptedFormats:".png",maxNumberOfFiles:2})};_this67=_callSuper(this,Xe,[e,En(),_n,n,s]),_this67.insertKeyPlaceholderText=_this67.genereteAPIKeyName("OpenAI"),_this67.keyHelpUrl=vn,_this67.url="",_this67.permittedErrorPrefixes=[fs,"Invalid input image"];var i=(o=t==null?void 0:t.openAI)==null?void 0:o[J];if(_this67[Ie]){var a=_typeof(i)=="object"&&i.size?Number.parseInt(i.size):1024;_this67[Ie][y]={dimensions:{width:a,height:a}};}_typeof(i)===B&&Object.assign(_this67.rawBody,i),_this67.canSendMessage=Xe.canFileSendMessage;return _this67;}_inherits(Xe,_R17);return _createClass(Xe,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t!==""&&(n.prompt=t),n;}// prettier-ignore
191
+ function Ge(e,t,n,s,i){var _this62;_classCallCheck(this,Ge);var a,l;_this62=_callSuper(this,Ge,[e,t,n,s,i]),_this62.keyHelpUrl=vn,_this62.url="".concat(Le,"responses"),_this62._functionStreamInProgress=!1,_this62._useConversation=!1,_this62._conversationLoadLimit=50;var o=i||((l=(a=e.directConnection)==null?void 0:a.openAI)==null?void 0:l.chat);_typeof(o)===B&&o!==!0&&o&&(o.conversation&&(_this62._useConversation=!0,typeof o.conversation=="string"&&(_this62._conversationId=o.conversation)),typeof o.conversationLoadLimit=="number"&&(_this62._conversationLoadLimit=o.conversationLoadLimit),_this62.cleanConfig(o)),_this62._conversationId&&(_this62.fetchHistory=_this62.fetchHistoryFunc.bind(_this62));return _this62;}_inherits(Ge,_Hs2);return _createClass(Ge,[{key:"processConfig",value:function processConfig(e,t){_superPropGet(Ge,"processConfig",this,3)([e,t]);}},{key:"cleanConfig",value:function cleanConfig(e){delete e.conversation,delete e.conversationLoadLimit;}},{key:"fetchHistoryFunc",value:function(){var _fetchHistoryFunc2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(){var _this63=this;var e,t,_t48;return _regenerator().w(function(_context125){while(1)switch(_context125.p=_context125.n){case 0:setTimeout(function(){return _this63.deepChat.disableSubmitButton();},2);_context125.p=1;e=this.url;this.url="".concat(Le,"conversations/").concat(this._conversationId,"/items?limit=").concat(this._conversationLoadLimit);_context125.n=2;return It(this,{},ae);case 2:t=_context125.v;return _context125.a(2,(this.connectSettings.method=he,this.url=e,this.deepChat.disableSubmitButton(!1),this.processConversationHistory(t)));case 3:_context125.p=3;_t48=_context125.v;return _context125.a(2,(this.deepChat.disableSubmitButton(!1),[_defineProperty({},f,vo)]));}},_callee125,this,[[1,3]]);}));function fetchHistoryFunc(){return _fetchHistoryFunc2.apply(this,arguments);}return fetchHistoryFunc;}()},{key:"processConversationHistory",value:function processConversationHistory(e){if(!e.data||!Array.isArray(e.data))return[];var t=[];var _iterator2=_createForOfIteratorHelper(Ge.filterCompleted(e.data.reverse())),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _n8=_step2.value;if(_n8.type==="message"&&_n8.content&&Array.isArray(_n8.content)){var _iterator3=_createForOfIteratorHelper(_n8.content),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var s=_step3.value;(s.type===Ci||s.type===Dr)&&s[h]?t.push(_defineProperty({role:_n8.role},h,s[h])):s.type===Br&&t.push(_defineProperty({role:_n8.role},y,Ge.generateImageFile(s[Ne]||"")));}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}}else _n8.type===gi&&t.push(_defineProperty({role:K},y,Ge.generateImageFile(_n8.result)));}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}return t;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e));t=this.processMessages(t),t=this._useConversation?[t[t.length-1]]:t;var s=t.map(function(i){return{content:Ge.getContent(i),role:R.getRoleViaUser(i.role)};});return n.input=s,this._conversationId&&(n.conversation=this._conversationId),n;}},{key:"createConversation",value:function(){var _createConversation=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(){var e,t,_t49;return _regenerator().w(function(_context126){while(1)switch(_context126.p=_context126.n){case 0:_context126.p=0;e=this.url;this.url="".concat(Le,"conversations");_context126.n=1;return It(this,{},he);case 1:t=_context126.v;return _context126.a(2,(this.url=e,t.id));case 2:_context126.p=2;_t49=_context126.v;throw console[f]("Failed to create conversation:",_t49),_t49;case 3:return _context126.a(2);}},_callee126,this,[[0,2]]);}));function createConversation(){return _createConversation.apply(this,arguments);}return createConversation;}()},{key:"callServiceAPI",value:function(){var _callServiceAPI21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(e,t){var _this$messages2;var _t50;return _regenerator().w(function(_context127){while(1)switch(_context127.n){case 0:(_this$messages2=this.messages)!==null&&_this$messages2!==void 0?_this$messages2:this.messages=e;_t50=this._useConversation&&!this._conversationId;if(!_t50){_context127.n=2;break;}_context127.n=1;return this.createConversation();case 1:this._conversationId=_context127.v;case 2:this._conversationId&&this.updateSessionId(this._conversationId);this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 3:return _context127.a(2);}},_callee127,this);}));function callServiceAPI(_x235,_x236){return _callServiceAPI21.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(e,t){var n;return _regenerator().w(function(_context128){while(1)switch(_context128.n){case 0:_context128.n=1;return this.extractResult(e,t);case 1:n=_context128.v;return _context128.a(2,(this._conversationId&&(n._sessionId=this._conversationId),n));}},_callee128,this);}));function extractResultData(_x237,_x238){return _extractResultData24.apply(this,arguments);}return extractResultData;}()},{key:"extractResult",value:function(){var _extractResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(e,t){var n,s,i,o,a,l,c,d;return _regenerator().w(function(_context129){while(1)switch(_context129.n){case 0:if(!e[f]){_context129.n=1;break;}throw e[f].message;case 1:if(!e.status){_context129.n=5;break;}a=Ge.filterCompleted(e.output);if(!(a.length>0)){_context129.n=4;break;}l=(i=(s=(n=a.find(function(p){var u,g;return typeof((g=(u=p.content)==null?void 0:u[0])==null?void 0:g[h])=="string";}))==null?void 0:n.content)==null?void 0:s[0])==null?void 0:i[h];_context129.n=2;return this.handleResponsesFunctionCalls(a,t,l);case 2:c=_context129.v;if(!c){_context129.n=3;break;}return _context129.a(2,c);case 3:d=this.handleFileGenerationResponse(a,l);return _context129.a(2,d||_defineProperty({},h,l));case 4:return _context129.a(2,_defineProperty({},h,""));case 5:return _context129.a(2,((o=e.item)==null?void 0:o.type)===As&&e.type?this.handleStreamedResponsesFunctionCall(e,t):e.type==="".concat(xn,".").concat(gi,".partial_image")&&e.partial_image_b64?_defineProperty({},y,[_defineProperty(_defineProperty({},A,"".concat(Ge.IMAGE_BASE64_PREFIX).concat(e.partial_image_b64)),T,q)]):e.delta&&!this._functionStreamInProgress&&e.type==="".concat(xn,".").concat(Dr,".delta")?_defineProperty({},h,e.delta):_defineProperty({},h,""));}},_callee129,this);}));function extractResult(_x239,_x240){return _extractResult.apply(this,arguments);}return extractResult;}()},{key:"handleStreamedResponsesFunctionCall",value:function(){var _handleStreamedResponsesFunctionCall=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(e,t){var n;return _regenerator().w(function(_context130){while(1)switch(_context130.n){case 0:if(!(e.type==="".concat(xn,".output_item.done"))){_context130.n=2;break;}if(!(this._functionStreamInProgress=!1,((n=e.item)==null?void 0:n.type)===As)){_context130.n=1;break;}return _context130.a(2,this.handleResponsesFunctionCalls([e.item],t));case 1:_context130.n=3;break;case 2:e.type==="".concat(xn,".output_item.added")&&(this._functionStreamInProgress=!0);case 3:return _context130.a(2,_defineProperty({},h,""));}},_callee130,this);}));function handleStreamedResponsesFunctionCall(_x241,_x242){return _handleStreamedResponsesFunctionCall.apply(this,arguments);}return handleStreamedResponsesFunctionCall;}()},{key:"handleFileGenerationResponse",value:function handleFileGenerationResponse(e,t){var n=e.find(function(s){return s.type===gi;});return n?_defineProperty(_defineProperty({},y,Ge.generateImageFile(n.result)),h,t):null;}},{key:"handleResponsesFunctionCalls",value:function(){var _handleResponsesFunctionCalls=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(e,t,n){var s,i,_yield$this$callToolF2,o,a,l;return _regenerator().w(function(_context131){while(1)switch(_context131.n){case 0:s=e.filter(function(c){return c.type===As;});if(!(s.length===0)){_context131.n=1;break;}return _context131.a(2,null);case 1:if(!(!t||!this.functionHandler)){_context131.n=2;break;}throw Error(kt);case 2:i=s.map(function(c){return{name:c.name,arguments:c.arguments};});_context131.n=3;return this.callToolFunction(this.functionHandler,i);case 3:_yield$this$callToolF2=_context131.v;o=_yield$this$callToolF2.responses;a=_yield$this$callToolF2.processedResponse;if(!a){_context131.n=4;break;}return _context131.a(2,a);case 4:l=JSON.parse(JSON.stringify(t));if(!(l.input&&(s.forEach(function(c){return l.input.push(c);}),!o.find(function(_ref128){var c=_ref128.response;return typeof c!="string";})&&i.length===o.length))){_context131.n=5;break;}return _context131.a(2,(o.forEach(function(c,d){var p=s[d];l.input.push({type:Oo,call_id:p.call_id,output:c[xn]});}),this.makeAnotherRequest(l,this.messages,n)));case 5:throw Error(Jt);case 6:return _context131.a(2);}},_callee131,this);}));function handleResponsesFunctionCalls(_x243,_x244,_x245){return _handleResponsesFunctionCalls.apply(this,arguments);}return handleResponsesFunctionCalls;}()}],[{key:"getFileContent",value:function getFileContent(e){return Hs.getBaseFileContent(e).map(function(n){return n.type===Gt?n:_defineProperty(_defineProperty({detail:"auto"},T,Br),Ne,n[A]);});}},{key:"getContent",value:function getContent(e){if(e.role===H&&e[y]&&e[y].length>0){var _n9=Ge.getFileContent(e[y]);return e[h]&&e[h].trim().length>0&&_n9.unshift(_defineProperty(_defineProperty({},T,Ci),h,e[h])),_n9;}return e[h];}},{key:"filterCompleted",value:function filterCompleted(e){return(e==null?void 0:e.filter(function(t){return t.status===ji;}))||[];}},{key:"generateImageFile",value:function generateImageFile(e){return[_defineProperty(_defineProperty({},A,"".concat(Ge.IMAGE_BASE64_PREFIX).concat(e)),T,q)];}}]);}(Hs);Ge.IMAGE_BASE64_PREFIX="data:image/png;base64,";var qs=Ge;var Yi=/*#__PURE__*/function(_qs){function Yi(e){var _this64;_classCallCheck(this,Yi);var o,a,l,c,d,p,u;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.azure,s=((a=(o=t.azure)==null?void 0:o.openAI)==null?void 0:a.urlDetails)||{},i=(c=(l=t.azure)==null?void 0:l.openAI)==null?void 0:c.chat;if(_this64=_callSuper(this,Yi,[e,Lo(s),Po,n,i]),_this64.permittedErrorPrefixes=[Fs],_this64.isTextInputDisabled=!1,_typeof(i)===B){var _ref131=(u=(p=(d=e.directConnection)==null?void 0:d.azure)==null?void 0:p.openAI)==null?void 0:u.chat,g=_ref131.function_handler;g&&(_this64.functionHandler=g);}Bo(s)?_this64.url=Yi.buildURL(s):(_this64.isTextInputDisabled=!0,_this64.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},f,Fs));}));return _this64;}_inherits(Yi,_qs);return _createClass(Yi,null,[{key:"buildURL",value:function buildURL(e){var t=e.endpoint,n=e.deploymentId,s=e.version;return"".concat(t,"/openai/deployments/").concat(n,"/chat/completions?api-version=").concat(s);}}]);}(qs);var $s=/*#__PURE__*/function(_R15){function $s(e){var _this65$maxMessages,_c$model2;var _this65;_classCallCheck(this,$s);var i,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.bigModel;_this65=_callSuper(this,$s,[e,Ji(),Vi,n]),_this65.insertKeyPlaceholderText=_this65.genereteAPIKeyName("BigModel"),_this65.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this65.url="https://open.bigmodel.cn/api/paas/v4/chat/completions",_this65.permittedErrorPrefixes=[oe,be];var s=(i=t.bigModel)==null?void 0:i.chat;_typeof(s)===B&&_this65.completeConfig(s,(l=(a=(o=e.directConnection)==null?void 0:o.bigModel)==null?void 0:a.chat)==null?void 0:l.function_handler),(_this65$maxMessages=_this65.maxMessages)!==null&&_this65$maxMessages!==void 0?_this65$maxMessages:_this65.maxMessages=-1,(_c$model2=(c=_this65.rawBody).model)!==null&&_c$model2!==void 0?_c$model2:c.model="glm-4.5";return _this65;}_inherits($s,_R15);return _createClass($s,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:$s.getTextWFilesContent(i,$s.getFileContent),role:R.getRoleViaAI(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(e,t){var _this$messages3;return _regenerator().w(function(_context132){while(1)switch(_context132.n){case 0:(_this$messages3=this.messages)!==null&&_this$messages3!==void 0?_this$messages3:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context132.a(2);}},_callee132,this);}));function callServiceAPI(_x246,_x247){return _callServiceAPI22.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(e,t){var _n0;return _regenerator().w(function(_context133){while(1)switch(_context133.n){case 0:if(!e[f]){_context133.n=1;break;}throw e[f].message;case 1:if(!(e.choices.length>0)){_context133.n=3;break;}if(!(e.choices[0].delta!==void 0)){_context133.n=2;break;}return _context133.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!(e.choices[0].message!==void 0)){_context133.n=3;break;}_n0=e.choices[0].message;return _context133.a(2,_n0.tool_calls?this.handleToolsGeneric({tool_calls:_n0.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n0.content));case 3:return _context133.a(2,_defineProperty({},h,""));}},_callee133,this);}));function extractResultData(_x248,_x249){return _extractResultData25.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(e,t){var o,a,l,c,n,s,i,d;return _regenerator().w(function(_context134){while(1)switch(_context134.n){case 0:n=e.delta,s=e.finish_reason,i=(o=this.messages)==null?void 0:o.messageToElements[this.messages.messageToElements.length-2];if(!((i==null?void 0:i[0].role)===K&&((a=i==null?void 0:i[0][h])==null?void 0:a.replace(/\n/g,"").trim().length)===0&&((l=this.messages)==null||l.removeMessage(i[1][h]),(c=this.messages)==null||c.messageToElements.splice(this.messages.messageToElements.length-2,1)),s==="tool_calls")){_context134.n=2;break;}if(!n.tool_calls){_context134.n=1;break;}d={tool_calls:n.tool_calls};return _context134.a(2,this.handleToolsGeneric(d,this.functionHandler,this.messages,t));case 1:return _context134.a(2,_defineProperty({},h,(n==null?void 0:n.content)||""));case 2:return _context134.a(2,_defineProperty({},h,(n==null?void 0:n.content)||""));}},_callee134,this);}));function extractStreamResult(_x250,_x251){return _extractStreamResult2.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type===q?_defineProperty(_defineProperty({},T,Ne),Ne,{url:t[A]||""}):_defineProperty(_defineProperty({},T,ee),"file_url",{url:t[A]||""});});}}]);}(R);var zc=/*#__PURE__*/function(_R16){function zc(e){var _this66$maxMessages,_o$model8;var _this66;_classCallCheck(this,zc);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.together;_this66=_callSuper(this,zc,[e,Ki(),Wi,n]),_this66.insertKeyPlaceholderText=_this66.genereteAPIKeyName("Together AI"),_this66.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this66.url="https://api.together.xyz/v1/chat/completions",_this66.permittedErrorPrefixes=[We,be];var s=(i=t.together)==null?void 0:i.chat;_typeof(s)===B&&_this66.completeConfig(s),(_this66$maxMessages=_this66.maxMessages)!==null&&_this66$maxMessages!==void 0?_this66$maxMessages:_this66.maxMessages=-1,(_o$model8=(o=_this66.rawBody).model)!==null&&_o$model8!==void 0?_o$model8:o.model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo";return _this66;}_inherits(zc,_R16);return _createClass(zc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:i.role===K?ot:i.role};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(e,t){return _regenerator().w(function(_context135){while(1)switch(_context135.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context135.a(2);}},_callee135,this);}));function callServiceAPI(_x252,_x253){return _callServiceAPI23.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData26=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136(e){return _regenerator().w(function(_context136){while(1)switch(_context136.n){case 0:if(!e[f]){_context136.n=1;break;}throw e[f].message;case 1:if(!(e.choices.length>0)){_context136.n=3;break;}if(!(e.choices[0].message!==void 0)){_context136.n=2;break;}return _context136.a(2,_defineProperty({},h,e.choices[0].message.content));case 2:if(!(e.choices[0].delta!==void 0)){_context136.n=3;break;}return _context136.a(2,_defineProperty({},h,e.choices[0].delta.content));case 3:return _context136.a(2,_defineProperty({},h,""));}},_callee136);}));function extractResultData(_x254){return _extractResultData26.apply(this,arguments);}return extractResultData;}()}]);}(R);var Xe=/*#__PURE__*/function(_R17){function Xe(e){var _this67;_classCallCheck(this,Xe);var o;var t=e.directConnection,n=t==null?void 0:t.openAI,s={images:_defineProperty({},y,{acceptedFormats:".png",maxNumberOfFiles:2})};_this67=_callSuper(this,Xe,[e,En(),_n,n,s]),_this67.insertKeyPlaceholderText=_this67.genereteAPIKeyName("OpenAI"),_this67.keyHelpUrl=vn,_this67.url="",_this67.permittedErrorPrefixes=[fs,"Invalid input image"];var i=(o=t==null?void 0:t.openAI)==null?void 0:o[J];if(_this67[Ie]){var a=_typeof(i)=="object"&&i.size?Number.parseInt(i.size):1024;_this67[Ie][y]={dimensions:{width:a,height:a}};}_typeof(i)===B&&Object.assign(_this67.rawBody,i),_this67.canSendMessage=Xe.canFileSendMessage;return _this67;}_inherits(Xe,_R17);return _createClass(Xe,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e));return t&&t!==""&&(n.prompt=t),n;}// prettier-ignore
192
192
  },{key:"callApiWithImage",value:function callApiWithImage(e,t,n){var o,a;var s;var i=(a=(o=t[t.length-1])==null?void 0:o[h])==null?void 0:a.trim();if(n[1]||i&&i!==""){this.url=Xe.IMAGE_EDIT_URL;var l=this.preprocessBody(this.rawBody,i);s=Xe.createFormDataBody(l,n[0],n[1]);}else this.url=Xe.IMAGE_VARIATIONS_URL,s=Xe.createFormDataBody(this.rawBody,n[0]);P.tempRemoveContentHeader(this.connectSettings,re.request.bind(this,this,s,e),!1);}},{key:"callServiceAPI",value:function(){var _callServiceAPI24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137(e,t,n){var s,i;return _regenerator().w(function(_context137){while(1)switch(_context137.n){case 0:if((s=this.connectSettings)!=null&&s.headers){_context137.n=1;break;}throw new Error(Me);case 1:if(!(n!=null&&n[0])){_context137.n=2;break;}this.callApiWithImage(e,t,n);_context137.n=4;break;case 2:if(this.connectSettings){_context137.n=3;break;}throw new Error(Me);case 3:this.url=Xe.IMAGE_GENERATION_URL;i=this.preprocessBody(this.rawBody,t[t.length-1][h]);re.request(this,i,e);case 4:return _context137.a(2);}},_callee137,this);}));function callServiceAPI(_x255,_x256,_x257){return _callServiceAPI24.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData27=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(e){var t;return _regenerator().w(function(_context138){while(1)switch(_context138.n){case 0:if(!e[f]){_context138.n=1;break;}throw e[f].message;case 1:t=e.data.map(function(n){return n.url?_defineProperty(_defineProperty({},A,n.url),T,q):_defineProperty(_defineProperty({},A,"".concat(bn).concat(n.b64_json)),T,q);});return _context138.a(2,_defineProperty({},y,t));}},_callee138);}));function extractResultData(_x258){return _extractResultData27.apply(this,arguments);}return extractResultData;}()// private static readonly MODAL_MARKDOWN = `
193
193
  // 1 image:
194
194
  // - With text - edits image based on the text
@@ -199,9 +199,9 @@ function Ge(e,t,n,s,i){var _this62;_classCallCheck(this,Ge);var a,l;_this62=_cal
199
199
  // Click here for [more info](https://platform.openai.com/docs/guides/images/introduction).
200
200
  // `;
201
201
  }],[{key:"canFileSendMessage",value:function canFileSendMessage(e,t){return!!(t!=null&&t[0])||!!(e&&e.trim()!=="");}},{key:"createFormDataBody",value:function createFormDataBody(e,t,n){var s=new FormData();return s.append(q,t),n&&s.append("mask",n),Object.keys(e).forEach(function(i){s.append(i,String(e[i]));}),s;}}]);}(R);Xe.IMAGE_GENERATION_URL="".concat(Le,"images/generations"),Xe.IMAGE_VARIATIONS_URL="".concat(Le,"images/variations"),Xe.IMAGE_EDIT_URL="".concat(Le,"images/edits");var Pi=Xe;var Vc=function Vc(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},Jc=function Jc(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},Wc=function Wc(){return ce("https://openrouter.ai/api/v1/key",ae,Jc);};var Zn=/*#__PURE__*/function(_R18){function Zn(e){var _this68$maxMessages,_o$model9,_a$max_tokens;var _this68;_classCallCheck(this,Zn);var s,i,o,a;var n=JSON.parse(JSON.stringify(e.directConnection)).openRouter;_this68=_callSuper(this,Zn,[e,Wc(),Vc,n]),_this68.insertKeyPlaceholderText=_this68.genereteAPIKeyName("OpenRouter"),_this68.keyHelpUrl="https://openrouter.ai/keys",_this68.url="https://openrouter.ai/api/v1/chat/completions",_this68.permittedErrorPrefixes=[We,be],_typeof(n)===B&&_this68.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.openRouter)==null?void 0:i.function_handler),(_this68$maxMessages=_this68.maxMessages)!==null&&_this68$maxMessages!==void 0?_this68$maxMessages:_this68.maxMessages=-1,(_o$model9=(o=_this68.rawBody).model)!==null&&_o$model9!==void 0?_o$model9:o.model="openai/gpt-4o",(_a$max_tokens=(a=_this68.rawBody).max_tokens)!==null&&_a$max_tokens!==void 0?_a$max_tokens:a.max_tokens=1e3;return _this68;}_inherits(Zn,_R18);return _createClass(Zn,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(o){return{content:Zn.getContent(o),role:R.getRoleViaUser(o.role)};}),i=[];return this.systemMessage&&i.push({role:"system",content:this.systemMessage}),i.push.apply(i,_toConsumableArray(s)),n.messages=i,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(e,t){var _this$messages4;return _regenerator().w(function(_context139){while(1)switch(_context139.n){case 0:(_this$messages4=this.messages)!==null&&_this$messages4!==void 0?_this$messages4:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context139.a(2);}},_callee139,this);}));function callServiceAPI(_x259,_x260){return _callServiceAPI25.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData28=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(e,t){var n,s,i,o,a,l,_a5,_l4;return _regenerator().w(function(_context140){while(1)switch(_context140.n){case 0:if(!e[f]){_context140.n=1;break;}throw e[f].message;case 1:if(!(e.object==="chat.completion.chunk")){_context140.n=4;break;}a=(n=e.choices)==null?void 0:n[0];if(!(a!=null&&a.delta)){_context140.n=2;break;}return _context140.a(2,this.extractStreamResult(a,t));case 2:if(!((s=e.message)!=null&&s[J])){_context140.n=3;break;}l=e.message[J].map(function(c){return _defineProperty({},A,c[Ne].url);});return _context140.a(2,_defineProperty(_defineProperty({},h,e.message.content||""),y,l));case 3:return _context140.a(2,_defineProperty({},h,""));case 4:if(!(e.object==="chat.completion")){_context140.n=6;break;}_a5=(i=e.choices)==null?void 0:i[0];if(!(_a5!=null&&_a5.message)){_context140.n=6;break;}if(!_a5.message.tool_calls){_context140.n=5;break;}return _context140.a(2,this.handleToolsGeneric({tool_calls:_a5.message.tool_calls},this.functionHandler,this.messages,t));case 5:_l4=((o=_a5.message[J])==null?void 0:o.map(function(c){return _defineProperty({},A,c[Ne].url);}))||[];return _context140.a(2,_defineProperty(_defineProperty({},h,_a5.message.content||""),"files",_l4));case 6:return _context140.a(2,_defineProperty({},h,""));}},_callee140,this);}));function extractResultData(_x261,_x262){return _extractResultData28.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(e,t){var n,s;return _regenerator().w(function(_context141){while(1)switch(_context141.n){case 0:n=e.delta;if(!(n!=null&&n[J])){_context141.n=1;break;}s=n[J].map(function(i){return _defineProperty({},A,i[Ne].url);});return _context141.a(2,_defineProperty(_defineProperty({},h,n.content||""),y,s));case 1:return _context141.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee141,this);}));function extractStreamResult(_x263,_x264){return _extractStreamResult3.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getAudioContent",value:function getAudioContent(e){return e.filter(function(t){return t.type===L;}).map(function(t){var i,o,a;var n=(i=t[A])==null?void 0:i.split(",")[1],s=(a=(o=t[A])==null?void 0:o.match(/data:audio\/([^;]+)/))==null?void 0:a[1];return _defineProperty(_defineProperty({},T,Gt),Gt,{data:n||"",format:s==="wav"||s==="mp3"?s:"mp3"});}).filter(function(t){return t[Gt].data.length>0;});}},{key:"getContent",value:function getContent(e){if(e[y]&&e[y].length>0){var t=[].concat(_toConsumableArray(Zn.getImageContent(e[y])),_toConsumableArray(Zn.getAudioContent(e[y])));return e[h]&&e[h].trim().length>0&&t.unshift(_defineProperty(_defineProperty({},T,h),h,e[h])),t.length>0?t:e[h]||"";}return e[h]||"";}}]);}(R);var Kc=function Kc(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},Xc=function Xc(r,e,t,n){r[f]?n(le):t(e);},Zc=function Zc(){return ce("https://api.perplexity.ai/chat/completions",he,Xc);};var Yc=/*#__PURE__*/function(_R19){function Yc(e){var _this69$maxMessages,_s$model;var _this69;_classCallCheck(this,Yc);var s;var n=JSON.parse(JSON.stringify(e.directConnection)).perplexity;_this69=_callSuper(this,Yc,[e,Zc(),Kc,n]),_this69.insertKeyPlaceholderText=_this69.genereteAPIKeyName("Perplexity"),_this69.keyHelpUrl="https://www.perplexity.ai/settings/api",_this69.url="https://api.perplexity.ai/chat/completions",_this69.permittedErrorPrefixes=[Ot,_o,"Permission denied"],_typeof(n)===B&&_this69.completeConfig(n),(_this69$maxMessages=_this69.maxMessages)!==null&&_this69$maxMessages!==void 0?_this69$maxMessages:_this69.maxMessages=-1,(_s$model=(s=_this69.rawBody).model)!==null&&_s$model!==void 0?_s$model:s.model="sonar";return _this69;}_inherits(Yc,_R19);return _createClass(Yc,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI26=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee142(e,t){return _regenerator().w(function(_context142){while(1)switch(_context142.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context142.a(2);}},_callee142,this);}));function callServiceAPI(_x265,_x266){return _callServiceAPI26.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData29=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee143(e){var t;return _regenerator().w(function(_context143){while(1)switch(_context143.n){case 0:if(!e[f]){_context143.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context143.n=3;break;}t=e.choices[0];if(!(t.delta&&t.delta.content)){_context143.n=2;break;}return _context143.a(2,_defineProperty({},h,t.delta.content));case 2:if(!(t.message&&t.message.content)){_context143.n=3;break;}return _context143.a(2,_defineProperty({},h,t.message.content));case 3:return _context143.a(2,_defineProperty({},h,""));}},_callee143);}));function extractResultData(_x267){return _extractResultData29.apply(this,arguments);}return extractResultData;}()}]);}(R);var Qc=function Qc(r){return _defineProperty(_defineProperty({},oe,"Bearer ".concat(r)),D,W);},ed=function ed(r,e,t,n){var s=r;s.detail?n(s.detail):t(e);},td=function td(){return ce("http://localhost:3000/api/v1/models",ae,ed);};var nd=/*#__PURE__*/function(_R20){function nd(e){var _this70$maxMessages,_o$model0,_a$stream;var _this70;_classCallCheck(this,nd);var s,i,o,a;var n=JSON.parse(JSON.stringify(e.directConnection)).openWebUI;_this70=_callSuper(this,nd,[e,td(),Qc,n]),_this70.insertKeyPlaceholderText="Open WebUI API Key",_this70.keyHelpUrl="https://docs.openwebui.com/getting-started/api-endpoints/",_this70.url="http://localhost:3000/api/chat/completions",_this70.permittedErrorPrefixes=["Error"],_typeof(n)===B&&(_this70.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.openWebUI)==null?void 0:i.function_handler),n[y]&&n[y].length>0&&(_this70.rawBody[y]=n[y])),(_this70$maxMessages=_this70.maxMessages)!==null&&_this70$maxMessages!==void 0?_this70$maxMessages:_this70.maxMessages=-1,(_o$model0=(o=_this70.rawBody).model)!==null&&_o$model0!==void 0?_o$model0:o.model="llama3.2",(_a$stream=(a=_this70.rawBody).stream)!==null&&_a$stream!==void 0?_a$stream:a.stream=!1;return _this70;}_inherits(nd,_R20);return _createClass(nd,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:R.getTextWImagesContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI27=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee144(e,t){var _this$messages5;return _regenerator().w(function(_context144){while(1)switch(_context144.n){case 0:(_this$messages5=this.messages)!==null&&_this$messages5!==void 0?_this$messages5:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context144.a(2);}},_callee144,this);}));function callServiceAPI(_x268,_x269){return _callServiceAPI27.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData30=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee145(e,t){var n,s,_s8;return _regenerator().w(function(_context145){while(1)switch(_context145.n){case 0:if(!e[f]){_context145.n=1;break;}throw e[f].message;case 1:if(!e[h]){_context145.n=2;break;}s=e[h].trim();return _context145.a(2,this.processStreamingResponse(s,t));case 2:if(!(e.choices&&(n=e.choices[0])!=null&&n.message)){_context145.n=3;break;}_s8=e.choices[0].message;return _context145.a(2,_s8.tool_calls?this.handleTools({tool_calls:_s8.tool_calls},t):_defineProperty({},h,_s8.content||""));case 3:return _context145.a(2,_defineProperty({},h,""));}},_callee145,this);}));function extractResultData(_x270,_x271){return _extractResultData30.apply(this,arguments);}return extractResultData;}()},{key:"processStreamingResponse",value:function(){var _processStreamingResponse=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee146(e,t){var i,n,s,_iterator4,_step4,o,a,l,c,_t51,_t52;return _regenerator().w(function(_context146){while(1)switch(_context146.p=_context146.n){case 0:n=e.split("\n").filter(function(o){return o.trim()!=="";});s="";_iterator4=_createForOfIteratorHelper(n);_context146.p=1;_iterator4.s();case 2:if((_step4=_iterator4.n()).done){_context146.n=8;break;}o=_step4.value;a=o.trim();if(!(a.startsWith("data: ")&&(a=a.substring(6)),a!=="[DONE]")){_context146.n=7;break;}_context146.p=3;l=JSON.parse(a);if(!(l.choices&&(i=l.choices[0])!=null&&i.delta)){_context146.n=5;break;}c=l.choices[0].delta;if(!c.tool_calls){_context146.n=4;break;}return _context146.a(2,this.handleTools({tool_calls:c.tool_calls},t));case 4:c.content&&(s+=c.content);case 5:_context146.n=7;break;case 6:_context146.p=6;_t51=_context146.v;return _context146.a(3,7);case 7:_context146.n=2;break;case 8:_context146.n=10;break;case 9:_context146.p=9;_t52=_context146.v;_iterator4.e(_t52);case 10:_context146.p=10;_iterator4.f();return _context146.f(10);case 11:return _context146.a(2,_defineProperty({},h,s));}},_callee146,this,[[3,6],[1,9,10,11]]);}));function processStreamingResponse(_x272,_x273){return _processStreamingResponse.apply(this,arguments);}return processStreamingResponse;}()},{key:"handleTools",value:function(){var _handleTools2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee147(e,t){var n,s,_yield$this$callToolF3,i,o;return _regenerator().w(function(_context147){while(1)switch(_context147.n){case 0:if(!(!e.tool_calls||!t||!this.functionHandler)){_context147.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.tool_calls.map(function(a){return{name:a["function"].name,arguments:a["function"].arguments};});_context147.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF3=_context147.v;i=_yield$this$callToolF3.responses;o=_yield$this$callToolF3.processedResponse;if(!o){_context147.n=3;break;}return _context147.a(2,o);case 3:if(!(n.messages.push({tool_calls:e.tool_calls,role:ot,content:""}),!i.find(function(_ref162){var a=_ref162.response;return typeof a!="string";})&&s.length===i.length)){_context147.n=4;break;}return _context147.a(2,(i.forEach(function(a,l){var d;var c=(d=e.tool_calls)==null?void 0:d[l];n==null||n.messages.push({role:"tool",tool_name:c==null?void 0:c["function"].name,content:a.response});}),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context147.a(2);}},_callee147,this);}));function handleTools(_x274,_x275){return _handleTools2.apply(this,arguments);}return handleTools;}()}]);}(R);var sd=function sd(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},id=function id(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},rd=function rd(){return ce("https://api.deepseek.com/models",ae,id);};var od=/*#__PURE__*/function(_R21){function od(e){var _this71$maxMessages,_s$model2,_i$temperature,_o$max_tokens;var _this71;_classCallCheck(this,od);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).deepSeek;_this71=_callSuper(this,od,[e,rd(),sd,n]),_this71.insertKeyPlaceholderText=_this71.genereteAPIKeyName("DeepSeek"),_this71.keyHelpUrl="https://platform.deepseek.com/api_keys",_this71.url="https://api.deepseek.com/v1/chat/completions",_this71.permittedErrorPrefixes=[We,be],_typeof(n)===B&&_this71.completeConfig(n),(_this71$maxMessages=_this71.maxMessages)!==null&&_this71$maxMessages!==void 0?_this71$maxMessages:_this71.maxMessages=-1,(_s$model2=(s=_this71.rawBody).model)!==null&&_s$model2!==void 0?_s$model2:s.model="deepseek-chat",(_i$temperature=(i=_this71.rawBody).temperature)!==null&&_i$temperature!==void 0?_i$temperature:i.temperature=1,(_o$max_tokens=(o=_this71.rawBody).max_tokens)!==null&&_o$max_tokens!==void 0?_o$max_tokens:o.max_tokens=4096;return _this71;}_inherits(od,_R21);return _createClass(od,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI28=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee148(e,t){return _regenerator().w(function(_context148){while(1)switch(_context148.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context148.a(2);}},_callee148,this);}));function callServiceAPI(_x276,_x277){return _callServiceAPI28.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData31=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee149(e){var t;return _regenerator().w(function(_context149){while(1)switch(_context149.n){case 0:if(!e[f]){_context149.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context149.n=3;break;}t=e.choices[0];if(!(t.delta&&t.delta.content)){_context149.n=2;break;}return _context149.a(2,_defineProperty({},h,t.delta.content));case 2:if(!(t.message&&t.message.content)){_context149.n=3;break;}return _context149.a(2,_defineProperty({},h,t.message.content));case 3:return _context149.a(2,_defineProperty({},h,""));}},_callee149);}));function extractResultData(_x278){return _extractResultData31.apply(this,arguments);}return extractResultData;}()}]);}(R);var ad=function ad(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},ld=function ld(r,e,t,n){var i;((i=r.base_resp)==null?void 0:i.status_code)===1004?n(le):t(e);},cd=function cd(){return ce("https://api.minimax.io/v1/files/delete",he,ld);};var dd=/*#__PURE__*/function(_R22){function dd(e){var _this72$maxMessages,_s$model3;var _this72;_classCallCheck(this,dd);var s;var n=JSON.parse(JSON.stringify(e.directConnection)).miniMax;_this72=_callSuper(this,dd,[e,cd(),ad,n]),_this72.insertKeyPlaceholderText=_this72.genereteAPIKeyName("MiniMax"),_this72.keyHelpUrl="https://www.minimaxi.com",_this72.url="https://api.minimax.io/v1/text/chatcompletion_v2",_this72.permittedErrorPrefixes=[We,be,"insufficient balance"],_typeof(n)===B&&_this72.completeConfig(n),(_this72$maxMessages=_this72.maxMessages)!==null&&_this72$maxMessages!==void 0?_this72$maxMessages:_this72.maxMessages=-1,(_s$model3=(s=_this72.rawBody).model)!==null&&_s$model3!==void 0?_s$model3:s.model="MiniMax-M1";return _this72;}_inherits(dd,_R22);return _createClass(dd,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI29=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee150(e,t){return _regenerator().w(function(_context150){while(1)switch(_context150.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context150.a(2);}},_callee150,this);}));function callServiceAPI(_x279,_x280){return _callServiceAPI29.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee151(e){var t,_n1;return _regenerator().w(function(_context151){while(1)switch(_context151.n){case 0:if(!e[f]){_context151.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context151.n=3;break;}_n1=e.choices[0];if(!(_n1.delta&&_n1.delta.content)){_context151.n=2;break;}return _context151.a(2,_defineProperty({},h,_n1.delta.content));case 2:if(!(_n1.message&&_n1.message.content)){_context151.n=3;break;}return _context151.a(2,_defineProperty({},h,_n1.message.content));case 3:if(!(typeof((t=e.base_resp)==null?void 0:t.status_code)=="number"&&e.base_resp.status_code>0)){_context151.n=4;break;}throw e.base_resp.status_msg;case 4:return _context151.a(2,_defineProperty({},h,""));}},_callee151);}));function extractResultData(_x281){return _extractResultData32.apply(this,arguments);}return extractResultData;}()}]);}(R);var hd=function hd(r){return _defineProperty(_defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W),"accept",W);},ud=function ud(r,e,t,n){r.detail?n(le):t(e);},pd=function pd(){return ce("https://api.mistral.ai/v1/models",ae,ud);};var Qi=/*#__PURE__*/function(_R23){function Qi(e){var _this73$maxMessages,_o$model1;var _this73;_classCallCheck(this,Qi);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).mistral;_this73=_callSuper(this,Qi,[e,pd(),hd,n]),_this73.insertKeyPlaceholderText=_this73.genereteAPIKeyName("Mistral"),_this73.keyHelpUrl="https://console.mistral.ai/api-keys/",_this73.url="https://api.mistral.ai/v1/chat/completions",_this73.permittedErrorPrefixes=[Ot],_typeof(n)===B&&_this73.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.mistral)==null?void 0:i.function_handler),(_this73$maxMessages=_this73.maxMessages)!==null&&_this73$maxMessages!==void 0?_this73$maxMessages:_this73.maxMessages=-1,(_o$model1=(o=_this73.rawBody).model)!==null&&_o$model1!==void 0?_o$model1:o.model="mistral-small-latest";return _this73;}_inherits(Qi,_R23);return _createClass(Qi,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{role:R.getRoleViaAI(i.role),content:R.getTextWFilesContent(i,Qi.getFileContent)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI30=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee152(e,t){var _this$messages6;return _regenerator().w(function(_context152){while(1)switch(_context152.n){case 0:(_this$messages6=this.messages)!==null&&_this$messages6!==void 0?_this$messages6:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context152.a(2);}},_callee152,this);}));function callServiceAPI(_x282,_x283){return _callServiceAPI30.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee153(e,t){var _n10;return _regenerator().w(function(_context153){while(1)switch(_context153.n){case 0:if(!e.message){_context153.n=1;break;}throw e.message;case 1:if(!e[f]){_context153.n=2;break;}throw e[f].message;case 2:if(!(e.choices&&e.choices.length>0)){_context153.n=4;break;}_n10=e.choices[0];if(!_n10.delta){_context153.n=3;break;}return _context153.a(2,this.extractStreamResult(_n10,t));case 3:if(!_n10.message){_context153.n=4;break;}return _context153.a(2,_n10.message.tool_calls?this.handleToolsGeneric({tool_calls:_n10.message.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n10.message.content||""));case 4:return _context153.a(2,_defineProperty({},h,""));}},_callee153,this);}));function extractResultData(_x284,_x285){return _extractResultData33.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee154(e,t){var n,s,i;return _regenerator().w(function(_context154){while(1)switch(_context154.n){case 0:n=e.delta,s=e.finish_reason;if(!(s==="tool_calls"&&n!=null&&n.tool_calls)){_context154.n=1;break;}i={tool_calls:n.tool_calls};return _context154.a(2,this.handleToolsGeneric(i,this.functionHandler,this.messages,t));case 1:return _context154.a(2,_defineProperty({},h,(n==null?void 0:n.content)||""));}},_callee154,this);}));function extractStreamResult(_x286,_x287){return _extractStreamResult4.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type===q?_defineProperty(_defineProperty({},T,Ne),Ne,t[A]||""):_defineProperty(_defineProperty({},T,h),h,"[Unsupported ".concat(ee," type: ").concat(t.type,"]"));});}}]);}(R);var er=/*#__PURE__*/function(_R24){function er(e){var _this74$maxMessages,_c$model3;var _this74;_classCallCheck(this,er);var i,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.groq;_this74=_callSuper(this,er,[e,qo(),jo,n]),_this74.insertKeyPlaceholderText=_this74.genereteAPIKeyName("Groq"),_this74.keyHelpUrl="https://console.groq.com/keys",_this74.url="https://api.groq.com/openai/v1/chat/completions",_this74.permittedErrorPrefixes=[Ot,"property"];var s=(i=t.groq)==null?void 0:i.chat;_typeof(s)===B&&_this74.completeConfig(s,(l=(a=(o=e.directConnection)==null?void 0:o.groq)==null?void 0:a.chat)==null?void 0:l.function_handler),(_this74$maxMessages=_this74.maxMessages)!==null&&_this74$maxMessages!==void 0?_this74$maxMessages:_this74.maxMessages=-1,(_c$model3=(c=_this74.rawBody).model)!==null&&_c$model3!==void 0?_c$model3:c.model="llama-3.3-70b-versatile";return _this74;}_inherits(er,_R24);return _createClass(er,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:er.getTextWImagesContent(i),role:i.role===K?ot:i.role};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI31=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee155(e,t){var _this$messages7;return _regenerator().w(function(_context155){while(1)switch(_context155.n){case 0:(_this$messages7=this.messages)!==null&&_this$messages7!==void 0?_this$messages7:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context155.a(2);}},_callee155,this);}));function callServiceAPI(_x288,_x289){return _callServiceAPI31.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee156(e,t){var n,s,i,o;return _regenerator().w(function(_context156){while(1)switch(_context156.n){case 0:if(!e[f]){_context156.n=1;break;}throw e[f].message;case 1:return _context156.a(2,(s=(n=e.choices)==null?void 0:n[0])!=null&&s.delta?this.extractStreamResult(e.choices[0],t):(o=(i=e.choices)==null?void 0:i[0])!=null&&o.message?e.choices[0].message.tool_calls?this.handleToolsGeneric(e.choices[0].message,this.functionHandler,this.messages,t,{message:this.systemMessage}):_defineProperty({},h,e.choices[0].message.content||""):_defineProperty({},h,""));}},_callee156,this);}));function extractResultData(_x290,_x291){return _extractResultData34.apply(this,arguments);}return extractResultData;}()// https://console.groq.com/docs/tool-use
202
- },{key:"extractStreamResult",value:function(){var _extractStreamResult5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee157(e,t){return _regenerator().w(function(_context157){while(1)switch(_context157.n){case 0:return _context157.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee157,this);}));function extractStreamResult(_x292,_x293){return _extractStreamResult5.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var fd=function fd(r){return _defineProperty(_defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W),"accept",W);},md=function md(r,e,t,n){typeof r.message=="string"?n(le):t(e);},gd=function gd(){return ce("https://api.cohere.ai/v1/models",ae,md);};var Gs=/*#__PURE__*/function(_R25){function Gs(e){var _this75$maxMessages,_s$model4;var _this75;_classCallCheck(this,Gs);var s;var n=JSON.parse(JSON.stringify(e.directConnection)).cohere;if(_this75=_callSuper(this,Gs,[e,gd(),fd,n]),_this75.insertKeyPlaceholderText=_this75.genereteAPIKeyName("Cohere"),_this75.keyHelpUrl="https://dashboard.cohere.ai/api-keys",_this75.permittedErrorPrefixes=["invalid"],_this75.url="https://api.cohere.com/v2/chat",_typeof(n)===B){var i=ne.processCohere(n);_this75.canSendMessage=function(){return i;},_this75.cleanConfig(n),Object.assign(_this75.rawBody,n);}(_this75$maxMessages=_this75.maxMessages)!==null&&_this75$maxMessages!==void 0?_this75$maxMessages:_this75.maxMessages=-1,(_s$model4=(s=_this75.rawBody).model)!==null&&_s$model4!==void 0?_s$model4:s.model="command-a-03-2025";return _this75;}_inherits(Gs,_R25);return _createClass(Gs,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t.filter(function(i){return i[h];});return n.messages=s.map(function(i){return{role:R.getRoleViaAI(i.role),content:i[h]};}),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee158(e,t){return _regenerator().w(function(_context158){while(1)switch(_context158.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context158.a(2);}},_callee158,this);}));function callServiceAPI(_x294,_x295){return _callServiceAPI32.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee159(e){var t,n,s,i;return _regenerator().w(function(_context159){while(1)switch(_context159.n){case 0:if(!(typeof e.message=="string")){_context159.n=1;break;}throw e.message;case 1:if(!(this.stream&&e[h])){_context159.n=2;break;}i=Gs.parseBundledEvents(e[h]);return _context159.a(2,{text:Gs.aggregateBundledEventsText(i)});case 2:if(!("message"in e&&(s=(n=(t=e.message)==null?void 0:t.content)==null?void 0:n[0])!=null&&s[h])){_context159.n=3;break;}return _context159.a(2,_defineProperty({},h,e.message.content[0][h]));case 3:throw new Error("Invalid response format from Cohere API");case 4:return _context159.a(2);}},_callee159,this);}));function extractResultData(_x296){return _extractResultData35.apply(this,arguments);}return extractResultData;}()}],[{key:"parseBundledEvents",value:function parseBundledEvents(e){var t=e.trim().split("\n"),n=[];var _iterator5=_createForOfIteratorHelper(t),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var s=_step5.value;if(s.trim())try{var i=JSON.parse(s);n.push(i);}catch(i){console[f]("Failed to parse line:",s,i);}}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}return n;}},{key:"aggregateBundledEventsText",value:function aggregateBundledEventsText(e){return e.filter(function(t){var n,s,i;return t.type==="content-delta"&&((i=(s=(n=t.delta)==null?void 0:n.message)==null?void 0:s.content)==null?void 0:i[h]);}).map(function(t){var n,s,i;return(i=(s=(n=t.delta)==null?void 0:n.message)==null?void 0:s.content)==null?void 0:i[h];}).join("");}}]);}(R);var yd=function yd(){return _defineProperty({},D,W);},bd=function bd(r,e,t,n){var i;var s=r;s[f]?s[f].code===403||(i=s[f].message)!=null&&i.includes("API key")?n(le):n(He):t(e);},vd=function vd(){var r="https://generativelanguage.googleapis.com/v1beta/models?key=";return ce(r,ae,bd,function(e){return"".concat(r).concat(e);});};var tr=/*#__PURE__*/function(_R26){function tr(e){var _this76$maxMessages;var _this76;_classCallCheck(this,tr);var s,i;var n=JSON.parse(JSON.stringify(e.directConnection)).gemini;_this76=_callSuper(this,tr,[e,vd(),yd,n]),_this76.insertKeyPlaceholderText=_this76.genereteAPIKeyName("Gemini"),_this76.keyHelpUrl="https://aistudio.google.com/app/apikey",_this76.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",_this76.url="",_this76.permittedErrorPrefixes=["API_KEY_INVALID"],_typeof(n)===B&&(n.model&&(_this76.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/".concat(n.model,":generateContent")),_this76.cleanConfig(n),_this76.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.gemini)==null?void 0:i.function_handler)),(_this76$maxMessages=_this76.maxMessages)!==null&&_this76$maxMessages!==void 0?_this76$maxMessages:_this76.maxMessages=-1;return _this76;}_inherits(tr,_R26);return _createClass(tr,[{key:"cleanConfig",value:function cleanConfig(e){delete e.model;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return tr.getContent(i);});return n.contents=s,this.systemMessage&&(n.systemInstruction={parts:[_defineProperty({},h,this.systemMessage)]}),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee160(e,t){var _this$messages8;var n,s;return _regenerator().w(function(_context160){while(1)switch(_context160.n){case 0:if(this.connectSettings){_context160.n=1;break;}throw new Error(Me);case 1:(_this$messages8=this.messages)!==null&&_this$messages8!==void 0?_this$messages8:this.messages=e;n=this.preprocessBody(this.rawBody,t),s=this.stream;s&&(_typeof(s)!==B||!s.simulation)||n.stream?(this.url="".concat(this.urlPrefix.replace(":generateContent",":streamGenerateContent"),"?alt=sse&key=").concat(this.key),U.request(this,n,e)):(this.url="".concat(this.urlPrefix,"?key=").concat(this.key),re.request(this,n,e));case 2:return _context160.a(2);}},_callee160,this);}));function callServiceAPI(_x297,_x298){return _callServiceAPI33.apply(this,arguments);}return callServiceAPI;}()// https://ai.google.dev/gemini-api/docs/function-calling?example=weather
203
- },{key:"extractResultData",value:function(){var _extractResultData36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee161(e,t){var n,s,i,o,a,l,c,d;return _regenerator().w(function(_context161){while(1)switch(_context161.n){case 0:if(!e[f]){_context161.n=1;break;}throw e[f].message||"Gemini API Error";case 1:if(!((i=(s=(n=e.candidates)==null?void 0:n[0])==null?void 0:s.content)!=null&&i.parts)){_context161.n=3;break;}a=e.candidates[0].content.parts,l=a.find(function(p){return p.functionCall;});if(!(l!=null&&l.functionCall)){_context161.n=2;break;}return _context161.a(2,this.handleTools([l.functionCall],t));case 2:c=a.find(function(p){return p[h];}),d=a.find(function(p){var u;return((u=p.inlineData)==null?void 0:u.mimeType)==="image/png";});return _context161.a(2,_defineProperty(_defineProperty({},h,(c==null?void 0:c[h])||""),y,(o=d==null?void 0:d.inlineData)!=null&&o.data?[_defineProperty({},A,"data:image/png;base64,".concat(d.inlineData.data))]:[]));case 3:return _context161.a(2,_defineProperty({},h,""));}},_callee161,this);}));function extractResultData(_x299,_x300){return _extractResultData36.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee162(e,t){var n,s,_yield$this$callToolF4,i,o,a,l;return _regenerator().w(function(_context162){while(1)switch(_context162.n){case 0:if(!(!e||!t||!this.functionHandler)){_context162.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.args)};});_context162.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF4=_context162.v;i=_yield$this$callToolF4.responses;o=_yield$this$callToolF4.processedResponse;if(!o){_context162.n=3;break;}return _context162.a(2,o);case 3:a={parts:e.map(function(l){return{functionCall:{name:l.name,args:l.args}};}),role:"model"};if(!(n.contents.push(a),!i.find(function(_ref186){var l=_ref186.response;return typeof l!="string";})&&s.length===i.length)){_context162.n=4;break;}l={parts:i.map(function(c,d){return{functionResponse:{name:e[d].name,response:{result:c.response}}};}),role:H};return _context162.a(2,(n.contents.push(l),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context162.a(2);}},_callee162,this);}));function handleTools(_x301,_x302){return _handleTools3.apply(this,arguments);}return handleTools;}()}],[{key:"getContent",value:function getContent(e){var t=[];return e[h]&&e[h].trim().length>0&&t.push(_defineProperty({},h,e[h])),e[y]&&e[y].length>0&&e[y].forEach(function(n){if(n[A]&&n[A].includes("data:")){var _n$A$split=n[A].split(","),_n$A$split2=_slicedToArray(_n$A$split,2),s=_n$A$split2[0],i=_n$A$split2[1];t.push({inlineData:{mimeType:s.replace("data:","").replace(";base64",""),data:i}});}}),{parts:t,role:e.role===H?H:"model"};}}]);}(R);var _d=function _d(r){return _defineProperty(_defineProperty(_defineProperty({"x-api-key":r},D,W),"anthropic-version","2023-06-01"),"anthropic-dangerous-direct-browser-access","true");},Ed=function Ed(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},Sd=function Sd(){return ce("https://api.anthropic.com/v1/models",ae,Ed);};var zs=/*#__PURE__*/function(_R27){function zs(e){var _this77$maxMessages,_o$model10,_a$max_tokens2;var _this77;_classCallCheck(this,zs);var s,i,o,a;var n=JSON.parse(JSON.stringify(e.directConnection)).claude;_this77=_callSuper(this,zs,[e,Sd(),_d,n]),_this77.insertKeyPlaceholderText=_this77.genereteAPIKeyName("Claude"),_this77.keyHelpUrl="https://console.anthropic.com/settings/keys",_this77.url="https://api.anthropic.com/v1/messages",_this77.permittedErrorPrefixes=[be,We],_this77._streamToolCalls=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},T,"tool_use"),"id",""),"name",""),"input",""),_typeof(n)===B&&_this77.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.claude)==null?void 0:i.function_handler),(_this77$maxMessages=_this77.maxMessages)!==null&&_this77$maxMessages!==void 0?_this77$maxMessages:_this77.maxMessages=-1,(_o$model10=(o=_this77.rawBody).model)!==null&&_o$model10!==void 0?_o$model10:o.model="claude-sonnet-4-5-20250929",(_a$max_tokens2=(a=_this77.rawBody).max_tokens)!==null&&_a$max_tokens2!==void 0?_a$max_tokens2:a.max_tokens=4096;return _this77;}_inherits(zs,_R27);return _createClass(zs,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:zs.getTextWFilesContent(i,zs.getFileContent),role:R.getRoleViaUser(i.role)};});return n.messages=s,this.systemMessage&&(n.system=this.systemMessage),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee163(e,t){var _this$messages9;return _regenerator().w(function(_context163){while(1)switch(_context163.n){case 0:(_this$messages9=this.messages)!==null&&_this$messages9!==void 0?_this$messages9:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context163.a(2);}},_callee163,this);}));function callServiceAPI(_x303,_x304){return _callServiceAPI34.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee164(e,t){var n,s,i,o,a;return _regenerator().w(function(_context164){while(1)switch(_context164.n){case 0:if(!e[f]){_context164.n=1;break;}throw e[f].message;case 1:if(!(e.content&&e.content.length>0)){_context164.n=3;break;}o=e.content.find(function(l){return l.type==="tool_use";});if(!o){_context164.n=2;break;}return _context164.a(2,this.handleTools([o],t));case 2:a=e.content.find(function(l){return l.type===h;});if(!a){_context164.n=3;break;}return _context164.a(2,_defineProperty({},h,a[h]));case 3:if(!(e.type==="content_block_delta"&&e.delta&&e.delta.type==="text_delta")){_context164.n=4;break;}return _context164.a(2,_defineProperty({},h,e.delta[h]||""));case 4:if(!(e.type==="content_block_start"&&((n=e.content_block)==null?void 0:n.type)==="tool_use")){_context164.n=5;break;}this._streamToolCalls=e.content_block,this._streamToolCalls.input="";_context164.n=7;break;case 5:if(!(e.type==="content_block_delta"&&((s=e.delta)==null?void 0:s.type)==="input_json_delta")){_context164.n=6;break;}this._streamToolCalls.input+=e.delta.partial_json||"";_context164.n=7;break;case 6:if(!(e.type==="message_delta"&&((i=e.delta)==null?void 0:i.stop_reason)==="tool_use")){_context164.n=7;break;}return _context164.a(2,(this._streamToolCalls.input=JSON.parse(this._streamToolCalls.input),this.handleTools([this._streamToolCalls],t)));case 7:return _context164.a(2,_defineProperty({},h,""));}},_callee164,this);}));function extractResultData(_x305,_x306){return _extractResultData37.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee165(e,t){var n,s,_yield$this$callToolF5,i,o,a,l;return _regenerator().w(function(_context165){while(1)switch(_context165.n){case 0:if(!(!e||!t||!this.functionHandler)){_context165.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.input)};});_context165.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF5=_context165.v;i=_yield$this$callToolF5.responses;o=_yield$this$callToolF5.processedResponse;if(!o){_context165.n=3;break;}return _context165.a(2,o);case 3:a=e.map(function(l){return _defineProperty(_defineProperty(_defineProperty(_defineProperty({},T,"tool_use"),"id",l.id),"name",l.name),"input",l.input);});if(!(n.messages.push({role:"assistant",content:a}),!i.find(function(_ref192){var l=_ref192.response;return typeof l!="string";})&&s.length===i.length)){_context165.n=4;break;}l=i.map(function(c,d){return _defineProperty(_defineProperty(_defineProperty({},T,"tool_result"),"tool_use_id",e[d].id),"content",c.response);});return _context165.a(2,(n.messages.push({role:H,content:l}),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context165.a(2);}},_callee165,this);}));function handleTools(_x307,_x308){return _handleTools4.apply(this,arguments);}return handleTools;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){var n,s,i;if(t.type===q){var o=(n=t[A])==null?void 0:n.split(",")[1],a=((i=(s=t[A])==null?void 0:s.match(/data:([^;]+)/))==null?void 0:i[1])||"image/jpeg";return _defineProperty(_defineProperty({},T,q),"source",_defineProperty(_defineProperty(_defineProperty({},T,"base64"),"media_type",a),"data",o||""));}return _defineProperty(_defineProperty({},T,h),h,"[Unsupported ".concat(ee," type: ").concat(t.type,"]"));});}}]);}(R);var xd=function xd(){return{};},Ad=function Ad(){},wd=function wd(){return ce("",ae,Ad);};var nr=/*#__PURE__*/function(_R28){function nr(e){var _this78$maxMessages,_o$model11,_a$stream2;var _this78;_classCallCheck(this,nr);var s,i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection));_this78=_callSuper(this,nr,[e,wd(),xd,{key:"placeholder"}]),_this78.insertKeyPlaceholderText="",_this78.keyHelpUrl="",_this78.validateKeyProperty=!1,_this78.url="http://localhost:11434/api/chat",_this78.permittedErrorPrefixes=["Error"];var n=t.ollama;_typeof(n)===B&&_this78.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.ollama)==null?void 0:i.function_handler),(_this78$maxMessages=_this78.maxMessages)!==null&&_this78$maxMessages!==void 0?_this78$maxMessages:_this78.maxMessages=-1,(_o$model11=(o=_this78.rawBody).model)!==null&&_o$model11!==void 0?_o$model11:o.model="llama3.2",(_a$stream2=(a=_this78.rawBody).stream)!==null&&_a$stream2!==void 0?_a$stream2:a.stream=!1;return _this78;}_inherits(nr,_R28);return _createClass(nr,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){var o={content:i[h]||"",role:R.getRoleViaUser(i.role)};if(i[y]&&i[y].length>0){var a=nr.getImageData(i[y]);a.length>0&&(o[J]=a);}return o;});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee166(e,t){var _this$messages0;return _regenerator().w(function(_context166){while(1)switch(_context166.n){case 0:(_this$messages0=this.messages)!==null&&_this$messages0!==void 0?_this$messages0:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context166.a(2);}},_callee166,this);}));function callServiceAPI(_x309,_x310){return _callServiceAPI35.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee167(e,t){var n,s,i;return _regenerator().w(function(_context167){while(1)switch(_context167.n){case 0:if(!e[f]){_context167.n=1;break;}throw e[f].message;case 1:if(!e[h]){_context167.n=2;break;}i=JSON.parse(e[h]);return _context167.a(2,(n=i.message)!=null&&n.tool_calls?this.handleTools({tool_calls:i.message.tool_calls},t):_defineProperty({},h,((s=i.message)==null?void 0:s.content)||""));case 2:return _context167.a(2,e.message?e.message.tool_calls?this.handleTools({tool_calls:e.message.tool_calls},t):_defineProperty({},h,e.message.content||""):_defineProperty({},h,""));}},_callee167,this);}));function extractResultData(_x311,_x312){return _extractResultData38.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee168(e,t){var n,s,_yield$this$callToolF6,i,o;return _regenerator().w(function(_context168){while(1)switch(_context168.n){case 0:if(!(!e.tool_calls||!t||!this.functionHandler)){_context168.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.tool_calls.map(function(a){return{name:a["function"].name,arguments:JSON.stringify(a["function"].arguments)};});_context168.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF6=_context168.v;i=_yield$this$callToolF6.responses;o=_yield$this$callToolF6.processedResponse;if(!o){_context168.n=3;break;}return _context168.a(2,o);case 3:if(!(n.messages.push({tool_calls:e.tool_calls,role:ot,content:""}),!i.find(function(_ref199){var a=_ref199.response;return typeof a!="string";})&&s.length===i.length)){_context168.n=4;break;}return _context168.a(2,(i.forEach(function(a,l){var d;var c=(d=e.tool_calls)==null?void 0:d[l];n==null||n.messages.push({role:"tool",tool_name:c==null?void 0:c["function"].name,content:a.response});}),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context168.a(2);}},_callee168,this);}));function handleTools(_x313,_x314){return _handleTools5.apply(this,arguments);}return handleTools;}()}],[{key:"getImageData",value:function getImageData(e){return e.filter(function(t){return t.type===q;}).map(function(t){var s;return((s=t[A])==null?void 0:s.split(",")[1])||"";}).filter(function(t){return t.length>0;});}}]);}(R);var $o=function $o(r){return _defineProperty({Authorization:"".concat(ye).concat(r)},D,W);},Cd=function Cd(r,e,t,n){var s=r;s[f]?s[f].type===be||s[f].type===We?n(le):n(He):t(e);},Go=function Go(){return ce("https://api.x.ai/v1/models",ae,Cd);},Ys=/*#__PURE__*/function(_R29){function Ys(e){var _o$model12;var _this79;_classCallCheck(this,Ys);var i,o;var t=e.directConnection,n=t==null?void 0:t.x;_this79=_callSuper(this,Ys,[e,Go(),$o,n]),_this79.insertKeyPlaceholderText=_this79.genereteAPIKeyName("X"),_this79.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this79.url=Ys.IMAGE_GENERATION_URL,_this79.permittedErrorPrefixes=[We,be];var s=(i=t==null?void 0:t.x)==null?void 0:i[J];_typeof(s)===B&&Object.assign(_this79.rawBody,s),(_o$model12=(o=_this79.rawBody).model)!==null&&_o$model12!==void 0?_o$model12:o.model="grok-2-image";return _this79;}_inherits(Ys,_R29);return _createClass(Ys,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h],s=JSON.parse(JSON.stringify(e));return n&&n!==""&&(s.prompt=n),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee169(e,t){return _regenerator().w(function(_context169){while(1)switch(_context169.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context169.a(2);}},_callee169,this);}));function callServiceAPI(_x315,_x316){return _callServiceAPI36.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee170(e){var t;return _regenerator().w(function(_context170){while(1)switch(_context170.n){case 0:if(!e[f]){_context170.n=1;break;}throw e[f].message;case 1:t=e.data.map(function(n){return n.url?_defineProperty(_defineProperty({},A,n.url),T,q):_defineProperty(_defineProperty({},A,"".concat(bn).concat(n.b64_json)),T,q);});return _context170.a(2,_defineProperty({},y,t));}},_callee170);}));function extractResultData(_x317){return _extractResultData39.apply(this,arguments);}return extractResultData;}()}]);}(R);Ys.IMAGE_GENERATION_URL="https://api.x.ai/v1/images/generations";var Li=Ys;var Td=function Td(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},Rd=function Rd(r,e,t,n){var s=r;s[f]?s[f].type===We?n(le):n(He):t(e);},Id=function Id(){return ce("https://dashscope-intl.aliyuncs.com/compatible-mode/v1/models",ae,Rd);};var sr=/*#__PURE__*/function(_R30){function sr(e){var _this80$maxMessages,_o$model13;var _this80;_classCallCheck(this,sr);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).qwen;_this80=_callSuper(this,sr,[e,Id(),Td,n]),_this80.insertKeyPlaceholderText=_this80.genereteAPIKeyName("Qwen"),_this80.keyHelpUrl="https://www.alibabacloud.com/help/en/model-studio/get-api-key",_this80.url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions",_this80.permittedErrorPrefixes=["No static","The model",fs],_typeof(n)===B&&_this80.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.qwen)==null?void 0:i.function_handler),(_this80$maxMessages=_this80.maxMessages)!==null&&_this80$maxMessages!==void 0?_this80$maxMessages:_this80.maxMessages=-1,(_o$model13=(o=_this80.rawBody).model)!==null&&_o$model13!==void 0?_o$model13:o.model="qwen-plus";return _this80;}_inherits(sr,_R30);return _createClass(sr,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:sr.getTextWImagesContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee171(e,t){var _this$messages1;return _regenerator().w(function(_context171){while(1)switch(_context171.n){case 0:(_this$messages1=this.messages)!==null&&_this$messages1!==void 0?_this$messages1:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context171.a(2);}},_callee171,this);}));function callServiceAPI(_x318,_x319){return _callServiceAPI37.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData40=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee172(e,t){var _n11;return _regenerator().w(function(_context172){while(1)switch(_context172.n){case 0:if(!e[f]){_context172.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context172.n=3;break;}_n11=e.choices[0];if(!_n11.delta){_context172.n=2;break;}return _context172.a(2,this.extractStreamResult(_n11,t));case 2:if(!_n11.message){_context172.n=3;break;}return _context172.a(2,_n11.message.tool_calls?this.handleToolsGeneric({tool_calls:_n11.message.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n11.message.content||""));case 3:return _context172.a(2,_defineProperty({},h,""));}},_callee172,this);}));function extractResultData(_x320,_x321){return _extractResultData40.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee173(e,t){return _regenerator().w(function(_context173){while(1)switch(_context173.n){case 0:return _context173.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee173,this);}));function extractStreamResult(_x322,_x323){return _extractStreamResult6.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var Md=function Md(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},kd=function kd(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},Od=function Od(){return ce("https://api.moonshot.ai/v1/models",ae,kd);};var ir=/*#__PURE__*/function(_R31){function ir(e){var _this81$maxMessages,_o$model14;var _this81;_classCallCheck(this,ir);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).kimi;_this81=_callSuper(this,ir,[e,Od(),Md,n]),_this81.insertKeyPlaceholderText=_this81.genereteAPIKeyName("Kimi"),_this81.keyHelpUrl="https://platform.moonshot.ai/console/api-keys",_this81.url="https://api.moonshot.ai/v1/chat/completions",_this81.permittedErrorPrefixes=[Ot,"Not found"],_typeof(n)===B&&_this81.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.kimi)==null?void 0:i.function_handler),(_this81$maxMessages=_this81.maxMessages)!==null&&_this81$maxMessages!==void 0?_this81$maxMessages:_this81.maxMessages=-1,(_o$model14=(o=_this81.rawBody).model)!==null&&_o$model14!==void 0?_o$model14:o.model="moonshot-v1-8k";return _this81;}_inherits(ir,_R31);return _createClass(ir,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:ir.getTextWImagesContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee174(e,t){var _this$messages10;return _regenerator().w(function(_context174){while(1)switch(_context174.n){case 0:(_this$messages10=this.messages)!==null&&_this$messages10!==void 0?_this$messages10:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context174.a(2);}},_callee174,this);}));function callServiceAPI(_x324,_x325){return _callServiceAPI38.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData41=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee175(e,t){var _n12;return _regenerator().w(function(_context175){while(1)switch(_context175.n){case 0:if(!e[f]){_context175.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context175.n=3;break;}_n12=e.choices[0];if(!_n12.delta){_context175.n=2;break;}return _context175.a(2,this.extractStreamResult(_n12,t));case 2:if(!_n12.message){_context175.n=3;break;}return _context175.a(2,_n12.message.tool_calls?this.handleToolsGeneric({tool_calls:_n12.message.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n12.message.content||""));case 3:return _context175.a(2,_defineProperty({},h,""));}},_callee175,this);}));function extractResultData(_x326,_x327){return _extractResultData41.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee176(e,t){return _regenerator().w(function(_context176){while(1)switch(_context176.n){case 0:return _context176.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee176,this);}));function extractStreamResult(_x328,_x329){return _extractStreamResult7.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var Nd=/*#__PURE__*/function(_R32){function Nd(e){var _this82$maxMessages,_o$model15;var _this82;_classCallCheck(this,Nd);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.x;_this82=_callSuper(this,Nd,[e,Go(),$o,n]),_this82.insertKeyPlaceholderText=_this82.genereteAPIKeyName("X"),_this82.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this82.url="https://api.x.ai/v1/chat/completions",_this82.permittedErrorPrefixes=[We,be];var s=(i=t.x)==null?void 0:i.chat;_typeof(s)===B&&_this82.completeConfig(s),(_this82$maxMessages=_this82.maxMessages)!==null&&_this82$maxMessages!==void 0?_this82$maxMessages:_this82.maxMessages=-1,(_o$model15=(o=_this82.rawBody).model)!==null&&_o$model15!==void 0?_o$model15:o.model="grok-3-latest";return _this82;}_inherits(Nd,_R32);return _createClass(Nd,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee177(e,t){return _regenerator().w(function(_context177){while(1)switch(_context177.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context177.a(2);}},_callee177,this);}));function callServiceAPI(_x330,_x331){return _callServiceAPI39.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData42=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee178(e){var t,n,s,i,o;return _regenerator().w(function(_context178){while(1)switch(_context178.n){case 0:if(!e[f]){_context178.n=1;break;}throw e[f].message;case 1:if(!(e.object==="chat.completion.chunk")){_context178.n=2;break;}o=(t=e.choices)==null?void 0:t[0];return _context178.a(2,(n=o==null?void 0:o.delta)!=null&&n.content?_defineProperty({},h,o.delta.content):_defineProperty({},h,""));case 2:return _context178.a(2,e.object==="chat.completion"&&(i=(s=e.choices)==null?void 0:s[0])!=null&&i.message?_defineProperty({},h,e.choices[0].message.content||""):_defineProperty({},h,""));}},_callee178);}));function extractResultData(_x332){return _extractResultData42.apply(this,arguments);}return extractResultData;}()}]);}(R);var Pd=/*#__PURE__*/function(){function Pd(){_classCallCheck(this,Pd);}return _createClass(Pd,null,[{key:"create",value:// this should only be called when no _activeService is set or is demo as otherwise we don't want to reconnect
204
- function create(e){var t=e.directConnection,n=e.connect,s=e.demo,i=e.webModel;if(i)return new ds(e);if(t){if(t.openAI)return t.openAI[J]?new Pi(e):t.openAI.speechToText?new Mi(e):t.openAI.textToSpeech?new Ii(e):t.openAI.assistant?new Xi(e):t.openAI.realtime?new Ri(e):t.openAI.completions?new js(e):new qs(e);if(t.assemblyAI)return new Zi(e);if(t.cohere)return new Gs(e);if(t.huggingFace)return t.huggingFace.textGeneration?new fc(e):t.huggingFace.summarization?new gc(e):t.huggingFace.translation?new bc(e):t.huggingFace.fillMask?new vc(e):t.huggingFace.questionAnswer?new mc(e):t.huggingFace.audioSpeechRecognition?new pc(e):t.huggingFace.audioClassification?new dc(e):t.huggingFace.imageClassification?new hc(e):new yc(e);if(t.azure){if(t.azure.openAI){if(t.azure.openAI.chat)return new Yi(e);if(t.azure.openAI.assistant)return new Ci(e);}if(t.azure.speechToText)return new Ni(e);if(t.azure.textToSpeech)return new Oi(e);if(t.azure.summarization)return new ki(e);if(t.azure.translation)return new Hc(e);}if(t.stabilityAI)return t.stabilityAI.imageToImage?new Ls(e):t.stabilityAI.imageToImageUpscale?new Ns(e):t.stabilityAI.imageToImageMasking?new Ps(e):new Bs(e);if(t.mistral)return new Qi(e);if(t.gemini)return new tr(e);if(t.claude)return new zs(e);if(t.deepSeek)return new od(e);if(t.miniMax)return new dd(e);if(t.openRouter)return new Zn(e);if(t.kimi)return new ir(e);if(t.x)return t.x[J]?new Li(e):new Nd(e);if(t.qwen)return new sr(e);if(t.together)return t.together[J]?new Gc(e):t.together.textToSpeech?new xc(e):new zc(e);if(t.bigModel)return t.bigModel[J]?new jc(e):t.bigModel.textToSpeech?new Ec(e):new $s(e);if(t.groq)return t.groq.textToSpeech?new $c(e):new er(e);if(t.perplexity)return new Yc(e);if(t.ollama)return new nr(e);if(t.openWebUI)return new nd(e);}return n&&Object.keys(n).length>0&&!s?new Zt(e):new Zt(e,void 0,s||!0);}}]);}();var ur=/*#__PURE__*/_createClass(function ur(){_classCallCheck(this,ur);});ur.attibutes={string:function string(e){return e;},number:function number(e){return parseFloat(e);},"boolean":function boolean(e){return e==="true";},object:function object(e){return JSON.parse(e);},array:function array(e){return JSON.parse(e);},"function":function _function(e){return new Function("return ".concat(e))();}};var Bi=ur;function k(r){return function(e,t){Object.defineProperty(e,t,{});var n=e.constructor,s=t.toLocaleLowerCase();n._attributes_[s]=Bi.attibutes[r],n._attributeToProperty_[s]=t;};}var Ld="deep-chat-downwards-mode",Bd="deep-chat-upwards-mode",An="submit-button",Ss="loading-button",wn="disabled-button",Fr="text-input-container-start-adjustment",Ur="text-input-container-end-adjustment",Hr="text-input-container-start-small-adjustment",jr="text-input-container-end-small-adjustment";var rr=/*#__PURE__*/function(){function rr(e){_classCallCheck(this,rr);this._isDisplayed=!1,this._elementRef=this.createIntroPanelWithChild(e),this._isDisplayed=!0;}return _createClass(rr,[{key:"createIntroPanelWithChild",value:function createIntroPanelWithChild(e){var t=rr.createIntroPanel();return e[_].display==="none"&&(e[_].display="block"),t.appendChild(e),t;}},{key:"hide",value:function hide(){this._isDisplayed&&(this._elementRef[_].display="none",this._isDisplayed=!1);}},{key:"display",value:function display(){this._isDisplayed||(this._elementRef[_].display="",this._isDisplayed=!0);}}],[{key:"createIntroPanel",value:function createIntroPanel(){var e=S();return e[m].add("intro-panel"),Object.assign(e[_]),e;}}]);}();var Dd="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n\t viewBox=\"50 30 420 450\" xml:space=\"preserve\">\n<g filter=\"brightness(0) saturate(100%) invert(16%) sepia(0%) saturate(1942%) hue-rotate(215deg) brightness(99%) contrast(93%)\">\n\t<g>\n\t\t<path d=\"M447.933,103.629c-0.034-3.076-1.224-6.09-3.485-8.352L352.683,3.511c-0.004-0.004-0.007-0.005-0.011-0.008\n\t\t\tC350.505,1.338,347.511,0,344.206,0H89.278C75.361,0,64.04,11.32,64.04,25.237v461.525c0,13.916,11.32,25.237,25.237,25.237\n\t\t\th333.444c13.916,0,25.237-11.32,25.237-25.237V103.753C447.96,103.709,447.937,103.672,447.933,103.629z M356.194,40.931\n\t\t\tl50.834,50.834h-49.572c-0.695,0-1.262-0.567-1.262-1.262V40.931z M423.983,486.763c0,0.695-0.566,1.261-1.261,1.261H89.278\n\t\t\tc-0.695,0-1.261-0.566-1.261-1.261V25.237c0-0.695,0.566-1.261,1.261-1.261h242.94v66.527c0,13.916,11.322,25.239,25.239,25.239\n\t\t\th66.527V486.763z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,164.014H149.912c-6.62,0-11.988,5.367-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,169.381,368.707,164.014,362.088,164.014z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,236.353H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,241.721,368.707,236.353,362.088,236.353z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,308.691H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C374.076,314.06,368.707,308.691,362.088,308.691z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M256,381.031H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988H256\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C267.988,386.398,262.62,381.031,256,381.031z\"/>\n\t</g>\n</g>\n</svg>",_e=/*#__PURE__*/function(){function _e(){_classCallCheck(this,_e);}return _createClass(_e,null,[{key:"createImage",value:function createImage(e,t){var n=new Image();return n[A]=e[A],t&&pe.scrollDownOnImageLoad(n[A],t),pe.processContent(q,n,n[A],e.name);}// WORK - image still does not scroll down when loaded
202
+ },{key:"extractStreamResult",value:function(){var _extractStreamResult5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee157(e,t){return _regenerator().w(function(_context157){while(1)switch(_context157.n){case 0:return _context157.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee157,this);}));function extractStreamResult(_x292,_x293){return _extractStreamResult5.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var fd=function fd(r){return _defineProperty(_defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W),"accept",W);},md=function md(r,e,t,n){typeof r.message=="string"?n(le):t(e);},gd=function gd(){return ce("https://api.cohere.ai/v1/models",ae,md);};var Gs=/*#__PURE__*/function(_R25){function Gs(e){var _this75$maxMessages,_s$model4;var _this75;_classCallCheck(this,Gs);var s;var n=JSON.parse(JSON.stringify(e.directConnection)).cohere;if(_this75=_callSuper(this,Gs,[e,gd(),fd,n]),_this75.insertKeyPlaceholderText=_this75.genereteAPIKeyName("Cohere"),_this75.keyHelpUrl="https://dashboard.cohere.ai/api-keys",_this75.permittedErrorPrefixes=["invalid"],_this75.url="https://api.cohere.com/v2/chat",_typeof(n)===B){var i=ne.processCohere(n);_this75.canSendMessage=function(){return i;},_this75.cleanConfig(n),Object.assign(_this75.rawBody,n);}(_this75$maxMessages=_this75.maxMessages)!==null&&_this75$maxMessages!==void 0?_this75$maxMessages:_this75.maxMessages=-1,(_s$model4=(s=_this75.rawBody).model)!==null&&_s$model4!==void 0?_s$model4:s.model="command-a-03-2025";return _this75;}_inherits(Gs,_R25);return _createClass(Gs,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=t.filter(function(i){return i[h];});return n.messages=s.map(function(i){return{role:R.getRoleViaAI(i.role),content:i[h]};}),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee158(e,t){return _regenerator().w(function(_context158){while(1)switch(_context158.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context158.a(2);}},_callee158,this);}));function callServiceAPI(_x294,_x295){return _callServiceAPI32.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee159(e){var t,n,s,i;return _regenerator().w(function(_context159){while(1)switch(_context159.n){case 0:if(!(typeof e.message=="string")){_context159.n=1;break;}throw e.message;case 1:if(!(this.stream&&e[h])){_context159.n=2;break;}i=Gs.parseBundledEvents(e[h]);return _context159.a(2,{text:Gs.aggregateBundledEventsText(i)});case 2:if(!("message"in e&&(s=(n=(t=e.message)==null?void 0:t.content)==null?void 0:n[0])!=null&&s[h])){_context159.n=3;break;}return _context159.a(2,_defineProperty({},h,e.message.content[0][h]));case 3:throw new Error("Invalid response format from Cohere API");case 4:return _context159.a(2);}},_callee159,this);}));function extractResultData(_x296){return _extractResultData35.apply(this,arguments);}return extractResultData;}()}],[{key:"parseBundledEvents",value:function parseBundledEvents(e){var t=e.trim().split("\n"),n=[];var _iterator5=_createForOfIteratorHelper(t),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var s=_step5.value;if(s.trim())try{var i=JSON.parse(s);n.push(i);}catch(i){console[f]("Failed to parse line:",s,i);}}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}return n;}},{key:"aggregateBundledEventsText",value:function aggregateBundledEventsText(e){return e.filter(function(t){var n,s,i;return t.type==="content-delta"&&((i=(s=(n=t.delta)==null?void 0:n.message)==null?void 0:s.content)==null?void 0:i[h]);}).map(function(t){var n,s,i;return(i=(s=(n=t.delta)==null?void 0:n.message)==null?void 0:s.content)==null?void 0:i[h];}).join("");}}]);}(R);var yd=function yd(){return _defineProperty({},D,W);},bd=function bd(r,e,t,n){var i;var s=r;s[f]?s[f].code===403||(i=s[f].message)!=null&&i.includes("API key")?n(le):n(He):t(e);},vd=function vd(){var r="https://generativelanguage.googleapis.com/v1beta/models?key=";return ce(r,ae,bd,function(e){return"".concat(r).concat(e);});};var tr=/*#__PURE__*/function(_R26){function tr(e){var _this76$maxMessages;var _this76;_classCallCheck(this,tr);var s,i;var n=JSON.parse(JSON.stringify(e.directConnection)).gemini;if(_this76=_callSuper(this,tr,[e,vd(),yd,n]),_this76.insertKeyPlaceholderText=_this76.genereteAPIKeyName("Gemini"),_this76.keyHelpUrl="https://aistudio.google.com/app/apikey",_this76.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",_this76.url="",_this76.permittedErrorPrefixes=["API_KEY_INVALID"],_typeof(n)===B){var o=n;o.model&&(_this76.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/".concat(o.model,":generateContent")),_this76.cleanConfig(o),_this76.completeConfig(o,(i=(s=e.directConnection)==null?void 0:s.gemini)==null?void 0:i.function_handler);}(_this76$maxMessages=_this76.maxMessages)!==null&&_this76$maxMessages!==void 0?_this76$maxMessages:_this76.maxMessages=-1;return _this76;}_inherits(tr,_R26);return _createClass(tr,[{key:"cleanConfig",value:function cleanConfig(e){delete e.model;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return tr.getContent(i);});return n.contents=s,this.systemMessage&&(n.systemInstruction={parts:[_defineProperty({},h,this.systemMessage)]}),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee160(e,t){var _this$messages8;var n,s;return _regenerator().w(function(_context160){while(1)switch(_context160.n){case 0:if(this.connectSettings){_context160.n=1;break;}throw new Error(Me);case 1:(_this$messages8=this.messages)!==null&&_this$messages8!==void 0?_this$messages8:this.messages=e;n=this.preprocessBody(this.rawBody,t),s=this.stream;s&&(_typeof(s)!==B||!s.simulation)||n.stream?(this.url="".concat(this.urlPrefix.replace(":generateContent",":streamGenerateContent"),"?alt=sse&key=").concat(this.key),U.request(this,n,e)):(this.url="".concat(this.urlPrefix,"?key=").concat(this.key),re.request(this,n,e));case 2:return _context160.a(2);}},_callee160,this);}));function callServiceAPI(_x297,_x298){return _callServiceAPI33.apply(this,arguments);}return callServiceAPI;}()// https://ai.google.dev/gemini-api/docs/function-calling?example=weather
203
+ },{key:"extractResultData",value:function(){var _extractResultData36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee161(e,t){var n,s,i,o,a,l,c,d;return _regenerator().w(function(_context161){while(1)switch(_context161.n){case 0:if(!e[f]){_context161.n=1;break;}throw e[f].message||"Gemini API Error";case 1:if(!((i=(s=(n=e.candidates)==null?void 0:n[0])==null?void 0:s.content)!=null&&i.parts)){_context161.n=3;break;}a=e.candidates[0].content.parts,l=a.find(function(p){return p.functionCall;});if(!(l!=null&&l.functionCall)){_context161.n=2;break;}return _context161.a(2,this.handleTools([l.functionCall],t));case 2:c=a.find(function(p){return p[h];}),d=a.find(function(p){var u;return((u=p.inlineData)==null?void 0:u.mimeType)==="image/png";});return _context161.a(2,_defineProperty(_defineProperty({},h,(c==null?void 0:c[h])||""),y,(o=d==null?void 0:d.inlineData)!=null&&o.data?[_defineProperty({},A,"data:image/png;base64,".concat(d.inlineData.data))]:[]));case 3:return _context161.a(2,_defineProperty({},h,""));}},_callee161,this);}));function extractResultData(_x299,_x300){return _extractResultData36.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee162(e,t){var n,s,_yield$this$callToolF4,i,o,a,l;return _regenerator().w(function(_context162){while(1)switch(_context162.n){case 0:if(!(!e||!t||!this.functionHandler)){_context162.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.args)};});_context162.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF4=_context162.v;i=_yield$this$callToolF4.responses;o=_yield$this$callToolF4.processedResponse;if(!o){_context162.n=3;break;}return _context162.a(2,o);case 3:a={parts:e.map(function(l){return{functionCall:{name:l.name,args:l.args}};}),role:"model"};if(!(n.contents.push(a),!i.find(function(_ref186){var l=_ref186.response;return typeof l!="string";})&&s.length===i.length)){_context162.n=4;break;}l={parts:i.map(function(c,d){return{functionResponse:{name:e[d].name,response:{result:c.response}}};}),role:H};return _context162.a(2,(n.contents.push(l),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context162.a(2);}},_callee162,this);}));function handleTools(_x301,_x302){return _handleTools3.apply(this,arguments);}return handleTools;}()}],[{key:"getContent",value:function getContent(e){var t=[];return e[h]&&e[h].trim().length>0&&t.push(_defineProperty({},h,e[h])),e[y]&&e[y].length>0&&e[y].forEach(function(n){if(n[A]&&n[A].includes("data:")){var _n$A$split=n[A].split(","),_n$A$split2=_slicedToArray(_n$A$split,2),s=_n$A$split2[0],i=_n$A$split2[1];t.push({inlineData:{mimeType:s.replace("data:","").replace(";base64",""),data:i}});}}),{parts:t,role:e.role===H?H:"model"};}}]);}(R);var _d=function _d(r){return _defineProperty(_defineProperty(_defineProperty({"x-api-key":r},D,W),"anthropic-version","2023-06-01"),"anthropic-dangerous-direct-browser-access","true");},Ed=function Ed(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},Sd=function Sd(){return ce("https://api.anthropic.com/v1/models",ae,Ed);};var zs=/*#__PURE__*/function(_R27){function zs(e){var _this77$maxMessages,_o$model10,_a$max_tokens2;var _this77;_classCallCheck(this,zs);var s,i,o,a;var n=JSON.parse(JSON.stringify(e.directConnection)).claude;_this77=_callSuper(this,zs,[e,Sd(),_d,n]),_this77.insertKeyPlaceholderText=_this77.genereteAPIKeyName("Claude"),_this77.keyHelpUrl="https://console.anthropic.com/settings/keys",_this77.url="https://api.anthropic.com/v1/messages",_this77.permittedErrorPrefixes=[be,We],_this77._streamToolCalls=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},T,"tool_use"),"id",""),"name",""),"input",""),_typeof(n)===B&&_this77.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.claude)==null?void 0:i.function_handler),(_this77$maxMessages=_this77.maxMessages)!==null&&_this77$maxMessages!==void 0?_this77$maxMessages:_this77.maxMessages=-1,(_o$model10=(o=_this77.rawBody).model)!==null&&_o$model10!==void 0?_o$model10:o.model="claude-sonnet-4-5-20250929",(_a$max_tokens2=(a=_this77.rawBody).max_tokens)!==null&&_a$max_tokens2!==void 0?_a$max_tokens2:a.max_tokens=4096;return _this77;}_inherits(zs,_R27);return _createClass(zs,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:zs.getTextWFilesContent(i,zs.getFileContent),role:R.getRoleViaUser(i.role)};});return n.messages=s,this.systemMessage&&(n.system=this.systemMessage),n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee163(e,t){var _this$messages9;return _regenerator().w(function(_context163){while(1)switch(_context163.n){case 0:(_this$messages9=this.messages)!==null&&_this$messages9!==void 0?_this$messages9:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context163.a(2);}},_callee163,this);}));function callServiceAPI(_x303,_x304){return _callServiceAPI34.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee164(e,t){var n,s,i,o,a;return _regenerator().w(function(_context164){while(1)switch(_context164.n){case 0:if(!e[f]){_context164.n=1;break;}throw e[f].message;case 1:if(!(e.content&&e.content.length>0)){_context164.n=3;break;}o=e.content.find(function(l){return l.type==="tool_use";});if(!o){_context164.n=2;break;}return _context164.a(2,this.handleTools([o],t));case 2:a=e.content.find(function(l){return l.type===h;});if(!a){_context164.n=3;break;}return _context164.a(2,_defineProperty({},h,a[h]));case 3:if(!(e.type==="content_block_delta"&&e.delta&&e.delta.type==="text_delta")){_context164.n=4;break;}return _context164.a(2,_defineProperty({},h,e.delta[h]||""));case 4:if(!(e.type==="content_block_start"&&((n=e.content_block)==null?void 0:n.type)==="tool_use")){_context164.n=5;break;}this._streamToolCalls=e.content_block,this._streamToolCalls.input="";_context164.n=7;break;case 5:if(!(e.type==="content_block_delta"&&((s=e.delta)==null?void 0:s.type)==="input_json_delta")){_context164.n=6;break;}this._streamToolCalls.input+=e.delta.partial_json||"";_context164.n=7;break;case 6:if(!(e.type==="message_delta"&&((i=e.delta)==null?void 0:i.stop_reason)==="tool_use")){_context164.n=7;break;}return _context164.a(2,(this._streamToolCalls.input=JSON.parse(this._streamToolCalls.input),this.handleTools([this._streamToolCalls],t)));case 7:return _context164.a(2,_defineProperty({},h,""));}},_callee164,this);}));function extractResultData(_x305,_x306){return _extractResultData37.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee165(e,t){var n,s,_yield$this$callToolF5,i,o,a,l;return _regenerator().w(function(_context165){while(1)switch(_context165.n){case 0:if(!(!e||!t||!this.functionHandler)){_context165.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.input)};});_context165.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF5=_context165.v;i=_yield$this$callToolF5.responses;o=_yield$this$callToolF5.processedResponse;if(!o){_context165.n=3;break;}return _context165.a(2,o);case 3:a=e.map(function(l){return _defineProperty(_defineProperty(_defineProperty(_defineProperty({},T,"tool_use"),"id",l.id),"name",l.name),"input",l.input);});if(!(n.messages.push({role:"assistant",content:a}),!i.find(function(_ref192){var l=_ref192.response;return typeof l!="string";})&&s.length===i.length)){_context165.n=4;break;}l=i.map(function(c,d){return _defineProperty(_defineProperty(_defineProperty({},T,"tool_result"),"tool_use_id",e[d].id),"content",c.response);});return _context165.a(2,(n.messages.push({role:H,content:l}),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context165.a(2);}},_callee165,this);}));function handleTools(_x307,_x308){return _handleTools4.apply(this,arguments);}return handleTools;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){var n,s,i;if(t.type===q){var o=(n=t[A])==null?void 0:n.split(",")[1],a=((i=(s=t[A])==null?void 0:s.match(/data:([^;]+)/))==null?void 0:i[1])||"image/jpeg";return _defineProperty(_defineProperty({},T,q),"source",_defineProperty(_defineProperty(_defineProperty({},T,"base64"),"media_type",a),"data",o||""));}return _defineProperty(_defineProperty({},T,h),h,"[Unsupported ".concat(ee," type: ").concat(t.type,"]"));});}}]);}(R);var xd=function xd(){return{};},Ad=function Ad(){},Cd=function Cd(){return ce("",ae,Ad);};var nr=/*#__PURE__*/function(_R28){function nr(e){var _this78$maxMessages,_o$model11,_a$stream2;var _this78;_classCallCheck(this,nr);var s,i,o,a;var t=JSON.parse(JSON.stringify(e.directConnection));_this78=_callSuper(this,nr,[e,Cd(),xd,{key:"placeholder"}]),_this78.insertKeyPlaceholderText="",_this78.keyHelpUrl="",_this78.validateKeyProperty=!1,_this78.url="http://localhost:11434/api/chat",_this78.permittedErrorPrefixes=["Error"];var n=t.ollama;_typeof(n)===B&&_this78.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.ollama)==null?void 0:i.function_handler),(_this78$maxMessages=_this78.maxMessages)!==null&&_this78$maxMessages!==void 0?_this78$maxMessages:_this78.maxMessages=-1,(_o$model11=(o=_this78.rawBody).model)!==null&&_o$model11!==void 0?_o$model11:o.model="llama3.2",(_a$stream2=(a=_this78.rawBody).stream)!==null&&_a$stream2!==void 0?_a$stream2:a.stream=!1;return _this78;}_inherits(nr,_R28);return _createClass(nr,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){var o={content:i[h]||"",role:R.getRoleViaUser(i.role)};if(i[y]&&i[y].length>0){var a=nr.getImageData(i[y]);a.length>0&&(o[J]=a);}return o;});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee166(e,t){var _this$messages0;return _regenerator().w(function(_context166){while(1)switch(_context166.n){case 0:(_this$messages0=this.messages)!==null&&_this$messages0!==void 0?_this$messages0:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context166.a(2);}},_callee166,this);}));function callServiceAPI(_x309,_x310){return _callServiceAPI35.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee167(e,t){var n,s,i;return _regenerator().w(function(_context167){while(1)switch(_context167.n){case 0:if(!e[f]){_context167.n=1;break;}throw e[f].message;case 1:if(!e[h]){_context167.n=2;break;}i=JSON.parse(e[h]);return _context167.a(2,(n=i.message)!=null&&n.tool_calls?this.handleTools({tool_calls:i.message.tool_calls},t):_defineProperty({},h,((s=i.message)==null?void 0:s.content)||""));case 2:return _context167.a(2,e.message?e.message.tool_calls?this.handleTools({tool_calls:e.message.tool_calls},t):_defineProperty({},h,e.message.content||""):_defineProperty({},h,""));}},_callee167,this);}));function extractResultData(_x311,_x312){return _extractResultData38.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee168(e,t){var n,s,_yield$this$callToolF6,i,o;return _regenerator().w(function(_context168){while(1)switch(_context168.n){case 0:if(!(!e.tool_calls||!t||!this.functionHandler)){_context168.n=1;break;}throw Error(kt);case 1:n=JSON.parse(JSON.stringify(t));s=e.tool_calls.map(function(a){return{name:a["function"].name,arguments:JSON.stringify(a["function"].arguments)};});_context168.n=2;return this.callToolFunction(this.functionHandler,s);case 2:_yield$this$callToolF6=_context168.v;i=_yield$this$callToolF6.responses;o=_yield$this$callToolF6.processedResponse;if(!o){_context168.n=3;break;}return _context168.a(2,o);case 3:if(!(n.messages.push({tool_calls:e.tool_calls,role:ot,content:""}),!i.find(function(_ref199){var a=_ref199.response;return typeof a!="string";})&&s.length===i.length)){_context168.n=4;break;}return _context168.a(2,(i.forEach(function(a,l){var d;var c=(d=e.tool_calls)==null?void 0:d[l];n==null||n.messages.push({role:"tool",tool_name:c==null?void 0:c["function"].name,content:a.response});}),this.makeAnotherRequest(n,this.messages)));case 4:throw Error(Jt);case 5:return _context168.a(2);}},_callee168,this);}));function handleTools(_x313,_x314){return _handleTools5.apply(this,arguments);}return handleTools;}()}],[{key:"getImageData",value:function getImageData(e){return e.filter(function(t){return t.type===q;}).map(function(t){var s;return((s=t[A])==null?void 0:s.split(",")[1])||"";}).filter(function(t){return t.length>0;});}}]);}(R);var $o=function $o(r){return _defineProperty({Authorization:"".concat(ye).concat(r)},D,W);},wd=function wd(r,e,t,n){var s=r;s[f]?s[f].type===be||s[f].type===We?n(le):n(He):t(e);},Go=function Go(){return ce("https://api.x.ai/v1/models",ae,wd);},Ys=/*#__PURE__*/function(_R29){function Ys(e){var _o$model12;var _this79;_classCallCheck(this,Ys);var i,o;var t=e.directConnection,n=t==null?void 0:t.x;_this79=_callSuper(this,Ys,[e,Go(),$o,n]),_this79.insertKeyPlaceholderText=_this79.genereteAPIKeyName("X"),_this79.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this79.url=Ys.IMAGE_GENERATION_URL,_this79.permittedErrorPrefixes=[We,be];var s=(i=t==null?void 0:t.x)==null?void 0:i[J];_typeof(s)===B&&Object.assign(_this79.rawBody,s),(_o$model12=(o=_this79.rawBody).model)!==null&&_o$model12!==void 0?_o$model12:o.model="grok-2-image";return _this79;}_inherits(Ys,_R29);return _createClass(Ys,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=t[t.length-1][h],s=JSON.parse(JSON.stringify(e));return n&&n!==""&&(s.prompt=n),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee169(e,t){return _regenerator().w(function(_context169){while(1)switch(_context169.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context169.a(2);}},_callee169,this);}));function callServiceAPI(_x315,_x316){return _callServiceAPI36.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee170(e){var t;return _regenerator().w(function(_context170){while(1)switch(_context170.n){case 0:if(!e[f]){_context170.n=1;break;}throw e[f].message;case 1:t=e.data.map(function(n){return n.url?_defineProperty(_defineProperty({},A,n.url),T,q):_defineProperty(_defineProperty({},A,"".concat(bn).concat(n.b64_json)),T,q);});return _context170.a(2,_defineProperty({},y,t));}},_callee170);}));function extractResultData(_x317){return _extractResultData39.apply(this,arguments);}return extractResultData;}()}]);}(R);Ys.IMAGE_GENERATION_URL="https://api.x.ai/v1/images/generations";var Li=Ys;var Td=function Td(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},Rd=function Rd(r,e,t,n){var s=r;s[f]?s[f].type===We?n(le):n(He):t(e);},Id=function Id(){return ce("https://dashscope-intl.aliyuncs.com/compatible-mode/v1/models",ae,Rd);};var sr=/*#__PURE__*/function(_R30){function sr(e){var _this80$maxMessages,_o$model13;var _this80;_classCallCheck(this,sr);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).qwen;_this80=_callSuper(this,sr,[e,Id(),Td,n]),_this80.insertKeyPlaceholderText=_this80.genereteAPIKeyName("Qwen"),_this80.keyHelpUrl="https://www.alibabacloud.com/help/en/model-studio/get-api-key",_this80.url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions",_this80.permittedErrorPrefixes=["No static","The model",fs],_typeof(n)===B&&_this80.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.qwen)==null?void 0:i.function_handler),(_this80$maxMessages=_this80.maxMessages)!==null&&_this80$maxMessages!==void 0?_this80$maxMessages:_this80.maxMessages=-1,(_o$model13=(o=_this80.rawBody).model)!==null&&_o$model13!==void 0?_o$model13:o.model="qwen-plus";return _this80;}_inherits(sr,_R30);return _createClass(sr,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:sr.getTextWImagesContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee171(e,t){var _this$messages1;return _regenerator().w(function(_context171){while(1)switch(_context171.n){case 0:(_this$messages1=this.messages)!==null&&_this$messages1!==void 0?_this$messages1:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context171.a(2);}},_callee171,this);}));function callServiceAPI(_x318,_x319){return _callServiceAPI37.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData40=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee172(e,t){var _n11;return _regenerator().w(function(_context172){while(1)switch(_context172.n){case 0:if(!e[f]){_context172.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context172.n=3;break;}_n11=e.choices[0];if(!_n11.delta){_context172.n=2;break;}return _context172.a(2,this.extractStreamResult(_n11,t));case 2:if(!_n11.message){_context172.n=3;break;}return _context172.a(2,_n11.message.tool_calls?this.handleToolsGeneric({tool_calls:_n11.message.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n11.message.content||""));case 3:return _context172.a(2,_defineProperty({},h,""));}},_callee172,this);}));function extractResultData(_x320,_x321){return _extractResultData40.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee173(e,t){return _regenerator().w(function(_context173){while(1)switch(_context173.n){case 0:return _context173.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee173,this);}));function extractStreamResult(_x322,_x323){return _extractStreamResult6.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var Md=function Md(r){return _defineProperty(_defineProperty({},oe,"".concat(ye).concat(r)),D,W);},kd=function kd(r,e,t,n){var s=r;s[f]?s[f].type===be?n(le):n(He):t(e);},Od=function Od(){return ce("https://api.moonshot.ai/v1/models",ae,kd);};var ir=/*#__PURE__*/function(_R31){function ir(e){var _this81$maxMessages,_o$model14;var _this81;_classCallCheck(this,ir);var s,i,o;var n=JSON.parse(JSON.stringify(e.directConnection)).kimi;_this81=_callSuper(this,ir,[e,Od(),Md,n]),_this81.insertKeyPlaceholderText=_this81.genereteAPIKeyName("Kimi"),_this81.keyHelpUrl="https://platform.moonshot.ai/console/api-keys",_this81.url="https://api.moonshot.ai/v1/chat/completions",_this81.permittedErrorPrefixes=[Ot,"Not found"],_typeof(n)===B&&_this81.completeConfig(n,(i=(s=e.directConnection)==null?void 0:s.kimi)==null?void 0:i.function_handler),(_this81$maxMessages=_this81.maxMessages)!==null&&_this81$maxMessages!==void 0?_this81$maxMessages:_this81.maxMessages=-1,(_o$model14=(o=_this81.rawBody).model)!==null&&_o$model14!==void 0?_o$model14:o.model="moonshot-v1-8k";return _this81;}_inherits(ir,_R31);return _createClass(ir,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:ir.getTextWImagesContent(i),role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee174(e,t){var _this$messages10;return _regenerator().w(function(_context174){while(1)switch(_context174.n){case 0:(_this$messages10=this.messages)!==null&&_this$messages10!==void 0?_this$messages10:this.messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context174.a(2);}},_callee174,this);}));function callServiceAPI(_x324,_x325){return _callServiceAPI38.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData41=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee175(e,t){var _n12;return _regenerator().w(function(_context175){while(1)switch(_context175.n){case 0:if(!e[f]){_context175.n=1;break;}throw e[f].message;case 1:if(!(e.choices&&e.choices.length>0)){_context175.n=3;break;}_n12=e.choices[0];if(!_n12.delta){_context175.n=2;break;}return _context175.a(2,this.extractStreamResult(_n12,t));case 2:if(!_n12.message){_context175.n=3;break;}return _context175.a(2,_n12.message.tool_calls?this.handleToolsGeneric({tool_calls:_n12.message.tool_calls},this.functionHandler,this.messages,t):_defineProperty({},h,_n12.message.content||""));case 3:return _context175.a(2,_defineProperty({},h,""));}},_callee175,this);}));function extractResultData(_x326,_x327){return _extractResultData41.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee176(e,t){return _regenerator().w(function(_context176){while(1)switch(_context176.n){case 0:return _context176.a(2,this.extractStreamResultWToolsGeneric(this,e,this.functionHandler,t));}},_callee176,this);}));function extractStreamResult(_x328,_x329){return _extractStreamResult7.apply(this,arguments);}return extractStreamResult;}()}]);}(R);var Nd=/*#__PURE__*/function(_R32){function Nd(e){var _this82$maxMessages,_o$model15;var _this82;_classCallCheck(this,Nd);var i,o;var t=JSON.parse(JSON.stringify(e.directConnection)),n=t.x;_this82=_callSuper(this,Nd,[e,Go(),$o,n]),_this82.insertKeyPlaceholderText=_this82.genereteAPIKeyName("X"),_this82.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this82.url="https://api.x.ai/v1/chat/completions",_this82.permittedErrorPrefixes=[We,be];var s=(i=t.x)==null?void 0:i.chat;_typeof(s)===B&&_this82.completeConfig(s),(_this82$maxMessages=_this82.maxMessages)!==null&&_this82$maxMessages!==void 0?_this82$maxMessages:_this82.maxMessages=-1,(_o$model15=(o=_this82.rawBody).model)!==null&&_o$model15!==void 0?_o$model15:o.model="grok-3-latest";return _this82;}_inherits(Nd,_R32);return _createClass(Nd,[{key:"preprocessBody",value:function preprocessBody(e,t){var n=JSON.parse(JSON.stringify(e)),s=this.processMessages(t).map(function(i){return{content:i[h]||"",role:R.getRoleViaUser(i.role)};});return this.addSystemMessage(s),n.messages=s,n;}},{key:"callServiceAPI",value:function(){var _callServiceAPI39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee177(e,t){return _regenerator().w(function(_context177){while(1)switch(_context177.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context177.a(2);}},_callee177,this);}));function callServiceAPI(_x330,_x331){return _callServiceAPI39.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData42=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee178(e){var t,n,s,i,o;return _regenerator().w(function(_context178){while(1)switch(_context178.n){case 0:if(!e[f]){_context178.n=1;break;}throw e[f].message;case 1:if(!(e.object==="chat.completion.chunk")){_context178.n=2;break;}o=(t=e.choices)==null?void 0:t[0];return _context178.a(2,(n=o==null?void 0:o.delta)!=null&&n.content?_defineProperty({},h,o.delta.content):_defineProperty({},h,""));case 2:return _context178.a(2,e.object==="chat.completion"&&(i=(s=e.choices)==null?void 0:s[0])!=null&&i.message?_defineProperty({},h,e.choices[0].message.content||""):_defineProperty({},h,""));}},_callee178);}));function extractResultData(_x332){return _extractResultData42.apply(this,arguments);}return extractResultData;}()}]);}(R);var Pd=/*#__PURE__*/function(){function Pd(){_classCallCheck(this,Pd);}return _createClass(Pd,null,[{key:"create",value:// this should only be called when no _activeService is set or is demo as otherwise we don't want to reconnect
204
+ function create(e){var t=e.directConnection,n=e.connect,s=e.demo,i=e.webModel;if(i)return new ds(e);if(t){if(t.openAI)return t.openAI[J]?new Pi(e):t.openAI.speechToText?new Mi(e):t.openAI.textToSpeech?new Ii(e):t.openAI.assistant?new Xi(e):t.openAI.realtime?new Ri(e):t.openAI.completions?new js(e):new qs(e);if(t.assemblyAI)return new Zi(e);if(t.cohere)return new Gs(e);if(t.huggingFace)return t.huggingFace.textGeneration?new fc(e):t.huggingFace.summarization?new gc(e):t.huggingFace.translation?new bc(e):t.huggingFace.fillMask?new vc(e):t.huggingFace.questionAnswer?new mc(e):t.huggingFace.audioSpeechRecognition?new pc(e):t.huggingFace.audioClassification?new dc(e):t.huggingFace.imageClassification?new hc(e):new yc(e);if(t.azure){if(t.azure.openAI){if(t.azure.openAI.chat)return new Yi(e);if(t.azure.openAI.assistant)return new wi(e);}if(t.azure.speechToText)return new Ni(e);if(t.azure.textToSpeech)return new Oi(e);if(t.azure.summarization)return new ki(e);if(t.azure.translation)return new Hc(e);}if(t.stabilityAI)return t.stabilityAI.imageToImage?new Ls(e):t.stabilityAI.imageToImageUpscale?new Ns(e):t.stabilityAI.imageToImageMasking?new Ps(e):new Bs(e);if(t.mistral)return new Qi(e);if(t.gemini)return new tr(e);if(t.claude)return new zs(e);if(t.deepSeek)return new od(e);if(t.miniMax)return new dd(e);if(t.openRouter)return new Zn(e);if(t.kimi)return new ir(e);if(t.x)return t.x[J]?new Li(e):new Nd(e);if(t.qwen)return new sr(e);if(t.together)return t.together[J]?new Gc(e):t.together.textToSpeech?new xc(e):new zc(e);if(t.bigModel)return t.bigModel[J]?new jc(e):t.bigModel.textToSpeech?new Ec(e):new $s(e);if(t.groq)return t.groq.textToSpeech?new $c(e):new er(e);if(t.perplexity)return new Yc(e);if(t.ollama)return new nr(e);if(t.openWebUI)return new nd(e);}return n&&Object.keys(n).length>0&&!s?new Zt(e):new Zt(e,void 0,s||!0);}}]);}();var ur=/*#__PURE__*/_createClass(function ur(){_classCallCheck(this,ur);});ur.attibutes={string:function string(e){return e;},number:function number(e){return parseFloat(e);},"boolean":function boolean(e){return e==="true";},object:function object(e){return JSON.parse(e);},array:function array(e){return JSON.parse(e);},"function":function _function(e){return new Function("return ".concat(e))();}};var Bi=ur;function k(r){return function(e,t){Object.defineProperty(e,t,{});var n=e.constructor,s=t.toLocaleLowerCase();n._attributes_[s]=Bi.attibutes[r],n._attributeToProperty_[s]=t;};}var Ld="deep-chat-downwards-mode",Bd="deep-chat-upwards-mode",An="submit-button",Ss="loading-button",Cn="disabled-button",Fr="text-input-container-start-adjustment",Ur="text-input-container-end-adjustment",Hr="text-input-container-start-small-adjustment",jr="text-input-container-end-small-adjustment";var rr=/*#__PURE__*/function(){function rr(e){_classCallCheck(this,rr);this._isDisplayed=!1,this._elementRef=this.createIntroPanelWithChild(e),this._isDisplayed=!0;}return _createClass(rr,[{key:"createIntroPanelWithChild",value:function createIntroPanelWithChild(e){var t=rr.createIntroPanel();return e[_].display==="none"&&(e[_].display="block"),t.appendChild(e),t;}},{key:"hide",value:function hide(){this._isDisplayed&&(this._elementRef[_].display="none",this._isDisplayed=!1);}},{key:"display",value:function display(){this._isDisplayed||(this._elementRef[_].display="",this._isDisplayed=!0);}}],[{key:"createIntroPanel",value:function createIntroPanel(){var e=S();return e[m].add("intro-panel"),Object.assign(e[_]),e;}}]);}();var Dd="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n\t viewBox=\"50 30 420 450\" xml:space=\"preserve\">\n<g filter=\"brightness(0) saturate(100%) invert(16%) sepia(0%) saturate(1942%) hue-rotate(215deg) brightness(99%) contrast(93%)\">\n\t<g>\n\t\t<path d=\"M447.933,103.629c-0.034-3.076-1.224-6.09-3.485-8.352L352.683,3.511c-0.004-0.004-0.007-0.005-0.011-0.008\n\t\t\tC350.505,1.338,347.511,0,344.206,0H89.278C75.361,0,64.04,11.32,64.04,25.237v461.525c0,13.916,11.32,25.237,25.237,25.237\n\t\t\th333.444c13.916,0,25.237-11.32,25.237-25.237V103.753C447.96,103.709,447.937,103.672,447.933,103.629z M356.194,40.931\n\t\t\tl50.834,50.834h-49.572c-0.695,0-1.262-0.567-1.262-1.262V40.931z M423.983,486.763c0,0.695-0.566,1.261-1.261,1.261H89.278\n\t\t\tc-0.695,0-1.261-0.566-1.261-1.261V25.237c0-0.695,0.566-1.261,1.261-1.261h242.94v66.527c0,13.916,11.322,25.239,25.239,25.239\n\t\t\th66.527V486.763z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,164.014H149.912c-6.62,0-11.988,5.367-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,169.381,368.707,164.014,362.088,164.014z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,236.353H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,241.721,368.707,236.353,362.088,236.353z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,308.691H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C374.076,314.06,368.707,308.691,362.088,308.691z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M256,381.031H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988H256\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C267.988,386.398,262.62,381.031,256,381.031z\"/>\n\t</g>\n</g>\n</svg>",_e=/*#__PURE__*/function(){function _e(){_classCallCheck(this,_e);}return _createClass(_e,null,[{key:"createImage",value:function createImage(e,t){var n=new Image();return n[A]=e[A],t&&pe.scrollDownOnImageLoad(n[A],t),pe.processContent(q,n,n[A],e.name);}// WORK - image still does not scroll down when loaded
205
205
  },{key:"createImageMessage",value:function createImageMessage(e,t,n,s){var i=e.createNewMessageElement("",n),o=s?e.scrollToFirstElement.bind(e,n,s):void 0,a=_e.createImage(t,o);return i.bubbleElement.appendChild(a),i.bubbleElement[m].add(_e.IMAGE_BUBBLE_CLASS),{type:q,elements:i};}},{key:"createAudioElement",value:function createAudioElement(e,t){var n=S(L);return n[A]=e[A],n[m].add("audio-player"),n.controls=!0,Oe.IS_SAFARI&&(n[m].add("audio-player-safari"),n[m].add(t===H?"audio-player-safari-end":"audio-player-safari-start")),n;}},{key:"autoPlayAudio",value:function autoPlayAudio(e){e.addEventListener("loadeddata",function(){e.play()["catch"](function(t){console.warn("Auto-play failed:",t);});});}},{key:"createNewAudioMessage",value:function createNewAudioMessage(e,t,n,s){var i=_e.createAudioElement(t,n),o=e.createMessageElementsOnOrientation("",n,s);return o.bubbleElement.appendChild(i),o.bubbleElement[m].add(_e.AUDIO_BUBBLE_CLASS),{type:L,elements:o,audioElement:i};}},{key:"createAnyFile",value:function createAnyFile(e){var t=S();t[m].add("any-file-message-contents");var n=S();n[m].add("any-file-message-icon-container");var s=_t.createSVGElement(Dd);s[m].add("any-file-message-icon"),n.appendChild(s);var i=S();return i[m].add("any-file-message-text"),i.textContent=e.name||ee,t.appendChild(n),t.appendChild(i),pe.processContent(Vt,t,e[A],i.textContent);}},{key:"createNewAnyFileMessage",value:function createNewAnyFileMessage(e,t,n,s){var i=e.createMessageElementsOnOrientation("",n,s),o=_e.createAnyFile(t);return i.bubbleElement[m].add(_e.ANY_FILE_BUBBLE_CLASS),i.bubbleElement.appendChild(o),{type:ee,elements:i};}},{key:"createMessages",value:function createMessages(e,t,n,s){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;return t.map(function(o,a){var l;if(o.ref&&(o=pe.removeFileRef(o)),pe.isAudioFile(o)){var c=_e.createNewAudioMessage(e,o,n,i),d=(l=e.textToSpeech)==null?void 0:l.audio;return d&&(d.autoPlay&&_e.autoPlayAudio(c.audioElement),typeof d.displayAudio=="boolean"&&!d.displayAudio)?void 0:c;}return pe.isImageFile(o)?_e.createImageMessage(e,o,n,!i&&s&&a===0):_e.createNewAnyFileMessage(e,o,n,i);}).filter(function(o){return o!==void 0;});}// no overwrite previous message logic as it is complex to track which files are to be overwritten
206
206
  },{key:"addMessages",value:function addMessages(e,t,n,s,i){_e.createMessages(e,t,n,s,i).filter(function(a){return a!==void 0;}).forEach(function(_ref214){var a=_ref214.type,l=_ref214.elements;pe.addMessage(e,l,a,n,i);});}}]);}();_e.IMAGE_BUBBLE_CLASS="image-message",_e.AUDIO_BUBBLE_CLASS="audio-message",_e.ANY_FILE_BUBBLE_CLASS="any-file-message";var Vs=_e;var $e=/*#__PURE__*/function(){function $e(){_classCallCheck(this,$e);}return _createClass($e,null,[{key:"removeElements",value:function removeElements(e,t){if(!t)return;var n=e.findIndex(function(s){return s===t;});e.splice(n,1),t==null||t.outerContainer.remove();}},{key:"removeFilesMessages",value:function removeFilesMessages(e,t){var n;(n=t[1][y])==null||n.forEach(function(s){$e.removeElements(e.messageElementRefs,s);}),delete t[0][y],delete t[1][y];}},{key:"removeTextHTMLMessage",value:function removeTextHTMLMessage(e,t,n){var s=t[1][n];$e.removeElements(e.messageElementRefs,s),delete t[0][n],delete t[1][n];}},{key:"updateHTMLMessage",value:function updateHTMLMessage(e,t,n){var s,i,o;if(t[1][M])lt.overwriteElements(e,n,t[1][M]);else{var a=lt.create(e,n,t[0].role),l=((i=t[1][y])==null?void 0:i[((s=t[1][y])==null?void 0:s.length)-1])||t[1][h],c=l.outerContainer.nextSibling;(o=c==null?void 0:c.parentElement)==null||o.insertBefore(a.outerContainer,c),e.messageElementRefs.splice(e.messageElementRefs.length-1,1);var d=e.messageElementRefs.findIndex(function(p){return p===l;});e.messageElementRefs.splice(d+1,0,a),t[1][M]=a;}t[0][M]=n;}// finds beforeElement, creates new elements, remove old and adds new ones
207
207
  },{key:"updateFileMessages",value:function updateFileMessages(e,t,n){var p,u;var s=t[0].role,i=Vs.createMessages(e,n,s,!1),o=t[1][M],a=((u=t[1][y])==null?void 0:u[((p=t[1][y])==null?void 0:p.length)-1])||t[1][h],l=o||a;var c=e.messageElementRefs.findIndex(function(g){return g===l;});a&&(c+=1);var d=(o==null?void 0:o.outerContainer)||(a==null?void 0:a.outerContainer.nextSibling);i.forEach(function(_ref215,v){var g=_ref215.type,b=_ref215.elements;var E;pe.setElementProps(e,b,g,s),(E=d.parentElement)==null||E.insertBefore(b.outerContainer,d),e.messageElementRefs.splice(e.messageElementRefs.length-1,1),e.messageElementRefs.splice(c+v,0,b);}),$e.removeFilesMessages(e,t),t[1][y]=i.map(function(_ref216){var g=_ref216.elements;return g;}),t[0][y]=n;}},{key:"updateTextMessage",value:function updateTextMessage(e,t,n){var s,i;if(t[1][h])e.renderText(t[1][h].bubbleElement,n,t[0].role);else{var o=e.createElements(n,t[0].role),a=((s=t[1][y])==null?void 0:s[0])||t[1][M];(i=a.outerContainer.parentElement)==null||i.insertBefore(o.outerContainer,a.outerContainer);var l=e.messageElementRefs.findIndex(function(c){return c===a;});e.messageElementRefs.splice(l,0,o),t[1][h]=o;}t[0][h]=n;}},{key:"isElementActive",value:function isElementActive(e){var t,n;return Ve.isActiveElement((t=e[h])==null?void 0:t.bubbleElement[m])||Ve.isActiveElement((n=e[M])==null?void 0:n.bubbleElement[m]);}// note that overwrite and 'deep-chat-temporary-message' are used to remove a message
@@ -220,10 +220,10 @@ function se(e,t,n,s){var _this88;_classCallCheck(this,se);var l,c,d,p,u,g;var i=
220
220
  },{key:"setDropupItem",value:function setDropupItem(e,t){this._menu=e,this.elementRef=t,this._originalElementRef=t.cloneNode(!0),this.changeState(this._state,!0);}},{key:"genStateInnerElements",value:function genStateInnerElements(e,t,n,s){var l,c,d,p;var i=this.createInnerElements(e,t,s);var o=(c=(l=s==null?void 0:s[t])==null?void 0:l.svg)==null?void 0:c.content,a=(p=(d=s==null?void 0:s[t])==null?void 0:d[h])==null?void 0:p.content;if(o===void 0||a===void 0){var _Xn$parseSVGTextEleme4=Xn.parseSVGTextElements(n),u=_Xn$parseSVGTextEleme4.svg,g=_Xn$parseSVGTextEleme4[h],_Xn$parseSVGTextEleme5=Xn.parseSVGTextElements(i),b=_Xn$parseSVGTextEleme5.svg,v=_Xn$parseSVGTextEleme5[h],E=[];se.addToInnerElements(E,o,u,b),se.addToInnerElements(E,a,g,v),i=E;}return i;}}],[{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button",se.BUTTON_CLASS),e;}},{key:"addToInnerElements",value:function addToInnerElements(e,t,n,s){t===void 0&&n?e.push(n.cloneNode(!0)):s&&e.push(s);}},{key:"add",value:function add(e,t){var n=e.customButtons,s=e.focusInput,i=e.dropupStyles;n==null||n.forEach(function(o,a){var l={button:new se(o,a+1,s,i==null?void 0:i.menu)};t["".concat(se.INDICATOR_PREFIX).concat(a+1)]=l;});}}]);}(tn);se.INDICATOR_PREFIX="custom",se.BUTTON_CLASS="custom-button",se.DISABLED_CONTAINER_CLASS="custom-button-container-disabled",se.DEFAULT_CONTAINER_CLASS="custom-button-container-default",se.ACTIVE_CONTAINER_CLASS="custom-button-container-active";var zt=se;var Hd="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M16 0c-8.836 0-16 7.163-16 16s7.163 16 16 16c8.837 0 16-7.163 16-16s-7.163-16-16-16zM16 30.032c-7.72 0-14-6.312-14-14.032s6.28-14 14-14 14 6.28 14 14-6.28 14.032-14 14.032zM23 15h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1z\"></path>\n</svg>";var hs=/*#__PURE__*/function(){function hs(){_classCallCheck(this,hs);}return _createClass(hs,null,[{key:"focusItemWhenOnEdge",value:function focusItemWhenOnEdge(e,t){var n=e.elementRef,s=t?n.children[0]:n.children[n.children.length-1];hs.focusSiblingItem(e,s,t,!0);}// isEdgeItem means is it a start or end item
221
221
  },{key:"focusSiblingItem",value:function focusSiblingItem(e,t,n){var s=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var i=s?t:t[n?"nextSibling":"previousSibling"];i?(t.dispatchEvent(new MouseEvent("mouseleave")),i.dispatchEvent(new MouseEvent("mouseenter")),i.focus()):(t.dispatchEvent(new MouseEvent("mouseleave")),hs.focusItemWhenOnEdge(e,n));}}]);}();var or=/*#__PURE__*/function(){function or(e,t){var _this91=this;_classCallCheck(this,or);var n;this._isOpen=!0,this._styles=t,this.elementRef=or.createElement((n=this._styles)==null?void 0:n.container),this.close(),setTimeout(function(){return _this91.addWindowEvents(e);});}return _createClass(or,[{key:"open",value:function open(){this.elementRef[_].display="block",this._isOpen=!0;}},{key:"close",value:function close(){this._isOpen&&(this.elementRef[_].display="none",this._isOpen=!1);}},{key:"toggle",value:function toggle(){this._isOpen?this.close():this.open();}},{key:"addItem",value:function addItem(e){var t=Qe.createItem(this,e,this._styles);this.elementRef.appendChild(t);}// prettier-ignore
222
222
  },{key:"addWindowEvents",value:function addWindowEvents(e){this.clickEvent=this.windowClick.bind(this,e),window.addEventListener(z,this.clickEvent),this.keyDownEvent=this.windowKeyDown.bind(this,e),window.addEventListener("keydown",this.keyDownEvent);}},{key:"windowClick",value:function windowClick(e,t){var n;!e.isConnected&&this.clickEvent?window.removeEventListener(z,this.clickEvent):e.parentElement!==((n=t.target.shadowRoot)==null?void 0:n.children[0])&&this.close();}// prettier-ignore
223
- },{key:"windowKeyDown",value:function windowKeyDown(e,t){var n,s,i;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===de.ESCAPE?(this.close(),(n=this.highlightedItem)==null||n.dispatchEvent(new MouseEvent("mouseleave"))):t.key===de.ENTER?((s=this.highlightedItem)==null||s[z](),(i=this.highlightedItem)==null||i.dispatchEvent(new MouseEvent("mouseleave"))):t.key===de.ARROW_DOWN?hs.focusSiblingItem(this,this.highlightedItem||this.elementRef.children[this.elementRef.children.length-1],!0):t.key===de.ARROW_UP&&hs.focusSiblingItem(this,this.highlightedItem||this.elementRef.children[0],!1));}}],[{key:"createElement",value:function createElement(e){var t=S();return t.id=ze,Object.assign(t[_],e),t;}}]);}();var jt=/*#__PURE__*/function(_tn3){function jt(e,t){var _this92;_classCallCheck(this,jt);var i,o;var n=nt.tryCreateConfig("Options",(i=t==null?void 0:t.button)==null?void 0:i.tooltip);_this92=_callSuper(this,jt,[jt.createButtonElement(),Hd,void 0,n,{styles:(o=t==null?void 0:t.button)==null?void 0:o.styles}]);var s=_this92.createInnerElementsForStates(_this92.customStyles);_this92._menu=new or(e,t==null?void 0:t.menu),_this92.addClickEvent(),_this92.buttonContainer=jt.createButtonContainer(),_this92.changeElementsByState(s.styles),_this92.buttonContainer.appendChild(_this92.elementRef),_this92.elementRef[m].add(jt.BUTTON_ICON_CLASS),_this92.buttonContainer.appendChild(_this92._menu.elementRef),_this92.reapplyStateStyle("styles"),_this92.addContainerEvents(e);return _this92;}_inherits(jt,_tn3);return _createClass(jt,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){return{styles:this.createInnerElements("dropup-icon","styles",e)};}},{key:"addClickEvent",value:function addClickEvent(){var _this93=this;this.elementRef.onclick=this._menu.toggle.bind(this._menu),this.elementRef.onkeydown=function(e){e.key===de.ENTER&&setTimeout(function(){_this93._menu.toggle();var t=_this93._menu.elementRef.children[0];t.focus(),t.dispatchEvent(new MouseEvent("mouseenter"));});};}},{key:"addItem",value:function addItem(e){this._menu.addItem(e);}},{key:"addContainerEvents",value:function addContainerEvents(e){var _this94=this;e.addEventListener(z,function(t){var n=t.target[m];!n.contains(jt.BUTTON_ICON_CLASS)&&!n.contains(zt.DISABLED_CONTAINER_CLASS)&&_this94._menu.close();});}}],[{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button"),e;}},{key:"createButtonContainer",value:function createButtonContainer(){var e=S();return e.id="dropup-container",e;}},{key:"getPosition",value:function getPosition(e,t){var n,s;return(n=t==null?void 0:t.button)!=null&&n.position?ne.processPosition((s=t==null?void 0:t.button)==null?void 0:s.position):e[Ae].length>0&&e[ue].length===0?ue:Ae;}}]);}(tn);jt.BUTTON_ICON_CLASS="dropup-button";var Js=jt;var Ce=/*#__PURE__*/function(){function Ce(){_classCallCheck(this,Ce);}return _createClass(Ce,null,[{key:"addToDropup",value:// prettier-ignore
223
+ },{key:"windowKeyDown",value:function windowKeyDown(e,t){var n,s,i;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===de.ESCAPE?(this.close(),(n=this.highlightedItem)==null||n.dispatchEvent(new MouseEvent("mouseleave"))):t.key===de.ENTER?((s=this.highlightedItem)==null||s[z](),(i=this.highlightedItem)==null||i.dispatchEvent(new MouseEvent("mouseleave"))):t.key===de.ARROW_DOWN?hs.focusSiblingItem(this,this.highlightedItem||this.elementRef.children[this.elementRef.children.length-1],!0):t.key===de.ARROW_UP&&hs.focusSiblingItem(this,this.highlightedItem||this.elementRef.children[0],!1));}}],[{key:"createElement",value:function createElement(e){var t=S();return t.id=ze,Object.assign(t[_],e),t;}}]);}();var jt=/*#__PURE__*/function(_tn3){function jt(e,t){var _this92;_classCallCheck(this,jt);var i,o;var n=nt.tryCreateConfig("Options",(i=t==null?void 0:t.button)==null?void 0:i.tooltip);_this92=_callSuper(this,jt,[jt.createButtonElement(),Hd,void 0,n,{styles:(o=t==null?void 0:t.button)==null?void 0:o.styles}]);var s=_this92.createInnerElementsForStates(_this92.customStyles);_this92._menu=new or(e,t==null?void 0:t.menu),_this92.addClickEvent(),_this92.buttonContainer=jt.createButtonContainer(),_this92.changeElementsByState(s.styles),_this92.buttonContainer.appendChild(_this92.elementRef),_this92.elementRef[m].add(jt.BUTTON_ICON_CLASS),_this92.buttonContainer.appendChild(_this92._menu.elementRef),_this92.reapplyStateStyle("styles"),_this92.addContainerEvents(e);return _this92;}_inherits(jt,_tn3);return _createClass(jt,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){return{styles:this.createInnerElements("dropup-icon","styles",e)};}},{key:"addClickEvent",value:function addClickEvent(){var _this93=this;this.elementRef.onclick=this._menu.toggle.bind(this._menu),this.elementRef.onkeydown=function(e){e.key===de.ENTER&&setTimeout(function(){_this93._menu.toggle();var t=_this93._menu.elementRef.children[0];t.focus(),t.dispatchEvent(new MouseEvent("mouseenter"));});};}},{key:"addItem",value:function addItem(e){this._menu.addItem(e);}},{key:"addContainerEvents",value:function addContainerEvents(e){var _this94=this;e.addEventListener(z,function(t){var n=t.target[m];!n.contains(jt.BUTTON_ICON_CLASS)&&!n.contains(zt.DISABLED_CONTAINER_CLASS)&&_this94._menu.close();});}}],[{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button"),e;}},{key:"createButtonContainer",value:function createButtonContainer(){var e=S();return e.id="dropup-container",e;}},{key:"getPosition",value:function getPosition(e,t){var n,s;return(n=t==null?void 0:t.button)!=null&&n.position?ne.processPosition((s=t==null?void 0:t.button)==null?void 0:s.position):e[Ae].length>0&&e[ue].length===0?ue:Ae;}}]);}(tn);jt.BUTTON_ICON_CLASS="dropup-button";var Js=jt;var we=/*#__PURE__*/function(){function we(){_classCallCheck(this,we);}return _createClass(we,null,[{key:"addToDropup",value:// prettier-ignore
224
224
  function addToDropup(e,t,n,s){var i=new Js(n,s);qr.forEach(function(a){var l=t[ze].findIndex(function(d){return d.buttonType===a;}),c=t[ze][l];c&&(i.addItem(c.button),t[ze].splice(l,1));}),t[ze].forEach(function(_ref224){var a=_ref224.button;return i.addItem(a);});var o=Js.getPosition(t,s);yn.addButton(e,i.buttonContainer,o),t[o].push({});}},{key:"addToSideContainer",value:function addToSideContainer(e,t){[fn,it,Ae,ue].forEach(function(s){var i=s;t[i].forEach(function(o){yn.addButton(e,o.button.elementRef,i);});});}},{key:"setPosition",value:function setPosition(e,t,n){var s=_objectSpread(_objectSpread({},e[t]),{},{buttonType:t});n.push(s),delete e[t];}},{key:"createPositionsToButtonsObj",value:function createPositionsToButtonsObj(){return _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},ze,[]),Ae,[]),fn,[]),it,[]),ue,[]);}// prettier-ignore
225
- },{key:"generatePositionToButtons",value:function generatePositionToButtons(e){var t=Ce.createPositionsToButtonsObj();Object.keys(e).forEach(function(s){var o;var i=(o=e[s])==null?void 0:o.button.position;i&&Ce.setPosition(e,s,t[i]);}),t[it].length===0&&e.submit&&Ce.setPosition(e,"submit",t[it]),t[ue].length===0&&(e.submit?Ce.setPosition(e,"submit",t[ue]):e.microphone?Ce.setPosition(e,Ye,t[ue]):e.camera?Ce.setPosition(e,Ie,t[ue]):e["".concat(zt.INDICATOR_PREFIX,"1")]&&Ce.setPosition(e,"".concat(zt.INDICATOR_PREFIX,"1"),t[ue])),e.submit&&Ce.setPosition(e,"submit",t[Ae].length===0?t[Ae]:t[it]),e.microphone&&Ce.setPosition(e,Ye,t[Ae].length===0?t[Ae]:t[it]);var n=Object.keys(e);return n.length>1||t[ze].length>0?(qr.forEach(function(s){e[s]&&t[ze].push(_objectSpread(_objectSpread({},e[s]),{},{buttonType:s}));}),n.forEach(function(s){var i=s;i.startsWith(zt.INDICATOR_PREFIX)&&e[i]&&t[ze].push(_objectSpread(_objectSpread({},e[i]),{},{customType:i}));})):n.length===1&&Ce.setPosition(e,n[0],t[ue].length===0?t[ue]:t[Ae]),t;}// prettier-ignore
226
- },{key:"addButtons",value:function addButtons(e,t,n,s){var i=Ce.generatePositionToButtons(t);return Ce.addToSideContainer(e,i),i[ze].length>0&&Ce.addToDropup(e,i,n,s),i;}}]);}();var jd="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M20 10.9696L11.9628 18.5497C10.9782 19.4783 9.64274 20 8.25028 20C6.85782 20 5.52239 19.4783 4.53777 18.5497C3.55315 17.6211 3 16.3616 3 15.0483C3 13.7351 3.55315 12.4756 4.53777 11.547L12.575 3.96687C13.2314 3.34779 14.1217 3 15.05 3C15.9783 3 16.8686 3.34779 17.525 3.96687C18.1814 4.58595 18.5502 5.4256 18.5502 6.30111C18.5502 7.17662 18.1814 8.01628 17.525 8.63535L9.47904 16.2154C9.15083 16.525 8.70569 16.6989 8.24154 16.6989C7.77738 16.6989 7.33224 16.525 7.00403 16.2154C6.67583 15.9059 6.49144 15.4861 6.49144 15.0483C6.49144 14.6106 6.67583 14.1907 7.00403 13.8812L14.429 6.88674\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>",qd="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20,15.2928932 L20,5.5 C20,4.67157288 19.3284271,4 18.5,4 L5.5,4 C4.67157288,4 4,4.67157288 4,5.5 L4,12.2928932 L7.14644661,9.14644661 C7.34170876,8.95118446 7.65829124,8.95118446 7.85355339,9.14644661 L13.5,14.7928932 L16.1464466,12.1464466 C16.3417088,11.9511845 16.6582912,11.9511845 16.8535534,12.1464466 L20,15.2928932 Z M20,16.7071068 L16.5,13.2071068 L13.8535534,15.8535534 C13.6582912,16.0488155 13.3417088,16.0488155 13.1464466,15.8535534 L7.5,10.2071068 L4,13.7071068 L4,18.5 C4,19.3284271 4.67157288,20 5.5,20 L18.5,20 C19.3284271,20 20,19.3284271 20,18.5 L20,16.7071068 Z M3,5.5 C3,4.11928813 4.11928813,3 5.5,3 L18.5,3 C19.8807119,3 21,4.11928813 21,5.5 L21,18.5 C21,19.8807119 19.8807119,21 18.5,21 L5.5,21 C4.11928813,21 3,19.8807119 3,18.5 L3,5.5 Z M15,6 L17,6 C17.5522847,6 18,6.44771525 18,7 L18,9 C18,9.55228475 17.5522847,10 17,10 L15,10 C14.4477153,10 14,9.55228475 14,9 L14,7 C14,6.44771525 14.4477153,6 15,6 Z M15,7 L15,9 L17,9 L17,7 L15,7 Z\"/>\n</svg>\n",$d="<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"-49.49 -49.49 593.87 593.87\" stroke-width=\"3.95908\" transform=\"rotate(0)\">\n <g stroke-width=\"0\"></g>\n <g stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"0.98977\"></g>\n <g>\n <g>\n <g>\n <path d=\"M163.205,76.413v293.301c-3.434-3.058-7.241-5.867-11.486-8.339c-21.38-12.452-49.663-15.298-77.567-7.846 c-49.038,13.096-80.904,54.519-71.038,92.337c4.019,15.404,14.188,28.221,29.404,37.087c13.553,7.894,29.87,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.447-4.087c42.74-11.406,72.411-44.344,72.807-77.654h0.011v-0.162c0.002-0.166,0-0.331,0-0.496V187.072 l290.971-67.3v178.082c-3.433-3.055-7.238-5.863-11.481-8.334c-21.385-12.452-49.654-15.308-77.567-7.846 c-49.038,13.087-80.904,54.519-71.038,92.356c4.019,15.385,14.183,28.212,29.404,37.067c13.548,7.894,29.875,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.452-4.087c42.74-11.413,72.411-44.346,72.804-77.654h0.004v-0.065c0.003-0.236,0.001-0.469,0-0.704V0 L163.205,76.413z M104.999,471.779c-22.543,6.038-45.942,3.846-62.572-5.846c-10.587-6.163-17.591-14.817-20.255-25.038 c-7.144-27.375,18.452-58.029,57.062-68.346c8.409-2.25,16.938-3.346,25.188-3.346c13.87,0,26.962,3.115,37.389,9.192 c10.587,6.163,17.591,14.817,20.255,25.029c0.809,3.102,1.142,6.248,1.139,9.4v0.321h0.014 C162.99,437.714,139.082,462.678,104.999,471.779z M182.898,166.853V92.067l290.971-67.298v74.784L182.898,166.853z M415.677,399.923c-22.558,6.038-45.942,3.837-62.587-5.846c-10.587-6.163-17.587-14.817-20.25-25.019 c-7.144-27.385,18.452-58.058,57.058-68.365c8.414-2.25,16.942-3.346,25.192-3.346c13.875,0,26.962,3.115,37.385,9.192 c10.596,6.163,17.596,14.817,20.26,25.029v0.01c0.796,3.05,1.124,6.144,1.135,9.244v0.468h0.02 C473.668,365.851,449.763,390.814,415.677,399.923z\">\n </path>\n </g>\n </g>\n </g>\n</svg>",Gd="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 5.9266752 5.6408391\" height=\"21.31971\" width=\"22.4\">\n <g>\n <path d=\"m 5.2564627,1.548212 c -3.1136005,-0.4796804 -1.5568006,-0.2398402 0,0 z M 2.0001198,2.0922063 c 0.1556781,0 0.2657489,0.020893 0.3917849,0.080366 0.081154,0.038347 0.1153492,0.134065 0.076377,0.2138602 -0.038973,0.07979 -0.1363527,0.1134129 -0.2175069,0.075091 -0.078199,-0.036919 -0.1407455,-0.048792 -0.250655,-0.048792 -0.2260486,0 -0.3921482,0.2042182 -0.3921482,0.4801409 0,0.2761822 0.1663188,0.4810688 0.3921482,0.4810688 0.1117901,0 0.2064255,-0.046133 0.255659,-0.1284198 l 0.00162,-0.00389 V 3.0534032 l -0.098011,1.75e-4 c -0.081844,0 -0.1495979,-0.059305 -0.1612403,-0.1365887 l -0.00175,-0.023683 c 0,-0.08047 0.060311,-0.1470874 0.1389194,-0.1585331 l 0.024085,-0.00195 h 0.2612303 c 0.081842,0 0.149598,0.059305 0.1612404,0.1365891 l 0.00175,0.023683 -3.398e-4,0.3968809 v 0 l -0.00168,0.014211 v 0 l -0.00553,0.023034 v 0 l -0.00532,0.014145 c -0.098178,0.22826 -0.3236506,0.3528713 -0.5706303,0.3528713 -0.4240855,0 -0.7181621,-0.3622714 -0.7181621,-0.8016063 0,-0.4391857 0.2940275,-0.8006848 0.7181621,-0.8006848 z m 1.2034759,0.031275 c 0.081843,0 0.1495977,0.059305 0.1612403,0.1365891 l 0.00175,0.023683 v 1.2211775 c 0,0.088516 -0.07298,0.1602721 -0.1630073,0.1602721 -0.081841,0 -0.1495972,-0.059305 -0.1612397,-0.1365892 L 3.040589,3.5049308 V 2.2837527 c 0,-0.088516 0.07298,-0.1602721 0.1630067,-0.1602714 z m 0.7813442,0 0.5209469,0.00195 c 0.090025,3.048e-4 0.1627543,0.072306 0.1624458,0.1608234 -2.809e-4,0.08047 -0.06083,0.1468798 -0.1394772,0.158066 l -0.024092,0.00195 -0.3575326,-0.0013 v 0.4497782 l 0.2928918,2.27e-4 c 0.081842,0 0.1495979,0.059305 0.1612403,0.136589 l 0.00175,0.023683 c 0,0.080469 -0.06031,0.1470871 -0.1389193,0.1585393 l -0.024092,0.00195 -0.2928919,-2.336e-4 1.563e-4,0.2860316 c 0,0.080471 -0.06031,0.1470873 -0.1389193,0.1585395 l -0.024085,0.00195 c -0.081843,0 -0.1495979,-0.059305 -0.1612403,-0.1365826 l -0.00175,-0.023691 V 2.2841354 c 2.798e-4,-0.08047 0.060829,-0.1468797 0.1394758,-0.1580594 z\"/>\n <path d=\"m 5.0894191,1.0943261 c 0,-0.21918999 -0.177687,-0.39686999 -0.396876,-0.39686999 h -3.43959 c -0.2191879,0 -0.391262,0.1777519 -0.3968759,0.39686999 l -0.027082,3.4379266 c 0.040152,0.2939927 0.4235456,0.409415 0.4235456,0.409415 l 3.4785583,-0.00851 c 0,0 0.3008506,-0.1402998 0.3236271,-0.4201576 0.042911,-0.5272495 0.034693,-1.6106146 0.034693,-3.4186761 z m -4.49792494,0 c 0,-0.36530999 0.29614504,-0.66145999 0.66145894,-0.66145999 h 3.43959 c 0.365314,0 0.66146,0.29615 0.66146,0.66145999 v 3.43959 c 0,0.36532 -0.296146,0.66146 -0.66146,0.66146 h -3.43959 c -0.3653139,0 -0.66145894,-0.29614 -0.66145894,-0.66146 z\"/>\n </g>\n</svg>\n",zd=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},J,{id:"upload-images-icon",svgString:qd,dropupText:"Image"}),hn,{id:"upload-gifs-icon",svgString:Gd,dropupText:"GIF"}),L,{id:"upload-audio-icon",svgString:$d,dropupText:"Audio"}),"mixedFiles",{id:"upload-mixed-files-icon",svgString:jd,dropupText:"File"});var ri=/*#__PURE__*/function(_tn4){function ri(e){var _this95;_classCallCheck(this,ri);(e==null?void 0:e.position)===ze&&(e.position=ue);var t=nt.tryCreateConfig("Microphone",e==null?void 0:e.tooltip);_this95=_callSuper(this,ri,[ri.createMicrophoneElement(),Do,e==null?void 0:e.position,t,e]),_this95.isActive=!1,_this95._innerElements=_this95.createInnerElementsForStates(_this95.customStyles),_this95.changeToDefault();return _this95;}_inherits(ri,_tn4);return _createClass(ri,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){var t="microphone-icon";return _defineProperty(_defineProperty(_defineProperty(_defineProperty({},x,this.createInnerElements(t,x,e)),"active",this.createInnerElements(t,"active",e)),"unsupported",this.createInnerElements(t,"unsupported",e)),"commandMode",this.createInnerElements(t,"commandMode",e));}},{key:"changeToActive",value:function changeToActive(){this.changeElementsByState(this._innerElements.active),this.toggleIconFilter("active"),this.reapplyStateStyle("active",[x,"commandMode"]),this.isActive=!0;}},{key:"changeToDefault",value:function changeToDefault(){this.changeElementsByState(this._innerElements[x]),this.toggleIconFilter(x),this.reapplyStateStyle(x,["active","commandMode"]),this.isActive=!1;}},{key:"changeToCommandMode",value:function changeToCommandMode(){this.changeElementsByState(this._innerElements.commandMode),this.toggleIconFilter("command"),this.reapplyStateStyle("commandMode",["active"]);}},{key:"changeToUnsupported",value:function changeToUnsupported(){this.changeElementsByState(this._innerElements.unsupported),this.elementRef[m].add("unsupported-microphone"),this.reapplyStateStyle("unsupported",["active"]);}},{key:"toggleIconFilter",value:function toggleIconFilter(e){var t=this.elementRef.children[0];if(t.tagName.toLocaleLowerCase()==="svg")switch(e){case x:t[m].remove("active-microphone-icon","command-microphone-icon"),t[m].add("default-microphone-icon");break;case"active":t[m].remove("default-microphone-icon","command-microphone-icon"),t[m].add("active-microphone-icon");break;case"command":t[m].remove("active-microphone-icon","default-microphone-icon"),t[m].add("command-microphone-icon");break;}}}],[{key:"createMicrophoneElement",value:function createMicrophoneElement(){var e=S();return e.id="microphone-button",e[m].add("input-button"),e;}}]);}(tn);function Vd(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r["default"]:r;}var xs={},Cn={},Tn={},Rn={},In={},$r;function oi(){if($r)return In;$r=1,Object.defineProperty(In,"__esModule",{value:!0}),In.Text=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"capitalize",value:function capitalize(t){return t.replace(r.FIRST_CHAR_REGEX,function(n){return n.toUpperCase();});}},{key:"lineBreak",value:function lineBreak(t){return t.replace(r.DOUBLE_LINE,"<p></p>").replace(r.ONE_LINE,"<br>");}},{key:"isCharDefined",value:function isCharDefined(t){return t!==void 0&&t!==" "&&t!==" "&&t!=="\n"&&t!=="";}},{key:"breakupIntoWordsArr",value:function breakupIntoWordsArr(t){return t.split(/(\W+)/);}}]);}();return In.Text=r,r.FIRST_CHAR_REGEX=/\S/,r.DOUBLE_LINE=/\n\n/g,r.ONE_LINE=/\n/g,In;}var Gr;function zo(){if(Gr)return Rn;Gr=1,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.Translate=void 0;var r=oi();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"translate",value:function translate(n,s){var i=r.Text.breakupIntoWordsArr(n);for(var o=0;o<i.length;o+=1)s[i[o]]&&(i[o]=s[i[o]]);return i.join("");}}]);}();return Rn.Translate=e,Rn;}var zr;function Jd(){if(zr)return Tn;zr=1,Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.WebSpeechTranscript=void 0;var r=zo();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"extract",value:function extract(n,s,i){var o="";for(var a=n.resultIndex;a<n.results.length;++a){var l=n.results[a][0].transcript;i&&(l=r.Translate.translate(l,i)),n.results[a].isFinal?s+=l:o+=l;}return{interimTranscript:o,finalTranscript:s,newText:o||s};}},{key:"extractSafari",value:function extractSafari(n,s,i){var o="";for(var l=n.resultIndex;l<n.results.length;++l){var c=n.results[l][0].transcript;i&&(c=r.Translate.translate(c,i)),o+=c;}return{interimTranscript:"",finalTranscript:o,newText:o};}}]);}();return Tn.WebSpeechTranscript=e,Tn;}var Mn={},Vr;function ar(){if(Vr)return Mn;Vr=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.Browser=void 0;var r=/*#__PURE__*/_createClass(function r(){_classCallCheck(this,r);});return Mn.Browser=r,r.IS_SAFARI=function(){return r._IS_SAFARI===void 0&&(r._IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),r._IS_SAFARI;},Mn;}var kn={},On={},Jr;function Wd(){if(Jr)return On;Jr=1,Object.defineProperty(On,"__esModule",{value:!0}),On.EventListeners=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"getElementIfFocusedOnAvailable",value:function getElementIfFocusedOnAvailable(t,n){return Array.isArray(t)?t.find(function(s){return n===s;}):n===t?t:void 0;}},{key:"keyDownWindow",value:function keyDownWindow(t){var _this96=this;t.element&&r.getElementIfFocusedOnAvailable(t.element,document.activeElement)&&(r.KEY_DOWN_TIMEOUT!==null&&clearTimeout(r.KEY_DOWN_TIMEOUT),r.KEY_DOWN_TIMEOUT=setTimeout(function(){r.KEY_DOWN_TIMEOUT=null,_this96.resetRecording(t);},500));}},{key:"mouseDownWindow",value:function mouseDownWindow(t,n){this.mouseDownElement=r.getElementIfFocusedOnAvailable(t,n.target);}},{key:"mouseUpWindow",value:function mouseUpWindow(t){this.mouseDownElement&&this.resetRecording(t),this.mouseDownElement=void 0;}},{key:"add",value:function add(t,n){var s=(n==null?void 0:n.insertInCursorLocation)===void 0||(n==null?void 0:n.insertInCursorLocation);n!=null&&n.element&&s&&(t.mouseDownEvent=r.mouseDownWindow.bind(t,n.element),document.addEventListener("mousedown",t.mouseDownEvent),t.mouseUpEvent=r.mouseUpWindow.bind(t,n),document.addEventListener("mouseup",t.mouseUpEvent),t.keyDownEvent=r.keyDownWindow.bind(t,n),document.addEventListener("keydown",t.keyDownEvent));}},{key:"remove",value:function remove(t){document.removeEventListener("mousedown",t.mouseDownEvent),document.removeEventListener("mouseup",t.mouseUpEvent),document.removeEventListener("keydown",t.keyDownEvent);}}]);}();return On.EventListeners=r,r.KEY_DOWN_TIMEOUT=null,On;}var Nn={},Wr;function Kd(){if(Wr)return Nn;Wr=1,Object.defineProperty(Nn,"__esModule",{value:!0}),Nn.PreResultUtils=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"process",value:function process(t,n,s,i,o){var a=i==null?void 0:i(n,s);return a?(setTimeout(function(){a.restart?t.resetRecording(o):a.stop&&t.stop();}),(a.stop||a.restart)&&a.removeNewText):!1;}}]);}();return Nn.PreResultUtils=r,Nn;}var Pn={},Ln={},Kr;function Vo(){if(Kr)return Ln;Kr=1,Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.AutoScroll=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"changeStateIfNeeded",value:function changeStateIfNeeded(t,n){n&&!t.isCursorAtEnd&&(t.endPadding="",t.scrollingSpan.innerHTML="&nbsp;");}},{key:"scrollGeneric",value:function scrollGeneric(t,n){t.isCursorAtEnd?n.scrollTop=n.scrollHeight:t.scrollingSpan.scrollIntoView({block:"nearest"});}// primitives don't need to be scrolled except in safari
225
+ },{key:"generatePositionToButtons",value:function generatePositionToButtons(e){var t=we.createPositionsToButtonsObj();Object.keys(e).forEach(function(s){var o;var i=(o=e[s])==null?void 0:o.button.position;i&&we.setPosition(e,s,t[i]);}),t[it].length===0&&e.submit&&we.setPosition(e,"submit",t[it]),t[ue].length===0&&(e.submit?we.setPosition(e,"submit",t[ue]):e.microphone?we.setPosition(e,Ye,t[ue]):e.camera?we.setPosition(e,Ie,t[ue]):e["".concat(zt.INDICATOR_PREFIX,"1")]&&we.setPosition(e,"".concat(zt.INDICATOR_PREFIX,"1"),t[ue])),e.submit&&we.setPosition(e,"submit",t[Ae].length===0?t[Ae]:t[it]),e.microphone&&we.setPosition(e,Ye,t[Ae].length===0?t[Ae]:t[it]);var n=Object.keys(e);return n.length>1||t[ze].length>0?(qr.forEach(function(s){e[s]&&t[ze].push(_objectSpread(_objectSpread({},e[s]),{},{buttonType:s}));}),n.forEach(function(s){var i=s;i.startsWith(zt.INDICATOR_PREFIX)&&e[i]&&t[ze].push(_objectSpread(_objectSpread({},e[i]),{},{customType:i}));})):n.length===1&&we.setPosition(e,n[0],t[ue].length===0?t[ue]:t[Ae]),t;}// prettier-ignore
226
+ },{key:"addButtons",value:function addButtons(e,t,n,s){var i=we.generatePositionToButtons(t);return we.addToSideContainer(e,i),i[ze].length>0&&we.addToDropup(e,i,n,s),i;}}]);}();var jd="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M20 10.9696L11.9628 18.5497C10.9782 19.4783 9.64274 20 8.25028 20C6.85782 20 5.52239 19.4783 4.53777 18.5497C3.55315 17.6211 3 16.3616 3 15.0483C3 13.7351 3.55315 12.4756 4.53777 11.547L12.575 3.96687C13.2314 3.34779 14.1217 3 15.05 3C15.9783 3 16.8686 3.34779 17.525 3.96687C18.1814 4.58595 18.5502 5.4256 18.5502 6.30111C18.5502 7.17662 18.1814 8.01628 17.525 8.63535L9.47904 16.2154C9.15083 16.525 8.70569 16.6989 8.24154 16.6989C7.77738 16.6989 7.33224 16.525 7.00403 16.2154C6.67583 15.9059 6.49144 15.4861 6.49144 15.0483C6.49144 14.6106 6.67583 14.1907 7.00403 13.8812L14.429 6.88674\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>",qd="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20,15.2928932 L20,5.5 C20,4.67157288 19.3284271,4 18.5,4 L5.5,4 C4.67157288,4 4,4.67157288 4,5.5 L4,12.2928932 L7.14644661,9.14644661 C7.34170876,8.95118446 7.65829124,8.95118446 7.85355339,9.14644661 L13.5,14.7928932 L16.1464466,12.1464466 C16.3417088,11.9511845 16.6582912,11.9511845 16.8535534,12.1464466 L20,15.2928932 Z M20,16.7071068 L16.5,13.2071068 L13.8535534,15.8535534 C13.6582912,16.0488155 13.3417088,16.0488155 13.1464466,15.8535534 L7.5,10.2071068 L4,13.7071068 L4,18.5 C4,19.3284271 4.67157288,20 5.5,20 L18.5,20 C19.3284271,20 20,19.3284271 20,18.5 L20,16.7071068 Z M3,5.5 C3,4.11928813 4.11928813,3 5.5,3 L18.5,3 C19.8807119,3 21,4.11928813 21,5.5 L21,18.5 C21,19.8807119 19.8807119,21 18.5,21 L5.5,21 C4.11928813,21 3,19.8807119 3,18.5 L3,5.5 Z M15,6 L17,6 C17.5522847,6 18,6.44771525 18,7 L18,9 C18,9.55228475 17.5522847,10 17,10 L15,10 C14.4477153,10 14,9.55228475 14,9 L14,7 C14,6.44771525 14.4477153,6 15,6 Z M15,7 L15,9 L17,9 L17,7 L15,7 Z\"/>\n</svg>\n",$d="<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"-49.49 -49.49 593.87 593.87\" stroke-width=\"3.95908\" transform=\"rotate(0)\">\n <g stroke-width=\"0\"></g>\n <g stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"0.98977\"></g>\n <g>\n <g>\n <g>\n <path d=\"M163.205,76.413v293.301c-3.434-3.058-7.241-5.867-11.486-8.339c-21.38-12.452-49.663-15.298-77.567-7.846 c-49.038,13.096-80.904,54.519-71.038,92.337c4.019,15.404,14.188,28.221,29.404,37.087c13.553,7.894,29.87,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.447-4.087c42.74-11.406,72.411-44.344,72.807-77.654h0.011v-0.162c0.002-0.166,0-0.331,0-0.496V187.072 l290.971-67.3v178.082c-3.433-3.055-7.238-5.863-11.481-8.334c-21.385-12.452-49.654-15.308-77.567-7.846 c-49.038,13.087-80.904,54.519-71.038,92.356c4.019,15.385,14.183,28.212,29.404,37.067c13.548,7.894,29.875,11.933,47.115,11.933 c9.962,0,20.231-1.356,30.452-4.087c42.74-11.413,72.411-44.346,72.804-77.654h0.004v-0.065c0.003-0.236,0.001-0.469,0-0.704V0 L163.205,76.413z M104.999,471.779c-22.543,6.038-45.942,3.846-62.572-5.846c-10.587-6.163-17.591-14.817-20.255-25.038 c-7.144-27.375,18.452-58.029,57.062-68.346c8.409-2.25,16.938-3.346,25.188-3.346c13.87,0,26.962,3.115,37.389,9.192 c10.587,6.163,17.591,14.817,20.255,25.029c0.809,3.102,1.142,6.248,1.139,9.4v0.321h0.014 C162.99,437.714,139.082,462.678,104.999,471.779z M182.898,166.853V92.067l290.971-67.298v74.784L182.898,166.853z M415.677,399.923c-22.558,6.038-45.942,3.837-62.587-5.846c-10.587-6.163-17.587-14.817-20.25-25.019 c-7.144-27.385,18.452-58.058,57.058-68.365c8.414-2.25,16.942-3.346,25.192-3.346c13.875,0,26.962,3.115,37.385,9.192 c10.596,6.163,17.596,14.817,20.26,25.029v0.01c0.796,3.05,1.124,6.144,1.135,9.244v0.468h0.02 C473.668,365.851,449.763,390.814,415.677,399.923z\">\n </path>\n </g>\n </g>\n </g>\n</svg>",Gd="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"0 0 5.9266752 5.6408391\" height=\"21.31971\" width=\"22.4\">\n <g>\n <path d=\"m 5.2564627,1.548212 c -3.1136005,-0.4796804 -1.5568006,-0.2398402 0,0 z M 2.0001198,2.0922063 c 0.1556781,0 0.2657489,0.020893 0.3917849,0.080366 0.081154,0.038347 0.1153492,0.134065 0.076377,0.2138602 -0.038973,0.07979 -0.1363527,0.1134129 -0.2175069,0.075091 -0.078199,-0.036919 -0.1407455,-0.048792 -0.250655,-0.048792 -0.2260486,0 -0.3921482,0.2042182 -0.3921482,0.4801409 0,0.2761822 0.1663188,0.4810688 0.3921482,0.4810688 0.1117901,0 0.2064255,-0.046133 0.255659,-0.1284198 l 0.00162,-0.00389 V 3.0534032 l -0.098011,1.75e-4 c -0.081844,0 -0.1495979,-0.059305 -0.1612403,-0.1365887 l -0.00175,-0.023683 c 0,-0.08047 0.060311,-0.1470874 0.1389194,-0.1585331 l 0.024085,-0.00195 h 0.2612303 c 0.081842,0 0.149598,0.059305 0.1612404,0.1365891 l 0.00175,0.023683 -3.398e-4,0.3968809 v 0 l -0.00168,0.014211 v 0 l -0.00553,0.023034 v 0 l -0.00532,0.014145 c -0.098178,0.22826 -0.3236506,0.3528713 -0.5706303,0.3528713 -0.4240855,0 -0.7181621,-0.3622714 -0.7181621,-0.8016063 0,-0.4391857 0.2940275,-0.8006848 0.7181621,-0.8006848 z m 1.2034759,0.031275 c 0.081843,0 0.1495977,0.059305 0.1612403,0.1365891 l 0.00175,0.023683 v 1.2211775 c 0,0.088516 -0.07298,0.1602721 -0.1630073,0.1602721 -0.081841,0 -0.1495972,-0.059305 -0.1612397,-0.1365892 L 3.040589,3.5049308 V 2.2837527 c 0,-0.088516 0.07298,-0.1602721 0.1630067,-0.1602714 z m 0.7813442,0 0.5209469,0.00195 c 0.090025,3.048e-4 0.1627543,0.072306 0.1624458,0.1608234 -2.809e-4,0.08047 -0.06083,0.1468798 -0.1394772,0.158066 l -0.024092,0.00195 -0.3575326,-0.0013 v 0.4497782 l 0.2928918,2.27e-4 c 0.081842,0 0.1495979,0.059305 0.1612403,0.136589 l 0.00175,0.023683 c 0,0.080469 -0.06031,0.1470871 -0.1389193,0.1585393 l -0.024092,0.00195 -0.2928919,-2.336e-4 1.563e-4,0.2860316 c 0,0.080471 -0.06031,0.1470873 -0.1389193,0.1585395 l -0.024085,0.00195 c -0.081843,0 -0.1495979,-0.059305 -0.1612403,-0.1365826 l -0.00175,-0.023691 V 2.2841354 c 2.798e-4,-0.08047 0.060829,-0.1468797 0.1394758,-0.1580594 z\"/>\n <path d=\"m 5.0894191,1.0943261 c 0,-0.21918999 -0.177687,-0.39686999 -0.396876,-0.39686999 h -3.43959 c -0.2191879,0 -0.391262,0.1777519 -0.3968759,0.39686999 l -0.027082,3.4379266 c 0.040152,0.2939927 0.4235456,0.409415 0.4235456,0.409415 l 3.4785583,-0.00851 c 0,0 0.3008506,-0.1402998 0.3236271,-0.4201576 0.042911,-0.5272495 0.034693,-1.6106146 0.034693,-3.4186761 z m -4.49792494,0 c 0,-0.36530999 0.29614504,-0.66145999 0.66145894,-0.66145999 h 3.43959 c 0.365314,0 0.66146,0.29615 0.66146,0.66145999 v 3.43959 c 0,0.36532 -0.296146,0.66146 -0.66146,0.66146 h -3.43959 c -0.3653139,0 -0.66145894,-0.29614 -0.66145894,-0.66146 z\"/>\n </g>\n</svg>\n",zd=_defineProperty(_defineProperty(_defineProperty(_defineProperty({},J,{id:"upload-images-icon",svgString:qd,dropupText:"Image"}),hn,{id:"upload-gifs-icon",svgString:Gd,dropupText:"GIF"}),L,{id:"upload-audio-icon",svgString:$d,dropupText:"Audio"}),"mixedFiles",{id:"upload-mixed-files-icon",svgString:jd,dropupText:"File"});var ri=/*#__PURE__*/function(_tn4){function ri(e){var _this95;_classCallCheck(this,ri);(e==null?void 0:e.position)===ze&&(e.position=ue);var t=nt.tryCreateConfig("Microphone",e==null?void 0:e.tooltip);_this95=_callSuper(this,ri,[ri.createMicrophoneElement(),Do,e==null?void 0:e.position,t,e]),_this95.isActive=!1,_this95._innerElements=_this95.createInnerElementsForStates(_this95.customStyles),_this95.changeToDefault();return _this95;}_inherits(ri,_tn4);return _createClass(ri,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){var t="microphone-icon";return _defineProperty(_defineProperty(_defineProperty(_defineProperty({},x,this.createInnerElements(t,x,e)),"active",this.createInnerElements(t,"active",e)),"unsupported",this.createInnerElements(t,"unsupported",e)),"commandMode",this.createInnerElements(t,"commandMode",e));}},{key:"changeToActive",value:function changeToActive(){this.changeElementsByState(this._innerElements.active),this.toggleIconFilter("active"),this.reapplyStateStyle("active",[x,"commandMode"]),this.isActive=!0;}},{key:"changeToDefault",value:function changeToDefault(){this.changeElementsByState(this._innerElements[x]),this.toggleIconFilter(x),this.reapplyStateStyle(x,["active","commandMode"]),this.isActive=!1;}},{key:"changeToCommandMode",value:function changeToCommandMode(){this.changeElementsByState(this._innerElements.commandMode),this.toggleIconFilter("command"),this.reapplyStateStyle("commandMode",["active"]);}},{key:"changeToUnsupported",value:function changeToUnsupported(){this.changeElementsByState(this._innerElements.unsupported),this.elementRef[m].add("unsupported-microphone"),this.reapplyStateStyle("unsupported",["active"]);}},{key:"toggleIconFilter",value:function toggleIconFilter(e){var t=this.elementRef.children[0];if(t.tagName.toLocaleLowerCase()==="svg")switch(e){case x:t[m].remove("active-microphone-icon","command-microphone-icon"),t[m].add("default-microphone-icon");break;case"active":t[m].remove("default-microphone-icon","command-microphone-icon"),t[m].add("active-microphone-icon");break;case"command":t[m].remove("active-microphone-icon","default-microphone-icon"),t[m].add("command-microphone-icon");break;}}}],[{key:"createMicrophoneElement",value:function createMicrophoneElement(){var e=S();return e.id="microphone-button",e[m].add("input-button"),e;}}]);}(tn);function Vd(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r["default"]:r;}var xs={},wn={},Tn={},Rn={},In={},$r;function oi(){if($r)return In;$r=1,Object.defineProperty(In,"__esModule",{value:!0}),In.Text=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"capitalize",value:function capitalize(t){return t.replace(r.FIRST_CHAR_REGEX,function(n){return n.toUpperCase();});}},{key:"lineBreak",value:function lineBreak(t){return t.replace(r.DOUBLE_LINE,"<p></p>").replace(r.ONE_LINE,"<br>");}},{key:"isCharDefined",value:function isCharDefined(t){return t!==void 0&&t!==" "&&t!==" "&&t!=="\n"&&t!=="";}},{key:"breakupIntoWordsArr",value:function breakupIntoWordsArr(t){return t.split(/(\W+)/);}}]);}();return In.Text=r,r.FIRST_CHAR_REGEX=/\S/,r.DOUBLE_LINE=/\n\n/g,r.ONE_LINE=/\n/g,In;}var Gr;function zo(){if(Gr)return Rn;Gr=1,Object.defineProperty(Rn,"__esModule",{value:!0}),Rn.Translate=void 0;var r=oi();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"translate",value:function translate(n,s){var i=r.Text.breakupIntoWordsArr(n);for(var o=0;o<i.length;o+=1)s[i[o]]&&(i[o]=s[i[o]]);return i.join("");}}]);}();return Rn.Translate=e,Rn;}var zr;function Jd(){if(zr)return Tn;zr=1,Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.WebSpeechTranscript=void 0;var r=zo();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"extract",value:function extract(n,s,i){var o="";for(var a=n.resultIndex;a<n.results.length;++a){var l=n.results[a][0].transcript;i&&(l=r.Translate.translate(l,i)),n.results[a].isFinal?s+=l:o+=l;}return{interimTranscript:o,finalTranscript:s,newText:o||s};}},{key:"extractSafari",value:function extractSafari(n,s,i){var o="";for(var l=n.resultIndex;l<n.results.length;++l){var c=n.results[l][0].transcript;i&&(c=r.Translate.translate(c,i)),o+=c;}return{interimTranscript:"",finalTranscript:o,newText:o};}}]);}();return Tn.WebSpeechTranscript=e,Tn;}var Mn={},Vr;function ar(){if(Vr)return Mn;Vr=1,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.Browser=void 0;var r=/*#__PURE__*/_createClass(function r(){_classCallCheck(this,r);});return Mn.Browser=r,r.IS_SAFARI=function(){return r._IS_SAFARI===void 0&&(r._IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),r._IS_SAFARI;},Mn;}var kn={},On={},Jr;function Wd(){if(Jr)return On;Jr=1,Object.defineProperty(On,"__esModule",{value:!0}),On.EventListeners=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"getElementIfFocusedOnAvailable",value:function getElementIfFocusedOnAvailable(t,n){return Array.isArray(t)?t.find(function(s){return n===s;}):n===t?t:void 0;}},{key:"keyDownWindow",value:function keyDownWindow(t){var _this96=this;t.element&&r.getElementIfFocusedOnAvailable(t.element,document.activeElement)&&(r.KEY_DOWN_TIMEOUT!==null&&clearTimeout(r.KEY_DOWN_TIMEOUT),r.KEY_DOWN_TIMEOUT=setTimeout(function(){r.KEY_DOWN_TIMEOUT=null,_this96.resetRecording(t);},500));}},{key:"mouseDownWindow",value:function mouseDownWindow(t,n){this.mouseDownElement=r.getElementIfFocusedOnAvailable(t,n.target);}},{key:"mouseUpWindow",value:function mouseUpWindow(t){this.mouseDownElement&&this.resetRecording(t),this.mouseDownElement=void 0;}},{key:"add",value:function add(t,n){var s=(n==null?void 0:n.insertInCursorLocation)===void 0||(n==null?void 0:n.insertInCursorLocation);n!=null&&n.element&&s&&(t.mouseDownEvent=r.mouseDownWindow.bind(t,n.element),document.addEventListener("mousedown",t.mouseDownEvent),t.mouseUpEvent=r.mouseUpWindow.bind(t,n),document.addEventListener("mouseup",t.mouseUpEvent),t.keyDownEvent=r.keyDownWindow.bind(t,n),document.addEventListener("keydown",t.keyDownEvent));}},{key:"remove",value:function remove(t){document.removeEventListener("mousedown",t.mouseDownEvent),document.removeEventListener("mouseup",t.mouseUpEvent),document.removeEventListener("keydown",t.keyDownEvent);}}]);}();return On.EventListeners=r,r.KEY_DOWN_TIMEOUT=null,On;}var Nn={},Wr;function Kd(){if(Wr)return Nn;Wr=1,Object.defineProperty(Nn,"__esModule",{value:!0}),Nn.PreResultUtils=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"process",value:function process(t,n,s,i,o){var a=i==null?void 0:i(n,s);return a?(setTimeout(function(){a.restart?t.resetRecording(o):a.stop&&t.stop();}),(a.stop||a.restart)&&a.removeNewText):!1;}}]);}();return Nn.PreResultUtils=r,Nn;}var Pn={},Ln={},Kr;function Vo(){if(Kr)return Ln;Kr=1,Object.defineProperty(Ln,"__esModule",{value:!0}),Ln.AutoScroll=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"changeStateIfNeeded",value:function changeStateIfNeeded(t,n){n&&!t.isCursorAtEnd&&(t.endPadding="",t.scrollingSpan.innerHTML="&nbsp;");}},{key:"scrollGeneric",value:function scrollGeneric(t,n){t.isCursorAtEnd?n.scrollTop=n.scrollHeight:t.scrollingSpan.scrollIntoView({block:"nearest"});}// primitives don't need to be scrolled except in safari
227
227
  // they can only safely be scrolled to the end
228
228
  },{key:"scrollSafariPrimitiveToEnd",value:function scrollSafariPrimitiveToEnd(t){t.scrollLeft=t.scrollWidth,t.scrollTop=t.scrollHeight;}},{key:"isElementOverflown",value:function isElementOverflown(t){return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth;}},{key:"isRequired",value:function isRequired(t,n){return t&&r.isElementOverflown(n);}}]);}();return Ln.AutoScroll=r,Ln;}var Bn={},Xr;function ai(){if(Xr)return Bn;Xr=1,Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.Elements=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"isPrimitiveElement",value:function isPrimitiveElement(t){return t.tagName==="INPUT"||t.tagName==="TEXTAREA";}},{key:"createInterimSpan",value:function createInterimSpan(){var t=document.createElement("span");return t.style.color="grey",t.style.pointerEvents="none",t;}},{key:"createGenericSpan",value:function createGenericSpan(){var t=document.createElement("span");return t.style.pointerEvents="none",t;}},{key:"appendSpans",value:function appendSpans(t,n){if(t.spansPopulated=!0,t.insertInCursorLocation&&document.activeElement===n){var s=window.getSelection();if(s!=null&&s.focusNode){var i=s.getRangeAt(0);i.insertNode(t.scrollingSpan),i.insertNode(t.interimSpan),i.insertNode(t.finalSpan),i.collapse(!1),s.removeAllRanges(),s.addRange(i);return;}}n.appendChild(t.finalSpan),n.appendChild(t.interimSpan),n.appendChild(t.scrollingSpan);}},{key:"applyCustomColors",value:function applyCustomColors(t,n){n.interim&&(t.interimSpan.style.color=n.interim),n["final"]&&(t.finalSpan.style.color=n["final"]);}},{key:"isInsideShadowDOM",value:function isInsideShadowDOM(t){return t.getRootNode()instanceof ShadowRoot;}}]);}();return Bn.Elements=r,Bn;}var Dn={},Zr;function li(){if(Zr)return Dn;Zr=1,Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.Cursor=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"setOffsetForGeneric",value:function setOffsetForGeneric(t,n){var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var i=0;for(var o=0;o<t.childNodes.length;o+=1){var a=t.childNodes[o];if(a.childNodes.length>0){var l=r.setOffsetForGeneric(a,n,s);if(l===-1)return-1;s+=l;}else if(a.textContent!==null){if(s+a.textContent.length>n){var _l5=document.createRange();_l5.setStart(a,n-s),_l5.collapse(!0);var c=window.getSelection();return c==null||c.removeAllRanges(),c==null||c.addRange(_l5),t.focus(),-1;}s+=a.textContent.length,i+=a.textContent.length;}}return i;}},{key:"focusEndOfGeneric",value:function focusEndOfGeneric(t){var n=document.createRange();n.selectNodeContents(t),n.collapse(!1);var s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(n));}},{key:"setOffsetForSafariGeneric",value:function setOffsetForSafariGeneric(t,n){var s=window.getSelection();if(s){var i=r.getGenericElementCursorOffset(t,s,!0);r.setOffsetForGeneric(t,i+n);}}// set to automatically scroll to cursor (scroll does not work in Safari)
229
229
  },{key:"setOffsetForPrimitive",value:function setOffsetForPrimitive(t,n,s){s&&t.blur(),t.setSelectionRange(n,n),t.focus();}// Scroll Input in Safari - does not work for TextArea and uses span which can have a different style
@@ -244,23 +244,23 @@ function addToDropup(e,t,n,s){var i=new Js(n,s);qr.forEach(function(a){var l=t[z
244
244
  // return {left: offsetWidth, top: offsetHeight};
245
245
  // }
246
246
  },{key:"getGenericElementCursorOffset",value:function getGenericElementCursorOffset(t,n,s){var i=0;if(n.rangeCount>0){var o=n.getRangeAt(0),a=o.cloneRange();a.selectNodeContents(t),s?a.setEnd(o.startContainer,o.startOffset):a.setEnd(o.endContainer,o.endOffset),i=a.toString().length;}return i;}}]);}();return Dn.Cursor=r,Dn;}var Yr;function Jo(){if(Yr)return Pn;Yr=1,Object.defineProperty(Pn,"__esModule",{value:!0}),Pn.CommandUtils=void 0;var r=Vo(),e=ai(),t=ar(),n=li(),s=oi();var i=/*#__PURE__*/function(){function i(){_classCallCheck(this,i);}return _createClass(i,null,[{key:"processCommand",value:function processCommand(a,l){return(!l||!l.caseSensitive)&&(a=a.toLowerCase()),(l==null?void 0:l.substrings)===!1?s.Text.breakupIntoWordsArr(a):a;}},{key:"process",value:function process(a){var l;return((l=a.settings)===null||l===void 0?void 0:l.caseSensitive)===!0?a:Object.keys(a).reduce(function(d,p){var u=a[p];return d[p]=typeof u=="string"?i.processCommand(u,a.settings):u,d;},{});}},{key:"toggleCommandModeOn",value:function toggleCommandModeOn(a){var l;a.isWaitingForCommand=!0,(l=a.onCommandModeTrigger)===null||l===void 0||l.call(a,!0);}},{key:"toggleCommandModeOff",value:function toggleCommandModeOff(a){var l;a.isWaitingForCommand&&((l=a.onCommandModeTrigger)===null||l===void 0||l.call(a,!1),a.isWaitingForCommand=!1);}},{key:"setText",value:function setText(a,l,c,d){i.toggleCommandModeOff(a),e.Elements.isPrimitiveElement(d)?(d.value=c,a.isTargetInShadow||n.Cursor.setOffsetForPrimitive(d,c.length,!0),t.Browser.IS_SAFARI()&&a.autoScroll&&r.AutoScroll.scrollSafariPrimitiveToEnd(d)):(d.textContent=c,a.isTargetInShadow||n.Cursor.focusEndOfGeneric(d),setTimeout(function(){return r.AutoScroll.scrollGeneric(a,d);})),a.resetRecording(l);}},{key:"checkIfMatchesSubstring",value:function checkIfMatchesSubstring(a,l){return l.includes(a);}},{key:"checkIfMatchesWord",value:function checkIfMatchesWord(a,l,c){var d=a;for(var p=c.length-1;p>=0;p-=1){var u=p,g=d.length-1;for(;c[u]===d[g]&&g>=0;)u-=1,g-=1;if(g<0)return!0;}return!1;}// prettier-ignore
247
- },{key:"execCommand",value:function execCommand(a,l,c,d,p){var u,g,b;var v=a.commands;if(!v||!d||!c)return;var E=((u=v.settings)===null||u===void 0?void 0:u.caseSensitive)===!0?l:l.toLowerCase(),C=s.Text.breakupIntoWordsArr(E),j=((g=v.settings)===null||g===void 0?void 0:g.substrings)===!1?i.checkIfMatchesWord:i.checkIfMatchesSubstring;if(v.commandMode&&j(v.commandMode,E,C))return a.setInterimColorToFinal(),setTimeout(function(){return i.toggleCommandModeOn(a);}),{doNotProcessTranscription:!1};if(!(v.commandMode&&!a.isWaitingForCommand)){if(v.stop&&j(v.stop,E,C))return i.toggleCommandModeOff(a),setTimeout(function(){return a.stop();}),{doNotProcessTranscription:!1};if(v.pause&&j(v.pause,E,C))return i.toggleCommandModeOff(a),a.setInterimColorToFinal(),setTimeout(function(){var X;a.isPaused=!0,(X=a.onPauseTrigger)===null||X===void 0||X.call(a,!0);}),{doNotProcessTranscription:!1};if(v.resume&&j(v.resume,E,C))return a.isPaused=!1,(b=a.onPauseTrigger)===null||b===void 0||b.call(a,!1),i.toggleCommandModeOff(a),a.resetRecording(c),{doNotProcessTranscription:!0};if(v.reset&&j(v.reset,E,C))return p!==void 0&&i.setText(a,c,p,d),{doNotProcessTranscription:!0};if(v.removeAllText&&j(v.removeAllText,E,C))return i.setText(a,c,"",d),{doNotProcessTranscription:!0};}}}]);}();return Pn.CommandUtils=i,Pn;}var Fn={},Qr;function Xd(){if(Qr)return Fn;Qr=1,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.Highlight=void 0;var r=ai(),e=li();var t=/*#__PURE__*/function(){function t(){_classCallCheck(this,t);}return _createClass(t,null,[{key:"setStateForPrimitive",value:function setStateForPrimitive(s,i){var o,a;i.selectionStart!==null&&(o=i.selectionStart),i.selectionEnd!==null&&(a=i.selectionEnd),s.isHighlighted=o!==a;}},{key:"setStateForGeneric",value:function setStateForGeneric(s,i){var o=window.getSelection();if(o!=null&&o.focusNode){var a=e.Cursor.getGenericElementCursorOffset(i,o,!0),l=e.Cursor.getGenericElementCursorOffset(i,o,!1);s.isHighlighted=a!==l;}}},{key:"setState",value:function setState(s,i){document.activeElement===i&&(r.Elements.isPrimitiveElement(i)?t.setStateForPrimitive(s,i):t.setStateForGeneric(s,i));}},{key:"removeForGeneric",value:function removeForGeneric(s,i){var o=window.getSelection();if(o){var a=e.Cursor.getGenericElementCursorOffset(i,o,!0);o.deleteFromDocument(),e.Cursor.setOffsetForGeneric(i,a),s.isHighlighted=!1;}}},{key:"removeForPrimitive",value:function removeForPrimitive(s,i){var o=i.selectionStart,a=i.selectionEnd,l=i.value;if(o&&a){var c=l.substring(0,o)+l.substring(a);i.value=c,e.Cursor.setOffsetForPrimitive(i,o,s.autoScroll);}s.isHighlighted=!1;}}]);}();return Fn.Highlight=t,Fn;}var Un={},eo;function Zd(){if(eo)return Un;eo=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.Padding=void 0;var r=ai(),e=li(),t=oi();var n=/*#__PURE__*/function(){function n(){_classCallCheck(this,n);}return _createClass(n,null,[{key:"setStateForPrimitiveElement",value:function setStateForPrimitiveElement(i,o){if(document.activeElement===o&&o.selectionStart!==null){var l=o.selectionStart,c=o.value[l-1],d=o.selectionEnd===null?l:o.selectionEnd,p=o.value[d];t.Text.isCharDefined(c)&&(i.startPadding=" ",i.numberOfSpacesBeforeNewText=1),t.Text.isCharDefined(p)&&(i.endPadding=" ",i.numberOfSpacesAfterNewText=1),i.isCursorAtEnd=o.value.length===d;return;}var a=o.value[o.value.length-1];t.Text.isCharDefined(a)&&(i.startPadding=" ",i.numberOfSpacesBeforeNewText=1),i.isCursorAtEnd=!0;}},{key:"setStateForGenericElement",value:function setStateForGenericElement(i,o){var a,l,c;if(document.activeElement===o){var p=window.getSelection();if(p!=null&&p.focusNode){var u=e.Cursor.getGenericElementCursorOffset(o,p,!0),g=(a=o.textContent)===null||a===void 0?void 0:a[u-1],b=e.Cursor.getGenericElementCursorOffset(o,p,!1),v=(l=o.textContent)===null||l===void 0?void 0:l[b];t.Text.isCharDefined(g)&&(i.startPadding=" "),t.Text.isCharDefined(v)&&(i.endPadding=" "),i.isCursorAtEnd=((c=o.textContent)===null||c===void 0?void 0:c.length)===b;return;}}var d=o.innerText.charAt(o.innerText.length-1);t.Text.isCharDefined(d)&&(i.startPadding=" "),i.isCursorAtEnd=!0;}},{key:"setState",value:function setState(i,o){r.Elements.isPrimitiveElement(o)?n.setStateForPrimitiveElement(i,o):n.setStateForGenericElement(i,o);}},{key:"adjustStateAfterRecodingPrimitiveElement",value:function adjustStateAfterRecodingPrimitiveElement(i,o){if(i.primitiveTextRecorded=!0,i.insertInCursorLocation&&document.activeElement===o&&(o.selectionEnd!==null&&(i.endPadding=i.endPadding+o.value.slice(o.selectionEnd)),o.selectionStart!==null)){i.startPadding=o.value.slice(0,o.selectionStart)+i.startPadding;return;}i.startPadding=o.value+i.startPadding;}},{key:"adjustSateForNoTextPrimitiveElement",value:function adjustSateForNoTextPrimitiveElement(i){i.numberOfSpacesBeforeNewText===1&&(i.startPadding=i.startPadding.substring(0,i.startPadding.length-1),i.numberOfSpacesBeforeNewText=0),i.numberOfSpacesAfterNewText===1&&(i.endPadding=i.endPadding.substring(1),i.numberOfSpacesAfterNewText=0);}}]);}();return Un.Padding=n,Un;}var to;function Wo(){if(to)return kn;to=1,Object.defineProperty(kn,"__esModule",{value:!0}),kn.Speech=void 0;var r=Wd(),e=Kd(),t=Jo(),n=Vo(),s=Xd(),i=ai(),o=Zd(),a=ar(),l=li(),c=oi();var d=/*#__PURE__*/function(){function d(){_classCallCheck(this,d);this.finalTranscript="",this.interimSpan=i.Elements.createInterimSpan(),this.finalSpan=i.Elements.createGenericSpan(),this.scrollingSpan=i.Elements.createGenericSpan(),this.isCursorAtEnd=!1,this.spansPopulated=!1,this.startPadding="",this.endPadding="",this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.recognizing=!1,this._displayInterimResults=!0,this.insertInCursorLocation=!0,this.autoScroll=!0,this.isRestarting=!1,this.isPaused=!1,this.isWaitingForCommand=!1,this.isTargetInShadow=!1,this.cannotBeStopped=!1,this.resetState();}return _createClass(d,[{key:"prepareBeforeStart",value:function prepareBeforeStart(u){var g,b;if(u!=null&&u.element)if(r.EventListeners.add(this,u),Array.isArray(u.element)){var E=u.element.find(function(C){return C===document.activeElement;})||u.element[0];if(!E)return;this.prepare(E);}else this.prepare(u.element);(u==null?void 0:u.displayInterimResults)!==void 0&&(this._displayInterimResults=u.displayInterimResults),u!=null&&u.textColor&&(this._finalTextColor=(g=u==null?void 0:u.textColor)===null||g===void 0?void 0:g["final"],i.Elements.applyCustomColors(this,u.textColor)),(u==null?void 0:u.insertInCursorLocation)!==void 0&&(this.insertInCursorLocation=u.insertInCursorLocation),(u==null?void 0:u.autoScroll)!==void 0&&(this.autoScroll=u.autoScroll),this._onResult=u==null?void 0:u.onResult,this._onPreResult=u==null?void 0:u.onPreResult,this._onStart=u==null?void 0:u.onStart,this._onStop=u==null?void 0:u.onStop,this._onError=u==null?void 0:u.onError,this.onCommandModeTrigger=u==null?void 0:u.onCommandModeTrigger,this.onPauseTrigger=u==null?void 0:u.onPauseTrigger,this._options=u,!((b=this._options)===null||b===void 0)&&b.commands&&(this.commands=t.CommandUtils.process(this._options.commands));}},{key:"prepare",value:function prepare(u){o.Padding.setState(this,u),s.Highlight.setState(this,u),this.isTargetInShadow=i.Elements.isInsideShadowDOM(u),i.Elements.isPrimitiveElement(u)?(this._primitiveElement=u,this._originalText=this._primitiveElement.value):(this._genericElement=u,this._originalText=this._genericElement.textContent);}// there was an attempt to optimize this by not having to restart the service and just reset state:
247
+ },{key:"execCommand",value:function execCommand(a,l,c,d,p){var u,g,b;var v=a.commands;if(!v||!d||!c)return;var E=((u=v.settings)===null||u===void 0?void 0:u.caseSensitive)===!0?l:l.toLowerCase(),w=s.Text.breakupIntoWordsArr(E),j=((g=v.settings)===null||g===void 0?void 0:g.substrings)===!1?i.checkIfMatchesWord:i.checkIfMatchesSubstring;if(v.commandMode&&j(v.commandMode,E,w))return a.setInterimColorToFinal(),setTimeout(function(){return i.toggleCommandModeOn(a);}),{doNotProcessTranscription:!1};if(!(v.commandMode&&!a.isWaitingForCommand)){if(v.stop&&j(v.stop,E,w))return i.toggleCommandModeOff(a),setTimeout(function(){return a.stop();}),{doNotProcessTranscription:!1};if(v.pause&&j(v.pause,E,w))return i.toggleCommandModeOff(a),a.setInterimColorToFinal(),setTimeout(function(){var X;a.isPaused=!0,(X=a.onPauseTrigger)===null||X===void 0||X.call(a,!0);}),{doNotProcessTranscription:!1};if(v.resume&&j(v.resume,E,w))return a.isPaused=!1,(b=a.onPauseTrigger)===null||b===void 0||b.call(a,!1),i.toggleCommandModeOff(a),a.resetRecording(c),{doNotProcessTranscription:!0};if(v.reset&&j(v.reset,E,w))return p!==void 0&&i.setText(a,c,p,d),{doNotProcessTranscription:!0};if(v.removeAllText&&j(v.removeAllText,E,w))return i.setText(a,c,"",d),{doNotProcessTranscription:!0};}}}]);}();return Pn.CommandUtils=i,Pn;}var Fn={},Qr;function Xd(){if(Qr)return Fn;Qr=1,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.Highlight=void 0;var r=ai(),e=li();var t=/*#__PURE__*/function(){function t(){_classCallCheck(this,t);}return _createClass(t,null,[{key:"setStateForPrimitive",value:function setStateForPrimitive(s,i){var o,a;i.selectionStart!==null&&(o=i.selectionStart),i.selectionEnd!==null&&(a=i.selectionEnd),s.isHighlighted=o!==a;}},{key:"setStateForGeneric",value:function setStateForGeneric(s,i){var o=window.getSelection();if(o!=null&&o.focusNode){var a=e.Cursor.getGenericElementCursorOffset(i,o,!0),l=e.Cursor.getGenericElementCursorOffset(i,o,!1);s.isHighlighted=a!==l;}}},{key:"setState",value:function setState(s,i){document.activeElement===i&&(r.Elements.isPrimitiveElement(i)?t.setStateForPrimitive(s,i):t.setStateForGeneric(s,i));}},{key:"removeForGeneric",value:function removeForGeneric(s,i){var o=window.getSelection();if(o){var a=e.Cursor.getGenericElementCursorOffset(i,o,!0);o.deleteFromDocument(),e.Cursor.setOffsetForGeneric(i,a),s.isHighlighted=!1;}}},{key:"removeForPrimitive",value:function removeForPrimitive(s,i){var o=i.selectionStart,a=i.selectionEnd,l=i.value;if(o&&a){var c=l.substring(0,o)+l.substring(a);i.value=c,e.Cursor.setOffsetForPrimitive(i,o,s.autoScroll);}s.isHighlighted=!1;}}]);}();return Fn.Highlight=t,Fn;}var Un={},eo;function Zd(){if(eo)return Un;eo=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.Padding=void 0;var r=ai(),e=li(),t=oi();var n=/*#__PURE__*/function(){function n(){_classCallCheck(this,n);}return _createClass(n,null,[{key:"setStateForPrimitiveElement",value:function setStateForPrimitiveElement(i,o){if(document.activeElement===o&&o.selectionStart!==null){var l=o.selectionStart,c=o.value[l-1],d=o.selectionEnd===null?l:o.selectionEnd,p=o.value[d];t.Text.isCharDefined(c)&&(i.startPadding=" ",i.numberOfSpacesBeforeNewText=1),t.Text.isCharDefined(p)&&(i.endPadding=" ",i.numberOfSpacesAfterNewText=1),i.isCursorAtEnd=o.value.length===d;return;}var a=o.value[o.value.length-1];t.Text.isCharDefined(a)&&(i.startPadding=" ",i.numberOfSpacesBeforeNewText=1),i.isCursorAtEnd=!0;}},{key:"setStateForGenericElement",value:function setStateForGenericElement(i,o){var a,l,c;if(document.activeElement===o){var p=window.getSelection();if(p!=null&&p.focusNode){var u=e.Cursor.getGenericElementCursorOffset(o,p,!0),g=(a=o.textContent)===null||a===void 0?void 0:a[u-1],b=e.Cursor.getGenericElementCursorOffset(o,p,!1),v=(l=o.textContent)===null||l===void 0?void 0:l[b];t.Text.isCharDefined(g)&&(i.startPadding=" "),t.Text.isCharDefined(v)&&(i.endPadding=" "),i.isCursorAtEnd=((c=o.textContent)===null||c===void 0?void 0:c.length)===b;return;}}var d=o.innerText.charAt(o.innerText.length-1);t.Text.isCharDefined(d)&&(i.startPadding=" "),i.isCursorAtEnd=!0;}},{key:"setState",value:function setState(i,o){r.Elements.isPrimitiveElement(o)?n.setStateForPrimitiveElement(i,o):n.setStateForGenericElement(i,o);}},{key:"adjustStateAfterRecodingPrimitiveElement",value:function adjustStateAfterRecodingPrimitiveElement(i,o){if(i.primitiveTextRecorded=!0,i.insertInCursorLocation&&document.activeElement===o&&(o.selectionEnd!==null&&(i.endPadding=i.endPadding+o.value.slice(o.selectionEnd)),o.selectionStart!==null)){i.startPadding=o.value.slice(0,o.selectionStart)+i.startPadding;return;}i.startPadding=o.value+i.startPadding;}},{key:"adjustSateForNoTextPrimitiveElement",value:function adjustSateForNoTextPrimitiveElement(i){i.numberOfSpacesBeforeNewText===1&&(i.startPadding=i.startPadding.substring(0,i.startPadding.length-1),i.numberOfSpacesBeforeNewText=0),i.numberOfSpacesAfterNewText===1&&(i.endPadding=i.endPadding.substring(1),i.numberOfSpacesAfterNewText=0);}}]);}();return Un.Padding=n,Un;}var to;function Wo(){if(to)return kn;to=1,Object.defineProperty(kn,"__esModule",{value:!0}),kn.Speech=void 0;var r=Wd(),e=Kd(),t=Jo(),n=Vo(),s=Xd(),i=ai(),o=Zd(),a=ar(),l=li(),c=oi();var d=/*#__PURE__*/function(){function d(){_classCallCheck(this,d);this.finalTranscript="",this.interimSpan=i.Elements.createInterimSpan(),this.finalSpan=i.Elements.createGenericSpan(),this.scrollingSpan=i.Elements.createGenericSpan(),this.isCursorAtEnd=!1,this.spansPopulated=!1,this.startPadding="",this.endPadding="",this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.recognizing=!1,this._displayInterimResults=!0,this.insertInCursorLocation=!0,this.autoScroll=!0,this.isRestarting=!1,this.isPaused=!1,this.isWaitingForCommand=!1,this.isTargetInShadow=!1,this.cannotBeStopped=!1,this.resetState();}return _createClass(d,[{key:"prepareBeforeStart",value:function prepareBeforeStart(u){var g,b;if(u!=null&&u.element)if(r.EventListeners.add(this,u),Array.isArray(u.element)){var E=u.element.find(function(w){return w===document.activeElement;})||u.element[0];if(!E)return;this.prepare(E);}else this.prepare(u.element);(u==null?void 0:u.displayInterimResults)!==void 0&&(this._displayInterimResults=u.displayInterimResults),u!=null&&u.textColor&&(this._finalTextColor=(g=u==null?void 0:u.textColor)===null||g===void 0?void 0:g["final"],i.Elements.applyCustomColors(this,u.textColor)),(u==null?void 0:u.insertInCursorLocation)!==void 0&&(this.insertInCursorLocation=u.insertInCursorLocation),(u==null?void 0:u.autoScroll)!==void 0&&(this.autoScroll=u.autoScroll),this._onResult=u==null?void 0:u.onResult,this._onPreResult=u==null?void 0:u.onPreResult,this._onStart=u==null?void 0:u.onStart,this._onStop=u==null?void 0:u.onStop,this._onError=u==null?void 0:u.onError,this.onCommandModeTrigger=u==null?void 0:u.onCommandModeTrigger,this.onPauseTrigger=u==null?void 0:u.onPauseTrigger,this._options=u,!((b=this._options)===null||b===void 0)&&b.commands&&(this.commands=t.CommandUtils.process(this._options.commands));}},{key:"prepare",value:function prepare(u){o.Padding.setState(this,u),s.Highlight.setState(this,u),this.isTargetInShadow=i.Elements.isInsideShadowDOM(u),i.Elements.isPrimitiveElement(u)?(this._primitiveElement=u,this._originalText=this._primitiveElement.value):(this._genericElement=u,this._originalText=this._genericElement.textContent);}// there was an attempt to optimize this by not having to restart the service and just reset state:
248
248
  // unfortunately it did not work because the service would still continue firing the intermediate and final results
249
249
  // into the new position
250
250
  },{key:"resetRecording",value:function resetRecording(u){this.isRestarting=!0,this.stop(!0),this.resetState(!0),this.start(u,!0);}// prettier-ignore
251
- },{key:"updateElements",value:function updateElements(u,g,b){var v;var E=c.Text.capitalize(g);if(this.finalTranscript===E&&u==="")return;e.PreResultUtils.process(this,b,u==="",this._onPreResult,this._options)&&(u="",b="");var C=this.commands&&t.CommandUtils.execCommand(this,b,this._options,this._primitiveElement||this._genericElement,this._originalText);if(C){if(C.doNotProcessTranscription)return;u="",b="";}if(this.isPaused||this.isWaitingForCommand)return;(v=this._onResult)===null||v===void 0||v.call(this,b,u===""),this.finalTranscript=E,this._displayInterimResults||(u="");var j=this.finalTranscript===""&&u==="";this._primitiveElement?this.updatePrimitiveElement(this._primitiveElement,u,j):this._genericElement&&this.updateGenericElement(this._genericElement,u,j);}// prettier-ignore
251
+ },{key:"updateElements",value:function updateElements(u,g,b){var v;var E=c.Text.capitalize(g);if(this.finalTranscript===E&&u==="")return;e.PreResultUtils.process(this,b,u==="",this._onPreResult,this._options)&&(u="",b="");var w=this.commands&&t.CommandUtils.execCommand(this,b,this._options,this._primitiveElement||this._genericElement,this._originalText);if(w){if(w.doNotProcessTranscription)return;u="",b="";}if(this.isPaused||this.isWaitingForCommand)return;(v=this._onResult)===null||v===void 0||v.call(this,b,u===""),this.finalTranscript=E,this._displayInterimResults||(u="");var j=this.finalTranscript===""&&u==="";this._primitiveElement?this.updatePrimitiveElement(this._primitiveElement,u,j):this._genericElement&&this.updateGenericElement(this._genericElement,u,j);}// prettier-ignore
252
252
  // remember that padding values here contain actual text left and right
253
- },{key:"updatePrimitiveElement",value:function updatePrimitiveElement(u,g,b){this.isHighlighted&&s.Highlight.removeForPrimitive(this,u),this.primitiveTextRecorded||o.Padding.adjustStateAfterRecodingPrimitiveElement(this,u),b&&o.Padding.adjustSateForNoTextPrimitiveElement(this);var v=this.startPadding+this.finalTranscript+g;if(u.value=v+this.endPadding,!this.isTargetInShadow){var E=v.length+this.numberOfSpacesAfterNewText;l.Cursor.setOffsetForPrimitive(u,E,this.autoScroll);}this.autoScroll&&a.Browser.IS_SAFARI()&&this.isCursorAtEnd&&n.AutoScroll.scrollSafariPrimitiveToEnd(u);}},{key:"updateGenericElement",value:function updateGenericElement(u,g,b){this.isHighlighted&&s.Highlight.removeForGeneric(this,u),this.spansPopulated||i.Elements.appendSpans(this,u);var v=(b?"":this.startPadding)+c.Text.lineBreak(this.finalTranscript);this.finalSpan.innerHTML=v;var E=n.AutoScroll.isRequired(this.autoScroll,u);n.AutoScroll.changeStateIfNeeded(this,E);var C=c.Text.lineBreak(g)+(b?"":this.endPadding);this.interimSpan.innerHTML=C,a.Browser.IS_SAFARI()&&this.insertInCursorLocation&&l.Cursor.setOffsetForSafariGeneric(u,v.length+C.length),E&&n.AutoScroll.scrollGeneric(this,u),b&&(this.scrollingSpan.innerHTML="");}},{key:"finalise",value:function finalise(u){this._genericElement&&(u?(this.finalSpan=i.Elements.createGenericSpan(),this.setInterimColorToFinal(),this.interimSpan=i.Elements.createInterimSpan(),this.scrollingSpan=i.Elements.createGenericSpan()):this._genericElement.textContent=this._genericElement.textContent,this.spansPopulated=!1),r.EventListeners.remove(this);}},{key:"setInterimColorToFinal",value:function setInterimColorToFinal(){this.interimSpan.style.color=this._finalTextColor||"black";}},{key:"resetState",value:function resetState(u){this._primitiveElement=void 0,this._genericElement=void 0,this.finalTranscript="",this.finalSpan.innerHTML="",this.interimSpan.innerHTML="",this.scrollingSpan.innerHTML="",this.startPadding="",this.endPadding="",this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,u||(this.stopTimeout=void 0);}},{key:"setStateOnStart",value:function setStateOnStart(){var u;this.recognizing=!0,this.isRestarting?this.isRestarting=!1:(u=this._onStart)===null||u===void 0||u.call(this);}},{key:"setStateOnStop",value:function setStateOnStop(){var u;this.recognizing=!1,this.isRestarting||(u=this._onStop)===null||u===void 0||u.call(this);}},{key:"setStateOnError",value:function setStateOnError(u){var g;(g=this._onError)===null||g===void 0||g.call(this,u),this.recognizing=!1;}}]);}();return kn.Speech=d,kn;}var no;function Yd(){if(no)return Cn;no=1,Object.defineProperty(Cn,"__esModule",{value:!0}),Cn.WebSpeech=void 0;var r=Jd(),e=ar(),t=Wo();var n=/*#__PURE__*/function(_t$Speech){function n(){_classCallCheck(this,n);return _callSuper(this,n);}_inherits(n,_t$Speech);return _createClass(n,[{key:"start",value:function start(i){var o;this._extractText===void 0&&(this._extractText=e.Browser.IS_SAFARI()?r.WebSpeechTranscript.extractSafari:r.WebSpeechTranscript.extract),this.validate()&&(this.prepareBeforeStart(i),this.instantiateService(i),(o=this._service)===null||o===void 0||o.start(),this._translations=i==null?void 0:i.translations);}},{key:"validate",value:function validate(){return n.getAPI()?!0:(this.error("Speech Recognition is unsupported"),!1);}},{key:"instantiateService",value:function instantiateService(i){var o,a;var l=n.getAPI();this._service=new l(),this._service.continuous=!0,this._service.interimResults=(o=i==null?void 0:i.displayInterimResults)!==null&&o!==void 0?o:!0,this._service.lang=((a=i==null?void 0:i.language)===null||a===void 0?void 0:a.trim())||"en-US",this.setEvents();}},{key:"setEvents",value:function setEvents(){var _this97=this;this._service&&(this._service.onstart=function(){_this97.setStateOnStart();},this._service.onerror=function(i){e.Browser.IS_SAFARI()&&i.message==="Another request is started"||i.error==="aborted"&&_this97.isRestarting||i.error!=="no-speech"&&_this97.error(i.message||i.error);},this._service.onaudioend=function(){_this97.setStateOnStop();},this._service.onend=function(){_this97._stopping=!1;},this._service.onresult=function(i){if(_typeof(i.results)>"u"&&_this97._service)_this97._service.onend=null,_this97._service.stop();else if(_this97._extractText&&!_this97._stopping){var _this97$_extractText=_this97._extractText(i,_this97.finalTranscript,_this97._translations),o=_this97$_extractText.interimTranscript,a=_this97$_extractText.finalTranscript,l=_this97$_extractText.newText;_this97.updateElements(o,a,l);}});}},{key:"stop",value:function stop(i){var o;this._stopping=!0,(o=this._service)===null||o===void 0||o.stop(),this.finalise(i);}},{key:"error",value:function error(i){console.error(i),this.setStateOnError(i),this.stop();}}],[{key:"getAPI",value:function getAPI(){return window.webkitSpeechRecognition||window.SpeechRecognition;}}]);}(t.Speech);return Cn.WebSpeech=n,Cn;}var Hn={},so;function Qd(){if(so)return Hn;so=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.GlobalState=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"doubleClickDetector",value:function doubleClickDetector(){return r.doubleClickPending?!0:(r.doubleClickPending=!0,setTimeout(function(){r.doubleClickPending=!1;},300),!1);}}]);}();return Hn.GlobalState=r,r.doubleClickPending=!1,Hn;}var jn={},qn={},io;function eh(){if(io)return qn;io=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.PreventConnectionStop=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"applyPrevention",value:function applyPrevention(t){clearTimeout(t._manualConnectionStopPrevention),t.cannotBeStopped=!0,t._manualConnectionStopPrevention=setTimeout(function(){t.cannotBeStopped=!1;},800);}},{key:"clearPrevention",value:function clearPrevention(t){clearTimeout(t._manualConnectionStopPrevention),t.cannotBeStopped=!1;}}]);}();return qn.PreventConnectionStop=r,qn;}var $n={},Gn={},ro;function th(){return ro||(ro=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.README_URL=void 0,Gn.README_URL="https://github.com/OvidijusParsiunas/speech-to-element"),Gn;}var oo;function nh(){if(oo)return $n;oo=1,Object.defineProperty($n,"__esModule",{value:!0}),$n.AzureSpeechConfig=void 0;var r=th();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"validateOptions",value:function validateOptions(n,s){return s?!s.subscriptionKey&&!s.token&&!s.retrieveToken?(n("Please define a 'subscriptionKey', 'token' or 'retrieveToken' property - more info: ".concat(r.README_URL)),!1):s.region?!0:(n("Please define a 'region' property - more info: ".concat(r.README_URL)),!1):(n("Please provide subscription details - more info: ".concat(r.README_URL)),!1);}},{key:"getNewSpeechConfig",value:function(){var _getNewSpeechConfig=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee181(n,s){return _regenerator().w(function(_context181){while(1)switch(_context181.n){case 0:if(!s.region){_context181.n=1;break;}return _context181.a(2,s.subscriptionKey?n.fromSubscription(s.subscriptionKey.trim(),s.region.trim()):s.token?n.fromAuthorizationToken(s.token.trim(),s.region.trim()):s.retrieveToken?s.retrieveToken().then(function(i){return s.region?n.fromAuthorizationToken((i==null?void 0:i.trim())||"",s.region.trim()):null;})["catch"](function(i){return console.error(i),null;}):null);case 1:return _context181.a(2);}},_callee181);}));function getNewSpeechConfig(_x335,_x336){return _getNewSpeechConfig.apply(this,arguments);}return getNewSpeechConfig;}()},{key:"process",value:function process(n,s){s.endpointId&&(n.endpointId=s.endpointId.trim()),s.language&&(n.speechRecognitionLanguage=s.language.trim());}},{key:"get",value:function(){var _get2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee182(n,s){var i;return _regenerator().w(function(_context182){while(1)switch(_context182.n){case 0:_context182.n=1;return e.getNewSpeechConfig(n,s);case 1:i=_context182.v;return _context182.a(2,(i&&e.process(i,s),i));}},_callee182);}));function get(_x337,_x338){return _get2.apply(this,arguments);}return get;}()}]);}();return $n.AzureSpeechConfig=e,$n;}var zn={},ao;function sh(){if(ao)return zn;ao=1,Object.defineProperty(zn,"__esModule",{value:!0}),zn.StopTimeout=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"set",value:function set(t){t.stopTimeout=setTimeout(function(){return t.stop();},t.stopTimeoutMS);}},{key:"reset",value:function reset(t,n){t.stopTimeoutMS=n||r.DEFAULT_MS,r.stop(t),r.set(t);}},{key:"stop",value:function stop(t){t.stopTimeout&&clearTimeout(t.stopTimeout);}}]);}();return zn.StopTimeout=r,r.DEFAULT_MS=2e4,zn;}var Vn={},lo;function ih(){if(lo)return Vn;lo=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.AzureAudioConfig=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"get",value:function get(t,n){return n?t.fromMicrophoneInput(n):t.fromDefaultMicrophoneInput();}}]);}();return Vn.AzureAudioConfig=r,Vn;}var Jn={},co;function rh(){if(co)return Jn;co=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.AzureTranscript=void 0;var r=zo();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"extract",value:// newText is used to only send new text in onResult as finalTranscript is continuously accumulated
253
+ },{key:"updatePrimitiveElement",value:function updatePrimitiveElement(u,g,b){this.isHighlighted&&s.Highlight.removeForPrimitive(this,u),this.primitiveTextRecorded||o.Padding.adjustStateAfterRecodingPrimitiveElement(this,u),b&&o.Padding.adjustSateForNoTextPrimitiveElement(this);var v=this.startPadding+this.finalTranscript+g;if(u.value=v+this.endPadding,!this.isTargetInShadow){var E=v.length+this.numberOfSpacesAfterNewText;l.Cursor.setOffsetForPrimitive(u,E,this.autoScroll);}this.autoScroll&&a.Browser.IS_SAFARI()&&this.isCursorAtEnd&&n.AutoScroll.scrollSafariPrimitiveToEnd(u);}},{key:"updateGenericElement",value:function updateGenericElement(u,g,b){this.isHighlighted&&s.Highlight.removeForGeneric(this,u),this.spansPopulated||i.Elements.appendSpans(this,u);var v=(b?"":this.startPadding)+c.Text.lineBreak(this.finalTranscript);this.finalSpan.innerHTML=v;var E=n.AutoScroll.isRequired(this.autoScroll,u);n.AutoScroll.changeStateIfNeeded(this,E);var w=c.Text.lineBreak(g)+(b?"":this.endPadding);this.interimSpan.innerHTML=w,a.Browser.IS_SAFARI()&&this.insertInCursorLocation&&l.Cursor.setOffsetForSafariGeneric(u,v.length+w.length),E&&n.AutoScroll.scrollGeneric(this,u),b&&(this.scrollingSpan.innerHTML="");}},{key:"finalise",value:function finalise(u){this._genericElement&&(u?(this.finalSpan=i.Elements.createGenericSpan(),this.setInterimColorToFinal(),this.interimSpan=i.Elements.createInterimSpan(),this.scrollingSpan=i.Elements.createGenericSpan()):this._genericElement.textContent=this._genericElement.textContent,this.spansPopulated=!1),r.EventListeners.remove(this);}},{key:"setInterimColorToFinal",value:function setInterimColorToFinal(){this.interimSpan.style.color=this._finalTextColor||"black";}},{key:"resetState",value:function resetState(u){this._primitiveElement=void 0,this._genericElement=void 0,this.finalTranscript="",this.finalSpan.innerHTML="",this.interimSpan.innerHTML="",this.scrollingSpan.innerHTML="",this.startPadding="",this.endPadding="",this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,u||(this.stopTimeout=void 0);}},{key:"setStateOnStart",value:function setStateOnStart(){var u;this.recognizing=!0,this.isRestarting?this.isRestarting=!1:(u=this._onStart)===null||u===void 0||u.call(this);}},{key:"setStateOnStop",value:function setStateOnStop(){var u;this.recognizing=!1,this.isRestarting||(u=this._onStop)===null||u===void 0||u.call(this);}},{key:"setStateOnError",value:function setStateOnError(u){var g;(g=this._onError)===null||g===void 0||g.call(this,u),this.recognizing=!1;}}]);}();return kn.Speech=d,kn;}var no;function Yd(){if(no)return wn;no=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.WebSpeech=void 0;var r=Jd(),e=ar(),t=Wo();var n=/*#__PURE__*/function(_t$Speech){function n(){_classCallCheck(this,n);return _callSuper(this,n);}_inherits(n,_t$Speech);return _createClass(n,[{key:"start",value:function start(i){var o;this._extractText===void 0&&(this._extractText=e.Browser.IS_SAFARI()?r.WebSpeechTranscript.extractSafari:r.WebSpeechTranscript.extract),this.validate()&&(this.prepareBeforeStart(i),this.instantiateService(i),(o=this._service)===null||o===void 0||o.start(),this._translations=i==null?void 0:i.translations);}},{key:"validate",value:function validate(){return n.getAPI()?!0:(this.error("Speech Recognition is unsupported"),!1);}},{key:"instantiateService",value:function instantiateService(i){var o,a;var l=n.getAPI();this._service=new l(),this._service.continuous=!0,this._service.interimResults=(o=i==null?void 0:i.displayInterimResults)!==null&&o!==void 0?o:!0,this._service.lang=((a=i==null?void 0:i.language)===null||a===void 0?void 0:a.trim())||"en-US",this.setEvents();}},{key:"setEvents",value:function setEvents(){var _this97=this;this._service&&(this._service.onstart=function(){_this97.setStateOnStart();},this._service.onerror=function(i){e.Browser.IS_SAFARI()&&i.message==="Another request is started"||i.error==="aborted"&&_this97.isRestarting||i.error!=="no-speech"&&_this97.error(i.message||i.error);},this._service.onaudioend=function(){_this97.setStateOnStop();},this._service.onend=function(){_this97._stopping=!1;},this._service.onresult=function(i){if(_typeof(i.results)>"u"&&_this97._service)_this97._service.onend=null,_this97._service.stop();else if(_this97._extractText&&!_this97._stopping){var _this97$_extractText=_this97._extractText(i,_this97.finalTranscript,_this97._translations),o=_this97$_extractText.interimTranscript,a=_this97$_extractText.finalTranscript,l=_this97$_extractText.newText;_this97.updateElements(o,a,l);}});}},{key:"stop",value:function stop(i){var o;this._stopping=!0,(o=this._service)===null||o===void 0||o.stop(),this.finalise(i);}},{key:"error",value:function error(i){console.error(i),this.setStateOnError(i),this.stop();}}],[{key:"getAPI",value:function getAPI(){return window.webkitSpeechRecognition||window.SpeechRecognition;}}]);}(t.Speech);return wn.WebSpeech=n,wn;}var Hn={},so;function Qd(){if(so)return Hn;so=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.GlobalState=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"doubleClickDetector",value:function doubleClickDetector(){return r.doubleClickPending?!0:(r.doubleClickPending=!0,setTimeout(function(){r.doubleClickPending=!1;},300),!1);}}]);}();return Hn.GlobalState=r,r.doubleClickPending=!1,Hn;}var jn={},qn={},io;function eh(){if(io)return qn;io=1,Object.defineProperty(qn,"__esModule",{value:!0}),qn.PreventConnectionStop=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"applyPrevention",value:function applyPrevention(t){clearTimeout(t._manualConnectionStopPrevention),t.cannotBeStopped=!0,t._manualConnectionStopPrevention=setTimeout(function(){t.cannotBeStopped=!1;},800);}},{key:"clearPrevention",value:function clearPrevention(t){clearTimeout(t._manualConnectionStopPrevention),t.cannotBeStopped=!1;}}]);}();return qn.PreventConnectionStop=r,qn;}var $n={},Gn={},ro;function th(){return ro||(ro=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.README_URL=void 0,Gn.README_URL="https://github.com/OvidijusParsiunas/speech-to-element"),Gn;}var oo;function nh(){if(oo)return $n;oo=1,Object.defineProperty($n,"__esModule",{value:!0}),$n.AzureSpeechConfig=void 0;var r=th();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"validateOptions",value:function validateOptions(n,s){return s?!s.subscriptionKey&&!s.token&&!s.retrieveToken?(n("Please define a 'subscriptionKey', 'token' or 'retrieveToken' property - more info: ".concat(r.README_URL)),!1):s.region?!0:(n("Please define a 'region' property - more info: ".concat(r.README_URL)),!1):(n("Please provide subscription details - more info: ".concat(r.README_URL)),!1);}},{key:"getNewSpeechConfig",value:function(){var _getNewSpeechConfig=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee181(n,s){return _regenerator().w(function(_context181){while(1)switch(_context181.n){case 0:if(!s.region){_context181.n=1;break;}return _context181.a(2,s.subscriptionKey?n.fromSubscription(s.subscriptionKey.trim(),s.region.trim()):s.token?n.fromAuthorizationToken(s.token.trim(),s.region.trim()):s.retrieveToken?s.retrieveToken().then(function(i){return s.region?n.fromAuthorizationToken((i==null?void 0:i.trim())||"",s.region.trim()):null;})["catch"](function(i){return console.error(i),null;}):null);case 1:return _context181.a(2);}},_callee181);}));function getNewSpeechConfig(_x335,_x336){return _getNewSpeechConfig.apply(this,arguments);}return getNewSpeechConfig;}()},{key:"process",value:function process(n,s){s.endpointId&&(n.endpointId=s.endpointId.trim()),s.language&&(n.speechRecognitionLanguage=s.language.trim());}},{key:"get",value:function(){var _get2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee182(n,s){var i;return _regenerator().w(function(_context182){while(1)switch(_context182.n){case 0:_context182.n=1;return e.getNewSpeechConfig(n,s);case 1:i=_context182.v;return _context182.a(2,(i&&e.process(i,s),i));}},_callee182);}));function get(_x337,_x338){return _get2.apply(this,arguments);}return get;}()}]);}();return $n.AzureSpeechConfig=e,$n;}var zn={},ao;function sh(){if(ao)return zn;ao=1,Object.defineProperty(zn,"__esModule",{value:!0}),zn.StopTimeout=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"set",value:function set(t){t.stopTimeout=setTimeout(function(){return t.stop();},t.stopTimeoutMS);}},{key:"reset",value:function reset(t,n){t.stopTimeoutMS=n||r.DEFAULT_MS,r.stop(t),r.set(t);}},{key:"stop",value:function stop(t){t.stopTimeout&&clearTimeout(t.stopTimeout);}}]);}();return zn.StopTimeout=r,r.DEFAULT_MS=2e4,zn;}var Vn={},lo;function ih(){if(lo)return Vn;lo=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.AzureAudioConfig=void 0;var r=/*#__PURE__*/function(){function r(){_classCallCheck(this,r);}return _createClass(r,null,[{key:"get",value:function get(t,n){return n?t.fromMicrophoneInput(n):t.fromDefaultMicrophoneInput();}}]);}();return Vn.AzureAudioConfig=r,Vn;}var Jn={},co;function rh(){if(co)return Jn;co=1,Object.defineProperty(Jn,"__esModule",{value:!0}),Jn.AzureTranscript=void 0;var r=zo();var e=/*#__PURE__*/function(){function e(){_classCallCheck(this,e);}return _createClass(e,null,[{key:"extract",value:// newText is used to only send new text in onResult as finalTranscript is continuously accumulated
254
254
  function extract(n,s,i,o){return o&&(n=r.Translate.translate(n,o)),i?{interimTranscript:"",finalTranscript:s+n,newText:n}:{interimTranscript:n,finalTranscript:s,newText:n};}}]);}();return Jn.AzureTranscript=e,Jn;}var ho;function oh(){if(ho)return jn;ho=1,Object.defineProperty(jn,"__esModule",{value:!0}),jn.Azure=void 0;var r=eh(),e=nh(),t=sh(),n=ih(),s=rh(),i=Wo();var o=/*#__PURE__*/function(_i$Speech){function o(){var _this98;_classCallCheck(this,o);_this98=_callSuper(this,o,arguments),_this98._newTextPadding="";return _this98;}_inherits(o,_i$Speech);return _createClass(o,[{key:"start",value:function start(l,c){this._newTextPadding="",this.stopTimeout===void 0&&t.StopTimeout.reset(this,l==null?void 0:l.stopAfterSilenceMs),this.prepareBeforeStart(l),this.startAsync(l),c||r.PreventConnectionStop.applyPrevention(this);}},{key:"startAsync",value:function(){var _startAsync=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee183(l){var c,_t53;return _regenerator().w(function(_context183){while(1)switch(_context183.n){case 0:_t53=this.validate(l);if(!_t53){_context183.n=2;break;}_context183.n=1;return this.instantiateService(l);case 1:this._translations=l==null?void 0:l.translations;(c=this._service)===null||c===void 0||c.startContinuousRecognitionAsync(function(){},this.error);case 2:return _context183.a(2);}},_callee183,this);}));function startAsync(_x339){return _startAsync.apply(this,arguments);}return startAsync;}()},{key:"validate",value:function validate(l){return o.getAPI()?e.AzureSpeechConfig.validateOptions(this.error.bind(this),l):(this.moduleNotFound(),!1);}},{key:"instantiateService",value:function(){var _instantiateService=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee184(l){var c,d,p,u,_l$autoLanguage,g,b,v,E;return _regenerator().w(function(_context184){while(1)switch(_context184.n){case 0:c=o.getAPI();d=n.AzureAudioConfig.get(c.AudioConfig,l.deviceId);_context184.n=1;return e.AzureSpeechConfig.get(c.SpeechConfig,l);case 1:p=_context184.v;if(p){if(l.autoLanguage&&l.autoLanguage.languages.length>0){_l$autoLanguage=l.autoLanguage,g=_l$autoLanguage.type,b=_l$autoLanguage.languages,v=b.slice(0,g==="Continuous"?10:4),E=c.AutoDetectSourceLanguageConfig.fromLanguages(v);g==="Continuous"&&(E.mode=1),u=c.SpeechRecognizer.FromConfig(p,E,d);}else u=new c.SpeechRecognizer(p,d);this.setEvents(u),this._service=u,l.retrieveToken&&this.retrieveTokenInterval(l.retrieveToken);}else this.error("Unable to contact Azure server");case 2:return _context184.a(2);}},_callee184,this);}));function instantiateService(_x340){return _instantiateService.apply(this,arguments);}return instantiateService;}()},{key:"setEvents",value:function setEvents(l){l.recognizing=this.onRecognizing.bind(this),l.recognized=this.onRecognized.bind(this),l.sessionStarted=this.onSessionStarted.bind(this),l.canceled=this.onCanceled.bind(this),l.sessionStopped=this.onSessionStopped.bind(this);}// prettier-ignore
255
255
  },{key:"onRecognizing",value:function onRecognizing(l,c){if(this._stopping)return;var _s$AzureTranscript$ex=s.AzureTranscript.extract(this._newTextPadding+c.result.text,this.finalTranscript,!1,this._translations),d=_s$AzureTranscript$ex.interimTranscript,p=_s$AzureTranscript$ex.finalTranscript,u=_s$AzureTranscript$ex.newText;t.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(d,p,u);}// prettier-ignore
256
- },{key:"onRecognized",value:function onRecognized(l,c){var d=c.result;switch(d.reason){case window.SpeechSDK.ResultReason.Canceled:break;case window.SpeechSDK.ResultReason.RecognizedSpeech:if(d.text&&!this._stopping){var _s$AzureTranscript$ex2=s.AzureTranscript.extract(this._newTextPadding+d.text,this.finalTranscript,!0,this._translations),p=_s$AzureTranscript$ex2.interimTranscript,u=_s$AzureTranscript$ex2.finalTranscript,g=_s$AzureTranscript$ex2.newText;t.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(p,u,g),u!==""&&(this._newTextPadding=" ");}break;}}},{key:"onCanceled",value:function onCanceled(l,c){c.reason===window.SpeechSDK.CancellationReason.Error&&this.error(c.errorDetails);}},{key:"onSessionStarted",value:function onSessionStarted(){r.PreventConnectionStop.clearPrevention(this),this.setStateOnStart();}},{key:"onSessionStopped",value:function onSessionStopped(){this._retrieveTokenInterval||clearInterval(this._retrieveTokenInterval),this._stopping=!1,this.setStateOnStop();}},{key:"retrieveTokenInterval",value:function retrieveTokenInterval(l){var _this99=this;this._retrieveTokenInterval=setInterval(function(){l==null||l().then(function(c){_this99._service&&(_this99._service.authorizationToken=(c==null?void 0:c.trim())||"");})["catch"](function(c){_this99.error(c);});},1e4);}},{key:"stop",value:function stop(l){var c;!l&&this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),this._stopping=!0,(c=this._service)===null||c===void 0||c.stopContinuousRecognitionAsync(),t.StopTimeout.stop(this),this.finalise(l);}},{key:"moduleNotFound",value:function moduleNotFound(){console.error("speech recognition module not found:"),console.error("please install the 'microsoft-cognitiveservices-speech-sdk' npm package or add a script tag: <script src=\"https://aka.ms/csspeech/jsbrowserpackageraw\"></script>"),this.setStateOnError("speech recognition module not found");}},{key:"error",value:function error(l){this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),console.error(l),this.setStateOnError(l),this.stop();}}],[{key:"getAPI",value:function getAPI(){return window.SpeechSDK;}}]);}(i.Speech);return jn.Azure=o,jn;}var uo;function ah(){if(uo)return xs;uo=1,Object.defineProperty(xs,"__esModule",{value:!0});var r=Yd(),e=Jo(),t=Qd(),n=oh();var s=/*#__PURE__*/function(){function s(){_classCallCheck(this,s);}return _createClass(s,null,[{key:"toggle",value:function toggle(o,a){var l,c;var d=o.toLocaleLowerCase().trim();!((l=t.GlobalState.service)===null||l===void 0)&&l.recognizing?this.stop():d==="webspeech"?s.startWebSpeech(a):d==="azure"?s.startAzure(a):(console.error("service not found - must be either 'webspeech' or 'azure'"),(c=a==null?void 0:a.onError)===null||c===void 0||c.call(a,"service not found - must be either 'webspeech' or 'azure'"));}},{key:"startWebSpeech",value:function startWebSpeech(o){s.stop()||(t.GlobalState.service=new r.WebSpeech(),t.GlobalState.service.start(o));}},{key:"isWebSpeechSupported",value:function isWebSpeechSupported(){return!!r.WebSpeech.getAPI();}},{key:"startAzure",value:function startAzure(o){var a;s.stop()||!((a=t.GlobalState.service)===null||a===void 0)&&a.cannotBeStopped||(t.GlobalState.service=new n.Azure(),t.GlobalState.service.start(o));}},{key:"stop",value:function stop(){var o;return t.GlobalState.doubleClickDetector()?!0:(!((o=t.GlobalState.service)===null||o===void 0)&&o.recognizing&&t.GlobalState.service.stop(),!1);}},{key:"endCommandMode",value:function endCommandMode(){t.GlobalState.service&&e.CommandUtils.toggleCommandModeOff(t.GlobalState.service);}}]);}();return xs["default"]=s,xs;}var lh=ah();var ws=/* @__PURE__ */Vd(lh);var ch=/*#__PURE__*/function(){function ch(e,t){_classCallCheck(this,ch);this._silenceMS=2e3,this._stop=!0,typeof t=="boolean"&&t===!1&&(this._stop=!1),typeof e=="number"&&(this._silenceMS=e);}return _createClass(ch,[{key:"setSilenceTimeout",value:function setSilenceTimeout(e,t){var _this100=this;this._silenceTimeout=setTimeout(function(){var n;(n=e.submit)==null||n.call(e),ws.stop(),_this100._stop||setTimeout(t,us.MICROPHONE_RESET_TIMEOUT_MS);},this._silenceMS);}},{key:"clearSilenceTimeout",value:function clearSilenceTimeout(){this._silenceTimeout&&clearTimeout(this._silenceTimeout);}},{key:"resetSilenceTimeout",value:function resetSilenceTimeout(e,t){this.clearSilenceTimeout(),this.setSilenceTimeout(e,t);}},{key:"onPause",value:function onPause(e,t,n){e?this.resetSilenceTimeout(t,n):this.clearSilenceTimeout();}}]);}();var rs=/*#__PURE__*/function(_ri){function rs(e,t,n){var _this101;_classCallCheck(this,rs);var s=_typeof(e.speechToText)=="object"?e.speechToText:{};_this101=_callSuper(this,rs,[s==null?void 0:s.button]);var _this101$processConfi=_this101.processConfiguration(t,e.speechToText),i=_this101$processConfi.serviceName,o=_this101$processConfi.processedConfig;if(_this101._addErrorMessage=n,i==="webspeech"&&!ws.isWebSpeechSupported())_this101.changeToUnsupported();else{var a=!e.textInput||!e.textInput.disabled;F.assignButtonEvents(_this101.elementRef,_this101.buttonClick.bind(_this101,t,a,i,o));}setTimeout(function(){_this101._validationHandler=e._validationHandler;});return _this101;}// prettier-ignore
257
- _inherits(rs,_ri);return _createClass(rs,[{key:"processConfiguration",value:function processConfiguration(e,t){var _n$displayInterimResu,_n$textColor,_n$translations,_n$commands,_n$events;var c;var n=_typeof(t)=="object"?t:{},s=_typeof(n.webSpeech)=="object"?n.webSpeech:{},i=n.azure||{},o=_objectSpread(_objectSpread({displayInterimResults:(_n$displayInterimResu=n.displayInterimResults)!==null&&_n$displayInterimResu!==void 0?_n$displayInterimResu:void 0,textColor:(_n$textColor=n.textColor)!==null&&_n$textColor!==void 0?_n$textColor:void 0,translations:(_n$translations=n.translations)!==null&&_n$translations!==void 0?_n$translations:void 0,commands:(_n$commands=n.commands)!==null&&_n$commands!==void 0?_n$commands:void 0,events:(_n$events=n.events)!==null&&_n$events!==void 0?_n$events:void 0},s),i),a=(c=n.commands)==null?void 0:c.submit;return a&&(o.onPreResult=function(d){return d.toLowerCase().includes(a)?(setTimeout(function(){var p;return(p=e.submit)==null?void 0:p.call(e);}),ws.endCommandMode(),{restart:!0,removeNewText:!0}):null;}),n.submitAfterSilence&&(this._silenceSubmit=new ch(n.submitAfterSilence,n.stopAfterSubmit)),{serviceName:rs.getServiceName(n),processedConfig:o};}},{key:"buttonClick",value:function buttonClick(e,t,n,s){var _this102=this;var i=s==null?void 0:s.events;e.removePlaceholderStyle(),ws.toggle(n,_objectSpread({insertInCursorLocation:!1,element:t?e.inputElementRef:void 0,onError:function onError(){var o;_this102.onError(),(o=_this102._silenceSubmit)==null||o.clearSilenceTimeout();},onStart:function onStart(){var o;_this102.changeToActive(),(o=i==null?void 0:i.onStart)==null||o.call(i);},onStop:function onStop(){var o,a,l;(o=_this102._validationHandler)==null||o.call(_this102),(a=_this102._silenceSubmit)==null||a.clearSilenceTimeout(),_this102.changeToDefault(),(l=i==null?void 0:i.onStop)==null||l.call(i);},onPauseTrigger:function onPauseTrigger(o){var a,l;(a=_this102._silenceSubmit)==null||a.onPause(o,e,_this102.elementRef.onclick),(l=i==null?void 0:i.onPauseTrigger)==null||l.call(i,o);},onPreResult:function onPreResult(o,a){var l;(l=i==null?void 0:i.onPreResult)==null||l.call(i,o,a);},onResult:function onResult(o,a){var l,c,d;a&&((l=_this102._validationHandler)==null||l.call(_this102)),(c=_this102._silenceSubmit)==null||c.resetSilenceTimeout(e,_this102.elementRef.onclick),(d=i==null?void 0:i.onResult)==null||d.call(i,o,a);},onCommandModeTrigger:function onCommandModeTrigger(o){var a;_this102.onCommandModeTrigger(o),(a=i==null?void 0:i.onCommandModeTrigger)==null||a.call(i,o);}},s));}},{key:"onCommandModeTrigger",value:function onCommandModeTrigger(e){e?this.changeToCommandMode():this.changeToActive();}},{key:"onError",value:function onError(){this._addErrorMessage("speechToText","speech input error");}}],[{key:"getServiceName",value:function getServiceName(e){return e.azure?"azure":"webspeech";}},{key:"toggleSpeechAfterSubmit",value:function toggleSpeechAfterSubmit(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;e[z](),t||setTimeout(function(){return e[z]();},rs.MICROPHONE_RESET_TIMEOUT_MS);}}]);}(ri);rs.MICROPHONE_RESET_TIMEOUT_MS=300;var us=rs;var yt=/*#__PURE__*/function(){// prettier-ignore
256
+ },{key:"onRecognized",value:function onRecognized(l,c){var d=c.result;switch(d.reason){case window.SpeechSDK.ResultReason.Canceled:break;case window.SpeechSDK.ResultReason.RecognizedSpeech:if(d.text&&!this._stopping){var _s$AzureTranscript$ex2=s.AzureTranscript.extract(this._newTextPadding+d.text,this.finalTranscript,!0,this._translations),p=_s$AzureTranscript$ex2.interimTranscript,u=_s$AzureTranscript$ex2.finalTranscript,g=_s$AzureTranscript$ex2.newText;t.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(p,u,g),u!==""&&(this._newTextPadding=" ");}break;}}},{key:"onCanceled",value:function onCanceled(l,c){c.reason===window.SpeechSDK.CancellationReason.Error&&this.error(c.errorDetails);}},{key:"onSessionStarted",value:function onSessionStarted(){r.PreventConnectionStop.clearPrevention(this),this.setStateOnStart();}},{key:"onSessionStopped",value:function onSessionStopped(){this._retrieveTokenInterval||clearInterval(this._retrieveTokenInterval),this._stopping=!1,this.setStateOnStop();}},{key:"retrieveTokenInterval",value:function retrieveTokenInterval(l){var _this99=this;this._retrieveTokenInterval=setInterval(function(){l==null||l().then(function(c){_this99._service&&(_this99._service.authorizationToken=(c==null?void 0:c.trim())||"");})["catch"](function(c){_this99.error(c);});},1e4);}},{key:"stop",value:function stop(l){var c;!l&&this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),this._stopping=!0,(c=this._service)===null||c===void 0||c.stopContinuousRecognitionAsync(),t.StopTimeout.stop(this),this.finalise(l);}},{key:"moduleNotFound",value:function moduleNotFound(){console.error("speech recognition module not found:"),console.error("please install the 'microsoft-cognitiveservices-speech-sdk' npm package or add a script tag: <script src=\"https://aka.ms/csspeech/jsbrowserpackageraw\"></script>"),this.setStateOnError("speech recognition module not found");}},{key:"error",value:function error(l){this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),console.error(l),this.setStateOnError(l),this.stop();}}],[{key:"getAPI",value:function getAPI(){return window.SpeechSDK;}}]);}(i.Speech);return jn.Azure=o,jn;}var uo;function ah(){if(uo)return xs;uo=1,Object.defineProperty(xs,"__esModule",{value:!0});var r=Yd(),e=Jo(),t=Qd(),n=oh();var s=/*#__PURE__*/function(){function s(){_classCallCheck(this,s);}return _createClass(s,null,[{key:"toggle",value:function toggle(o,a){var l,c;var d=o.toLocaleLowerCase().trim();!((l=t.GlobalState.service)===null||l===void 0)&&l.recognizing?this.stop():d==="webspeech"?s.startWebSpeech(a):d==="azure"?s.startAzure(a):(console.error("service not found - must be either 'webspeech' or 'azure'"),(c=a==null?void 0:a.onError)===null||c===void 0||c.call(a,"service not found - must be either 'webspeech' or 'azure'"));}},{key:"startWebSpeech",value:function startWebSpeech(o){s.stop()||(t.GlobalState.service=new r.WebSpeech(),t.GlobalState.service.start(o));}},{key:"isWebSpeechSupported",value:function isWebSpeechSupported(){return!!r.WebSpeech.getAPI();}},{key:"startAzure",value:function startAzure(o){var a;s.stop()||!((a=t.GlobalState.service)===null||a===void 0)&&a.cannotBeStopped||(t.GlobalState.service=new n.Azure(),t.GlobalState.service.start(o));}},{key:"stop",value:function stop(){var o;return t.GlobalState.doubleClickDetector()?!0:(!((o=t.GlobalState.service)===null||o===void 0)&&o.recognizing&&t.GlobalState.service.stop(),!1);}},{key:"endCommandMode",value:function endCommandMode(){t.GlobalState.service&&e.CommandUtils.toggleCommandModeOff(t.GlobalState.service);}}]);}();return xs["default"]=s,xs;}var lh=ah();var Cs=/* @__PURE__ */Vd(lh);var ch=/*#__PURE__*/function(){function ch(e,t){_classCallCheck(this,ch);this._silenceMS=2e3,this._stop=!0,typeof t=="boolean"&&t===!1&&(this._stop=!1),typeof e=="number"&&(this._silenceMS=e);}return _createClass(ch,[{key:"setSilenceTimeout",value:function setSilenceTimeout(e,t){var _this100=this;this._silenceTimeout=setTimeout(function(){var n;(n=e.submit)==null||n.call(e),Cs.stop(),_this100._stop||setTimeout(t,us.MICROPHONE_RESET_TIMEOUT_MS);},this._silenceMS);}},{key:"clearSilenceTimeout",value:function clearSilenceTimeout(){this._silenceTimeout&&clearTimeout(this._silenceTimeout);}},{key:"resetSilenceTimeout",value:function resetSilenceTimeout(e,t){this.clearSilenceTimeout(),this.setSilenceTimeout(e,t);}},{key:"onPause",value:function onPause(e,t,n){e?this.resetSilenceTimeout(t,n):this.clearSilenceTimeout();}}]);}();var rs=/*#__PURE__*/function(_ri){function rs(e,t,n){var _this101;_classCallCheck(this,rs);var s=_typeof(e.speechToText)=="object"?e.speechToText:{};_this101=_callSuper(this,rs,[s==null?void 0:s.button]);var _this101$processConfi=_this101.processConfiguration(t,e.speechToText),i=_this101$processConfi.serviceName,o=_this101$processConfi.processedConfig;if(_this101._addErrorMessage=n,i==="webspeech"&&!Cs.isWebSpeechSupported())_this101.changeToUnsupported();else{var a=!e.textInput||!e.textInput.disabled;F.assignButtonEvents(_this101.elementRef,_this101.buttonClick.bind(_this101,t,a,i,o));}setTimeout(function(){_this101._validationHandler=e._validationHandler;});return _this101;}// prettier-ignore
257
+ _inherits(rs,_ri);return _createClass(rs,[{key:"processConfiguration",value:function processConfiguration(e,t){var _n$displayInterimResu,_n$textColor,_n$translations,_n$commands,_n$events;var c;var n=_typeof(t)=="object"?t:{},s=_typeof(n.webSpeech)=="object"?n.webSpeech:{},i=n.azure||{},o=_objectSpread(_objectSpread({displayInterimResults:(_n$displayInterimResu=n.displayInterimResults)!==null&&_n$displayInterimResu!==void 0?_n$displayInterimResu:void 0,textColor:(_n$textColor=n.textColor)!==null&&_n$textColor!==void 0?_n$textColor:void 0,translations:(_n$translations=n.translations)!==null&&_n$translations!==void 0?_n$translations:void 0,commands:(_n$commands=n.commands)!==null&&_n$commands!==void 0?_n$commands:void 0,events:(_n$events=n.events)!==null&&_n$events!==void 0?_n$events:void 0},s),i),a=(c=n.commands)==null?void 0:c.submit;return a&&(o.onPreResult=function(d){return d.toLowerCase().includes(a)?(setTimeout(function(){var p;return(p=e.submit)==null?void 0:p.call(e);}),Cs.endCommandMode(),{restart:!0,removeNewText:!0}):null;}),n.submitAfterSilence&&(this._silenceSubmit=new ch(n.submitAfterSilence,n.stopAfterSubmit)),{serviceName:rs.getServiceName(n),processedConfig:o};}},{key:"buttonClick",value:function buttonClick(e,t,n,s){var _this102=this;var i=s==null?void 0:s.events;e.removePlaceholderStyle(),Cs.toggle(n,_objectSpread({insertInCursorLocation:!1,element:t?e.inputElementRef:void 0,onError:function onError(){var o;_this102.onError(),(o=_this102._silenceSubmit)==null||o.clearSilenceTimeout();},onStart:function onStart(){var o;_this102.changeToActive(),(o=i==null?void 0:i.onStart)==null||o.call(i);},onStop:function onStop(){var o,a,l;(o=_this102._validationHandler)==null||o.call(_this102),(a=_this102._silenceSubmit)==null||a.clearSilenceTimeout(),_this102.changeToDefault(),(l=i==null?void 0:i.onStop)==null||l.call(i);},onPauseTrigger:function onPauseTrigger(o){var a,l;(a=_this102._silenceSubmit)==null||a.onPause(o,e,_this102.elementRef.onclick),(l=i==null?void 0:i.onPauseTrigger)==null||l.call(i,o);},onPreResult:function onPreResult(o,a){var l;(l=i==null?void 0:i.onPreResult)==null||l.call(i,o,a);},onResult:function onResult(o,a){var l,c,d;a&&((l=_this102._validationHandler)==null||l.call(_this102)),(c=_this102._silenceSubmit)==null||c.resetSilenceTimeout(e,_this102.elementRef.onclick),(d=i==null?void 0:i.onResult)==null||d.call(i,o,a);},onCommandModeTrigger:function onCommandModeTrigger(o){var a;_this102.onCommandModeTrigger(o),(a=i==null?void 0:i.onCommandModeTrigger)==null||a.call(i,o);}},s));}},{key:"onCommandModeTrigger",value:function onCommandModeTrigger(e){e?this.changeToCommandMode():this.changeToActive();}},{key:"onError",value:function onError(){this._addErrorMessage("speechToText","speech input error");}}],[{key:"getServiceName",value:function getServiceName(e){return e.azure?"azure":"webspeech";}},{key:"toggleSpeechAfterSubmit",value:function toggleSpeechAfterSubmit(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;e[z](),t||setTimeout(function(){return e[z]();},rs.MICROPHONE_RESET_TIMEOUT_MS);}}]);}(ri);rs.MICROPHONE_RESET_TIMEOUT_MS=300;var us=rs;var yt=/*#__PURE__*/function(){// prettier-ignore
258
258
  function yt(e,t,n,s,i){var _this103=this;_classCallCheck(this,yt);this._attachments=[],this._fileCountLimit=99,this._acceptedFormat="",this._hiddenAttachments=/* @__PURE__ */new Set(),n.maxNumberOfFiles&&(this._fileCountLimit=n.maxNumberOfFiles),this._toggleContainerDisplay=s,this._fileAttachmentsContainerRef=i,n.acceptedFormats&&(this._acceptedFormat=n.acceptedFormats),setTimeout(function(){_this103._validationHandler=e._validationHandler,_this103._onInput=t.onInput;});}return _createClass(yt,[{key:"attemptAddFile",value:function attemptAddFile(e,t){var n;return yt.isFileTypeValid(e,this._acceptedFormat)?(this.addAttachmentBasedOnType(e,t,!0),(n=this._onInput)==null||n.call(this,!0),!0):!1;}},{key:"addAttachmentBasedOnType",value:function addAttachmentBasedOnType(e,t,n){var s=yt.getTypeFromBlob(e);if(s===q){var i=yt.createImageAttachment(t);this.addFileAttachment(e,q,i,n);}else if(s===L){var _i9=ps.createAudioAttachment(t);this.addFileAttachment(e,L,_i9,n);}else{var _i0=yt.createAnyFileAttachment(e.name);this.addFileAttachment(e,Vt,_i0,n);}}},{key:"addFileAttachment",value:function addFileAttachment(e,t,n,s){var a;var i=yt.createContainer(n);if(this._attachments.length>=this._fileCountLimit){var l=this._attachments[this._attachments.length-1].removeButton;l==null||l[z]();var c=this._fileAttachmentsContainerRef.children;this._fileAttachmentsContainerRef.insertBefore(i,c[0]);}else this._fileAttachmentsContainerRef.appendChild(i);var o={file:e,attachmentContainerElement:i,fileType:t};return s&&(o.removeButton=this.createRemoveAttachmentButton(o),i.appendChild(o.removeButton)),this._toggleContainerDisplay(!0),this._attachments.push(o),this._fileAttachmentsContainerRef.scrollTop=this._fileAttachmentsContainerRef.scrollHeight,(a=this._validationHandler)==null||a.call(this),o;}},{key:"createRemoveAttachmentButton",value:function createRemoveAttachmentButton(e){var t=S();t[m].add("remove-file-attachment-button"),t.onclick=this.removeAttachment.bind(this,e);var n=S();return n[m].add("x-icon"),n.innerText="×",t.appendChild(n),t;}},{key:"removeAttachment",value:function removeAttachment(e,t){var i,o;var n=this._attachments.findIndex(function(a){return a===e;});if(n<0)return;(i=this._onInput)==null||i.call(this,!!(t!=null&&t.isTrusted));var s=this._attachments[n].attachmentContainerElement;this._attachments.splice(n,1),ps.stopAttachmentPlayback(s),s.remove(),this._toggleContainerDisplay(!1),(o=this._validationHandler)==null||o.call(this);}},{key:"getFiles",value:function getFiles(){return Array.from(this._attachments).map(function(e){return _defineProperty(_defineProperty({},ee,e[ee]),"type",e.fileType);});}},{key:"hideAttachments",value:function hideAttachments(){var _this104=this;this._hiddenAttachments.clear(),this._attachments.forEach(function(e){setTimeout(function(){var t;return(t=e.removeButton)==null?void 0:t[z]();}),_this104._hiddenAttachments.add(e);});}},{key:"removeAttachments",value:function removeAttachments(){this._attachments.forEach(function(e){setTimeout(function(){var t;return(t=e.removeButton)==null?void 0:t[z]();});}),this._hiddenAttachments.clear();}},{key:"readdAttachments",value:function readdAttachments(){var _this105=this;var e;Array.from(this._hiddenAttachments).forEach(function(t){_this105._fileAttachmentsContainerRef.appendChild(t.attachmentContainerElement),_this105._attachments.push(t);}),(e=this._onInput)==null||e.call(this,!1),this._hiddenAttachments.clear();}}],[{key:"isFileTypeValid",value:function isFileTypeValid(e,t){if(t==="")return!0;var n=t.split(",");for(var s=0;s<n.length;s++){var i=n[s].trim();if(e.type===i)return!0;if(i.startsWith(".")){var o=i.slice(1);if(e.name.endsWith(o))return!0;}else{if(e.name.endsWith(i))return!0;if(i.endsWith("/*")&&e.type.startsWith(i.slice(0,-2)))return!0;}}return!1;}},{key:"getTypeFromBlob",value:function getTypeFromBlob(e){var t=e.type;return t.startsWith(q)?q:t.startsWith(L)?L:Vt;}},{key:"createImageAttachment",value:function createImageAttachment(e){var t=new Image();return t[A]=e,t[m].add("image-attachment"),t;}},{key:"createAnyFileAttachment",value:function createAnyFileAttachment(e){var t=S();t[m].add("border-bound-attachment"),Oe.IS_SAFARI&&t[m].add("border-bound-attachment-safari");var n=S();n[m].add("any-file-attachment-text");var s=S();return s[m].add("file-attachment-text-container"),s.appendChild(n),n.textContent=e,t.appendChild(s),t;}},{key:"createContainer",value:function createContainer(e){var t=S();return t[m].add("file-attachment"),t.appendChild(e),t;}}]);}();var mt=/*#__PURE__*/function(_yt){// prettier-ignore
259
259
  function mt(e,t,n,s,i){_classCallCheck(this,mt);return _callSuper(this,mt,[e,t,n,s,i]);}_inherits(mt,_yt);return _createClass(mt,[{key:"createTimer",value:function createTimer(e,t){var _this106=this;var n=0;var s=t!==void 0&&t<mt.TIMER_LIMIT_S?t:mt.TIMER_LIMIT_S;return setInterval(function(){var a;n+=1,n===s&&((a=_this106.stopPlaceholderCallback)==null||a.call(_this106),_this106.clearTimer()),n===600&&e[m].add("audio-placeholder-text-4-digits");var i=Math.floor(n/60),o=(n%60).toString().padStart(2,"0");e.textContent="".concat(i,":").concat(o);},1e3);}},{key:"createPlaceholderAudioAttachment",value:function createPlaceholderAudioAttachment(e){var t=mt.createAudioContainer(),n=S();n[m].add("audio-placeholder-text-3-digits");var s=S();s[m].add("file-attachment-text-container","audio-placeholder-text-3-digits-container"),s.appendChild(n);var i=_t.createSVGElement(Ti);return i[m].add("attachment-icon","stop-icon","not-removable-attachment-icon"),n.textContent="0:00",this._activePlaceholderTimer=this.createTimer(n,e),t.appendChild(s),this.addPlaceholderAudioAttachmentEvents(t,i,s),t;}},{key:"addPlaceholderAudioAttachmentEvents",value:function addPlaceholderAudioAttachmentEvents(e,t,n){var _this107=this;var s=function s(){return e.replaceChildren(t);};e.addEventListener("mouseenter",s);var i=function i(){return e.replaceChildren(n);};e.addEventListener("mouseleave",i);var o=function o(){var a;return(a=_this107.stopPlaceholderCallback)==null?void 0:a.call(_this107);};e.addEventListener(z,o);}},{key:"addPlaceholderAttachment",value:function addPlaceholderAttachment(e,t){var n=this.createPlaceholderAudioAttachment(t);this._activePlaceholderAttachment=this.addFileAttachment(new File([],""),L,n,!1),this.stopPlaceholderCallback=e;}// prettier-ignore
260
260
  },{key:"completePlaceholderAttachment",value:function completePlaceholderAttachment(e,t){var n=this._activePlaceholderAttachment;n&&(n[ee]=e,mt.addAudioElements(n.attachmentContainerElement.children[0],t),n.removeButton=this.createRemoveAttachmentButton(n),n.attachmentContainerElement.appendChild(n.removeButton),this._activePlaceholderAttachment=void 0,this.clearTimer());}},{key:"removePlaceholderAttachment",value:function removePlaceholderAttachment(){this._activePlaceholderAttachment&&(this.removeAttachment(this._activePlaceholderAttachment),this._activePlaceholderAttachment=void 0,this.clearTimer());}},{key:"clearTimer",value:function clearTimer(){this._activePlaceholderTimer!==void 0&&(clearInterval(this._activePlaceholderTimer),this._activePlaceholderTimer=void 0,this.stopPlaceholderCallback=void 0);}}],[{key:"createAudioContainer",value:function createAudioContainer(){var e=S();return e[m].add("border-bound-attachment","audio-attachment-icon-container"),Oe.IS_SAFARI&&e[m].add("border-bound-attachment-safari"),e;}},{key:"addAudioElements",value:function addAudioElements(e,t){var n=e.parentElement?F.cloneElement(e):e,s=S(L);s[A]=t;var i=_t.createSVGElement(Fo);i[m].add("attachment-icon","play-icon");var o=_t.createSVGElement(Ti);o[m].add("attachment-icon","stop-icon"),n.replaceChildren(i),s.onplay=function(){n.replaceChildren(o);},s.onpause=function(){n.replaceChildren(i),s.currentTime=0;},s.onended=function(){n.replaceChildren(i);},F.assignButtonEvents(n,function(){s.paused?s.play():s.pause();});}},{key:"createAudioAttachment",value:function createAudioAttachment(e){var t=mt.createAudioContainer();return mt.addAudioElements(t,e),t;}},{key:"stopAttachmentPlayback",value:function stopAttachmentPlayback(e){var t,n,s;(s=(n=(t=e.children[0])==null?void 0:t.children)==null?void 0:n[0])!=null&&s[m].contains("stop-icon")&&e.children[0][z]();}}]);}(yt);mt.TIMER_LIMIT_S=5999;var ps=mt;var dh=/*#__PURE__*/function(){function dh(){_classCallCheck(this,dh);}return _createClass(dh,null,[{key:"create",value:// prettier-ignore
261
261
  function create(e,t,n,s,i,o){return o===L?new ps(e,t,n,s,i):new yt(e,t,n,s,i);}}]);}();var gs=/*#__PURE__*/function(){function gs(e,t,n){_classCallCheck(this,gs);this._fileAttachmentsTypes=[],this.elementRef=this.createAttachmentContainer();var s=_typeof(n)=="object"&&!!n.displayFileAttachmentContainer;this.toggleContainerDisplay(s),e.appendChild(this.elementRef),t&&Object.assign(this.elementRef[_],t);}// prettier-ignore
262
262
  return _createClass(gs,[{key:"addType",value:function addType(e,t,n,s){var i=dh.create(e,t,n,this.toggleContainerDisplay.bind(this),this.elementRef,s);return this._fileAttachmentsTypes.push(i),i;}},{key:"createAttachmentContainer",value:function createAttachmentContainer(){var e=S();return e.id="file-attachment-container",e;}},{key:"toggleContainerDisplay",value:function toggleContainerDisplay(e){e?this.elementRef[_].display="block":this.elementRef.children.length===0&&(this.elementRef[_].display="none");}},{key:"getAllFileData",value:function getAllFileData(){var e=this._fileAttachmentsTypes.map(function(t){return t.getFiles();}).flat();return e.length>0?e:void 0;}},{key:"completePlaceholders",value:function(){var _completePlaceholders=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee186(){return _regenerator().w(function(_context186){while(1)switch(_context186.n){case 0:_context186.n=1;return Promise.all(this._fileAttachmentsTypes.map(/*#__PURE__*/function(){var _ref228=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee185(e){var t;return _regenerator().w(function(_context185){while(1)switch(_context185.n){case 0:return _context185.a(2,(t=e.stopPlaceholderCallback)==null?void 0:t.call(e));}},_callee185);}));return function(_x341){return _ref228.apply(this,arguments);};}()));case 1:return _context186.a(2);}},_callee186,this);}));function completePlaceholders(){return _completePlaceholders.apply(this,arguments);}return completePlaceholders;}()},{key:"addFilesToAnyType",value:function addFilesToAnyType(e){gs.addFilesToType(e,this._fileAttachmentsTypes);}},{key:"hideFiles",value:function hideFiles(){this._fileAttachmentsTypes.forEach(function(e){return e.hideAttachments();}),this.elementRef.replaceChildren(),this.toggleContainerDisplay(!1);}},{key:"removeHiddenFiles",value:function removeHiddenFiles(){this._fileAttachmentsTypes.forEach(function(e){return e.removeAttachments();});}},{key:"readdHiddenFiles",value:function readdHiddenFiles(){this._fileAttachmentsTypes.forEach(function(e){return e.readdAttachments();}),this.toggleContainerDisplay(!0);}},{key:"getNumberOfTypes",value:function getNumberOfTypes(){return this._fileAttachmentsTypes.length;}}],[{key:"addFilesToType",value:function addFilesToType(e,t){e.forEach(function(n){var s=new FileReader();s.readAsDataURL(n),s.onload=function(i){for(var o=0;o<t.length&&!t[o].attemptAddFile(n,i.target.result);o+=1);};});}}]);}();var Ze=/*#__PURE__*/function(){function Ze(e,t,n){_classCallCheck(this,Ze);this._isOpen=!1,this._contentRef=Ze.createModalContent(t,n==null?void 0:n.backgroundColor),this._buttonPanel=Ze.createButtonPanel(n==null?void 0:n.backgroundColor),this._elementRef=Ze.createContainer(this._contentRef,n),this._elementRef.appendChild(this._buttonPanel),e.appendChild(this._elementRef),this._backgroundPanelRef=Ze.createDarkBackgroundPanel(),e.appendChild(this._backgroundPanelRef),this.addWindowEvents(e);}return _createClass(Ze,[{key:"isOpen",value:function isOpen(){return this._isOpen;}},{key:"addButtons",value:function addButtons(){var _this108=this;for(var _len2=arguments.length,e=new Array(_len2),_key2=0;_key2<_len2;_key2++){e[_key2]=arguments[_key2];}e.forEach(function(t){ie.addAttributes(t),_this108._buttonPanel.appendChild(t);});}},{key:"close",value:function close(){var _this109=this;this._elementRef[m].remove("show-modal"),this._elementRef[m].add("hide-modal"),this._backgroundPanelRef[m].remove("show-modal-background"),this._backgroundPanelRef[m].add("hide-modal-background"),this._isOpen=!1,setTimeout(function(){_this109._elementRef[_].display="none",_this109._backgroundPanelRef[_].display="none";},Ze.MODAL_CLOSE_TIMEOUT_MS);}},{key:"displayModalElements",value:function displayModalElements(){this._elementRef[_].display="flex",this._elementRef[m].remove("hide-modal"),this._elementRef[m].add("show-modal"),this._backgroundPanelRef[_].display="block",this._backgroundPanelRef[m].remove("hide-modal-background"),this._backgroundPanelRef[m].add("show-modal-background"),this._isOpen=!0;}},{key:"openTextModal",value:function openTextModal(e){this._contentRef.innerHTML=e,this.displayModalElements();}},{key:"addCloseButton",value:function addCloseButton(e,t,n){var _this110=this;var s=t?Ze.createSVGButton(e):Ze.createTextButton(e);return this.addButtons(s),F.assignButtonEvents(s,function(){_this110.close(),setTimeout(function(){n==null||n();},140);}),s;}},{key:"addWindowEvents",value:function addWindowEvents(e){this.keyDownEvent=this.windowKeyDown.bind(this,e),window.addEventListener("keydown",this.keyDownEvent);}},{key:"windowKeyDown",value:function windowKeyDown(e,t){var n,s;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===de.ESCAPE?(this.close(),(n=this.extensionCloseCallback)==null||n.call(this)):t.key===de.ENTER&&(this.close(),(s=this.extensionCloseCallback)==null||s.call(this)));}}],[{key:"createContainer",value:function createContainer(e,t){var n=S();return n[m].add("modal"),n.appendChild(e),t&&delete t.backgroundColor,Object.assign(n[_],t),n;}},{key:"createModalContent",value:function createModalContent(e,t){var _n$m;var n=S();return(_n$m=n[m]).add.apply(_n$m,_toConsumableArray(e)),t&&(n[_].backgroundColor=t),S().appendChild(n),n;}},{key:"createButtonPanel",value:function createButtonPanel(e){var t=S();return t[m].add("modal-button-panel"),e&&(t[_].backgroundColor=e),t;}},{key:"createDarkBackgroundPanel",value:function createDarkBackgroundPanel(){var e=S();return e.id="modal-background-panel",e;}},{key:"createTextButton",value:function createTextButton(e){var t=S();return t[m].add("modal-button"),t.textContent=e,t;}},{key:"createSVGButton",value:function createSVGButton(e){var t=S();t[m].add("modal-button","modal-svg-button");var n=_t.createSVGElement(e);return n[m].add("modal-svg-button-icon"),t.appendChild(n),t;}},{key:"createTextModalFunc",value:function createTextModalFunc(e,t,n){var s;if(_typeof(t)=="object"&&(s=t[y])!=null&&s.infoModal){var i=new Ze(e,["modal-content"],t[y].infoModal.containerStyle);return i.addCloseButton("OK",!1,n),i.openTextModal.bind(i,t.infoModalTextMarkUp||"");}}}]);}();Ze.MODAL_CLOSE_TIMEOUT_MS=190;var qt=Ze;var Ws=/*#__PURE__*/function(_tn5){// prettier-ignore
263
- function Ws(e,t,n,s,i,o){var _this111;_classCallCheck(this,Ws);var p,u,g,b,v,E,C,j,X,Z;var a=ne.processPosition((p=n==null?void 0:n.button)==null?void 0:p.position),l=((b=(g=(u=n==null?void 0:n.button)==null?void 0:u.styles)==null?void 0:g[h])==null?void 0:b.content)||o,c=nt.tryCreateConfig("Upload File",(v=n==null?void 0:n.button)==null?void 0:v.tooltip);_this111=_callSuper(this,Ws,[Ws.createButtonElement(),i,a,c,n.button,l]);var d=_this111.createInnerElementsForStates(s,_this111.customStyles);_this111._inputElement=Ws.createInputElement((E=n==null?void 0:n[y])==null?void 0:E.acceptedFormats),_this111.addClickEvent(e,n),_this111.changeElementsByState(d.styles),_this111.reapplyStateStyle("styles"),_this111._fileAttachmentsType=t,_this111._openModalOnce=((j=(C=n[y])==null?void 0:C.infoModal)==null?void 0:j.openModalOnce)===!1||(Z=(X=n[y])==null?void 0:X.infoModal)==null?void 0:Z.openModalOnce;return _this111;}_inherits(Ws,_tn5);return _createClass(Ws,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e,t){return{styles:this.createInnerElements(e,"styles",t)};}},{key:"triggerImportPrompt",value:function triggerImportPrompt(e){e.onchange=this["import"].bind(this,e),e[z]();}},{key:"import",value:function _import(e){gs.addFilesToType(Array.from(e[y]||[]),[this._fileAttachmentsType]),e.value="";}},{key:"addClickEvent",value:function addClickEvent(e,t){var n=this.triggerImportPrompt.bind(this,this._inputElement),s=qt.createTextModalFunc(e,t,n);this.elementRef.onclick=this[z].bind(this,s);}},{key:"click",value:function click(e){e&&(this._openModalOnce===void 0||this._openModalOnce===!0)?(e(),this._openModalOnce===!0&&(this._openModalOnce=!1)):this.triggerImportPrompt(this._inputElement);}}],[{key:"createInputElement",value:function createInputElement(e){var t=S("input");return t.type=ee,t.accept=e||"",t.hidden=!0,t.multiple=!0,t;}},{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button"),e;}}]);}(tn);var gt=/*#__PURE__*/function(){function gt(){_classCallCheck(this,gt);}return _createClass(gt,null,[{key:"create",value:function create(e,t,n){var s=gt.createElement(n);gt.addEvents(s,e,t),e.appendChild(s);}},{key:"createElement",value:function createElement(e){var t=S();return t.id="drag-and-drop",_typeof(e)===B&&Object.assign(t[_],e),t;}},{key:"addEvents",value:function addEvents(e,t,n){t.ondragenter=function(s){s.preventDefault(),gt.display(e);},e.ondragleave=function(s){s.preventDefault(),gt.hide(e);},e.ondragover=function(s){s.preventDefault();},e.ondrop=function(s){s.preventDefault(),gt.uploadFile(n,s),gt.hide(e);};}},{key:"uploadFile",value:function uploadFile(e,t){var s;var n=(s=t.dataTransfer)==null?void 0:s[y];n&&e.addFilesToAnyType(Array.from(n));}},{key:"display",value:function display(e){e[_].display="block";}},{key:"hide",value:function hide(e){e[_].display="none";}},{key:"isEnabled",value:function isEnabled(e,t){return t!==void 0&&t===!1?!1:!!t||e.getNumberOfTypes()>0;}}]);}();var Lt=/*#__PURE__*/function(){function Lt(){_classCallCheck(this,Lt);}return _createClass(Lt,null,[{key:"validate",value:// prettier-ignore
263
+ function Ws(e,t,n,s,i,o){var _this111;_classCallCheck(this,Ws);var p,u,g,b,v,E,w,j,X,Z;var a=ne.processPosition((p=n==null?void 0:n.button)==null?void 0:p.position),l=((b=(g=(u=n==null?void 0:n.button)==null?void 0:u.styles)==null?void 0:g[h])==null?void 0:b.content)||o,c=nt.tryCreateConfig("Upload File",(v=n==null?void 0:n.button)==null?void 0:v.tooltip);_this111=_callSuper(this,Ws,[Ws.createButtonElement(),i,a,c,n.button,l]);var d=_this111.createInnerElementsForStates(s,_this111.customStyles);_this111._inputElement=Ws.createInputElement((E=n==null?void 0:n[y])==null?void 0:E.acceptedFormats),_this111.addClickEvent(e,n),_this111.changeElementsByState(d.styles),_this111.reapplyStateStyle("styles"),_this111._fileAttachmentsType=t,_this111._openModalOnce=((j=(w=n[y])==null?void 0:w.infoModal)==null?void 0:j.openModalOnce)===!1||(Z=(X=n[y])==null?void 0:X.infoModal)==null?void 0:Z.openModalOnce;return _this111;}_inherits(Ws,_tn5);return _createClass(Ws,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e,t){return{styles:this.createInnerElements(e,"styles",t)};}},{key:"triggerImportPrompt",value:function triggerImportPrompt(e){e.onchange=this["import"].bind(this,e),e[z]();}},{key:"import",value:function _import(e){gs.addFilesToType(Array.from(e[y]||[]),[this._fileAttachmentsType]),e.value="";}},{key:"addClickEvent",value:function addClickEvent(e,t){var n=this.triggerImportPrompt.bind(this,this._inputElement),s=qt.createTextModalFunc(e,t,n);this.elementRef.onclick=this[z].bind(this,s);}},{key:"click",value:function click(e){e&&(this._openModalOnce===void 0||this._openModalOnce===!0)?(e(),this._openModalOnce===!0&&(this._openModalOnce=!1)):this.triggerImportPrompt(this._inputElement);}}],[{key:"createInputElement",value:function createInputElement(e){var t=S("input");return t.type=ee,t.accept=e||"",t.hidden=!0,t.multiple=!0,t;}},{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button"),e;}}]);}(tn);var gt=/*#__PURE__*/function(){function gt(){_classCallCheck(this,gt);}return _createClass(gt,null,[{key:"create",value:function create(e,t,n){var s=gt.createElement(n);gt.addEvents(s,e,t),e.appendChild(s);}},{key:"createElement",value:function createElement(e){var t=S();return t.id="drag-and-drop",_typeof(e)===B&&Object.assign(t[_],e),t;}},{key:"addEvents",value:function addEvents(e,t,n){t.ondragenter=function(s){s.preventDefault(),gt.display(e);},e.ondragleave=function(s){s.preventDefault(),gt.hide(e);},e.ondragover=function(s){s.preventDefault();},e.ondrop=function(s){s.preventDefault(),gt.uploadFile(n,s),gt.hide(e);};}},{key:"uploadFile",value:function uploadFile(e,t){var s;var n=(s=t.dataTransfer)==null?void 0:s[y];n&&e.addFilesToAnyType(Array.from(n));}},{key:"display",value:function display(e){e[_].display="block";}},{key:"hide",value:function hide(e){e[_].display="none";}},{key:"isEnabled",value:function isEnabled(e,t){return t!==void 0&&t===!1?!1:!!t||e.getNumberOfTypes()>0;}}]);}();var Lt=/*#__PURE__*/function(){function Lt(){_classCallCheck(this,Lt);}return _createClass(Lt,null,[{key:"validate",value:// prettier-ignore
264
264
  function validate(e,t,n,s,i,o,a){var l=n.isSubmitProgrammaticallyDisabled?!1:e(s,i,a);return l?t.changeToSubmitIcon():t.changeToDisabledIcon(),o==null||o.addInputText(s||""),l;}// prettier-ignore
265
265
  },{key:"useValidationFunc",value:function(){var _useValidationFunc=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee187(e,t,n,s,i,o){var a,l,c;return _regenerator().w(function(_context187){while(1)switch(_context187.n){case 0:a=t.isTextInputEmpty()?"":t.inputElementRef.textContent;_context187.n=1;return n.completePlaceholders();case 1:l=n.getAllFileData(),c=l==null?void 0:l.map(function(d){return d[ee];});return _context187.a(2,Lt.validate(e,s,i,a,c,o));}},_callee187);}));function useValidationFunc(_x342,_x343,_x344,_x345,_x346,_x347){return _useValidationFunc.apply(this,arguments);}return useValidationFunc;}()// prettier-ignore
266
266
  },{key:"useValidationFuncProgrammatic",value:function(){var _useValidationFuncProgrammatic=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee188(e,t,n,s,i){var a,o;return _regenerator().w(function(_context188){while(1)switch(_context188.n){case 0:o=(a=t[y])==null?void 0:a.map(function(l){return l[ee];});return _context188.a(2,Lt.validate(e,n,s,t[h],o,i,!0));}},_callee188);}));function useValidationFuncProgrammatic(_x348,_x349,_x350,_x351,_x352){return _useValidationFuncProgrammatic.apply(this,arguments);}return useValidationFuncProgrammatic;}()},{key:"validateWebsocket",value:function validateWebsocket(e,t){var n=e.websocket,s=e.connectSettings;return n&&s.url!==st.URL&&!Se.canSendMessage(n)?(t.changeToDisabledIcon(),!1):!0;}// prettier-ignore
@@ -268,14 +268,14 @@ function validate(e,t,n,s,i,o,a){var l=n.isSubmitProgrammaticallyDisabled?!1:e(s
268
268
  },{key:"setUpDisabledButton",value:function setUpDisabledButton(e){xe.setPropertyValueIfDoesNotExist(e,["submit","container",x,"backgroundColor"],""),xe.setPropertyValueIfDoesNotExist(e,["disabled","container",x,"backgroundColor"],Xo),xe.setPropertyValueIfDoesNotExist(e.submit,["svg","styles",x,"filter"],""),xe.setPropertyValueIfDoesNotExist(e.disabled,["svg","styles",x,"filter"],"brightness(0) saturate(100%) invert(70%) sepia(0%) saturate(5564%) hue-rotate(207deg) brightness(100%) contrast(97%)"),xe.setPropertyValueIfDoesNotExist(e.disabled,[h,"styles",x,"color"],"grey"),$t.overwriteDefaultStyleWithSubmit(e,"disabled");}},{key:"process",value:function process(e){var t=JSON.parse(JSON.stringify(e||{}));return $t.overwriteDefaultStyleWithSubmit(t,"loading"),$t.overwriteDefaultStyleWithSubmit(t,"stop"),e!=null&&e.alwaysEnabled||$t.setUpDisabledButton(t),t;}}]);}();var Qn=/*#__PURE__*/function(_tn6){// prettier-ignore
269
269
  function Qn(e,t,n,s,i,o){var _this116;_classCallCheck(this,Qn);var a=$t.process(e.submitButtonStyles),l=uh,c=nt.tryCreateConfig("Submit",a==null?void 0:a.tooltip);_this116=_callSuper(this,Qn,[Qn.createButtonContainerElement(),l,a==null?void 0:a.position,c,a]),_this116._isSVGLoadingIconOverriden=!1,_this116.status={requestInProgress:!1,loadingActive:!1},_this116._messages=n,_this116._textInput=t,_this116._fileAttachments=i,_this116._innerElements=_this116.createInnerElementsForStates(),_this116._stopClicked={listener:function listener(){}},_this116._serviceIO=s,_this116._alwaysEnabled=!!(a!=null&&a.alwaysEnabled),e.disableSubmitButton=_this116.disableSubmitButton.bind(_assertThisInitialized(_this116),s),_this116.attemptOverwriteLoadingStyle(e),o.microphone&&_this116.setUpSpeechToText(o.microphone.button,e.speechToText),setTimeout(function(){var d;_this116._validationHandler=e._validationHandler,_this116.assignHandlers(_this116._validationHandler),(d=_this116._validationHandler)==null||d.call(_assertThisInitialized(_this116));});return _this116;}_inherits(Qn,_tn6);return _createClass(Qn,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(){var _this$createCustomEle=this.createCustomElements(),e=_this$createCustomEle.submit,t=_this$createCustomEle.loading,n=_this$createCustomEle.stop;return{submit:e,loading:t||[Qn.createLoadingIconElement()],stop:n||[Qn.createStopIconElement()],disabled:this.createDisabledIconElement(e)};}},{key:"createCustomElements",value:function createCustomElements(){var _this117=this;var e=dt.createCustomElements("submit",this.svg,this.customStyles),t={loading:void 0,stop:void 0};return Object.keys(t).forEach(function(n){var s=n,i=dt.createCustomElements(s,_this117.svg,_this117.customStyles);i&&(t[s]=i);}),t.submit=e||this.buildDefaultIconElement("submit-icon"),t;}},{key:"createDisabledIconElement",value:function createDisabledIconElement(e){return dt.createCustomElements("disabled",this.svg,this.customStyles)||[e[0].cloneNode(!0)];}// prettier-ignore
270
270
  },{key:"attemptOverwriteLoadingStyle",value:function attemptOverwriteLoadingStyle(e){var t,n,s,i,o,a,l,c,d;if(!((n=(t=this.customStyles)==null?void 0:t.submit)!=null&&n.svg||(o=(i=(s=this.customStyles)==null?void 0:s.loading)==null?void 0:i.svg)!=null&&o.content||(c=(l=(a=this.customStyles)==null?void 0:a.loading)==null?void 0:l[h])!=null&&c.content)&&(e.displayLoadingBubble===void 0||e.displayLoadingBubble===!0)){var p=S("style");p.textContent="\n .loading-button > * {\n filter: brightness(0) saturate(100%) invert(72%) sepia(0%) saturate(3044%) hue-rotate(322deg) brightness(100%)\n contrast(96%) !important;\n }",(d=e.shadowRoot)==null||d.appendChild(p),this._isSVGLoadingIconOverriden=!0;}}},{key:"assignHandlers",value:function assignHandlers(e){this._serviceIO.completionsHandlers={onFinish:this.resetSubmit.bind(this,e)},this._serviceIO.streamHandlers={onOpen:this.changeToStopIcon.bind(this),onClose:this.resetSubmit.bind(this,e),stopClicked:this._stopClicked};var t=this._serviceIO.stream;_typeof(t)=="object"&&typeof t.simulation=="number"&&(this._serviceIO.streamHandlers.simulationInterim=t.simulation);}},{key:"setUpSpeechToText",value:function setUpSpeechToText(e,t){this._microphoneButton=e,this._stopSTTAfterSubmit=_typeof(t)=="object"?t.stopAfterSubmit:!1;}},{key:"resetSubmit",value:function resetSubmit(e){this.status.requestInProgress=!1,this.status.loadingActive=!1,e();}},{key:"submitFromInput",value:function(){var _submitFromInput=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee190(){var _this118=this;var e,t;return _regenerator().w(function(_context190){while(1)switch(_context190.n){case 0:_context190.n=1;return this._fileAttachments.completePlaceholders();case 1:e=this._fileAttachments.getAllFileData();if(this._textInput.isTextInputEmpty())this.attemptSubmit(_defineProperty(_defineProperty({},h,""),y,e));else{t=this._textInput.inputElementRef.innerText.trim();this.attemptSubmit(_defineProperty(_defineProperty({},h,t),y,e));}(Oe.IS_SAFARI||Oe.IS_MOBILE)&&setTimeout(function(){return Wt.focusEndOfInput(_this118._textInput.inputElementRef);});case 2:return _context190.a(2);}},_callee190,this);}));function submitFromInput(){return _submitFromInput.apply(this,arguments);}return submitFromInput;}()},{key:"programmaticSubmit",value:function(){var _programmaticSubmit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee191(e){var _this119=this;var t;return _regenerator().w(function(_context191){while(1)switch(_context191.n){case 0:typeof e=="string"&&(e=ne.processSubmitUserMessage(e));t=_defineProperty({},h,e[h]);e[y]&&(t[y]=Array.from(e[y]).map(function(n){return{file:n,type:yt.getTypeFromBlob(n)};})),e.custom&&(t.custom=e.custom),setTimeout(function(){return _this119.attemptSubmit(t,!0);});case 1:return _context191.a(2);}},_callee191);}));function programmaticSubmit(_x354){return _programmaticSubmit.apply(this,arguments);}return programmaticSubmit;}()// TO-DO - should be disabled when loading history
271
- },{key:"attemptSubmit",value:function(){var _attemptSubmit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee192(e){var _this120=this;var t,i,o,a,l,n,s,_args192=arguments,_t55,_t56,_t57;return _regenerator().w(function(_context192){while(1)switch(_context192.n){case 0:t=_args192.length>1&&_args192[1]!==undefined?_args192[1]:!1;_context192.n=1;return(i=this._validationHandler)==null?void 0:i.call(this,t?e:void 0);case 1:_t55=_context192.v;_t56=!1;if(!(_t55===_t56)){_context192.n=2;break;}return _context192.a(2);case 2:this.changeToLoadingIcon();this._textInput.clear();Oe.IS_MOBILE&&setTimeout(function(){return _this120._textInput.inputElementRef.focus();});_t57=typeof this._messages.focusMode!="boolean"&&(o=this._messages.focusMode)!=null&&o.fade;if(!_t57){_context192.n=3;break;}_context192.n=3;return Ms.fadeAnimation(this._messages.elementRef,this._messages.focusMode.fade);case 3:_context192.n=4;return this.addNewMessage(e);case 4:this._serviceIO.isWebModel()||this._messages.addLoadingMessage();n=(a=e[y])==null?void 0:a.map(function(c){return c[ee];}),s=_defineProperty(_defineProperty({},h,e[h]===""?void 0:e[h]),y,n);_context192.n=5;return this._serviceIO.callAPI(s,this._messages);case 5:(l=this._fileAttachments)==null||l.hideFiles();case 6:return _context192.a(2);}},_callee192,this);}));function attemptSubmit(_x355){return _attemptSubmit.apply(this,arguments);}return attemptSubmit;}()},{key:"addNewMessage",value:function(){var _addNewMessage=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee193(_ref230){var e,t,n,s,_t58;return _regenerator().w(function(_context193){while(1)switch(_context193.n){case 0:e=_ref230.text,t=_ref230.files,n=_ref230.custom;s={role:H,custom:n};e&&(s[h]=e);_t58=t;if(!_t58){_context193.n=2;break;}_context193.n=1;return this._messages.addMultipleFiles(t,this._fileAttachments);case 1:s[y]=_context193.v;case 2:this._serviceIO.sessionId&&(s._sessionId=this._serviceIO.sessionId);Object.keys(s).length>0&&this._messages.addNewMessage(s);case 3:return _context193.a(2);}},_callee193,this);}));function addNewMessage(_x356){return _addNewMessage.apply(this,arguments);}return addNewMessage;}()},{key:"stopStream",value:function stopStream(){var e,t,n;(t=(e=this._serviceIO.streamHandlers).onAbort)==null||t.call(e),(n=this._stopClicked)==null||n.listener(),this._validationHandler&&this.resetSubmit(this._validationHandler);}},{key:"changeToStopIcon",value:function changeToStopIcon(){this._serviceIO.websocket||(this.elementRef[m].remove(Ss,wn,An),ie.removeAriaAttributes(this.elementRef),this.changeElementsByState(this._innerElements.stop),this.reapplyStateStyle("stop",["loading","submit"]),F.assignButtonEvents(this.elementRef,this.stopStream.bind(this)),this.status.loadingActive=!1);}},{key:"changeToLoadingIcon",value:function changeToLoadingIcon(){this._serviceIO.websocket||(this._isSVGLoadingIconOverriden||this.changeElementsByState(this._innerElements.loading),this.elementRef[m].remove(An,wn),ie.removeAriaDisabled(this.elementRef),this.elementRef[m].add(Ss),ie.addAriaBusy(this.elementRef),this.reapplyStateStyle("loading",["submit"]),F.assignButtonEvents(this.elementRef,function(){}),this.status.requestInProgress=!0,this.status.loadingActive=!0);}// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
272
- },{key:"changeToSubmitIcon",value:function changeToSubmitIcon(){var _this121=this;this.elementRef[m].contains(An)||(this.elementRef[m].remove(Ss,wn),ie.removeAriaAttributes(this.elementRef),this.elementRef[m].add(An),this.changeElementsByState(this._innerElements.submit),$t.resetSubmit(this,this.status.loadingActive),F.assignButtonEvents(this.elementRef,function(){var e;_this121.submitFromInput(),(e=_this121._microphoneButton)!=null&&e.isActive&&us.toggleSpeechAfterSubmit(_this121._microphoneButton.elementRef,!!_this121._stopSTTAfterSubmit),setTimeout(function(){return Wt.focusEndOfInput(_this121._textInput.inputElementRef);});}));}// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
273
- },{key:"changeToDisabledIcon",value:function changeToDisabledIcon(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;this._alwaysEnabled&&!e?this.changeToSubmitIcon():this.elementRef[m].contains(wn)||(this.elementRef[m].remove(Ss,An),ie.removeAriaBusy(this.elementRef),this.elementRef[m].add(wn),ie.addAriaDisabled(this.elementRef),this.changeElementsByState(this._innerElements.disabled),this.reapplyStateStyle("disabled",["submit"]),F.assignButtonEvents(this.elementRef,function(){}));}},{key:"disableSubmitButton",value:function disableSubmitButton(e,t){var n;e.isSubmitProgrammaticallyDisabled=t!==!1,!(this.status.requestInProgress||this.status.loadingActive)&&(t===!1?(n=this._validationHandler)==null||n.call(this):this.changeToDisabledIcon(!0));}}],[{key:"createButtonContainerElement",value:function createButtonContainerElement(){var e=S();return e[m].add("input-button"),e;}},{key:"createLoadingIconElement",value:function createLoadingIconElement(){var e=S();return e[m].add("loading-submit-button"),e;}},{key:"createStopIconElement",value:function createStopIconElement(){var e=S();return e.id="stop-icon",e;}}]);}(tn);var ph="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M27.1 14.313V5.396L24.158 8.34c-2.33-2.325-5.033-3.503-8.11-3.503C9.902 4.837 4.901 9.847 4.899 16c.001 6.152 5.003 11.158 11.15 11.16 4.276 0 9.369-2.227 10.836-8.478l.028-.122h-3.23l-.022.068c-1.078 3.242-4.138 5.421-7.613 5.421a8 8 0 0 1-5.691-2.359A7.993 7.993 0 0 1 8 16.001c0-4.438 3.611-8.049 8.05-8.049 2.069 0 3.638.58 5.924 2.573l-3.792 3.789H27.1z\"/>\n</svg>\n",fh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M0 16q0 3.264 1.28 6.208t3.392 5.12 5.12 3.424 6.208 1.248 6.208-1.248 5.12-3.424 3.392-5.12 1.28-6.208-1.28-6.208-3.392-5.12-5.088-3.392-6.24-1.28q-3.264 0-6.208 1.28t-5.12 3.392-3.392 5.12-1.28 6.208zM4 16q0-3.264 1.6-6.016t4.384-4.352 6.016-1.632 6.016 1.632 4.384 4.352 1.6 6.016-1.6 6.048-4.384 4.352-6.016 1.6-6.016-1.6-4.384-4.352-1.6-6.048z\"></path>\n</svg>\n",mh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z\"/>\n</svg>",gh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4.89163 13.2687L9.16582 17.5427L18.7085 8\" stroke=\"#000000\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";var lr=/*#__PURE__*/function(_qt){// prettier-ignore
271
+ },{key:"attemptSubmit",value:function(){var _attemptSubmit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee192(e){var _this120=this;var t,i,o,a,l,n,s,_args192=arguments,_t55,_t56,_t57;return _regenerator().w(function(_context192){while(1)switch(_context192.n){case 0:t=_args192.length>1&&_args192[1]!==undefined?_args192[1]:!1;_context192.n=1;return(i=this._validationHandler)==null?void 0:i.call(this,t?e:void 0);case 1:_t55=_context192.v;_t56=!1;if(!(_t55===_t56)){_context192.n=2;break;}return _context192.a(2);case 2:this.changeToLoadingIcon();this._textInput.clear();Oe.IS_MOBILE&&setTimeout(function(){return _this120._textInput.inputElementRef.focus();});_t57=typeof this._messages.focusMode!="boolean"&&(o=this._messages.focusMode)!=null&&o.fade;if(!_t57){_context192.n=3;break;}_context192.n=3;return Ms.fadeAnimation(this._messages.elementRef,this._messages.focusMode.fade);case 3:_context192.n=4;return this.addNewMessage(e);case 4:this._serviceIO.isWebModel()||this._messages.addLoadingMessage();n=(a=e[y])==null?void 0:a.map(function(c){return c[ee];}),s=_defineProperty(_defineProperty({},h,e[h]===""?void 0:e[h]),y,n);_context192.n=5;return this._serviceIO.callAPI(s,this._messages);case 5:(l=this._fileAttachments)==null||l.hideFiles();case 6:return _context192.a(2);}},_callee192,this);}));function attemptSubmit(_x355){return _attemptSubmit.apply(this,arguments);}return attemptSubmit;}()},{key:"addNewMessage",value:function(){var _addNewMessage=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee193(_ref230){var e,t,n,s,_t58;return _regenerator().w(function(_context193){while(1)switch(_context193.n){case 0:e=_ref230.text,t=_ref230.files,n=_ref230.custom;s={role:H,custom:n};e&&(s[h]=e);_t58=t;if(!_t58){_context193.n=2;break;}_context193.n=1;return this._messages.addMultipleFiles(t,this._fileAttachments);case 1:s[y]=_context193.v;case 2:this._serviceIO.sessionId&&(s._sessionId=this._serviceIO.sessionId);Object.keys(s).length>0&&this._messages.addNewMessage(s);case 3:return _context193.a(2);}},_callee193,this);}));function addNewMessage(_x356){return _addNewMessage.apply(this,arguments);}return addNewMessage;}()},{key:"stopStream",value:function stopStream(){var e,t,n;(t=(e=this._serviceIO.streamHandlers).onAbort)==null||t.call(e),(n=this._stopClicked)==null||n.listener(),this._validationHandler&&this.resetSubmit(this._validationHandler);}},{key:"changeToStopIcon",value:function changeToStopIcon(){this._serviceIO.websocket||(this.elementRef[m].remove(Ss,Cn,An),ie.removeAriaAttributes(this.elementRef),this.changeElementsByState(this._innerElements.stop),this.reapplyStateStyle("stop",["loading","submit"]),F.assignButtonEvents(this.elementRef,this.stopStream.bind(this)),this.status.loadingActive=!1);}},{key:"changeToLoadingIcon",value:function changeToLoadingIcon(){this._serviceIO.websocket||(this._isSVGLoadingIconOverriden||this.changeElementsByState(this._innerElements.loading),this.elementRef[m].remove(An,Cn),ie.removeAriaDisabled(this.elementRef),this.elementRef[m].add(Ss),ie.addAriaBusy(this.elementRef),this.reapplyStateStyle("loading",["submit"]),F.assignButtonEvents(this.elementRef,function(){}),this.status.requestInProgress=!0,this.status.loadingActive=!0);}// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
272
+ },{key:"changeToSubmitIcon",value:function changeToSubmitIcon(){var _this121=this;this.elementRef[m].contains(An)||(this.elementRef[m].remove(Ss,Cn),ie.removeAriaAttributes(this.elementRef),this.elementRef[m].add(An),this.changeElementsByState(this._innerElements.submit),$t.resetSubmit(this,this.status.loadingActive),F.assignButtonEvents(this.elementRef,function(){var e;_this121.submitFromInput(),(e=_this121._microphoneButton)!=null&&e.isActive&&us.toggleSpeechAfterSubmit(_this121._microphoneButton.elementRef,!!_this121._stopSTTAfterSubmit),setTimeout(function(){return Wt.focusEndOfInput(_this121._textInput.inputElementRef);});}));}// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
273
+ },{key:"changeToDisabledIcon",value:function changeToDisabledIcon(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;this._alwaysEnabled&&!e?this.changeToSubmitIcon():this.elementRef[m].contains(Cn)||(this.elementRef[m].remove(Ss,An),ie.removeAriaBusy(this.elementRef),this.elementRef[m].add(Cn),ie.addAriaDisabled(this.elementRef),this.changeElementsByState(this._innerElements.disabled),this.reapplyStateStyle("disabled",["submit"]),F.assignButtonEvents(this.elementRef,function(){}));}},{key:"disableSubmitButton",value:function disableSubmitButton(e,t){var n;e.isSubmitProgrammaticallyDisabled=t!==!1,!(this.status.requestInProgress||this.status.loadingActive)&&(t===!1?(n=this._validationHandler)==null||n.call(this):this.changeToDisabledIcon(!0));}}],[{key:"createButtonContainerElement",value:function createButtonContainerElement(){var e=S();return e[m].add("input-button"),e;}},{key:"createLoadingIconElement",value:function createLoadingIconElement(){var e=S();return e[m].add("loading-submit-button"),e;}},{key:"createStopIconElement",value:function createStopIconElement(){var e=S();return e.id="stop-icon",e;}}]);}(tn);var ph="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M27.1 14.313V5.396L24.158 8.34c-2.33-2.325-5.033-3.503-8.11-3.503C9.902 4.837 4.901 9.847 4.899 16c.001 6.152 5.003 11.158 11.15 11.16 4.276 0 9.369-2.227 10.836-8.478l.028-.122h-3.23l-.022.068c-1.078 3.242-4.138 5.421-7.613 5.421a8 8 0 0 1-5.691-2.359A7.993 7.993 0 0 1 8 16.001c0-4.438 3.611-8.049 8.05-8.049 2.069 0 3.638.58 5.924 2.573l-3.792 3.789H27.1z\"/>\n</svg>\n",fh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M0 16q0 3.264 1.28 6.208t3.392 5.12 5.12 3.424 6.208 1.248 6.208-1.248 5.12-3.424 3.392-5.12 1.28-6.208-1.28-6.208-3.392-5.12-5.088-3.392-6.24-1.28q-3.264 0-6.208 1.28t-5.12 3.392-3.392 5.12-1.28 6.208zM4 16q0-3.264 1.6-6.016t4.384-4.352 6.016-1.632 6.016 1.632 4.384 4.352 1.6 6.016-1.6 6.048-4.384 4.352-6.016 1.6-6.016-1.6-4.384-4.352-1.6-6.048z\"></path>\n</svg>\n",mh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z\"/>\n</svg>",gh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4.89163 13.2687L9.16582 17.5427L18.7085 8\" stroke=\"#000000\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";var lr=/*#__PURE__*/function(_qt){// prettier-ignore
274
274
  function lr(e,t,n,s){var _this122;_classCallCheck(this,lr);_this122=_callSuper(this,lr,[e,["modal-content","modal-camera-content"],n]),_this122._stopped=!1,_this122._format="image/png",_this122._canvas=S("canvas"),_this122._canvas[m].add("camera-modal-canvas");var _this122$addButtonsAn=_this122.addButtonsAndTheirEvents(t),i=_this122$addButtonsAn.captureButton,o=_this122$addButtonsAn.submitButton;_this122._captureButton=i,_this122._submitButton=o,_this122._captureIcon=_this122._captureButton.children[0],_this122._refreshIcon=_t.createSVGElement(ph),_this122._refreshIcon[m].add("modal-svg-button-icon","modal-svg-refresh-icon"),(s==null?void 0:s.format)==="jpeg"&&(_this122._format="image/jpeg"),s!=null&&s.dimensions&&(_this122._dimensions=s.dimensions),_this122._contentRef.appendChild(_this122._canvas),_this122.extensionCloseCallback=_this122.stop;return _this122;}_inherits(lr,_qt);return _createClass(lr,[{key:"addButtonsAndTheirEvents",value:function addButtonsAndTheirEvents(e){var t=qt.createSVGButton(fh);t[m].add("modal-svg-camera-button"),t.children[0][m].add("modal-svg-camera-icon");var n=this.addCloseButton(mh,!0);n[m].add("modal-svg-close-button"),n.children[0][m].add("modal-svg-close-icon");var s=qt.createSVGButton(gh);return s[m].add("modal-svg-submit-button"),this.addButtons(t,s),this.addButtonEvents(t,n,s,e),{captureButton:t,submitButton:s};}// prettier-ignore
275
275
  },{key:"addButtonEvents",value:function addButtonEvents(e,t,n,s){var _this123=this;F.assignButtonEvents(e,this.capture.bind(this)),F.assignButtonEvents(t,this.stop.bind(this)),F.assignButtonEvents(n,function(){var i=_this123.getFile();i&&gs.addFilesToType([i],[s]),_this123.stop(),_this123.close();});}},{key:"stop",value:function stop(){var _this124=this;this._mediaStream&&this._mediaStream.getTracks().forEach(function(e){return e.stop();}),this._stopped=!0,setTimeout(function(){_this124._captureButton.replaceChildren(_this124._captureIcon),_this124._captureButton[m].replace("modal-svg-refresh-button","modal-svg-camera-button");var e=_this124._canvas.getContext("2d");e==null||e.clearRect(0,0,_this124._canvas.width,_this124._canvas.height);},qt.MODAL_CLOSE_TIMEOUT_MS);}},{key:"start",value:function start(){var _this125=this;this._dataURL=void 0,this._submitButton[m].add("modal-svg-submit-disabled"),this._stopped=!1,navigator.mediaDevices.getUserMedia({video:this._dimensions||!0}).then(function(e){if(_this125._mediaStream=e,!_this125.isOpen())return _this125.stop();var t=S("video");t.srcObject=e,t.play(),requestAnimationFrame(_this125.updateCanvas.bind(_this125,t,_this125._canvas));})["catch"](function(e){console[f](e),_this125.stop(),_this125.close();});}},{key:"capture",value:function capture(){this._dataURL?(this._captureButton.replaceChildren(this._captureIcon),this._captureButton[m].replace("modal-svg-refresh-button","modal-svg-camera-button"),this._submitButton[m].add("modal-svg-submit-disabled"),this._dataURL=void 0):(this._captureButton.replaceChildren(this._refreshIcon),this._captureButton[m].replace("modal-svg-camera-button","modal-svg-refresh-button"),this._submitButton[m].remove("modal-svg-submit-disabled"),this._dataURL=this._canvas.toDataURL());}},{key:"getFile",value:function getFile(){if(this._dataURL){var e=atob(this._dataURL.split(",")[1]),t=new Array(e.length);for(var a=0;a<e.length;a++)t[a]=e.charCodeAt(a);var _n17=new Uint8Array(t),s=new Blob([_n17],{type:this._format}),i=this._format==="image/jpeg"?"jpeg":"png",o=Ko.getFileName(this._newFilePrefix||"photo",i);return new File([s],o,{type:s.type});}}},{key:"updateCanvas",value:function updateCanvas(e,t){if(!this._stopped){if(!this._dataURL){t.width=e.videoWidth,t.height=e.videoHeight;var _n18=t.getContext("2d");_n18==null||_n18.drawImage(e,0,0,t.width,t.height);}requestAnimationFrame(this.updateCanvas.bind(this,e,t));}}},{key:"openCameraModal",value:function openCameraModal(e){this.displayModalElements(),e[Mt]();}// prettier-ignore
276
276
  }],[{key:"createCameraModalFunc",value:function createCameraModalFunc(e,t,n,s){var i=new lr(e,t,n,s);return i.openCameraModal.bind(i,i);}}]);}(qt);var yh="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M29 7h-4.599l-2.401-4h-12l-2.4 4h-4.6c-1 0-3 1-3 2.969v16.031c0 1.657 1.5 3 2.792 3h26.271c1.313 0 2.938-1.406 2.938-2.968v-16.032c0-1-1-3-3-3zM30 26.032c0 0.395-0.639 0.947-0.937 0.969h-26.265c-0.232-0.019-0.797-0.47-0.797-1v-16.031c0-0.634 0.851-0.953 1-0.969h5.732l2.4-4h9.802l1.785 3.030 0.55 0.97h5.731c0.705 0 0.99 0.921 1 1v16.032zM16 10c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zM16 22c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z\"></path>\n</svg>";var cr=/*#__PURE__*/function(_tn7){function cr(e,t,n){var _this126;_classCallCheck(this,cr);var c,d,p,u,g,b;var s=ne.processPosition((c=n==null?void 0:n.button)==null?void 0:c.position),i=((u=(p=(d=n==null?void 0:n.button)==null?void 0:d.styles)==null?void 0:p[h])==null?void 0:u.content)||"Photo",o=nt.tryCreateConfig("Camera",(g=n==null?void 0:n.button)==null?void 0:g.tooltip),a=((b=n==null?void 0:n.button)==null?void 0:b.styles)||{};_this126=_callSuper(this,cr,[cr.createButtonElement(),yh,s,o,a,i]);var l=_this126.createInnerElementsForStates(_this126.customStyles);n&&_this126.addClickEvent(e,t,n.modalContainerStyle,n[y]),_this126.changeElementsByState(l.styles),_this126.reapplyStateStyle("styles");return _this126;}_inherits(cr,_tn7);return _createClass(cr,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){return{styles:this.createInnerElements("camera-icon","styles",e)};}},{key:"addClickEvent",value:// prettier-ignore
277
277
  function addClickEvent(e,t,n,s){var i=lr.createCameraModalFunc(e,t,n,s);F.assignButtonEvents(this.elementRef,i);}}],[{key:"createButtonElement",value:function createButtonElement(){var e=S();return e[m].add("input-button"),e;}}]);}(tn);var rn=/*#__PURE__*/function(){function rn(e,t,n,s){_classCallCheck(this,rn);this.elementRef=rn.createPanelElement(e.inputAreaStyle);var i={},o=this.createFileUploadComponents(e,n,s,i),a=new Is(e,n,o,t.browserStorage);e.speechToText&&!i.microphone&&(i.microphone={button:new us(e,a,t.addNewErrorMessage.bind(t))});var l=new Qn(e,a,t,n,o,i);a.submit=l.submitFromInput.bind(l),Lt.attach(e,n,a,o,l,t.browserStorage),e.submitUserMessage=l.programmaticSubmit.bind(l),i.submit={button:l},e.customButtons&&zt.add(e,i),rn.addElements(this.elementRef,a,i,s,o,e.dropupStyles),rn.assignOnInput(e,n,o,a);}return _createClass(rn,[{key:"createFileUploadComponents",value:// prettier-ignore
278
278
  function createFileUploadComponents(e,t,n,s){var o,a,l,c;var i=new gs(this.elementRef,e.attachmentContainerStyle,t.demo);if(rn.createUploadButtons(e,t,t.fileTypes||{},i,n,s),(o=t[Ie])!=null&&o[y]){var d=((a=s[J])==null?void 0:a.fileType)||i.addType(e,t,t[Ie][y],J);s[Ie]={button:new cr(n,d,t[Ie])};}if((l=t.recordAudio)!=null&&l[y]){var _d3=((c=s[L])==null?void 0:c.fileType)||i.addType(e,t,t.recordAudio[y],L);s.microphone={button:new hh(_d3,t.recordAudio)};}return gt.isEnabled(i,e.dragAndDrop)&&gt.create(n,i,e.dragAndDrop),i;}// prettier-ignore
279
279
  }],[{key:"createPanelElement",value:function createPanelElement(e){var t=S();return t.id="input",Object.assign(t[_],e),t;}},{key:"createUploadButtons",value:function createUploadButtons(e,t,n,s,i,o){Object.keys(n).forEach(function(a){var l=a,c=n[l];if(c[y]){var d=s.addType(e,t,c[y],l),_zd$l=zd[l],p=_zd$l.id,u=_zd$l.svgString,g=_zd$l.dropupText,b=new Ws(i,d,c,p,u,g);o[l]={button:b,fileType:d};}});}// prettier-ignore
280
- },{key:"addElements",value:function addElements(e,t,n,s,i,o){F.addElements(e,t.elementRef);var a=yn.create(),l=Ce.addButtons(a,n,s,o);Yn.set(t.inputElementRef,a,i.elementRef,l),yn.add(e,a);}},{key:"assignOnInput",value:function assignOnInput(e,t,n,s){t.onInput=function(i){setTimeout(function(){var o=n.getAllFileData(),a=s.inputElementRef.innerText.trim(),l=_defineProperty({},h,a);o&&(l[y]=o.map(function(c){return c[ee];})),Xt.onInput(e,l,i);});};}}]);}();var dr=/*#__PURE__*/function(){function dr(){_classCallCheck(this,dr);}return _createClass(dr,null,[{key:"createElements",value:function createElements(e,t,n){var s=S();s.id="chat-view";var i=!e.focusMode&&e.upwardsMode;s.classList.add(i?Bd:Ld);var o=new Ve(e,t,n);t.websocket&&Se.createConnection(t,o);var a=new rn(e,o,t,s),l=i?o.elementRef.parentElement:o.elementRef;return F.addElements(s,l,a.elementRef),s;}},{key:"render",value:function render(e,t,n,s){var i=dr.createElements(e,n,s);t.replaceChildren(i),n.isCustomView()&&n.setUpView(i,t);}}]);}();var bh="#validate-property-key-view{height:100%;position:relative;display:flex;justify-content:center;align-items:center;padding:8px}#loading-validate-key-property{display:inline-block;width:50px;height:50px}#loading-validate-key-property:after{content:\" \";display:block;width:38px;height:38px;margin:1px;border-radius:50%;border:5px solid #5fb2ff;border-color:#5fb2ff transparent #5fb2ff transparent;animation:loading-spinner 1.4s linear infinite}#deep-chat-openai-realtime-container{height:100%;width:100%}#deep-chat-openai-realtime-avatar-container{height:60%;width:100%;display:flex;justify-content:center;align-items:center}#deep-chat-openai-realtime-avatar{border-radius:50%;height:110px;border:1px solid rgb(215,215,215);padding:8px;-webkit-user-select:none;user-select:none;margin-top:20px}#deep-chat-openai-realtime-buttons-container{height:40%;display:flex;position:relative}.deep-chat-openai-realtime-button-container{height:100%;width:50%;display:flex;justify-content:center;align-items:center}.deep-chat-openai-realtime-button{width:70px;height:70px;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer}.deep-chat-openai-realtime-button-default{background-color:#e3e3e3}.deep-chat-openai-realtime-button-default:hover{background-color:#d4d4d4}.deep-chat-openai-realtime-button-default:active{background-color:#c5c5c5}.deep-chat-openai-realtime-button-loading{opacity:.7;pointer-events:none}.deep-chat-openai-realtime-microphone-active{background-color:#ffe7e7}.deep-chat-openai-realtime-microphone-active:hover{background-color:#ffdede}.deep-chat-openai-realtime-microphone-active:active{background-color:#ffd2d2}.deep-chat-openai-realtime-microphone>*{height:30px;width:30px}.deep-chat-openai-realtime-microphone-active>*{filter:brightness(0) saturate(100%) invert(35%) sepia(60%) saturate(1360%) hue-rotate(325deg) brightness(95%) contrast(92%)}.deep-chat-openai-realtime-toggle>*{height:32px;width:32px;padding-inline-start:3px;filter:brightness(0) saturate(100%) invert(22%) sepia(0%) saturate(4537%) hue-rotate(208deg) brightness(105%) contrast(91%)}.deep-chat-openai-realtime-button-unavailable{opacity:.45;pointer-events:none}#deep-chat-openai-realtime-error{color:red;position:absolute;top:calc(50% + 40px);inset-inline-start:50%;transform:translate(-50%,-50%);font-size:17px}#deep-chat-openai-realtime-loading{position:absolute;font-size:15px;top:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}#insert-key-view{height:100%;position:relative}#insert-key-contents{text-align:center;position:absolute;inset-block-start:44%;inset-inline-start:50%;transform:translate(-50%,-50%);width:82%;display:flex;max-width:700px}#insert-key-title{margin-bottom:15px}#insert-key-input-container{margin-inline-end:2.7em;width:calc(100% - 80px)}#insert-key-input{padding:.3em 1.7em .3em .3em;border-width:1px;border-style:solid;border-radius:3px;width:100%;font-size:inherit}.insert-key-input-valid{border-color:gray}.insert-key-input-invalid{border-color:red}#visibility-icon-container{position:relative;float:inline-end;cursor:pointer;-webkit-user-select:none;user-select:none}.visibility-icon{filter:brightness(0) saturate(100%) invert(63%) sepia(1%) saturate(9%) hue-rotate(43deg) brightness(98%) contrast(92%);position:absolute;inset-inline-end:-1.7em;inset-block-start:-1.43em}#visible-icon{inset-block-start:-1.4em}.visibility-icon:hover{filter:unset}.visibility-icon>*{pointer-events:none}#start-button{border:1px solid grey;color:#454545;border-radius:4px;width:3em;display:flex;justify-content:center;align-items:center;cursor:pointer;padding:.28em .3em;-webkit-user-select:none;user-select:none;background-color:#fff}#start-button:hover{background-color:#f2f2f2}#start-button:active{background-color:#d2d2d2}#insert-key-help-text-container{width:100%;position:absolute;margin-top:32px;margin-bottom:20px}#insert-key-help-text-contents{width:100%;position:absolute}#insert-key-input-invalid-text{display:block;margin-top:1em;margin-bottom:.5em;color:red}.insert-key-input-help-text{display:block;margin-top:16px}#loading-key{display:inline-block;width:16px;height:16px}#loading-key:after{content:\" \";display:block;width:11px;height:11px;margin:1px;border-radius:50%;border:2px solid #0084ff;border-color:#0084ff transparent #0084ff transparent;animation:loading-spinner 1.2s linear infinite}#error-view{color:red;font-size:1.2em;line-height:1.3em;margin-top:-5px;text-align:center;height:100%;display:flex;justify-content:center;align-items:center;padding-inline:8px}@keyframes loading-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.intro-panel{position:absolute;display:flex;justify-content:center;right:0;bottom:0;left:0;margin:auto;height:fit-content;top:-2.5em}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!\n Theme: a11y-dark\n Author: @ericwbailey\n Maintainer: @ericwbailey\n\n Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css\n*/.hljs{background:#2b2b2b;color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast:active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}#messages,.deep-chat-upwards-mode #messages>div{overflow:auto;overflow-anchor:none}.deep-chat-upwards-mode #messages{height:100%;display:flex;flex-direction:column;justify-content:flex-end}.outer-message-container:last-child{margin-bottom:5px}.inner-message-container{display:flex;margin-inline:auto;width:calc(97.5% - 24px);max-width:100%}.message-bubble{margin-top:10px;word-wrap:break-word;width:fit-content;max-width:60%;border-radius:10px;padding:.42em .55em;height:fit-content;line-height:1.26em}.user-message-text{color:#fff;background-color:#0084ff;margin-inline-end:0px;margin-inline-start:auto}.ai-message-text{color:#000;background-color:#e4e6eb;margin-inline-start:0px;margin-inline-end:auto}.deep-chat-last-group-messages-active{height:100%}#scroll-button{position:absolute;top:75%;left:50%;right:50%;transform:translate(-50%,-50%);transition:opacity .1s ease;display:flex;opacity:0;padding:8px;background-color:#fff;border:.5px solid #000000;justify-content:center;align-items:center;white-space:nowrap;cursor:pointer}#scroll-button:hover{background-color:#fafafa}.loading-history-message-full-view{position:absolute;height:70%;width:100%;display:flex;align-items:center}.deep-chat-upwards-mode #messages .loading-history-message-full-view{height:100%}.loading-history-message-small{height:20px;margin-bottom:30px}.loading-history-message-small>div>div{scale:.6}.loading-history-message{margin-top:0;width:100%;max-width:100%;display:flex;justify-content:center;background-color:unset}.loading-history{width:70px}.loading-history div{position:absolute;width:var(--loading-history-width);height:var(--loading-history-height);margin:var(--loading-history-margin);border:var(--loading-history-border);border-radius:50%;animation:loading-spinner 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:var(--loading-history-color) transparent transparent transparent}.loading-history div:nth-child(1){animation-delay:-.45s}.loading-history div:nth-child(2){animation-delay:-.3s}.loading-history div:nth-child(3){animation-delay:-.15s}.html-message{max-width:unset}.error-message-text{margin-inline:auto;background-color:#f4c0c0;color:#474747;text-align:center;max-width:95%;margin-top:14px;margin-bottom:10px}.deep-chat-loading-message-dots-container{width:1em;padding-top:.6em;padding-bottom:.6em;padding-inline-start:1.3em;padding-inline-end:.75em}.loading-message-dots{position:relative;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite linear alternate;animation-delay:.5s}.loading-message-dots:before,.loading-message-dots:after{content:\"\";display:inline-block;position:absolute;top:0}.loading-message-dots:before{inset-inline-start:-.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:0s}.loading-message-dots:after{inset-inline-start:.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:1s}@keyframes loading-message-dots{0%{background-color:var(--loading-message-color)}50%,to{background-color:var(--loading-message-color-fade)}}.message-bubble>p:first-child,.message-bubble>.partial-render-message>p:first-child,.html-wrapper>p:first-child{margin-top:0}.message-bubble>p:last-child,.message-bubble>.partial-render-message:last-child>p,.html-wrapper>p:last-child{margin-bottom:0}pre{overflow:auto;display:block;word-break:break-all;word-wrap:break-word;border-radius:7px;background:#2b2b2b;color:#f8f8f2;margin-top:.8em;margin-bottom:.8em;padding:.6em;font-size:.9em;line-height:1.5em}.image-message{padding:0;display:flex;background-color:#ddd}.image-message>*,.image-message>*>*{width:100%;border-radius:8px;display:flex}.audio-message{width:60%;max-width:300px;height:2.2em;max-height:54px;padding:0;background-color:unset}.audio-player{width:100%;height:100%}.audio-player-safari{height:fit-content;width:40px}.audio-player-safari-start{float:inline-start}.audio-player-safari-end{float:inline-end}.any-file-message{padding:1px}.any-file-message-contents{display:flex}.any-file-message-icon-container{width:1.3em;min-width:1.3em;position:relative;border-radius:4px;margin-inline-start:6px;margin-inline-end:2px}.any-file-message-icon{background-color:#fff;border-radius:4px;position:absolute;width:1em;height:1.25em;padding:1px;margin-top:auto;margin-bottom:auto;top:0;bottom:0}.any-file-message-text{padding-top:5px;overflow-wrap:anywhere;padding-bottom:5px;padding-inline-end:7px}.message-bubble>a{color:inherit}.start-item-position{margin-inline-end:10px}.end-item-position{margin-inline-start:10px}.role-hidden{display:none}.avatar{padding-top:5px;width:1.5em;height:1.5em;border-radius:1px}.avatar-container{margin-top:9px}.name{margin-top:16px;font-size:15px}#drag-and-drop{position:absolute;display:none;z-index:10;height:calc(100% - 10px);width:calc(100% - 10px);background-color:#70c6ff4d;border:5px dashed #6dafff}#file-attachment-container{position:absolute;height:3.6em;width:calc(80% - 4px);top:-2.5em;border-radius:5px;overflow:auto;text-align:start;background-color:#d7d7d73b;padding-inline-start:4px}.file-attachment{width:2.85em;height:2.85em;display:inline-flex;margin-inline-end:.6em;margin-bottom:.44em;margin-top:4px;position:relative;background-color:#fff;border-radius:5px}.image-attachment{width:100%;height:100%;object-fit:cover;border-radius:5px}.border-bound-attachment{width:calc(100% - 2px);height:calc(100% - 2px);border:1px solid #c3c3c3;border-radius:5px;overflow:hidden}.border-bound-attachment-safari{width:calc(100% - 1px);height:calc(100% - 1px)}.audio-attachment-icon-container{cursor:pointer}.audio-attachment-icon-container:hover{background-color:#f8f8f8}.attachment-icon{inset-inline:0;bottom:0;top:2px;margin:auto;position:absolute;width:25px;-webkit-user-select:none;user-select:none}.not-removable-attachment-icon{top:0;right:0;bottom:0;left:0}.play-icon{filter:brightness(0) saturate(100%) invert(17%) sepia(0%) saturate(1392%) hue-rotate(67deg) brightness(98%) contrast(97%)}.stop-icon{filter:brightness(0) saturate(100%) invert(29%) sepia(90%) saturate(1228%) hue-rotate(198deg) brightness(93%) contrast(98%)}.audio-placeholder-text-3-digits{padding-inline-start:.26rem}.audio-placeholder-text-4-digits{padding-inline-start:.1rem}.any-file-attachment{padding:2px 0}.file-attachment-text-container{position:absolute;width:inherit;display:flex;align-items:center;height:100%;top:-1px}.audio-placeholder-text-3-digits-container{padding-top:1px;cursor:default}.any-file-attachment-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding-inline-start:.13em;margin-inline:auto}.remove-file-attachment-button{height:1.25em;width:1.25em;border:1px solid #cfcfcf;border-radius:25px;background-color:#fff;top:-4px;inset-inline-end:-5px;position:absolute;display:flex;justify-content:center;cursor:pointer;-webkit-user-select:none;user-select:none}.remove-file-attachment-button:hover{background-color:#e4e4e4}.remove-file-attachment-button:active{background-color:#d7d7d7}.x-icon{color:#4e4e4e;top:-.075em;position:relative;font-size:1.05em}.modal{display:none;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:80%;max-width:420px;max-height:80%;margin:auto;top:0;right:0;bottom:0;left:0;z-index:3}.modal-content{border-top:1px solid rgb(217,217,217);border-inline:1px solid rgb(217,217,217);border-start-start-radius:inherit;border-start-end-radius:inherit;background-color:#fff;overflow-y:auto;height:fit-content;max-height:calc(100% - 3.3em);width:100%}.modal-content>p{margin-inline:1em}.modal-content>ul{margin-inline-end:1em}.modal-button-panel{height:3.3em;border:1px solid;border-color:rgb(223,223,223) rgb(217,217,217) rgb(217,217,217);border-end-start-radius:inherit;border-end-end-radius:inherit;background-color:#fff;text-align:center;justify-content:center;display:flex;width:100%}.modal-button{min-width:2.5em;text-align:center;color:#fff;border-radius:5px;padding:.4em .4em .3em;height:1.25em;background-color:#3279b2;inset-block:0;margin-top:auto;margin-bottom:auto;cursor:pointer;-webkit-user-select:none;user-select:none;margin-inline:.31em}.modal-button:hover{background-color:#276da7}.modal-button:active{background-color:#1b5687}.modal-svg-button{padding:0 0 2px;width:2em;height:1.8em}.modal-svg-button-icon{width:100%;height:100%;filter:brightness(0) saturate(100%) invert(100%) sepia(15%) saturate(4%) hue-rotate(346deg) brightness(101%) contrast(102%)}#modal-background-panel{position:absolute;width:100%;height:100%;background-color:#00000042;z-index:2;display:none}.show-modal-background{animation:fadeInBackground .3s ease-in-out}@keyframes fadeInBackground{0%{opacity:0}to{opacity:1}}.show-modal{animation:fadeInModal .3s ease-in-out}@keyframes fadeInModal{0%{opacity:0;scale:.95}to{opacity:1;scale:1}}.hide-modal-background{animation:fadeOutBackground .2s ease-in-out}@keyframes fadeOutBackground{0%{opacity:1}to{opacity:0}}.hide-modal{animation:fadeOutModal .2s ease-in-out}@keyframes fadeOutModal{0%{opacity:1;scale:1}to{opacity:0;scale:.95}}.modal-camera-content{overflow:hidden;text-align:center;border:unset;height:100%;background-color:#2a2a2a;display:flex;justify-content:center}.camera-modal-canvas{max-width:100%;max-height:100%;margin-top:auto;margin-bottom:auto}.modal-svg-submit-button{background-color:green}.modal-svg-submit-button:hover{background-color:#007500}.modal-svg-submit-button:active{background-color:#006500}.modal-svg-submit-disabled{pointer-events:none;background-color:#747474}.modal-svg-close-button{height:1.56em;padding-top:.37em;padding-bottom:0;background-color:#c13e3e}.modal-svg-close-button:hover{background-color:#b43434}.modal-svg-close-button:active{background-color:#972929}.modal-svg-close-icon{width:80%;height:80%}.modal-svg-camera-button{height:1.6em;padding-top:.38em;padding-bottom:0}.modal-svg-camera-icon{height:76%}.modal-svg-refresh-icon{height:105%}.modal-svg-refresh-button{height:1.66em;padding-top:.11em;padding-bottom:.21em}.input-button-container{position:relative;z-index:1}.inside-end{position:absolute;inset-inline-end:calc(10% + .35em);inset-block-end:.85em}.inside-start{position:absolute;inset-inline-start:calc(10% + .35em);inset-block-end:.85em}.outside-start{position:absolute;inset-inline-end:calc(11px - .55em);inset-block-end:.88em}.outside-end{position:absolute;inset-inline-start:calc(11px - .55em);inset-block-end:.88em}#upload-images-icon{position:absolute;pointer-events:none;width:1.45em;height:1.45em;inset-inline-start:.11em;inset-block-end:.08em;filter:brightness(0) saturate(100%) invert(43%) sepia(0%) saturate(740%) hue-rotate(77deg) brightness(99%) contrast(92%)}#upload-gifs-icon{position:absolute;pointer-events:none;width:1.5em;height:1.48em;inset-inline-start:.07em;inset-block-end:.08em;filter:brightness(0) saturate(100%) invert(49%) sepia(0%) saturate(2586%) hue-rotate(12deg) brightness(93%) contrast(90%)}#upload-audio-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.17em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%);transform:scaleX(.95)}#camera-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.23em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(52%) sepia(0%) saturate(161%) hue-rotate(164deg) brightness(91%) contrast(92%);transform:scaleX(.95)}#upload-mixed-files-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.25em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(53%) sepia(0%) saturate(36%) hue-rotate(74deg) brightness(98%) contrast(93%);transform:scaleX(.95)}#interim-text{color:gray}#microphone-button{padding-top:.5px}.outer-button-container>#microphone-button{padding-bottom:1px}#microphone-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.25em;inset-block-end:.25em}.default-microphone-icon{filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%)}.active-microphone-icon{filter:brightness(0) saturate(100%) invert(10%) sepia(97%) saturate(7495%) hue-rotate(0deg) brightness(101%) contrast(107%);border-radius:10px}.command-microphone-icon{filter:brightness(0) saturate(100%) invert(42%) sepia(96%) saturate(1067%) hue-rotate(77deg) brightness(99%) contrast(102%)}.unsupported-microphone{display:none}#submit-icon{height:100%;filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%);width:1.21em}#stop-icon{background-color:#acacac;position:absolute;width:.95em;height:.95em;inset-inline-start:.35em;inset-block-end:.35em;border-radius:2px}.submit-button-enlarged{scale:1.1;margin-inline:.3em}.loading-submit-button{position:relative;inset-inline-start:calc(-9990px + .275em);width:.22em;height:.22em;border-radius:5px;background-color:#848484;color:#848484;box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484;animation:loading-submit-button 1.5s infinite linear;inset-block-end:-.75em}@keyframes loading-submit-button{0%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}16.667%{box-shadow:9990px -6px #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}33.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}50%{box-shadow:9990px 0 #848484,calc(9990px + .44em) -6px 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}66.667%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}83.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) -6px 0 0 #848484}to{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}}.tooltip{position:absolute;visibility:hidden;z-index:1;pointer-events:none;padding:5px;padding-inline:7px;background-color:#333;border-radius:5px;width:max-content}.tooltip-text{color:#fff;font-size:13px}.input-button{border-radius:4px;cursor:pointer;margin-bottom:.2em;-webkit-user-select:none;user-select:none}.input-button-svg{width:1.65em;height:1.65em}.input-button-svg-text{padding:1px;height:1.65em;display:flex}.input-button-svg-text>svg{padding:.22rem}.input-button-svg-text>div{margin-inline-start:2px}.input-button:hover,.input-button:focus-visible{background-color:#9c9c9c2e}.input-button:active{background-color:#9c9c9c5e}.input-button:active:not(:hover){background-color:transparent}.loading-button{cursor:auto}.loading-button:hover{background-color:unset}.text-button{filter:unset!important;display:flex;justify-content:center;align-items:center;margin-inline:4px;height:1.6em;width:max-content}#custom-icon{height:100%;width:1.2em}.custom-button-container-default{color:#505050}.custom-button-container-default>.dropup-menu-item-icon{color:unset}.custom-button-container-default>svg{filter:brightness(0) saturate(100%) invert(39%) sepia(1%) saturate(0%) hue-rotate(83deg) brightness(93%) contrast(90%)}.custom-button-container-default>.dropup-menu-item-icon>svg{position:absolute;inset-inline-start:.2em}.custom-button-container-active{background-color:#edf7ff;color:#0285ff}.custom-button-container-active:hover,.custom-button-container-active:focus-visible{background-color:#def0ff}.custom-button-container-active:active{background-color:#d2eaff}.custom-button-container-active>svg{filter:brightness(0) saturate(100%) invert(32%) sepia(34%) saturate(4196%) hue-rotate(196deg) brightness(107%) contrast(104%)}.custom-button-container-disabled{color:#aeaeae;cursor:auto}.custom-button-container-disabled>div{pointer-events:none}.custom-button-container-disabled:hover,.custom-button-container-disabled:focus-visible{background-color:transparent}.custom-button-container-disabled:active{background-color:transparent}.custom-button-container-disabled>svg{filter:brightness(0) saturate(100%) invert(67%) sepia(0%) saturate(818%) hue-rotate(28deg) brightness(102%) contrast(100%)}#text-input-container{background-color:#fff;width:80%;display:flex;border:1px solid #0000001a;border-radius:5px;margin-top:.8em;margin-bottom:.8em;box-shadow:#959da533 0 1px 12px;overflow-y:auto;max-height:200px;position:relative}.text-input-container-start-adjustment{margin-inline-start:1.5em}.text-input-container-end-adjustment{margin-inline-end:1.5em}.text-input-container-start-small-adjustment{margin-inline-start:1.1em}.text-input-container-start-small-adjustment>.outside-start{inset-inline-end:calc(14px - .55em)}.text-input-container-end-small-adjustment{margin-inline-end:1.1em}.text-input-container-end-small-adjustment>.outside-end{inset-inline-start:calc(14px - .55em)}#text-input{text-align:start;outline:none;word-wrap:break-word;line-break:auto}.text-input-styling{padding:.4em .5em;overflow:overlay;width:100%}.text-input-inner-start-adjustment{padding-inline-start:2.2em}.text-input-inner-end-adjustment{padding-inline-end:2em}.text-input-disabled{pointer-events:none;-webkit-user-select:none;user-select:none}[contenteditable]:empty:before{content:attr(deep-chat-placeholder-text);pointer-events:none}[contenteditable][textcolor]:empty:before{color:gray}.outside-end>#dropup-menu,.inside-end>#dropup-menu{inset-inline-end:0px}#dropup-icon{position:absolute;pointer-events:none;width:1.16em;height:1.2em;inset-inline-start:.265em;bottom:.43em;filter:brightness(0) saturate(100%) invert(54%) sepia(0%) saturate(724%) hue-rotate(6deg) brightness(92%) contrast(90%)}.dropup-button>*{pointer-events:none}#dropup-menu{background-color:#fff;position:absolute;transform:translateY(-100%);border-radius:5px;z-index:1;top:-.49em;box-shadow:#0003 -1px 2px 10px,#0000001a 0 2px 4px;cursor:pointer;-webkit-user-select:none;user-select:none}.dropup-menu-item{height:1.4em;padding-inline-start:.35em;padding-inline-end:.84em;padding-top:.28em;padding-bottom:.28em;display:flex;position:relative}.dropup-menu-item:hover,.dropup-menu-item:focus-visible{background-color:#f3f3f3}.dropup-menu-item:active{background-color:#ebebeb}.dropup-menu-item:active:not(:hover){background-color:transparent}.dropup-menu-item:first-child{padding-top:.49em;border-start-start-radius:inherit;border-start-end-radius:inherit}.dropup-menu-item:last-child{padding-bottom:.45em;border-end-start-radius:inherit;border-end-end-radius:inherit}.dropup-menu-item-icon{width:1.39em;position:relative}.dropup-menu-item-icon>svg{bottom:0!important;top:0!important;margin-bottom:auto;margin-top:auto}#dropup-menu-item-icon-element-custom{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.28em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%)}.dropup-menu-item-text{margin-inline-start:.56em;margin-top:.08em;width:max-content}#input{width:100%;display:inline-flex;text-align:center;margin-inline:auto;margin-top:auto;position:relative;justify-content:center}#chat-view{height:100%;grid-template-columns:100%}.deep-chat-downwards-mode{display:grid}.deep-chat-upwards-mode{display:flex;flex-direction:column}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background-color:#d0d0d0;border-radius:5px}::-webkit-scrollbar-track{background-color:#f2f2f2}.deep-chat-web-model-button{margin-top:10px;margin-bottom:5px;margin-inline-start:1px}:host{all:initial;display:table-cell}#container{height:inherit;width:inherit;overflow:hidden}";var vh=Object.defineProperty,O=function O(r,e,t,n){for(var s=void 0,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=o(e,t,s)||s);return s&&vh(e,t,s),s;};var I=/*#__PURE__*/function(_xi){function I(){var _this127;_classCallCheck(this,I);var e;_this127=_callSuper(this,I),_this127.getMessages=function(){return[];},_this127.submitUserMessage=function(){return console.warn(vr("submitUserMessage"));},_this127.addMessage=function(){return console.warn(vr("addMessage"));},_this127.updateMessage=function(){},_this127.clearMessages=function(){},_this127.focusInput=function(){return Wt.focusFromParentElement(_this127._elementRef);},_this127.refreshMessages=function(){},_this127.scrollToBottom=function(){},_this127.disableSubmitButton=function(){},_this127.setPlaceholderText=function(){},_this127._hasBeenRendered=!1,_this127._auxiliaryStyleApplied=!1,_this127._elementRef=S(),_this127._elementRef.id="container",_this127.attachShadow({mode:"open"}).appendChild(_this127._elementRef),(e=_this127.shadowRoot)==null||e.appendChild(nt.buildElement()),Wn.apply(bh,_this127.shadowRoot),setTimeout(function(){_this127._hasBeenRendered||_this127.onRender();},20);return _this127;}_inherits(I,_xi);return _createClass(I,[{key:"changeToChatView",value:function changeToChatView(){this._activeService&&(this._activeService.validateKeyProperty=!1),this.onRender();}// prettier-ignore
281
- },{key:"onRender",value:function onRender(){var _this$_childElement;Rs.attemptAppendStyleSheetToHead(this.style),ne.processConnect(this),(!this._activeService||this._activeService.demo)&&(this._activeService=Pd.create(this)),this.auxiliaryStyle&&!this._auxiliaryStyleApplied&&(Wn.apply(this.auxiliaryStyle,this.shadowRoot),this._auxiliaryStyleApplied=!0),Wn.applyDefaultStyleToComponent(this.style,this.chatStyle),ne.checkForContainerStyles(this,this._elementRef),this._activeService.key&&this._activeService.validateKeyProperty?Cs.render(this._elementRef,this.changeToChatView.bind(this),this._activeService):!(this._activeService instanceof R)||this._activeService.key?((_this$_childElement=this._childElement)!==null&&_this$_childElement!==void 0?_this$_childElement:this._childElement=this.children[0],dr.render(this,this._elementRef,this._activeService,this._childElement)):this._activeService instanceof R&&we.render(this._elementRef,this.changeToChatView.bind(this),this._activeService),this._hasBeenRendered||Xt.onRender(this),this._hasBeenRendered=!0;}},{key:"disconnectedCallback",value:function disconnectedCallback(){ds.chat=void 0;}}]);}(xi);O([k("object")],I.prototype,"connect");O([k("object")],I.prototype,"directConnection");O([k("object")],I.prototype,"webModel");O([k("object")],I.prototype,"requestBodyLimits");O([k("function")],I.prototype,"requestInterceptor");O([k("function")],I.prototype,"responseInterceptor");O([k("function")],I.prototype,"validateInput");O([k("function")],I.prototype,"loadHistory");O([k("object")],I.prototype,"chatStyle");O([k("object")],I.prototype,"attachmentContainerStyle");O([k("object")],I.prototype,"dropupStyles");O([k("object")],I.prototype,"inputAreaStyle");O([k("object")],I.prototype,"textInput");O([k("object")],I.prototype,"defaultInput");O([k("object")],I.prototype,"submitButtonStyles");O([k("object")],I.prototype,"customButtons");O([k("string")],I.prototype,"auxiliaryStyle");O([k("array")],I.prototype,"history");O([k("object")],I.prototype,"browserStorage");O([k("object")],I.prototype,"introMessage");O([k("object")],I.prototype,"avatars");O([k("object")],I.prototype,"names");O([k("object")],I.prototype,"displayLoadingBubble");O([k("object")],I.prototype,"errorMessages");O([k("object")],I.prototype,"messageStyles");O([k("object")],I.prototype,"textToSpeech");O([k("object")],I.prototype,"speechToText");O([k("object")],I.prototype,"images");O([k("object")],I.prototype,"gifs");O([k("object")],I.prototype,"camera");O([k("object")],I.prototype,"audio");O([k("object")],I.prototype,"microphone");O([k("object")],I.prototype,"mixedFiles");O([k("object")],I.prototype,"dragAndDrop");O([k("object")],I.prototype,"htmlWrappers");O([k("object")],I.prototype,"htmlClassUtilities");O([k("object")],I.prototype,"remarkable");O([k("object")],I.prototype,"focusMode");O([k("boolean")],I.prototype,"upwardsMode");O([k("object")],I.prototype,"scrollButton");O([k("object")],I.prototype,"hiddenMessages");O([k("number")],I.prototype,"maxVisibleMessages");O([k("function")],I.prototype,"onMessage");O([k("function")],I.prototype,"onClearMessages");O([k("function")],I.prototype,"onComponentRender");O([k("function")],I.prototype,"onInput");O([k("function")],I.prototype,"onError");O([k("object")],I.prototype,"demo");O([k("object")],I.prototype,"_insertKeyViewStyles");customElements.define("deep-chat",I);export{I as DeepChat};
280
+ },{key:"addElements",value:function addElements(e,t,n,s,i,o){F.addElements(e,t.elementRef);var a=yn.create(),l=we.addButtons(a,n,s,o);Yn.set(t.inputElementRef,a,i.elementRef,l),yn.add(e,a);}},{key:"assignOnInput",value:function assignOnInput(e,t,n,s){t.onInput=function(i){setTimeout(function(){var o=n.getAllFileData(),a=s.inputElementRef.innerText.trim(),l=_defineProperty({},h,a);o&&(l[y]=o.map(function(c){return c[ee];})),Xt.onInput(e,l,i);});};}}]);}();var dr=/*#__PURE__*/function(){function dr(){_classCallCheck(this,dr);}return _createClass(dr,null,[{key:"createElements",value:function createElements(e,t,n){var s=S();s.id="chat-view";var i=!e.focusMode&&e.upwardsMode;s.classList.add(i?Bd:Ld);var o=new Ve(e,t,n);t.websocket&&Se.createConnection(t,o);var a=new rn(e,o,t,s),l=i?o.elementRef.parentElement:o.elementRef;return F.addElements(s,l,a.elementRef),s;}},{key:"render",value:function render(e,t,n,s){var i=dr.createElements(e,n,s);t.replaceChildren(i),n.isCustomView()&&n.setUpView(i,t);}}]);}();var bh="#validate-property-key-view{height:100%;position:relative;display:flex;justify-content:center;align-items:center;padding:8px}#loading-validate-key-property{display:inline-block;width:50px;height:50px}#loading-validate-key-property:after{content:\" \";display:block;width:38px;height:38px;margin:1px;border-radius:50%;border:5px solid #5fb2ff;border-color:#5fb2ff transparent #5fb2ff transparent;animation:loading-spinner 1.4s linear infinite}#deep-chat-openai-realtime-container{height:100%;width:100%}#deep-chat-openai-realtime-avatar-container{height:60%;width:100%;display:flex;justify-content:center;align-items:center}#deep-chat-openai-realtime-avatar{border-radius:50%;height:110px;border:1px solid rgb(215,215,215);padding:8px;-webkit-user-select:none;user-select:none;margin-top:20px}#deep-chat-openai-realtime-buttons-container{height:40%;display:flex;position:relative}.deep-chat-openai-realtime-button-container{height:100%;width:50%;display:flex;justify-content:center;align-items:center}.deep-chat-openai-realtime-button{width:70px;height:70px;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer}.deep-chat-openai-realtime-button-default{background-color:#e3e3e3}.deep-chat-openai-realtime-button-default:hover{background-color:#d4d4d4}.deep-chat-openai-realtime-button-default:active{background-color:#c5c5c5}.deep-chat-openai-realtime-button-loading{opacity:.7;pointer-events:none}.deep-chat-openai-realtime-microphone-active{background-color:#ffe7e7}.deep-chat-openai-realtime-microphone-active:hover{background-color:#ffdede}.deep-chat-openai-realtime-microphone-active:active{background-color:#ffd2d2}.deep-chat-openai-realtime-microphone>*{height:30px;width:30px}.deep-chat-openai-realtime-microphone-active>*{filter:brightness(0) saturate(100%) invert(35%) sepia(60%) saturate(1360%) hue-rotate(325deg) brightness(95%) contrast(92%)}.deep-chat-openai-realtime-toggle>*{height:32px;width:32px;padding-inline-start:3px;filter:brightness(0) saturate(100%) invert(22%) sepia(0%) saturate(4537%) hue-rotate(208deg) brightness(105%) contrast(91%)}.deep-chat-openai-realtime-button-unavailable{opacity:.45;pointer-events:none}#deep-chat-openai-realtime-error{color:red;position:absolute;top:calc(50% + 40px);inset-inline-start:50%;transform:translate(-50%,-50%);font-size:17px}#deep-chat-openai-realtime-loading{position:absolute;font-size:15px;top:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}#insert-key-view{height:100%;position:relative}#insert-key-contents{text-align:center;position:absolute;inset-block-start:44%;inset-inline-start:50%;transform:translate(-50%,-50%);width:82%;display:flex;max-width:700px}#insert-key-title{margin-bottom:15px}#insert-key-input-container{margin-inline-end:2.7em;width:calc(100% - 80px)}#insert-key-input{padding:.3em 1.7em .3em .3em;border-width:1px;border-style:solid;border-radius:3px;width:100%;font-size:inherit}.insert-key-input-valid{border-color:gray}.insert-key-input-invalid{border-color:red}#visibility-icon-container{position:relative;float:inline-end;cursor:pointer;-webkit-user-select:none;user-select:none}.visibility-icon{filter:brightness(0) saturate(100%) invert(63%) sepia(1%) saturate(9%) hue-rotate(43deg) brightness(98%) contrast(92%);position:absolute;inset-inline-end:-1.7em;inset-block-start:-1.43em}#visible-icon{inset-block-start:-1.4em}.visibility-icon:hover{filter:unset}.visibility-icon>*{pointer-events:none}#start-button{border:1px solid grey;color:#454545;border-radius:4px;width:3em;display:flex;justify-content:center;align-items:center;cursor:pointer;padding:.28em .3em;-webkit-user-select:none;user-select:none;background-color:#fff}#start-button:hover{background-color:#f2f2f2}#start-button:active{background-color:#d2d2d2}#insert-key-help-text-container{width:100%;position:absolute;margin-top:32px;margin-bottom:20px}#insert-key-help-text-contents{width:100%;position:absolute}#insert-key-input-invalid-text{display:block;margin-top:1em;margin-bottom:.5em;color:red}.insert-key-input-help-text{display:block;margin-top:16px}#loading-key{display:inline-block;width:16px;height:16px}#loading-key:after{content:\" \";display:block;width:11px;height:11px;margin:1px;border-radius:50%;border:2px solid #0084ff;border-color:#0084ff transparent #0084ff transparent;animation:loading-spinner 1.2s linear infinite}#error-view{color:red;font-size:1.2em;line-height:1.3em;margin-top:-5px;text-align:center;height:100%;display:flex;justify-content:center;align-items:center;padding-inline:8px}@keyframes loading-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.intro-panel{position:absolute;display:flex;justify-content:center;right:0;bottom:0;left:0;margin:auto;height:fit-content;top:-2.5em}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!\n Theme: a11y-dark\n Author: @ericwbailey\n Maintainer: @ericwbailey\n\n Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css\n*/.hljs{background:#2b2b2b;color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast:active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}#messages,.deep-chat-upwards-mode #messages>div{overflow:auto;overflow-anchor:none}.deep-chat-upwards-mode #messages{height:100%;display:flex;flex-direction:column;justify-content:flex-end}.outer-message-container:last-child{margin-bottom:5px}.inner-message-container{display:flex;margin-inline:auto;width:calc(97.5% - 24px);max-width:100%}.message-bubble{margin-top:10px;word-wrap:break-word;width:fit-content;max-width:60%;border-radius:10px;padding:.42em .55em;height:fit-content;line-height:1.26em}.user-message-text{color:#fff;background-color:#0084ff;margin-inline-end:0px;margin-inline-start:auto}.ai-message-text{color:#000;background-color:#e4e6eb;margin-inline-start:0px;margin-inline-end:auto}.deep-chat-last-group-messages-active{height:100%}#scroll-button{position:absolute;top:75%;left:50%;right:50%;transform:translate(-50%,-50%);transition:opacity .1s ease;display:flex;opacity:0;padding:8px;background-color:#fff;border:.5px solid #000000;justify-content:center;align-items:center;white-space:nowrap;cursor:pointer}#scroll-button:hover{background-color:#fafafa}.loading-history-message-full-view{position:absolute;height:70%;width:100%;display:flex;align-items:center}.deep-chat-upwards-mode #messages .loading-history-message-full-view{height:100%}.loading-history-message-small{height:20px;margin-bottom:30px}.loading-history-message-small>div>div{scale:.6}.loading-history-message{margin-top:0;width:100%;max-width:100%;display:flex;justify-content:center;background-color:unset}.loading-history{width:70px}.loading-history div{position:absolute;width:var(--loading-history-width);height:var(--loading-history-height);margin:var(--loading-history-margin);border:var(--loading-history-border);border-radius:50%;animation:loading-spinner 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:var(--loading-history-color) transparent transparent transparent}.loading-history div:nth-child(1){animation-delay:-.45s}.loading-history div:nth-child(2){animation-delay:-.3s}.loading-history div:nth-child(3){animation-delay:-.15s}.html-message{max-width:unset}.error-message-text{margin-inline:auto;background-color:#f4c0c0;color:#474747;text-align:center;max-width:95%;margin-top:14px;margin-bottom:10px}.deep-chat-loading-message-dots-container{width:1em;padding-top:.6em;padding-bottom:.6em;padding-inline-start:1.3em;padding-inline-end:.75em}.loading-message-dots{position:relative;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite linear alternate;animation-delay:.5s}.loading-message-dots:before,.loading-message-dots:after{content:\"\";display:inline-block;position:absolute;top:0}.loading-message-dots:before{inset-inline-start:-.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:0s}.loading-message-dots:after{inset-inline-start:.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:1s}@keyframes loading-message-dots{0%{background-color:var(--loading-message-color)}50%,to{background-color:var(--loading-message-color-fade)}}.message-bubble>p:first-child,.message-bubble>.partial-render-message>p:first-child,.html-wrapper>p:first-child{margin-top:0}.message-bubble>p:last-child,.message-bubble>.partial-render-message:last-child>p,.html-wrapper>p:last-child{margin-bottom:0}pre{overflow:auto;display:block;word-break:break-all;word-wrap:break-word;border-radius:7px;background:#2b2b2b;color:#f8f8f2;margin-top:.8em;margin-bottom:.8em;padding:.6em;font-size:.9em;line-height:1.5em}.image-message{padding:0;display:flex;background-color:#ddd}.image-message>*,.image-message>*>*{width:100%;border-radius:8px;display:flex}.audio-message{width:60%;max-width:300px;height:2.2em;max-height:54px;padding:0;background-color:unset}.audio-player{width:100%;height:100%}.audio-player-safari{height:fit-content;width:40px}.audio-player-safari-start{float:inline-start}.audio-player-safari-end{float:inline-end}.any-file-message{padding:1px}.any-file-message-contents{display:flex}.any-file-message-icon-container{width:1.3em;min-width:1.3em;position:relative;border-radius:4px;margin-inline-start:6px;margin-inline-end:2px}.any-file-message-icon{background-color:#fff;border-radius:4px;position:absolute;width:1em;height:1.25em;padding:1px;margin-top:auto;margin-bottom:auto;top:0;bottom:0}.any-file-message-text{padding-top:5px;overflow-wrap:anywhere;padding-bottom:5px;padding-inline-end:7px}.message-bubble>a{color:inherit}.start-item-position{margin-inline-end:10px}.end-item-position{margin-inline-start:10px}.role-hidden{display:none}.avatar{padding-top:5px;width:1.5em;height:1.5em;border-radius:1px}.avatar-container{margin-top:9px}.name{margin-top:16px;font-size:15px}#drag-and-drop{position:absolute;display:none;z-index:10;height:calc(100% - 10px);width:calc(100% - 10px);background-color:#70c6ff4d;border:5px dashed #6dafff}#file-attachment-container{position:absolute;height:3.6em;width:calc(80% - 4px);top:-2.5em;border-radius:5px;overflow:auto;text-align:start;background-color:#d7d7d73b;padding-inline-start:4px}.file-attachment{width:2.85em;height:2.85em;display:inline-flex;margin-inline-end:.6em;margin-bottom:.44em;margin-top:4px;position:relative;background-color:#fff;border-radius:5px}.image-attachment{width:100%;height:100%;object-fit:cover;border-radius:5px}.border-bound-attachment{width:calc(100% - 2px);height:calc(100% - 2px);border:1px solid #c3c3c3;border-radius:5px;overflow:hidden}.border-bound-attachment-safari{width:calc(100% - 1px);height:calc(100% - 1px)}.audio-attachment-icon-container{cursor:pointer}.audio-attachment-icon-container:hover{background-color:#f8f8f8}.attachment-icon{inset-inline:0;bottom:0;top:2px;margin:auto;position:absolute;width:25px;-webkit-user-select:none;user-select:none}.not-removable-attachment-icon{top:0;right:0;bottom:0;left:0}.play-icon{filter:brightness(0) saturate(100%) invert(17%) sepia(0%) saturate(1392%) hue-rotate(67deg) brightness(98%) contrast(97%)}.stop-icon{filter:brightness(0) saturate(100%) invert(29%) sepia(90%) saturate(1228%) hue-rotate(198deg) brightness(93%) contrast(98%)}.audio-placeholder-text-3-digits{padding-inline-start:.26rem}.audio-placeholder-text-4-digits{padding-inline-start:.1rem}.any-file-attachment{padding:2px 0}.file-attachment-text-container{position:absolute;width:inherit;display:flex;align-items:center;height:100%;top:-1px}.audio-placeholder-text-3-digits-container{padding-top:1px;cursor:default}.any-file-attachment-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding-inline-start:.13em;margin-inline:auto}.remove-file-attachment-button{height:1.25em;width:1.25em;border:1px solid #cfcfcf;border-radius:25px;background-color:#fff;top:-4px;inset-inline-end:-5px;position:absolute;display:flex;justify-content:center;cursor:pointer;-webkit-user-select:none;user-select:none}.remove-file-attachment-button:hover{background-color:#e4e4e4}.remove-file-attachment-button:active{background-color:#d7d7d7}.x-icon{color:#4e4e4e;top:-.075em;position:relative;font-size:1.05em}.modal{display:none;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:80%;max-width:420px;max-height:80%;margin:auto;top:0;right:0;bottom:0;left:0;z-index:3}.modal-content{border-top:1px solid rgb(217,217,217);border-inline:1px solid rgb(217,217,217);border-start-start-radius:inherit;border-start-end-radius:inherit;background-color:#fff;overflow-y:auto;height:fit-content;max-height:calc(100% - 3.3em);width:100%}.modal-content>p{margin-inline:1em}.modal-content>ul{margin-inline-end:1em}.modal-button-panel{height:3.3em;border:1px solid;border-color:rgb(223,223,223) rgb(217,217,217) rgb(217,217,217);border-end-start-radius:inherit;border-end-end-radius:inherit;background-color:#fff;text-align:center;justify-content:center;display:flex;width:100%}.modal-button{min-width:2.5em;text-align:center;color:#fff;border-radius:5px;padding:.4em .4em .3em;height:1.25em;background-color:#3279b2;inset-block:0;margin-top:auto;margin-bottom:auto;cursor:pointer;-webkit-user-select:none;user-select:none;margin-inline:.31em}.modal-button:hover{background-color:#276da7}.modal-button:active{background-color:#1b5687}.modal-svg-button{padding:0 0 2px;width:2em;height:1.8em}.modal-svg-button-icon{width:100%;height:100%;filter:brightness(0) saturate(100%) invert(100%) sepia(15%) saturate(4%) hue-rotate(346deg) brightness(101%) contrast(102%)}#modal-background-panel{position:absolute;width:100%;height:100%;background-color:#00000042;z-index:2;display:none}.show-modal-background{animation:fadeInBackground .3s ease-in-out}@keyframes fadeInBackground{0%{opacity:0}to{opacity:1}}.show-modal{animation:fadeInModal .3s ease-in-out}@keyframes fadeInModal{0%{opacity:0;scale:.95}to{opacity:1;scale:1}}.hide-modal-background{animation:fadeOutBackground .2s ease-in-out}@keyframes fadeOutBackground{0%{opacity:1}to{opacity:0}}.hide-modal{animation:fadeOutModal .2s ease-in-out}@keyframes fadeOutModal{0%{opacity:1;scale:1}to{opacity:0;scale:.95}}.modal-camera-content{overflow:hidden;text-align:center;border:unset;height:100%;background-color:#2a2a2a;display:flex;justify-content:center}.camera-modal-canvas{max-width:100%;max-height:100%;margin-top:auto;margin-bottom:auto}.modal-svg-submit-button{background-color:green}.modal-svg-submit-button:hover{background-color:#007500}.modal-svg-submit-button:active{background-color:#006500}.modal-svg-submit-disabled{pointer-events:none;background-color:#747474}.modal-svg-close-button{height:1.56em;padding-top:.37em;padding-bottom:0;background-color:#c13e3e}.modal-svg-close-button:hover{background-color:#b43434}.modal-svg-close-button:active{background-color:#972929}.modal-svg-close-icon{width:80%;height:80%}.modal-svg-camera-button{height:1.6em;padding-top:.38em;padding-bottom:0}.modal-svg-camera-icon{height:76%}.modal-svg-refresh-icon{height:105%}.modal-svg-refresh-button{height:1.66em;padding-top:.11em;padding-bottom:.21em}.input-button-container{position:relative;z-index:1}.inside-end{position:absolute;inset-inline-end:calc(10% + .35em);inset-block-end:.85em}.inside-start{position:absolute;inset-inline-start:calc(10% + .35em);inset-block-end:.85em}.outside-start{position:absolute;inset-inline-end:calc(11px - .55em);inset-block-end:.88em}.outside-end{position:absolute;inset-inline-start:calc(11px - .55em);inset-block-end:.88em}#upload-images-icon{position:absolute;pointer-events:none;width:1.45em;height:1.45em;inset-inline-start:.11em;inset-block-end:.08em;filter:brightness(0) saturate(100%) invert(43%) sepia(0%) saturate(740%) hue-rotate(77deg) brightness(99%) contrast(92%)}#upload-gifs-icon{position:absolute;pointer-events:none;width:1.5em;height:1.48em;inset-inline-start:.07em;inset-block-end:.08em;filter:brightness(0) saturate(100%) invert(49%) sepia(0%) saturate(2586%) hue-rotate(12deg) brightness(93%) contrast(90%)}#upload-audio-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.17em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%);transform:scaleX(.95)}#camera-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.23em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(52%) sepia(0%) saturate(161%) hue-rotate(164deg) brightness(91%) contrast(92%);transform:scaleX(.95)}#upload-mixed-files-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.25em;inset-block-end:.2em;filter:brightness(0) saturate(100%) invert(53%) sepia(0%) saturate(36%) hue-rotate(74deg) brightness(98%) contrast(93%);transform:scaleX(.95)}#interim-text{color:gray}#microphone-button{padding-top:.5px}.outer-button-container>#microphone-button{padding-bottom:1px}#microphone-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.25em;inset-block-end:.25em}.default-microphone-icon{filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%)}.active-microphone-icon{filter:brightness(0) saturate(100%) invert(10%) sepia(97%) saturate(7495%) hue-rotate(0deg) brightness(101%) contrast(107%);border-radius:10px}.command-microphone-icon{filter:brightness(0) saturate(100%) invert(42%) sepia(96%) saturate(1067%) hue-rotate(77deg) brightness(99%) contrast(102%)}.unsupported-microphone{display:none}#submit-icon{height:100%;filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%);width:1.21em}#stop-icon{background-color:#acacac;position:absolute;width:.95em;height:.95em;inset-inline-start:.35em;inset-block-end:.35em;border-radius:2px}.submit-button-enlarged{scale:1.1;margin-inline:.3em}.loading-submit-button{position:relative;inset-inline-start:calc(-9990px + .275em);width:.22em;height:.22em;border-radius:5px;background-color:#848484;color:#848484;box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484;animation:loading-submit-button 1.5s infinite linear;inset-block-end:-.75em}@keyframes loading-submit-button{0%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}16.667%{box-shadow:9990px -6px #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}33.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}50%{box-shadow:9990px 0 #848484,calc(9990px + .44em) -6px 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}66.667%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}83.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) -6px 0 0 #848484}to{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}}.tooltip{position:absolute;visibility:hidden;z-index:1;pointer-events:none;padding:5px;padding-inline:7px;background-color:#333;border-radius:5px;width:max-content}.tooltip-text{color:#fff;font-size:13px}.input-button{border-radius:4px;cursor:pointer;margin-bottom:.2em;-webkit-user-select:none;user-select:none}.input-button-svg{width:1.65em;height:1.65em}.input-button-svg-text{padding:1px;height:1.65em;display:flex}.input-button-svg-text>svg{padding:.22rem}.input-button-svg-text>div{margin-inline-start:2px}.input-button:hover,.input-button:focus-visible{background-color:#9c9c9c2e}.input-button:active{background-color:#9c9c9c5e}.input-button:active:not(:hover){background-color:transparent}.loading-button{cursor:auto}.loading-button:hover{background-color:unset}.text-button{filter:unset!important;display:flex;justify-content:center;align-items:center;margin-inline:4px;height:1.6em;width:max-content}#custom-icon{height:100%;width:1.2em}.custom-button-container-default{color:#505050}.custom-button-container-default>.dropup-menu-item-icon{color:unset}.custom-button-container-default>svg{filter:brightness(0) saturate(100%) invert(39%) sepia(1%) saturate(0%) hue-rotate(83deg) brightness(93%) contrast(90%)}.custom-button-container-default>.dropup-menu-item-icon>svg{position:absolute;inset-inline-start:.2em}.custom-button-container-active{background-color:#edf7ff;color:#0285ff}.custom-button-container-active:hover,.custom-button-container-active:focus-visible{background-color:#def0ff}.custom-button-container-active:active{background-color:#d2eaff}.custom-button-container-active>svg{filter:brightness(0) saturate(100%) invert(32%) sepia(34%) saturate(4196%) hue-rotate(196deg) brightness(107%) contrast(104%)}.custom-button-container-disabled{color:#aeaeae;cursor:auto}.custom-button-container-disabled>div{pointer-events:none}.custom-button-container-disabled:hover,.custom-button-container-disabled:focus-visible{background-color:transparent}.custom-button-container-disabled:active{background-color:transparent}.custom-button-container-disabled>svg{filter:brightness(0) saturate(100%) invert(67%) sepia(0%) saturate(818%) hue-rotate(28deg) brightness(102%) contrast(100%)}#text-input-container{background-color:#fff;width:80%;display:flex;border:1px solid #0000001a;border-radius:5px;margin-top:.8em;margin-bottom:.8em;box-shadow:#959da533 0 1px 12px;overflow-y:auto;max-height:200px;position:relative}.text-input-container-start-adjustment{margin-inline-start:1.5em}.text-input-container-end-adjustment{margin-inline-end:1.5em}.text-input-container-start-small-adjustment{margin-inline-start:1.1em}.text-input-container-start-small-adjustment>.outside-start{inset-inline-end:calc(14px - .55em)}.text-input-container-end-small-adjustment{margin-inline-end:1.1em}.text-input-container-end-small-adjustment>.outside-end{inset-inline-start:calc(14px - .55em)}#text-input{text-align:start;outline:none;word-wrap:break-word;line-break:auto}.text-input-styling{padding:.4em .5em;overflow:overlay;width:100%}.text-input-inner-start-adjustment{padding-inline-start:2.2em}.text-input-inner-end-adjustment{padding-inline-end:2em}.text-input-disabled{pointer-events:none;-webkit-user-select:none;user-select:none}[contenteditable]:empty:before{content:attr(deep-chat-placeholder-text);pointer-events:none}[contenteditable][textcolor]:empty:before{color:gray}.outside-end>#dropup-menu,.inside-end>#dropup-menu{inset-inline-end:0px}#dropup-icon{position:absolute;pointer-events:none;width:1.16em;height:1.2em;inset-inline-start:.265em;bottom:.43em;filter:brightness(0) saturate(100%) invert(54%) sepia(0%) saturate(724%) hue-rotate(6deg) brightness(92%) contrast(90%)}.dropup-button>*{pointer-events:none}#dropup-menu{background-color:#fff;position:absolute;transform:translateY(-100%);border-radius:5px;z-index:1;top:-.49em;box-shadow:#0003 -1px 2px 10px,#0000001a 0 2px 4px;cursor:pointer;-webkit-user-select:none;user-select:none}.dropup-menu-item{height:1.4em;padding-inline-start:.35em;padding-inline-end:.84em;padding-top:.28em;padding-bottom:.28em;display:flex;position:relative}.dropup-menu-item:hover,.dropup-menu-item:focus-visible{background-color:#f3f3f3}.dropup-menu-item:active{background-color:#ebebeb}.dropup-menu-item:active:not(:hover){background-color:transparent}.dropup-menu-item:first-child{padding-top:.49em;border-start-start-radius:inherit;border-start-end-radius:inherit}.dropup-menu-item:last-child{padding-bottom:.45em;border-end-start-radius:inherit;border-end-end-radius:inherit}.dropup-menu-item-icon{width:1.39em;position:relative}.dropup-menu-item-icon>svg{bottom:0!important;top:0!important;margin-bottom:auto;margin-top:auto}#dropup-menu-item-icon-element-custom{position:absolute;pointer-events:none;width:1.21em;height:1.21em;inset-inline-start:.28em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%)}.dropup-menu-item-text{margin-inline-start:.56em;margin-top:.08em;width:max-content}#input{width:100%;display:inline-flex;text-align:center;margin-inline:auto;margin-top:auto;position:relative;justify-content:center}#chat-view{height:100%;grid-template-columns:100%}.deep-chat-downwards-mode{display:grid}.deep-chat-upwards-mode{display:flex;flex-direction:column}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background-color:#d0d0d0;border-radius:5px}::-webkit-scrollbar-track{background-color:#f2f2f2}.deep-chat-web-model-button{margin-top:10px;margin-bottom:5px;margin-inline-start:1px}:host{all:initial;display:table-cell}#container{height:inherit;width:inherit;overflow:hidden}";var vh=Object.defineProperty,O=function O(r,e,t,n){for(var s=void 0,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=o(e,t,s)||s);return s&&vh(e,t,s),s;};var I=/*#__PURE__*/function(_xi){function I(){var _this127;_classCallCheck(this,I);var e;_this127=_callSuper(this,I),_this127.getMessages=function(){return[];},_this127.submitUserMessage=function(){return console.warn(vr("submitUserMessage"));},_this127.addMessage=function(){return console.warn(vr("addMessage"));},_this127.updateMessage=function(){},_this127.clearMessages=function(){},_this127.focusInput=function(){return Wt.focusFromParentElement(_this127._elementRef);},_this127.refreshMessages=function(){},_this127.scrollToBottom=function(){},_this127.disableSubmitButton=function(){},_this127.setPlaceholderText=function(){},_this127._hasBeenRendered=!1,_this127._auxiliaryStyleApplied=!1,_this127._elementRef=S(),_this127._elementRef.id="container",_this127.attachShadow({mode:"open"}).appendChild(_this127._elementRef),(e=_this127.shadowRoot)==null||e.appendChild(nt.buildElement()),Wn.apply(bh,_this127.shadowRoot),setTimeout(function(){_this127._hasBeenRendered||_this127.onRender();},20);return _this127;}_inherits(I,_xi);return _createClass(I,[{key:"changeToChatView",value:function changeToChatView(){this._activeService&&(this._activeService.validateKeyProperty=!1),this.onRender();}// prettier-ignore
281
+ },{key:"onRender",value:function onRender(){var _this$_childElement;Rs.attemptAppendStyleSheetToHead(this.style),ne.processConnect(this),(!this._activeService||this._activeService.demo)&&(this._activeService=Pd.create(this)),this.auxiliaryStyle&&!this._auxiliaryStyleApplied&&(Wn.apply(this.auxiliaryStyle,this.shadowRoot),this._auxiliaryStyleApplied=!0),Wn.applyDefaultStyleToComponent(this.style,this.chatStyle),ne.checkForContainerStyles(this,this._elementRef),this._activeService.key&&this._activeService.validateKeyProperty?ws.render(this._elementRef,this.changeToChatView.bind(this),this._activeService):!(this._activeService instanceof R)||this._activeService.key?((_this$_childElement=this._childElement)!==null&&_this$_childElement!==void 0?_this$_childElement:this._childElement=this.children[0],dr.render(this,this._elementRef,this._activeService,this._childElement)):this._activeService instanceof R&&Ce.render(this._elementRef,this.changeToChatView.bind(this),this._activeService),this._hasBeenRendered||Xt.onRender(this),this._hasBeenRendered=!0;}},{key:"disconnectedCallback",value:function disconnectedCallback(){ds.chat=void 0;}}]);}(xi);O([k("object")],I.prototype,"connect");O([k("object")],I.prototype,"directConnection");O([k("object")],I.prototype,"webModel");O([k("object")],I.prototype,"requestBodyLimits");O([k("function")],I.prototype,"requestInterceptor");O([k("function")],I.prototype,"responseInterceptor");O([k("function")],I.prototype,"validateInput");O([k("function")],I.prototype,"loadHistory");O([k("object")],I.prototype,"chatStyle");O([k("object")],I.prototype,"attachmentContainerStyle");O([k("object")],I.prototype,"dropupStyles");O([k("object")],I.prototype,"inputAreaStyle");O([k("object")],I.prototype,"textInput");O([k("object")],I.prototype,"defaultInput");O([k("object")],I.prototype,"submitButtonStyles");O([k("object")],I.prototype,"customButtons");O([k("string")],I.prototype,"auxiliaryStyle");O([k("array")],I.prototype,"history");O([k("object")],I.prototype,"browserStorage");O([k("object")],I.prototype,"introMessage");O([k("object")],I.prototype,"avatars");O([k("object")],I.prototype,"names");O([k("object")],I.prototype,"displayLoadingBubble");O([k("object")],I.prototype,"errorMessages");O([k("object")],I.prototype,"messageStyles");O([k("object")],I.prototype,"textToSpeech");O([k("object")],I.prototype,"speechToText");O([k("object")],I.prototype,"images");O([k("object")],I.prototype,"gifs");O([k("object")],I.prototype,"camera");O([k("object")],I.prototype,"audio");O([k("object")],I.prototype,"microphone");O([k("object")],I.prototype,"mixedFiles");O([k("object")],I.prototype,"dragAndDrop");O([k("object")],I.prototype,"htmlWrappers");O([k("object")],I.prototype,"htmlClassUtilities");O([k("object")],I.prototype,"remarkable");O([k("object")],I.prototype,"focusMode");O([k("boolean")],I.prototype,"upwardsMode");O([k("object")],I.prototype,"scrollButton");O([k("object")],I.prototype,"hiddenMessages");O([k("number")],I.prototype,"maxVisibleMessages");O([k("function")],I.prototype,"onMessage");O([k("function")],I.prototype,"onClearMessages");O([k("function")],I.prototype,"onComponentRender");O([k("function")],I.prototype,"onInput");O([k("function")],I.prototype,"onError");O([k("object")],I.prototype,"demo");O([k("object")],I.prototype,"_insertKeyViewStyles");customElements.define("deep-chat",I);export{I as DeepChat};